| 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/test-signatures.h" | 9 #include "test/cctest/wasm/test-signatures.h" |
| 10 #include "test/cctest/wasm/wasm-run-utils.h" | 10 #include "test/cctest/wasm/wasm-run-utils.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 {"callFn", 1}}; | 115 {"callFn", 1}}; |
| 116 CheckExceptionInfos(isolate, maybe_exc.ToHandleChecked(), | 116 CheckExceptionInfos(isolate, maybe_exc.ToHandleChecked(), |
| 117 expected_exceptions); | 117 expected_exceptions); |
| 118 } | 118 } |
| 119 | 119 |
| 120 // Trigger a trap in WASM, stack should be JS -> WASM -> WASM. | 120 // Trigger a trap in WASM, stack should be JS -> WASM -> WASM. |
| 121 TEST(CollectDetailedWasmStack_WasmError) { | 121 TEST(CollectDetailedWasmStack_WasmError) { |
| 122 TestSignatures sigs; | 122 TestSignatures sigs; |
| 123 TestingModule module; | 123 TestingModule module; |
| 124 | 124 |
| 125 WasmFunctionCompiler comp1(sigs.i_v(), &module, "exec_unreachable"); | 125 WasmFunctionCompiler comp1(sigs.i_v(), &module, |
| 126 ArrayVector("exec_unreachable")); |
| 126 // Set the execution context, such that a runtime error can be thrown. | 127 // Set the execution context, such that a runtime error can be thrown. |
| 127 comp1.SetModuleContext(); | 128 comp1.SetModuleContext(); |
| 128 BUILD(comp1, WASM_UNREACHABLE); | 129 BUILD(comp1, WASM_UNREACHABLE); |
| 129 uint32_t wasm_index = comp1.CompileAndAdd(); | 130 uint32_t wasm_index = comp1.CompileAndAdd(); |
| 130 | 131 |
| 131 WasmFunctionCompiler comp2(sigs.i_v(), &module, "call_exec_unreachable"); | 132 WasmFunctionCompiler comp2(sigs.i_v(), &module, |
| 133 ArrayVector("call_exec_unreachable")); |
| 132 BUILD(comp2, WASM_CALL_FUNCTION0(wasm_index)); | 134 BUILD(comp2, WASM_CALL_FUNCTION0(wasm_index)); |
| 133 uint32_t wasm_index_2 = comp2.CompileAndAdd(); | 135 uint32_t wasm_index_2 = comp2.CompileAndAdd(); |
| 134 | 136 |
| 135 Handle<JSFunction> js_wasm_wrapper = module.WrapCode(wasm_index_2); | 137 Handle<JSFunction> js_wasm_wrapper = module.WrapCode(wasm_index_2); |
| 136 | 138 |
| 137 Handle<JSFunction> js_trampoline = Handle<JSFunction>::cast( | 139 Handle<JSFunction> js_trampoline = Handle<JSFunction>::cast( |
| 138 v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast( | 140 v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast( |
| 139 CompileRun("(function callFn(fn) { fn(); })")))); | 141 CompileRun("(function callFn(fn) { fn(); })")))); |
| 140 | 142 |
| 141 Isolate* isolate = js_wasm_wrapper->GetIsolate(); | 143 Isolate* isolate = js_wasm_wrapper->GetIsolate(); |
| 142 isolate->SetCaptureStackTraceForUncaughtExceptions(true, 10, | 144 isolate->SetCaptureStackTraceForUncaughtExceptions(true, 10, |
| 143 v8::StackTrace::kOverview); | 145 v8::StackTrace::kOverview); |
| 144 Handle<Object> global(isolate->context()->global_object(), isolate); | 146 Handle<Object> global(isolate->context()->global_object(), isolate); |
| 145 MaybeHandle<Object> maybe_exc; | 147 MaybeHandle<Object> maybe_exc; |
| 146 Handle<Object> args[] = {js_wasm_wrapper}; | 148 Handle<Object> args[] = {js_wasm_wrapper}; |
| 147 MaybeHandle<Object> maybe_return_obj = | 149 MaybeHandle<Object> maybe_return_obj = |
| 148 Execution::TryCall(isolate, js_trampoline, global, 1, args, &maybe_exc); | 150 Execution::TryCall(isolate, js_trampoline, global, 1, args, &maybe_exc); |
| 149 CHECK(maybe_return_obj.is_null()); | 151 CHECK(maybe_return_obj.is_null()); |
| 150 | 152 |
| 151 // Line number is 1-based, with 0 == kNoLineNumberInfo. | 153 // Line number is 1-based, with 0 == kNoLineNumberInfo. |
| 152 ExceptionInfo expected_exceptions[] = { | 154 ExceptionInfo expected_exceptions[] = { |
| 153 {"<WASM>", 0}, // Comment to prevent clang-format complaints. | 155 {"<WASM>", 0}, // Comment to prevent clang-format complaints. |
| 154 {"<WASM>", 0}, | 156 {"<WASM>", 0}, |
| 155 {"callFn", 1}}; | 157 {"callFn", 1}}; |
| 156 CheckExceptionInfos(isolate, maybe_exc.ToHandleChecked(), | 158 CheckExceptionInfos(isolate, maybe_exc.ToHandleChecked(), |
| 157 expected_exceptions); | 159 expected_exceptions); |
| 158 } | 160 } |
| OLD | NEW |