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 #include "src/wasm/wasm-macro-gen.h" | 5 #include "src/wasm/wasm-macro-gen.h" |
6 | 6 |
7 #include "test/cctest/cctest.h" | 7 #include "test/cctest/cctest.h" |
8 #include "test/cctest/compiler/value-helper.h" | 8 #include "test/cctest/compiler/value-helper.h" |
9 #include "test/cctest/wasm/wasm-run-utils.h" | 9 #include "test/cctest/wasm/wasm-run-utils.h" |
10 #include "test/common/wasm/test-signatures.h" | 10 #include "test/common/wasm/test-signatures.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 }; | 93 }; |
94 CheckExceptionInfos(maybe_exc.ToHandleChecked(), expected_exceptions); | 94 CheckExceptionInfos(maybe_exc.ToHandleChecked(), expected_exceptions); |
95 } | 95 } |
96 | 96 |
97 // Trigger a trap for loading from out-of-bounds. | 97 // Trigger a trap for loading from out-of-bounds. |
98 TEST(IllegalLoad) { | 98 TEST(IllegalLoad) { |
99 WasmRunner<void> r(kExecuteCompiled); | 99 WasmRunner<void> r(kExecuteCompiled); |
100 TestSignatures sigs; | 100 TestSignatures sigs; |
101 // Set the execution context, such that a runtime error can be thrown. | 101 // Set the execution context, such that a runtime error can be thrown. |
102 r.SetModuleContext(); | 102 r.SetModuleContext(); |
| 103 r.module().AddMemory(0L); |
103 | 104 |
104 BUILD(r, WASM_IF(WASM_ONE, WASM_SEQ(WASM_LOAD_MEM(MachineType::Int32(), | 105 BUILD(r, WASM_IF(WASM_ONE, WASM_SEQ(WASM_LOAD_MEM(MachineType::Int32(), |
105 WASM_I32V_1(-3)), | 106 WASM_I32V_1(-3)), |
106 WASM_DROP))); | 107 WASM_DROP))); |
107 uint32_t wasm_index_1 = r.function()->func_index; | 108 uint32_t wasm_index_1 = r.function()->func_index; |
108 | 109 |
109 WasmFunctionCompiler& f2 = r.NewFunction<void>("call_main"); | 110 WasmFunctionCompiler& f2 = r.NewFunction<void>("call_main"); |
110 // Insert a NOP such that the position of the call is not one. | 111 // Insert a NOP such that the position of the call is not one. |
111 BUILD(f2, WASM_NOP, WASM_CALL_FUNCTION0(wasm_index_1)); | 112 BUILD(f2, WASM_NOP, WASM_CALL_FUNCTION0(wasm_index_1)); |
112 uint32_t wasm_index_2 = f2.function_index(); | 113 uint32_t wasm_index_2 = f2.function_index(); |
(...skipping 15 matching lines...) Expand all Loading... |
128 CHECK(returnObjMaybe.is_null()); | 129 CHECK(returnObjMaybe.is_null()); |
129 | 130 |
130 // Line and column are 1-based, so add 1 for the expected wasm output. | 131 // Line and column are 1-based, so add 1 for the expected wasm output. |
131 ExceptionInfo expected_exceptions[] = { | 132 ExceptionInfo expected_exceptions[] = { |
132 {"main", static_cast<int>(wasm_index_1) + 1, 8}, // -- | 133 {"main", static_cast<int>(wasm_index_1) + 1, 8}, // -- |
133 {"call_main", static_cast<int>(wasm_index_2) + 1, 3}, // -- | 134 {"call_main", static_cast<int>(wasm_index_2) + 1, 3}, // -- |
134 {"callFn", 1, 24} // -- | 135 {"callFn", 1, 24} // -- |
135 }; | 136 }; |
136 CheckExceptionInfos(maybe_exc.ToHandleChecked(), expected_exceptions); | 137 CheckExceptionInfos(maybe_exc.ToHandleChecked(), expected_exceptions); |
137 } | 138 } |
OLD | NEW |