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

Side by Side Diff: test/cctest/wasm/test-run-wasm-module.cc

Issue 2391223002: Revert of [wasm] Call a runtime function for a MemorySize instruction. (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 | « test/cctest/wasm/test-run-wasm.cc ('k') | test/mjsunit/regress/wasm/regression-651961.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 <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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 .ToHandleChecked(); 246 .ToHandleChecked();
247 Handle<Object> params[1] = {Handle<Object>(Smi::FromInt(41), isolate)}; 247 Handle<Object> params[1] = {Handle<Object>(Smi::FromInt(41), isolate)};
248 int32_t result = testing::CallWasmFunctionForTesting( 248 int32_t result = testing::CallWasmFunctionForTesting(
249 isolate, instance, &thrower, kFunctionName, 1, params, 249 isolate, instance, &thrower, kFunctionName, 1, params,
250 ModuleOrigin::kWasmOrigin); 250 ModuleOrigin::kWasmOrigin);
251 CHECK(result == 42); 251 CHECK(result == 42);
252 new_ctx->Exit(); 252 new_ctx->Exit();
253 } 253 }
254 } 254 }
255 255
256 TEST(MemorySize) {
257 // Initial memory size is 16, see wasm-module-builder.cc
258 static const int kExpectedValue = 16;
259 TestSignatures sigs;
260 v8::internal::AccountingAllocator allocator;
261 Zone zone(&allocator);
262
263 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
264 WasmFunctionBuilder* f = builder->AddFunction(sigs.i_v());
265 ExportAsMain(f);
266 byte code[] = {WASM_MEMORY_SIZE};
267 f->EmitCode(code, sizeof(code));
268 TestModule(&zone, builder, kExpectedValue);
269 }
270
271 TEST(Run_WasmModule_MemSize_GrowMem) { 256 TEST(Run_WasmModule_MemSize_GrowMem) {
272 // Initial memory size = 16 + GrowMemory(10) 257 // Initial memory size = 16 + GrowMemory(10)
273 static const int kExpectedValue = 26; 258 static const int kExpectedValue = 26;
274 TestSignatures sigs; 259 TestSignatures sigs;
275 v8::internal::AccountingAllocator allocator; 260 v8::internal::AccountingAllocator allocator;
276 Zone zone(&allocator); 261 Zone zone(&allocator);
277 262
278 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone); 263 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
279 WasmFunctionBuilder* f = builder->AddFunction(sigs.i_v()); 264 WasmFunctionBuilder* f = builder->AddFunction(sigs.i_v());
280 ExportAsMain(f); 265 ExportAsMain(f);
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 } 392 }
408 393
409 v8::TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate)); 394 v8::TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate));
410 Handle<Object> params[1] = { 395 Handle<Object> params[1] = {
411 Handle<Object>(Smi::FromInt(25 * kPageSize), isolate)}; 396 Handle<Object>(Smi::FromInt(25 * kPageSize), isolate)};
412 testing::RunWasmModuleForTesting(isolate, instance, 1, params, 397 testing::RunWasmModuleForTesting(isolate, instance, 1, params,
413 ModuleOrigin::kWasmOrigin); 398 ModuleOrigin::kWasmOrigin);
414 CHECK(try_catch.HasCaught()); 399 CHECK(try_catch.HasCaught());
415 isolate->clear_pending_exception(); 400 isolate->clear_pending_exception();
416 } 401 }
OLDNEW
« no previous file with comments | « test/cctest/wasm/test-run-wasm.cc ('k') | test/mjsunit/regress/wasm/regression-651961.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698