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/v8.h" | 9 #include "src/v8.h" |
10 | 10 |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 state->sp = sp; | 558 state->sp = sp; |
559 state->fp = fp; | 559 state->fp = fp; |
560 state->pc_address = ResolveReturnAddressLocation( | 560 state->pc_address = ResolveReturnAddressLocation( |
561 reinterpret_cast<Address*>(sp - 1 * kPCOnStackSize)); | 561 reinterpret_cast<Address*>(sp - 1 * kPCOnStackSize)); |
562 state->constant_pool_address = | 562 state->constant_pool_address = |
563 reinterpret_cast<Address*>(fp + ExitFrameConstants::kConstantPoolOffset); | 563 reinterpret_cast<Address*>(fp + ExitFrameConstants::kConstantPoolOffset); |
564 } | 564 } |
565 | 565 |
566 | 566 |
567 Address StandardFrame::GetExpressionAddress(int n) const { | 567 Address StandardFrame::GetExpressionAddress(int n) const { |
568 const int offset = StandardFrameConstants::kExpressionsOffset; | 568 const int offset = (is_java_script() && !is_optimized()) |
| 569 ? JavaScriptFrameConstants::kLocal0Offset |
| 570 : StandardFrameConstants::kExpressionsOffset; |
569 return fp() + offset - n * kPointerSize; | 571 return fp() + offset - n * kPointerSize; |
570 } | 572 } |
571 | 573 |
572 | 574 |
573 Object* StandardFrame::GetExpression(Address fp, int index) { | 575 Object* StandardFrame::GetStandardFrameExpression(Address fp, int index) { |
574 return Memory::Object_at(GetExpressionAddress(fp, index)); | 576 return Memory::Object_at(GetStandardFrameExpressionAddress(fp, index)); |
575 } | 577 } |
576 | 578 |
577 | 579 |
578 Address StandardFrame::GetExpressionAddress(Address fp, int n) { | 580 Address StandardFrame::GetStandardFrameExpressionAddress(Address fp, int n) { |
579 const int offset = StandardFrameConstants::kExpressionsOffset; | 581 const int offset = StandardFrameConstants::kExpressionsOffset; |
580 return fp + offset - n * kPointerSize; | 582 return fp + offset - n * kPointerSize; |
581 } | 583 } |
582 | 584 |
583 | 585 |
584 int StandardFrame::ComputeExpressionsCount() const { | 586 int StandardFrame::ComputeExpressionsCount() const { |
585 const int offset = | 587 const int offsetStart = (is_java_script() && !is_optimized()) |
586 StandardFrameConstants::kExpressionsOffset + kPointerSize; | 588 ? JavaScriptFrameConstants::kLocal0Offset |
| 589 : StandardFrameConstants::kExpressionsOffset; |
| 590 const int offset = offsetStart + kPointerSize; |
587 Address base = fp() + offset; | 591 Address base = fp() + offset; |
588 Address limit = sp(); | 592 Address limit = sp(); |
589 DCHECK(base >= limit); // stack grows downwards | 593 DCHECK(base >= limit); // stack grows downwards |
590 // Include register-allocated locals in number of expressions. | 594 // Include register-allocated locals in number of expressions. |
591 return static_cast<int>((base - limit) / kPointerSize); | 595 return static_cast<int>((base - limit) / kPointerSize); |
592 } | 596 } |
593 | 597 |
594 | 598 |
595 void StandardFrame::ComputeCallerState(State* state) const { | 599 void StandardFrame::ComputeCallerState(State* state) const { |
596 state->sp = caller_sp(); | 600 state->sp = caller_sp(); |
(...skipping 27 matching lines...) Expand all Loading... |
624 | 628 |
625 // Compute the safepoint information. | 629 // Compute the safepoint information. |
626 unsigned stack_slots = 0; | 630 unsigned stack_slots = 0; |
627 SafepointEntry safepoint_entry; | 631 SafepointEntry safepoint_entry; |
628 Code* code = StackFrame::GetSafepointData( | 632 Code* code = StackFrame::GetSafepointData( |
629 isolate(), pc(), &safepoint_entry, &stack_slots); | 633 isolate(), pc(), &safepoint_entry, &stack_slots); |
630 unsigned slot_space = stack_slots * kPointerSize; | 634 unsigned slot_space = stack_slots * kPointerSize; |
631 | 635 |
632 // Visit the outgoing parameters. | 636 // Visit the outgoing parameters. |
633 Object** parameters_base = &Memory::Object_at(sp()); | 637 Object** parameters_base = &Memory::Object_at(sp()); |
634 Object** parameters_limit = &Memory::Object_at( | 638 Object** parameters_limit = |
635 fp() + JavaScriptFrameConstants::kFunctionOffset - slot_space); | 639 &Memory::Object_at(fp() + StandardFrameConstants::kMarkerOffset - |
| 640 slot_space); |
636 | 641 |
637 // Visit the parameters that may be on top of the saved registers. | 642 // Visit the parameters that may be on top of the saved registers. |
638 if (safepoint_entry.argument_count() > 0) { | 643 if (safepoint_entry.argument_count() > 0) { |
639 v->VisitPointers(parameters_base, | 644 v->VisitPointers(parameters_base, |
640 parameters_base + safepoint_entry.argument_count()); | 645 parameters_base + safepoint_entry.argument_count()); |
641 parameters_base += safepoint_entry.argument_count(); | 646 parameters_base += safepoint_entry.argument_count(); |
642 } | 647 } |
643 | 648 |
644 // Skip saved double registers. | 649 // Skip saved double registers. |
645 if (safepoint_entry.has_doubles()) { | 650 if (safepoint_entry.has_doubles()) { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 // Skip the arguments adaptor frame and look at the real caller. | 736 // Skip the arguments adaptor frame and look at the real caller. |
732 fp = Memory::Address_at(fp + StandardFrameConstants::kCallerFPOffset); | 737 fp = Memory::Address_at(fp + StandardFrameConstants::kCallerFPOffset); |
733 } | 738 } |
734 return IsConstructFrame(fp); | 739 return IsConstructFrame(fp); |
735 } | 740 } |
736 | 741 |
737 | 742 |
738 int JavaScriptFrame::GetArgumentsLength() const { | 743 int JavaScriptFrame::GetArgumentsLength() const { |
739 // If there is an arguments adaptor frame get the arguments length from it. | 744 // If there is an arguments adaptor frame get the arguments length from it. |
740 if (has_adapted_arguments()) { | 745 if (has_adapted_arguments()) { |
741 return Smi::cast(GetExpression(caller_fp(), 0))->value(); | 746 return ArgumentsAdaptorFrame::GetArgumentsLength(caller_fp()); |
742 } else { | 747 } else { |
743 return GetNumberOfIncomingArguments(); | 748 return GetNumberOfIncomingArguments(); |
744 } | 749 } |
745 } | 750 } |
746 | 751 |
747 | 752 |
748 Code* JavaScriptFrame::unchecked_code() const { | 753 Code* JavaScriptFrame::unchecked_code() const { |
749 return function()->code(); | 754 return function()->code(); |
750 } | 755 } |
751 | 756 |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1115 it.Next(); // Skip height. | 1120 it.Next(); // Skip height. |
1116 functions->Add(function); | 1121 functions->Add(function); |
1117 } else { | 1122 } else { |
1118 // Skip over operands to advance to the next opcode. | 1123 // Skip over operands to advance to the next opcode. |
1119 it.Skip(Translation::NumberOfOperandsFor(opcode)); | 1124 it.Skip(Translation::NumberOfOperandsFor(opcode)); |
1120 } | 1125 } |
1121 } | 1126 } |
1122 } | 1127 } |
1123 | 1128 |
1124 | 1129 |
| 1130 int ArgumentsAdaptorFrame::GetArgumentsLength(Address fp) { |
| 1131 return Smi::cast(GetStandardFrameExpression(fp, 0))->value(); |
| 1132 } |
| 1133 |
| 1134 |
1125 int ArgumentsAdaptorFrame::GetNumberOfIncomingArguments() const { | 1135 int ArgumentsAdaptorFrame::GetNumberOfIncomingArguments() const { |
1126 return Smi::cast(GetExpression(0))->value(); | 1136 return Smi::cast(GetExpression(0))->value(); |
1127 } | 1137 } |
1128 | 1138 |
1129 | 1139 |
1130 Address ArgumentsAdaptorFrame::GetCallerStackPointer() const { | 1140 Address ArgumentsAdaptorFrame::GetCallerStackPointer() const { |
1131 return fp() + StandardFrameConstants::kCallerSPOffset; | 1141 return fp() + StandardFrameConstants::kCallerSPOffset; |
1132 } | 1142 } |
1133 | 1143 |
1134 | 1144 |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1639 ZoneList<StackFrame*> list(10, zone); | 1649 ZoneList<StackFrame*> list(10, zone); |
1640 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { | 1650 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { |
1641 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); | 1651 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); |
1642 list.Add(frame, zone); | 1652 list.Add(frame, zone); |
1643 } | 1653 } |
1644 return list.ToVector(); | 1654 return list.ToVector(); |
1645 } | 1655 } |
1646 | 1656 |
1647 | 1657 |
1648 } } // namespace v8::internal | 1658 } } // namespace v8::internal |
OLD | NEW |