Commit a03ac68c authored by ahaas's avatar ahaas Committed by Commit bot

[wasm] grow_memory(0) is the same as memory_size()

BUG=chromium:653264
TEST=cctest/test-run-wasm-module/GrowMemoryZero
R=titzer@chromium.org

Review-Url: https://codereview.chromium.org/2389263005
Cr-Commit-Position: refs/heads/master@{#40030}
parent f5c439db
......@@ -1822,6 +1822,9 @@ int32_t GetInstanceMemorySize(Isolate* isolate, Handle<JSObject> instance) {
int32_t GrowInstanceMemory(Isolate* isolate, Handle<JSObject> instance,
uint32_t pages) {
if (pages == 0) {
return GetInstanceMemorySize(isolate, instance);
}
Address old_mem_start = nullptr;
uint32_t old_size = 0, new_size = 0;
......
......@@ -283,6 +283,21 @@ TEST(Run_WasmModule_MemSize_GrowMem) {
TestModule(&zone, builder, kExpectedValue);
}
TEST(GrowMemoryZero) {
// Initial memory size is 16, see wasm-module-builder.cc
static const int kExpectedValue = 16;
TestSignatures sigs;
v8::internal::AccountingAllocator allocator;
Zone zone(&allocator);
WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
WasmFunctionBuilder* f = builder->AddFunction(sigs.i_v());
ExportAsMain(f);
byte code[] = {WASM_GROW_MEMORY(WASM_I32V(0))};
f->EmitCode(code, sizeof(code));
TestModule(&zone, builder, kExpectedValue);
}
TEST(Run_WasmModule_GrowMemoryInIf) {
TestSignatures sigs;
v8::internal::AccountingAllocator allocator;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment