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

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

Issue 2386183004: [wasm] Call a runtime function for a MemorySize instruction. (Closed)
Patch Set: Comments addressed Created 4 years, 2 months 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 | « src/wasm/wasm-module.h ('k') | test/cctest/wasm/test-run-wasm.cc » ('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 1791 matching lines...) Expand 10 before | Expand all | Expand 10 after
1802 1802
1803 void SetInstanceMemory(Handle<JSObject> instance, JSArrayBuffer* buffer) { 1803 void SetInstanceMemory(Handle<JSObject> instance, JSArrayBuffer* buffer) {
1804 DisallowHeapAllocation no_gc; 1804 DisallowHeapAllocation no_gc;
1805 DCHECK(IsWasmObject(*instance)); 1805 DCHECK(IsWasmObject(*instance));
1806 instance->SetInternalField(kWasmMemArrayBuffer, buffer); 1806 instance->SetInternalField(kWasmMemArrayBuffer, buffer);
1807 WasmCompiledModule* module = 1807 WasmCompiledModule* module =
1808 WasmCompiledModule::cast(instance->GetInternalField(kWasmCompiledModule)); 1808 WasmCompiledModule::cast(instance->GetInternalField(kWasmCompiledModule));
1809 module->set_ptr_to_heap(buffer); 1809 module->set_ptr_to_heap(buffer);
1810 } 1810 }
1811 1811
1812 int32_t GetInstanceMemorySize(Isolate* isolate, Handle<JSObject> instance) {
1813 MaybeHandle<JSArrayBuffer> maybe_mem_buffer =
1814 GetInstanceMemory(isolate, instance);
1815 Handle<JSArrayBuffer> buffer;
1816 if (!maybe_mem_buffer.ToHandle(&buffer)) {
1817 return 0;
1818 } else {
1819 return buffer->byte_length()->Number() / WasmModule::kPageSize;
1820 }
1821 }
1822
1812 int32_t GrowInstanceMemory(Isolate* isolate, Handle<JSObject> instance, 1823 int32_t GrowInstanceMemory(Isolate* isolate, Handle<JSObject> instance,
1813 uint32_t pages) { 1824 uint32_t pages) {
1814 Address old_mem_start = nullptr; 1825 Address old_mem_start = nullptr;
1815 uint32_t old_size = 0, new_size = 0; 1826 uint32_t old_size = 0, new_size = 0;
1816 1827
1817 MaybeHandle<JSArrayBuffer> maybe_mem_buffer = 1828 MaybeHandle<JSArrayBuffer> maybe_mem_buffer =
1818 GetInstanceMemory(isolate, instance); 1829 GetInstanceMemory(isolate, instance);
1819 Handle<JSArrayBuffer> old_buffer; 1830 Handle<JSArrayBuffer> old_buffer;
1820 if (!maybe_mem_buffer.ToHandle(&old_buffer)) { 1831 if (!maybe_mem_buffer.ToHandle(&old_buffer)) {
1821 // If module object does not have linear memory associated with it, 1832 // If module object does not have linear memory associated with it,
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1902 WasmCompiledModule* compiled_module = 1913 WasmCompiledModule* compiled_module =
1903 WasmCompiledModule::cast(instance->GetInternalField(kWasmCompiledModule)); 1914 WasmCompiledModule::cast(instance->GetInternalField(kWasmCompiledModule));
1904 CHECK(compiled_module->has_weak_module_object()); 1915 CHECK(compiled_module->has_weak_module_object());
1905 CHECK(compiled_module->ptr_to_weak_module_object()->cleared()); 1916 CHECK(compiled_module->ptr_to_weak_module_object()->cleared());
1906 } 1917 }
1907 1918
1908 } // namespace testing 1919 } // namespace testing
1909 } // namespace wasm 1920 } // namespace wasm
1910 } // namespace internal 1921 } // namespace internal
1911 } // namespace v8 1922 } // namespace v8
OLDNEW
« no previous file with comments | « src/wasm/wasm-module.h ('k') | test/cctest/wasm/test-run-wasm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698