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

Side by Side Diff: test/cctest/wasm/test-wasm-stack.cc

Issue 2090333002: Use instance type in Object::IsErrorObject(). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@RefactorToString
Patch Set: Rebase Created 4 years, 5 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 | « src/objects-inl.h ('k') | test/cctest/wasm/test-wasm-trap-position.cc » ('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/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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 } 44 }
45 } 45 }
46 46
47 struct ExceptionInfo { 47 struct ExceptionInfo {
48 const char* func_name; 48 const char* func_name;
49 int line_nr; 49 int line_nr;
50 int column; 50 int column;
51 }; 51 };
52 52
53 template <int N> 53 template <int N>
54 void CheckExceptionInfos(Isolate* isolate, Handle<Object> exc, 54 void CheckExceptionInfos(Handle<Object> exc,
55 const ExceptionInfo (&excInfos)[N]) { 55 const ExceptionInfo (&excInfos)[N]) {
56 // Check that it's indeed an Error object. 56 // Check that it's indeed an Error object.
57 CHECK(Object::IsErrorObject(isolate, exc)); 57 CHECK(exc->IsJSError());
58 58
59 // Extract stack frame from the exception. 59 // Extract stack frame from the exception.
60 Local<v8::Value> localExc = Utils::ToLocal(exc); 60 Local<v8::Value> localExc = Utils::ToLocal(exc);
61 v8::Local<v8::StackTrace> stack = v8::Exception::GetStackTrace(localExc); 61 v8::Local<v8::StackTrace> stack = v8::Exception::GetStackTrace(localExc);
62 PrintStackTrace(stack); 62 PrintStackTrace(stack);
63 CHECK(!stack.IsEmpty()); 63 CHECK(!stack.IsEmpty());
64 CHECK_EQ(N, stack->GetFrameCount()); 64 CHECK_EQ(N, stack->GetFrameCount());
65 65
66 for (int frameNr = 0; frameNr < N; ++frameNr) { 66 for (int frameNr = 0; frameNr < N; ++frameNr) {
67 v8::Local<v8::StackFrame> frame = stack->GetFrame(frameNr); 67 v8::Local<v8::StackFrame> frame = stack->GetFrame(frameNr);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 CHECK(returnObjMaybe.is_null()); 111 CHECK(returnObjMaybe.is_null());
112 112
113 // The column is 1-based, so add 1 to the actual byte offset. 113 // The column is 1-based, so add 1 to the actual byte offset.
114 ExceptionInfo expected_exceptions[] = { 114 ExceptionInfo expected_exceptions[] = {
115 {"a", 3, 8}, // - 115 {"a", 3, 8}, // -
116 {"js", 4, 2}, // - 116 {"js", 4, 2}, // -
117 {"<WASM UNNAMED>", static_cast<int>(wasm_index), 3}, // - 117 {"<WASM UNNAMED>", static_cast<int>(wasm_index), 3}, // -
118 {"<WASM UNNAMED>", static_cast<int>(wasm_index_2), 2}, // - 118 {"<WASM UNNAMED>", static_cast<int>(wasm_index_2), 2}, // -
119 {"callFn", 1, 24} // - 119 {"callFn", 1, 24} // -
120 }; 120 };
121 CheckExceptionInfos(isolate, maybe_exc.ToHandleChecked(), 121 CheckExceptionInfos(maybe_exc.ToHandleChecked(), expected_exceptions);
122 expected_exceptions);
123 } 122 }
124 123
125 // Trigger a trap in WASM, stack should be JS -> WASM -> WASM. 124 // Trigger a trap in WASM, stack should be JS -> WASM -> WASM.
126 TEST(CollectDetailedWasmStack_WasmError) { 125 TEST(CollectDetailedWasmStack_WasmError) {
127 TestSignatures sigs; 126 TestSignatures sigs;
128 TestingModule module; 127 TestingModule module;
129 128
130 WasmFunctionCompiler comp1(sigs.i_v(), &module, 129 WasmFunctionCompiler comp1(sigs.i_v(), &module,
131 ArrayVector("exec_unreachable")); 130 ArrayVector("exec_unreachable"));
132 // Set the execution context, such that a runtime error can be thrown. 131 // Set the execution context, such that a runtime error can be thrown.
(...skipping 21 matching lines...) Expand all
154 MaybeHandle<Object> maybe_return_obj = 153 MaybeHandle<Object> maybe_return_obj =
155 Execution::TryCall(isolate, js_trampoline, global, 1, args, &maybe_exc); 154 Execution::TryCall(isolate, js_trampoline, global, 1, args, &maybe_exc);
156 CHECK(maybe_return_obj.is_null()); 155 CHECK(maybe_return_obj.is_null());
157 156
158 // The column is 1-based, so add 1 to the actual byte offset. 157 // The column is 1-based, so add 1 to the actual byte offset.
159 ExceptionInfo expected_exceptions[] = { 158 ExceptionInfo expected_exceptions[] = {
160 {"<WASM UNNAMED>", static_cast<int>(wasm_index), 2}, // - 159 {"<WASM UNNAMED>", static_cast<int>(wasm_index), 2}, // -
161 {"<WASM UNNAMED>", static_cast<int>(wasm_index_2), 2}, // - 160 {"<WASM UNNAMED>", static_cast<int>(wasm_index_2), 2}, // -
162 {"callFn", 1, 24} //- 161 {"callFn", 1, 24} //-
163 }; 162 };
164 CheckExceptionInfos(isolate, maybe_exc.ToHandleChecked(), 163 CheckExceptionInfos(maybe_exc.ToHandleChecked(), expected_exceptions);
165 expected_exceptions);
166 } 164 }
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | test/cctest/wasm/test-wasm-trap-position.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698