| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 state->pc_address = reinterpret_cast<Address*>(sp - 1 * kPointerSize); | 521 state->pc_address = reinterpret_cast<Address*>(sp - 1 * kPointerSize); |
| 522 } | 522 } |
| 523 | 523 |
| 524 | 524 |
| 525 Address StandardFrame::GetExpressionAddress(int n) const { | 525 Address StandardFrame::GetExpressionAddress(int n) const { |
| 526 const int offset = StandardFrameConstants::kExpressionsOffset; | 526 const int offset = StandardFrameConstants::kExpressionsOffset; |
| 527 return fp() + offset - n * kPointerSize; | 527 return fp() + offset - n * kPointerSize; |
| 528 } | 528 } |
| 529 | 529 |
| 530 | 530 |
| 531 Object* StandardFrame::GetExpression(Address fp, int index) { |
| 532 return Memory::Object_at(GetExpressionAddress(fp, index)); |
| 533 } |
| 534 |
| 535 |
| 536 Address StandardFrame::GetExpressionAddress(Address fp, int n) { |
| 537 const int offset = StandardFrameConstants::kExpressionsOffset; |
| 538 return fp + offset - n * kPointerSize; |
| 539 } |
| 540 |
| 541 |
| 531 int StandardFrame::ComputeExpressionsCount() const { | 542 int StandardFrame::ComputeExpressionsCount() const { |
| 532 const int offset = | 543 const int offset = |
| 533 StandardFrameConstants::kExpressionsOffset + kPointerSize; | 544 StandardFrameConstants::kExpressionsOffset + kPointerSize; |
| 534 Address base = fp() + offset; | 545 Address base = fp() + offset; |
| 535 Address limit = sp(); | 546 Address limit = sp(); |
| 536 ASSERT(base >= limit); // stack grows downwards | 547 ASSERT(base >= limit); // stack grows downwards |
| 537 // Include register-allocated locals in number of expressions. | 548 // Include register-allocated locals in number of expressions. |
| 538 return static_cast<int>((base - limit) / kPointerSize); | 549 return static_cast<int>((base - limit) / kPointerSize); |
| 539 } | 550 } |
| 540 | 551 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 bool JavaScriptFrame::IsConstructor() const { | 650 bool JavaScriptFrame::IsConstructor() const { |
| 640 Address fp = caller_fp(); | 651 Address fp = caller_fp(); |
| 641 if (has_adapted_arguments()) { | 652 if (has_adapted_arguments()) { |
| 642 // Skip the arguments adaptor frame and look at the real caller. | 653 // Skip the arguments adaptor frame and look at the real caller. |
| 643 fp = Memory::Address_at(fp + StandardFrameConstants::kCallerFPOffset); | 654 fp = Memory::Address_at(fp + StandardFrameConstants::kCallerFPOffset); |
| 644 } | 655 } |
| 645 return IsConstructFrame(fp); | 656 return IsConstructFrame(fp); |
| 646 } | 657 } |
| 647 | 658 |
| 648 | 659 |
| 660 int JavaScriptFrame::GetArgumentsLength() const { |
| 661 // If there is an arguments adaptor frame get the arguments length from it. |
| 662 if (has_adapted_arguments()) { |
| 663 return Smi::cast(GetExpression(caller_fp(), 0))->value(); |
| 664 } else { |
| 665 return GetNumberOfIncomingArguments(); |
| 666 } |
| 667 } |
| 668 |
| 669 |
| 649 Code* JavaScriptFrame::unchecked_code() const { | 670 Code* JavaScriptFrame::unchecked_code() const { |
| 650 JSFunction* function = JSFunction::cast(this->function()); | 671 JSFunction* function = JSFunction::cast(this->function()); |
| 651 return function->unchecked_code(); | 672 return function->unchecked_code(); |
| 652 } | 673 } |
| 653 | 674 |
| 654 | 675 |
| 655 int JavaScriptFrame::GetNumberOfIncomingArguments() const { | 676 int JavaScriptFrame::GetNumberOfIncomingArguments() const { |
| 656 ASSERT(!SafeStackFrameIterator::is_active(isolate()) && | 677 ASSERT(!SafeStackFrameIterator::is_active(isolate()) && |
| 657 isolate()->heap()->gc_state() == Heap::NOT_IN_GC); | 678 isolate()->heap()->gc_state() == Heap::NOT_IN_GC); |
| 658 | 679 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 ASSERT(code->kind() == Code::OPTIMIZED_FUNCTION); | 826 ASSERT(code->kind() == Code::OPTIMIZED_FUNCTION); |
| 806 | 827 |
| 807 SafepointEntry safepoint_entry = code->GetSafepointEntry(pc()); | 828 SafepointEntry safepoint_entry = code->GetSafepointEntry(pc()); |
| 808 *deopt_index = safepoint_entry.deoptimization_index(); | 829 *deopt_index = safepoint_entry.deoptimization_index(); |
| 809 ASSERT(*deopt_index != Safepoint::kNoDeoptimizationIndex); | 830 ASSERT(*deopt_index != Safepoint::kNoDeoptimizationIndex); |
| 810 | 831 |
| 811 return DeoptimizationInputData::cast(code->deoptimization_data()); | 832 return DeoptimizationInputData::cast(code->deoptimization_data()); |
| 812 } | 833 } |
| 813 | 834 |
| 814 | 835 |
| 836 int OptimizedFrame::GetInlineCount() { |
| 837 ASSERT(is_optimized()); |
| 838 |
| 839 int deopt_index = Safepoint::kNoDeoptimizationIndex; |
| 840 DeoptimizationInputData* data = GetDeoptimizationData(&deopt_index); |
| 841 |
| 842 TranslationIterator it(data->TranslationByteArray(), |
| 843 data->TranslationIndex(deopt_index)->value()); |
| 844 Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next()); |
| 845 ASSERT(opcode == Translation::BEGIN); |
| 846 USE(opcode); |
| 847 int frame_count = it.Next(); |
| 848 return frame_count; |
| 849 } |
| 850 |
| 851 |
| 815 void OptimizedFrame::GetFunctions(List<JSFunction*>* functions) { | 852 void OptimizedFrame::GetFunctions(List<JSFunction*>* functions) { |
| 816 ASSERT(functions->length() == 0); | 853 ASSERT(functions->length() == 0); |
| 817 ASSERT(is_optimized()); | 854 ASSERT(is_optimized()); |
| 818 | 855 |
| 819 int deopt_index = Safepoint::kNoDeoptimizationIndex; | 856 int deopt_index = Safepoint::kNoDeoptimizationIndex; |
| 820 DeoptimizationInputData* data = GetDeoptimizationData(&deopt_index); | 857 DeoptimizationInputData* data = GetDeoptimizationData(&deopt_index); |
| 821 | 858 |
| 822 TranslationIterator it(data->TranslationByteArray(), | 859 TranslationIterator it(data->TranslationByteArray(), |
| 823 data->TranslationIndex(deopt_index)->value()); | 860 data->TranslationIndex(deopt_index)->value()); |
| 824 Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next()); | 861 Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next()); |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1234 ZoneList<StackFrame*> list(10); | 1271 ZoneList<StackFrame*> list(10); |
| 1235 for (StackFrameIterator it; !it.done(); it.Advance()) { | 1272 for (StackFrameIterator it; !it.done(); it.Advance()) { |
| 1236 StackFrame* frame = AllocateFrameCopy(it.frame()); | 1273 StackFrame* frame = AllocateFrameCopy(it.frame()); |
| 1237 list.Add(frame); | 1274 list.Add(frame); |
| 1238 } | 1275 } |
| 1239 return list.ToVector(); | 1276 return list.ToVector(); |
| 1240 } | 1277 } |
| 1241 | 1278 |
| 1242 | 1279 |
| 1243 } } // namespace v8::internal | 1280 } } // namespace v8::internal |
| OLD | NEW |