OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 <stdlib.h> | 5 #include <stdlib.h> |
6 #include <string.h> | 6 #include <string.h> |
7 | 7 |
8 #include "src/objects-inl.h" | 8 #include "src/objects-inl.h" |
9 #include "src/snapshot/code-serializer.h" | 9 #include "src/snapshot/code-serializer.h" |
10 #include "src/version.h" | 10 #include "src/version.h" |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 } | 265 } |
266 | 266 |
267 void DeserializeAndRun() { | 267 void DeserializeAndRun() { |
268 ErrorThrower thrower(current_isolate(), ""); | 268 ErrorThrower thrower(current_isolate(), ""); |
269 v8::Local<v8::WasmCompiledModule> deserialized_module; | 269 v8::Local<v8::WasmCompiledModule> deserialized_module; |
270 CHECK(Deserialize().ToLocal(&deserialized_module)); | 270 CHECK(Deserialize().ToLocal(&deserialized_module)); |
271 Handle<WasmModuleObject> module_object = Handle<WasmModuleObject>::cast( | 271 Handle<WasmModuleObject> module_object = Handle<WasmModuleObject>::cast( |
272 v8::Utils::OpenHandle(*deserialized_module)); | 272 v8::Utils::OpenHandle(*deserialized_module)); |
273 { | 273 { |
274 DisallowHeapAllocation assume_no_gc; | 274 DisallowHeapAllocation assume_no_gc; |
275 Handle<WasmCompiledModule> compiled_part( | 275 Handle<WasmCompiledModule> compiled_part(module_object->compiled_module(), |
276 WasmCompiledModule::cast(module_object->GetEmbedderField(0)), | 276 current_isolate()); |
277 current_isolate()); | |
278 CHECK_EQ(memcmp(compiled_part->module_bytes()->GetCharsAddress(), | 277 CHECK_EQ(memcmp(compiled_part->module_bytes()->GetCharsAddress(), |
279 wire_bytes().first, wire_bytes().second), | 278 wire_bytes().first, wire_bytes().second), |
280 0); | 279 0); |
281 } | 280 } |
282 Handle<JSObject> instance = | 281 Handle<JSObject> instance = |
283 SyncInstantiate(current_isolate(), &thrower, module_object, | 282 SyncInstantiate(current_isolate(), &thrower, module_object, |
284 Handle<JSReceiver>::null(), | 283 Handle<JSReceiver>::null(), |
285 MaybeHandle<JSArrayBuffer>()) | 284 MaybeHandle<JSArrayBuffer>()) |
286 .ToHandleChecked(); | 285 .ToHandleChecked(); |
287 Handle<Object> params[1] = { | 286 Handle<Object> params[1] = { |
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1102 // Fake the Embedder flow by creating a memory object, externalize and grow. | 1101 // Fake the Embedder flow by creating a memory object, externalize and grow. |
1103 Handle<WasmMemoryObject> mem_obj = | 1102 Handle<WasmMemoryObject> mem_obj = |
1104 WasmMemoryObject::New(isolate, memory, 100); | 1103 WasmMemoryObject::New(isolate, memory, 100); |
1105 | 1104 |
1106 v8::Utils::ToLocal(memory)->Externalize(); | 1105 v8::Utils::ToLocal(memory)->Externalize(); |
1107 | 1106 |
1108 uint32_t result = WasmMemoryObject::Grow(isolate, mem_obj, 4); | 1107 uint32_t result = WasmMemoryObject::Grow(isolate, mem_obj, 4); |
1109 const bool free_memory = true; | 1108 const bool free_memory = true; |
1110 wasm::DetachWebAssemblyMemoryBuffer(isolate, memory, free_memory); | 1109 wasm::DetachWebAssemblyMemoryBuffer(isolate, memory, free_memory); |
1111 CHECK_EQ(16, result); | 1110 CHECK_EQ(16, result); |
1112 memory = handle(mem_obj->buffer()); | 1111 memory = handle(mem_obj->array_buffer()); |
1113 instance->set_memory_buffer(*memory); | 1112 instance->set_memory_buffer(*memory); |
1114 // Externalize should make no difference without the JS API as in this case | 1113 // Externalize should make no difference without the JS API as in this case |
1115 // the buffer is not detached. | 1114 // the buffer is not detached. |
1116 v8::Utils::ToLocal(memory)->Externalize(); | 1115 v8::Utils::ToLocal(memory)->Externalize(); |
1117 result = testing::RunWasmModuleForTesting(isolate, instance, 0, nullptr); | 1116 result = testing::RunWasmModuleForTesting(isolate, instance, 0, nullptr); |
1118 CHECK_EQ(kExpectedValue, result); | 1117 CHECK_EQ(kExpectedValue, result); |
1119 // Free the buffer as the tracker does not know about it. | 1118 // Free the buffer as the tracker does not know about it. |
1120 const v8::ArrayBuffer::Allocator::AllocationMode allocation_mode = | 1119 const v8::ArrayBuffer::Allocator::AllocationMode allocation_mode = |
1121 memory->allocation_mode(); | 1120 memory->allocation_mode(); |
1122 CHECK_NOT_NULL(memory->allocation_base()); | 1121 CHECK_NOT_NULL(memory->allocation_base()); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1164 Handle<JSArrayBuffer> buffer = wasm::SetupArrayBuffer( | 1163 Handle<JSArrayBuffer> buffer = wasm::SetupArrayBuffer( |
1165 isolate, backing_store, 16 * WasmModule::kPageSize, backing_store, | 1164 isolate, backing_store, 16 * WasmModule::kPageSize, backing_store, |
1166 16 * WasmModule::kPageSize, false, false); | 1165 16 * WasmModule::kPageSize, false, false); |
1167 v8::Utils::ToLocal(buffer)->Externalize(); | 1166 v8::Utils::ToLocal(buffer)->Externalize(); |
1168 wasm::DetachWebAssemblyMemoryBuffer(isolate, buffer, true); | 1167 wasm::DetachWebAssemblyMemoryBuffer(isolate, buffer, true); |
1169 isolate->array_buffer_allocator()->Free(backing_store, | 1168 isolate->array_buffer_allocator()->Free(backing_store, |
1170 16 * WasmModule::kPageSize); | 1169 16 * WasmModule::kPageSize); |
1171 } | 1170 } |
1172 Cleanup(); | 1171 Cleanup(); |
1173 } | 1172 } |
OLD | NEW |