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

Side by Side Diff: src/frames.cc

Issue 2134093002: [builtins] Show builtin frames in PrintStack() (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Print frame kind 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/frames.h ('k') | src/frames-inl.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/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"
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 JSFunction* BuiltinExitFrame::function() const { 650 JSFunction* BuiltinExitFrame::function() const {
651 return JSFunction::cast(target_slot_object()); 651 return JSFunction::cast(target_slot_object());
652 } 652 }
653 653
654 Object* BuiltinExitFrame::receiver() const { return receiver_slot_object(); } 654 Object* BuiltinExitFrame::receiver() const { return receiver_slot_object(); }
655 655
656 bool BuiltinExitFrame::IsConstructor() const { 656 bool BuiltinExitFrame::IsConstructor() const {
657 return !new_target_slot_object()->IsUndefined(isolate()); 657 return !new_target_slot_object()->IsUndefined(isolate());
658 } 658 }
659 659
660 Object* BuiltinExitFrame::GetParameter(int i) const {
661 DCHECK(i >= 0 && i < ComputeParametersCount());
662 int offset = BuiltinExitFrameConstants::kArgcOffset + (i + 1) * kPointerSize;
663 return Memory::Object_at(fp() + offset);
664 }
665
666 int BuiltinExitFrame::ComputeParametersCount() const {
667 Object* argc_slot = argc_slot_object();
668 DCHECK(argc_slot->IsSmi());
669 // Argc also counts the receiver, target, new target, and argc itself as args,
670 // therefore the real argument count is argc - 4.
671 int argc = Smi::cast(argc_slot)->value() - 4;
672 DCHECK(argc >= 0);
673 return argc;
674 }
675
676 void BuiltinExitFrame::Print(StringStream* accumulator, PrintMode mode,
677 int index) const {
678 DisallowHeapAllocation no_gc;
679 Object* receiver = this->receiver();
680 JSFunction* function = this->function();
681
682 accumulator->PrintSecurityTokenIfChanged(function);
683 PrintIndex(accumulator, mode, index);
684 accumulator->Add("builtin exit frame: ");
685 Code* code = NULL;
686 if (IsConstructor()) accumulator->Add("new ");
687 accumulator->PrintFunction(function, receiver, &code);
688
689 accumulator->Add("(this=%o", receiver);
690
691 // Print the parameters.
692 int parameters_count = ComputeParametersCount();
693 for (int i = 0; i < parameters_count; i++) {
694 accumulator->Add(",%o", GetParameter(i));
695 }
696
697 accumulator->Add(")\n\n");
698 }
699
660 Address StandardFrame::GetExpressionAddress(int n) const { 700 Address StandardFrame::GetExpressionAddress(int n) const {
661 const int offset = StandardFrameConstants::kExpressionsOffset; 701 const int offset = StandardFrameConstants::kExpressionsOffset;
662 return fp() + offset - n * kPointerSize; 702 return fp() + offset - n * kPointerSize;
663 } 703 }
664 704
665 Address InterpretedFrame::GetExpressionAddress(int n) const { 705 Address InterpretedFrame::GetExpressionAddress(int n) const {
666 const int offset = InterpreterFrameConstants::kExpressionsOffset; 706 const int offset = InterpreterFrameConstants::kExpressionsOffset;
667 return fp() + offset - n * kPointerSize; 707 return fp() + offset - n * kPointerSize;
668 } 708 }
669 709
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 int ArgumentsAdaptorFrame::GetLength(Address fp) { 1410 int ArgumentsAdaptorFrame::GetLength(Address fp) {
1371 const int offset = ArgumentsAdaptorFrameConstants::kLengthOffset; 1411 const int offset = ArgumentsAdaptorFrameConstants::kLengthOffset;
1372 return Smi::cast(Memory::Object_at(fp + offset))->value(); 1412 return Smi::cast(Memory::Object_at(fp + offset))->value();
1373 } 1413 }
1374 1414
1375 Code* ArgumentsAdaptorFrame::unchecked_code() const { 1415 Code* ArgumentsAdaptorFrame::unchecked_code() const {
1376 return isolate()->builtins()->builtin( 1416 return isolate()->builtins()->builtin(
1377 Builtins::kArgumentsAdaptorTrampoline); 1417 Builtins::kArgumentsAdaptorTrampoline);
1378 } 1418 }
1379 1419
1380 void BuiltinFrame::Print(StringStream* accumulator, PrintMode mode,
1381 int index) const {
1382 // TODO(bmeurer)
1383 }
1384
1385 int BuiltinFrame::GetNumberOfIncomingArguments() const { 1420 int BuiltinFrame::GetNumberOfIncomingArguments() const {
1386 return Smi::cast(GetExpression(0))->value(); 1421 return Smi::cast(GetExpression(0))->value();
1387 } 1422 }
1388 1423
1424 void BuiltinFrame::PrintFrameKind(StringStream* accumulator) const {
1425 accumulator->Add("builtin frame: ");
1426 }
1427
1389 Address InternalFrame::GetCallerStackPointer() const { 1428 Address InternalFrame::GetCallerStackPointer() const {
1390 // Internal frames have no arguments. The stack pointer of the 1429 // Internal frames have no arguments. The stack pointer of the
1391 // caller is at a fixed offset from the frame pointer. 1430 // caller is at a fixed offset from the frame pointer.
1392 return fp() + StandardFrameConstants::kCallerSPOffset; 1431 return fp() + StandardFrameConstants::kCallerSPOffset;
1393 } 1432 }
1394 1433
1395 Code* InternalFrame::unchecked_code() const { 1434 Code* InternalFrame::unchecked_code() const {
1396 const int offset = InternalFrameConstants::kCodeOffset; 1435 const int offset = InternalFrameConstants::kCodeOffset;
1397 Object* code = Memory::Object_at(fp() + offset); 1436 Object* code = Memory::Object_at(fp() + offset);
1398 DCHECK(code != NULL); 1437 DCHECK(code != NULL);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1459 1498
1460 void JavaScriptFrame::Print(StringStream* accumulator, 1499 void JavaScriptFrame::Print(StringStream* accumulator,
1461 PrintMode mode, 1500 PrintMode mode,
1462 int index) const { 1501 int index) const {
1463 DisallowHeapAllocation no_gc; 1502 DisallowHeapAllocation no_gc;
1464 Object* receiver = this->receiver(); 1503 Object* receiver = this->receiver();
1465 JSFunction* function = this->function(); 1504 JSFunction* function = this->function();
1466 1505
1467 accumulator->PrintSecurityTokenIfChanged(function); 1506 accumulator->PrintSecurityTokenIfChanged(function);
1468 PrintIndex(accumulator, mode, index); 1507 PrintIndex(accumulator, mode, index);
1508 PrintFrameKind(accumulator);
1469 Code* code = NULL; 1509 Code* code = NULL;
1470 if (IsConstructor()) accumulator->Add("new "); 1510 if (IsConstructor()) accumulator->Add("new ");
1471 accumulator->PrintFunction(function, receiver, &code); 1511 accumulator->PrintFunction(function, receiver, &code);
1472 1512
1473 // Get scope information for nicer output, if possible. If code is NULL, or 1513 // Get scope information for nicer output, if possible. If code is NULL, or
1474 // doesn't contain scope info, scope_info will return 0 for the number of 1514 // doesn't contain scope info, scope_info will return 0 for the number of
1475 // parameters, stack local variables, context local variables, stack slots, 1515 // parameters, stack local variables, context local variables, stack slots,
1476 // or context slots. 1516 // or context slots.
1477 SharedFunctionInfo* shared = function->shared(); 1517 SharedFunctionInfo* shared = function->shared();
1478 ScopeInfo* scope_info = shared->scope_info(); 1518 ScopeInfo* scope_info = shared->scope_info();
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
1869 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { 1909 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) {
1870 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); 1910 StackFrame* frame = AllocateFrameCopy(it.frame(), zone);
1871 list.Add(frame, zone); 1911 list.Add(frame, zone);
1872 } 1912 }
1873 return list.ToVector(); 1913 return list.ToVector();
1874 } 1914 }
1875 1915
1876 1916
1877 } // namespace internal 1917 } // namespace internal
1878 } // namespace v8 1918 } // namespace v8
OLDNEW
« no previous file with comments | « src/frames.h ('k') | src/frames-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698