OLD | NEW |
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 Loading... |
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 |
256 TEST(Run_WasmModule_MemSize_GrowMem) { | 271 TEST(Run_WasmModule_MemSize_GrowMem) { |
257 // Initial memory size = 16 + GrowMemory(10) | 272 // Initial memory size = 16 + GrowMemory(10) |
258 static const int kExpectedValue = 26; | 273 static const int kExpectedValue = 26; |
259 TestSignatures sigs; | 274 TestSignatures sigs; |
260 v8::internal::AccountingAllocator allocator; | 275 v8::internal::AccountingAllocator allocator; |
261 Zone zone(&allocator); | 276 Zone zone(&allocator); |
262 | 277 |
263 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone); | 278 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone); |
264 WasmFunctionBuilder* f = builder->AddFunction(sigs.i_v()); | 279 WasmFunctionBuilder* f = builder->AddFunction(sigs.i_v()); |
265 ExportAsMain(f); | 280 ExportAsMain(f); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 } | 407 } |
393 | 408 |
394 v8::TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate)); | 409 v8::TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate)); |
395 Handle<Object> params[1] = { | 410 Handle<Object> params[1] = { |
396 Handle<Object>(Smi::FromInt(25 * kPageSize), isolate)}; | 411 Handle<Object>(Smi::FromInt(25 * kPageSize), isolate)}; |
397 testing::RunWasmModuleForTesting(isolate, instance, 1, params, | 412 testing::RunWasmModuleForTesting(isolate, instance, 1, params, |
398 ModuleOrigin::kWasmOrigin); | 413 ModuleOrigin::kWasmOrigin); |
399 CHECK(try_catch.HasCaught()); | 414 CHECK(try_catch.HasCaught()); |
400 isolate->clear_pending_exception(); | 415 isolate->clear_pending_exception(); |
401 } | 416 } |
OLD | NEW |