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 7216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7227 return Local<WasmCompiledModule>::Cast( | 7227 return Local<WasmCompiledModule>::Cast( |
7228 Utils::ToLocal(i::wasm::CreateCompiledModuleObject( | 7228 Utils::ToLocal(i::wasm::CreateCompiledModuleObject( |
7229 i_isolate, compiled_module, i::wasm::ModuleOrigin::kWasmOrigin))); | 7229 i_isolate, compiled_module, i::wasm::ModuleOrigin::kWasmOrigin))); |
7230 } | 7230 } |
7231 | 7231 |
7232 MaybeLocal<WasmCompiledModule> WasmCompiledModule::DeserializeOrCompile( | 7232 MaybeLocal<WasmCompiledModule> WasmCompiledModule::DeserializeOrCompile( |
7233 Isolate* isolate, | 7233 Isolate* isolate, |
7234 const WasmCompiledModule::CallerOwnedBuffer& serialized_module, | 7234 const WasmCompiledModule::CallerOwnedBuffer& serialized_module, |
7235 const WasmCompiledModule::CallerOwnedBuffer& wire_bytes) { | 7235 const WasmCompiledModule::CallerOwnedBuffer& wire_bytes) { |
7236 MaybeLocal<WasmCompiledModule> ret = Deserialize(isolate, serialized_module); | 7236 MaybeLocal<WasmCompiledModule> ret = Deserialize(isolate, serialized_module); |
7237 if (!ret.IsEmpty()) return ret; | 7237 if (!ret.IsEmpty()) { |
| 7238 // TODO(mtrofin): once we stop taking a dependency on Deserialize, |
| 7239 // clean this up to avoid the back and forth between internal |
| 7240 // and external representations. |
| 7241 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 7242 i::Vector<const uint8_t> str(wire_bytes.first, |
| 7243 static_cast<int>(wire_bytes.second)); |
| 7244 i::Handle<i::SeqOneByteString> wire_bytes_as_string( |
| 7245 i::SeqOneByteString::cast( |
| 7246 *i_isolate->factory()->NewStringFromOneByte(str).ToHandleChecked()), |
| 7247 i_isolate); |
| 7248 |
| 7249 i::Handle<i::JSObject> obj = |
| 7250 i::Handle<i::JSObject>::cast(Utils::OpenHandle(*ret.ToLocalChecked())); |
| 7251 i::Handle<i::wasm::WasmCompiledModule> compiled_part = |
| 7252 i::handle(i::wasm::WasmCompiledModule::cast(obj->GetInternalField(0))); |
| 7253 compiled_part->set_module_bytes(wire_bytes_as_string); |
| 7254 return ret; |
| 7255 } |
7238 return Compile(isolate, wire_bytes.first, wire_bytes.second); | 7256 return Compile(isolate, wire_bytes.first, wire_bytes.second); |
7239 } | 7257 } |
7240 | 7258 |
7241 MaybeLocal<WasmCompiledModule> WasmCompiledModule::Compile(Isolate* isolate, | 7259 MaybeLocal<WasmCompiledModule> WasmCompiledModule::Compile(Isolate* isolate, |
7242 const uint8_t* start, | 7260 const uint8_t* start, |
7243 size_t length) { | 7261 size_t length) { |
7244 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 7262 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
7245 i::wasm::ErrorThrower thrower(i_isolate, "WasmCompiledModule::Deserialize()"); | 7263 i::wasm::ErrorThrower thrower(i_isolate, "WasmCompiledModule::Deserialize()"); |
7246 i::MaybeHandle<i::JSObject> maybe_compiled = | 7264 i::MaybeHandle<i::JSObject> maybe_compiled = |
7247 i::wasm::CreateModuleObjectFromBytes( | 7265 i::wasm::CreateModuleObjectFromBytes( |
(...skipping 2167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9415 Address callback_address = | 9433 Address callback_address = |
9416 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 9434 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
9417 VMState<EXTERNAL> state(isolate); | 9435 VMState<EXTERNAL> state(isolate); |
9418 ExternalCallbackScope call_scope(isolate, callback_address); | 9436 ExternalCallbackScope call_scope(isolate, callback_address); |
9419 callback(info); | 9437 callback(info); |
9420 } | 9438 } |
9421 | 9439 |
9422 | 9440 |
9423 } // namespace internal | 9441 } // namespace internal |
9424 } // namespace v8 | 9442 } // namespace v8 |
OLD | NEW |