OLD | NEW |
---|---|
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 Loading... | |
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 Code* code = NULL; | |
685 if (IsConstructor()) accumulator->Add("new "); | |
686 accumulator->PrintFunction(function, receiver, &code); | |
687 | |
688 accumulator->Add("(this=%o", receiver); | |
689 | |
690 // Print the parameters. | |
691 int parameters_count = ComputeParametersCount(); | |
Yang
2016/07/11 10:24:32
Let's only print up to, let's say, 5 parameters.
| |
692 for (int i = 0; i < parameters_count; i++) { | |
693 accumulator->Add(",%o", GetParameter(i)); | |
694 } | |
695 | |
696 accumulator->Add(")\n\n"); | |
697 } | |
698 | |
660 Address StandardFrame::GetExpressionAddress(int n) const { | 699 Address StandardFrame::GetExpressionAddress(int n) const { |
661 const int offset = StandardFrameConstants::kExpressionsOffset; | 700 const int offset = StandardFrameConstants::kExpressionsOffset; |
662 return fp() + offset - n * kPointerSize; | 701 return fp() + offset - n * kPointerSize; |
663 } | 702 } |
664 | 703 |
665 Address InterpretedFrame::GetExpressionAddress(int n) const { | 704 Address InterpretedFrame::GetExpressionAddress(int n) const { |
666 const int offset = InterpreterFrameConstants::kExpressionsOffset; | 705 const int offset = InterpreterFrameConstants::kExpressionsOffset; |
667 return fp() + offset - n * kPointerSize; | 706 return fp() + offset - n * kPointerSize; |
668 } | 707 } |
669 | 708 |
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1370 int ArgumentsAdaptorFrame::GetLength(Address fp) { | 1409 int ArgumentsAdaptorFrame::GetLength(Address fp) { |
1371 const int offset = ArgumentsAdaptorFrameConstants::kLengthOffset; | 1410 const int offset = ArgumentsAdaptorFrameConstants::kLengthOffset; |
1372 return Smi::cast(Memory::Object_at(fp + offset))->value(); | 1411 return Smi::cast(Memory::Object_at(fp + offset))->value(); |
1373 } | 1412 } |
1374 | 1413 |
1375 Code* ArgumentsAdaptorFrame::unchecked_code() const { | 1414 Code* ArgumentsAdaptorFrame::unchecked_code() const { |
1376 return isolate()->builtins()->builtin( | 1415 return isolate()->builtins()->builtin( |
1377 Builtins::kArgumentsAdaptorTrampoline); | 1416 Builtins::kArgumentsAdaptorTrampoline); |
1378 } | 1417 } |
1379 | 1418 |
1380 void BuiltinFrame::Print(StringStream* accumulator, PrintMode mode, | |
1381 int index) const { | |
1382 // TODO(bmeurer) | |
1383 } | |
1384 | |
1385 int BuiltinFrame::GetNumberOfIncomingArguments() const { | 1419 int BuiltinFrame::GetNumberOfIncomingArguments() const { |
1386 return Smi::cast(GetExpression(0))->value(); | 1420 return Smi::cast(GetExpression(0))->value(); |
1387 } | 1421 } |
1388 | 1422 |
1389 Address InternalFrame::GetCallerStackPointer() const { | 1423 Address InternalFrame::GetCallerStackPointer() const { |
1390 // Internal frames have no arguments. The stack pointer of the | 1424 // Internal frames have no arguments. The stack pointer of the |
1391 // caller is at a fixed offset from the frame pointer. | 1425 // caller is at a fixed offset from the frame pointer. |
1392 return fp() + StandardFrameConstants::kCallerSPOffset; | 1426 return fp() + StandardFrameConstants::kCallerSPOffset; |
1393 } | 1427 } |
1394 | 1428 |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1869 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { | 1903 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { |
1870 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); | 1904 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); |
1871 list.Add(frame, zone); | 1905 list.Add(frame, zone); |
1872 } | 1906 } |
1873 return list.ToVector(); | 1907 return list.ToVector(); |
1874 } | 1908 } |
1875 | 1909 |
1876 | 1910 |
1877 } // namespace internal | 1911 } // namespace internal |
1878 } // namespace v8 | 1912 } // namespace v8 |
OLD | NEW |