Chromium Code Reviews| Index: src/deoptimizer.cc |
| diff --git a/src/deoptimizer.cc b/src/deoptimizer.cc |
| index 7335fa54612e341ad05e59b81663caa39663a9c5..d02d42fecfd97fe9ea6f0dd1058f6195cdb0360d 100644 |
| --- a/src/deoptimizer.cc |
| +++ b/src/deoptimizer.cc |
| @@ -2683,8 +2683,13 @@ DeoptimizedFrameInfo::DeoptimizedFrameInfo(TranslatedState* state, |
| parameter_frame != state->begin() && |
| (parameter_frame - 1)->kind() == TranslatedFrame::kConstructStub; |
| - source_position_ = Deoptimizer::ComputeSourcePosition( |
| - *frame_it->shared_info(), frame_it->node_id()); |
| + if (frame_it->kind() == TranslatedFrame::kInterpretedFunction) { |
| + source_position_ = Deoptimizer::ComputeSourcePositionFromBytecodeArray( |
| + *frame_it->shared_info(), frame_it->node_id()); |
| + } else { |
| + source_position_ = Deoptimizer::ComputeSourcePositionFromBaselineCode( |
|
Michael Starzinger
2016/08/12 10:56:49
nit: Can we add DCHECK(frame_it->kind() == Transla
|
| + *frame_it->shared_info(), frame_it->node_id()); |
| + } |
| TranslatedFrame::iterator value_it = frame_it->begin(); |
| // Get the function. Note that this might materialize the function. |
| @@ -2762,22 +2767,27 @@ Deoptimizer::DeoptInfo Deoptimizer::GetDeoptInfo(Code* code, Address pc) { |
| // static |
| -int Deoptimizer::ComputeSourcePosition(SharedFunctionInfo* shared, |
| - BailoutId node_id) { |
| - AbstractCode* abstract_code = shared->abstract_code(); |
| - int code_offset; |
| - if (abstract_code->IsBytecodeArray()) { |
| - // BailoutId points to the next bytecode in the bytecode aray. Subtract |
| - // 1 to get the end of current bytecode. |
| - code_offset = node_id.ToInt() - 1; |
| - } else { |
| - FixedArray* raw_data = abstract_code->GetCode()->deoptimization_data(); |
| - DeoptimizationOutputData* data = DeoptimizationOutputData::cast(raw_data); |
| - unsigned pc_and_state = Deoptimizer::GetOutputInfo(data, node_id, shared); |
| - code_offset = |
| - static_cast<int>(FullCodeGenerator::PcField::decode(pc_and_state)); |
| - } |
| - return abstract_code->SourcePosition(code_offset); |
| +int Deoptimizer::ComputeSourcePositionFromBaselineCode( |
| + SharedFunctionInfo* shared, BailoutId node_id) { |
| + DCHECK(shared->HasBaselineCode()); |
| + Code* code = shared->code(); |
| + FixedArray* raw_data = code->deoptimization_data(); |
| + DeoptimizationOutputData* data = DeoptimizationOutputData::cast(raw_data); |
| + unsigned pc_and_state = Deoptimizer::GetOutputInfo(data, node_id, shared); |
| + int code_offset = |
| + static_cast<int>(FullCodeGenerator::PcField::decode(pc_and_state)); |
| + return AbstractCode::cast(code)->SourcePosition(code_offset); |
| +} |
| + |
| +// static |
| +int Deoptimizer::ComputeSourcePositionFromBytecodeArray( |
| + SharedFunctionInfo* shared, BailoutId node_id) { |
| + DCHECK(shared->HasBytecodeArray()); |
| + // BailoutId points to the next bytecode in the bytecode aray. Subtract |
| + // 1 to get the end of current bytecode. |
| + int code_offset = node_id.ToInt() - 1; |
| + return AbstractCode::cast(shared->bytecode_array()) |
| + ->SourcePosition(code_offset); |
| } |
| // static |