| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/api.h" | 5 #include "src/api.h" |
| 6 | 6 |
| 7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
| 8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
| 9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
| 10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
| (...skipping 7703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7714 i::Handle<i::JSReceiver> target = Utils::OpenHandle(*local_target); | 7714 i::Handle<i::JSReceiver> target = Utils::OpenHandle(*local_target); |
| 7715 i::Handle<i::JSReceiver> handler = Utils::OpenHandle(*local_handler); | 7715 i::Handle<i::JSReceiver> handler = Utils::OpenHandle(*local_handler); |
| 7716 Local<Proxy> result; | 7716 Local<Proxy> result; |
| 7717 has_pending_exception = | 7717 has_pending_exception = |
| 7718 !ToLocal<Proxy>(i::JSProxy::New(isolate, target, handler), &result); | 7718 !ToLocal<Proxy>(i::JSProxy::New(isolate, target, handler), &result); |
| 7719 RETURN_ON_FAILED_EXECUTION(Proxy); | 7719 RETURN_ON_FAILED_EXECUTION(Proxy); |
| 7720 RETURN_ESCAPED(result); | 7720 RETURN_ESCAPED(result); |
| 7721 } | 7721 } |
| 7722 | 7722 |
| 7723 Local<String> WasmCompiledModule::GetWasmWireBytes() { | 7723 Local<String> WasmCompiledModule::GetWasmWireBytes() { |
| 7724 i::Handle<i::JSObject> obj = | 7724 i::Handle<i::WasmModuleObject> obj = |
| 7725 i::Handle<i::JSObject>::cast(Utils::OpenHandle(this)); | 7725 i::Handle<i::WasmModuleObject>::cast(Utils::OpenHandle(this)); |
| 7726 i::Handle<i::WasmCompiledModule> compiled_part = | 7726 i::Handle<i::WasmCompiledModule> compiled_part = |
| 7727 i::handle(i::WasmCompiledModule::cast(obj->GetEmbedderField(0))); | 7727 i::handle(i::WasmCompiledModule::cast(obj->compiled_module())); |
| 7728 i::Handle<i::String> wire_bytes(compiled_part->module_bytes()); | 7728 i::Handle<i::String> wire_bytes(compiled_part->module_bytes()); |
| 7729 return Local<String>::Cast(Utils::ToLocal(wire_bytes)); | 7729 return Local<String>::Cast(Utils::ToLocal(wire_bytes)); |
| 7730 } | 7730 } |
| 7731 | 7731 |
| 7732 // Currently, wasm modules are bound, both to Isolate and to | 7732 // Currently, wasm modules are bound, both to Isolate and to |
| 7733 // the Context they were created in. The currently-supported means to | 7733 // the Context they were created in. The currently-supported means to |
| 7734 // decontextualize and then re-contextualize a module is via | 7734 // decontextualize and then re-contextualize a module is via |
| 7735 // serialization/deserialization. | 7735 // serialization/deserialization. |
| 7736 WasmCompiledModule::TransferrableModule | 7736 WasmCompiledModule::TransferrableModule |
| 7737 WasmCompiledModule::GetTransferrableModule() { | 7737 WasmCompiledModule::GetTransferrableModule() { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 7753 MaybeLocal<WasmCompiledModule> WasmCompiledModule::FromTransferrableModule( | 7753 MaybeLocal<WasmCompiledModule> WasmCompiledModule::FromTransferrableModule( |
| 7754 Isolate* isolate, | 7754 Isolate* isolate, |
| 7755 const WasmCompiledModule::TransferrableModule& transferrable_module) { | 7755 const WasmCompiledModule::TransferrableModule& transferrable_module) { |
| 7756 MaybeLocal<WasmCompiledModule> ret = | 7756 MaybeLocal<WasmCompiledModule> ret = |
| 7757 Deserialize(isolate, AsCallerOwned(transferrable_module.compiled_code), | 7757 Deserialize(isolate, AsCallerOwned(transferrable_module.compiled_code), |
| 7758 AsCallerOwned(transferrable_module.wire_bytes)); | 7758 AsCallerOwned(transferrable_module.wire_bytes)); |
| 7759 return ret; | 7759 return ret; |
| 7760 } | 7760 } |
| 7761 | 7761 |
| 7762 WasmCompiledModule::SerializedModule WasmCompiledModule::Serialize() { | 7762 WasmCompiledModule::SerializedModule WasmCompiledModule::Serialize() { |
| 7763 i::Handle<i::JSObject> obj = | 7763 i::Handle<i::WasmModuleObject> obj = |
| 7764 i::Handle<i::JSObject>::cast(Utils::OpenHandle(this)); | 7764 i::Handle<i::WasmModuleObject>::cast(Utils::OpenHandle(this)); |
| 7765 i::Handle<i::WasmCompiledModule> compiled_part = | 7765 i::Handle<i::WasmCompiledModule> compiled_part = |
| 7766 i::handle(i::WasmCompiledModule::cast(obj->GetEmbedderField(0))); | 7766 i::handle(i::WasmCompiledModule::cast(obj->compiled_module())); |
| 7767 | 7767 |
| 7768 std::unique_ptr<i::ScriptData> script_data = | 7768 std::unique_ptr<i::ScriptData> script_data = |
| 7769 i::WasmCompiledModuleSerializer::SerializeWasmModule(obj->GetIsolate(), | 7769 i::WasmCompiledModuleSerializer::SerializeWasmModule(obj->GetIsolate(), |
| 7770 compiled_part); | 7770 compiled_part); |
| 7771 script_data->ReleaseDataOwnership(); | 7771 script_data->ReleaseDataOwnership(); |
| 7772 | 7772 |
| 7773 size_t size = static_cast<size_t>(script_data->length()); | 7773 size_t size = static_cast<size_t>(script_data->length()); |
| 7774 return {std::unique_ptr<const uint8_t[]>(script_data->data()), size}; | 7774 return {std::unique_ptr<const uint8_t[]>(script_data->data()), size}; |
| 7775 } | 7775 } |
| 7776 | 7776 |
| (...skipping 2862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10639 Address callback_address = | 10639 Address callback_address = |
| 10640 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 10640 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 10641 VMState<EXTERNAL> state(isolate); | 10641 VMState<EXTERNAL> state(isolate); |
| 10642 ExternalCallbackScope call_scope(isolate, callback_address); | 10642 ExternalCallbackScope call_scope(isolate, callback_address); |
| 10643 callback(info); | 10643 callback(info); |
| 10644 } | 10644 } |
| 10645 | 10645 |
| 10646 | 10646 |
| 10647 } // namespace internal | 10647 } // namespace internal |
| 10648 } // namespace v8 | 10648 } // namespace v8 |
| OLD | NEW |