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 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 state->sp = sp; | 552 state->sp = sp; |
553 state->fp = fp; | 553 state->fp = fp; |
554 state->pc_address = ResolveReturnAddressLocation( | 554 state->pc_address = ResolveReturnAddressLocation( |
555 reinterpret_cast<Address*>(sp - 1 * kPCOnStackSize)); | 555 reinterpret_cast<Address*>(sp - 1 * kPCOnStackSize)); |
556 state->constant_pool_address = | 556 state->constant_pool_address = |
557 reinterpret_cast<Address*>(fp + ExitFrameConstants::kConstantPoolOffset); | 557 reinterpret_cast<Address*>(fp + ExitFrameConstants::kConstantPoolOffset); |
558 } | 558 } |
559 | 559 |
560 | 560 |
561 Address StandardFrame::GetExpressionAddress(int n) const { | 561 Address StandardFrame::GetExpressionAddress(int n) const { |
562 const int offset = StandardFrameConstants::kExpressionsOffset; | 562 const int offset = (is_java_script() && !is_optimized()) |
| 563 ? JavaScriptFrameConstants::kLocal0Offset |
| 564 : StandardFrameConstants::kExpressionsOffset; |
563 return fp() + offset - n * kPointerSize; | 565 return fp() + offset - n * kPointerSize; |
564 } | 566 } |
565 | 567 |
566 | 568 |
567 Object* StandardFrame::GetExpression(Address fp, int index) { | 569 Object* StandardFrame::GetStandardFrameExpression(Address fp, int index) { |
568 return Memory::Object_at(GetExpressionAddress(fp, index)); | 570 return Memory::Object_at(GetStandardFrameExpressionAddress(fp, index)); |
569 } | 571 } |
570 | 572 |
571 | 573 |
572 Address StandardFrame::GetExpressionAddress(Address fp, int n) { | 574 Address StandardFrame::GetStandardFrameExpressionAddress(Address fp, int n) { |
573 const int offset = StandardFrameConstants::kExpressionsOffset; | 575 const int offset = StandardFrameConstants::kExpressionsOffset; |
574 return fp + offset - n * kPointerSize; | 576 return fp + offset - n * kPointerSize; |
575 } | 577 } |
576 | 578 |
577 | 579 |
578 int StandardFrame::ComputeExpressionsCount() const { | 580 int StandardFrame::ComputeExpressionsCount() const { |
579 const int offset = | 581 const int offsetStart = (is_java_script() && !is_optimized()) |
580 StandardFrameConstants::kExpressionsOffset + kPointerSize; | 582 ? JavaScriptFrameConstants::kLocal0Offset |
| 583 : StandardFrameConstants::kExpressionsOffset; |
| 584 const int offset = offsetStart + kPointerSize; |
581 Address base = fp() + offset; | 585 Address base = fp() + offset; |
582 Address limit = sp(); | 586 Address limit = sp(); |
583 DCHECK(base >= limit); // stack grows downwards | 587 DCHECK(base >= limit); // stack grows downwards |
584 // Include register-allocated locals in number of expressions. | 588 // Include register-allocated locals in number of expressions. |
585 return static_cast<int>((base - limit) / kPointerSize); | 589 return static_cast<int>((base - limit) / kPointerSize); |
586 } | 590 } |
587 | 591 |
588 | 592 |
589 void StandardFrame::ComputeCallerState(State* state) const { | 593 void StandardFrame::ComputeCallerState(State* state) const { |
590 state->sp = caller_sp(); | 594 state->sp = caller_sp(); |
(...skipping 18 matching lines...) Expand all Loading... |
609 | 613 |
610 // Compute the safepoint information. | 614 // Compute the safepoint information. |
611 unsigned stack_slots = 0; | 615 unsigned stack_slots = 0; |
612 SafepointEntry safepoint_entry; | 616 SafepointEntry safepoint_entry; |
613 Code* code = StackFrame::GetSafepointData( | 617 Code* code = StackFrame::GetSafepointData( |
614 isolate(), pc(), &safepoint_entry, &stack_slots); | 618 isolate(), pc(), &safepoint_entry, &stack_slots); |
615 unsigned slot_space = stack_slots * kPointerSize; | 619 unsigned slot_space = stack_slots * kPointerSize; |
616 | 620 |
617 // Visit the outgoing parameters. | 621 // Visit the outgoing parameters. |
618 Object** parameters_base = &Memory::Object_at(sp()); | 622 Object** parameters_base = &Memory::Object_at(sp()); |
619 Object** parameters_limit = &Memory::Object_at( | 623 Object** parameters_limit = |
620 fp() + JavaScriptFrameConstants::kFunctionOffset - slot_space); | 624 &Memory::Object_at(fp() + StandardFrameConstants::kMarkerOffset - |
| 625 slot_space); |
621 | 626 |
622 // Visit the parameters that may be on top of the saved registers. | 627 // Visit the parameters that may be on top of the saved registers. |
623 if (safepoint_entry.argument_count() > 0) { | 628 if (safepoint_entry.argument_count() > 0) { |
624 v->VisitPointers(parameters_base, | 629 v->VisitPointers(parameters_base, |
625 parameters_base + safepoint_entry.argument_count()); | 630 parameters_base + safepoint_entry.argument_count()); |
626 parameters_base += safepoint_entry.argument_count(); | 631 parameters_base += safepoint_entry.argument_count(); |
627 } | 632 } |
628 | 633 |
629 // Skip saved double registers. | 634 // Skip saved double registers. |
630 if (safepoint_entry.has_doubles()) { | 635 if (safepoint_entry.has_doubles()) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 // Skip the arguments adaptor frame and look at the real caller. | 715 // Skip the arguments adaptor frame and look at the real caller. |
711 fp = Memory::Address_at(fp + StandardFrameConstants::kCallerFPOffset); | 716 fp = Memory::Address_at(fp + StandardFrameConstants::kCallerFPOffset); |
712 } | 717 } |
713 return IsConstructFrame(fp); | 718 return IsConstructFrame(fp); |
714 } | 719 } |
715 | 720 |
716 | 721 |
717 int JavaScriptFrame::GetArgumentsLength() const { | 722 int JavaScriptFrame::GetArgumentsLength() const { |
718 // If there is an arguments adaptor frame get the arguments length from it. | 723 // If there is an arguments adaptor frame get the arguments length from it. |
719 if (has_adapted_arguments()) { | 724 if (has_adapted_arguments()) { |
720 return Smi::cast(GetExpression(caller_fp(), 0))->value(); | 725 return ArgumentsAdaptorFrame::GetArgumentsLength(caller_fp()); |
721 } else { | 726 } else { |
722 return GetNumberOfIncomingArguments(); | 727 return GetNumberOfIncomingArguments(); |
723 } | 728 } |
724 } | 729 } |
725 | 730 |
726 | 731 |
727 Code* JavaScriptFrame::unchecked_code() const { | 732 Code* JavaScriptFrame::unchecked_code() const { |
728 return function()->code(); | 733 return function()->code(); |
729 } | 734 } |
730 | 735 |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1066 it.Next(); // Skip height. | 1071 it.Next(); // Skip height. |
1067 functions->Add(function); | 1072 functions->Add(function); |
1068 } else { | 1073 } else { |
1069 // Skip over operands to advance to the next opcode. | 1074 // Skip over operands to advance to the next opcode. |
1070 it.Skip(Translation::NumberOfOperandsFor(opcode)); | 1075 it.Skip(Translation::NumberOfOperandsFor(opcode)); |
1071 } | 1076 } |
1072 } | 1077 } |
1073 } | 1078 } |
1074 | 1079 |
1075 | 1080 |
| 1081 int ArgumentsAdaptorFrame::GetArgumentsLength(Address fp) { |
| 1082 return Smi::cast(GetStandardFrameExpression(fp, 0))->value(); |
| 1083 } |
| 1084 |
| 1085 |
1076 int ArgumentsAdaptorFrame::GetNumberOfIncomingArguments() const { | 1086 int ArgumentsAdaptorFrame::GetNumberOfIncomingArguments() const { |
1077 return Smi::cast(GetExpression(0))->value(); | 1087 return Smi::cast(GetExpression(0))->value(); |
1078 } | 1088 } |
1079 | 1089 |
1080 | 1090 |
1081 Address ArgumentsAdaptorFrame::GetCallerStackPointer() const { | 1091 Address ArgumentsAdaptorFrame::GetCallerStackPointer() const { |
1082 return fp() + StandardFrameConstants::kCallerSPOffset; | 1092 return fp() + StandardFrameConstants::kCallerSPOffset; |
1083 } | 1093 } |
1084 | 1094 |
1085 | 1095 |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1514 ZoneList<StackFrame*> list(10, zone); | 1524 ZoneList<StackFrame*> list(10, zone); |
1515 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { | 1525 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { |
1516 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); | 1526 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); |
1517 list.Add(frame, zone); | 1527 list.Add(frame, zone); |
1518 } | 1528 } |
1519 return list.ToVector(); | 1529 return list.ToVector(); |
1520 } | 1530 } |
1521 | 1531 |
1522 | 1532 |
1523 } } // namespace v8::internal | 1533 } } // namespace v8::internal |
OLD | NEW |