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

Side by Side Diff: test/cctest/wasm/test-wasm-trap-position.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, 6 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-wasm-stack.cc ('k') | no next file » | 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 20 matching lines...) Expand all
31 } \ 31 } \
32 } while (0) 32 } while (0)
33 33
34 struct ExceptionInfo { 34 struct ExceptionInfo {
35 const char* func_name; 35 const char* func_name;
36 int line_nr; 36 int line_nr;
37 int column; 37 int column;
38 }; 38 };
39 39
40 template <int N> 40 template <int N>
41 void CheckExceptionInfos(Isolate* isolate, Handle<Object> exc, 41 void CheckExceptionInfos(Handle<Object> exc,
42 const ExceptionInfo (&excInfos)[N]) { 42 const ExceptionInfo (&excInfos)[N]) {
43 // Check that it's indeed an Error object. 43 // Check that it's indeed an Error object.
44 CHECK(Object::IsErrorObject(isolate, exc)); 44 CHECK(exc->IsJSError());
45 45
46 // Extract stack frame from the exception. 46 // Extract stack frame from the exception.
47 Local<v8::Value> localExc = Utils::ToLocal(exc); 47 Local<v8::Value> localExc = Utils::ToLocal(exc);
48 v8::Local<v8::StackTrace> stack = v8::Exception::GetStackTrace(localExc); 48 v8::Local<v8::StackTrace> stack = v8::Exception::GetStackTrace(localExc);
49 CHECK(!stack.IsEmpty()); 49 CHECK(!stack.IsEmpty());
50 CHECK_EQ(N, stack->GetFrameCount()); 50 CHECK_EQ(N, stack->GetFrameCount());
51 51
52 for (int frameNr = 0; frameNr < N; ++frameNr) { 52 for (int frameNr = 0; frameNr < N; ++frameNr) {
53 v8::Local<v8::StackFrame> frame = stack->GetFrame(frameNr); 53 v8::Local<v8::StackFrame> frame = stack->GetFrame(frameNr);
54 v8::String::Utf8Value funName(frame->GetFunctionName()); 54 v8::String::Utf8Value funName(frame->GetFunctionName());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 Handle<Object> args[] = {js_wasm_wrapper}; 86 Handle<Object> args[] = {js_wasm_wrapper};
87 MaybeHandle<Object> returnObjMaybe = 87 MaybeHandle<Object> returnObjMaybe =
88 Execution::TryCall(isolate, js_trampoline, global, 1, args, &maybe_exc); 88 Execution::TryCall(isolate, js_trampoline, global, 1, args, &maybe_exc);
89 CHECK(returnObjMaybe.is_null()); 89 CHECK(returnObjMaybe.is_null());
90 90
91 // The column is 1-based, so add 1 to the actual byte offset. 91 // The column is 1-based, so add 1 to the actual byte offset.
92 ExceptionInfo expected_exceptions[] = { 92 ExceptionInfo expected_exceptions[] = {
93 {"<WASM UNNAMED>", static_cast<int>(wasm_index), 2}, // -- 93 {"<WASM UNNAMED>", static_cast<int>(wasm_index), 2}, // --
94 {"callFn", 1, 24} // -- 94 {"callFn", 1, 24} // --
95 }; 95 };
96 CheckExceptionInfos(isolate, maybe_exc.ToHandleChecked(), 96 CheckExceptionInfos(maybe_exc.ToHandleChecked(), expected_exceptions);
97 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 TestSignatures sigs; 101 TestSignatures sigs;
103 TestingModule module; 102 TestingModule module;
104 103
105 WasmFunctionCompiler comp1(sigs.v_v(), &module, ArrayVector("mem_oob")); 104 WasmFunctionCompiler comp1(sigs.v_v(), &module, ArrayVector("mem_oob"));
106 // Set the execution context, such that a runtime error can be thrown. 105 // Set the execution context, such that a runtime error can be thrown.
107 comp1.SetModuleContext(); 106 comp1.SetModuleContext();
(...skipping 21 matching lines...) Expand all
129 MaybeHandle<Object> returnObjMaybe = 128 MaybeHandle<Object> returnObjMaybe =
130 Execution::TryCall(isolate, js_trampoline, global, 1, args, &maybe_exc); 129 Execution::TryCall(isolate, js_trampoline, global, 1, args, &maybe_exc);
131 CHECK(returnObjMaybe.is_null()); 130 CHECK(returnObjMaybe.is_null());
132 131
133 // The column is 1-based, so add 1 to the actual byte offset. 132 // The column is 1-based, so add 1 to the actual byte offset.
134 ExceptionInfo expected_exceptions[] = { 133 ExceptionInfo expected_exceptions[] = {
135 {"<WASM UNNAMED>", static_cast<int>(wasm_index), 7}, // -- 134 {"<WASM UNNAMED>", static_cast<int>(wasm_index), 7}, // --
136 {"<WASM UNNAMED>", static_cast<int>(wasm_index_2), 3}, // -- 135 {"<WASM UNNAMED>", static_cast<int>(wasm_index_2), 3}, // --
137 {"callFn", 1, 24} // -- 136 {"callFn", 1, 24} // --
138 }; 137 };
139 CheckExceptionInfos(isolate, maybe_exc.ToHandleChecked(), 138 CheckExceptionInfos(maybe_exc.ToHandleChecked(), expected_exceptions);
140 expected_exceptions);
141 } 139 }
OLDNEW
« no previous file with comments | « test/cctest/wasm/test-wasm-stack.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698