Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(266)

Side by Side Diff: test/cctest/wasm/test-wasm-trap-position.cc

Issue 2640453003: [wasm] Fix and tighten memory validation (Closed)
Patch Set: Comments Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/wasm/test-run-wasm.cc ('k') | test/cctest/wasm/wasm-run-utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « test/cctest/wasm/test-run-wasm.cc ('k') | test/cctest/wasm/wasm-run-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698