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/encoder.h" | 8 #include "src/wasm/encoder.h" |
9 #include "src/wasm/module-decoder.h" | 9 #include "src/wasm/module-decoder.h" |
10 #include "src/wasm/wasm-js.h" | 10 #include "src/wasm/wasm-js.h" |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 CHECK(deserialized.ToLocal(&compiled_module)); | 244 CHECK(deserialized.ToLocal(&compiled_module)); |
245 Handle<JSObject> module_object = | 245 Handle<JSObject> module_object = |
246 Handle<JSObject>::cast(v8::Utils::OpenHandle(*compiled_module)); | 246 Handle<JSObject>::cast(v8::Utils::OpenHandle(*compiled_module)); |
247 Handle<JSObject> instance = | 247 Handle<JSObject> instance = |
248 WasmModule::Instantiate(isolate, module_object, | 248 WasmModule::Instantiate(isolate, module_object, |
249 Handle<JSReceiver>::null(), | 249 Handle<JSReceiver>::null(), |
250 Handle<JSArrayBuffer>::null()) | 250 Handle<JSArrayBuffer>::null()) |
251 .ToHandleChecked(); | 251 .ToHandleChecked(); |
252 Handle<Object> params[1] = {Handle<Object>(Smi::FromInt(41), isolate)}; | 252 Handle<Object> params[1] = {Handle<Object>(Smi::FromInt(41), isolate)}; |
253 int32_t result = testing::CallWasmFunctionForTesting( | 253 int32_t result = testing::CallWasmFunctionForTesting( |
254 isolate, instance, thrower, kFunctionName, 1, params, | 254 isolate, instance, &thrower, kFunctionName, 1, params, |
255 ModuleOrigin::kWasmOrigin); | 255 ModuleOrigin::kWasmOrigin); |
256 CHECK(result == 42); | 256 CHECK(result == 42); |
257 new_ctx->Exit(); | 257 new_ctx->Exit(); |
258 } | 258 } |
259 } | 259 } |
260 | 260 |
261 TEST(Run_WasmModule_MemSize_GrowMem) { | 261 TEST(Run_WasmModule_MemSize_GrowMem) { |
262 static const int kPageSize = 0x10000; | 262 static const int kPageSize = 0x10000; |
263 // Initial memory size = 16 + GrowMemory(10) | 263 // Initial memory size = 16 + GrowMemory(10) |
264 static const int kExpectedValue = kPageSize * 26; | 264 static const int kExpectedValue = kPageSize * 26; |
(...skipping 18 matching lines...) Expand all Loading... |
283 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone); | 283 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone); |
284 uint16_t f_index = builder->AddFunction(); | 284 uint16_t f_index = builder->AddFunction(); |
285 WasmFunctionBuilder* f = builder->FunctionAt(f_index); | 285 WasmFunctionBuilder* f = builder->FunctionAt(f_index); |
286 f->SetSignature(sigs.i_v()); | 286 f->SetSignature(sigs.i_v()); |
287 ExportAsMain(f); | 287 ExportAsMain(f); |
288 byte code[] = {WASM_IF_ELSE(WASM_I32V(0), WASM_GROW_MEMORY(WASM_I32V(1)), | 288 byte code[] = {WASM_IF_ELSE(WASM_I32V(0), WASM_GROW_MEMORY(WASM_I32V(1)), |
289 WASM_I32V(12))}; | 289 WASM_I32V(12))}; |
290 f->EmitCode(code, sizeof(code)); | 290 f->EmitCode(code, sizeof(code)); |
291 TestModule(&zone, builder, 12); | 291 TestModule(&zone, builder, 12); |
292 } | 292 } |
OLD | NEW |