summaryrefslogtreecommitdiff
path: root/deps/v8/src/value-serializer.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/value-serializer.cc')
-rw-r--r--deps/v8/src/value-serializer.cc50
1 files changed, 24 insertions, 26 deletions
diff --git a/deps/v8/src/value-serializer.cc b/deps/v8/src/value-serializer.cc
index 2ba06c170b..a6e741042f 100644
--- a/deps/v8/src/value-serializer.cc
+++ b/deps/v8/src/value-serializer.cc
@@ -449,12 +449,7 @@ Maybe<bool> ValueSerializer::WriteJSReceiver(Handle<JSReceiver> receiver) {
case JS_OBJECT_TYPE:
case JS_API_OBJECT_TYPE: {
Handle<JSObject> js_object = Handle<JSObject>::cast(receiver);
- Map* map = js_object->map();
- if (!FLAG_wasm_disable_structured_cloning &&
- map->GetConstructor() ==
- isolate_->native_context()->wasm_module_constructor()) {
- return WriteWasmModule(js_object);
- } else if (JSObject::GetEmbedderFieldCount(map)) {
+ if (JSObject::GetEmbedderFieldCount(js_object->map())) {
return WriteHostObject(js_object);
} else {
return WriteJSObject(js_object);
@@ -479,6 +474,11 @@ Maybe<bool> ValueSerializer::WriteJSReceiver(Handle<JSReceiver> receiver) {
case JS_TYPED_ARRAY_TYPE:
case JS_DATA_VIEW_TYPE:
return WriteJSArrayBufferView(JSArrayBufferView::cast(*receiver));
+ case WASM_MODULE_TYPE:
+ if (!FLAG_wasm_disable_structured_cloning) {
+ // Only write WebAssembly modules if not disabled by a flag.
+ return WriteWasmModule(Handle<WasmModuleObject>::cast(receiver));
+ } // fall through to error case
default:
ThrowDataCloneError(MessageTemplate::kDataCloneError, receiver);
return Nothing<bool>();
@@ -560,7 +560,7 @@ Maybe<bool> ValueSerializer::WriteJSArray(Handle<JSArray> array) {
// existed (as only indices which were enumerable own properties at this point
// should be serialized).
const bool should_serialize_densely =
- array->HasFastElements() && !array->HasFastHoleyElements();
+ array->HasFastElements() && !array->HasHoleyElements();
if (should_serialize_densely) {
DCHECK_LE(length, static_cast<uint32_t>(FixedArray::kMaxLength));
@@ -568,16 +568,16 @@ Maybe<bool> ValueSerializer::WriteJSArray(Handle<JSArray> array) {
WriteVarint<uint32_t>(length);
uint32_t i = 0;
- // Fast paths. Note that FAST_ELEMENTS in particular can bail due to the
+ // Fast paths. Note that PACKED_ELEMENTS in particular can bail due to the
// structure of the elements changing.
switch (array->GetElementsKind()) {
- case FAST_SMI_ELEMENTS: {
+ case PACKED_SMI_ELEMENTS: {
Handle<FixedArray> elements(FixedArray::cast(array->elements()),
isolate_);
for (; i < length; i++) WriteSmi(Smi::cast(elements->get(i)));
break;
}
- case FAST_DOUBLE_ELEMENTS: {
+ case PACKED_DOUBLE_ELEMENTS: {
// Elements are empty_fixed_array, not a FixedDoubleArray, if the array
// is empty. No elements to encode in this case anyhow.
if (length == 0) break;
@@ -589,11 +589,11 @@ Maybe<bool> ValueSerializer::WriteJSArray(Handle<JSArray> array) {
}
break;
}
- case FAST_ELEMENTS: {
+ case PACKED_ELEMENTS: {
Handle<Object> old_length(array->length(), isolate_);
for (; i < length; i++) {
if (array->length() != *old_length ||
- array->GetElementsKind() != FAST_ELEMENTS) {
+ array->GetElementsKind() != PACKED_ELEMENTS) {
// Fall back to slow path.
break;
}
@@ -815,11 +815,13 @@ Maybe<bool> ValueSerializer::WriteJSArrayBufferView(JSArrayBufferView* view) {
return ThrowIfOutOfMemory();
}
-Maybe<bool> ValueSerializer::WriteWasmModule(Handle<JSObject> object) {
+Maybe<bool> ValueSerializer::WriteWasmModule(Handle<WasmModuleObject> object) {
if (delegate_ != nullptr) {
+ // TODO(titzer): introduce a Utils::ToLocal for WasmModuleObject.
Maybe<uint32_t> transfer_id = delegate_->GetWasmModuleTransferId(
reinterpret_cast<v8::Isolate*>(isolate_),
- v8::Local<v8::WasmCompiledModule>::Cast(Utils::ToLocal(object)));
+ v8::Local<v8::WasmCompiledModule>::Cast(
+ Utils::ToLocal(Handle<JSObject>::cast(object))));
RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate_, Nothing<bool>());
uint32_t id = 0;
if (transfer_id.To(&id)) {
@@ -829,8 +831,7 @@ Maybe<bool> ValueSerializer::WriteWasmModule(Handle<JSObject> object) {
}
}
- Handle<WasmCompiledModule> compiled_part(
- WasmCompiledModule::cast(object->GetEmbedderField(0)), isolate_);
+ Handle<WasmCompiledModule> compiled_part(object->compiled_module(), isolate_);
WasmEncodingTag encoding_tag = WasmEncodingTag::kRawBytes;
WriteTag(SerializationTag::kWasmModule);
WriteRawBytes(&encoding_tag, sizeof(encoding_tag));
@@ -1064,14 +1065,12 @@ void ValueDeserializer::TransferArrayBuffer(
uint32_t transfer_id, Handle<JSArrayBuffer> array_buffer) {
if (array_buffer_transfer_map_.is_null()) {
array_buffer_transfer_map_ = isolate_->global_handles()->Create(
- *SeededNumberDictionary::New(isolate_, 0));
+ *UnseededNumberDictionary::New(isolate_, 0));
}
- Handle<SeededNumberDictionary> dictionary =
+ Handle<UnseededNumberDictionary> dictionary =
array_buffer_transfer_map_.ToHandleChecked();
- Handle<JSObject> not_a_prototype_holder;
- Handle<SeededNumberDictionary> new_dictionary =
- SeededNumberDictionary::AtNumberPut(dictionary, transfer_id, array_buffer,
- not_a_prototype_holder);
+ Handle<UnseededNumberDictionary> new_dictionary =
+ UnseededNumberDictionary::Set(dictionary, transfer_id, array_buffer);
if (!new_dictionary.is_identical_to(dictionary)) {
GlobalHandles::Destroy(Handle<Object>::cast(dictionary).location());
array_buffer_transfer_map_ =
@@ -1366,7 +1365,7 @@ MaybeHandle<JSArray> ValueDeserializer::ReadDenseJSArray() {
uint32_t id = next_id_++;
HandleScope scope(isolate_);
Handle<JSArray> array = isolate_->factory()->NewJSArray(
- FAST_HOLEY_ELEMENTS, length, length, INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE,
+ HOLEY_ELEMENTS, length, length, INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE,
pretenure_);
AddObjectWithID(id, array);
@@ -1451,7 +1450,6 @@ MaybeHandle<JSValue> ValueDeserializer::ReadJSValue(SerializationTag tag) {
}
default:
UNREACHABLE();
- return MaybeHandle<JSValue>();
}
AddObjectWithID(id, value);
return value;
@@ -1581,13 +1579,13 @@ MaybeHandle<JSArrayBuffer> ValueDeserializer::ReadTransferredJSArrayBuffer(
bool is_shared) {
uint32_t id = next_id_++;
uint32_t transfer_id;
- Handle<SeededNumberDictionary> transfer_map;
+ Handle<UnseededNumberDictionary> transfer_map;
if (!ReadVarint<uint32_t>().To(&transfer_id) ||
!array_buffer_transfer_map_.ToHandle(&transfer_map)) {
return MaybeHandle<JSArrayBuffer>();
}
int index = transfer_map->FindEntry(isolate_, transfer_id);
- if (index == SeededNumberDictionary::kNotFound) {
+ if (index == UnseededNumberDictionary::kNotFound) {
return MaybeHandle<JSArrayBuffer>();
}
Handle<JSArrayBuffer> array_buffer(