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

Side by Side Diff: src/isolate.cc

Issue 2275233002: Refactor call site handling for stack formatting (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address comments Created 4 years, 3 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/heap-symbols.h ('k') | src/messages.h » ('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 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/isolate.h" 5 #include "src/isolate.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include <fstream> // NOLINT(readability/streams) 9 #include <fstream> // NOLINT(readability/streams)
10 #include <sstream> 10 #include <sstream>
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 494
495 case StackFrame::BUILTIN_EXIT: { 495 case StackFrame::BUILTIN_EXIT: {
496 BuiltinExitFrame* exit_frame = BuiltinExitFrame::cast(frame); 496 BuiltinExitFrame* exit_frame = BuiltinExitFrame::cast(frame);
497 Handle<JSFunction> fun = handle(exit_frame->function(), this); 497 Handle<JSFunction> fun = handle(exit_frame->function(), this);
498 498
499 // Filter out internal frames that we do not want to show. 499 // Filter out internal frames that we do not want to show.
500 if (!helper.IsVisibleInStackTrace(*fun)) continue; 500 if (!helper.IsVisibleInStackTrace(*fun)) continue;
501 501
502 Handle<Object> recv(exit_frame->receiver(), this); 502 Handle<Object> recv(exit_frame->receiver(), this);
503 Handle<Code> code(exit_frame->LookupCode(), this); 503 Handle<Code> code(exit_frame->LookupCode(), this);
504 int offset = 504 const int offset =
505 static_cast<int>(exit_frame->pc() - code->instruction_start()); 505 static_cast<int>(exit_frame->pc() - code->instruction_start());
506 506
507 int flags = 0; 507 int flags = 0;
508 if (helper.IsStrictFrame(*fun)) flags |= FrameArray::kIsStrict; 508 if (helper.IsStrictFrame(*fun)) flags |= FrameArray::kIsStrict;
509 if (exit_frame->IsConstructor()) flags |= FrameArray::kForceConstructor; 509 if (exit_frame->IsConstructor()) flags |= FrameArray::kForceConstructor;
510 510
511 elements = FrameArray::AppendJSFrame(elements, recv, fun, 511 elements = FrameArray::AppendJSFrame(elements, recv, fun,
512 Handle<AbstractCode>::cast(code), 512 Handle<AbstractCode>::cast(code),
513 offset, flags); 513 offset, flags);
514 } break; 514 } break;
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after
1388 1388
1389 Object* Isolate::PromoteScheduledException() { 1389 Object* Isolate::PromoteScheduledException() {
1390 Object* thrown = scheduled_exception(); 1390 Object* thrown = scheduled_exception();
1391 clear_scheduled_exception(); 1391 clear_scheduled_exception();
1392 // Re-throw the exception to avoid getting repeated error reporting. 1392 // Re-throw the exception to avoid getting repeated error reporting.
1393 return ReThrow(thrown); 1393 return ReThrow(thrown);
1394 } 1394 }
1395 1395
1396 1396
1397 void Isolate::PrintCurrentStackTrace(FILE* out) { 1397 void Isolate::PrintCurrentStackTrace(FILE* out) {
1398 StackTraceFrameIterator it(this); 1398 for (StackTraceFrameIterator it(this); !it.done(); it.Advance()) {
1399 while (!it.done()) { 1399 if (!it.is_javascript()) continue;
1400
1400 HandleScope scope(this); 1401 HandleScope scope(this);
1401 // Find code position if recorded in relocation info. 1402 JavaScriptFrame* frame = it.javascript_frame();
1402 StandardFrame* frame = it.frame(); 1403
1403 AbstractCode* abstract_code; 1404 Handle<Object> receiver(frame->receiver(), this);
1404 int code_offset; 1405 Handle<JSFunction> function(frame->function(), this);
1405 if (frame->is_interpreted()) { 1406 Handle<AbstractCode> code(AbstractCode::cast(frame->LookupCode()), this);
1406 InterpretedFrame* iframe = reinterpret_cast<InterpretedFrame*>(frame); 1407 const int offset =
1407 abstract_code = AbstractCode::cast(iframe->GetBytecodeArray()); 1408 static_cast<int>(frame->pc() - code->instruction_start());
1408 code_offset = iframe->GetBytecodeOffset(); 1409
1409 } else { 1410 JSStackFrame site(this, receiver, function, code, offset);
1410 DCHECK(frame->is_java_script() || frame->is_wasm()); 1411 Handle<String> line = site.ToString().ToHandleChecked();
1411 Code* code = frame->LookupCode();
1412 abstract_code = AbstractCode::cast(code);
1413 code_offset = static_cast<int>(frame->pc() - code->instruction_start());
1414 }
1415 int pos = abstract_code->SourcePosition(code_offset);
1416 JavaScriptFrame* js_frame = JavaScriptFrame::cast(frame);
1417 Handle<Object> pos_obj(Smi::FromInt(pos), this);
1418 // Fetch function and receiver.
1419 Handle<JSFunction> fun(js_frame->function(), this);
1420 Handle<Object> recv(js_frame->receiver(), this);
1421 // Advance to the next JavaScript frame and determine if the
1422 // current frame is the top-level frame.
1423 it.Advance();
1424 Handle<Object> is_top_level = factory()->ToBoolean(it.done());
1425 // Generate and print stack trace line.
1426 Handle<String> line =
1427 Execution::GetStackTraceLine(recv, fun, pos_obj, is_top_level);
1428 if (line->length() > 0) { 1412 if (line->length() > 0) {
1429 line->PrintOn(out); 1413 line->PrintOn(out);
1430 PrintF(out, "\n"); 1414 PrintF(out, "\n");
1431 } 1415 }
1432 } 1416 }
1433 } 1417 }
1434 1418
1435 bool Isolate::ComputeLocation(MessageLocation* target) { 1419 bool Isolate::ComputeLocation(MessageLocation* target) {
1436 StackTraceFrameIterator it(this); 1420 StackTraceFrameIterator it(this);
1437 if (it.done()) return false; 1421 if (it.done()) return false;
(...skipping 1741 matching lines...) Expand 10 before | Expand all | Expand 10 after
3179 // Then check whether this scope intercepts. 3163 // Then check whether this scope intercepts.
3180 if ((flag & intercept_mask_)) { 3164 if ((flag & intercept_mask_)) {
3181 intercepted_flags_ |= flag; 3165 intercepted_flags_ |= flag;
3182 return true; 3166 return true;
3183 } 3167 }
3184 return false; 3168 return false;
3185 } 3169 }
3186 3170
3187 } // namespace internal 3171 } // namespace internal
3188 } // namespace v8 3172 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap-symbols.h ('k') | src/messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698