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

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

Issue 2389263005: [wasm] grow_memory(0) is the same as memory_size() (Closed)
Patch Set: 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 | « no previous file | test/cctest/wasm/test-run-wasm-module.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 1804 matching lines...) Expand 10 before | Expand all | Expand 10 after
1815 Handle<JSArrayBuffer> buffer; 1815 Handle<JSArrayBuffer> buffer;
1816 if (!maybe_mem_buffer.ToHandle(&buffer)) { 1816 if (!maybe_mem_buffer.ToHandle(&buffer)) {
1817 return 0; 1817 return 0;
1818 } else { 1818 } else {
1819 return buffer->byte_length()->Number() / WasmModule::kPageSize; 1819 return buffer->byte_length()->Number() / WasmModule::kPageSize;
1820 } 1820 }
1821 } 1821 }
1822 1822
1823 int32_t GrowInstanceMemory(Isolate* isolate, Handle<JSObject> instance, 1823 int32_t GrowInstanceMemory(Isolate* isolate, Handle<JSObject> instance,
1824 uint32_t pages) { 1824 uint32_t pages) {
1825 if (pages == 0) {
1826 return GetInstanceMemorySize(isolate, instance);
1827 }
1825 Address old_mem_start = nullptr; 1828 Address old_mem_start = nullptr;
1826 uint32_t old_size = 0, new_size = 0; 1829 uint32_t old_size = 0, new_size = 0;
1827 1830
1828 MaybeHandle<JSArrayBuffer> maybe_mem_buffer = 1831 MaybeHandle<JSArrayBuffer> maybe_mem_buffer =
1829 GetInstanceMemory(isolate, instance); 1832 GetInstanceMemory(isolate, instance);
1830 Handle<JSArrayBuffer> old_buffer; 1833 Handle<JSArrayBuffer> old_buffer;
1831 if (!maybe_mem_buffer.ToHandle(&old_buffer)) { 1834 if (!maybe_mem_buffer.ToHandle(&old_buffer)) {
1832 // If module object does not have linear memory associated with it, 1835 // If module object does not have linear memory associated with it,
1833 // Allocate new array buffer of given size. 1836 // Allocate new array buffer of given size.
1834 // TODO(gdeepti): Fix bounds check to take into account size of memtype. 1837 // TODO(gdeepti): Fix bounds check to take into account size of memtype.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1913 WasmCompiledModule* compiled_module = 1916 WasmCompiledModule* compiled_module =
1914 WasmCompiledModule::cast(instance->GetInternalField(kWasmCompiledModule)); 1917 WasmCompiledModule::cast(instance->GetInternalField(kWasmCompiledModule));
1915 CHECK(compiled_module->has_weak_module_object()); 1918 CHECK(compiled_module->has_weak_module_object());
1916 CHECK(compiled_module->ptr_to_weak_module_object()->cleared()); 1919 CHECK(compiled_module->ptr_to_weak_module_object()->cleared());
1917 } 1920 }
1918 1921
1919 } // namespace testing 1922 } // namespace testing
1920 } // namespace wasm 1923 } // namespace wasm
1921 } // namespace internal 1924 } // namespace internal
1922 } // namespace v8 1925 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/cctest/wasm/test-run-wasm-module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698