| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 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 | 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 #ifndef WASM_RUN_UTILS_H | 5 #ifndef WASM_RUN_UTILS_H |
| 6 #define WASM_RUN_UTILS_H | 6 #define WASM_RUN_UTILS_H |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <stdlib.h> | 9 #include <stdlib.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 // limit number of globals. | 214 // limit number of globals. |
| 215 CHECK_LT(global_offset, kMaxGlobalsSize); | 215 CHECK_LT(global_offset, kMaxGlobalsSize); |
| 216 return &module->globals.back(); | 216 return &module->globals.back(); |
| 217 } | 217 } |
| 218 }; | 218 }; |
| 219 | 219 |
| 220 inline void TestBuildingGraph(Zone* zone, JSGraph* jsgraph, ModuleEnv* module, | 220 inline void TestBuildingGraph(Zone* zone, JSGraph* jsgraph, ModuleEnv* module, |
| 221 FunctionSig* sig, const byte* start, | 221 FunctionSig* sig, const byte* start, |
| 222 const byte* end) { | 222 const byte* end) { |
| 223 compiler::WasmGraphBuilder builder(zone, jsgraph, sig); | 223 compiler::WasmGraphBuilder builder(zone, jsgraph, sig); |
| 224 TreeResult result = BuildTFGraph(&builder, module, sig, start, end); | 224 TreeResult result = |
| 225 BuildTFGraph(zone->allocator(), &builder, module, sig, start, end); |
| 225 if (result.failed()) { | 226 if (result.failed()) { |
| 226 ptrdiff_t pc = result.error_pc - result.start; | 227 ptrdiff_t pc = result.error_pc - result.start; |
| 227 ptrdiff_t pt = result.error_pt - result.start; | 228 ptrdiff_t pt = result.error_pt - result.start; |
| 228 std::ostringstream str; | 229 std::ostringstream str; |
| 229 str << "Verification failed: " << result.error_code << " pc = +" << pc; | 230 str << "Verification failed: " << result.error_code << " pc = +" << pc; |
| 230 if (result.error_pt) str << ", pt = +" << pt; | 231 if (result.error_pt) str << ", pt = +" << pt; |
| 231 str << ", msg = " << result.error_msg.get(); | 232 str << ", msg = " << result.error_msg.get(); |
| 232 FATAL(str.str().c_str()); | 233 FATAL(str.str().c_str()); |
| 233 } | 234 } |
| 234 builder.Int64LoweringForTesting(); | 235 builder.Int64LoweringForTesting(); |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 ReturnType return_value; | 571 ReturnType return_value; |
| 571 int32_t result = runner.Call<void*, void*, void*, void*, void*>( | 572 int32_t result = runner.Call<void*, void*, void*, void*, void*>( |
| 572 &p0, &p1, &p2, &p3, &return_value); | 573 &p0, &p1, &p2, &p3, &return_value); |
| 573 CHECK_EQ(WASM_WRAPPER_RETURN_VALUE, result); | 574 CHECK_EQ(WASM_WRAPPER_RETURN_VALUE, result); |
| 574 return return_value; | 575 return return_value; |
| 575 } | 576 } |
| 576 | 577 |
| 577 byte AllocateLocal(LocalType type) { return compiler_.AllocateLocal(type); } | 578 byte AllocateLocal(LocalType type) { return compiler_.AllocateLocal(type); } |
| 578 | 579 |
| 579 protected: | 580 protected: |
| 580 Zone zone; | 581 ZoneForTesting zone; |
| 581 bool compiled_; | 582 bool compiled_; |
| 582 LocalType storage_[WASM_RUNNER_MAX_NUM_PARAMETERS]; | 583 LocalType storage_[WASM_RUNNER_MAX_NUM_PARAMETERS]; |
| 583 FunctionSig signature_; | 584 FunctionSig signature_; |
| 584 WasmFunctionCompiler compiler_; | 585 WasmFunctionCompiler compiler_; |
| 585 WasmFunctionWrapper<ReturnType> wrapper_; | 586 WasmFunctionWrapper<ReturnType> wrapper_; |
| 586 | 587 |
| 587 static size_t GetParameterCount(MachineType p0, MachineType p1, | 588 static size_t GetParameterCount(MachineType p0, MachineType p1, |
| 588 MachineType p2, MachineType p3) { | 589 MachineType p2, MachineType p3) { |
| 589 if (p0 == MachineType::None()) return 0; | 590 if (p0 == MachineType::None()) return 0; |
| 590 if (p1 == MachineType::None()) return 1; | 591 if (p1 == MachineType::None()) return 1; |
| 591 if (p2 == MachineType::None()) return 2; | 592 if (p2 == MachineType::None()) return 2; |
| 592 if (p3 == MachineType::None()) return 3; | 593 if (p3 == MachineType::None()) return 3; |
| 593 return 4; | 594 return 4; |
| 594 } | 595 } |
| 595 }; | 596 }; |
| 596 | 597 |
| 597 } // namespace | 598 } // namespace |
| 598 | 599 |
| 599 #endif | 600 #endif |
| OLD | NEW |