diff --git a/BUILD.bazel b/BUILD.bazel index 63262438aa..13c79bee9a 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1164,7 +1164,6 @@ filegroup( "src/builtins/builtins-utils-inl.h", "src/builtins/builtins-utils.h", "src/builtins/builtins-weak-refs.cc", - "src/builtins/builtins-web-snapshots.cc", "src/builtins/builtins.cc", "src/builtins/builtins.h", "src/builtins/constants-table-builder.cc", @@ -2207,8 +2206,6 @@ filegroup( "src/utils/utils.h", "src/utils/version.cc", "src/utils/version.h", - "src/web-snapshot/web-snapshot.h", - "src/web-snapshot/web-snapshot.cc", "src/zone/accounting-allocator.cc", "src/zone/accounting-allocator.h", "src/zone/compressed-zone-ptr.h", diff --git a/BUILD.gn b/BUILD.gn index bc2c332cbd..480d68d646 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -4562,7 +4562,6 @@ v8_source_set("v8_base_without_compiler") { "src/builtins/builtins-trace.cc", "src/builtins/builtins-typed-array.cc", "src/builtins/builtins-weak-refs.cc", - "src/builtins/builtins-web-snapshots.cc", "src/builtins/builtins.cc", "src/builtins/constants-table-builder.cc", "src/codegen/aligned-slot-allocator.cc", @@ -4955,8 +4954,6 @@ v8_source_set("v8_base_without_compiler") { "src/utils/sha-256.cc", "src/utils/utils.cc", "src/utils/version.cc", - "src/web-snapshot/web-snapshot.cc", - "src/web-snapshot/web-snapshot.h", "src/zone/accounting-allocator.cc", "src/zone/type-stats.cc", "src/zone/zone-segment.cc", diff --git a/src/api/api.cc b/src/api/api.cc index e1fc639b7e..ee0ac18dc3 100644 --- a/src/api/api.cc +++ b/src/api/api.cc @@ -128,7 +128,6 @@ #include "src/tracing/trace-event.h" #include "src/utils/detachable-vector.h" #include "src/utils/version.h" -#include "src/web-snapshot/web-snapshot.h" #if V8_ENABLE_WEBASSEMBLY #include "src/trap-handler/trap-handler.h" @@ -2225,22 +2224,6 @@ MaybeLocal Script::Run(Local context, } #endif auto fun = i::Handle::cast(Utils::OpenHandle(this)); - - if (V8_UNLIKELY(i::v8_flags.experimental_web_snapshots)) { - i::Handle maybe_script = - handle(fun->shared().script(), i_isolate); - if (maybe_script->IsScript() && - i::Script::cast(*maybe_script).type() == i::Script::TYPE_WEB_SNAPSHOT) { - i::WebSnapshotDeserializer deserializer( - reinterpret_cast(v8_isolate), - i::Handle::cast(maybe_script)); - deserializer.Deserialize(); - RETURN_ON_FAILED_EXECUTION(Value); - Local result = v8::Undefined(v8_isolate); - RETURN_ESCAPED(result); - } - } - i::Handle receiver = i_isolate->global_proxy(); // TODO(cbruni, chromium:1244145): Remove once migrated to the context. i::Handle options( diff --git a/src/builtins/builtins-definitions.h b/src/builtins/builtins-definitions.h index 0ca201fc61..424580e38a 100644 --- a/src/builtins/builtins-definitions.h +++ b/src/builtins/builtins-definitions.h @@ -626,10 +626,6 @@ namespace internal { CPP(JsonRawJson) \ CPP(JsonIsRawJson) \ \ - /* Web snapshots */ \ - CPP(WebSnapshotSerialize) \ - CPP(WebSnapshotDeserialize) \ - \ /* ICs */ \ TFH(LoadIC, LoadWithVector) \ TFH(LoadIC_Megamorphic, LoadWithVector) \ diff --git a/src/builtins/builtins-web-snapshots.cc b/src/builtins/builtins-web-snapshots.cc deleted file mode 100644 index 1e85edd919..0000000000 --- a/src/builtins/builtins-web-snapshots.cc +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright 2022 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "src/builtins/builtins-utils-inl.h" -#include "src/builtins/builtins.h" -#include "src/logging/counters.h" -#include "src/objects/js-array-buffer-inl.h" -#include "src/objects/js-array-inl.h" -#include "src/objects/objects-inl.h" -#include "src/web-snapshot/web-snapshot.h" - -namespace v8 { -namespace internal { - -BUILTIN(WebSnapshotSerialize) { - HandleScope scope(isolate); - if (args.length() < 2 || args.length() > 3) { - THROW_NEW_ERROR_RETURN_FAILURE( - isolate, NewTypeError(MessageTemplate::kInvalidArgument)); - } - Handle object = args.at(1); - Handle block_list = isolate->factory()->empty_fixed_array(); - Handle block_list_js_array; - if (args.length() == 3) { - if (!args[2].IsJSArray()) { - THROW_NEW_ERROR_RETURN_FAILURE( - isolate, NewTypeError(MessageTemplate::kInvalidArgument)); - } - block_list_js_array = args.at(2); - ASSIGN_RETURN_FAILURE_ON_EXCEPTION( - isolate, block_list, - JSReceiver::GetOwnValues(isolate, block_list_js_array, - PropertyFilter::ENUMERABLE_STRINGS)); - } - - auto snapshot_data = std::make_shared(); - WebSnapshotSerializer serializer(isolate); - if (!serializer.TakeSnapshot(object, block_list, *snapshot_data)) { - DCHECK(isolate->has_pending_exception()); - return ReadOnlyRoots(isolate).exception(); - } - if (!block_list_js_array.is_null() && - static_cast(block_list->length()) < - serializer.external_object_count()) { - Handle externals = serializer.GetExternals(); - Handle map = JSObject::GetElementsTransitionMap(block_list_js_array, - PACKED_ELEMENTS); - block_list_js_array->set_elements(*externals); - block_list_js_array->set_length(Smi::FromInt(externals->length())); - block_list_js_array->set_map(*map); - } - - MaybeHandle maybe_result = - isolate->factory()->NewJSArrayBufferAndBackingStore( - snapshot_data->buffer_size, InitializedFlag::kUninitialized); - Handle result; - if (!maybe_result.ToHandle(&result)) { - THROW_NEW_ERROR_RETURN_FAILURE( - isolate, NewTypeError(MessageTemplate::kOutOfMemory, - isolate->factory()->NewStringFromAsciiChecked( - "WebSnapshotSerialize"))); - } - uint8_t* data = - reinterpret_cast(result->GetBackingStore()->buffer_start()); - memcpy(data, snapshot_data->buffer, snapshot_data->buffer_size); - - return *result; -} - -BUILTIN(WebSnapshotDeserialize) { - HandleScope scope(isolate); - if (args.length() < 2 || args.length() > 3) { - THROW_NEW_ERROR_RETURN_FAILURE( - isolate, NewTypeError(MessageTemplate::kInvalidArgument)); - } - - if (!args[1].IsJSArrayBuffer()) { - THROW_NEW_ERROR_RETURN_FAILURE( - isolate, NewTypeError(MessageTemplate::kInvalidArgument)); - } - auto buffer = args.at(1); - std::shared_ptr backing_store = buffer->GetBackingStore(); - if (backing_store.get() == nullptr) { - THROW_NEW_ERROR_RETURN_FAILURE( - isolate, NewTypeError(MessageTemplate::kInvalidArgument)); - } - const uint8_t* data = - reinterpret_cast(backing_store->buffer_start()); - - Handle injected_references = - isolate->factory()->empty_fixed_array(); - if (args.length() == 3) { - if (!args[2].IsJSArray()) { - THROW_NEW_ERROR_RETURN_FAILURE( - isolate, NewTypeError(MessageTemplate::kInvalidArgument)); - } - auto js_array = args.at(2); - ASSIGN_RETURN_FAILURE_ON_EXCEPTION( - isolate, injected_references, - JSReceiver::GetOwnValues(isolate, js_array, - PropertyFilter::ENUMERABLE_STRINGS)); - } - - WebSnapshotDeserializer deserializer(reinterpret_cast(isolate), - data, backing_store->byte_length()); - if (!deserializer.Deserialize(injected_references)) { - DCHECK(isolate->has_pending_exception()); - return ReadOnlyRoots(isolate).exception(); - } - Handle object; - if (!deserializer.value().ToHandle(&object)) { - return ReadOnlyRoots(isolate).undefined_value(); - } - return *object; -} - -} // namespace internal -} // namespace v8 diff --git a/src/codegen/compiler.cc b/src/codegen/compiler.cc index fa0872b842..a8f40090a0 100644 --- a/src/codegen/compiler.cc +++ b/src/codegen/compiler.cc @@ -62,7 +62,6 @@ #include "src/parsing/scanner-character-streams.h" #include "src/snapshot/code-serializer.h" #include "src/utils/ostreams.h" -#include "src/web-snapshot/web-snapshot.h" #include "src/zone/zone-list-inl.h" // crbug.com/v8/8816 #ifdef V8_ENABLE_MAGLEV @@ -3451,29 +3450,6 @@ MaybeHandle GetSharedFunctionInfoForScriptImpl( DCHECK_NULL(deserialize_task); } - if (V8_UNLIKELY( - v8_flags.experimental_web_snapshots && - (source->IsExternalOneByteString() || source->IsSeqOneByteString() || - source->IsExternalTwoByteString() || source->IsSeqTwoByteString()) && - source->length() > 4)) { - // Experimental: Treat the script as a web snapshot if it starts with the - // magic byte sequence. TODO(v8:11525): Remove this once proper embedder - // integration is done. - bool magic_matches = true; - for (size_t i = 0; - i < sizeof(WebSnapshotSerializerDeserializer::kMagicNumber); ++i) { - if (source->Get(static_cast(i)) != - WebSnapshotSerializerDeserializer::kMagicNumber[i]) { - magic_matches = false; - break; - } - } - if (magic_matches) { - return Compiler::GetSharedFunctionInfoForWebSnapshot( - isolate, source, script_details.name_obj); - } - } - LanguageMode language_mode = construct_language_mode(v8_flags.use_strict); CompilationCache* compilation_cache = isolate->compilation_cache(); @@ -3801,30 +3777,6 @@ Compiler::GetSharedFunctionInfoForStreamedScript( return maybe_result; } // namespace internal -// static -Handle Compiler::GetSharedFunctionInfoForWebSnapshot( - Isolate* isolate, Handle source, - MaybeHandle maybe_script_name) { - // This script won't hold the functions created from the web snapshot; - // reserving space only for the top-level SharedFunctionInfo is enough. - Handle shared_function_infos = - isolate->factory()->NewWeakFixedArray(1, AllocationType::kOld); - Handle