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

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

Issue 1573213002: [wasm] Create a wrapper function for WASM.asmCompileRun(). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Disable arm64 Created 4 years, 11 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/encoder.h" 8 #include "src/wasm/encoder.h"
9 #include "src/wasm/wasm-js.h"
9 #include "src/wasm/wasm-macro-gen.h" 10 #include "src/wasm/wasm-macro-gen.h"
10 #include "src/wasm/wasm-module.h" 11 #include "src/wasm/wasm-module.h"
11 #include "src/wasm/wasm-opcodes.h" 12 #include "src/wasm/wasm-opcodes.h"
12 13
13 #include "test/cctest/cctest.h" 14 #include "test/cctest/cctest.h"
14 15
15 using namespace v8::base; 16 using namespace v8::base;
16 using namespace v8::internal; 17 using namespace v8::internal;
17 using namespace v8::internal::compiler; 18 using namespace v8::internal::compiler;
18 using namespace v8::internal::wasm; 19 using namespace v8::internal::wasm;
19 20
20 21
22 #if !V8_TARGET_ARCH_ARM64
23 // TODO(titzer): fix arm64 frame alignment.
21 namespace { 24 namespace {
22 void TestModule(WasmModuleIndex* module, int32_t expected_result) { 25 void TestModule(WasmModuleIndex* module, int32_t expected_result) {
23 Isolate* isolate = CcTest::InitIsolateOnce(); 26 Isolate* isolate = CcTest::InitIsolateOnce();
27 HandleScope scope(isolate);
28 WasmJs::InstallWasmFunctionMap(isolate, isolate->native_context());
24 int32_t result = 29 int32_t result =
25 CompileAndRunWasmModule(isolate, module->Begin(), module->End()); 30 CompileAndRunWasmModule(isolate, module->Begin(), module->End());
26 CHECK_EQ(expected_result, result); 31 CHECK_EQ(expected_result, result);
27 } 32 }
28 } // namespace 33 } // namespace
29 34
30 35
31 // A raw test that skips the WasmModuleBuilder. 36 // A raw test that skips the WasmModuleBuilder.
32 TEST(Run_WasmModule_CallAdd_rev) { 37 TEST(Run_WasmModule_CallAdd_rev) {
33 static const byte data[] = { 38 static const byte data[] = {
34 // sig#0 ------------------------------------------ 39 // sig#0 ------------------------------------------
35 kDeclSignatures, 2, 0, kLocalI32, // void -> int 40 kDeclSignatures, 2, 0, kLocalI32, // void -> int
36 2, kLocalI32, kLocalI32, kLocalI32, // int,int -> int 41 2, kLocalI32, kLocalI32, kLocalI32, // int,int -> int
37 // func#0 (main) ---------------------------------- 42 // func#0 (main) ----------------------------------
38 kDeclFunctions, 2, kDeclFunctionExport, 0, 0, // sig index 43 kDeclFunctions, 2, kDeclFunctionExport, 0, 0, // sig index
39 6, 0, // body size 44 6, 0, // body size
40 kExprCallFunction, 1, // -- 45 kExprCallFunction, 1, // --
41 kExprI8Const, 77, // -- 46 kExprI8Const, 77, // --
42 kExprI8Const, 22, // -- 47 kExprI8Const, 22, // --
43 // func#1 ----------------------------------------- 48 // func#1 -----------------------------------------
44 0, // no name, not exported 49 0, // no name, not exported
45 1, 0, // sig index 50 1, 0, // sig index
46 5, 0, // body size 51 5, 0, // body size
47 kExprI32Add, // -- 52 kExprI32Add, // --
48 kExprGetLocal, 0, // -- 53 kExprGetLocal, 0, // --
49 kExprGetLocal, 1, // -- 54 kExprGetLocal, 1, // --
50 }; 55 };
51 56
52 Isolate* isolate = CcTest::InitIsolateOnce(); 57 Isolate* isolate = CcTest::InitIsolateOnce();
58 HandleScope scope(isolate);
59 WasmJs::InstallWasmFunctionMap(isolate, isolate->native_context());
53 int32_t result = 60 int32_t result =
54 CompileAndRunWasmModule(isolate, data, data + arraysize(data)); 61 CompileAndRunWasmModule(isolate, data, data + arraysize(data));
55 CHECK_EQ(99, result); 62 CHECK_EQ(99, result);
56 } 63 }
57 64
58 65
59 TEST(Run_WasmModule_Return114) { 66 TEST(Run_WasmModule_Return114) {
60 static const int32_t kReturnValue = 114; 67 static const int32_t kReturnValue = 114;
61 Zone zone; 68 Zone zone;
62 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone); 69 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 f->ReturnType(kAstI32); 197 f->ReturnType(kAstI32);
191 f->Exported(1); 198 f->Exported(1);
192 byte code2[] = {WASM_STORE_GLOBAL(global1, WASM_I32(56)), 199 byte code2[] = {WASM_STORE_GLOBAL(global1, WASM_I32(56)),
193 WASM_STORE_GLOBAL(global2, WASM_I32(41)), 200 WASM_STORE_GLOBAL(global2, WASM_I32(41)),
194 WASM_RETURN(WASM_CALL_FUNCTION0(f1_index))}; 201 WASM_RETURN(WASM_CALL_FUNCTION0(f1_index))};
195 f->EmitCode(code2, sizeof(code2)); 202 f->EmitCode(code2, sizeof(code2));
196 WasmModuleWriter* writer = builder->Build(&zone); 203 WasmModuleWriter* writer = builder->Build(&zone);
197 TestModule(writer->WriteTo(&zone), 97); 204 TestModule(writer->WriteTo(&zone), 97);
198 } 205 }
199 #endif 206 #endif
207
208 #endif // !V8_TARGET_ARCH_ARM64
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