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

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

Issue 2406133003: [wasm] Decouple function name and exported name in WasmFunctionBuilder (Closed)
Patch Set: Change interface to Vector<const char>; avoids size_t/int confusion Created 4 years, 2 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-builder.cc ('k') | test/fuzzer/wasm-code.cc » ('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/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 30 matching lines...) Expand all
41 Isolate* isolate = CcTest::InitIsolateOnce(); 41 Isolate* isolate = CcTest::InitIsolateOnce();
42 HandleScope scope(isolate); 42 HandleScope scope(isolate);
43 testing::SetupIsolateForWasmModule(isolate); 43 testing::SetupIsolateForWasmModule(isolate);
44 v8::TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate)); 44 v8::TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate));
45 testing::CompileAndRunWasmModule(isolate, buffer.begin(), buffer.end(), 45 testing::CompileAndRunWasmModule(isolate, buffer.begin(), buffer.end(),
46 ModuleOrigin::kWasmOrigin); 46 ModuleOrigin::kWasmOrigin);
47 CHECK(try_catch.HasCaught()); 47 CHECK(try_catch.HasCaught());
48 isolate->clear_pending_exception(); 48 isolate->clear_pending_exception();
49 } 49 }
50 50
51 void ExportAs(WasmFunctionBuilder* f, const char* name) { 51 void ExportAsMain(WasmFunctionBuilder* f) { f->ExportAs(CStrVector("main")); }
52 f->SetExported();
53 f->SetName(name, static_cast<int>(strlen(name)));
54 }
55
56 void ExportAsMain(WasmFunctionBuilder* f) {
57 static const char kMainName[] = "main";
58 ExportAs(f, kMainName);
59 }
60 52
61 } // namespace 53 } // namespace
62 54
63 TEST(Run_WasmModule_Return114) { 55 TEST(Run_WasmModule_Return114) {
64 static const int32_t kReturnValue = 114; 56 static const int32_t kReturnValue = 114;
65 TestSignatures sigs; 57 TestSignatures sigs;
66 v8::internal::AccountingAllocator allocator; 58 v8::internal::AccountingAllocator allocator;
67 Zone zone(&allocator); 59 Zone zone(&allocator);
68 60
69 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone); 61 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 static const char* kFunctionName = "increment"; 175 static const char* kFunctionName = "increment";
184 v8::internal::AccountingAllocator allocator; 176 v8::internal::AccountingAllocator allocator;
185 Zone zone(&allocator); 177 Zone zone(&allocator);
186 178
187 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone); 179 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
188 TestSignatures sigs; 180 TestSignatures sigs;
189 181
190 WasmFunctionBuilder* f = builder->AddFunction(sigs.i_i()); 182 WasmFunctionBuilder* f = builder->AddFunction(sigs.i_i());
191 byte code[] = {WASM_GET_LOCAL(0), kExprI32Const, 1, kExprI32Add}; 183 byte code[] = {WASM_GET_LOCAL(0), kExprI32Const, 1, kExprI32Add};
192 f->EmitCode(code, sizeof(code)); 184 f->EmitCode(code, sizeof(code));
193 ExportAs(f, kFunctionName); 185 f->ExportAs(CStrVector(kFunctionName));
194 186
195 ZoneBuffer buffer(&zone); 187 ZoneBuffer buffer(&zone);
196 builder->WriteTo(buffer); 188 builder->WriteTo(buffer);
197 189
198 Isolate* isolate = CcTest::InitIsolateOnce(); 190 Isolate* isolate = CcTest::InitIsolateOnce();
199 ErrorThrower thrower(isolate, ""); 191 ErrorThrower thrower(isolate, "");
200 uint8_t* bytes = nullptr; 192 uint8_t* bytes = nullptr;
201 size_t bytes_size = 0; 193 size_t bytes_size = 0;
202 v8::WasmCompiledModule::SerializedModule data; 194 v8::WasmCompiledModule::SerializedModule data;
203 { 195 {
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 527
536 TEST(Run_WasmModule_Global_f32) { 528 TEST(Run_WasmModule_Global_f32) {
537 RunWasmModuleGlobalInitTest<float>(kAstF32, -983.9f); 529 RunWasmModuleGlobalInitTest<float>(kAstF32, -983.9f);
538 RunWasmModuleGlobalInitTest<float>(kAstF32, 1122.99f); 530 RunWasmModuleGlobalInitTest<float>(kAstF32, 1122.99f);
539 } 531 }
540 532
541 TEST(Run_WasmModule_Global_f64) { 533 TEST(Run_WasmModule_Global_f64) {
542 RunWasmModuleGlobalInitTest<double>(kAstF64, -833.9); 534 RunWasmModuleGlobalInitTest<double>(kAstF64, -833.9);
543 RunWasmModuleGlobalInitTest<double>(kAstF64, 86374.25); 535 RunWasmModuleGlobalInitTest<double>(kAstF64, 86374.25);
544 } 536 }
OLDNEW
« no previous file with comments | « src/wasm/wasm-module-builder.cc ('k') | test/fuzzer/wasm-code.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698