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 2696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2707 | 2707 |
2708 // For interpreter frame, skip the accumulator. | 2708 // For interpreter frame, skip the accumulator. |
2709 if (frame_it->kind() == TranslatedFrame::kInterpretedFunction) { | 2709 if (frame_it->kind() == TranslatedFrame::kInterpretedFunction) { |
2710 stack_it++; | 2710 stack_it++; |
2711 } | 2711 } |
2712 CHECK(stack_it == frame_it->end()); | 2712 CHECK(stack_it == frame_it->end()); |
2713 } | 2713 } |
2714 | 2714 |
2715 | 2715 |
2716 Deoptimizer::DeoptInfo Deoptimizer::GetDeoptInfo(Code* code, Address pc) { | 2716 Deoptimizer::DeoptInfo Deoptimizer::GetDeoptInfo(Code* code, Address pc) { |
| 2717 CHECK(code->instruction_start() <= pc && pc <= code->instruction_end()); |
2717 SourcePosition last_position = SourcePosition::Unknown(); | 2718 SourcePosition last_position = SourcePosition::Unknown(); |
2718 DeoptimizeReason last_reason = DeoptimizeReason::kNoReason; | 2719 DeoptimizeReason last_reason = DeoptimizeReason::kNoReason; |
2719 int last_deopt_id = kNoDeoptimizationId; | 2720 int last_deopt_id = kNoDeoptimizationId; |
2720 int mask = RelocInfo::ModeMask(RelocInfo::DEOPT_REASON) | | 2721 int mask = RelocInfo::ModeMask(RelocInfo::DEOPT_REASON) | |
2721 RelocInfo::ModeMask(RelocInfo::DEOPT_ID) | | 2722 RelocInfo::ModeMask(RelocInfo::DEOPT_ID) | |
2722 RelocInfo::ModeMask(RelocInfo::DEOPT_SCRIPT_OFFSET) | | 2723 RelocInfo::ModeMask(RelocInfo::DEOPT_SCRIPT_OFFSET) | |
2723 RelocInfo::ModeMask(RelocInfo::DEOPT_INLINING_ID); | 2724 RelocInfo::ModeMask(RelocInfo::DEOPT_INLINING_ID); |
2724 for (RelocIterator it(code, mask); !it.done(); it.next()) { | 2725 for (RelocIterator it(code, mask); !it.done(); it.next()) { |
2725 RelocInfo* info = it.rinfo(); | 2726 RelocInfo* info = it.rinfo(); |
2726 if (info->pc() >= pc) { | 2727 if (info->pc() >= pc) break; |
2727 return DeoptInfo(last_position, last_reason, last_deopt_id); | |
2728 } | |
2729 if (info->rmode() == RelocInfo::DEOPT_SCRIPT_OFFSET) { | 2728 if (info->rmode() == RelocInfo::DEOPT_SCRIPT_OFFSET) { |
2730 int script_offset = static_cast<int>(info->data()); | 2729 int script_offset = static_cast<int>(info->data()); |
2731 it.next(); | 2730 it.next(); |
2732 DCHECK(it.rinfo()->rmode() == RelocInfo::DEOPT_INLINING_ID); | 2731 DCHECK(it.rinfo()->rmode() == RelocInfo::DEOPT_INLINING_ID); |
2733 int inlining_id = static_cast<int>(it.rinfo()->data()); | 2732 int inlining_id = static_cast<int>(it.rinfo()->data()); |
2734 last_position = SourcePosition(script_offset, inlining_id); | 2733 last_position = SourcePosition(script_offset, inlining_id); |
2735 } else if (info->rmode() == RelocInfo::DEOPT_ID) { | 2734 } else if (info->rmode() == RelocInfo::DEOPT_ID) { |
2736 last_deopt_id = static_cast<int>(info->data()); | 2735 last_deopt_id = static_cast<int>(info->data()); |
2737 } else if (info->rmode() == RelocInfo::DEOPT_REASON) { | 2736 } else if (info->rmode() == RelocInfo::DEOPT_REASON) { |
2738 last_reason = static_cast<DeoptimizeReason>(info->data()); | 2737 last_reason = static_cast<DeoptimizeReason>(info->data()); |
2739 } | 2738 } |
2740 } | 2739 } |
2741 return DeoptInfo(SourcePosition::Unknown(), DeoptimizeReason::kNoReason, -1); | 2740 return DeoptInfo(last_position, last_reason, last_deopt_id); |
2742 } | 2741 } |
2743 | 2742 |
2744 | 2743 |
2745 // static | 2744 // static |
2746 int Deoptimizer::ComputeSourcePositionFromBaselineCode( | 2745 int Deoptimizer::ComputeSourcePositionFromBaselineCode( |
2747 SharedFunctionInfo* shared, BailoutId node_id) { | 2746 SharedFunctionInfo* shared, BailoutId node_id) { |
2748 DCHECK(shared->HasBaselineCode()); | 2747 DCHECK(shared->HasBaselineCode()); |
2749 Code* code = shared->code(); | 2748 Code* code = shared->code(); |
2750 FixedArray* raw_data = code->deoptimization_data(); | 2749 FixedArray* raw_data = code->deoptimization_data(); |
2751 DeoptimizationOutputData* data = DeoptimizationOutputData::cast(raw_data); | 2750 DeoptimizationOutputData* data = DeoptimizationOutputData::cast(raw_data); |
(...skipping 1256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4008 CHECK(value_info->IsMaterializedObject()); | 4007 CHECK(value_info->IsMaterializedObject()); |
4009 | 4008 |
4010 value_info->value_ = | 4009 value_info->value_ = |
4011 Handle<Object>(previously_materialized_objects->get(i), isolate_); | 4010 Handle<Object>(previously_materialized_objects->get(i), isolate_); |
4012 } | 4011 } |
4013 } | 4012 } |
4014 } | 4013 } |
4015 | 4014 |
4016 } // namespace internal | 4015 } // namespace internal |
4017 } // namespace v8 | 4016 } // namespace v8 |
OLD | NEW |