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 7597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7608 size_t length) { | 7608 size_t length) { |
7609 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 7609 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
7610 i::wasm::ErrorThrower thrower(i_isolate, "WasmCompiledModule::Deserialize()"); | 7610 i::wasm::ErrorThrower thrower(i_isolate, "WasmCompiledModule::Deserialize()"); |
7611 i::MaybeHandle<i::JSObject> maybe_compiled = i::wasm::SyncCompile( | 7611 i::MaybeHandle<i::JSObject> maybe_compiled = i::wasm::SyncCompile( |
7612 i_isolate, &thrower, i::wasm::ModuleWireBytes(start, start + length)); | 7612 i_isolate, &thrower, i::wasm::ModuleWireBytes(start, start + length)); |
7613 if (maybe_compiled.is_null()) return MaybeLocal<WasmCompiledModule>(); | 7613 if (maybe_compiled.is_null()) return MaybeLocal<WasmCompiledModule>(); |
7614 return Local<WasmCompiledModule>::Cast( | 7614 return Local<WasmCompiledModule>::Cast( |
7615 Utils::ToLocal(maybe_compiled.ToHandleChecked())); | 7615 Utils::ToLocal(maybe_compiled.ToHandleChecked())); |
7616 } | 7616 } |
7617 | 7617 |
| 7618 void WasmModuleObjectBuilder::OnBytesReceived( |
| 7619 std::unique_ptr<const uint8_t[]>&& bytes, size_t size) { |
| 7620 received_buffers_.push_back(Buffer(std::move(bytes), size)); |
| 7621 total_size_ += size; |
| 7622 } |
| 7623 |
| 7624 MaybeLocal<WasmCompiledModule> WasmModuleObjectBuilder::Finish() { |
| 7625 std::unique_ptr<uint8_t[]> wire_bytes(new uint8_t[total_size_]); |
| 7626 uint8_t* insert_at = wire_bytes.get(); |
| 7627 |
| 7628 for (size_t i = 0; i < received_buffers_.size(); ++i) { |
| 7629 const Buffer& buff = received_buffers_[i]; |
| 7630 memcpy(insert_at, buff.first.get(), buff.second); |
| 7631 insert_at += buff.second; |
| 7632 } |
| 7633 return WasmCompiledModule::Compile(isolate_, wire_bytes.get(), total_size_); |
| 7634 } |
| 7635 |
7618 // static | 7636 // static |
7619 v8::ArrayBuffer::Allocator* v8::ArrayBuffer::Allocator::NewDefaultAllocator() { | 7637 v8::ArrayBuffer::Allocator* v8::ArrayBuffer::Allocator::NewDefaultAllocator() { |
7620 return new ArrayBufferAllocator(); | 7638 return new ArrayBufferAllocator(); |
7621 } | 7639 } |
7622 | 7640 |
7623 bool v8::ArrayBuffer::IsExternal() const { | 7641 bool v8::ArrayBuffer::IsExternal() const { |
7624 return Utils::OpenHandle(this)->is_external(); | 7642 return Utils::OpenHandle(this)->is_external(); |
7625 } | 7643 } |
7626 | 7644 |
7627 | 7645 |
(...skipping 2662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10290 Address callback_address = | 10308 Address callback_address = |
10291 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 10309 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
10292 VMState<EXTERNAL> state(isolate); | 10310 VMState<EXTERNAL> state(isolate); |
10293 ExternalCallbackScope call_scope(isolate, callback_address); | 10311 ExternalCallbackScope call_scope(isolate, callback_address); |
10294 callback(info); | 10312 callback(info); |
10295 } | 10313 } |
10296 | 10314 |
10297 | 10315 |
10298 } // namespace internal | 10316 } // namespace internal |
10299 } // namespace v8 | 10317 } // namespace v8 |
OLD | NEW |