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

Side by Side Diff: test/cctest/wasm/test-run-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 | « src/wasm/wasm-module.cc ('k') | no next file » | 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 <stdlib.h> 5 #include <stdlib.h>
6 #include <string.h> 6 #include <string.h>
7 7
8 #include "src/wasm/module-decoder.h" 8 #include "src/wasm/module-decoder.h"
9 #include "src/wasm/wasm-macro-gen.h" 9 #include "src/wasm/wasm-macro-gen.h"
10 #include "src/wasm/wasm-module-builder.h" 10 #include "src/wasm/wasm-module-builder.h"
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 Zone zone(&allocator); 276 Zone zone(&allocator);
277 277
278 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone); 278 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
279 WasmFunctionBuilder* f = builder->AddFunction(sigs.i_v()); 279 WasmFunctionBuilder* f = builder->AddFunction(sigs.i_v());
280 ExportAsMain(f); 280 ExportAsMain(f);
281 byte code[] = {WASM_GROW_MEMORY(WASM_I8(10)), WASM_DROP, WASM_MEMORY_SIZE}; 281 byte code[] = {WASM_GROW_MEMORY(WASM_I8(10)), WASM_DROP, WASM_MEMORY_SIZE};
282 f->EmitCode(code, sizeof(code)); 282 f->EmitCode(code, sizeof(code));
283 TestModule(&zone, builder, kExpectedValue); 283 TestModule(&zone, builder, kExpectedValue);
284 } 284 }
285 285
286 TEST(GrowMemoryZero) {
287 // Initial memory size is 16, see wasm-module-builder.cc
288 static const int kExpectedValue = 16;
289 TestSignatures sigs;
290 v8::internal::AccountingAllocator allocator;
291 Zone zone(&allocator);
292
293 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
294 WasmFunctionBuilder* f = builder->AddFunction(sigs.i_v());
295 ExportAsMain(f);
296 byte code[] = {WASM_GROW_MEMORY(WASM_I32V(0))};
297 f->EmitCode(code, sizeof(code));
298 TestModule(&zone, builder, kExpectedValue);
299 }
300
286 TEST(Run_WasmModule_GrowMemoryInIf) { 301 TEST(Run_WasmModule_GrowMemoryInIf) {
287 TestSignatures sigs; 302 TestSignatures sigs;
288 v8::internal::AccountingAllocator allocator; 303 v8::internal::AccountingAllocator allocator;
289 Zone zone(&allocator); 304 Zone zone(&allocator);
290 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone); 305 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
291 WasmFunctionBuilder* f = builder->AddFunction(sigs.i_v()); 306 WasmFunctionBuilder* f = builder->AddFunction(sigs.i_v());
292 ExportAsMain(f); 307 ExportAsMain(f);
293 byte code[] = {WASM_IF_ELSE_I(WASM_I32V(0), WASM_GROW_MEMORY(WASM_I32V(1)), 308 byte code[] = {WASM_IF_ELSE_I(WASM_I32V(0), WASM_GROW_MEMORY(WASM_I32V(1)),
294 WASM_I32V(12))}; 309 WASM_I32V(12))};
295 f->EmitCode(code, sizeof(code)); 310 f->EmitCode(code, sizeof(code));
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 } 422 }
408 423
409 v8::TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate)); 424 v8::TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate));
410 Handle<Object> params[1] = { 425 Handle<Object> params[1] = {
411 Handle<Object>(Smi::FromInt(25 * kPageSize), isolate)}; 426 Handle<Object>(Smi::FromInt(25 * kPageSize), isolate)};
412 testing::RunWasmModuleForTesting(isolate, instance, 1, params, 427 testing::RunWasmModuleForTesting(isolate, instance, 1, params,
413 ModuleOrigin::kWasmOrigin); 428 ModuleOrigin::kWasmOrigin);
414 CHECK(try_catch.HasCaught()); 429 CHECK(try_catch.HasCaught());
415 isolate->clear_pending_exception(); 430 isolate->clear_pending_exception();
416 } 431 }
OLDNEW
« no previous file with comments | « src/wasm/wasm-module.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698