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 7572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7583 size_t length) { | 7583 size_t length) { |
7584 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 7584 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
7585 i::wasm::ErrorThrower thrower(i_isolate, "WasmCompiledModule::Deserialize()"); | 7585 i::wasm::ErrorThrower thrower(i_isolate, "WasmCompiledModule::Deserialize()"); |
7586 i::MaybeHandle<i::JSObject> maybe_compiled = i::wasm::SyncCompile( | 7586 i::MaybeHandle<i::JSObject> maybe_compiled = i::wasm::SyncCompile( |
7587 i_isolate, &thrower, i::wasm::ModuleWireBytes(start, start + length)); | 7587 i_isolate, &thrower, i::wasm::ModuleWireBytes(start, start + length)); |
7588 if (maybe_compiled.is_null()) return MaybeLocal<WasmCompiledModule>(); | 7588 if (maybe_compiled.is_null()) return MaybeLocal<WasmCompiledModule>(); |
7589 return Local<WasmCompiledModule>::Cast( | 7589 return Local<WasmCompiledModule>::Cast( |
7590 Utils::ToLocal(maybe_compiled.ToHandleChecked())); | 7590 Utils::ToLocal(maybe_compiled.ToHandleChecked())); |
7591 } | 7591 } |
7592 | 7592 |
7593 void WasmModuleObjectBuilder::OnBytesReceived( | 7593 void WasmModuleObjectBuilder::OnBytesReceived(const uint8_t* bytes, |
7594 std::unique_ptr<const uint8_t[]>&& bytes, size_t size) { | 7594 size_t size) { |
7595 received_buffers_.push_back(Buffer(std::move(bytes), size)); | 7595 std::unique_ptr<uint8_t[]> cloned_bytes(new uint8_t[size]); |
| 7596 memcpy(cloned_bytes.get(), bytes, size); |
| 7597 received_buffers_.push_back( |
| 7598 Buffer(std::unique_ptr<const uint8_t[]>( |
| 7599 const_cast<const uint8_t*>(cloned_bytes.release())), |
| 7600 size)); |
7596 total_size_ += size; | 7601 total_size_ += size; |
7597 } | 7602 } |
7598 | 7603 |
7599 MaybeLocal<WasmCompiledModule> WasmModuleObjectBuilder::Finish() { | 7604 MaybeLocal<WasmCompiledModule> WasmModuleObjectBuilder::Finish() { |
7600 std::unique_ptr<uint8_t[]> wire_bytes(new uint8_t[total_size_]); | 7605 std::unique_ptr<uint8_t[]> wire_bytes(new uint8_t[total_size_]); |
7601 uint8_t* insert_at = wire_bytes.get(); | 7606 uint8_t* insert_at = wire_bytes.get(); |
7602 | 7607 |
7603 for (size_t i = 0; i < received_buffers_.size(); ++i) { | 7608 for (size_t i = 0; i < received_buffers_.size(); ++i) { |
7604 const Buffer& buff = received_buffers_[i]; | 7609 const Buffer& buff = received_buffers_[i]; |
7605 memcpy(insert_at, buff.first.get(), buff.second); | 7610 memcpy(insert_at, buff.first.get(), buff.second); |
(...skipping 2718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10324 Address callback_address = | 10329 Address callback_address = |
10325 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 10330 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
10326 VMState<EXTERNAL> state(isolate); | 10331 VMState<EXTERNAL> state(isolate); |
10327 ExternalCallbackScope call_scope(isolate, callback_address); | 10332 ExternalCallbackScope call_scope(isolate, callback_address); |
10328 callback(info); | 10333 callback(info); |
10329 } | 10334 } |
10330 | 10335 |
10331 | 10336 |
10332 } // namespace internal | 10337 } // namespace internal |
10333 } // namespace v8 | 10338 } // namespace v8 |
OLD | NEW |