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

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

Issue 1830663002: [wasm] Binary 11: AST changes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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-js.cc ('k') | test/mjsunit/wasm/asm-wasm.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/encoder.h" 8 #include "src/wasm/encoder.h"
9 #include "src/wasm/wasm-js.h" 9 #include "src/wasm/wasm-js.h"
10 #include "src/wasm/wasm-macro-gen.h" 10 #include "src/wasm/wasm-macro-gen.h"
(...skipping 19 matching lines...) Expand all
30 CHECK_EQ(expected_result, result); 30 CHECK_EQ(expected_result, result);
31 } 31 }
32 } // namespace 32 } // namespace
33 33
34 34
35 // A raw test that skips the WasmModuleBuilder. 35 // A raw test that skips the WasmModuleBuilder.
36 TEST(Run_WasmModule_CallAdd_rev) { 36 TEST(Run_WasmModule_CallAdd_rev) {
37 static const byte data[] = { 37 static const byte data[] = {
38 WASM_MODULE_HEADER, 38 WASM_MODULE_HEADER,
39 // sig#0 ------------------------------------------ 39 // sig#0 ------------------------------------------
40 WASM_SECTION_SIGNATURES_SIZE + 7, // Section size. 40 WASM_SECTION_SIGNATURES_SIZE + 7, // Section size.
41 WASM_SECTION_SIGNATURES, 2, 0, kLocalI32, // void -> int 41 WASM_SECTION_SIGNATURES, 2, // --
42 2, kLocalI32, kLocalI32, kLocalI32, // int,int -> int 42 0, kLocalI32, // void -> int
43 2, kLocalI32, kLocalI32, kLocalI32, // int,int -> int
43 // func#0 (main) ---------------------------------- 44 // func#0 (main) ----------------------------------
44 WASM_SECTION_FUNCTIONS_SIZE + 24, WASM_SECTION_FUNCTIONS, 2, 45 WASM_SECTION_FUNCTIONS_SIZE + 25, WASM_SECTION_FUNCTIONS, 2,
45 kDeclFunctionExport, 0, 0, // sig index 46 kDeclFunctionExport, 0, 0, // sig index
46 7, 0, // body size 47 8, 0, // body size
47 0, // locals 48 0, // locals
48 kExprCallFunction, 1, // --
49 kExprI8Const, 77, // -- 49 kExprI8Const, 77, // --
50 kExprI8Const, 22, // -- 50 kExprI8Const, 22, // --
51 kExprCallFunction, 2, 1, // --
51 // func#1 ----------------------------------------- 52 // func#1 -----------------------------------------
52 0, // no name, not exported 53 0, // no name, not exported
53 1, 0, // sig index 54 1, 0, // sig index
54 6, 0, // body size 55 6, 0, // body size
55 0, // locals 56 0, // locals
56 kExprI32Add, // --
57 kExprGetLocal, 0, // -- 57 kExprGetLocal, 0, // --
58 kExprGetLocal, 1, // -- 58 kExprGetLocal, 1, // --
59 kExprI32Add, // --
59 }; 60 };
60 61
61 Isolate* isolate = CcTest::InitIsolateOnce(); 62 Isolate* isolate = CcTest::InitIsolateOnce();
62 HandleScope scope(isolate); 63 HandleScope scope(isolate);
63 WasmJs::InstallWasmFunctionMap(isolate, isolate->native_context()); 64 WasmJs::InstallWasmFunctionMap(isolate, isolate->native_context());
64 int32_t result = 65 int32_t result =
65 CompileAndRunWasmModule(isolate, data, data + arraysize(data)); 66 CompileAndRunWasmModule(isolate, data, data + arraysize(data));
66 CHECK_EQ(99, result); 67 CHECK_EQ(99, result);
67 } 68 }
68 69
(...skipping 17 matching lines...) Expand all
86 TEST(Run_WasmModule_CallAdd) { 87 TEST(Run_WasmModule_CallAdd) {
87 v8::base::AccountingAllocator allocator; 88 v8::base::AccountingAllocator allocator;
88 Zone zone(&allocator); 89 Zone zone(&allocator);
89 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone); 90 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
90 uint16_t f1_index = builder->AddFunction(); 91 uint16_t f1_index = builder->AddFunction();
91 WasmFunctionBuilder* f = builder->FunctionAt(f1_index); 92 WasmFunctionBuilder* f = builder->FunctionAt(f1_index);
92 f->ReturnType(kAstI32); 93 f->ReturnType(kAstI32);
93 uint16_t param1 = f->AddParam(kAstI32); 94 uint16_t param1 = f->AddParam(kAstI32);
94 uint16_t param2 = f->AddParam(kAstI32); 95 uint16_t param2 = f->AddParam(kAstI32);
95 byte code1[] = {WASM_I32_ADD(WASM_GET_LOCAL(param1), WASM_GET_LOCAL(param2))}; 96 byte code1[] = {WASM_I32_ADD(WASM_GET_LOCAL(param1), WASM_GET_LOCAL(param2))};
96 uint32_t local_indices1[] = {2, 4}; 97 f->EmitCode(code1, sizeof(code1));
97 f->EmitCode(code1, sizeof(code1), local_indices1, sizeof(local_indices1) / 4);
98 uint16_t f2_index = builder->AddFunction(); 98 uint16_t f2_index = builder->AddFunction();
99 f = builder->FunctionAt(f2_index); 99 f = builder->FunctionAt(f2_index);
100 f->ReturnType(kAstI32); 100 f->ReturnType(kAstI32);
101 f->Exported(1); 101 f->Exported(1);
102 byte code2[] = {WASM_CALL_FUNCTION(f1_index, WASM_I8(77), WASM_I8(22))}; 102 byte code2[] = {WASM_CALL_FUNCTION2(f1_index, WASM_I8(77), WASM_I8(22))};
103 f->EmitCode(code2, sizeof(code2)); 103 f->EmitCode(code2, sizeof(code2));
104 WasmModuleWriter* writer = builder->Build(&zone); 104 WasmModuleWriter* writer = builder->Build(&zone);
105 TestModule(writer->WriteTo(&zone), 99); 105 TestModule(writer->WriteTo(&zone), 99);
106 } 106 }
107 107
108 108
109 TEST(Run_WasmModule_ReadLoadedDataSegment) { 109 TEST(Run_WasmModule_ReadLoadedDataSegment) {
110 static const byte kDataSegmentDest0 = 12; 110 static const byte kDataSegmentDest0 = 12;
111 v8::base::AccountingAllocator allocator; 111 v8::base::AccountingAllocator allocator;
112 Zone zone(&allocator); 112 Zone zone(&allocator);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 f->ReturnType(kAstI32); 181 f->ReturnType(kAstI32);
182 byte code1[] = { 182 byte code1[] = {
183 WASM_I32_ADD(WASM_LOAD_GLOBAL(global1), WASM_LOAD_GLOBAL(global2))}; 183 WASM_I32_ADD(WASM_LOAD_GLOBAL(global1), WASM_LOAD_GLOBAL(global2))};
184 f->EmitCode(code1, sizeof(code1)); 184 f->EmitCode(code1, sizeof(code1));
185 uint16_t f2_index = builder->AddFunction(); 185 uint16_t f2_index = builder->AddFunction();
186 f = builder->FunctionAt(f2_index); 186 f = builder->FunctionAt(f2_index);
187 f->ReturnType(kAstI32); 187 f->ReturnType(kAstI32);
188 f->Exported(1); 188 f->Exported(1);
189 byte code2[] = {WASM_STORE_GLOBAL(global1, WASM_I32V_1(56)), 189 byte code2[] = {WASM_STORE_GLOBAL(global1, WASM_I32V_1(56)),
190 WASM_STORE_GLOBAL(global2, WASM_I32V_1(41)), 190 WASM_STORE_GLOBAL(global2, WASM_I32V_1(41)),
191 WASM_RETURN(WASM_CALL_FUNCTION0(f1_index))}; 191 WASM_RETURN1(WASM_CALL_FUNCTION0(f1_index))};
192 f->EmitCode(code2, sizeof(code2)); 192 f->EmitCode(code2, sizeof(code2));
193 WasmModuleWriter* writer = builder->Build(&zone); 193 WasmModuleWriter* writer = builder->Build(&zone);
194 TestModule(writer->WriteTo(&zone), 97); 194 TestModule(writer->WriteTo(&zone), 97);
195 } 195 }
OLDNEW
« no previous file with comments | « test/cctest/wasm/test-run-wasm-js.cc ('k') | test/mjsunit/wasm/asm-wasm.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698