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

Side by Side Diff: src/frames.cc

Issue 2069823003: [wasm] Enable wasm frame inspection for debugging (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@split-wasm-debug
Patch Set: fix gcmole reports 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/frames.h" 5 #include "src/frames.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "src/ast/ast.h" 9 #include "src/ast/ast.h"
10 #include "src/ast/scopeinfo.h" 10 #include "src/ast/scopeinfo.h"
11 #include "src/base/bits.h" 11 #include "src/base/bits.h"
12 #include "src/deoptimizer.h" 12 #include "src/deoptimizer.h"
13 #include "src/frames-inl.h" 13 #include "src/frames-inl.h"
14 #include "src/full-codegen/full-codegen.h" 14 #include "src/full-codegen/full-codegen.h"
15 #include "src/register-configuration.h" 15 #include "src/register-configuration.h"
16 #include "src/safepoint-table.h" 16 #include "src/safepoint-table.h"
17 #include "src/string-stream.h" 17 #include "src/string-stream.h"
18 #include "src/vm-state-inl.h" 18 #include "src/vm-state-inl.h"
19 #include "src/wasm/wasm-module.h"
19 20
20 namespace v8 { 21 namespace v8 {
21 namespace internal { 22 namespace internal {
22 23
23 ReturnAddressLocationResolver 24 ReturnAddressLocationResolver
24 StackFrame::return_address_location_resolver_ = NULL; 25 StackFrame::return_address_location_resolver_ = NULL;
25 26
26 27
27 // Iterator that supports traversing the stack handlers of a 28 // Iterator that supports traversing the stack handlers of a
28 // particular frame. Needs to know the top of the handler chain. 29 // particular frame. Needs to know the top of the handler chain.
(...skipping 27 matching lines...) Expand all
56 #define INITIALIZE_SINGLETON(type, field) field##_(this), 57 #define INITIALIZE_SINGLETON(type, field) field##_(this),
57 StackFrameIteratorBase::StackFrameIteratorBase(Isolate* isolate, 58 StackFrameIteratorBase::StackFrameIteratorBase(Isolate* isolate,
58 bool can_access_heap_objects) 59 bool can_access_heap_objects)
59 : isolate_(isolate), 60 : isolate_(isolate),
60 STACK_FRAME_TYPE_LIST(INITIALIZE_SINGLETON) 61 STACK_FRAME_TYPE_LIST(INITIALIZE_SINGLETON)
61 frame_(NULL), handler_(NULL), 62 frame_(NULL), handler_(NULL),
62 can_access_heap_objects_(can_access_heap_objects) { 63 can_access_heap_objects_(can_access_heap_objects) {
63 } 64 }
64 #undef INITIALIZE_SINGLETON 65 #undef INITIALIZE_SINGLETON
65 66
66
67 StackFrameIterator::StackFrameIterator(Isolate* isolate) 67 StackFrameIterator::StackFrameIterator(Isolate* isolate)
68 : StackFrameIteratorBase(isolate, true) { 68 : StackFrameIterator(isolate, isolate->thread_local_top()) {}
69 Reset(isolate->thread_local_top());
70 }
71
72 69
73 StackFrameIterator::StackFrameIterator(Isolate* isolate, ThreadLocalTop* t) 70 StackFrameIterator::StackFrameIterator(Isolate* isolate, ThreadLocalTop* t)
74 : StackFrameIteratorBase(isolate, true) { 71 : StackFrameIteratorBase(isolate, true) {
75 Reset(t); 72 Reset(t);
76 } 73 }
77 74
78
79 void StackFrameIterator::Advance() { 75 void StackFrameIterator::Advance() {
80 DCHECK(!done()); 76 DCHECK(!done());
81 // Compute the state of the calling frame before restoring 77 // Compute the state of the calling frame before restoring
82 // callee-saved registers and unwinding handlers. This allows the 78 // callee-saved registers and unwinding handlers. This allows the
83 // frame code that computes the caller state to access the top 79 // frame code that computes the caller state to access the top
84 // handler and the value of any callee-saved register if needed. 80 // handler and the value of any callee-saved register if needed.
85 StackFrame::State state; 81 StackFrame::State state;
86 StackFrame::Type type = frame_->GetCallerState(&state); 82 StackFrame::Type type = frame_->GetCallerState(&state);
87 83
88 // Unwind handlers corresponding to the current frame. 84 // Unwind handlers corresponding to the current frame.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 } 154 }
159 155
160 156
161 // ------------------------------------------------------------------------- 157 // -------------------------------------------------------------------------
162 158
163 StackTraceFrameIterator::StackTraceFrameIterator(Isolate* isolate) 159 StackTraceFrameIterator::StackTraceFrameIterator(Isolate* isolate)
164 : iterator_(isolate) { 160 : iterator_(isolate) {
165 if (!done() && !IsValidFrame(iterator_.frame())) Advance(); 161 if (!done() && !IsValidFrame(iterator_.frame())) Advance();
166 } 162 }
167 163
164 StackTraceFrameIterator::StackTraceFrameIterator(Isolate* isolate,
165 StackFrame::Id id)
166 : StackTraceFrameIterator(isolate) {
167 while (!done() && frame()->id() != id) Advance();
168 }
168 169
169 void StackTraceFrameIterator::Advance() { 170 void StackTraceFrameIterator::Advance() {
170 do { 171 do {
171 iterator_.Advance(); 172 iterator_.Advance();
172 } while (!done() && !IsValidFrame(iterator_.frame())); 173 } while (!done() && !IsValidFrame(iterator_.frame()));
173 } 174 }
174 175
175 bool StackTraceFrameIterator::IsValidFrame(StackFrame* frame) const { 176 bool StackTraceFrameIterator::IsValidFrame(StackFrame* frame) const {
176 if (frame->is_java_script()) { 177 if (frame->is_java_script()) {
177 JavaScriptFrame* jsFrame = static_cast<JavaScriptFrame*>(frame); 178 JavaScriptFrame* jsFrame = static_cast<JavaScriptFrame*>(frame);
178 if (!jsFrame->function()->IsJSFunction()) return false; 179 if (!jsFrame->function()->IsJSFunction()) return false;
179 Object* script = jsFrame->function()->shared()->script(); 180 Object* script = jsFrame->function()->shared()->script();
180 // Don't show functions from native scripts to user. 181 // Don't show functions from native scripts to user.
181 return (script->IsScript() && 182 return (script->IsScript() &&
182 Script::TYPE_NATIVE != Script::cast(script)->type()); 183 Script::TYPE_NATIVE != Script::cast(script)->type());
183 } 184 }
184 // apart from javascript, only wasm is valid 185 // apart from javascript, only wasm is valid
185 return frame->is_wasm(); 186 return frame->is_wasm();
186 } 187 }
187 188
189 void StackTraceFrameIterator::AdvanceToArgumentsFrame() {
190 if (!is_javascript() || !javascript_frame()->has_adapted_arguments()) return;
191 iterator_.Advance();
192 DCHECK(iterator_.frame()->is_arguments_adaptor());
193 }
188 194
189 // ------------------------------------------------------------------------- 195 // -------------------------------------------------------------------------
190 196
191 197
192 SafeStackFrameIterator::SafeStackFrameIterator( 198 SafeStackFrameIterator::SafeStackFrameIterator(
193 Isolate* isolate, 199 Isolate* isolate,
194 Address fp, Address sp, Address js_entry_sp) 200 Address fp, Address sp, Address js_entry_sp)
195 : StackFrameIteratorBase(isolate, false), 201 : StackFrameIteratorBase(isolate, false),
196 low_bound_(sp), 202 low_bound_(sp),
197 high_bound_(js_entry_sp), 203 high_bound_(js_entry_sp),
(...skipping 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1332 Code* WasmFrame::unchecked_code() const { 1338 Code* WasmFrame::unchecked_code() const {
1333 return static_cast<Code*>(isolate()->FindCodeObject(pc())); 1339 return static_cast<Code*>(isolate()->FindCodeObject(pc()));
1334 } 1340 }
1335 1341
1336 void WasmFrame::Iterate(ObjectVisitor* v) const { IterateCompiledFrame(v); } 1342 void WasmFrame::Iterate(ObjectVisitor* v) const { IterateCompiledFrame(v); }
1337 1343
1338 Address WasmFrame::GetCallerStackPointer() const { 1344 Address WasmFrame::GetCallerStackPointer() const {
1339 return fp() + ExitFrameConstants::kCallerSPOffset; 1345 return fp() + ExitFrameConstants::kCallerSPOffset;
1340 } 1346 }
1341 1347
1342 Object* WasmFrame::wasm_obj() { 1348 Object* WasmFrame::wasm_obj() const {
1343 FixedArray* deopt_data = LookupCode()->deoptimization_data(); 1349 FixedArray* deopt_data = LookupCode()->deoptimization_data();
1344 DCHECK(deopt_data->length() == 2); 1350 DCHECK(deopt_data->length() == 2);
1345 return deopt_data->get(0); 1351 return deopt_data->get(0);
1346 } 1352 }
1347 1353
1348 uint32_t WasmFrame::function_index() { 1354 uint32_t WasmFrame::function_index() const {
1349 FixedArray* deopt_data = LookupCode()->deoptimization_data(); 1355 FixedArray* deopt_data = LookupCode()->deoptimization_data();
1350 DCHECK(deopt_data->length() == 2); 1356 DCHECK(deopt_data->length() == 2);
1351 Object* func_index_obj = deopt_data->get(1); 1357 return Smi::cast(deopt_data->get(1))->value();
1352 if (func_index_obj->IsUndefined(isolate())) return static_cast<uint32_t>(-1);
1353 if (func_index_obj->IsSmi()) return Smi::cast(func_index_obj)->value();
1354 DCHECK(func_index_obj->IsHeapNumber());
1355 uint32_t val = static_cast<uint32_t>(-1);
1356 func_index_obj->ToUint32(&val);
1357 DCHECK(val != static_cast<uint32_t>(-1));
1358 return val;
1359 } 1358 }
1360 1359
1361 namespace { 1360 namespace {
1362 1361
1363 1362
1364 void PrintFunctionSource(StringStream* accumulator, SharedFunctionInfo* shared, 1363 void PrintFunctionSource(StringStream* accumulator, SharedFunctionInfo* shared,
1365 Code* code) { 1364 Code* code) {
1366 if (FLAG_max_stack_trace_source_length != 0 && code != NULL) { 1365 if (FLAG_max_stack_trace_source_length != 0 && code != NULL) {
1367 std::ostringstream os; 1366 std::ostringstream os;
1368 os << "--------- s o u r c e c o d e ---------\n" 1367 os << "--------- s o u r c e c o d e ---------\n"
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
1788 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { 1787 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) {
1789 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); 1788 StackFrame* frame = AllocateFrameCopy(it.frame(), zone);
1790 list.Add(frame, zone); 1789 list.Add(frame, zone);
1791 } 1790 }
1792 return list.ToVector(); 1791 return list.ToVector();
1793 } 1792 }
1794 1793
1795 1794
1796 } // namespace internal 1795 } // namespace internal
1797 } // namespace v8 1796 } // namespace v8
OLDNEW
« src/debug/mirrors.js ('K') | « src/frames.h ('k') | src/frames-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698