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 7228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7239 if (!ret.IsEmpty()) return ret; | 7239 if (!ret.IsEmpty()) return ret; |
7240 return Compile(isolate, uncompiled_bytes); | 7240 return Compile(isolate, uncompiled_bytes); |
7241 } | 7241 } |
7242 | 7242 |
7243 MaybeLocal<WasmCompiledModule> WasmCompiledModule::Compile( | 7243 MaybeLocal<WasmCompiledModule> WasmCompiledModule::Compile( |
7244 Isolate* isolate, Local<String> bytes) { | 7244 Isolate* isolate, Local<String> bytes) { |
7245 i::Handle<i::String> module_bytes = Utils::OpenHandle(*bytes); | 7245 i::Handle<i::String> module_bytes = Utils::OpenHandle(*bytes); |
7246 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 7246 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
7247 i::wasm::ErrorThrower thrower(i_isolate, "WasmCompiledModule::Deserialize()"); | 7247 i::wasm::ErrorThrower thrower(i_isolate, "WasmCompiledModule::Deserialize()"); |
7248 i::SeqOneByteString* data = i::SeqOneByteString::cast(*module_bytes); | 7248 i::SeqOneByteString* data = i::SeqOneByteString::cast(*module_bytes); |
7249 i::ScopedVector<unsigned char> bytes_copy(data->length()); | |
titzer
2016/10/07 09:29:58
Can you leave a TODO here, since we eventually mak
Clemens Hammacher
2016/10/07 09:43:27
Done.
| |
7250 memcpy(bytes_copy.start(), data->GetChars(), data->length()); | |
7249 i::MaybeHandle<i::JSObject> maybe_compiled = | 7251 i::MaybeHandle<i::JSObject> maybe_compiled = |
7250 i::wasm::CreateModuleObjectFromBytes( | 7252 i::wasm::CreateModuleObjectFromBytes( |
7251 i_isolate, data->GetChars(), data->GetChars() + data->length(), | 7253 i_isolate, bytes_copy.start(), |
7252 &thrower, i::wasm::ModuleOrigin::kWasmOrigin); | 7254 bytes_copy.start() + bytes_copy.length(), &thrower, |
7255 i::wasm::ModuleOrigin::kWasmOrigin); | |
7253 if (maybe_compiled.is_null()) return MaybeLocal<WasmCompiledModule>(); | 7256 if (maybe_compiled.is_null()) return MaybeLocal<WasmCompiledModule>(); |
7254 return Local<WasmCompiledModule>::Cast( | 7257 return Local<WasmCompiledModule>::Cast( |
7255 Utils::ToLocal(maybe_compiled.ToHandleChecked())); | 7258 Utils::ToLocal(maybe_compiled.ToHandleChecked())); |
7256 } | 7259 } |
7257 | 7260 |
7258 // static | 7261 // static |
7259 v8::ArrayBuffer::Allocator* v8::ArrayBuffer::Allocator::NewDefaultAllocator() { | 7262 v8::ArrayBuffer::Allocator* v8::ArrayBuffer::Allocator::NewDefaultAllocator() { |
7260 return new ArrayBufferAllocator(); | 7263 return new ArrayBufferAllocator(); |
7261 } | 7264 } |
7262 | 7265 |
(...skipping 2154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9417 Address callback_address = | 9420 Address callback_address = |
9418 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 9421 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
9419 VMState<EXTERNAL> state(isolate); | 9422 VMState<EXTERNAL> state(isolate); |
9420 ExternalCallbackScope call_scope(isolate, callback_address); | 9423 ExternalCallbackScope call_scope(isolate, callback_address); |
9421 callback(info); | 9424 callback(info); |
9422 } | 9425 } |
9423 | 9426 |
9424 | 9427 |
9425 } // namespace internal | 9428 } // namespace internal |
9426 } // namespace v8 | 9429 } // namespace v8 |
OLD | NEW |