diff options
Diffstat (limited to 'deps/v8/src/snapshot')
-rw-r--r-- | deps/v8/src/snapshot/code-serializer.cc | 3 | ||||
-rw-r--r-- | deps/v8/src/snapshot/context-deserializer.cc | 4 | ||||
-rw-r--r-- | deps/v8/src/snapshot/deserializer.cc | 3 | ||||
-rw-r--r-- | deps/v8/src/snapshot/embedded/embedded-data.cc | 21 | ||||
-rw-r--r-- | deps/v8/src/snapshot/embedded/embedded-data.h | 8 | ||||
-rw-r--r-- | deps/v8/src/snapshot/mksnapshot.cc | 4 | ||||
-rw-r--r-- | deps/v8/src/snapshot/object-deserializer.cc | 4 | ||||
-rw-r--r-- | deps/v8/src/snapshot/read-only-serializer.cc | 17 | ||||
-rw-r--r-- | deps/v8/src/snapshot/read-only-serializer.h | 2 | ||||
-rw-r--r-- | deps/v8/src/snapshot/serializer-deserializer.h | 9 | ||||
-rw-r--r-- | deps/v8/src/snapshot/serializer.cc | 2 | ||||
-rw-r--r-- | deps/v8/src/snapshot/serializer.h | 4 | ||||
-rw-r--r-- | deps/v8/src/snapshot/snapshot-utils.cc | 2 | ||||
-rw-r--r-- | deps/v8/src/snapshot/snapshot.cc | 26 | ||||
-rw-r--r-- | deps/v8/src/snapshot/snapshot.h | 9 |
15 files changed, 87 insertions, 31 deletions
diff --git a/deps/v8/src/snapshot/code-serializer.cc b/deps/v8/src/snapshot/code-serializer.cc index a4641baabf..3725b267f5 100644 --- a/deps/v8/src/snapshot/code-serializer.cc +++ b/deps/v8/src/snapshot/code-serializer.cc @@ -44,8 +44,7 @@ ScriptCompiler::CachedData* CodeSerializer::Serialize( Isolate* isolate = info->GetIsolate(); TRACE_EVENT_CALL_STATS_SCOPED(isolate, "v8", "V8.Execute"); HistogramTimerScope histogram_timer(isolate->counters()->compile_serialize()); - RuntimeCallTimerScope runtimeTimer(isolate, - RuntimeCallCounterId::kCompileSerialize); + RCS_SCOPE(isolate, RuntimeCallCounterId::kCompileSerialize); TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.CompileSerialize"); base::ElapsedTimer timer; diff --git a/deps/v8/src/snapshot/context-deserializer.cc b/deps/v8/src/snapshot/context-deserializer.cc index 04756b5ffe..ad109bacca 100644 --- a/deps/v8/src/snapshot/context-deserializer.cc +++ b/deps/v8/src/snapshot/context-deserializer.cc @@ -62,9 +62,11 @@ void ContextDeserializer::SetupOffHeapArrayBufferBackingStores() { uint32_t store_index = buffer->GetBackingStoreRefForDeserialization(); auto bs = backing_store(store_index); buffer->AllocateExternalPointerEntries(isolate()); + // TODO(v8:11111): Support RAB / GSAB. + CHECK(!buffer->is_resizable()); SharedFlag shared = bs && bs->is_shared() ? SharedFlag::kShared : SharedFlag::kNotShared; - buffer->Setup(shared, bs); + buffer->Setup(shared, ResizableFlag::kNotResizable, bs); } } diff --git a/deps/v8/src/snapshot/deserializer.cc b/deps/v8/src/snapshot/deserializer.cc index ecfa889f1e..7756580c83 100644 --- a/deps/v8/src/snapshot/deserializer.cc +++ b/deps/v8/src/snapshot/deserializer.cc @@ -464,6 +464,9 @@ void Deserializer::PostProcessNewObject(Handle<Map> map, Handle<HeapObject> obj, DCHECK(InstanceTypeChecker::IsStrongDescriptorArray(instance_type)); Handle<DescriptorArray> descriptors = Handle<DescriptorArray>::cast(obj); new_descriptor_arrays_.push_back(descriptors); + } else if (InstanceTypeChecker::IsNativeContext(instance_type)) { + Handle<NativeContext> context = Handle<NativeContext>::cast(obj); + context->AllocateExternalPointerEntries(isolate()); } // Check alignment. diff --git a/deps/v8/src/snapshot/embedded/embedded-data.cc b/deps/v8/src/snapshot/embedded/embedded-data.cc index 2a0549cfbb..fb3883a410 100644 --- a/deps/v8/src/snapshot/embedded/embedded-data.cc +++ b/deps/v8/src/snapshot/embedded/embedded-data.cc @@ -6,6 +6,7 @@ #include "src/codegen/assembler-inl.h" #include "src/codegen/callable.h" +#include "src/codegen/interface-descriptors-inl.h" #include "src/objects/objects-inl.h" #include "src/snapshot/snapshot-utils.h" #include "src/snapshot/snapshot.h" @@ -137,6 +138,9 @@ void InstructionStream::CreateOffHeapInstructionStream(Isolate* isolate, // in the binary) and what we are currently setting up here (where the blob is // on the native heap). std::memcpy(allocated_code_bytes, d.code(), d.code_size()); + if (FLAG_experimental_flush_embedded_blob_icache) { + FlushInstructionCache(allocated_code_bytes, d.code_size()); + } CHECK(SetPermissions(page_allocator, allocated_code_bytes, allocation_code_size, PageAllocator::kReadExecute)); @@ -184,14 +188,15 @@ bool BuiltinAliasesOffHeapTrampolineRegister(Isolate* isolate, Code code) { return false; } + if (CallInterfaceDescriptor::ContextRegister() == + kOffHeapTrampolineRegister) { + return true; + } + Callable callable = Builtins::CallableFor( isolate, static_cast<Builtins::Name>(code.builtin_index())); CallInterfaceDescriptor descriptor = callable.descriptor(); - if (descriptor.ContextRegister() == kOffHeapTrampolineRegister) { - return true; - } - for (int i = 0; i < descriptor.GetRegisterParameterCount(); i++) { Register reg = descriptor.GetRegisterParameter(i); if (reg == kOffHeapTrampolineRegister) return true; @@ -213,7 +218,8 @@ void FinalizeEmbeddedCodeTargets(Isolate* isolate, EmbeddedData* blob) { #if defined(V8_TARGET_ARCH_X64) || defined(V8_TARGET_ARCH_ARM64) || \ defined(V8_TARGET_ARCH_ARM) || defined(V8_TARGET_ARCH_MIPS) || \ - defined(V8_TARGET_ARCH_IA32) || defined(V8_TARGET_ARCH_S390) + defined(V8_TARGET_ARCH_IA32) || defined(V8_TARGET_ARCH_S390) || \ + defined(V8_TARGET_ARCH_RISCV64) // On these platforms we emit relative builtin-to-builtin // jumps for isolate independent builtins in the snapshot. This fixes up the // relative jumps to the right offsets in the snapshot. @@ -453,10 +459,9 @@ void EmbeddedData::PrintStatistics() const { const int k99th = kCount * 0.99; PrintF("EmbeddedData:\n"); - PrintF(" Total size: %d\n", + PrintF(" Total size: %d\n", static_cast<int>(code_size() + data_size())); - PrintF(" Data size: %d\n", - static_cast<int>(data_size())); + PrintF(" Data size: %d\n", static_cast<int>(data_size())); PrintF(" Code size: %d\n", static_cast<int>(code_size())); PrintF(" Instruction size (50th percentile): %d\n", sizes[k50th]); PrintF(" Instruction size (75th percentile): %d\n", sizes[k75th]); diff --git a/deps/v8/src/snapshot/embedded/embedded-data.h b/deps/v8/src/snapshot/embedded/embedded-data.h index 6518c38d02..12f524d154 100644 --- a/deps/v8/src/snapshot/embedded/embedded-data.h +++ b/deps/v8/src/snapshot/embedded/embedded-data.h @@ -9,6 +9,7 @@ #include "src/builtins/builtins.h" #include "src/common/globals.h" #include "src/execution/isolate.h" +#include "src/heap/code-range.h" namespace v8 { namespace internal { @@ -62,6 +63,13 @@ class EmbeddedData final { isolate->embedded_blob_data(), isolate->embedded_blob_data_size()); } + static EmbeddedData FromBlob(CodeRange* code_range) { + return EmbeddedData(code_range->embedded_blob_code_copy(), + Isolate::CurrentEmbeddedBlobCodeSize(), + Isolate::CurrentEmbeddedBlobData(), + Isolate::CurrentEmbeddedBlobDataSize()); + } + const uint8_t* code() const { return code_; } uint32_t code_size() const { return code_size_; } const uint8_t* data() const { return data_; } diff --git a/deps/v8/src/snapshot/mksnapshot.cc b/deps/v8/src/snapshot/mksnapshot.cc index 4cccc8d173..9a1e988bf8 100644 --- a/deps/v8/src/snapshot/mksnapshot.cc +++ b/deps/v8/src/snapshot/mksnapshot.cc @@ -11,10 +11,10 @@ #include "include/libplatform/libplatform.h" #include "src/base/platform/platform.h" #include "src/base/platform/wrappers.h" +#include "src/base/sanitizer/msan.h" #include "src/codegen/assembler-arch.h" #include "src/codegen/source-position-table.h" #include "src/flags/flags.h" -#include "src/sanitizer/msan.h" #include "src/snapshot/context-serializer.h" #include "src/snapshot/embedded/embedded-file-writer.h" #include "src/snapshot/snapshot.h" @@ -155,7 +155,7 @@ v8::StartupData CreateSnapshotDataBlob(v8::Isolate* isolate, isolate); if (i::FLAG_profile_deserialization) { - i::PrintF("Creating snapshot took %0.3f ms\n", + i::PrintF("[Creating snapshot took %0.3f ms]\n", timer.Elapsed().InMillisecondsF()); } diff --git a/deps/v8/src/snapshot/object-deserializer.cc b/deps/v8/src/snapshot/object-deserializer.cc index 929996ee10..d5ce8cc6e9 100644 --- a/deps/v8/src/snapshot/object-deserializer.cc +++ b/deps/v8/src/snapshot/object-deserializer.cc @@ -66,7 +66,9 @@ void ObjectDeserializer::CommitPostProcessedObjects() { auto bs = backing_store(store_index); SharedFlag shared = bs && bs->is_shared() ? SharedFlag::kShared : SharedFlag::kNotShared; - buffer->Setup(shared, bs); + // TODO(v8:11111): Support RAB / GSAB. + CHECK(!bs || !bs->is_resizable()); + buffer->Setup(shared, ResizableFlag::kNotResizable, bs); } for (Handle<Script> script : new_scripts()) { diff --git a/deps/v8/src/snapshot/read-only-serializer.cc b/deps/v8/src/snapshot/read-only-serializer.cc index 06c5094782..3dc5af0b0d 100644 --- a/deps/v8/src/snapshot/read-only-serializer.cc +++ b/deps/v8/src/snapshot/read-only-serializer.cc @@ -74,6 +74,10 @@ void ReadOnlySerializer::SerializeReadOnlyRoots() { isolate()->handle_scope_implementer()->blocks()->empty()); ReadOnlyRoots(isolate()).Iterate(this); + + if (reconstruct_read_only_object_cache_for_testing()) { + ReconstructReadOnlyObjectCacheForTesting(); + } } void ReadOnlySerializer::FinalizeSerialization() { @@ -129,5 +133,18 @@ bool ReadOnlySerializer::SerializeUsingReadOnlyObjectCache( return true; } +void ReadOnlySerializer::ReconstructReadOnlyObjectCacheForTesting() { + ReadOnlyHeap* ro_heap = isolate()->read_only_heap(); + DCHECK(ro_heap->read_only_object_cache_is_initialized()); + for (size_t i = 0, size = ro_heap->read_only_object_cache_size(); i < size; + i++) { + Handle<HeapObject> obj( + HeapObject::cast(ro_heap->cached_read_only_object(i)), isolate()); + int cache_index = SerializeInObjectCache(obj); + USE(cache_index); + DCHECK_EQ(cache_index, i); + } +} + } // namespace internal } // namespace v8 diff --git a/deps/v8/src/snapshot/read-only-serializer.h b/deps/v8/src/snapshot/read-only-serializer.h index fd88b9f7b6..7f9482f3b9 100644 --- a/deps/v8/src/snapshot/read-only-serializer.h +++ b/deps/v8/src/snapshot/read-only-serializer.h @@ -37,6 +37,8 @@ class V8_EXPORT_PRIVATE ReadOnlySerializer : public RootsSerializer { Handle<HeapObject> obj); private: + void ReconstructReadOnlyObjectCacheForTesting(); + void SerializeObjectImpl(Handle<HeapObject> o) override; bool MustBeDeferred(HeapObject object) override; diff --git a/deps/v8/src/snapshot/serializer-deserializer.h b/deps/v8/src/snapshot/serializer-deserializer.h index 0e156f75a0..82f3400106 100644 --- a/deps/v8/src/snapshot/serializer-deserializer.h +++ b/deps/v8/src/snapshot/serializer-deserializer.h @@ -187,14 +187,13 @@ class SerializerDeserializer : public RootVisitor { } static constexpr byte Encode(TValue value) { - CONSTEXPR_DCHECK(IsEncodable(value)); + DCHECK(IsEncodable(value)); return static_cast<byte>(kBytecode + static_cast<int>(value) - kMinValue); } static constexpr TValue Decode(byte bytecode) { - CONSTEXPR_DCHECK(base::IsInRange(bytecode, - Encode(static_cast<TValue>(kMinValue)), - Encode(static_cast<TValue>(kMaxValue)))); + DCHECK(base::IsInRange(bytecode, Encode(static_cast<TValue>(kMinValue)), + Encode(static_cast<TValue>(kMaxValue)))); return static_cast<TValue>(bytecode - kBytecode + kMinValue); } }; @@ -241,7 +240,7 @@ class SerializerDeserializer : public RootVisitor { } static constexpr int Encode(int repeat_count) { - CONSTEXPR_DCHECK(IsEncodable(repeat_count)); + DCHECK(IsEncodable(repeat_count)); return repeat_count - kFirstEncodableVariableRepeatCount; } diff --git a/deps/v8/src/snapshot/serializer.cc b/deps/v8/src/snapshot/serializer.cc index 89c5485d62..7f7551316c 100644 --- a/deps/v8/src/snapshot/serializer.cc +++ b/deps/v8/src/snapshot/serializer.cc @@ -98,9 +98,9 @@ void Serializer::OutputStatistics(const char* name) { } INSTANCE_TYPE_LIST(PRINT_INSTANCE_TYPE) #undef PRINT_INSTANCE_TYPE +#endif // OBJECT_PRINT PrintF("\n"); -#endif // OBJECT_PRINT } void Serializer::SerializeDeferredObjects() { diff --git a/deps/v8/src/snapshot/serializer.h b/deps/v8/src/snapshot/serializer.h index 3743fa02c9..a1b17e4fd5 100644 --- a/deps/v8/src/snapshot/serializer.h +++ b/deps/v8/src/snapshot/serializer.h @@ -298,6 +298,10 @@ class Serializer : public SerializerDeserializer { return (flags_ & Snapshot::kAllowActiveIsolateForTesting) != 0; } + bool reconstruct_read_only_object_cache_for_testing() const { + return (flags_ & Snapshot::kReconstructReadOnlyObjectCacheForTesting) != 0; + } + private: // A circular queue of hot objects. This is added to in the same order as in // Deserializer::HotObjectsList, but this stores the objects as an array of diff --git a/deps/v8/src/snapshot/snapshot-utils.cc b/deps/v8/src/snapshot/snapshot-utils.cc index eb2372372c..df53dfe751 100644 --- a/deps/v8/src/snapshot/snapshot-utils.cc +++ b/deps/v8/src/snapshot/snapshot-utils.cc @@ -4,7 +4,7 @@ #include "src/snapshot/snapshot-utils.h" -#include "src/sanitizer/msan.h" +#include "src/base/sanitizer/msan.h" #include "third_party/zlib/zlib.h" namespace v8 { diff --git a/deps/v8/src/snapshot/snapshot.cc b/deps/v8/src/snapshot/snapshot.cc index b78e6a70d6..3b4db28447 100644 --- a/deps/v8/src/snapshot/snapshot.cc +++ b/deps/v8/src/snapshot/snapshot.cc @@ -144,8 +144,7 @@ bool Snapshot::VersionIsValid(const v8::StartupData* data) { bool Snapshot::Initialize(Isolate* isolate) { if (!isolate->snapshot_available()) return false; - RuntimeCallTimerScope rcs_timer(isolate, - RuntimeCallCounterId::kDeserializeIsolate); + RCS_SCOPE(isolate, RuntimeCallCounterId::kDeserializeIsolate); base::ElapsedTimer timer; if (FLAG_profile_deserialization) timer.Start(); @@ -173,8 +172,7 @@ MaybeHandle<Context> Snapshot::NewContextFromSnapshot( Isolate* isolate, Handle<JSGlobalProxy> global_proxy, size_t context_index, v8::DeserializeEmbedderFieldsCallback embedder_fields_deserializer) { if (!isolate->snapshot_available()) return Handle<Context>(); - RuntimeCallTimerScope rcs_timer(isolate, - RuntimeCallCounterId::kDeserializeContext); + RCS_SCOPE(isolate, RuntimeCallCounterId::kDeserializeContext); base::ElapsedTimer timer; if (FLAG_profile_deserialization) timer.Start(); @@ -288,7 +286,10 @@ void Snapshot::SerializeDeserializeAndVerifyForTesting( Snapshot::SerializerFlags flags( Snapshot::kAllowUnknownExternalReferencesForTesting | - Snapshot::kAllowActiveIsolateForTesting); + Snapshot::kAllowActiveIsolateForTesting | + (ReadOnlyHeap::IsReadOnlySpaceShared() + ? Snapshot::kReconstructReadOnlyObjectCacheForTesting + : 0)); serialized_data = Snapshot::Create(isolate, *default_context, no_gc, flags); auto_delete_serialized_data.reset(serialized_data.data); } @@ -360,7 +361,7 @@ v8::StartupData Snapshot::Create( context_serializer.Serialize(&contexts->at(i), no_gc); can_be_rehashed = can_be_rehashed && context_serializer.can_be_rehashed(); context_snapshots.push_back(new SnapshotData(&context_serializer)); - if (FLAG_profile_deserialization) { + if (FLAG_serialization_statistics) { context_allocation_sizes.push_back( context_serializer.TotalAllocationSize()); } @@ -374,15 +375,19 @@ v8::StartupData Snapshot::Create( read_only_serializer.FinalizeSerialization(); can_be_rehashed = can_be_rehashed && read_only_serializer.can_be_rehashed(); - if (FLAG_profile_deserialization) { + if (FLAG_serialization_statistics) { // These prints should match the regexp in test/memory/Memory.json + DCHECK_NE(read_only_serializer.TotalAllocationSize(), 0); + DCHECK_NE(startup_serializer.TotalAllocationSize(), 0); PrintF("Deserialization will allocate:\n"); PrintF("%10d bytes per isolate\n", read_only_serializer.TotalAllocationSize() + startup_serializer.TotalAllocationSize()); for (int i = 0; i < num_contexts; i++) { + DCHECK_NE(context_allocation_sizes[i], 0); PrintF("%10d bytes per context #%d\n", context_allocation_sizes[i], i); } + PrintF("\n"); } SnapshotData read_only_snapshot(&read_only_serializer); @@ -471,7 +476,7 @@ v8::StartupData SnapshotImpl::CreateSnapshotBlob( CopyBytes(data + payload_offset, reinterpret_cast<const char*>(startup_snapshot->RawData().begin()), payload_length); - if (FLAG_profile_deserialization) { + if (FLAG_serialization_statistics) { PrintF("Snapshot blob consists of:\n%10d bytes for startup\n", payload_length); } @@ -485,7 +490,7 @@ v8::StartupData SnapshotImpl::CreateSnapshotBlob( data + payload_offset, reinterpret_cast<const char*>(read_only_snapshot->RawData().begin()), payload_length); - if (FLAG_profile_deserialization) { + if (FLAG_serialization_statistics) { PrintF("%10d bytes for read-only\n", payload_length); } payload_offset += payload_length; @@ -500,11 +505,12 @@ v8::StartupData SnapshotImpl::CreateSnapshotBlob( data + payload_offset, reinterpret_cast<const char*>(context_snapshot->RawData().begin()), payload_length); - if (FLAG_profile_deserialization) { + if (FLAG_serialization_statistics) { PrintF("%10d bytes for context #%d\n", payload_length, i); } payload_offset += payload_length; } + if (FLAG_serialization_statistics) PrintF("\n"); DCHECK_EQ(total_length, payload_offset); v8::StartupData result = {data, static_cast<int>(total_length)}; diff --git a/deps/v8/src/snapshot/snapshot.h b/deps/v8/src/snapshot/snapshot.h index 0e510f0096..2f16eee6d5 100644 --- a/deps/v8/src/snapshot/snapshot.h +++ b/deps/v8/src/snapshot/snapshot.h @@ -36,6 +36,15 @@ class Snapshot : public AllStatic { // after deserialization. // If unset, we assert that these previously mentioned areas are empty. kAllowActiveIsolateForTesting = 1 << 1, + // If set, the ReadOnlySerializer reconstructs the read-only object cache + // from the existing ReadOnlyHeap's read-only object cache so the same + // mapping is used. This mode is used for testing deserialization of a + // snapshot from a live isolate that's using a shared + // ReadOnlyHeap. Otherwise during deserialization the indices will mismatch, + // causing deserialization crashes when e.g. types mismatch. + // If unset, the read-only object cache is populated as read-only objects + // are serialized. + kReconstructReadOnlyObjectCacheForTesting = 1 << 2, }; using SerializerFlags = base::Flags<SerializerFlag>; V8_EXPORT_PRIVATE static constexpr SerializerFlags kDefaultSerializerFlags = |