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

Side by Side Diff: src/runtime/runtime-internal.cc

Issue 1924253002: [wasm] Patch trapping position into stack trace (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@pass-wasm-position-to-runtime
Patch Set: Created 4 years, 7 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
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/ast/prettyprinter.h" 8 #include "src/ast/prettyprinter.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/conversions.h" 10 #include "src/conversions.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 SealHandleScope shs(isolate); 94 SealHandleScope shs(isolate);
95 DCHECK_LE(0, args.length()); 95 DCHECK_LE(0, args.length());
96 return isolate->StackOverflow(); 96 return isolate->StackOverflow();
97 } 97 }
98 98
99 RUNTIME_FUNCTION(Runtime_ThrowWasmError) { 99 RUNTIME_FUNCTION(Runtime_ThrowWasmError) {
100 HandleScope scope(isolate); 100 HandleScope scope(isolate);
101 DCHECK_EQ(2, args.length()); 101 DCHECK_EQ(2, args.length());
102 CONVERT_SMI_ARG_CHECKED(message_id, 0); 102 CONVERT_SMI_ARG_CHECKED(message_id, 0);
103 CONVERT_SMI_ARG_CHECKED(byte_offset, 1); 103 CONVERT_SMI_ARG_CHECKED(byte_offset, 1);
104 USE(byte_offset); // TODO(clemensh): patch the stack trace with this offset 104 Handle<Object> error_obj = isolate->factory()->NewError(
105 Handle<Object> error = isolate->factory()->NewError(
106 static_cast<MessageTemplate::Template>(message_id)); 105 static_cast<MessageTemplate::Template>(message_id));
107 return isolate->Throw(*error); 106
107 // Now patch the given byte offset into the top-most frame (which must be a
titzer 2016/04/28 12:07:59 Can you adjust the comments a bit here to explain
Clemens Hammacher 2016/04/28 12:32:12 Done.
108 // wasm frame).
109 Handle<JSObject> error = Handle<JSObject>::cast(error_obj);
110 Handle<Object> stack_trace_obj = JSReceiver::GetDataProperty(
111 error, isolate->factory()->stack_trace_symbol());
112 // Patch the stack trace (array of <receiver, function, code, position>).
113 if (stack_trace_obj->IsJSArray()) {
114 Handle<FixedArray> stack_elements(
115 FixedArray::cast(JSArray::cast(*stack_trace_obj)->elements()));
116 DCHECK_EQ(1, stack_elements->length() % 4);
117 DCHECK(Code::cast(stack_elements->get(3))->kind() == Code::WASM_FUNCTION);
118 DCHECK(stack_elements->get(4)->IsSmi() &&
119 Smi::cast(stack_elements->get(4))->value() >= 0);
120 stack_elements->set(4, Smi::FromInt(-1 - byte_offset));
121 }
122 Handle<Object> detailed_stack_trace_obj = JSReceiver::GetDataProperty(
123 error, isolate->factory()->detailed_stack_trace_symbol());
124 // Patch the detailed stack trace (array of JSObjects with various
125 // properties).
126 if (detailed_stack_trace_obj->IsJSArray()) {
127 Handle<FixedArray> stack_elements(
128 FixedArray::cast(JSArray::cast(*detailed_stack_trace_obj)->elements()));
129 DCHECK_GE(stack_elements->length(), 1);
130 Handle<JSObject> top_frame(JSObject::cast(stack_elements->get(0)));
131 Handle<String> wasm_offset_key =
132 isolate->factory()->InternalizeOneByteString(
133 STATIC_CHAR_VECTOR("wasmByteOffset"));
134 LookupIterator it(top_frame, wasm_offset_key, top_frame,
135 LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
136 if (it.IsFound()) {
137 DCHECK(JSReceiver::GetDataProperty(&it)->IsSmi());
138 Maybe<bool> data_set = JSReceiver::SetDataProperty(
139 &it, handle(Smi::FromInt(byte_offset), isolate));
140 DCHECK(data_set.IsJust() && data_set.FromJust() == true);
141 }
142 }
143
144 return isolate->Throw(*error_obj);
108 } 145 }
109 146
110 RUNTIME_FUNCTION(Runtime_UnwindAndFindExceptionHandler) { 147 RUNTIME_FUNCTION(Runtime_UnwindAndFindExceptionHandler) {
111 SealHandleScope shs(isolate); 148 SealHandleScope shs(isolate);
112 DCHECK(args.length() == 0); 149 DCHECK(args.length() == 0);
113 return isolate->UnwindAndFindHandler(); 150 return isolate->UnwindAndFindHandler();
114 } 151 }
115 152
116 153
117 RUNTIME_FUNCTION(Runtime_PromoteScheduledException) { 154 RUNTIME_FUNCTION(Runtime_PromoteScheduledException) {
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 } 552 }
516 553
517 RUNTIME_FUNCTION(Runtime_RunMicrotasks) { 554 RUNTIME_FUNCTION(Runtime_RunMicrotasks) {
518 HandleScope scope(isolate); 555 HandleScope scope(isolate);
519 DCHECK(args.length() == 0); 556 DCHECK(args.length() == 0);
520 isolate->RunMicrotasks(); 557 isolate->RunMicrotasks();
521 return isolate->heap()->undefined_value(); 558 return isolate->heap()->undefined_value();
522 } 559 }
523 } // namespace internal 560 } // namespace internal
524 } // namespace v8 561 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698