Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(754)

Side by Side Diff: src/deoptimizer.cc

Issue 2239773003: [deoptimizer] use correct code/bytecode to compute source position. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: add dcheck Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/deoptimizer.h ('k') | src/profiler/profiler-listener.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 DCHECK_EQ(TranslatedFrame::kFunction, frame_it->kind());
2691 source_position_ = Deoptimizer::ComputeSourcePositionFromBaselineCode(
2692 *frame_it->shared_info(), frame_it->node_id());
2693 }
2688 2694
2689 TranslatedFrame::iterator value_it = frame_it->begin(); 2695 TranslatedFrame::iterator value_it = frame_it->begin();
2690 // Get the function. Note that this might materialize the function. 2696 // Get the function. Note that this might materialize the function.
2691 // In case the debugger mutates this value, we should deoptimize 2697 // In case the debugger mutates this value, we should deoptimize
2692 // the function and remember the value in the materialized value store. 2698 // the function and remember the value in the materialized value store.
2693 function_ = Handle<JSFunction>::cast(value_it->GetValue()); 2699 function_ = Handle<JSFunction>::cast(value_it->GetValue());
2694 2700
2695 parameters_.resize(static_cast<size_t>(parameter_count)); 2701 parameters_.resize(static_cast<size_t>(parameter_count));
2696 for (int i = 0; i < parameter_count; i++) { 2702 for (int i = 0; i < parameter_count; i++) {
2697 Handle<Object> parameter = GetValueForDebugger(parameter_it, isolate); 2703 Handle<Object> parameter = GetValueForDebugger(parameter_it, isolate);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2755 last_deopt_id = static_cast<int>(info->data()); 2761 last_deopt_id = static_cast<int>(info->data());
2756 } else if (info->rmode() == RelocInfo::DEOPT_REASON) { 2762 } else if (info->rmode() == RelocInfo::DEOPT_REASON) {
2757 last_reason = static_cast<DeoptimizeReason>(info->data()); 2763 last_reason = static_cast<DeoptimizeReason>(info->data());
2758 } 2764 }
2759 } 2765 }
2760 return DeoptInfo(SourcePosition::Unknown(), DeoptimizeReason::kNoReason, -1); 2766 return DeoptInfo(SourcePosition::Unknown(), DeoptimizeReason::kNoReason, -1);
2761 } 2767 }
2762 2768
2763 2769
2764 // static 2770 // static
2765 int Deoptimizer::ComputeSourcePosition(SharedFunctionInfo* shared, 2771 int Deoptimizer::ComputeSourcePositionFromBaselineCode(
2766 BailoutId node_id) { 2772 SharedFunctionInfo* shared, BailoutId node_id) {
2767 AbstractCode* abstract_code = shared->abstract_code(); 2773 DCHECK(shared->HasBaselineCode());
2768 int code_offset; 2774 Code* code = shared->code();
2769 if (abstract_code->IsBytecodeArray()) { 2775 FixedArray* raw_data = code->deoptimization_data();
2770 // BailoutId points to the next bytecode in the bytecode aray. Subtract 2776 DeoptimizationOutputData* data = DeoptimizationOutputData::cast(raw_data);
2771 // 1 to get the end of current bytecode. 2777 unsigned pc_and_state = Deoptimizer::GetOutputInfo(data, node_id, shared);
2772 code_offset = node_id.ToInt() - 1; 2778 int code_offset =
2773 } else { 2779 static_cast<int>(FullCodeGenerator::PcField::decode(pc_and_state));
2774 FixedArray* raw_data = abstract_code->GetCode()->deoptimization_data(); 2780 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 } 2781 }
2782 2782
2783 // static 2783 // static
2784 int Deoptimizer::ComputeSourcePositionFromBytecodeArray(
2785 SharedFunctionInfo* shared, BailoutId node_id) {
2786 DCHECK(shared->HasBytecodeArray());
2787 // BailoutId points to the next bytecode in the bytecode aray. Subtract
2788 // 1 to get the end of current bytecode.
2789 int code_offset = node_id.ToInt() - 1;
2790 return AbstractCode::cast(shared->bytecode_array())
2791 ->SourcePosition(code_offset);
2792 }
2793
2794 // static
2784 TranslatedValue TranslatedValue::NewArgumentsObject(TranslatedState* container, 2795 TranslatedValue TranslatedValue::NewArgumentsObject(TranslatedState* container,
2785 int length, 2796 int length,
2786 int object_index) { 2797 int object_index) {
2787 TranslatedValue slot(container, kArgumentsObject); 2798 TranslatedValue slot(container, kArgumentsObject);
2788 slot.materialization_info_ = {object_index, length}; 2799 slot.materialization_info_ = {object_index, length};
2789 return slot; 2800 return slot;
2790 } 2801 }
2791 2802
2792 2803
2793 // static 2804 // static
(...skipping 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after
3995 CHECK(value_info->IsMaterializedObject()); 4006 CHECK(value_info->IsMaterializedObject());
3996 4007
3997 value_info->value_ = 4008 value_info->value_ =
3998 Handle<Object>(previously_materialized_objects->get(i), isolate_); 4009 Handle<Object>(previously_materialized_objects->get(i), isolate_);
3999 } 4010 }
4000 } 4011 }
4001 } 4012 }
4002 4013
4003 } // namespace internal 4014 } // namespace internal
4004 } // namespace v8 4015 } // namespace v8
OLDNEW
« no previous file with comments | « src/deoptimizer.h ('k') | src/profiler/profiler-listener.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698