Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef V8_TEST_RUN_WASM_MODULE_HELPER_H | |
| 6 #define V8_TEST_RUN_WASM_MODULE_HELPER_H | |
| 7 | |
| 8 #include <stdlib.h> | |
| 9 #include <string.h> | |
| 10 | |
| 11 #include "src/wasm/encoder.h" | |
| 12 #include "src/wasm/module-decoder.h" | |
| 13 #include "src/wasm/wasm-js.h" | |
| 14 #include "src/wasm/wasm-module.h" | |
| 15 | |
| 16 #include "test/cctest/cctest.h" | |
| 17 | |
| 18 using namespace v8::base; | |
| 19 using namespace v8::internal; | |
| 20 using namespace v8::internal::compiler; | |
| 21 using namespace v8::internal::wasm; | |
| 22 | |
| 23 class TestRunWasmModuleHelper { | |
|
bradnelson
2016/08/31 22:42:08
Land as a separate refactor (but I think you said
titzer
2016/09/05 13:01:45
I'm not sure we need to extract this out. It shoul
aseemgarg
2016/10/10 17:35:17
removed file. Moved to different test type.
| |
| 24 public: | |
| 25 static void TestModule(Zone* zone, WasmModuleBuilder* builder, | |
| 26 int32_t expected_result) { | |
| 27 ZoneBuffer buffer(zone); | |
| 28 builder->WriteTo(buffer); | |
| 29 | |
| 30 Isolate* isolate = CcTest::InitIsolateOnce(); | |
| 31 HandleScope scope(isolate); | |
| 32 WasmJs::InstallWasmFunctionMap(isolate, isolate->native_context()); | |
| 33 int32_t result = | |
| 34 testing::CompileAndRunWasmModule(isolate, buffer.begin(), buffer.end()); | |
| 35 CHECK_EQ(expected_result, result); | |
| 36 } | |
| 37 | |
| 38 static void ExportAs(WasmFunctionBuilder* f, const char* name) { | |
| 39 f->SetExported(); | |
| 40 f->SetName(name, static_cast<int>(strlen(name))); | |
| 41 } | |
| 42 | |
| 43 static void ExportAsMain(WasmFunctionBuilder* f) { | |
| 44 static const char kMainName[] = "main"; | |
| 45 ExportAs(f, kMainName); | |
| 46 } | |
| 47 }; | |
| 48 | |
| 49 #endif // V8_TEST_RUN_WASM_MODULE_HELPER_H | |
| OLD | NEW |