Commit 579264e3 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[interpreter] Refactor iterator access in BytecodeGraphBuilder.

This refactors how the BytecodeArrayIterator is passed to visitation
methods on the BytecodeGraphBuilder. We no longer pass it explicitly,
but use the field accessor instead. Note that const-ness is still
preserved and visitation methods are still not able to mutate the
iterator. The main goal of this refactoring is increased readability.

R=rmcilroy@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#33607}
parent 64588037
This diff is collapsed.
...@@ -25,8 +25,6 @@ class BytecodeGraphBuilder { ...@@ -25,8 +25,6 @@ class BytecodeGraphBuilder {
// Creates a graph by visiting bytecodes. // Creates a graph by visiting bytecodes.
bool CreateGraph(bool stack_check = true); bool CreateGraph(bool stack_check = true);
Graph* graph() const { return jsgraph_->graph(); }
private: private:
class Environment; class Environment;
class FrameStateBeforeAndAfter; class FrameStateBeforeAndAfter;
...@@ -34,8 +32,6 @@ class BytecodeGraphBuilder { ...@@ -34,8 +32,6 @@ class BytecodeGraphBuilder {
void CreateGraphBody(bool stack_check); void CreateGraphBody(bool stack_check);
void VisitBytecodes(); void VisitBytecodes();
Node* LoadAccumulator(Node* value);
// Get or create the node that represents the outer function closure. // Get or create the node that represents the outer function closure.
Node* GetFunctionClosure(); Node* GetFunctionClosure();
...@@ -125,42 +121,30 @@ class BytecodeGraphBuilder { ...@@ -125,42 +121,30 @@ class BytecodeGraphBuilder {
interpreter::Register first_arg, interpreter::Register first_arg,
size_t arity); size_t arity);
void BuildCreateLiteral(const Operator* op, void BuildCreateLiteral(const Operator* op);
const interpreter::BytecodeArrayIterator& iterator); void BuildCreateRegExpLiteral();
void BuildCreateRegExpLiteral( void BuildCreateArrayLiteral();
const interpreter::BytecodeArrayIterator& iterator); void BuildCreateObjectLiteral();
void BuildCreateArrayLiteral( void BuildCreateArguments(CreateArgumentsParameters::Type type);
const interpreter::BytecodeArrayIterator& iterator); void BuildLoadGlobal(TypeofMode typeof_mode);
void BuildCreateObjectLiteral( void BuildStoreGlobal();
const interpreter::BytecodeArrayIterator& iterator); void BuildNamedLoad();
void BuildCreateArguments(CreateArgumentsParameters::Type type, void BuildKeyedLoad();
const interpreter::BytecodeArrayIterator& iterator); void BuildNamedStore();
void BuildLoadGlobal(const interpreter::BytecodeArrayIterator& iterator, void BuildKeyedStore();
TypeofMode typeof_mode); void BuildLdaLookupSlot(TypeofMode typeof_mode);
void BuildStoreGlobal(const interpreter::BytecodeArrayIterator& iterator); void BuildStaLookupSlot(LanguageMode language_mode);
void BuildNamedLoad(const interpreter::BytecodeArrayIterator& iterator); void BuildCall();
void BuildKeyedLoad(const interpreter::BytecodeArrayIterator& iterator); void BuildCallJSRuntime();
void BuildNamedStore(const interpreter::BytecodeArrayIterator& iterator); void BuildCallRuntime();
void BuildKeyedStore(const interpreter::BytecodeArrayIterator& iterator); void BuildCallRuntimeForPair();
void BuildLdaLookupSlot(TypeofMode typeof_mode, void BuildCallConstruct();
const interpreter::BytecodeArrayIterator& iterator); void BuildBinaryOp(const Operator* op);
void BuildStaLookupSlot(LanguageMode language_mode, void BuildCompareOp(const Operator* op);
const interpreter::BytecodeArrayIterator& iterator); void BuildDelete();
void BuildCall(const interpreter::BytecodeArrayIterator& iterator); void BuildCastOperator(const Operator* js_op);
void BuildCallJSRuntime(const interpreter::BytecodeArrayIterator& iterator); void BuildForInPrepare();
void BuildCallRuntime(const interpreter::BytecodeArrayIterator& iterator); void BuildForInNext();
void BuildCallRuntimeForPair(
const interpreter::BytecodeArrayIterator& iterator);
void BuildCallConstruct(const interpreter::BytecodeArrayIterator& iterator);
void BuildBinaryOp(const Operator* op,
const interpreter::BytecodeArrayIterator& iterator);
void BuildCompareOp(const Operator* op,
const interpreter::BytecodeArrayIterator& iterator);
void BuildDelete(const interpreter::BytecodeArrayIterator& iterator);
void BuildCastOperator(const Operator* js_op,
const interpreter::BytecodeArrayIterator& iterator);
void BuildForInPrepare(const interpreter::BytecodeArrayIterator& iterator);
void BuildForInNext(const interpreter::BytecodeArrayIterator& iterator);
// Control flow plumbing. // Control flow plumbing.
void BuildJump(int source_offset, int target_offset); void BuildJump(int source_offset, int target_offset);
...@@ -196,6 +180,7 @@ class BytecodeGraphBuilder { ...@@ -196,6 +180,7 @@ class BytecodeGraphBuilder {
}; };
// Field accessors // Field accessors
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_; } CompilationInfo* info() const { return info_; }
...@@ -217,8 +202,8 @@ class BytecodeGraphBuilder { ...@@ -217,8 +202,8 @@ class BytecodeGraphBuilder {
return info()->language_mode(); return info()->language_mode();
} }
const interpreter::BytecodeArrayIterator* bytecode_iterator() const { const interpreter::BytecodeArrayIterator& bytecode_iterator() const {
return bytecode_iterator_; return *bytecode_iterator_;
} }
void set_bytecode_iterator( void set_bytecode_iterator(
...@@ -234,8 +219,7 @@ class BytecodeGraphBuilder { ...@@ -234,8 +219,7 @@ class BytecodeGraphBuilder {
branch_analysis_ = branch_analysis; branch_analysis_ = branch_analysis;
} }
#define DECLARE_VISIT_BYTECODE(name, ...) \ #define DECLARE_VISIT_BYTECODE(name, ...) void Visit##name();
void Visit##name(const interpreter::BytecodeArrayIterator& iterator);
BYTECODE_LIST(DECLARE_VISIT_BYTECODE) BYTECODE_LIST(DECLARE_VISIT_BYTECODE)
#undef DECLARE_VISIT_BYTECODE #undef DECLARE_VISIT_BYTECODE
......
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