OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include <stdlib.h> | |
6 #include <string.h> | |
7 | |
8 #include "src/wasm/encoder.h" | |
9 #include "src/wasm/wasm-js.h" | |
10 #include "src/wasm/wasm-macro-gen.h" | |
11 #include "src/wasm/wasm-module.h" | |
12 #include "src/wasm/wasm-opcodes.h" | |
13 | |
14 #include "test/cctest/cctest.h" | |
15 #include "test/cctest/wasm/test-signatures.h" | |
16 | |
17 using namespace v8::base; | |
18 using namespace v8::internal; | |
19 using namespace v8::internal::compiler; | |
20 using namespace v8::internal::wasm; | |
21 | |
22 namespace { | |
23 void TestModule(Zone* zone, WasmModuleBuilder* builder, | |
24 int32_t expected_result) { | |
25 FLAG_wasm_simd_prototype = true; | |
26 FLAG_wasm_num_compilation_tasks = 0; | |
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 void ExportAsMain(WasmFunctionBuilder* f) { | |
39 static const char kMainName[] = "main"; | |
40 f->SetExported(); | |
41 f->SetName(kMainName, arraysize(kMainName) - 1); | |
42 } | |
43 } // namespace | |
44 | |
45 TEST(Run_WasmMoule_simd) { | |
46 v8::base::AccountingAllocator allocator; | |
47 Zone zone(&allocator); | |
48 TestSignatures sigs; | |
49 | |
50 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone); | |
51 uint16_t f_index = builder->AddFunction(); | |
52 WasmFunctionBuilder* f = builder->FunctionAt(f_index); | |
53 f->SetSignature(sigs.i_i()); | |
54 ExportAsMain(f); | |
55 | |
56 byte code[] = {WASM_SIMD_I32x4_EXTRACT_LANE( | |
57 WASM_SIMD_I32x4_SPLAT(WASM_I8(123)), WASM_I8(2))}; | |
58 f->EmitCode(code, sizeof(code)); | |
59 TestModule(&zone, builder, 123); | |
60 } | |
OLD | NEW |