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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 Handle<JSObject> module_object = | 249 Handle<JSObject> module_object = |
250 Handle<JSObject>::cast(v8::Utils::OpenHandle(*compiled_module)); | 250 Handle<JSObject>::cast(v8::Utils::OpenHandle(*compiled_module)); |
251 Handle<FixedArray> compiled_part = | 251 Handle<FixedArray> compiled_part = |
252 handle(FixedArray::cast(module_object->GetInternalField(0))); | 252 handle(FixedArray::cast(module_object->GetInternalField(0))); |
253 Handle<JSObject> instance = | 253 Handle<JSObject> instance = |
254 WasmModule::Instantiate(isolate, compiled_part, | 254 WasmModule::Instantiate(isolate, compiled_part, |
255 Handle<JSReceiver>::null(), | 255 Handle<JSReceiver>::null(), |
256 Handle<JSArrayBuffer>::null()) | 256 Handle<JSArrayBuffer>::null()) |
257 .ToHandleChecked(); | 257 .ToHandleChecked(); |
258 Handle<Object> params[1] = {Handle<Object>(Smi::FromInt(41), isolate)}; | 258 Handle<Object> params[1] = {Handle<Object>(Smi::FromInt(41), isolate)}; |
259 int32_t result = testing::CallFunction(isolate, instance, &thrower, | 259 int32_t result = testing::CallWasmFunctionForTesting( |
260 kFunctionName, 1, params); | 260 isolate, instance, thrower, kFunctionName, 1, params); |
261 CHECK(result == 42); | 261 CHECK(result == 42); |
262 new_ctx->Exit(); | 262 new_ctx->Exit(); |
263 } | 263 } |
264 } | 264 } |
265 | 265 |
266 TEST(Run_WasmModule_MemSize_GrowMem) { | 266 TEST(Run_WasmModule_MemSize_GrowMem) { |
267 static const int kPageSize = 0x10000; | 267 static const int kPageSize = 0x10000; |
268 // Initial memory size = 16 + GrowMemory(10) | 268 // Initial memory size = 16 + GrowMemory(10) |
269 static const int kExpectedValue = kPageSize * 26; | 269 static const int kExpectedValue = kPageSize * 26; |
270 TestSignatures sigs; | 270 TestSignatures sigs; |
(...skipping 17 matching lines...) Expand all Loading... |
288 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone); | 288 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone); |
289 uint16_t f_index = builder->AddFunction(); | 289 uint16_t f_index = builder->AddFunction(); |
290 WasmFunctionBuilder* f = builder->FunctionAt(f_index); | 290 WasmFunctionBuilder* f = builder->FunctionAt(f_index); |
291 f->SetSignature(sigs.i_v()); | 291 f->SetSignature(sigs.i_v()); |
292 ExportAsMain(f); | 292 ExportAsMain(f); |
293 byte code[] = {WASM_IF_ELSE(WASM_I32V(0), WASM_GROW_MEMORY(WASM_I32V(1)), | 293 byte code[] = {WASM_IF_ELSE(WASM_I32V(0), WASM_GROW_MEMORY(WASM_I32V(1)), |
294 WASM_I32V(12))}; | 294 WASM_I32V(12))}; |
295 f->EmitCode(code, sizeof(code)); | 295 f->EmitCode(code, sizeof(code)); |
296 TestModule(&zone, builder, 12); | 296 TestModule(&zone, builder, 12); |
297 } | 297 } |
OLD | NEW |