Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: src/wasm/wasm-module.cc

Issue 2548223002: [wasm] Update WasmMemoryObject correctly when module memory is exported. (Closed)
Patch Set: Format Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/mjsunit/regress/wasm/regression-670683.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <memory> 5 #include <memory>
6 6
7 #include "src/base/atomic-utils.h" 7 #include "src/base/atomic-utils.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 9
10 #include "src/macro-assembler.h" 10 #include "src/macro-assembler.h"
(...skipping 1773 matching lines...) Expand 10 before | Expand all | Expand 10 after
1784 desc.set_value(table_instance.table_object); 1784 desc.set_value(table_instance.table_object);
1785 break; 1785 break;
1786 } 1786 }
1787 case kExternalMemory: { 1787 case kExternalMemory: {
1788 // Export the memory as a WebAssembly.Memory object. 1788 // Export the memory as a WebAssembly.Memory object.
1789 Handle<WasmMemoryObject> memory_object; 1789 Handle<WasmMemoryObject> memory_object;
1790 if (!instance->has_memory_object()) { 1790 if (!instance->has_memory_object()) {
1791 // If there was no imported WebAssembly.Memory object, create one. 1791 // If there was no imported WebAssembly.Memory object, create one.
1792 Handle<JSArrayBuffer> buffer(instance->get_memory_buffer(), 1792 Handle<JSArrayBuffer> buffer(instance->get_memory_buffer(),
1793 isolate_); 1793 isolate_);
1794 memory_object = WasmMemoryObject::New( 1794 if (!buffer.is_null() && buffer->has_guard_region()) {
Eric Holk 2016/12/05 19:54:52 We talked about this offline, but I'm summarizing
gdeepti 2016/12/07 07:10:33 Summarizing offline discussions, previous interpre
1795 isolate_, buffer, 1795 // If guard pages are enabled, use a different buffer to create
1796 (module_->max_mem_pages != 0) ? module_->max_mem_pages : -1); 1796 // the exported memory object. Using the same buffer will result
1797 instance->set_memory_object(*memory_object); 1797 // in the exported memory object having a handle to the buffer
1798 // associated with a live instance.
1799 Handle<JSArrayBuffer> new_buffer =
1800 isolate_->factory()->NewJSArrayBuffer();
1801 JSArrayBuffer::Setup(new_buffer, isolate_, true,
1802 buffer->backing_store(),
1803 buffer->byte_length()->Number());
1804 new_buffer->set_is_neuterable(false);
1805 new_buffer->set_has_guard_region(true);
1806 memory_object = WasmMemoryObject::New(
1807 isolate_, new_buffer,
1808 (module_->max_mem_pages != 0) ? module_->max_mem_pages : -1);
1809 } else {
1810 memory_object = WasmMemoryObject::New(
1811 isolate_, buffer,
1812 (module_->max_mem_pages != 0) ? module_->max_mem_pages : -1);
1813 }
1798 } else { 1814 } else {
1799 memory_object = Handle<WasmMemoryObject>( 1815 memory_object = Handle<WasmMemoryObject>(
1800 instance->get_memory_object(), isolate_); 1816 instance->get_memory_object(), isolate_);
1801 DCHECK(WasmJs::IsWasmMemoryObject(isolate_, memory_object)); 1817 DCHECK(WasmJs::IsWasmMemoryObject(isolate_, memory_object));
1802 memory_object->ResetInstancesLink(isolate_); 1818 memory_object->ResetInstancesLink(isolate_);
1803 } 1819 }
1804 1820
1805 desc.set_value(memory_object); 1821 desc.set_value(memory_object);
1806 break; 1822 break;
1807 } 1823 }
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
2357 MaybeHandle<String> WasmCompiledModule::GetFunctionName( 2373 MaybeHandle<String> WasmCompiledModule::GetFunctionName(
2358 Handle<WasmCompiledModule> compiled_module, uint32_t func_index) { 2374 Handle<WasmCompiledModule> compiled_module, uint32_t func_index) {
2359 DCHECK_LT(func_index, compiled_module->module()->functions.size()); 2375 DCHECK_LT(func_index, compiled_module->module()->functions.size());
2360 WasmFunction& function = compiled_module->module()->functions[func_index]; 2376 WasmFunction& function = compiled_module->module()->functions[func_index];
2361 Isolate* isolate = compiled_module->GetIsolate(); 2377 Isolate* isolate = compiled_module->GetIsolate();
2362 MaybeHandle<String> string = ExtractStringFromModuleBytes( 2378 MaybeHandle<String> string = ExtractStringFromModuleBytes(
2363 isolate, compiled_module, function.name_offset, function.name_length); 2379 isolate, compiled_module, function.name_offset, function.name_length);
2364 if (!string.is_null()) return string.ToHandleChecked(); 2380 if (!string.is_null()) return string.ToHandleChecked();
2365 return {}; 2381 return {};
2366 } 2382 }
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/wasm/regression-670683.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698