summaryrefslogtreecommitdiff
path: root/deps/v8/src/snapshot
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2017-03-21 10:16:54 +0100
committerMichaël Zasso <targos@protonmail.com>2017-03-25 09:44:10 +0100
commitc459d8ea5d402c702948c860d9497b2230ff7e8a (patch)
tree56c282fc4d40e5cb613b47cf7be3ea0526ed5b6f /deps/v8/src/snapshot
parente0bc5a7361b1d29c3ed034155fd779ce6f44fb13 (diff)
downloadandroid-node-v8-c459d8ea5d402c702948c860d9497b2230ff7e8a.tar.gz
android-node-v8-c459d8ea5d402c702948c860d9497b2230ff7e8a.tar.bz2
android-node-v8-c459d8ea5d402c702948c860d9497b2230ff7e8a.zip
deps: update V8 to 5.7.492.69
PR-URL: https://github.com/nodejs/node/pull/11752 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Diffstat (limited to 'deps/v8/src/snapshot')
-rw-r--r--deps/v8/src/snapshot/code-serializer.cc27
-rw-r--r--deps/v8/src/snapshot/deserializer.cc22
-rw-r--r--deps/v8/src/snapshot/deserializer.h9
-rw-r--r--deps/v8/src/snapshot/partial-serializer.cc12
-rw-r--r--deps/v8/src/snapshot/partial-serializer.h2
-rw-r--r--deps/v8/src/snapshot/serializer-common.cc12
-rw-r--r--deps/v8/src/snapshot/serializer-common.h2
-rw-r--r--deps/v8/src/snapshot/snapshot-common.cc8
-rw-r--r--deps/v8/src/snapshot/snapshot-source-sink.cc2
-rw-r--r--deps/v8/src/snapshot/snapshot.h3
-rw-r--r--deps/v8/src/snapshot/startup-serializer.cc13
-rw-r--r--deps/v8/src/snapshot/startup-serializer.h1
12 files changed, 81 insertions, 32 deletions
diff --git a/deps/v8/src/snapshot/code-serializer.cc b/deps/v8/src/snapshot/code-serializer.cc
index 86a91643d2..1776cf1e4f 100644
--- a/deps/v8/src/snapshot/code-serializer.cc
+++ b/deps/v8/src/snapshot/code-serializer.cc
@@ -88,7 +88,12 @@ void CodeSerializer::SerializeObject(HeapObject* obj, HowToCode how_to_code,
#define IC_KIND_CASE(KIND) case Code::KIND:
IC_KIND_LIST(IC_KIND_CASE)
#undef IC_KIND_CASE
- SerializeCodeStub(code_object, how_to_code, where_to_point);
+ if (code_object->builtin_index() == -1) {
+ SerializeCodeStub(code_object, how_to_code, where_to_point);
+ } else {
+ SerializeBuiltin(code_object->builtin_index(), how_to_code,
+ where_to_point);
+ }
return;
case Code::FUNCTION:
DCHECK(code_object->has_reloc_info_for_serialization());
@@ -104,6 +109,12 @@ void CodeSerializer::SerializeObject(HeapObject* obj, HowToCode how_to_code,
return SerializeObject(isolate()->heap()->undefined_value(), how_to_code,
where_to_point, skip);
}
+
+ if (obj->IsScript()) {
+ // Wrapper object is a context-dependent JSValue. Reset it here.
+ Script::cast(obj)->set_wrapper(isolate()->heap()->undefined_value());
+ }
+
// Past this point we should not see any (context-specific) maps anymore.
CHECK(!obj->IsMap());
// There should be no references to the global object embedded.
@@ -225,16 +236,20 @@ std::unique_ptr<ScriptData> WasmCompiledModuleSerializer::SerializeWasmModule(
WasmCompiledModuleSerializer wasm_cs(isolate, 0);
wasm_cs.reference_map()->AddAttachedReference(*isolate->native_context());
wasm_cs.reference_map()->AddAttachedReference(
- *compiled_module->module_bytes());
+ compiled_module->module_bytes());
ScriptData* data = wasm_cs.Serialize(compiled_module);
return std::unique_ptr<ScriptData>(data);
}
MaybeHandle<FixedArray> WasmCompiledModuleSerializer::DeserializeWasmModule(
Isolate* isolate, ScriptData* data, Vector<const byte> wire_bytes) {
+ MaybeHandle<FixedArray> nothing;
+ if (!wasm::IsWasmCodegenAllowed(isolate, isolate->native_context())) {
+ return nothing;
+ }
SerializedCodeData::SanityCheckResult sanity_check_result =
SerializedCodeData::CHECK_SUCCESS;
- MaybeHandle<FixedArray> nothing;
+
const SerializedCodeData scd = SerializedCodeData::FromCachedData(
isolate, data, 0, &sanity_check_result);
@@ -262,10 +277,12 @@ MaybeHandle<FixedArray> WasmCompiledModuleSerializer::DeserializeWasmModule(
MaybeHandle<HeapObject> obj = deserializer.DeserializeObject(isolate);
if (obj.is_null() || !obj.ToHandleChecked()->IsFixedArray()) return nothing;
- Handle<WasmCompiledModule> compiled_module =
- Handle<WasmCompiledModule>::cast(obj.ToHandleChecked());
+ // Cast without type checks, as the module wrapper is not there yet.
+ Handle<WasmCompiledModule> compiled_module(
+ static_cast<WasmCompiledModule*>(*obj.ToHandleChecked()), isolate);
WasmCompiledModule::RecreateModuleWrapper(isolate, compiled_module);
+ DCHECK(WasmCompiledModule::IsWasmCompiledModule(*compiled_module));
return compiled_module;
}
diff --git a/deps/v8/src/snapshot/deserializer.cc b/deps/v8/src/snapshot/deserializer.cc
index aabd806b7a..87e430baf5 100644
--- a/deps/v8/src/snapshot/deserializer.cc
+++ b/deps/v8/src/snapshot/deserializer.cc
@@ -93,6 +93,7 @@ void Deserializer::Deserialize(Isolate* isolate) {
isolate_->heap()->IterateWeakRoots(this, VISIT_ALL);
DeserializeDeferredObjects();
FlushICacheForNewIsolate();
+ RestoreExternalReferenceRedirectors(&accessor_infos_);
}
isolate_->heap()->set_native_contexts_list(
@@ -111,7 +112,8 @@ void Deserializer::Deserialize(Isolate* isolate) {
}
MaybeHandle<Object> Deserializer::DeserializePartial(
- Isolate* isolate, Handle<JSGlobalProxy> global_proxy) {
+ Isolate* isolate, Handle<JSGlobalProxy> global_proxy,
+ v8::DeserializeInternalFieldsCallback internal_fields_deserializer) {
Initialize(isolate);
if (!ReserveSpace()) {
V8::FatalProcessOutOfMemory("deserialize context");
@@ -128,7 +130,7 @@ MaybeHandle<Object> Deserializer::DeserializePartial(
Object* root;
VisitPointer(&root);
DeserializeDeferredObjects();
- DeserializeInternalFields();
+ DeserializeInternalFields(internal_fields_deserializer);
isolate->heap()->RegisterReservationsForBlackAllocation(reservations_);
@@ -213,14 +215,13 @@ void Deserializer::DeserializeDeferredObjects() {
}
}
-void Deserializer::DeserializeInternalFields() {
+void Deserializer::DeserializeInternalFields(
+ v8::DeserializeInternalFieldsCallback internal_fields_deserializer) {
if (!source_.HasMore() || source_.Get() != kInternalFieldsData) return;
DisallowHeapAllocation no_gc;
DisallowJavascriptExecution no_js(isolate_);
DisallowCompilation no_compile(isolate_);
- v8::DeserializeInternalFieldsCallback callback =
- isolate_->deserialize_internal_fields_callback();
- DCHECK_NOT_NULL(callback);
+ DCHECK_NOT_NULL(internal_fields_deserializer.callback);
for (int code = source_.Get(); code != kSynchronize; code = source_.Get()) {
HandleScope scope(isolate_);
int space = code & kSpaceMask;
@@ -232,8 +233,9 @@ void Deserializer::DeserializeInternalFields() {
int size = source_.GetInt();
byte* data = new byte[size];
source_.CopyRaw(data, size);
- callback(v8::Utils::ToLocal(obj), index,
- {reinterpret_cast<char*>(data), size});
+ internal_fields_deserializer.callback(v8::Utils::ToLocal(obj), index,
+ {reinterpret_cast<char*>(data), size},
+ internal_fields_deserializer.data);
delete[] data;
}
}
@@ -316,6 +318,10 @@ HeapObject* Deserializer::PostProcessNewObject(HeapObject* obj, int space) {
if (deserializing_user_code() || space == LO_SPACE) {
new_code_objects_.Add(Code::cast(obj));
}
+ } else if (obj->IsAccessorInfo()) {
+ if (isolate_->external_reference_redirector()) {
+ accessor_infos_.Add(AccessorInfo::cast(obj));
+ }
}
// Check alignment.
DCHECK_EQ(0, Heap::GetFillToAlign(obj->address(), obj->RequiredAlignment()));
diff --git a/deps/v8/src/snapshot/deserializer.h b/deps/v8/src/snapshot/deserializer.h
index db7996297d..7b1ced8159 100644
--- a/deps/v8/src/snapshot/deserializer.h
+++ b/deps/v8/src/snapshot/deserializer.h
@@ -48,8 +48,9 @@ class Deserializer : public SerializerDeserializer {
void Deserialize(Isolate* isolate);
// Deserialize a single object and the objects reachable from it.
- MaybeHandle<Object> DeserializePartial(Isolate* isolate,
- Handle<JSGlobalProxy> global_proxy);
+ MaybeHandle<Object> DeserializePartial(
+ Isolate* isolate, Handle<JSGlobalProxy> global_proxy,
+ v8::DeserializeInternalFieldsCallback internal_fields_deserializer);
// Deserialize an object graph. Fail gracefully.
MaybeHandle<HeapObject> DeserializeObject(Isolate* isolate);
@@ -88,7 +89,8 @@ class Deserializer : public SerializerDeserializer {
}
void DeserializeDeferredObjects();
- void DeserializeInternalFields();
+ void DeserializeInternalFields(
+ v8::DeserializeInternalFieldsCallback internal_fields_deserializer);
void FlushICacheForNewIsolate();
void FlushICacheForNewCodeObjectsAndRecordEmbeddedObjects();
@@ -138,6 +140,7 @@ class Deserializer : public SerializerDeserializer {
List<HeapObject*> deserialized_large_objects_;
List<Code*> new_code_objects_;
+ List<AccessorInfo*> accessor_infos_;
List<Handle<String> > new_internalized_strings_;
List<Handle<Script> > new_scripts_;
diff --git a/deps/v8/src/snapshot/partial-serializer.cc b/deps/v8/src/snapshot/partial-serializer.cc
index e89f44f6e2..b78a1edbd0 100644
--- a/deps/v8/src/snapshot/partial-serializer.cc
+++ b/deps/v8/src/snapshot/partial-serializer.cc
@@ -23,7 +23,7 @@ PartialSerializer::~PartialSerializer() {
OutputStatistics("PartialSerializer");
}
-void PartialSerializer::Serialize(Object** o) {
+void PartialSerializer::Serialize(Object** o, bool include_global_proxy) {
if ((*o)->IsContext()) {
Context* context = Context::cast(*o);
reference_map()->AddAttachedReference(context->global_proxy());
@@ -102,7 +102,10 @@ void PartialSerializer::SerializeObject(HeapObject* obj, HowToCode how_to_code,
if (obj->IsJSObject()) {
JSObject* jsobj = JSObject::cast(obj);
- if (jsobj->GetInternalFieldCount() > 0) internal_field_holders_.Add(jsobj);
+ if (jsobj->GetInternalFieldCount() > 0) {
+ DCHECK_NOT_NULL(serialize_internal_fields_.callback);
+ internal_field_holders_.Add(jsobj);
+ }
}
// Object has not yet been serialized. Serialize it here.
@@ -129,7 +132,7 @@ void PartialSerializer::SerializeInternalFields() {
DisallowHeapAllocation no_gc;
DisallowJavascriptExecution no_js(isolate());
DisallowCompilation no_compile(isolate());
- DCHECK_NOT_NULL(serialize_internal_fields_);
+ DCHECK_NOT_NULL(serialize_internal_fields_.callback);
sink_.Put(kInternalFieldsData, "internal fields data");
while (internal_field_holders_.length() > 0) {
HandleScope scope(isolate());
@@ -139,7 +142,8 @@ void PartialSerializer::SerializeInternalFields() {
int internal_fields_count = obj->GetInternalFieldCount();
for (int i = 0; i < internal_fields_count; i++) {
if (obj->GetInternalField(i)->IsHeapObject()) continue;
- StartupData data = serialize_internal_fields_(v8::Utils::ToLocal(obj), i);
+ StartupData data = serialize_internal_fields_.callback(
+ v8::Utils::ToLocal(obj), i, serialize_internal_fields_.data);
sink_.Put(kNewObject + reference.space(), "internal field holder");
PutBackReference(*obj, reference);
sink_.PutInt(i, "internal field index");
diff --git a/deps/v8/src/snapshot/partial-serializer.h b/deps/v8/src/snapshot/partial-serializer.h
index 45d64e431e..2d7c9ed415 100644
--- a/deps/v8/src/snapshot/partial-serializer.h
+++ b/deps/v8/src/snapshot/partial-serializer.h
@@ -21,7 +21,7 @@ class PartialSerializer : public Serializer {
~PartialSerializer() override;
// Serialize the objects reachable from a single object pointer.
- void Serialize(Object** o);
+ void Serialize(Object** o, bool include_global_proxy);
private:
void SerializeObject(HeapObject* o, HowToCode how_to_code,
diff --git a/deps/v8/src/snapshot/serializer-common.cc b/deps/v8/src/snapshot/serializer-common.cc
index f188793419..ca4db75239 100644
--- a/deps/v8/src/snapshot/serializer-common.cc
+++ b/deps/v8/src/snapshot/serializer-common.cc
@@ -21,8 +21,7 @@ ExternalReferenceEncoder::ExternalReferenceEncoder(Isolate* isolate) {
ExternalReferenceTable* table = ExternalReferenceTable::instance(isolate);
for (uint32_t i = 0; i < table->size(); ++i) {
Address addr = table->address(i);
- DCHECK(map_->Get(addr).IsNothing() ||
- strncmp(table->name(i), "Redirect to ", 12) == 0);
+ DCHECK(map_->Get(addr).IsNothing());
map_->Set(addr, i);
DCHECK(map_->Get(addr).IsJust());
}
@@ -81,5 +80,14 @@ bool SerializerDeserializer::CanBeDeferred(HeapObject* o) {
return !o->IsString() && !o->IsScript();
}
+void SerializerDeserializer::RestoreExternalReferenceRedirectors(
+ List<AccessorInfo*>* accessor_infos) {
+ // Restore wiped accessor infos.
+ for (AccessorInfo* info : *accessor_infos) {
+ Foreign::cast(info->js_getter())
+ ->set_foreign_address(info->redirected_getter());
+ }
+}
+
} // namespace internal
} // namespace v8
diff --git a/deps/v8/src/snapshot/serializer-common.h b/deps/v8/src/snapshot/serializer-common.h
index 201ac4e039..b426efd538 100644
--- a/deps/v8/src/snapshot/serializer-common.h
+++ b/deps/v8/src/snapshot/serializer-common.h
@@ -86,6 +86,8 @@ class SerializerDeserializer : public ObjectVisitor {
protected:
static bool CanBeDeferred(HeapObject* o);
+ void RestoreExternalReferenceRedirectors(List<AccessorInfo*>* accessor_infos);
+
// ---------- byte code range 0x00..0x7f ----------
// Byte codes in this range represent Where, HowToCode and WhereToPoint.
// Where the pointed-to object can be found:
diff --git a/deps/v8/src/snapshot/snapshot-common.cc b/deps/v8/src/snapshot/snapshot-common.cc
index 959ac56fa9..83ad2e7d39 100644
--- a/deps/v8/src/snapshot/snapshot-common.cc
+++ b/deps/v8/src/snapshot/snapshot-common.cc
@@ -50,8 +50,8 @@ bool Snapshot::Initialize(Isolate* isolate) {
}
MaybeHandle<Context> Snapshot::NewContextFromSnapshot(
- Isolate* isolate, Handle<JSGlobalProxy> global_proxy,
- size_t context_index) {
+ Isolate* isolate, Handle<JSGlobalProxy> global_proxy, size_t context_index,
+ v8::DeserializeInternalFieldsCallback internal_fields_deserializer) {
if (!isolate->snapshot_available()) return Handle<Context>();
base::ElapsedTimer timer;
if (FLAG_profile_deserialization) timer.Start();
@@ -62,8 +62,8 @@ MaybeHandle<Context> Snapshot::NewContextFromSnapshot(
SnapshotData snapshot_data(context_data);
Deserializer deserializer(&snapshot_data);
- MaybeHandle<Object> maybe_context =
- deserializer.DeserializePartial(isolate, global_proxy);
+ MaybeHandle<Object> maybe_context = deserializer.DeserializePartial(
+ isolate, global_proxy, internal_fields_deserializer);
Handle<Object> result;
if (!maybe_context.ToHandle(&result)) return MaybeHandle<Context>();
CHECK(result->IsContext());
diff --git a/deps/v8/src/snapshot/snapshot-source-sink.cc b/deps/v8/src/snapshot/snapshot-source-sink.cc
index cee5875310..66a14bc599 100644
--- a/deps/v8/src/snapshot/snapshot-source-sink.cc
+++ b/deps/v8/src/snapshot/snapshot-source-sink.cc
@@ -7,7 +7,7 @@
#include "src/base/logging.h"
#include "src/handles-inl.h"
-
+#include "src/objects-inl.h"
namespace v8 {
namespace internal {
diff --git a/deps/v8/src/snapshot/snapshot.h b/deps/v8/src/snapshot/snapshot.h
index 49a60926dc..010072a694 100644
--- a/deps/v8/src/snapshot/snapshot.h
+++ b/deps/v8/src/snapshot/snapshot.h
@@ -59,7 +59,8 @@ class Snapshot : public AllStatic {
// Create a new context using the internal partial snapshot.
static MaybeHandle<Context> NewContextFromSnapshot(
Isolate* isolate, Handle<JSGlobalProxy> global_proxy,
- size_t context_index);
+ size_t context_index,
+ v8::DeserializeInternalFieldsCallback internal_fields_deserializer);
static bool HaveASnapshotToStartFrom(Isolate* isolate);
diff --git a/deps/v8/src/snapshot/startup-serializer.cc b/deps/v8/src/snapshot/startup-serializer.cc
index 80598e80bd..4b27746f8e 100644
--- a/deps/v8/src/snapshot/startup-serializer.cc
+++ b/deps/v8/src/snapshot/startup-serializer.cc
@@ -21,6 +21,7 @@ StartupSerializer::StartupSerializer(
}
StartupSerializer::~StartupSerializer() {
+ RestoreExternalReferenceRedirectors(&accessor_infos_);
OutputStatistics("StartupSerializer");
}
@@ -66,6 +67,14 @@ void StartupSerializer::SerializeObject(HeapObject* obj, HowToCode how_to_code,
FlushSkip(skip);
+ if (isolate_->external_reference_redirector() && obj->IsAccessorInfo()) {
+ // Wipe external reference redirects in the accessor info.
+ AccessorInfo* info = AccessorInfo::cast(obj);
+ Address original_address = Foreign::cast(info->getter())->foreign_address();
+ Foreign::cast(info->js_getter())->set_foreign_address(original_address);
+ accessor_infos_.Add(info);
+ }
+
// Object has not yet been serialized. Serialize it here.
ObjectSerializer object_serializer(this, obj, &sink_, how_to_code,
where_to_point);
@@ -116,10 +125,8 @@ void StartupSerializer::SerializeStrongReferences() {
CHECK_NULL(isolate->thread_manager()->FirstThreadStateInUse());
// No active or weak handles.
CHECK(isolate->handle_scope_implementer()->blocks()->is_empty());
- CHECK_EQ(0, isolate->global_handles()->NumberOfWeakHandles());
+ CHECK_EQ(0, isolate->global_handles()->global_handles_count());
CHECK_EQ(0, isolate->eternal_handles()->NumberOfHandles());
- // We don't support serializing installed extensions.
- CHECK(!isolate->has_installed_extensions());
// First visit immortal immovables to make sure they end up in the first page.
serializing_immortal_immovables_roots_ = true;
isolate->heap()->IterateStrongRoots(this, VISIT_ONLY_STRONG_ROOT_LIST);
diff --git a/deps/v8/src/snapshot/startup-serializer.h b/deps/v8/src/snapshot/startup-serializer.h
index ac75c5d163..4a597e6a32 100644
--- a/deps/v8/src/snapshot/startup-serializer.h
+++ b/deps/v8/src/snapshot/startup-serializer.h
@@ -73,6 +73,7 @@ class StartupSerializer : public Serializer {
bool serializing_immortal_immovables_roots_;
std::bitset<Heap::kStrongRootListLength> root_has_been_serialized_;
PartialCacheIndexMap partial_cache_index_map_;
+ List<AccessorInfo*> accessor_infos_;
DISALLOW_COPY_AND_ASSIGN(StartupSerializer);
};