Commit ce2b39f2 authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Record SharedFunctionInfo of inlined functions.

We need the shared function info of inlined functions to prevent code
flushing for their unoptimized code, and also to make sure that liveedit
can find the proper functions to deoptimize.

R=jarin@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#28677}
parent 77b7b39b
......@@ -851,7 +851,8 @@ Node* AstGraphBuilder::Environment::Checkpoint(
UpdateStateValues(&stack_node_, parameters_count() + locals_count(),
stack_height());
const Operator* op = common()->FrameState(JS_FRAME, ast_id, combine);
const Operator* op = common()->FrameState(JS_FRAME, ast_id, combine,
builder()->info()->shared_info());
Node* result = graph()->NewNode(op, parameters_node_, locals_node_,
stack_node_, builder()->current_context(),
......
......@@ -45,6 +45,7 @@ CodeGenerator::CodeGenerator(Frame* frame, Linkage* linkage,
handlers_(code->zone()),
deoptimization_states_(code->zone()),
deoptimization_literals_(code->zone()),
inlined_function_count_(0),
translations_(code->zone()),
last_lazy_deopt_pc_(0),
jump_tables_(nullptr),
......@@ -73,6 +74,17 @@ Handle<Code> CodeGenerator::GenerateCode() {
info->set_prologue_offset(masm()->pc_offset());
AssemblePrologue();
// Define deoptimization literals for all inlined functions.
DCHECK_EQ(0u, deoptimization_literals_.size());
for (auto frame_state_descriptor : code()->frame_state_descriptors()) {
Handle<SharedFunctionInfo> shared_info;
if (frame_state_descriptor->shared_info().ToHandle(&shared_info) &&
!shared_info.is_identical_to(info->shared_info())) {
DefineDeoptimizationLiteral(shared_info);
}
}
inlined_function_count_ = deoptimization_literals_.size();
// Assemble all non-deferred blocks, followed by deferred ones.
for (int deferred = 0; deferred < 2; ++deferred) {
for (auto const block : code()->instruction_blocks()) {
......@@ -302,7 +314,8 @@ void CodeGenerator::PopulateDeoptimizationData(Handle<Code> code_object) {
translations_.CreateByteArray(isolate()->factory());
data->SetTranslationByteArray(*translation_array);
data->SetInlinedFunctionCount(Smi::FromInt(0));
data->SetInlinedFunctionCount(
Smi::FromInt(static_cast<int>(inlined_function_count_)));
data->SetOptimizationId(Smi::FromInt(info->optimization_id()));
// TODO(jarin) The following code was copied over from Lithium, not sure
// whether the scope or the IsOptimizing condition are really needed.
......
......@@ -179,6 +179,7 @@ class CodeGenerator final : public GapResolver::Assembler {
ZoneVector<HandlerInfo> handlers_;
ZoneDeque<DeoptimizationState*> deoptimization_states_;
ZoneDeque<Handle<Object>> deoptimization_literals_;
size_t inlined_function_count_;
TranslationBuffer translations_;
int last_lazy_deopt_pc_;
JumpTable* jump_tables_;
......
......@@ -651,12 +651,14 @@ const Operator* CommonOperatorBuilder::TypedStateValues(
const Operator* CommonOperatorBuilder::FrameState(
FrameStateType type, BailoutId bailout_id,
OutputFrameStateCombine state_combine) {
return new (zone()) Operator1<FrameStateCallInfo>( // --
IrOpcode::kFrameState, Operator::kPure, // opcode
"FrameState", // name
5, 0, 0, 1, 0, 0, // counts
FrameStateCallInfo(type, bailout_id, state_combine)); // parameter
OutputFrameStateCombine state_combine,
MaybeHandle<SharedFunctionInfo> shared_info) {
FrameStateCallInfo state_info(type, bailout_id, state_combine, shared_info);
return new (zone()) Operator1<FrameStateCallInfo>( // --
IrOpcode::kFrameState, Operator::kPure, // opcode
"FrameState", // name
5, 0, 0, 1, 0, 0, // counts
state_info); // parameter
}
......
......@@ -129,7 +129,9 @@ class CommonOperatorBuilder final : public ZoneObject {
const Operator* StateValues(int arguments);
const Operator* TypedStateValues(const ZoneVector<MachineType>* types);
const Operator* FrameState(FrameStateType type, BailoutId bailout_id,
OutputFrameStateCombine state_combine);
OutputFrameStateCombine state_combine,
MaybeHandle<SharedFunctionInfo> shared_info =
MaybeHandle<SharedFunctionInfo>());
const Operator* Call(const CallDescriptor* descriptor);
const Operator* TailCall(const CallDescriptor* descriptor);
const Operator* Projection(size_t index);
......
......@@ -45,8 +45,13 @@ size_t hash_value(FrameStateCallInfo const& info) {
std::ostream& operator<<(std::ostream& os, FrameStateCallInfo const& info) {
return os << info.type() << ", " << info.bailout_id() << ", "
<< info.state_combine();
os << info.type() << ", " << info.bailout_id() << ", "
<< info.state_combine();
Handle<SharedFunctionInfo> shared_info;
if (info.shared_info().ToHandle(&shared_info)) {
os << ", " << Brief(*shared_info);
}
return os;
}
} // namespace compiler
......
......@@ -5,7 +5,7 @@
#ifndef V8_COMPILER_FRAME_STATES_H_
#define V8_COMPILER_FRAME_STATES_H_
#include "src/utils.h"
#include "src/handles-inl.h"
namespace v8 {
namespace internal {
......@@ -79,19 +79,23 @@ enum FrameStateType {
class FrameStateCallInfo final {
public:
FrameStateCallInfo(FrameStateType type, BailoutId bailout_id,
OutputFrameStateCombine state_combine)
OutputFrameStateCombine state_combine,
MaybeHandle<SharedFunctionInfo> shared_info)
: type_(type),
bailout_id_(bailout_id),
frame_state_combine_(state_combine) {}
frame_state_combine_(state_combine),
shared_info_(shared_info) {}
FrameStateType type() const { return type_; }
BailoutId bailout_id() const { return bailout_id_; }
OutputFrameStateCombine state_combine() const { return frame_state_combine_; }
MaybeHandle<SharedFunctionInfo> shared_info() const { return shared_info_; }
private:
FrameStateType const type_;
BailoutId const bailout_id_;
OutputFrameStateCombine const frame_state_combine_;
MaybeHandle<SharedFunctionInfo> const shared_info_;
};
bool operator==(FrameStateCallInfo const&, FrameStateCallInfo const&);
......
......@@ -1052,7 +1052,8 @@ FrameStateDescriptor* InstructionSelector::GetFrameStateDescriptor(
return new (instruction_zone()) FrameStateDescriptor(
instruction_zone(), state_info.type(), state_info.bailout_id(),
state_info.state_combine(), parameters, locals, stack, outer_state);
state_info.state_combine(), parameters, locals, stack,
state_info.shared_info(), outer_state);
}
......
......@@ -664,7 +664,9 @@ void InstructionSequence::SetSourcePosition(const Instruction* instr,
FrameStateDescriptor::FrameStateDescriptor(
Zone* zone, FrameStateType type, BailoutId bailout_id,
OutputFrameStateCombine state_combine, size_t parameters_count,
size_t locals_count, size_t stack_count, FrameStateDescriptor* outer_state)
size_t locals_count, size_t stack_count,
MaybeHandle<SharedFunctionInfo> shared_info,
FrameStateDescriptor* outer_state)
: type_(type),
bailout_id_(bailout_id),
frame_state_combine_(state_combine),
......@@ -672,6 +674,7 @@ FrameStateDescriptor::FrameStateDescriptor(
locals_count_(locals_count),
stack_count_(stack_count),
types_(zone),
shared_info_(shared_info),
outer_state_(outer_state) {
types_.resize(GetSize(), kMachNone);
}
......
......@@ -866,6 +866,7 @@ class FrameStateDescriptor : public ZoneObject {
OutputFrameStateCombine state_combine,
size_t parameters_count, size_t locals_count,
size_t stack_count,
MaybeHandle<SharedFunctionInfo> shared_info,
FrameStateDescriptor* outer_state = nullptr);
FrameStateType type() const { return type_; }
......@@ -874,6 +875,7 @@ class FrameStateDescriptor : public ZoneObject {
size_t parameters_count() const { return parameters_count_; }
size_t locals_count() const { return locals_count_; }
size_t stack_count() const { return stack_count_; }
MaybeHandle<SharedFunctionInfo> shared_info() const { return shared_info_; }
FrameStateDescriptor* outer_state() const { return outer_state_; }
bool HasContext() const { return type_ == JS_FRAME; }
......@@ -894,6 +896,7 @@ class FrameStateDescriptor : public ZoneObject {
size_t locals_count_;
size_t stack_count_;
ZoneVector<MachineType> types_;
MaybeHandle<SharedFunctionInfo> const shared_info_;
FrameStateDescriptor* outer_state_;
};
......@@ -1149,6 +1152,9 @@ class InstructionSequence final : public ZoneObject {
StateId AddFrameStateDescriptor(FrameStateDescriptor* descriptor);
FrameStateDescriptor* GetFrameStateDescriptor(StateId deoptimization_id);
int GetFrameStateDescriptorCount();
DeoptimizationVector const& frame_state_descriptors() const {
return deoptimization_entries_;
}
RpoNumber InputRpo(Instruction* instr, size_t index);
......
......@@ -11636,6 +11636,13 @@ WeakCell* Code::CachedWeakCell() {
void DeoptimizationInputData::DeoptimizationInputDataPrint(
std::ostream& os) { // NOLINT
disasm::NameConverter converter;
int const inlined_function_count = InlinedFunctionCount()->value();
os << "Inlined functions (count = " << inlined_function_count << ")\n";
for (int id = 0; id < inlined_function_count; ++id) {
Object* info = LiteralArray()->get(id);
os << " " << Brief(SharedFunctionInfo::cast(info)) << "\n";
}
os << "\n";
int deopt_count = DeoptCount();
os << "Deoptimization Input Data (deopt points = " << deopt_count << ")\n";
if (0 != deopt_count) {
......
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