OLD | NEW |
---|---|
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/deoptimizer.h" | 5 #include "src/deoptimizer.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/accessors.h" | 9 #include "src/accessors.h" |
10 #include "src/ast/prettyprinter.h" | 10 #include "src/ast/prettyprinter.h" |
(...skipping 2665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2676 TranslatedFrame::iterator parameter_it = parameter_frame->begin(); | 2676 TranslatedFrame::iterator parameter_it = parameter_frame->begin(); |
2677 parameter_it++; // Skip the function. | 2677 parameter_it++; // Skip the function. |
2678 parameter_it++; // Skip the receiver. | 2678 parameter_it++; // Skip the receiver. |
2679 | 2679 |
2680 // Figure out whether there is a construct stub frame on top of | 2680 // Figure out whether there is a construct stub frame on top of |
2681 // the parameter frame. | 2681 // the parameter frame. |
2682 has_construct_stub_ = | 2682 has_construct_stub_ = |
2683 parameter_frame != state->begin() && | 2683 parameter_frame != state->begin() && |
2684 (parameter_frame - 1)->kind() == TranslatedFrame::kConstructStub; | 2684 (parameter_frame - 1)->kind() == TranslatedFrame::kConstructStub; |
2685 | 2685 |
2686 source_position_ = Deoptimizer::ComputeSourcePosition( | 2686 if (frame_it->kind() == TranslatedFrame::kInterpretedFunction) { |
2687 *frame_it->shared_info(), frame_it->node_id()); | 2687 source_position_ = Deoptimizer::ComputeSourcePositionFromBytecodeArray( |
2688 *frame_it->shared_info(), frame_it->node_id()); | |
2689 } else { | |
2690 source_position_ = Deoptimizer::ComputeSourcePositionFromBaselineCode( | |
Michael Starzinger
2016/08/12 10:56:49
nit: Can we add DCHECK(frame_it->kind() == Transla
| |
2691 *frame_it->shared_info(), frame_it->node_id()); | |
2692 } | |
2688 | 2693 |
2689 TranslatedFrame::iterator value_it = frame_it->begin(); | 2694 TranslatedFrame::iterator value_it = frame_it->begin(); |
2690 // Get the function. Note that this might materialize the function. | 2695 // Get the function. Note that this might materialize the function. |
2691 // In case the debugger mutates this value, we should deoptimize | 2696 // In case the debugger mutates this value, we should deoptimize |
2692 // the function and remember the value in the materialized value store. | 2697 // the function and remember the value in the materialized value store. |
2693 function_ = Handle<JSFunction>::cast(value_it->GetValue()); | 2698 function_ = Handle<JSFunction>::cast(value_it->GetValue()); |
2694 | 2699 |
2695 parameters_.resize(static_cast<size_t>(parameter_count)); | 2700 parameters_.resize(static_cast<size_t>(parameter_count)); |
2696 for (int i = 0; i < parameter_count; i++) { | 2701 for (int i = 0; i < parameter_count; i++) { |
2697 Handle<Object> parameter = GetValueForDebugger(parameter_it, isolate); | 2702 Handle<Object> parameter = GetValueForDebugger(parameter_it, isolate); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2755 last_deopt_id = static_cast<int>(info->data()); | 2760 last_deopt_id = static_cast<int>(info->data()); |
2756 } else if (info->rmode() == RelocInfo::DEOPT_REASON) { | 2761 } else if (info->rmode() == RelocInfo::DEOPT_REASON) { |
2757 last_reason = static_cast<DeoptimizeReason>(info->data()); | 2762 last_reason = static_cast<DeoptimizeReason>(info->data()); |
2758 } | 2763 } |
2759 } | 2764 } |
2760 return DeoptInfo(SourcePosition::Unknown(), DeoptimizeReason::kNoReason, -1); | 2765 return DeoptInfo(SourcePosition::Unknown(), DeoptimizeReason::kNoReason, -1); |
2761 } | 2766 } |
2762 | 2767 |
2763 | 2768 |
2764 // static | 2769 // static |
2765 int Deoptimizer::ComputeSourcePosition(SharedFunctionInfo* shared, | 2770 int Deoptimizer::ComputeSourcePositionFromBaselineCode( |
2766 BailoutId node_id) { | 2771 SharedFunctionInfo* shared, BailoutId node_id) { |
2767 AbstractCode* abstract_code = shared->abstract_code(); | 2772 DCHECK(shared->HasBaselineCode()); |
2768 int code_offset; | 2773 Code* code = shared->code(); |
2769 if (abstract_code->IsBytecodeArray()) { | 2774 FixedArray* raw_data = code->deoptimization_data(); |
2770 // BailoutId points to the next bytecode in the bytecode aray. Subtract | 2775 DeoptimizationOutputData* data = DeoptimizationOutputData::cast(raw_data); |
2771 // 1 to get the end of current bytecode. | 2776 unsigned pc_and_state = Deoptimizer::GetOutputInfo(data, node_id, shared); |
2772 code_offset = node_id.ToInt() - 1; | 2777 int code_offset = |
2773 } else { | 2778 static_cast<int>(FullCodeGenerator::PcField::decode(pc_and_state)); |
2774 FixedArray* raw_data = abstract_code->GetCode()->deoptimization_data(); | 2779 return AbstractCode::cast(code)->SourcePosition(code_offset); |
2775 DeoptimizationOutputData* data = DeoptimizationOutputData::cast(raw_data); | |
2776 unsigned pc_and_state = Deoptimizer::GetOutputInfo(data, node_id, shared); | |
2777 code_offset = | |
2778 static_cast<int>(FullCodeGenerator::PcField::decode(pc_and_state)); | |
2779 } | |
2780 return abstract_code->SourcePosition(code_offset); | |
2781 } | 2780 } |
2782 | 2781 |
2783 // static | 2782 // static |
2783 int Deoptimizer::ComputeSourcePositionFromBytecodeArray( | |
2784 SharedFunctionInfo* shared, BailoutId node_id) { | |
2785 DCHECK(shared->HasBytecodeArray()); | |
2786 // BailoutId points to the next bytecode in the bytecode aray. Subtract | |
2787 // 1 to get the end of current bytecode. | |
2788 int code_offset = node_id.ToInt() - 1; | |
2789 return AbstractCode::cast(shared->bytecode_array()) | |
2790 ->SourcePosition(code_offset); | |
2791 } | |
2792 | |
2793 // static | |
2784 TranslatedValue TranslatedValue::NewArgumentsObject(TranslatedState* container, | 2794 TranslatedValue TranslatedValue::NewArgumentsObject(TranslatedState* container, |
2785 int length, | 2795 int length, |
2786 int object_index) { | 2796 int object_index) { |
2787 TranslatedValue slot(container, kArgumentsObject); | 2797 TranslatedValue slot(container, kArgumentsObject); |
2788 slot.materialization_info_ = {object_index, length}; | 2798 slot.materialization_info_ = {object_index, length}; |
2789 return slot; | 2799 return slot; |
2790 } | 2800 } |
2791 | 2801 |
2792 | 2802 |
2793 // static | 2803 // static |
(...skipping 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3995 CHECK(value_info->IsMaterializedObject()); | 4005 CHECK(value_info->IsMaterializedObject()); |
3996 | 4006 |
3997 value_info->value_ = | 4007 value_info->value_ = |
3998 Handle<Object>(previously_materialized_objects->get(i), isolate_); | 4008 Handle<Object>(previously_materialized_objects->get(i), isolate_); |
3999 } | 4009 } |
4000 } | 4010 } |
4001 } | 4011 } |
4002 | 4012 |
4003 } // namespace internal | 4013 } // namespace internal |
4004 } // namespace v8 | 4014 } // namespace v8 |
OLD | NEW |