| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/value-serializer.h" | 5 #include "src/value-serializer.h" |
| 6 | 6 |
| 7 #include <type_traits> | 7 #include <type_traits> |
| 8 | 8 |
| 9 #include "src/base/logging.h" | 9 #include "src/base/logging.h" |
| 10 #include "src/conversions.h" | 10 #include "src/conversions.h" |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 STACK_CHECK(isolate_, Nothing<bool>()); | 411 STACK_CHECK(isolate_, Nothing<bool>()); |
| 412 | 412 |
| 413 HandleScope scope(isolate_); | 413 HandleScope scope(isolate_); |
| 414 switch (instance_type) { | 414 switch (instance_type) { |
| 415 case JS_ARRAY_TYPE: | 415 case JS_ARRAY_TYPE: |
| 416 return WriteJSArray(Handle<JSArray>::cast(receiver)); | 416 return WriteJSArray(Handle<JSArray>::cast(receiver)); |
| 417 case JS_OBJECT_TYPE: | 417 case JS_OBJECT_TYPE: |
| 418 case JS_API_OBJECT_TYPE: { | 418 case JS_API_OBJECT_TYPE: { |
| 419 Handle<JSObject> js_object = Handle<JSObject>::cast(receiver); | 419 Handle<JSObject> js_object = Handle<JSObject>::cast(receiver); |
| 420 Map* map = js_object->map(); | 420 Map* map = js_object->map(); |
| 421 if (FLAG_expose_wasm && | 421 if (!FLAG_wasm_disable_structured_cloning && |
| 422 map->GetConstructor() == | 422 map->GetConstructor() == |
| 423 isolate_->native_context()->wasm_module_constructor()) { | 423 isolate_->native_context()->wasm_module_constructor()) { |
| 424 return WriteWasmModule(js_object); | 424 return WriteWasmModule(js_object); |
| 425 } else if (JSObject::GetInternalFieldCount(map)) { | 425 } else if (JSObject::GetInternalFieldCount(map)) { |
| 426 return WriteHostObject(js_object); | 426 return WriteHostObject(js_object); |
| 427 } else { | 427 } else { |
| 428 return WriteJSObject(js_object); | 428 return WriteJSObject(js_object); |
| 429 } | 429 } |
| 430 } | 430 } |
| 431 case JS_SPECIAL_API_OBJECT_TYPE: | 431 case JS_SPECIAL_API_OBJECT_TYPE: |
| (...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1525 return MaybeHandle<JSArrayBufferView>(); | 1525 return MaybeHandle<JSArrayBufferView>(); |
| 1526 } | 1526 } |
| 1527 Handle<JSTypedArray> typed_array = isolate_->factory()->NewJSTypedArray( | 1527 Handle<JSTypedArray> typed_array = isolate_->factory()->NewJSTypedArray( |
| 1528 external_array_type, buffer, byte_offset, byte_length / element_size, | 1528 external_array_type, buffer, byte_offset, byte_length / element_size, |
| 1529 pretenure_); | 1529 pretenure_); |
| 1530 AddObjectWithID(id, typed_array); | 1530 AddObjectWithID(id, typed_array); |
| 1531 return typed_array; | 1531 return typed_array; |
| 1532 } | 1532 } |
| 1533 | 1533 |
| 1534 MaybeHandle<JSObject> ValueDeserializer::ReadWasmModule() { | 1534 MaybeHandle<JSObject> ValueDeserializer::ReadWasmModule() { |
| 1535 if (!FLAG_expose_wasm) return MaybeHandle<JSObject>(); | 1535 if (FLAG_wasm_disable_structured_cloning) return MaybeHandle<JSObject>(); |
| 1536 | 1536 |
| 1537 Vector<const uint8_t> encoding_tag; | 1537 Vector<const uint8_t> encoding_tag; |
| 1538 if (!ReadRawBytes(sizeof(WasmEncodingTag)).To(&encoding_tag) || | 1538 if (!ReadRawBytes(sizeof(WasmEncodingTag)).To(&encoding_tag) || |
| 1539 encoding_tag[0] != static_cast<uint8_t>(WasmEncodingTag::kRawBytes)) { | 1539 encoding_tag[0] != static_cast<uint8_t>(WasmEncodingTag::kRawBytes)) { |
| 1540 return MaybeHandle<JSObject>(); | 1540 return MaybeHandle<JSObject>(); |
| 1541 } | 1541 } |
| 1542 | 1542 |
| 1543 // Extract the data from the buffer: wasm wire bytes, followed by V8 compiled | 1543 // Extract the data from the buffer: wasm wire bytes, followed by V8 compiled |
| 1544 // script data. | 1544 // script data. |
| 1545 static_assert(sizeof(int) <= sizeof(uint32_t), | 1545 static_assert(sizeof(int) <= sizeof(uint32_t), |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1879 if (stack.size() != 1) { | 1879 if (stack.size() != 1) { |
| 1880 isolate_->Throw(*isolate_->factory()->NewError( | 1880 isolate_->Throw(*isolate_->factory()->NewError( |
| 1881 MessageTemplate::kDataCloneDeserializationError)); | 1881 MessageTemplate::kDataCloneDeserializationError)); |
| 1882 return MaybeHandle<Object>(); | 1882 return MaybeHandle<Object>(); |
| 1883 } | 1883 } |
| 1884 return scope.CloseAndEscape(stack[0]); | 1884 return scope.CloseAndEscape(stack[0]); |
| 1885 } | 1885 } |
| 1886 | 1886 |
| 1887 } // namespace internal | 1887 } // namespace internal |
| 1888 } // namespace v8 | 1888 } // namespace v8 |
| OLD | NEW |