Commit 9dd5fe29 authored by jarin's avatar jarin Committed by Commit bot

Use SharedFunctionInfo rather than the JSFunction in the deoptimizer (first step).

This removes uses of JSFunction by the (proper) deoptimizer. This will be useful
when we escape analyze JSFunction away. Unfortunately, the debugger still needs
JSFunction, so escape analysis would not work yet.

Review URL: https://codereview.chromium.org/1686183003

Cr-Commit-Position: refs/heads/master@{#33891}
parent d69ce04d
...@@ -124,8 +124,7 @@ void Deoptimizer::CopyDoubleRegisters(FrameDescription* output_frame) { ...@@ -124,8 +124,7 @@ void Deoptimizer::CopyDoubleRegisters(FrameDescription* output_frame) {
} }
} }
bool Deoptimizer::HasAlignmentPadding(SharedFunctionInfo* shared) {
bool Deoptimizer::HasAlignmentPadding(JSFunction* function) {
// There is no dynamic alignment padding on ARM in the input frame. // There is no dynamic alignment padding on ARM in the input frame.
return false; return false;
} }
......
...@@ -87,8 +87,7 @@ void Deoptimizer::FillInputFrame(Address tos, JavaScriptFrame* frame) { ...@@ -87,8 +87,7 @@ void Deoptimizer::FillInputFrame(Address tos, JavaScriptFrame* frame) {
} }
} }
bool Deoptimizer::HasAlignmentPadding(SharedFunctionInfo* shared) {
bool Deoptimizer::HasAlignmentPadding(JSFunction* function) {
// There is no dynamic alignment padding on ARM64 in the input frame. // There is no dynamic alignment padding on ARM64 in the input frame.
return false; return false;
} }
......
...@@ -813,6 +813,8 @@ void Deoptimizer::DoComputeOutputFrames() { ...@@ -813,6 +813,8 @@ void Deoptimizer::DoComputeOutputFrames() {
void Deoptimizer::DoComputeJSFrame(int frame_index) { void Deoptimizer::DoComputeJSFrame(int frame_index) {
TranslatedFrame* translated_frame = TranslatedFrame* translated_frame =
&(translated_state_.frames()[frame_index]); &(translated_state_.frames()[frame_index]);
SharedFunctionInfo* shared = translated_frame->raw_shared_info();
TranslatedFrame::iterator value_iterator = translated_frame->begin(); TranslatedFrame::iterator value_iterator = translated_frame->begin();
int input_index = 0; int input_index = 0;
...@@ -825,14 +827,15 @@ void Deoptimizer::DoComputeJSFrame(int frame_index) { ...@@ -825,14 +827,15 @@ void Deoptimizer::DoComputeJSFrame(int frame_index) {
input_index++; input_index++;
if (trace_scope_ != NULL) { if (trace_scope_ != NULL) {
PrintF(trace_scope_->file(), " translating frame "); PrintF(trace_scope_->file(), " translating frame ");
function->PrintName(trace_scope_->file()); base::SmartArrayPointer<char> name = shared->DebugName()->ToCString();
PrintF(trace_scope_->file(), "%s", name.get());
PrintF(trace_scope_->file(), PrintF(trace_scope_->file(),
" => node=%d, height=%d\n", node_id.ToInt(), height_in_bytes); " => node=%d, height=%d\n", node_id.ToInt(), height_in_bytes);
} }
// The 'fixed' part of the frame consists of the incoming parameters and // The 'fixed' part of the frame consists of the incoming parameters and
// the part described by JavaScriptFrameConstants. // the part described by JavaScriptFrameConstants.
unsigned fixed_frame_size = ComputeJavascriptFixedSize(function); unsigned fixed_frame_size = ComputeJavascriptFixedSize(shared);
unsigned input_frame_size = input_->GetFrameSize(); unsigned input_frame_size = input_->GetFrameSize();
unsigned output_frame_size = height_in_bytes + fixed_frame_size; unsigned output_frame_size = height_in_bytes + fixed_frame_size;
...@@ -856,8 +859,7 @@ void Deoptimizer::DoComputeJSFrame(int frame_index) { ...@@ -856,8 +859,7 @@ void Deoptimizer::DoComputeJSFrame(int frame_index) {
if (is_bottommost) { if (is_bottommost) {
// Determine whether the input frame contains alignment padding. // Determine whether the input frame contains alignment padding.
has_alignment_padding_ = has_alignment_padding_ =
(!compiled_code_->is_turbofanned() && HasAlignmentPadding(function)) (!compiled_code_->is_turbofanned() && HasAlignmentPadding(shared)) ? 1
? 1
: 0; : 0;
// 2 = context and function in the frame. // 2 = context and function in the frame.
// If the optimized frame had alignment padding, adjust the frame pointer // If the optimized frame had alignment padding, adjust the frame pointer
...@@ -872,8 +874,7 @@ void Deoptimizer::DoComputeJSFrame(int frame_index) { ...@@ -872,8 +874,7 @@ void Deoptimizer::DoComputeJSFrame(int frame_index) {
output_frame->SetTop(top_address); output_frame->SetTop(top_address);
// Compute the incoming parameter translation. // Compute the incoming parameter translation.
int parameter_count = int parameter_count = shared->internal_formal_parameter_count() + 1;
function->shared()->internal_formal_parameter_count() + 1;
unsigned output_offset = output_frame_size; unsigned output_offset = output_frame_size;
unsigned input_offset = input_frame_size; unsigned input_offset = input_frame_size;
for (int i = 0; i < parameter_count; ++i) { for (int i = 0; i < parameter_count; ++i) {
...@@ -988,11 +989,11 @@ void Deoptimizer::DoComputeJSFrame(int frame_index) { ...@@ -988,11 +989,11 @@ void Deoptimizer::DoComputeJSFrame(int frame_index) {
CHECK_EQ(0u, output_offset); CHECK_EQ(0u, output_offset);
// Compute this frame's PC, state, and continuation. // Compute this frame's PC, state, and continuation.
Code* non_optimized_code = function->shared()->code(); Code* non_optimized_code = shared->code();
FixedArray* raw_data = non_optimized_code->deoptimization_data(); FixedArray* raw_data = non_optimized_code->deoptimization_data();
DeoptimizationOutputData* data = DeoptimizationOutputData::cast(raw_data); DeoptimizationOutputData* data = DeoptimizationOutputData::cast(raw_data);
Address start = non_optimized_code->instruction_start(); Address start = non_optimized_code->instruction_start();
unsigned pc_and_state = GetOutputInfo(data, node_id, function->shared()); unsigned pc_and_state = GetOutputInfo(data, node_id, shared);
unsigned pc_offset = FullCodeGenerator::PcField::decode(pc_and_state); unsigned pc_offset = FullCodeGenerator::PcField::decode(pc_and_state);
intptr_t pc_value = reinterpret_cast<intptr_t>(start + pc_offset); intptr_t pc_value = reinterpret_cast<intptr_t>(start + pc_offset);
output_frame->SetPc(pc_value); output_frame->SetPc(pc_value);
...@@ -1033,6 +1034,8 @@ void Deoptimizer::DoComputeJSFrame(int frame_index) { ...@@ -1033,6 +1034,8 @@ void Deoptimizer::DoComputeJSFrame(int frame_index) {
void Deoptimizer::DoComputeInterpretedFrame(int frame_index) { void Deoptimizer::DoComputeInterpretedFrame(int frame_index) {
TranslatedFrame* translated_frame = TranslatedFrame* translated_frame =
&(translated_state_.frames()[frame_index]); &(translated_state_.frames()[frame_index]);
SharedFunctionInfo* shared = translated_frame->raw_shared_info();
TranslatedFrame::iterator value_iterator = translated_frame->begin(); TranslatedFrame::iterator value_iterator = translated_frame->begin();
int input_index = 0; int input_index = 0;
...@@ -1044,14 +1047,15 @@ void Deoptimizer::DoComputeInterpretedFrame(int frame_index) { ...@@ -1044,14 +1047,15 @@ void Deoptimizer::DoComputeInterpretedFrame(int frame_index) {
input_index++; input_index++;
if (trace_scope_ != NULL) { if (trace_scope_ != NULL) {
PrintF(trace_scope_->file(), " translating interpreted frame "); PrintF(trace_scope_->file(), " translating interpreted frame ");
function->PrintName(trace_scope_->file()); base::SmartArrayPointer<char> name = shared->DebugName()->ToCString();
PrintF(trace_scope_->file(), "%s", name.get());
PrintF(trace_scope_->file(), " => bytecode_offset=%d, height=%d\n", PrintF(trace_scope_->file(), " => bytecode_offset=%d, height=%d\n",
bytecode_offset.ToInt(), height_in_bytes); bytecode_offset.ToInt(), height_in_bytes);
} }
// The 'fixed' part of the frame consists of the incoming parameters and // The 'fixed' part of the frame consists of the incoming parameters and
// the part described by InterpreterFrameConstants. // the part described by InterpreterFrameConstants.
unsigned fixed_frame_size = ComputeInterpretedFixedSize(function); unsigned fixed_frame_size = ComputeInterpretedFixedSize(shared);
unsigned input_frame_size = input_->GetFrameSize(); unsigned input_frame_size = input_->GetFrameSize();
unsigned output_frame_size = height_in_bytes + fixed_frame_size; unsigned output_frame_size = height_in_bytes + fixed_frame_size;
...@@ -1084,8 +1088,7 @@ void Deoptimizer::DoComputeInterpretedFrame(int frame_index) { ...@@ -1084,8 +1088,7 @@ void Deoptimizer::DoComputeInterpretedFrame(int frame_index) {
output_frame->SetTop(top_address); output_frame->SetTop(top_address);
// Compute the incoming parameter translation. // Compute the incoming parameter translation.
int parameter_count = int parameter_count = shared->internal_formal_parameter_count() + 1;
function->shared()->internal_formal_parameter_count() + 1;
unsigned output_offset = output_frame_size; unsigned output_offset = output_frame_size;
unsigned input_offset = input_frame_size; unsigned input_offset = input_frame_size;
for (int i = 0; i < parameter_count; ++i) { for (int i = 0; i < parameter_count; ++i) {
...@@ -1981,7 +1984,12 @@ void Deoptimizer::DebugPrintOutputSlot(intptr_t value, int frame_index, ...@@ -1981,7 +1984,12 @@ void Deoptimizer::DebugPrintOutputSlot(intptr_t value, int frame_index,
unsigned Deoptimizer::ComputeInputFrameSize() const { unsigned Deoptimizer::ComputeInputFrameSize() const {
unsigned fixed_size = ComputeJavascriptFixedSize(function_); unsigned fixed_size = StandardFrameConstants::kFixedFrameSize;
if (!function_->IsSmi()) {
fixed_size += ComputeIncomingArgumentSize(function_->shared());
} else {
CHECK_EQ(Smi::cast(function_), Smi::FromInt(StackFrame::STUB));
}
// The fp-to-sp delta already takes the context, constant pool pointer and the // The fp-to-sp delta already takes the context, constant pool pointer and the
// function into account so we have to avoid double counting them. // function into account so we have to avoid double counting them.
unsigned result = fixed_size + fp_to_sp_delta_ - unsigned result = fixed_size + fp_to_sp_delta_ -
...@@ -1995,34 +2003,26 @@ unsigned Deoptimizer::ComputeInputFrameSize() const { ...@@ -1995,34 +2003,26 @@ unsigned Deoptimizer::ComputeInputFrameSize() const {
return result; return result;
} }
// static
unsigned Deoptimizer::ComputeJavascriptFixedSize(JSFunction* function) const { unsigned Deoptimizer::ComputeJavascriptFixedSize(SharedFunctionInfo* shared) {
// The fixed part of the frame consists of the return address, frame // The fixed part of the frame consists of the return address, frame
// pointer, function, context, and all the incoming arguments. // pointer, function, context, and all the incoming arguments.
return ComputeIncomingArgumentSize(function) + return ComputeIncomingArgumentSize(shared) +
StandardFrameConstants::kFixedFrameSize; StandardFrameConstants::kFixedFrameSize;
} }
// static
unsigned Deoptimizer::ComputeInterpretedFixedSize(JSFunction* function) const { unsigned Deoptimizer::ComputeInterpretedFixedSize(SharedFunctionInfo* shared) {
// The fixed part of the frame consists of the return address, frame // The fixed part of the frame consists of the return address, frame
// pointer, function, context, new.target, bytecode offset and all the // pointer, function, context, new.target, bytecode offset and all the
// incoming arguments. // incoming arguments.
return ComputeIncomingArgumentSize(function) + return ComputeIncomingArgumentSize(shared) +
InterpreterFrameConstants::kFixedFrameSize; InterpreterFrameConstants::kFixedFrameSize;
} }
// static
unsigned Deoptimizer::ComputeIncomingArgumentSize(JSFunction* function) const { unsigned Deoptimizer::ComputeIncomingArgumentSize(SharedFunctionInfo* shared) {
// The incoming arguments is the values for formal parameters and return (shared->internal_formal_parameter_count() + 1) * kPointerSize;
// the receiver. Every slot contains a pointer.
if (function->IsSmi()) {
CHECK_EQ(Smi::cast(function), Smi::FromInt(StackFrame::STUB));
return 0;
}
unsigned arguments =
function->shared()->internal_formal_parameter_count() + 1;
return arguments * kPointerSize;
} }
......
...@@ -128,6 +128,11 @@ class TranslatedFrame { ...@@ -128,6 +128,11 @@ class TranslatedFrame {
Handle<SharedFunctionInfo> shared_info() const { return shared_info_; } Handle<SharedFunctionInfo> shared_info() const { return shared_info_; }
int height() const { return height_; } int height() const { return height_; }
SharedFunctionInfo* raw_shared_info() const {
CHECK_NOT_NULL(raw_shared_info_);
return raw_shared_info_;
}
class iterator { class iterator {
public: public:
iterator& operator++() { iterator& operator++() {
...@@ -611,10 +616,10 @@ class Deoptimizer : public Malloced { ...@@ -611,10 +616,10 @@ class Deoptimizer : public Malloced {
const char* debug_hint_string); const char* debug_hint_string);
unsigned ComputeInputFrameSize() const; unsigned ComputeInputFrameSize() const;
unsigned ComputeJavascriptFixedSize(JSFunction* function) const; static unsigned ComputeJavascriptFixedSize(SharedFunctionInfo* shared);
unsigned ComputeInterpretedFixedSize(JSFunction* function) const; static unsigned ComputeInterpretedFixedSize(SharedFunctionInfo* shared);
unsigned ComputeIncomingArgumentSize(JSFunction* function) const; static unsigned ComputeIncomingArgumentSize(SharedFunctionInfo* shared);
static unsigned ComputeOutgoingArgumentSize(Code* code, unsigned bailout_id); static unsigned ComputeOutgoingArgumentSize(Code* code, unsigned bailout_id);
Object* ComputeLiteral(int index) const; Object* ComputeLiteral(int index) const;
...@@ -656,7 +661,7 @@ class Deoptimizer : public Malloced { ...@@ -656,7 +661,7 @@ class Deoptimizer : public Malloced {
// Determines whether the input frame contains alignment padding by looking // Determines whether the input frame contains alignment padding by looking
// at the dynamic alignment state slot inside the frame. // at the dynamic alignment state slot inside the frame.
bool HasAlignmentPadding(JSFunction* function); bool HasAlignmentPadding(SharedFunctionInfo* shared);
Isolate* isolate_; Isolate* isolate_;
JSFunction* function_; JSFunction* function_;
......
...@@ -207,10 +207,8 @@ void Deoptimizer::CopyDoubleRegisters(FrameDescription* output_frame) { ...@@ -207,10 +207,8 @@ void Deoptimizer::CopyDoubleRegisters(FrameDescription* output_frame) {
} }
} }
bool Deoptimizer::HasAlignmentPadding(SharedFunctionInfo* shared) {
bool Deoptimizer::HasAlignmentPadding(JSFunction* function) { int parameter_count = shared->internal_formal_parameter_count() + 1;
int parameter_count =
function->shared()->internal_formal_parameter_count() + 1;
unsigned input_frame_size = input_->GetFrameSize(); unsigned input_frame_size = input_->GetFrameSize();
unsigned alignment_state_offset = unsigned alignment_state_offset =
input_frame_size - parameter_count * kPointerSize - input_frame_size - parameter_count * kPointerSize -
......
...@@ -119,8 +119,7 @@ void Deoptimizer::CopyDoubleRegisters(FrameDescription* output_frame) { ...@@ -119,8 +119,7 @@ void Deoptimizer::CopyDoubleRegisters(FrameDescription* output_frame) {
} }
} }
bool Deoptimizer::HasAlignmentPadding(SharedFunctionInfo* shared) {
bool Deoptimizer::HasAlignmentPadding(JSFunction* function) {
// There is no dynamic alignment padding on MIPS in the input frame. // There is no dynamic alignment padding on MIPS in the input frame.
return false; return false;
} }
......
...@@ -119,8 +119,7 @@ void Deoptimizer::CopyDoubleRegisters(FrameDescription* output_frame) { ...@@ -119,8 +119,7 @@ void Deoptimizer::CopyDoubleRegisters(FrameDescription* output_frame) {
} }
} }
bool Deoptimizer::HasAlignmentPadding(SharedFunctionInfo* shared) {
bool Deoptimizer::HasAlignmentPadding(JSFunction* function) {
// There is no dynamic alignment padding on MIPS in the input frame. // There is no dynamic alignment padding on MIPS in the input frame.
return false; return false;
} }
......
...@@ -131,8 +131,7 @@ void Deoptimizer::CopyDoubleRegisters(FrameDescription* output_frame) { ...@@ -131,8 +131,7 @@ void Deoptimizer::CopyDoubleRegisters(FrameDescription* output_frame) {
} }
} }
bool Deoptimizer::HasAlignmentPadding(SharedFunctionInfo* shared) {
bool Deoptimizer::HasAlignmentPadding(JSFunction* function) {
// There is no dynamic alignment padding on PPC in the input frame. // There is no dynamic alignment padding on PPC in the input frame.
return false; return false;
} }
......
...@@ -125,8 +125,7 @@ void Deoptimizer::CopyDoubleRegisters(FrameDescription* output_frame) { ...@@ -125,8 +125,7 @@ void Deoptimizer::CopyDoubleRegisters(FrameDescription* output_frame) {
} }
} }
bool Deoptimizer::HasAlignmentPadding(SharedFunctionInfo* shared) {
bool Deoptimizer::HasAlignmentPadding(JSFunction* function) {
// There is no dynamic alignment padding on x64 in the input frame. // There is no dynamic alignment padding on x64 in the input frame.
return false; return false;
} }
......
...@@ -207,10 +207,8 @@ void Deoptimizer::CopyDoubleRegisters(FrameDescription* output_frame) { ...@@ -207,10 +207,8 @@ void Deoptimizer::CopyDoubleRegisters(FrameDescription* output_frame) {
} }
} }
bool Deoptimizer::HasAlignmentPadding(SharedFunctionInfo* shared) {
bool Deoptimizer::HasAlignmentPadding(JSFunction* function) { int parameter_count = shared->internal_formal_parameter_count() + 1;
int parameter_count =
function->shared()->internal_formal_parameter_count() + 1;
unsigned input_frame_size = input_->GetFrameSize(); unsigned input_frame_size = input_->GetFrameSize();
unsigned alignment_state_offset = unsigned alignment_state_offset =
input_frame_size - parameter_count * kPointerSize - input_frame_size - parameter_count * kPointerSize -
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment