diff options
Diffstat (limited to 'deps/v8/src/value-serializer.cc')
-rw-r--r-- | deps/v8/src/value-serializer.cc | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/deps/v8/src/value-serializer.cc b/deps/v8/src/value-serializer.cc index 4c9c9a9aa2d..26ab746e8cc 100644 --- a/deps/v8/src/value-serializer.cc +++ b/deps/v8/src/value-serializer.cc @@ -7,14 +7,16 @@ #include <type_traits> #include "include/v8-value-serializer-version.h" -#include "src/api.h" +#include "src/api-inl.h" #include "src/base/logging.h" #include "src/conversions.h" #include "src/flags.h" #include "src/handles-inl.h" #include "src/heap/factory.h" #include "src/isolate.h" +#include "src/maybe-handles-inl.h" #include "src/objects-inl.h" +#include "src/objects/js-array-inl.h" #include "src/objects/js-collection-inl.h" #include "src/objects/js-regexp-inl.h" #include "src/objects/ordered-hash-table-inl.h" @@ -521,11 +523,13 @@ Maybe<bool> ValueSerializer::WriteJSReceiver(Handle<JSReceiver> receiver) { return WriteWasmModule(Handle<WasmModuleObject>::cast(receiver)); } break; - case WASM_MEMORY_TYPE: - if (FLAG_experimental_wasm_threads) { + case WASM_MEMORY_TYPE: { + auto enabled_features = wasm::WasmFeaturesFromIsolate(isolate_); + if (enabled_features.threads) { return WriteWasmMemory(Handle<WasmMemoryObject>::cast(receiver)); } break; + } default: break; } @@ -849,9 +853,9 @@ Maybe<bool> ValueSerializer::WriteJSArrayBufferView(JSArrayBufferView* view) { ArrayBufferViewTag tag = ArrayBufferViewTag::kInt8Array; if (view->IsJSTypedArray()) { switch (JSTypedArray::cast(view)->type()) { -#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ - case kExternal##Type##Array: \ - tag = ArrayBufferViewTag::k##Type##Array; \ +#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype) \ + case kExternal##Type##Array: \ + tag = ArrayBufferViewTag::k##Type##Array; \ break; TYPED_ARRAYS(TYPED_ARRAY_CASE) #undef TYPED_ARRAY_CASE @@ -894,14 +898,13 @@ Maybe<bool> ValueSerializer::WriteWasmModule(Handle<WasmModuleObject> object) { memcpy(destination, wire_bytes.start(), wire_bytes.size()); } - size_t module_size = - wasm::GetSerializedNativeModuleSize(isolate_, native_module); + wasm::WasmSerializer wasm_serializer(isolate_, native_module); + size_t module_size = wasm_serializer.GetSerializedNativeModuleSize(); CHECK_GE(std::numeric_limits<uint32_t>::max(), module_size); WriteVarint<uint32_t>(static_cast<uint32_t>(module_size)); uint8_t* module_buffer; if (ReserveRawBytes(module_size).To(&module_buffer)) { - if (!wasm::SerializeNativeModule(isolate_, native_module, - {module_buffer, module_size})) { + if (!wasm_serializer.SerializeNativeModule({module_buffer, module_size})) { return Nothing<bool>(); } } @@ -1730,10 +1733,10 @@ MaybeHandle<JSArrayBufferView> ValueDeserializer::ReadJSArrayBufferView( AddObjectWithID(id, data_view); return data_view; } -#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ - case ArrayBufferViewTag::k##Type##Array: \ - external_array_type = kExternal##Type##Array; \ - element_size = size; \ +#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype) \ + case ArrayBufferViewTag::k##Type##Array: \ + external_array_type = kExternal##Type##Array; \ + element_size = sizeof(ctype); \ break; TYPED_ARRAYS(TYPED_ARRAY_CASE) #undef TYPED_ARRAY_CASE @@ -1805,8 +1808,11 @@ MaybeHandle<JSObject> ValueDeserializer::ReadWasmModule() { wasm::DeserializeNativeModule(isolate_, compiled_bytes, wire_bytes); if (result.is_null()) { wasm::ErrorThrower thrower(isolate_, "ValueDeserializer::ReadWasmModule"); + // TODO(titzer): are the current features appropriate for deserializing? + auto enabled_features = wasm::WasmFeaturesFromIsolate(isolate_); result = isolate_->wasm_engine()->SyncCompile( - isolate_, &thrower, wasm::ModuleWireBytes(wire_bytes)); + isolate_, enabled_features, &thrower, + wasm::ModuleWireBytes(wire_bytes)); } uint32_t id = next_id_++; if (!result.is_null()) { @@ -1818,7 +1824,8 @@ MaybeHandle<JSObject> ValueDeserializer::ReadWasmModule() { MaybeHandle<WasmMemoryObject> ValueDeserializer::ReadWasmMemory() { uint32_t id = next_id_++; - if (!FLAG_experimental_wasm_threads) { + auto enabled_features = wasm::WasmFeaturesFromIsolate(isolate_); + if (!enabled_features.threads) { return MaybeHandle<WasmMemoryObject>(); } |