Commit 0dc896c4 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[interpreter] Remove CompilationInfo from graph builder.

This removes the CompilationInfo field from the BytecodeGraphBuilder
class. The intention is to reduce the risk of using uninitialized or
unavailable values from the CompilationInfo (e.g. values that are only
available after parsing).

R=rmcilroy@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#34081}
parent 0200dd56
...@@ -355,7 +355,7 @@ void BytecodeGraphBuilder::Environment::PrepareForLoop() { ...@@ -355,7 +355,7 @@ void BytecodeGraphBuilder::Environment::PrepareForLoop() {
bool BytecodeGraphBuilder::Environment::StateValuesRequireUpdate( bool BytecodeGraphBuilder::Environment::StateValuesRequireUpdate(
Node** state_values, int offset, int count) { Node** state_values, int offset, int count) {
if (!builder()->info()->is_deoptimization_enabled()) { if (!builder()->deoptimization_enabled_) {
return false; return false;
} }
if (*state_values == nullptr) { if (*state_values == nullptr) {
...@@ -385,7 +385,7 @@ void BytecodeGraphBuilder::Environment::UpdateStateValues(Node** state_values, ...@@ -385,7 +385,7 @@ void BytecodeGraphBuilder::Environment::UpdateStateValues(Node** state_values,
Node* BytecodeGraphBuilder::Environment::Checkpoint( Node* BytecodeGraphBuilder::Environment::Checkpoint(
BailoutId bailout_id, OutputFrameStateCombine combine) { BailoutId bailout_id, OutputFrameStateCombine combine) {
if (!builder()->info()->is_deoptimization_enabled()) { if (!builder()->deoptimization_enabled_) {
return builder()->jsgraph()->EmptyFrameState(); return builder()->jsgraph()->EmptyFrameState();
} }
...@@ -423,7 +423,7 @@ bool BytecodeGraphBuilder::Environment::StateValuesAreUpToDate( ...@@ -423,7 +423,7 @@ bool BytecodeGraphBuilder::Environment::StateValuesAreUpToDate(
bool BytecodeGraphBuilder::Environment::StateValuesAreUpToDate( bool BytecodeGraphBuilder::Environment::StateValuesAreUpToDate(
int output_poke_offset, int output_poke_count) { int output_poke_offset, int output_poke_count) {
if (!builder()->info()->is_deoptimization_enabled()) return true; if (!builder()->deoptimization_enabled_) return true;
// Poke offset is relative to the top of the stack (i.e., the accumulator). // Poke offset is relative to the top of the stack (i.e., the accumulator).
int output_poke_start = accumulator_base() - output_poke_offset; int output_poke_start = accumulator_base() - output_poke_offset;
int output_poke_end = output_poke_start + output_poke_count; int output_poke_end = output_poke_start + output_poke_count;
...@@ -437,19 +437,20 @@ bool BytecodeGraphBuilder::Environment::StateValuesAreUpToDate( ...@@ -437,19 +437,20 @@ bool BytecodeGraphBuilder::Environment::StateValuesAreUpToDate(
} }
BytecodeGraphBuilder::BytecodeGraphBuilder(Zone* local_zone, BytecodeGraphBuilder::BytecodeGraphBuilder(Zone* local_zone,
CompilationInfo* compilation_info, CompilationInfo* info,
JSGraph* jsgraph) JSGraph* jsgraph)
: local_zone_(local_zone), : local_zone_(local_zone),
info_(compilation_info),
jsgraph_(jsgraph), jsgraph_(jsgraph),
bytecode_array_(handle(info()->shared_info()->bytecode_array())), bytecode_array_(handle(info->shared_info()->bytecode_array())),
exception_handler_table_( exception_handler_table_(
handle(HandlerTable::cast(bytecode_array()->handler_table()))), handle(HandlerTable::cast(bytecode_array()->handler_table()))),
feedback_vector_(info->feedback_vector()),
frame_state_function_info_(common()->CreateFrameStateFunctionInfo( frame_state_function_info_(common()->CreateFrameStateFunctionInfo(
FrameStateType::kInterpretedFunction, FrameStateType::kInterpretedFunction,
bytecode_array()->parameter_count(), bytecode_array()->parameter_count(),
bytecode_array()->register_count(), info()->shared_info(), bytecode_array()->register_count(), info->shared_info(),
CALL_MAINTAINS_NATIVE_CONTEXT)), CALL_MAINTAINS_NATIVE_CONTEXT)),
deoptimization_enabled_(info->is_deoptimization_enabled()),
merge_environments_(local_zone), merge_environments_(local_zone),
exception_handlers_(local_zone), exception_handlers_(local_zone),
current_exception_handler_(0), current_exception_handler_(0),
...@@ -501,12 +502,11 @@ Node* BytecodeGraphBuilder::BuildLoadNativeContextField(int index) { ...@@ -501,12 +502,11 @@ Node* BytecodeGraphBuilder::BuildLoadNativeContextField(int index) {
VectorSlotPair BytecodeGraphBuilder::CreateVectorSlotPair(int slot_id) { VectorSlotPair BytecodeGraphBuilder::CreateVectorSlotPair(int slot_id) {
Handle<TypeFeedbackVector> feedback_vector = info()->feedback_vector();
FeedbackVectorSlot slot; FeedbackVectorSlot slot;
if (slot_id >= TypeFeedbackVector::kReservedIndexCount) { if (slot_id >= TypeFeedbackVector::kReservedIndexCount) {
slot = feedback_vector->ToSlot(slot_id); slot = feedback_vector()->ToSlot(slot_id);
} }
return VectorSlotPair(feedback_vector, slot); return VectorSlotPair(feedback_vector(), slot);
} }
bool BytecodeGraphBuilder::CreateGraph() { bool BytecodeGraphBuilder::CreateGraph() {
...@@ -981,7 +981,7 @@ Node* BytecodeGraphBuilder::ProcessCallArguments(const Operator* call_op, ...@@ -981,7 +981,7 @@ Node* BytecodeGraphBuilder::ProcessCallArguments(const Operator* call_op,
Node* callee, Node* callee,
interpreter::Register receiver, interpreter::Register receiver,
size_t arity) { size_t arity) {
Node** all = info()->zone()->NewArray<Node*>(static_cast<int>(arity)); Node** all = local_zone()->NewArray<Node*>(static_cast<int>(arity));
all[0] = callee; all[0] = callee;
all[1] = environment()->LookupRegister(receiver); all[1] = environment()->LookupRegister(receiver);
int receiver_index = receiver.index(); int receiver_index = receiver.index();
...@@ -1037,7 +1037,7 @@ void BytecodeGraphBuilder::VisitCallJSRuntimeWide() { BuildCallJSRuntime(); } ...@@ -1037,7 +1037,7 @@ void BytecodeGraphBuilder::VisitCallJSRuntimeWide() { BuildCallJSRuntime(); }
Node* BytecodeGraphBuilder::ProcessCallRuntimeArguments( Node* BytecodeGraphBuilder::ProcessCallRuntimeArguments(
const Operator* call_runtime_op, interpreter::Register first_arg, const Operator* call_runtime_op, interpreter::Register first_arg,
size_t arity) { size_t arity) {
Node** all = info()->zone()->NewArray<Node*>(arity); Node** all = local_zone()->NewArray<Node*>(arity);
int first_arg_index = first_arg.index(); int first_arg_index = first_arg.index();
for (int i = 0; i < static_cast<int>(arity); ++i) { for (int i = 0; i < static_cast<int>(arity); ++i) {
all[i] = environment()->LookupRegister( all[i] = environment()->LookupRegister(
...@@ -1090,7 +1090,7 @@ void BytecodeGraphBuilder::VisitCallRuntimeForPairWide() { ...@@ -1090,7 +1090,7 @@ void BytecodeGraphBuilder::VisitCallRuntimeForPairWide() {
Node* BytecodeGraphBuilder::ProcessCallNewArguments( Node* BytecodeGraphBuilder::ProcessCallNewArguments(
const Operator* call_new_op, Node* callee, Node* new_target, const Operator* call_new_op, Node* callee, Node* new_target,
interpreter::Register first_arg, size_t arity) { interpreter::Register first_arg, size_t arity) {
Node** all = info()->zone()->NewArray<Node*>(arity); Node** all = local_zone()->NewArray<Node*>(arity);
all[0] = new_target; all[0] = new_target;
int first_arg_index = first_arg.index(); int first_arg_index = first_arg.index();
for (int i = 1; i < static_cast<int>(arity) - 1; ++i) { for (int i = 1; i < static_cast<int>(arity) - 1; ++i) {
......
...@@ -177,7 +177,6 @@ class BytecodeGraphBuilder { ...@@ -177,7 +177,6 @@ class BytecodeGraphBuilder {
Graph* graph() const { return jsgraph_->graph(); } Graph* graph() const { return jsgraph_->graph(); }
CommonOperatorBuilder* common() const { return jsgraph_->common(); } CommonOperatorBuilder* common() const { return jsgraph_->common(); }
Zone* graph_zone() const { return graph()->zone(); } Zone* graph_zone() const { return graph()->zone(); }
CompilationInfo* info() const { return info_; }
JSGraph* jsgraph() const { return jsgraph_; } JSGraph* jsgraph() const { return jsgraph_; }
JSOperatorBuilder* javascript() const { return jsgraph_->javascript(); } JSOperatorBuilder* javascript() const { return jsgraph_->javascript(); }
Zone* local_zone() const { return local_zone_; } Zone* local_zone() const { return local_zone_; }
...@@ -187,15 +186,13 @@ class BytecodeGraphBuilder { ...@@ -187,15 +186,13 @@ class BytecodeGraphBuilder {
const Handle<HandlerTable>& exception_handler_table() const { const Handle<HandlerTable>& exception_handler_table() const {
return exception_handler_table_; return exception_handler_table_;
} }
const Handle<TypeFeedbackVector>& feedback_vector() const {
return feedback_vector_;
}
const FrameStateFunctionInfo* frame_state_function_info() const { const FrameStateFunctionInfo* frame_state_function_info() const {
return frame_state_function_info_; return frame_state_function_info_;
} }
LanguageMode language_mode() const {
// TODO(mythria): Don't rely on parse information to get language mode.
return info()->language_mode();
}
const interpreter::BytecodeArrayIterator& bytecode_iterator() const { const interpreter::BytecodeArrayIterator& bytecode_iterator() const {
return *bytecode_iterator_; return *bytecode_iterator_;
} }
...@@ -218,15 +215,19 @@ class BytecodeGraphBuilder { ...@@ -218,15 +215,19 @@ class BytecodeGraphBuilder {
#undef DECLARE_VISIT_BYTECODE #undef DECLARE_VISIT_BYTECODE
Zone* local_zone_; Zone* local_zone_;
CompilationInfo* info_;
JSGraph* jsgraph_; JSGraph* jsgraph_;
Handle<BytecodeArray> bytecode_array_; Handle<BytecodeArray> bytecode_array_;
Handle<HandlerTable> exception_handler_table_; Handle<HandlerTable> exception_handler_table_;
Handle<TypeFeedbackVector> feedback_vector_;
const FrameStateFunctionInfo* frame_state_function_info_; const FrameStateFunctionInfo* frame_state_function_info_;
const interpreter::BytecodeArrayIterator* bytecode_iterator_; const interpreter::BytecodeArrayIterator* bytecode_iterator_;
const BytecodeBranchAnalysis* branch_analysis_; const BytecodeBranchAnalysis* branch_analysis_;
Environment* environment_; Environment* environment_;
// Indicates whether deoptimization support is enabled for this compilation
// and whether valid frame states need to be attached to deoptimizing nodes.
bool deoptimization_enabled_;
// Merge environments are snapshots of the environment at points where the // Merge environments are snapshots of the environment at points where the
// control flow merges. This models a forward data flow propagation of all // control flow merges. This models a forward data flow propagation of all
// values from all predecessors of the merge in question. // values from all predecessors of the merge in question.
...@@ -245,9 +246,6 @@ class BytecodeGraphBuilder { ...@@ -245,9 +246,6 @@ class BytecodeGraphBuilder {
SetOncePointer<Node> function_closure_; SetOncePointer<Node> function_closure_;
SetOncePointer<Node> new_target_; SetOncePointer<Node> new_target_;
// Optimization to cache loaded feedback vector.
SetOncePointer<Node> feedback_vector_;
// Control nodes that exit the function body. // Control nodes that exit the function body.
ZoneVector<Node*> exit_controls_; ZoneVector<Node*> exit_controls_;
......
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