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

Side by Side Diff: src/deoptimizer.cc

Issue 1264483008: [deoptimizer] Fix the frame size calculation for debugger-inspectable frame construction. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Reuse ComputeOutgoingArgumentSize() Created 5 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') | test/mjsunit/regress/regress-514362.js » ('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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/codegen.h" 8 #include "src/codegen.h"
9 #include "src/cpu-profiler.h" 9 #include "src/cpu-profiler.h"
10 #include "src/deoptimizer.h" 10 #include "src/deoptimizer.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 147
148 // Locate the deoptimization point in the code. As we are at a call the 148 // Locate the deoptimization point in the code. As we are at a call the
149 // return address must be at a place in the code with deoptimization support. 149 // return address must be at a place in the code with deoptimization support.
150 SafepointEntry safepoint_entry = code->GetSafepointEntry(frame->pc()); 150 SafepointEntry safepoint_entry = code->GetSafepointEntry(frame->pc());
151 int deoptimization_index = safepoint_entry.deoptimization_index(); 151 int deoptimization_index = safepoint_entry.deoptimization_index();
152 CHECK_NE(deoptimization_index, Safepoint::kNoDeoptimizationIndex); 152 CHECK_NE(deoptimization_index, Safepoint::kNoDeoptimizationIndex);
153 153
154 // Always use the actual stack slots when calculating the fp to sp 154 // Always use the actual stack slots when calculating the fp to sp
155 // delta adding two for the function and context. 155 // delta adding two for the function and context.
156 unsigned stack_slots = code->stack_slots(); 156 unsigned stack_slots = code->stack_slots();
157 unsigned arguments_stack_height =
158 Deoptimizer::ComputeOutgoingArgumentSize(code, deoptimization_index);
157 unsigned fp_to_sp_delta = (stack_slots * kPointerSize) + 159 unsigned fp_to_sp_delta = (stack_slots * kPointerSize) +
158 StandardFrameConstants::kFixedFrameSizeFromFp; 160 StandardFrameConstants::kFixedFrameSizeFromFp +
161 arguments_stack_height;
159 162
160 Deoptimizer* deoptimizer = new Deoptimizer(isolate, 163 Deoptimizer* deoptimizer = new Deoptimizer(isolate,
161 function, 164 function,
162 Deoptimizer::DEBUGGER, 165 Deoptimizer::DEBUGGER,
163 deoptimization_index, 166 deoptimization_index,
164 frame->pc(), 167 frame->pc(),
165 fp_to_sp_delta, 168 fp_to_sp_delta,
166 code); 169 code);
167 Address tos = frame->fp() - fp_to_sp_delta; 170 Address tos = frame->fp() - fp_to_sp_delta;
168 deoptimizer->FillInputFrame(tos, frame); 171 deoptimizer->FillInputFrame(tos, frame);
(...skipping 1594 matching lines...) Expand 10 before | Expand all | Expand 10 after
1763 1766
1764 1767
1765 unsigned Deoptimizer::ComputeInputFrameSize() const { 1768 unsigned Deoptimizer::ComputeInputFrameSize() const {
1766 unsigned fixed_size = ComputeFixedSize(function_); 1769 unsigned fixed_size = ComputeFixedSize(function_);
1767 // The fp-to-sp delta already takes the context, constant pool pointer and the 1770 // The fp-to-sp delta already takes the context, constant pool pointer and the
1768 // function into account so we have to avoid double counting them. 1771 // function into account so we have to avoid double counting them.
1769 unsigned result = fixed_size + fp_to_sp_delta_ - 1772 unsigned result = fixed_size + fp_to_sp_delta_ -
1770 StandardFrameConstants::kFixedFrameSizeFromFp; 1773 StandardFrameConstants::kFixedFrameSizeFromFp;
1771 if (compiled_code_->kind() == Code::OPTIMIZED_FUNCTION) { 1774 if (compiled_code_->kind() == Code::OPTIMIZED_FUNCTION) {
1772 unsigned stack_slots = compiled_code_->stack_slots(); 1775 unsigned stack_slots = compiled_code_->stack_slots();
1773 unsigned outgoing_size = ComputeOutgoingArgumentSize(); 1776 unsigned outgoing_size =
1777 ComputeOutgoingArgumentSize(compiled_code_, bailout_id_);
1774 CHECK(result == fixed_size + (stack_slots * kPointerSize) + outgoing_size); 1778 CHECK(result == fixed_size + (stack_slots * kPointerSize) + outgoing_size);
1775 } 1779 }
1776 return result; 1780 return result;
1777 } 1781 }
1778 1782
1779 1783
1780 unsigned Deoptimizer::ComputeFixedSize(JSFunction* function) const { 1784 unsigned Deoptimizer::ComputeFixedSize(JSFunction* function) const {
1781 // The fixed part of the frame consists of the return address, frame 1785 // The fixed part of the frame consists of the return address, frame
1782 // pointer, function, context, and all the incoming arguments. 1786 // pointer, function, context, and all the incoming arguments.
1783 return ComputeIncomingArgumentSize(function) + 1787 return ComputeIncomingArgumentSize(function) +
1784 StandardFrameConstants::kFixedFrameSize; 1788 StandardFrameConstants::kFixedFrameSize;
1785 } 1789 }
1786 1790
1787 1791
1788 unsigned Deoptimizer::ComputeIncomingArgumentSize(JSFunction* function) const { 1792 unsigned Deoptimizer::ComputeIncomingArgumentSize(JSFunction* function) const {
1789 // The incoming arguments is the values for formal parameters and 1793 // The incoming arguments is the values for formal parameters and
1790 // the receiver. Every slot contains a pointer. 1794 // the receiver. Every slot contains a pointer.
1791 if (function->IsSmi()) { 1795 if (function->IsSmi()) {
1792 CHECK_EQ(Smi::cast(function), Smi::FromInt(StackFrame::STUB)); 1796 CHECK_EQ(Smi::cast(function), Smi::FromInt(StackFrame::STUB));
1793 return 0; 1797 return 0;
1794 } 1798 }
1795 unsigned arguments = 1799 unsigned arguments =
1796 function->shared()->internal_formal_parameter_count() + 1; 1800 function->shared()->internal_formal_parameter_count() + 1;
1797 return arguments * kPointerSize; 1801 return arguments * kPointerSize;
1798 } 1802 }
1799 1803
1800 1804
1801 unsigned Deoptimizer::ComputeOutgoingArgumentSize() const { 1805 // static
1806 unsigned Deoptimizer::ComputeOutgoingArgumentSize(Code* code,
1807 unsigned bailout_id) {
1802 DeoptimizationInputData* data = 1808 DeoptimizationInputData* data =
1803 DeoptimizationInputData::cast(compiled_code_->deoptimization_data()); 1809 DeoptimizationInputData::cast(code->deoptimization_data());
1804 unsigned height = data->ArgumentsStackHeight(bailout_id_)->value(); 1810 unsigned height = data->ArgumentsStackHeight(bailout_id)->value();
1805 return height * kPointerSize; 1811 return height * kPointerSize;
1806 } 1812 }
1807 1813
1808 1814
1809 Object* Deoptimizer::ComputeLiteral(int index) const { 1815 Object* Deoptimizer::ComputeLiteral(int index) const {
1810 DeoptimizationInputData* data = 1816 DeoptimizationInputData* data =
1811 DeoptimizationInputData::cast(compiled_code_->deoptimization_data()); 1817 DeoptimizationInputData::cast(compiled_code_->deoptimization_data());
1812 FixedArray* literals = data->LiteralArray(); 1818 FixedArray* literals = data->LiteralArray();
1813 return literals->get(index); 1819 return literals->get(index);
1814 } 1820 }
(...skipping 1601 matching lines...) Expand 10 before | Expand all | Expand 10 after
3416 DCHECK(value_info->IsMaterializedObject()); 3422 DCHECK(value_info->IsMaterializedObject());
3417 3423
3418 value_info->value_ = 3424 value_info->value_ =
3419 Handle<Object>(previously_materialized_objects->get(i), isolate_); 3425 Handle<Object>(previously_materialized_objects->get(i), isolate_);
3420 } 3426 }
3421 } 3427 }
3422 } 3428 }
3423 3429
3424 } // namespace internal 3430 } // namespace internal
3425 } // namespace v8 3431 } // namespace v8
OLDNEW
« no previous file with comments | « src/deoptimizer.h ('k') | test/mjsunit/regress/regress-514362.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698