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/assembler-inl.h" | 5 #include "src/assembler-inl.h" |
6 #include "src/trap-handler/trap-handler.h" | |
7 #include "src/wasm/wasm-macro-gen.h" | 6 #include "src/wasm/wasm-macro-gen.h" |
8 #include "test/cctest/cctest.h" | 7 #include "test/cctest/cctest.h" |
9 #include "test/cctest/compiler/value-helper.h" | 8 #include "test/cctest/compiler/value-helper.h" |
10 #include "test/cctest/wasm/wasm-run-utils.h" | 9 #include "test/cctest/wasm/wasm-run-utils.h" |
11 #include "test/common/wasm/test-signatures.h" | 10 #include "test/common/wasm/test-signatures.h" |
12 | 11 |
13 using namespace v8::base; | 12 using namespace v8::base; |
14 using namespace v8::internal; | 13 using namespace v8::internal; |
15 using namespace v8::internal::compiler; | 14 using namespace v8::internal::compiler; |
16 using namespace v8::internal::wasm; | 15 using namespace v8::internal::wasm; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // Line and column are 1-based, so add 1 for the expected wasm output. | 91 // Line and column are 1-based, so add 1 for the expected wasm output. |
93 ExceptionInfo expected_exceptions[] = { | 92 ExceptionInfo expected_exceptions[] = { |
94 {"main", static_cast<int>(wasm_index) + 1, 2}, // -- | 93 {"main", static_cast<int>(wasm_index) + 1, 2}, // -- |
95 {"callFn", 1, 24} // -- | 94 {"callFn", 1, 24} // -- |
96 }; | 95 }; |
97 CheckExceptionInfos(maybe_exc.ToHandleChecked(), expected_exceptions); | 96 CheckExceptionInfos(maybe_exc.ToHandleChecked(), expected_exceptions); |
98 } | 97 } |
99 | 98 |
100 // Trigger a trap for loading from out-of-bounds. | 99 // Trigger a trap for loading from out-of-bounds. |
101 TEST(IllegalLoad) { | 100 TEST(IllegalLoad) { |
102 if (trap_handler::UseTrapHandler()) { | |
103 // r.module().AddMemory() does not allocate guard pages, so we skip this | |
104 // test for now when using trap handlers. The simple out of bounds access | |
105 // case is covered by mjsunit tests, so we are still getting test coverage. | |
106 // | |
107 // TODO(eholk): make this test work with trap handlers. | |
108 return; | |
109 } | |
110 WasmRunner<void> r(kExecuteCompiled); | 101 WasmRunner<void> r(kExecuteCompiled); |
111 TestSignatures sigs; | 102 TestSignatures sigs; |
112 // Set the execution context, such that a runtime error can be thrown. | 103 // Set the execution context, such that a runtime error can be thrown. |
113 r.SetModuleContext(); | 104 r.SetModuleContext(); |
114 r.module().AddMemory(0L); | 105 r.module().AddMemory(0L); |
115 | 106 |
116 BUILD(r, WASM_IF(WASM_ONE, WASM_SEQ(WASM_LOAD_MEM(MachineType::Int32(), | 107 BUILD(r, WASM_IF(WASM_ONE, WASM_SEQ(WASM_LOAD_MEM(MachineType::Int32(), |
117 WASM_I32V_1(-3)), | 108 WASM_I32V_1(-3)), |
118 WASM_DROP))); | 109 WASM_DROP))); |
119 uint32_t wasm_index_1 = r.function()->func_index; | 110 uint32_t wasm_index_1 = r.function()->func_index; |
(...skipping 21 matching lines...) Expand all Loading... |
141 CHECK(returnObjMaybe.is_null()); | 132 CHECK(returnObjMaybe.is_null()); |
142 | 133 |
143 // Line and column are 1-based, so add 1 for the expected wasm output. | 134 // Line and column are 1-based, so add 1 for the expected wasm output. |
144 ExceptionInfo expected_exceptions[] = { | 135 ExceptionInfo expected_exceptions[] = { |
145 {"main", static_cast<int>(wasm_index_1) + 1, 8}, // -- | 136 {"main", static_cast<int>(wasm_index_1) + 1, 8}, // -- |
146 {"call_main", static_cast<int>(wasm_index_2) + 1, 3}, // -- | 137 {"call_main", static_cast<int>(wasm_index_2) + 1, 3}, // -- |
147 {"callFn", 1, 24} // -- | 138 {"callFn", 1, 24} // -- |
148 }; | 139 }; |
149 CheckExceptionInfos(maybe_exc.ToHandleChecked(), expected_exceptions); | 140 CheckExceptionInfos(maybe_exc.ToHandleChecked(), expected_exceptions); |
150 } | 141 } |
OLD | NEW |