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
...@@ -103,17 +103,17 @@ class BytecodeGraphBuilder::Environment : public ZoneObject { ...@@ -103,17 +103,17 @@ class BytecodeGraphBuilder::Environment : public ZoneObject {
// Helper for generating frame states for before and after a bytecode. // Helper for generating frame states for before and after a bytecode.
class BytecodeGraphBuilder::FrameStateBeforeAndAfter { class BytecodeGraphBuilder::FrameStateBeforeAndAfter {
public: public:
FrameStateBeforeAndAfter(BytecodeGraphBuilder* builder, explicit FrameStateBeforeAndAfter(BytecodeGraphBuilder* builder)
const interpreter::BytecodeArrayIterator& iterator)
: builder_(builder), : builder_(builder),
id_after_(BailoutId::None()), id_after_(BailoutId::None()),
added_to_node_(false), added_to_node_(false),
output_poke_offset_(0), output_poke_offset_(0),
output_poke_count_(0) { output_poke_count_(0) {
BailoutId id_before(iterator.current_offset()); BailoutId id_before(builder->bytecode_iterator().current_offset());
frame_state_before_ = builder_->environment()->Checkpoint( frame_state_before_ = builder_->environment()->Checkpoint(
id_before, OutputFrameStateCombine::Ignore()); id_before, OutputFrameStateCombine::Ignore());
id_after_ = BailoutId(id_before.ToInt() + iterator.current_bytecode_size()); id_after_ = BailoutId(id_before.ToInt() +
builder->bytecode_iterator().current_bytecode_size());
} }
~FrameStateBeforeAndAfter() { ~FrameStateBeforeAndAfter() {
...@@ -624,7 +624,7 @@ void BytecodeGraphBuilder::VisitBytecodes() { ...@@ -624,7 +624,7 @@ void BytecodeGraphBuilder::VisitBytecodes() {
switch (iterator.current_bytecode()) { switch (iterator.current_bytecode()) {
#define BYTECODE_CASE(name, ...) \ #define BYTECODE_CASE(name, ...) \
case interpreter::Bytecode::k##name: \ case interpreter::Bytecode::k##name: \
Visit##name(iterator); \ Visit##name(); \
break; break;
BYTECODE_LIST(BYTECODE_CASE) BYTECODE_LIST(BYTECODE_CASE)
#undef BYTECODE_CODE #undef BYTECODE_CODE
...@@ -637,173 +637,131 @@ void BytecodeGraphBuilder::VisitBytecodes() { ...@@ -637,173 +637,131 @@ void BytecodeGraphBuilder::VisitBytecodes() {
DCHECK(exception_handlers_.empty()); DCHECK(exception_handlers_.empty());
} }
void BytecodeGraphBuilder::VisitLdaZero() {
void BytecodeGraphBuilder::VisitLdaZero(
const interpreter::BytecodeArrayIterator& iterator) {
Node* node = jsgraph()->ZeroConstant(); Node* node = jsgraph()->ZeroConstant();
environment()->BindAccumulator(node); environment()->BindAccumulator(node);
} }
void BytecodeGraphBuilder::VisitLdaSmi8() {
void BytecodeGraphBuilder::VisitLdaSmi8( Node* node = jsgraph()->Constant(bytecode_iterator().GetImmediateOperand(0));
const interpreter::BytecodeArrayIterator& iterator) {
Node* node = jsgraph()->Constant(iterator.GetImmediateOperand(0));
environment()->BindAccumulator(node); environment()->BindAccumulator(node);
} }
void BytecodeGraphBuilder::VisitLdaConstantWide() {
void BytecodeGraphBuilder::VisitLdaConstantWide( Node* node =
const interpreter::BytecodeArrayIterator& iterator) { jsgraph()->Constant(bytecode_iterator().GetConstantForIndexOperand(0));
Node* node = jsgraph()->Constant(iterator.GetConstantForIndexOperand(0));
environment()->BindAccumulator(node); environment()->BindAccumulator(node);
} }
void BytecodeGraphBuilder::VisitLdaConstant() {
void BytecodeGraphBuilder::VisitLdaConstant( Node* node =
const interpreter::BytecodeArrayIterator& iterator) { jsgraph()->Constant(bytecode_iterator().GetConstantForIndexOperand(0));
Node* node = jsgraph()->Constant(iterator.GetConstantForIndexOperand(0));
environment()->BindAccumulator(node); environment()->BindAccumulator(node);
} }
void BytecodeGraphBuilder::VisitLdaUndefined() {
void BytecodeGraphBuilder::VisitLdaUndefined(
const interpreter::BytecodeArrayIterator& iterator) {
Node* node = jsgraph()->UndefinedConstant(); Node* node = jsgraph()->UndefinedConstant();
environment()->BindAccumulator(node); environment()->BindAccumulator(node);
} }
void BytecodeGraphBuilder::VisitLdaNull() {
void BytecodeGraphBuilder::VisitLdaNull(
const interpreter::BytecodeArrayIterator& iterator) {
Node* node = jsgraph()->NullConstant(); Node* node = jsgraph()->NullConstant();
environment()->BindAccumulator(node); environment()->BindAccumulator(node);
} }
void BytecodeGraphBuilder::VisitLdaTheHole() {
void BytecodeGraphBuilder::VisitLdaTheHole(
const interpreter::BytecodeArrayIterator& iterator) {
Node* node = jsgraph()->TheHoleConstant(); Node* node = jsgraph()->TheHoleConstant();
environment()->BindAccumulator(node); environment()->BindAccumulator(node);
} }
void BytecodeGraphBuilder::VisitLdaTrue() {
void BytecodeGraphBuilder::VisitLdaTrue(
const interpreter::BytecodeArrayIterator& iterator) {
Node* node = jsgraph()->TrueConstant(); Node* node = jsgraph()->TrueConstant();
environment()->BindAccumulator(node); environment()->BindAccumulator(node);
} }
void BytecodeGraphBuilder::VisitLdaFalse() {
void BytecodeGraphBuilder::VisitLdaFalse(
const interpreter::BytecodeArrayIterator& iterator) {
Node* node = jsgraph()->FalseConstant(); Node* node = jsgraph()->FalseConstant();
environment()->BindAccumulator(node); environment()->BindAccumulator(node);
} }
void BytecodeGraphBuilder::VisitLdar() {
void BytecodeGraphBuilder::VisitLdar( Node* value =
const interpreter::BytecodeArrayIterator& iterator) { environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0));
Node* value = environment()->LookupRegister(iterator.GetRegisterOperand(0));
environment()->BindAccumulator(value); environment()->BindAccumulator(value);
} }
void BytecodeGraphBuilder::VisitStar() {
void BytecodeGraphBuilder::VisitStar(
const interpreter::BytecodeArrayIterator& iterator) {
Node* value = environment()->LookupAccumulator(); Node* value = environment()->LookupAccumulator();
environment()->BindRegister(iterator.GetRegisterOperand(0), value); environment()->BindRegister(bytecode_iterator().GetRegisterOperand(0), value);
}
void BytecodeGraphBuilder::VisitMov(
const interpreter::BytecodeArrayIterator& iterator) {
Node* value = environment()->LookupRegister(iterator.GetRegisterOperand(0));
environment()->BindRegister(iterator.GetRegisterOperand(1), value);
} }
void BytecodeGraphBuilder::VisitMov() {
void BytecodeGraphBuilder::VisitMovWide( Node* value =
const interpreter::BytecodeArrayIterator& iterator) { environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0));
VisitMov(iterator); environment()->BindRegister(bytecode_iterator().GetRegisterOperand(1), value);
} }
void BytecodeGraphBuilder::VisitMovWide() { VisitMov(); }
void BytecodeGraphBuilder::BuildLoadGlobal( void BytecodeGraphBuilder::BuildLoadGlobal(
const interpreter::BytecodeArrayIterator& iterator,
TypeofMode typeof_mode) { TypeofMode typeof_mode) {
FrameStateBeforeAndAfter states(this, iterator); FrameStateBeforeAndAfter states(this);
Handle<Name> name = Handle<Name> name =
Handle<Name>::cast(iterator.GetConstantForIndexOperand(0)); Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(0));
VectorSlotPair feedback = CreateVectorSlotPair(iterator.GetIndexOperand(1)); VectorSlotPair feedback =
CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(1));
const Operator* op = javascript()->LoadGlobal(name, feedback, typeof_mode); const Operator* op = javascript()->LoadGlobal(name, feedback, typeof_mode);
Node* node = NewNode(op, BuildLoadFeedbackVector()); Node* node = NewNode(op, BuildLoadFeedbackVector());
environment()->BindAccumulator(node, &states); environment()->BindAccumulator(node, &states);
} }
void BytecodeGraphBuilder::VisitLdaGlobalSloppy() {
void BytecodeGraphBuilder::VisitLdaGlobalSloppy(
const interpreter::BytecodeArrayIterator& iterator) {
DCHECK(is_sloppy(language_mode())); DCHECK(is_sloppy(language_mode()));
BuildLoadGlobal(iterator, TypeofMode::NOT_INSIDE_TYPEOF); BuildLoadGlobal(TypeofMode::NOT_INSIDE_TYPEOF);
} }
void BytecodeGraphBuilder::VisitLdaGlobalStrict() {
void BytecodeGraphBuilder::VisitLdaGlobalStrict(
const interpreter::BytecodeArrayIterator& iterator) {
DCHECK(is_strict(language_mode())); DCHECK(is_strict(language_mode()));
BuildLoadGlobal(iterator, TypeofMode::NOT_INSIDE_TYPEOF); BuildLoadGlobal(TypeofMode::NOT_INSIDE_TYPEOF);
} }
void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeofSloppy() {
void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeofSloppy(
const interpreter::BytecodeArrayIterator& iterator) {
DCHECK(is_sloppy(language_mode())); DCHECK(is_sloppy(language_mode()));
BuildLoadGlobal(iterator, TypeofMode::INSIDE_TYPEOF); BuildLoadGlobal(TypeofMode::INSIDE_TYPEOF);
} }
void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeofStrict() {
void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeofStrict(
const interpreter::BytecodeArrayIterator& iterator) {
DCHECK(is_strict(language_mode())); DCHECK(is_strict(language_mode()));
BuildLoadGlobal(iterator, TypeofMode::INSIDE_TYPEOF); BuildLoadGlobal(TypeofMode::INSIDE_TYPEOF);
} }
void BytecodeGraphBuilder::VisitLdaGlobalSloppyWide() {
void BytecodeGraphBuilder::VisitLdaGlobalSloppyWide(
const interpreter::BytecodeArrayIterator& iterator) {
DCHECK(is_sloppy(language_mode())); DCHECK(is_sloppy(language_mode()));
BuildLoadGlobal(iterator, TypeofMode::NOT_INSIDE_TYPEOF); BuildLoadGlobal(TypeofMode::NOT_INSIDE_TYPEOF);
} }
void BytecodeGraphBuilder::VisitLdaGlobalStrictWide() {
void BytecodeGraphBuilder::VisitLdaGlobalStrictWide(
const interpreter::BytecodeArrayIterator& iterator) {
DCHECK(is_strict(language_mode())); DCHECK(is_strict(language_mode()));
BuildLoadGlobal(iterator, TypeofMode::NOT_INSIDE_TYPEOF); BuildLoadGlobal(TypeofMode::NOT_INSIDE_TYPEOF);
} }
void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeofSloppyWide() {
void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeofSloppyWide(
const interpreter::BytecodeArrayIterator& iterator) {
DCHECK(is_sloppy(language_mode())); DCHECK(is_sloppy(language_mode()));
BuildLoadGlobal(iterator, TypeofMode::INSIDE_TYPEOF); BuildLoadGlobal(TypeofMode::INSIDE_TYPEOF);
} }
void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeofStrictWide() {
void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeofStrictWide(
const interpreter::BytecodeArrayIterator& iterator) {
DCHECK(is_strict(language_mode())); DCHECK(is_strict(language_mode()));
BuildLoadGlobal(iterator, TypeofMode::INSIDE_TYPEOF); BuildLoadGlobal(TypeofMode::INSIDE_TYPEOF);
} }
void BytecodeGraphBuilder::BuildStoreGlobal() {
void BytecodeGraphBuilder::BuildStoreGlobal( FrameStateBeforeAndAfter states(this);
const interpreter::BytecodeArrayIterator& iterator) {
FrameStateBeforeAndAfter states(this, iterator);
Handle<Name> name = Handle<Name> name =
Handle<Name>::cast(iterator.GetConstantForIndexOperand(0)); Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(0));
VectorSlotPair feedback = CreateVectorSlotPair(iterator.GetIndexOperand(1)); VectorSlotPair feedback =
CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(1));
Node* value = environment()->LookupAccumulator(); Node* value = environment()->LookupAccumulator();
const Operator* op = const Operator* op =
...@@ -812,240 +770,184 @@ void BytecodeGraphBuilder::BuildStoreGlobal( ...@@ -812,240 +770,184 @@ void BytecodeGraphBuilder::BuildStoreGlobal(
environment()->RecordAfterState(node, &states); environment()->RecordAfterState(node, &states);
} }
void BytecodeGraphBuilder::VisitStaGlobalSloppy() {
void BytecodeGraphBuilder::VisitStaGlobalSloppy(
const interpreter::BytecodeArrayIterator& iterator) {
DCHECK(is_sloppy(language_mode())); DCHECK(is_sloppy(language_mode()));
BuildStoreGlobal(iterator); BuildStoreGlobal();
} }
void BytecodeGraphBuilder::VisitStaGlobalStrict() {
void BytecodeGraphBuilder::VisitStaGlobalStrict(
const interpreter::BytecodeArrayIterator& iterator) {
DCHECK(is_strict(language_mode())); DCHECK(is_strict(language_mode()));
BuildStoreGlobal(iterator); BuildStoreGlobal();
} }
void BytecodeGraphBuilder::VisitStaGlobalSloppyWide( void BytecodeGraphBuilder::VisitStaGlobalSloppyWide() {
const interpreter::BytecodeArrayIterator& iterator) {
DCHECK(is_sloppy(language_mode())); DCHECK(is_sloppy(language_mode()));
BuildStoreGlobal(iterator); BuildStoreGlobal();
} }
void BytecodeGraphBuilder::VisitStaGlobalStrictWide() {
void BytecodeGraphBuilder::VisitStaGlobalStrictWide(
const interpreter::BytecodeArrayIterator& iterator) {
DCHECK(is_strict(language_mode())); DCHECK(is_strict(language_mode()));
BuildStoreGlobal(iterator); BuildStoreGlobal();
} }
void BytecodeGraphBuilder::VisitLdaContextSlot() {
void BytecodeGraphBuilder::VisitLdaContextSlot(
const interpreter::BytecodeArrayIterator& iterator) {
// TODO(mythria): LoadContextSlots are unrolled by the required depth when // TODO(mythria): LoadContextSlots are unrolled by the required depth when
// generating bytecode. Hence the value of depth is always 0. Update this // generating bytecode. Hence the value of depth is always 0. Update this
// code, when the implementation changes. // code, when the implementation changes.
// TODO(mythria): immutable flag is also set to false. This information is not // TODO(mythria): immutable flag is also set to false. This information is not
// available in bytecode array. update this code when the implementation // available in bytecode array. update this code when the implementation
// changes. // changes.
const Operator* op = const Operator* op = javascript()->LoadContext(
javascript()->LoadContext(0, iterator.GetIndexOperand(1), false); 0, bytecode_iterator().GetIndexOperand(1), false);
Node* context = environment()->LookupRegister(iterator.GetRegisterOperand(0)); Node* context =
environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0));
Node* node = NewNode(op, context); Node* node = NewNode(op, context);
environment()->BindAccumulator(node); environment()->BindAccumulator(node);
} }
void BytecodeGraphBuilder::VisitLdaContextSlotWide() { VisitLdaContextSlot(); }
void BytecodeGraphBuilder::VisitLdaContextSlotWide( void BytecodeGraphBuilder::VisitStaContextSlot() {
const interpreter::BytecodeArrayIterator& iterator) {
VisitLdaContextSlot(iterator);
}
void BytecodeGraphBuilder::VisitStaContextSlot(
const interpreter::BytecodeArrayIterator& iterator) {
// TODO(mythria): LoadContextSlots are unrolled by the required depth when // TODO(mythria): LoadContextSlots are unrolled by the required depth when
// generating bytecode. Hence the value of depth is always 0. Update this // generating bytecode. Hence the value of depth is always 0. Update this
// code, when the implementation changes. // code, when the implementation changes.
const Operator* op = const Operator* op =
javascript()->StoreContext(0, iterator.GetIndexOperand(1)); javascript()->StoreContext(0, bytecode_iterator().GetIndexOperand(1));
Node* context = environment()->LookupRegister(iterator.GetRegisterOperand(0)); Node* context =
environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0));
Node* value = environment()->LookupAccumulator(); Node* value = environment()->LookupAccumulator();
NewNode(op, context, value); NewNode(op, context, value);
} }
void BytecodeGraphBuilder::VisitStaContextSlotWide() { VisitStaContextSlot(); }
void BytecodeGraphBuilder::VisitStaContextSlotWide( void BytecodeGraphBuilder::BuildLdaLookupSlot(TypeofMode typeof_mode) {
const interpreter::BytecodeArrayIterator& iterator) { FrameStateBeforeAndAfter states(this);
VisitStaContextSlot(iterator);
}
void BytecodeGraphBuilder::BuildLdaLookupSlot(
TypeofMode typeof_mode,
const interpreter::BytecodeArrayIterator& iterator) {
FrameStateBeforeAndAfter states(this, iterator);
Handle<String> name = Handle<String> name =
Handle<String>::cast(iterator.GetConstantForIndexOperand(0)); Handle<String>::cast(bytecode_iterator().GetConstantForIndexOperand(0));
const Operator* op = javascript()->LoadDynamic(name, typeof_mode); const Operator* op = javascript()->LoadDynamic(name, typeof_mode);
Node* value = Node* value =
NewNode(op, BuildLoadFeedbackVector(), environment()->Context()); NewNode(op, BuildLoadFeedbackVector(), environment()->Context());
environment()->BindAccumulator(value, &states); environment()->BindAccumulator(value, &states);
} }
void BytecodeGraphBuilder::VisitLdaLookupSlot() {
void BytecodeGraphBuilder::VisitLdaLookupSlot( BuildLdaLookupSlot(TypeofMode::NOT_INSIDE_TYPEOF);
const interpreter::BytecodeArrayIterator& iterator) {
BuildLdaLookupSlot(TypeofMode::NOT_INSIDE_TYPEOF, iterator);
} }
void BytecodeGraphBuilder::VisitLdaLookupSlotInsideTypeof() {
void BytecodeGraphBuilder::VisitLdaLookupSlotInsideTypeof( BuildLdaLookupSlot(TypeofMode::INSIDE_TYPEOF);
const interpreter::BytecodeArrayIterator& iterator) {
BuildLdaLookupSlot(TypeofMode::INSIDE_TYPEOF, iterator);
} }
void BytecodeGraphBuilder::BuildStaLookupSlot(LanguageMode language_mode) {
void BytecodeGraphBuilder::BuildStaLookupSlot( FrameStateBeforeAndAfter states(this);
LanguageMode language_mode,
const interpreter::BytecodeArrayIterator& iterator) {
FrameStateBeforeAndAfter states(this, iterator);
Node* value = environment()->LookupAccumulator(); Node* value = environment()->LookupAccumulator();
Node* name = jsgraph()->Constant(iterator.GetConstantForIndexOperand(0)); Node* name =
jsgraph()->Constant(bytecode_iterator().GetConstantForIndexOperand(0));
Node* language = jsgraph()->Constant(language_mode); Node* language = jsgraph()->Constant(language_mode);
const Operator* op = javascript()->CallRuntime(Runtime::kStoreLookupSlot); const Operator* op = javascript()->CallRuntime(Runtime::kStoreLookupSlot);
Node* store = NewNode(op, value, environment()->Context(), name, language); Node* store = NewNode(op, value, environment()->Context(), name, language);
environment()->BindAccumulator(store, &states); environment()->BindAccumulator(store, &states);
} }
void BytecodeGraphBuilder::VisitLdaLookupSlotWide() { VisitLdaLookupSlot(); }
void BytecodeGraphBuilder::VisitLdaLookupSlotWide( void BytecodeGraphBuilder::VisitLdaLookupSlotInsideTypeofWide() {
const interpreter::BytecodeArrayIterator& iterator) { VisitLdaLookupSlotInsideTypeof();
VisitLdaLookupSlot(iterator);
} }
void BytecodeGraphBuilder::VisitStaLookupSlotSloppy() {
void BytecodeGraphBuilder::VisitLdaLookupSlotInsideTypeofWide( BuildStaLookupSlot(LanguageMode::SLOPPY);
const interpreter::BytecodeArrayIterator& iterator) {
VisitLdaLookupSlotInsideTypeof(iterator);
} }
void BytecodeGraphBuilder::VisitStaLookupSlotStrict() {
void BytecodeGraphBuilder::VisitStaLookupSlotSloppy( BuildStaLookupSlot(LanguageMode::STRICT);
const interpreter::BytecodeArrayIterator& iterator) {
BuildStaLookupSlot(LanguageMode::SLOPPY, iterator);
} }
void BytecodeGraphBuilder::VisitStaLookupSlotSloppyWide() {
void BytecodeGraphBuilder::VisitStaLookupSlotStrict( VisitStaLookupSlotSloppy();
const interpreter::BytecodeArrayIterator& iterator) {
BuildStaLookupSlot(LanguageMode::STRICT, iterator);
} }
void BytecodeGraphBuilder::VisitStaLookupSlotStrictWide() {
void BytecodeGraphBuilder::VisitStaLookupSlotSloppyWide( VisitStaLookupSlotStrict();
const interpreter::BytecodeArrayIterator& iterator) {
VisitStaLookupSlotSloppy(iterator);
} }
void BytecodeGraphBuilder::BuildNamedLoad() {
void BytecodeGraphBuilder::VisitStaLookupSlotStrictWide( FrameStateBeforeAndAfter states(this);
const interpreter::BytecodeArrayIterator& iterator) { Node* object =
VisitStaLookupSlotStrict(iterator); environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0));
}
void BytecodeGraphBuilder::BuildNamedLoad(
const interpreter::BytecodeArrayIterator& iterator) {
FrameStateBeforeAndAfter states(this, iterator);
Node* object = environment()->LookupRegister(iterator.GetRegisterOperand(0));
Handle<Name> name = Handle<Name> name =
Handle<Name>::cast(iterator.GetConstantForIndexOperand(1)); Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(1));
VectorSlotPair feedback = CreateVectorSlotPair(iterator.GetIndexOperand(2)); VectorSlotPair feedback =
CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(2));
const Operator* op = javascript()->LoadNamed(language_mode(), name, feedback); const Operator* op = javascript()->LoadNamed(language_mode(), name, feedback);
Node* node = NewNode(op, object, BuildLoadFeedbackVector()); Node* node = NewNode(op, object, BuildLoadFeedbackVector());
environment()->BindAccumulator(node, &states); environment()->BindAccumulator(node, &states);
} }
void BytecodeGraphBuilder::VisitLoadICSloppy() {
void BytecodeGraphBuilder::VisitLoadICSloppy(
const interpreter::BytecodeArrayIterator& iterator) {
DCHECK(is_sloppy(language_mode())); DCHECK(is_sloppy(language_mode()));
BuildNamedLoad(iterator); BuildNamedLoad();
} }
void BytecodeGraphBuilder::VisitLoadICStrict() {
void BytecodeGraphBuilder::VisitLoadICStrict(
const interpreter::BytecodeArrayIterator& iterator) {
DCHECK(is_strict(language_mode())); DCHECK(is_strict(language_mode()));
BuildNamedLoad(iterator); BuildNamedLoad();
} }
void BytecodeGraphBuilder::VisitLoadICSloppyWide() {
void BytecodeGraphBuilder::VisitLoadICSloppyWide(
const interpreter::BytecodeArrayIterator& iterator) {
DCHECK(is_sloppy(language_mode())); DCHECK(is_sloppy(language_mode()));
BuildNamedLoad(iterator); BuildNamedLoad();
} }
void BytecodeGraphBuilder::VisitLoadICStrictWide() {
void BytecodeGraphBuilder::VisitLoadICStrictWide(
const interpreter::BytecodeArrayIterator& iterator) {
DCHECK(is_strict(language_mode())); DCHECK(is_strict(language_mode()));
BuildNamedLoad(iterator); BuildNamedLoad();
} }
void BytecodeGraphBuilder::BuildKeyedLoad() {
void BytecodeGraphBuilder::BuildKeyedLoad( FrameStateBeforeAndAfter states(this);
const interpreter::BytecodeArrayIterator& iterator) {
FrameStateBeforeAndAfter states(this, iterator);
Node* key = environment()->LookupAccumulator(); Node* key = environment()->LookupAccumulator();
Node* object = environment()->LookupRegister(iterator.GetRegisterOperand(0)); Node* object =
VectorSlotPair feedback = CreateVectorSlotPair(iterator.GetIndexOperand(1)); environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0));
VectorSlotPair feedback =
CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(1));
const Operator* op = javascript()->LoadProperty(language_mode(), feedback); const Operator* op = javascript()->LoadProperty(language_mode(), feedback);
Node* node = NewNode(op, object, key, BuildLoadFeedbackVector()); Node* node = NewNode(op, object, key, BuildLoadFeedbackVector());
environment()->BindAccumulator(node, &states); environment()->BindAccumulator(node, &states);
} }
void BytecodeGraphBuilder::VisitKeyedLoadICSloppy() {
void BytecodeGraphBuilder::VisitKeyedLoadICSloppy(
const interpreter::BytecodeArrayIterator& iterator) {
DCHECK(is_sloppy(language_mode())); DCHECK(is_sloppy(language_mode()));
BuildKeyedLoad(iterator); BuildKeyedLoad();
} }
void BytecodeGraphBuilder::VisitKeyedLoadICStrict() {
void BytecodeGraphBuilder::VisitKeyedLoadICStrict(
const interpreter::BytecodeArrayIterator& iterator) {
DCHECK(is_strict(language_mode())); DCHECK(is_strict(language_mode()));
BuildKeyedLoad(iterator); BuildKeyedLoad();
} }
void BytecodeGraphBuilder::VisitKeyedLoadICSloppyWide() {
void BytecodeGraphBuilder::VisitKeyedLoadICSloppyWide(
const interpreter::BytecodeArrayIterator& iterator) {
DCHECK(is_sloppy(language_mode())); DCHECK(is_sloppy(language_mode()));
BuildKeyedLoad(iterator); BuildKeyedLoad();
} }
void BytecodeGraphBuilder::VisitKeyedLoadICStrictWide() {
void BytecodeGraphBuilder::VisitKeyedLoadICStrictWide(
const interpreter::BytecodeArrayIterator& iterator) {
DCHECK(is_strict(language_mode())); DCHECK(is_strict(language_mode()));
BuildKeyedLoad(iterator); BuildKeyedLoad();
} }
void BytecodeGraphBuilder::BuildNamedStore() {
void BytecodeGraphBuilder::BuildNamedStore( FrameStateBeforeAndAfter states(this);
const interpreter::BytecodeArrayIterator& iterator) {
FrameStateBeforeAndAfter states(this, iterator);
Node* value = environment()->LookupAccumulator(); Node* value = environment()->LookupAccumulator();
Node* object = environment()->LookupRegister(iterator.GetRegisterOperand(0)); Node* object =
environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0));
Handle<Name> name = Handle<Name> name =
Handle<Name>::cast(iterator.GetConstantForIndexOperand(1)); Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(1));
VectorSlotPair feedback = CreateVectorSlotPair(iterator.GetIndexOperand(2)); VectorSlotPair feedback =
CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(2));
const Operator* op = const Operator* op =
javascript()->StoreNamed(language_mode(), name, feedback); javascript()->StoreNamed(language_mode(), name, feedback);
...@@ -1053,210 +955,160 @@ void BytecodeGraphBuilder::BuildNamedStore( ...@@ -1053,210 +955,160 @@ void BytecodeGraphBuilder::BuildNamedStore(
environment()->RecordAfterState(node, &states); environment()->RecordAfterState(node, &states);
} }
void BytecodeGraphBuilder::VisitStoreICSloppy() {
void BytecodeGraphBuilder::VisitStoreICSloppy(
const interpreter::BytecodeArrayIterator& iterator) {
DCHECK(is_sloppy(language_mode())); DCHECK(is_sloppy(language_mode()));
BuildNamedStore(iterator); BuildNamedStore();
} }
void BytecodeGraphBuilder::VisitStoreICStrict() {
void BytecodeGraphBuilder::VisitStoreICStrict(
const interpreter::BytecodeArrayIterator& iterator) {
DCHECK(is_strict(language_mode())); DCHECK(is_strict(language_mode()));
BuildNamedStore(iterator); BuildNamedStore();
} }
void BytecodeGraphBuilder::VisitStoreICSloppyWide() {
void BytecodeGraphBuilder::VisitStoreICSloppyWide(
const interpreter::BytecodeArrayIterator& iterator) {
DCHECK(is_sloppy(language_mode())); DCHECK(is_sloppy(language_mode()));
BuildNamedStore(iterator); BuildNamedStore();
} }
void BytecodeGraphBuilder::VisitStoreICStrictWide() {
void BytecodeGraphBuilder::VisitStoreICStrictWide(
const interpreter::BytecodeArrayIterator& iterator) {
DCHECK(is_strict(language_mode())); DCHECK(is_strict(language_mode()));
BuildNamedStore(iterator); BuildNamedStore();
} }
void BytecodeGraphBuilder::BuildKeyedStore() {
void BytecodeGraphBuilder::BuildKeyedStore( FrameStateBeforeAndAfter states(this);
const interpreter::BytecodeArrayIterator& iterator) {
FrameStateBeforeAndAfter states(this, iterator);
Node* value = environment()->LookupAccumulator(); Node* value = environment()->LookupAccumulator();
Node* object = environment()->LookupRegister(iterator.GetRegisterOperand(0)); Node* object =
Node* key = environment()->LookupRegister(iterator.GetRegisterOperand(1)); environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0));
VectorSlotPair feedback = CreateVectorSlotPair(iterator.GetIndexOperand(2)); Node* key =
environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(1));
VectorSlotPair feedback =
CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(2));
const Operator* op = javascript()->StoreProperty(language_mode(), feedback); const Operator* op = javascript()->StoreProperty(language_mode(), feedback);
Node* node = NewNode(op, object, key, value, BuildLoadFeedbackVector()); Node* node = NewNode(op, object, key, value, BuildLoadFeedbackVector());
environment()->RecordAfterState(node, &states); environment()->RecordAfterState(node, &states);
} }
void BytecodeGraphBuilder::VisitKeyedStoreICSloppy() {
void BytecodeGraphBuilder::VisitKeyedStoreICSloppy(
const interpreter::BytecodeArrayIterator& iterator) {
DCHECK(is_sloppy(language_mode())); DCHECK(is_sloppy(language_mode()));
BuildKeyedStore(iterator); BuildKeyedStore();
} }
void BytecodeGraphBuilder::VisitKeyedStoreICStrict() {
void BytecodeGraphBuilder::VisitKeyedStoreICStrict(
const interpreter::BytecodeArrayIterator& iterator) {
DCHECK(is_strict(language_mode())); DCHECK(is_strict(language_mode()));
BuildKeyedStore(iterator); BuildKeyedStore();
} }
void BytecodeGraphBuilder::VisitKeyedStoreICSloppyWide() {
void BytecodeGraphBuilder::VisitKeyedStoreICSloppyWide(
const interpreter::BytecodeArrayIterator& iterator) {
DCHECK(is_sloppy(language_mode())); DCHECK(is_sloppy(language_mode()));
BuildKeyedStore(iterator); BuildKeyedStore();
} }
void BytecodeGraphBuilder::VisitKeyedStoreICStrictWide() {
void BytecodeGraphBuilder::VisitKeyedStoreICStrictWide(
const interpreter::BytecodeArrayIterator& iterator) {
DCHECK(is_strict(language_mode())); DCHECK(is_strict(language_mode()));
BuildKeyedStore(iterator); BuildKeyedStore();
} }
void BytecodeGraphBuilder::VisitPushContext() {
void BytecodeGraphBuilder::VisitPushContext(
const interpreter::BytecodeArrayIterator& iterator) {
Node* new_context = environment()->LookupAccumulator(); Node* new_context = environment()->LookupAccumulator();
environment()->BindRegister(iterator.GetRegisterOperand(0), environment()->BindRegister(bytecode_iterator().GetRegisterOperand(0),
environment()->Context()); environment()->Context());
environment()->SetContext(new_context); environment()->SetContext(new_context);
} }
void BytecodeGraphBuilder::VisitPopContext() {
void BytecodeGraphBuilder::VisitPopContext( Node* context =
const interpreter::BytecodeArrayIterator& iterator) { environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0));
Node* context = environment()->LookupRegister(iterator.GetRegisterOperand(0));
environment()->SetContext(context); environment()->SetContext(context);
} }
void BytecodeGraphBuilder::VisitCreateClosure() {
void BytecodeGraphBuilder::VisitCreateClosure( Handle<SharedFunctionInfo> shared_info = Handle<SharedFunctionInfo>::cast(
const interpreter::BytecodeArrayIterator& iterator) { bytecode_iterator().GetConstantForIndexOperand(0));
Handle<SharedFunctionInfo> shared_info =
Handle<SharedFunctionInfo>::cast(iterator.GetConstantForIndexOperand(0));
PretenureFlag tenured = PretenureFlag tenured =
iterator.GetImmediateOperand(1) ? TENURED : NOT_TENURED; bytecode_iterator().GetImmediateOperand(1) ? TENURED : NOT_TENURED;
const Operator* op = javascript()->CreateClosure(shared_info, tenured); const Operator* op = javascript()->CreateClosure(shared_info, tenured);
Node* closure = NewNode(op); Node* closure = NewNode(op);
environment()->BindAccumulator(closure); environment()->BindAccumulator(closure);
} }
void BytecodeGraphBuilder::VisitCreateClosureWide() { VisitCreateClosure(); }
void BytecodeGraphBuilder::VisitCreateClosureWide(
const interpreter::BytecodeArrayIterator& iterator) {
VisitCreateClosure(iterator);
}
void BytecodeGraphBuilder::BuildCreateArguments( void BytecodeGraphBuilder::BuildCreateArguments(
CreateArgumentsParameters::Type type, CreateArgumentsParameters::Type type) {
const interpreter::BytecodeArrayIterator& iterator) { FrameStateBeforeAndAfter states(this);
FrameStateBeforeAndAfter states(this, iterator);
const Operator* op = javascript()->CreateArguments(type, 0); const Operator* op = javascript()->CreateArguments(type, 0);
Node* object = NewNode(op, GetFunctionClosure()); Node* object = NewNode(op, GetFunctionClosure());
environment()->BindAccumulator(object, &states); environment()->BindAccumulator(object, &states);
} }
void BytecodeGraphBuilder::VisitCreateMappedArguments() {
void BytecodeGraphBuilder::VisitCreateMappedArguments( BuildCreateArguments(CreateArgumentsParameters::kMappedArguments);
const interpreter::BytecodeArrayIterator& iterator) {
BuildCreateArguments(CreateArgumentsParameters::kMappedArguments, iterator);
} }
void BytecodeGraphBuilder::VisitCreateUnmappedArguments() {
void BytecodeGraphBuilder::VisitCreateUnmappedArguments( BuildCreateArguments(CreateArgumentsParameters::kUnmappedArguments);
const interpreter::BytecodeArrayIterator& iterator) {
BuildCreateArguments(CreateArgumentsParameters::kUnmappedArguments, iterator);
} }
void BytecodeGraphBuilder::BuildCreateLiteral(const Operator* op) {
void BytecodeGraphBuilder::BuildCreateLiteral( FrameStateBeforeAndAfter states(this);
const Operator* op, const interpreter::BytecodeArrayIterator& iterator) {
FrameStateBeforeAndAfter states(this, iterator);
Node* literal = NewNode(op, GetFunctionClosure()); Node* literal = NewNode(op, GetFunctionClosure());
environment()->BindAccumulator(literal, &states); environment()->BindAccumulator(literal, &states);
} }
void BytecodeGraphBuilder::BuildCreateRegExpLiteral() {
void BytecodeGraphBuilder::BuildCreateRegExpLiteral(
const interpreter::BytecodeArrayIterator& iterator) {
Handle<String> constant_pattern = Handle<String> constant_pattern =
Handle<String>::cast(iterator.GetConstantForIndexOperand(0)); Handle<String>::cast(bytecode_iterator().GetConstantForIndexOperand(0));
int literal_index = iterator.GetIndexOperand(1); int literal_index = bytecode_iterator().GetIndexOperand(1);
int literal_flags = iterator.GetImmediateOperand(2); int literal_flags = bytecode_iterator().GetImmediateOperand(2);
const Operator* op = javascript()->CreateLiteralRegExp( const Operator* op = javascript()->CreateLiteralRegExp(
constant_pattern, literal_flags, literal_index); constant_pattern, literal_flags, literal_index);
BuildCreateLiteral(op, iterator); BuildCreateLiteral(op);
} }
void BytecodeGraphBuilder::VisitCreateRegExpLiteral() {
void BytecodeGraphBuilder::VisitCreateRegExpLiteral( BuildCreateRegExpLiteral();
const interpreter::BytecodeArrayIterator& iterator) {
BuildCreateRegExpLiteral(iterator);
} }
void BytecodeGraphBuilder::VisitCreateRegExpLiteralWide() {
void BytecodeGraphBuilder::VisitCreateRegExpLiteralWide( BuildCreateRegExpLiteral();
const interpreter::BytecodeArrayIterator& iterator) {
BuildCreateRegExpLiteral(iterator);
} }
void BytecodeGraphBuilder::BuildCreateArrayLiteral() {
void BytecodeGraphBuilder::BuildCreateArrayLiteral( Handle<FixedArray> constant_elements = Handle<FixedArray>::cast(
const interpreter::BytecodeArrayIterator& iterator) { bytecode_iterator().GetConstantForIndexOperand(0));
Handle<FixedArray> constant_elements = int literal_index = bytecode_iterator().GetIndexOperand(1);
Handle<FixedArray>::cast(iterator.GetConstantForIndexOperand(0)); int literal_flags = bytecode_iterator().GetImmediateOperand(2);
int literal_index = iterator.GetIndexOperand(1);
int literal_flags = iterator.GetImmediateOperand(2);
const Operator* op = javascript()->CreateLiteralArray( const Operator* op = javascript()->CreateLiteralArray(
constant_elements, literal_flags, literal_index); constant_elements, literal_flags, literal_index);
BuildCreateLiteral(op, iterator); BuildCreateLiteral(op);
} }
void BytecodeGraphBuilder::VisitCreateArrayLiteral() {
void BytecodeGraphBuilder::VisitCreateArrayLiteral( BuildCreateArrayLiteral();
const interpreter::BytecodeArrayIterator& iterator) {
BuildCreateArrayLiteral(iterator);
} }
void BytecodeGraphBuilder::VisitCreateArrayLiteralWide() {
void BytecodeGraphBuilder::VisitCreateArrayLiteralWide( BuildCreateArrayLiteral();
const interpreter::BytecodeArrayIterator& iterator) {
BuildCreateArrayLiteral(iterator);
} }
void BytecodeGraphBuilder::BuildCreateObjectLiteral() {
void BytecodeGraphBuilder::BuildCreateObjectLiteral( Handle<FixedArray> constant_properties = Handle<FixedArray>::cast(
const interpreter::BytecodeArrayIterator& iterator) { bytecode_iterator().GetConstantForIndexOperand(0));
Handle<FixedArray> constant_properties = int literal_index = bytecode_iterator().GetIndexOperand(1);
Handle<FixedArray>::cast(iterator.GetConstantForIndexOperand(0)); int literal_flags = bytecode_iterator().GetImmediateOperand(2);
int literal_index = iterator.GetIndexOperand(1);
int literal_flags = iterator.GetImmediateOperand(2);
const Operator* op = javascript()->CreateLiteralObject( const Operator* op = javascript()->CreateLiteralObject(
constant_properties, literal_flags, literal_index); constant_properties, literal_flags, literal_index);
BuildCreateLiteral(op, iterator); BuildCreateLiteral(op);
} }
void BytecodeGraphBuilder::VisitCreateObjectLiteral() {
void BytecodeGraphBuilder::VisitCreateObjectLiteral( BuildCreateObjectLiteral();
const interpreter::BytecodeArrayIterator& iterator) {
BuildCreateObjectLiteral(iterator);
} }
void BytecodeGraphBuilder::VisitCreateObjectLiteralWide() {
void BytecodeGraphBuilder::VisitCreateObjectLiteralWide( BuildCreateObjectLiteral();
const interpreter::BytecodeArrayIterator& iterator) {
BuildCreateObjectLiteral(iterator);
} }
...@@ -1276,18 +1128,18 @@ Node* BytecodeGraphBuilder::ProcessCallArguments(const Operator* call_op, ...@@ -1276,18 +1128,18 @@ Node* BytecodeGraphBuilder::ProcessCallArguments(const Operator* call_op,
return value; return value;
} }
void BytecodeGraphBuilder::BuildCall() {
void BytecodeGraphBuilder::BuildCall( FrameStateBeforeAndAfter states(this);
const interpreter::BytecodeArrayIterator& iterator) {
FrameStateBeforeAndAfter states(this, iterator);
// TODO(rmcilroy): Set receiver_hint correctly based on whether the receiver // TODO(rmcilroy): Set receiver_hint correctly based on whether the receiver
// register has been loaded with null / undefined explicitly or we are sure it // register has been loaded with null / undefined explicitly or we are sure it
// is not null / undefined. // is not null / undefined.
ConvertReceiverMode receiver_hint = ConvertReceiverMode::kAny; ConvertReceiverMode receiver_hint = ConvertReceiverMode::kAny;
Node* callee = environment()->LookupRegister(iterator.GetRegisterOperand(0)); Node* callee =
interpreter::Register receiver = iterator.GetRegisterOperand(1); environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0));
size_t arg_count = iterator.GetCountOperand(2); interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1);
VectorSlotPair feedback = CreateVectorSlotPair(iterator.GetIndexOperand(3)); size_t arg_count = bytecode_iterator().GetCountOperand(2);
VectorSlotPair feedback =
CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(3));
// TODO(ishell): provide correct tail_call_mode value to CallFunction. // TODO(ishell): provide correct tail_call_mode value to CallFunction.
const Operator* call = javascript()->CallFunction( const Operator* call = javascript()->CallFunction(
...@@ -1296,25 +1148,16 @@ void BytecodeGraphBuilder::BuildCall( ...@@ -1296,25 +1148,16 @@ void BytecodeGraphBuilder::BuildCall(
environment()->BindAccumulator(value, &states); environment()->BindAccumulator(value, &states);
} }
void BytecodeGraphBuilder::VisitCall() { BuildCall(); }
void BytecodeGraphBuilder::VisitCall( void BytecodeGraphBuilder::VisitCallWide() { BuildCall(); }
const interpreter::BytecodeArrayIterator& iterator) {
BuildCall(iterator);
}
void BytecodeGraphBuilder::VisitCallWide(
const interpreter::BytecodeArrayIterator& iterator) {
BuildCall(iterator);
}
void BytecodeGraphBuilder::BuildCallJSRuntime( void BytecodeGraphBuilder::BuildCallJSRuntime() {
const interpreter::BytecodeArrayIterator& iterator) { FrameStateBeforeAndAfter states(this);
FrameStateBeforeAndAfter states(this, iterator); Node* callee =
Node* callee = BuildLoadNativeContextField(iterator.GetIndexOperand(0)); BuildLoadNativeContextField(bytecode_iterator().GetIndexOperand(0));
interpreter::Register receiver = iterator.GetRegisterOperand(1); interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1);
size_t arg_count = iterator.GetCountOperand(2); size_t arg_count = bytecode_iterator().GetCountOperand(2);
// Create node to perform the JS runtime call. // Create node to perform the JS runtime call.
const Operator* call = const Operator* call =
...@@ -1323,18 +1166,9 @@ void BytecodeGraphBuilder::BuildCallJSRuntime( ...@@ -1323,18 +1166,9 @@ void BytecodeGraphBuilder::BuildCallJSRuntime(
environment()->BindAccumulator(value, &states); environment()->BindAccumulator(value, &states);
} }
void BytecodeGraphBuilder::VisitCallJSRuntime() { BuildCallJSRuntime(); }
void BytecodeGraphBuilder::VisitCallJSRuntime( void BytecodeGraphBuilder::VisitCallJSRuntimeWide() { BuildCallJSRuntime(); }
const interpreter::BytecodeArrayIterator& iterator) {
BuildCallJSRuntime(iterator);
}
void BytecodeGraphBuilder::VisitCallJSRuntimeWide(
const interpreter::BytecodeArrayIterator& iterator) {
BuildCallJSRuntime(iterator);
}
Node* BytecodeGraphBuilder::ProcessCallRuntimeArguments( Node* BytecodeGraphBuilder::ProcessCallRuntimeArguments(
const Operator* call_runtime_op, interpreter::Register first_arg, const Operator* call_runtime_op, interpreter::Register first_arg,
...@@ -1349,14 +1183,12 @@ Node* BytecodeGraphBuilder::ProcessCallRuntimeArguments( ...@@ -1349,14 +1183,12 @@ Node* BytecodeGraphBuilder::ProcessCallRuntimeArguments(
return value; return value;
} }
void BytecodeGraphBuilder::BuildCallRuntime() {
void BytecodeGraphBuilder::BuildCallRuntime( FrameStateBeforeAndAfter states(this);
const interpreter::BytecodeArrayIterator& iterator) {
FrameStateBeforeAndAfter states(this, iterator);
Runtime::FunctionId functionId = Runtime::FunctionId functionId =
static_cast<Runtime::FunctionId>(iterator.GetIndexOperand(0)); static_cast<Runtime::FunctionId>(bytecode_iterator().GetIndexOperand(0));
interpreter::Register first_arg = iterator.GetRegisterOperand(1); interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1);
size_t arg_count = iterator.GetCountOperand(2); size_t arg_count = bytecode_iterator().GetCountOperand(2);
// Create node to perform the runtime call. // Create node to perform the runtime call.
const Operator* call = javascript()->CallRuntime(functionId, arg_count); const Operator* call = javascript()->CallRuntime(functionId, arg_count);
...@@ -1364,27 +1196,18 @@ void BytecodeGraphBuilder::BuildCallRuntime( ...@@ -1364,27 +1196,18 @@ void BytecodeGraphBuilder::BuildCallRuntime(
environment()->BindAccumulator(value, &states); environment()->BindAccumulator(value, &states);
} }
void BytecodeGraphBuilder::VisitCallRuntime() { BuildCallRuntime(); }
void BytecodeGraphBuilder::VisitCallRuntime( void BytecodeGraphBuilder::VisitCallRuntimeWide() { BuildCallRuntime(); }
const interpreter::BytecodeArrayIterator& iterator) {
BuildCallRuntime(iterator);
}
void BytecodeGraphBuilder::VisitCallRuntimeWide(
const interpreter::BytecodeArrayIterator& iterator) {
BuildCallRuntime(iterator);
}
void BytecodeGraphBuilder::BuildCallRuntimeForPair( void BytecodeGraphBuilder::BuildCallRuntimeForPair() {
const interpreter::BytecodeArrayIterator& iterator) { FrameStateBeforeAndAfter states(this);
FrameStateBeforeAndAfter states(this, iterator);
Runtime::FunctionId functionId = Runtime::FunctionId functionId =
static_cast<Runtime::FunctionId>(iterator.GetIndexOperand(0)); static_cast<Runtime::FunctionId>(bytecode_iterator().GetIndexOperand(0));
interpreter::Register first_arg = iterator.GetRegisterOperand(1); interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1);
size_t arg_count = iterator.GetCountOperand(2); size_t arg_count = bytecode_iterator().GetCountOperand(2);
interpreter::Register first_return = iterator.GetRegisterOperand(3); interpreter::Register first_return =
bytecode_iterator().GetRegisterOperand(3);
// Create node to perform the runtime call. // Create node to perform the runtime call.
const Operator* call = javascript()->CallRuntime(functionId, arg_count); const Operator* call = javascript()->CallRuntime(functionId, arg_count);
...@@ -1392,16 +1215,12 @@ void BytecodeGraphBuilder::BuildCallRuntimeForPair( ...@@ -1392,16 +1215,12 @@ void BytecodeGraphBuilder::BuildCallRuntimeForPair(
environment()->BindRegistersToProjections(first_return, return_pair, &states); environment()->BindRegistersToProjections(first_return, return_pair, &states);
} }
void BytecodeGraphBuilder::VisitCallRuntimeForPair() {
void BytecodeGraphBuilder::VisitCallRuntimeForPair( BuildCallRuntimeForPair();
const interpreter::BytecodeArrayIterator& iterator) {
BuildCallRuntimeForPair(iterator);
} }
void BytecodeGraphBuilder::VisitCallRuntimeForPairWide() {
void BytecodeGraphBuilder::VisitCallRuntimeForPairWide( BuildCallRuntimeForPair();
const interpreter::BytecodeArrayIterator& iterator) {
BuildCallRuntimeForPair(iterator);
} }
...@@ -1421,13 +1240,11 @@ Node* BytecodeGraphBuilder::ProcessCallNewArguments( ...@@ -1421,13 +1240,11 @@ Node* BytecodeGraphBuilder::ProcessCallNewArguments(
return value; return value;
} }
void BytecodeGraphBuilder::BuildCallConstruct() {
void BytecodeGraphBuilder::BuildCallConstruct( FrameStateBeforeAndAfter states(this);
const interpreter::BytecodeArrayIterator& iterator) { interpreter::Register callee = bytecode_iterator().GetRegisterOperand(0);
FrameStateBeforeAndAfter states(this, iterator); interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1);
interpreter::Register callee = iterator.GetRegisterOperand(0); size_t arg_count = bytecode_iterator().GetCountOperand(2);
interpreter::Register first_arg = iterator.GetRegisterOperand(1);
size_t arg_count = iterator.GetCountOperand(2);
// TODO(turbofan): Pass the feedback here. // TODO(turbofan): Pass the feedback here.
const Operator* call = javascript()->CallConstruct( const Operator* call = javascript()->CallConstruct(
...@@ -1436,22 +1253,12 @@ void BytecodeGraphBuilder::BuildCallConstruct( ...@@ -1436,22 +1253,12 @@ void BytecodeGraphBuilder::BuildCallConstruct(
environment()->BindAccumulator(value, &states); environment()->BindAccumulator(value, &states);
} }
void BytecodeGraphBuilder::VisitNew() { BuildCallConstruct(); }
void BytecodeGraphBuilder::VisitNew( void BytecodeGraphBuilder::VisitNewWide() { BuildCallConstruct(); }
const interpreter::BytecodeArrayIterator& iterator) {
BuildCallConstruct(iterator);
}
void BytecodeGraphBuilder::VisitNewWide(
const interpreter::BytecodeArrayIterator& iterator) {
BuildCallConstruct(iterator);
}
void BytecodeGraphBuilder::VisitThrow() {
void BytecodeGraphBuilder::VisitThrow( FrameStateBeforeAndAfter states(this);
const interpreter::BytecodeArrayIterator& iterator) {
FrameStateBeforeAndAfter states(this, iterator);
Node* value = environment()->LookupAccumulator(); Node* value = environment()->LookupAccumulator();
Node* call = NewNode(javascript()->CallRuntime(Runtime::kThrow), value); Node* call = NewNode(javascript()->CallRuntime(Runtime::kThrow), value);
environment()->RecordAfterState(call, &states); environment()->RecordAfterState(call, &states);
...@@ -1459,10 +1266,8 @@ void BytecodeGraphBuilder::VisitThrow( ...@@ -1459,10 +1266,8 @@ void BytecodeGraphBuilder::VisitThrow(
UpdateControlDependencyToLeaveFunction(control); UpdateControlDependencyToLeaveFunction(control);
} }
void BytecodeGraphBuilder::VisitReThrow() {
void BytecodeGraphBuilder::VisitReThrow( FrameStateBeforeAndAfter states(this);
const interpreter::BytecodeArrayIterator& iterator) {
FrameStateBeforeAndAfter states(this, iterator);
Node* value = environment()->LookupAccumulator(); Node* value = environment()->LookupAccumulator();
Node* call = NewNode(javascript()->CallRuntime(Runtime::kReThrow), value); Node* call = NewNode(javascript()->CallRuntime(Runtime::kReThrow), value);
environment()->RecordAfterState(call, &states); environment()->RecordAfterState(call, &states);
...@@ -1470,98 +1275,72 @@ void BytecodeGraphBuilder::VisitReThrow( ...@@ -1470,98 +1275,72 @@ void BytecodeGraphBuilder::VisitReThrow(
UpdateControlDependencyToLeaveFunction(control); UpdateControlDependencyToLeaveFunction(control);
} }
void BytecodeGraphBuilder::BuildBinaryOp(const Operator* js_op) {
void BytecodeGraphBuilder::BuildBinaryOp( FrameStateBeforeAndAfter states(this);
const Operator* js_op, const interpreter::BytecodeArrayIterator& iterator) { Node* left =
FrameStateBeforeAndAfter states(this, iterator); environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0));
Node* left = environment()->LookupRegister(iterator.GetRegisterOperand(0));
Node* right = environment()->LookupAccumulator(); Node* right = environment()->LookupAccumulator();
Node* node = NewNode(js_op, left, right); Node* node = NewNode(js_op, left, right);
environment()->BindAccumulator(node, &states); environment()->BindAccumulator(node, &states);
} }
void BytecodeGraphBuilder::VisitAdd() {
void BytecodeGraphBuilder::VisitAdd(
const interpreter::BytecodeArrayIterator& iterator) {
BinaryOperationHints hints = BinaryOperationHints::Any(); BinaryOperationHints hints = BinaryOperationHints::Any();
BuildBinaryOp(javascript()->Add(language_mode(), hints), iterator); BuildBinaryOp(javascript()->Add(language_mode(), hints));
} }
void BytecodeGraphBuilder::VisitSub() {
void BytecodeGraphBuilder::VisitSub(
const interpreter::BytecodeArrayIterator& iterator) {
BinaryOperationHints hints = BinaryOperationHints::Any(); BinaryOperationHints hints = BinaryOperationHints::Any();
BuildBinaryOp(javascript()->Subtract(language_mode(), hints), iterator); BuildBinaryOp(javascript()->Subtract(language_mode(), hints));
} }
void BytecodeGraphBuilder::VisitMul() {
void BytecodeGraphBuilder::VisitMul(
const interpreter::BytecodeArrayIterator& iterator) {
BinaryOperationHints hints = BinaryOperationHints::Any(); BinaryOperationHints hints = BinaryOperationHints::Any();
BuildBinaryOp(javascript()->Multiply(language_mode(), hints), iterator); BuildBinaryOp(javascript()->Multiply(language_mode(), hints));
} }
void BytecodeGraphBuilder::VisitDiv() {
void BytecodeGraphBuilder::VisitDiv(
const interpreter::BytecodeArrayIterator& iterator) {
BinaryOperationHints hints = BinaryOperationHints::Any(); BinaryOperationHints hints = BinaryOperationHints::Any();
BuildBinaryOp(javascript()->Divide(language_mode(), hints), iterator); BuildBinaryOp(javascript()->Divide(language_mode(), hints));
} }
void BytecodeGraphBuilder::VisitMod() {
void BytecodeGraphBuilder::VisitMod(
const interpreter::BytecodeArrayIterator& iterator) {
BinaryOperationHints hints = BinaryOperationHints::Any(); BinaryOperationHints hints = BinaryOperationHints::Any();
BuildBinaryOp(javascript()->Modulus(language_mode(), hints), iterator); BuildBinaryOp(javascript()->Modulus(language_mode(), hints));
} }
void BytecodeGraphBuilder::VisitBitwiseOr() {
void BytecodeGraphBuilder::VisitBitwiseOr(
const interpreter::BytecodeArrayIterator& iterator) {
BinaryOperationHints hints = BinaryOperationHints::Any(); BinaryOperationHints hints = BinaryOperationHints::Any();
BuildBinaryOp(javascript()->BitwiseOr(language_mode(), hints), iterator); BuildBinaryOp(javascript()->BitwiseOr(language_mode(), hints));
} }
void BytecodeGraphBuilder::VisitBitwiseXor() {
void BytecodeGraphBuilder::VisitBitwiseXor(
const interpreter::BytecodeArrayIterator& iterator) {
BinaryOperationHints hints = BinaryOperationHints::Any(); BinaryOperationHints hints = BinaryOperationHints::Any();
BuildBinaryOp(javascript()->BitwiseXor(language_mode(), hints), iterator); BuildBinaryOp(javascript()->BitwiseXor(language_mode(), hints));
} }
void BytecodeGraphBuilder::VisitBitwiseAnd() {
void BytecodeGraphBuilder::VisitBitwiseAnd(
const interpreter::BytecodeArrayIterator& iterator) {
BinaryOperationHints hints = BinaryOperationHints::Any(); BinaryOperationHints hints = BinaryOperationHints::Any();
BuildBinaryOp(javascript()->BitwiseAnd(language_mode(), hints), iterator); BuildBinaryOp(javascript()->BitwiseAnd(language_mode(), hints));
} }
void BytecodeGraphBuilder::VisitShiftLeft() {
void BytecodeGraphBuilder::VisitShiftLeft(
const interpreter::BytecodeArrayIterator& iterator) {
BinaryOperationHints hints = BinaryOperationHints::Any(); BinaryOperationHints hints = BinaryOperationHints::Any();
BuildBinaryOp(javascript()->ShiftLeft(language_mode(), hints), iterator); BuildBinaryOp(javascript()->ShiftLeft(language_mode(), hints));
} }
void BytecodeGraphBuilder::VisitShiftRight() {
void BytecodeGraphBuilder::VisitShiftRight(
const interpreter::BytecodeArrayIterator& iterator) {
BinaryOperationHints hints = BinaryOperationHints::Any(); BinaryOperationHints hints = BinaryOperationHints::Any();
BuildBinaryOp(javascript()->ShiftRight(language_mode(), hints), iterator); BuildBinaryOp(javascript()->ShiftRight(language_mode(), hints));
} }
void BytecodeGraphBuilder::VisitShiftRightLogical() {
void BytecodeGraphBuilder::VisitShiftRightLogical(
const interpreter::BytecodeArrayIterator& iterator) {
BinaryOperationHints hints = BinaryOperationHints::Any(); BinaryOperationHints hints = BinaryOperationHints::Any();
BuildBinaryOp(javascript()->ShiftRightLogical(language_mode(), hints), BuildBinaryOp(javascript()->ShiftRightLogical(language_mode(), hints));
iterator);
} }
void BytecodeGraphBuilder::VisitInc() {
void BytecodeGraphBuilder::VisitInc( FrameStateBeforeAndAfter states(this);
const interpreter::BytecodeArrayIterator& iterator) {
FrameStateBeforeAndAfter states(this, iterator);
const Operator* js_op = const Operator* js_op =
javascript()->Add(language_mode(), BinaryOperationHints::Any()); javascript()->Add(language_mode(), BinaryOperationHints::Any());
Node* node = NewNode(js_op, environment()->LookupAccumulator(), Node* node = NewNode(js_op, environment()->LookupAccumulator(),
...@@ -1569,10 +1348,8 @@ void BytecodeGraphBuilder::VisitInc( ...@@ -1569,10 +1348,8 @@ void BytecodeGraphBuilder::VisitInc(
environment()->BindAccumulator(node, &states); environment()->BindAccumulator(node, &states);
} }
void BytecodeGraphBuilder::VisitDec() {
void BytecodeGraphBuilder::VisitDec( FrameStateBeforeAndAfter states(this);
const interpreter::BytecodeArrayIterator& iterator) {
FrameStateBeforeAndAfter states(this, iterator);
const Operator* js_op = const Operator* js_op =
javascript()->Subtract(language_mode(), BinaryOperationHints::Any()); javascript()->Subtract(language_mode(), BinaryOperationHints::Any());
Node* node = NewNode(js_op, environment()->LookupAccumulator(), Node* node = NewNode(js_op, environment()->LookupAccumulator(),
...@@ -1580,9 +1357,7 @@ void BytecodeGraphBuilder::VisitDec( ...@@ -1580,9 +1357,7 @@ void BytecodeGraphBuilder::VisitDec(
environment()->BindAccumulator(node, &states); environment()->BindAccumulator(node, &states);
} }
void BytecodeGraphBuilder::VisitLogicalNot() {
void BytecodeGraphBuilder::VisitLogicalNot(
const interpreter::BytecodeArrayIterator& iterator) {
Node* value = NewNode(javascript()->ToBoolean(ToBooleanHint::kAny), Node* value = NewNode(javascript()->ToBoolean(ToBooleanHint::kAny),
environment()->LookupAccumulator()); environment()->LookupAccumulator());
Node* node = NewNode(common()->Select(MachineRepresentation::kTagged), value, Node* node = NewNode(common()->Select(MachineRepresentation::kTagged), value,
...@@ -1590,321 +1365,221 @@ void BytecodeGraphBuilder::VisitLogicalNot( ...@@ -1590,321 +1365,221 @@ void BytecodeGraphBuilder::VisitLogicalNot(
environment()->BindAccumulator(node); environment()->BindAccumulator(node);
} }
void BytecodeGraphBuilder::VisitTypeOf() {
void BytecodeGraphBuilder::VisitTypeOf(
const interpreter::BytecodeArrayIterator& iterator) {
Node* node = Node* node =
NewNode(javascript()->TypeOf(), environment()->LookupAccumulator()); NewNode(javascript()->TypeOf(), environment()->LookupAccumulator());
environment()->BindAccumulator(node); environment()->BindAccumulator(node);
} }
void BytecodeGraphBuilder::BuildDelete() {
void BytecodeGraphBuilder::BuildDelete( FrameStateBeforeAndAfter states(this);
const interpreter::BytecodeArrayIterator& iterator) {
FrameStateBeforeAndAfter states(this, iterator);
Node* key = environment()->LookupAccumulator(); Node* key = environment()->LookupAccumulator();
Node* object = environment()->LookupRegister(iterator.GetRegisterOperand(0)); Node* object =
environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0));
Node* node = Node* node =
NewNode(javascript()->DeleteProperty(language_mode()), object, key); NewNode(javascript()->DeleteProperty(language_mode()), object, key);
environment()->BindAccumulator(node, &states); environment()->BindAccumulator(node, &states);
} }
void BytecodeGraphBuilder::VisitDeletePropertyStrict() {
void BytecodeGraphBuilder::VisitDeletePropertyStrict(
const interpreter::BytecodeArrayIterator& iterator) {
DCHECK(is_strict(language_mode())); DCHECK(is_strict(language_mode()));
BuildDelete(iterator); BuildDelete();
} }
void BytecodeGraphBuilder::VisitDeletePropertySloppy() {
void BytecodeGraphBuilder::VisitDeletePropertySloppy(
const interpreter::BytecodeArrayIterator& iterator) {
DCHECK(is_sloppy(language_mode())); DCHECK(is_sloppy(language_mode()));
BuildDelete(iterator); BuildDelete();
} }
void BytecodeGraphBuilder::VisitDeleteLookupSlot() {
void BytecodeGraphBuilder::VisitDeleteLookupSlot( FrameStateBeforeAndAfter states(this);
const interpreter::BytecodeArrayIterator& iterator) {
FrameStateBeforeAndAfter states(this, iterator);
Node* name = environment()->LookupAccumulator(); Node* name = environment()->LookupAccumulator();
const Operator* op = javascript()->CallRuntime(Runtime::kDeleteLookupSlot); const Operator* op = javascript()->CallRuntime(Runtime::kDeleteLookupSlot);
Node* result = NewNode(op, environment()->Context(), name); Node* result = NewNode(op, environment()->Context(), name);
environment()->BindAccumulator(result, &states); environment()->BindAccumulator(result, &states);
} }
void BytecodeGraphBuilder::BuildCompareOp(const Operator* js_op) {
void BytecodeGraphBuilder::BuildCompareOp( FrameStateBeforeAndAfter states(this);
const Operator* js_op, const interpreter::BytecodeArrayIterator& iterator) { Node* left =
FrameStateBeforeAndAfter states(this, iterator); environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0));
Node* left = environment()->LookupRegister(iterator.GetRegisterOperand(0));
Node* right = environment()->LookupAccumulator(); Node* right = environment()->LookupAccumulator();
Node* node = NewNode(js_op, left, right); Node* node = NewNode(js_op, left, right);
environment()->BindAccumulator(node, &states); environment()->BindAccumulator(node, &states);
} }
void BytecodeGraphBuilder::VisitTestEqual() {
void BytecodeGraphBuilder::VisitTestEqual( BuildCompareOp(javascript()->Equal());
const interpreter::BytecodeArrayIterator& iterator) {
BuildCompareOp(javascript()->Equal(), iterator);
} }
void BytecodeGraphBuilder::VisitTestNotEqual() {
void BytecodeGraphBuilder::VisitTestNotEqual( BuildCompareOp(javascript()->NotEqual());
const interpreter::BytecodeArrayIterator& iterator) {
BuildCompareOp(javascript()->NotEqual(), iterator);
} }
void BytecodeGraphBuilder::VisitTestEqualStrict() {
void BytecodeGraphBuilder::VisitTestEqualStrict( BuildCompareOp(javascript()->StrictEqual());
const interpreter::BytecodeArrayIterator& iterator) {
BuildCompareOp(javascript()->StrictEqual(), iterator);
} }
void BytecodeGraphBuilder::VisitTestNotEqualStrict() {
void BytecodeGraphBuilder::VisitTestNotEqualStrict( BuildCompareOp(javascript()->StrictNotEqual());
const interpreter::BytecodeArrayIterator& iterator) {
BuildCompareOp(javascript()->StrictNotEqual(), iterator);
} }
void BytecodeGraphBuilder::VisitTestLessThan() {
void BytecodeGraphBuilder::VisitTestLessThan( BuildCompareOp(javascript()->LessThan(language_mode()));
const interpreter::BytecodeArrayIterator& iterator) {
BuildCompareOp(javascript()->LessThan(language_mode()), iterator);
} }
void BytecodeGraphBuilder::VisitTestGreaterThan() {
void BytecodeGraphBuilder::VisitTestGreaterThan( BuildCompareOp(javascript()->GreaterThan(language_mode()));
const interpreter::BytecodeArrayIterator& iterator) {
BuildCompareOp(javascript()->GreaterThan(language_mode()), iterator);
} }
void BytecodeGraphBuilder::VisitTestLessThanOrEqual() {
void BytecodeGraphBuilder::VisitTestLessThanOrEqual( BuildCompareOp(javascript()->LessThanOrEqual(language_mode()));
const interpreter::BytecodeArrayIterator& iterator) {
BuildCompareOp(javascript()->LessThanOrEqual(language_mode()), iterator);
} }
void BytecodeGraphBuilder::VisitTestGreaterThanOrEqual() {
void BytecodeGraphBuilder::VisitTestGreaterThanOrEqual( BuildCompareOp(javascript()->GreaterThanOrEqual(language_mode()));
const interpreter::BytecodeArrayIterator& iterator) {
BuildCompareOp(javascript()->GreaterThanOrEqual(language_mode()), iterator);
} }
void BytecodeGraphBuilder::VisitTestIn() {
void BytecodeGraphBuilder::VisitTestIn( BuildCompareOp(javascript()->HasProperty());
const interpreter::BytecodeArrayIterator& iterator) {
BuildCompareOp(javascript()->HasProperty(), iterator);
} }
void BytecodeGraphBuilder::VisitTestInstanceOf() {
void BytecodeGraphBuilder::VisitTestInstanceOf( BuildCompareOp(javascript()->InstanceOf());
const interpreter::BytecodeArrayIterator& iterator) {
BuildCompareOp(javascript()->InstanceOf(), iterator);
} }
void BytecodeGraphBuilder::BuildCastOperator(const Operator* js_op) {
void BytecodeGraphBuilder::BuildCastOperator( FrameStateBeforeAndAfter states(this);
const Operator* js_op, const interpreter::BytecodeArrayIterator& iterator) {
FrameStateBeforeAndAfter states(this, iterator);
Node* node = NewNode(js_op, environment()->LookupAccumulator()); Node* node = NewNode(js_op, environment()->LookupAccumulator());
environment()->BindAccumulator(node, &states); environment()->BindAccumulator(node, &states);
} }
void BytecodeGraphBuilder::VisitToName() {
void BytecodeGraphBuilder::VisitToName( BuildCastOperator(javascript()->ToName());
const interpreter::BytecodeArrayIterator& iterator) {
BuildCastOperator(javascript()->ToName(), iterator);
} }
void BytecodeGraphBuilder::VisitToObject() {
void BytecodeGraphBuilder::VisitToObject( BuildCastOperator(javascript()->ToObject());
const interpreter::BytecodeArrayIterator& iterator) {
BuildCastOperator(javascript()->ToObject(), iterator);
} }
void BytecodeGraphBuilder::VisitToNumber() {
void BytecodeGraphBuilder::VisitToNumber( BuildCastOperator(javascript()->ToNumber());
const interpreter::BytecodeArrayIterator& iterator) {
BuildCastOperator(javascript()->ToNumber(), iterator);
} }
void BytecodeGraphBuilder::VisitJump() { BuildJump(); }
void BytecodeGraphBuilder::VisitJump( void BytecodeGraphBuilder::VisitJumpConstant() { BuildJump(); }
const interpreter::BytecodeArrayIterator& iterator) {
BuildJump();
}
void BytecodeGraphBuilder::VisitJumpConstant( void BytecodeGraphBuilder::VisitJumpConstantWide() { BuildJump(); }
const interpreter::BytecodeArrayIterator& iterator) {
BuildJump();
}
void BytecodeGraphBuilder::VisitJumpIfTrue() {
void BytecodeGraphBuilder::VisitJumpConstantWide(
const interpreter::BytecodeArrayIterator& iterator) {
BuildJump();
}
void BytecodeGraphBuilder::VisitJumpIfTrue(
const interpreter::BytecodeArrayIterator& iterator) {
BuildJumpIfEqual(jsgraph()->TrueConstant()); BuildJumpIfEqual(jsgraph()->TrueConstant());
} }
void BytecodeGraphBuilder::VisitJumpIfTrueConstant() {
void BytecodeGraphBuilder::VisitJumpIfTrueConstant(
const interpreter::BytecodeArrayIterator& iterator) {
BuildJumpIfEqual(jsgraph()->TrueConstant()); BuildJumpIfEqual(jsgraph()->TrueConstant());
} }
void BytecodeGraphBuilder::VisitJumpIfTrueConstantWide() {
void BytecodeGraphBuilder::VisitJumpIfTrueConstantWide(
const interpreter::BytecodeArrayIterator& iterator) {
BuildJumpIfEqual(jsgraph()->TrueConstant()); BuildJumpIfEqual(jsgraph()->TrueConstant());
} }
void BytecodeGraphBuilder::VisitJumpIfFalse() {
void BytecodeGraphBuilder::VisitJumpIfFalse(
const interpreter::BytecodeArrayIterator& iterator) {
BuildJumpIfEqual(jsgraph()->FalseConstant()); BuildJumpIfEqual(jsgraph()->FalseConstant());
} }
void BytecodeGraphBuilder::VisitJumpIfFalseConstant() {
void BytecodeGraphBuilder::VisitJumpIfFalseConstant(
const interpreter::BytecodeArrayIterator& iterator) {
BuildJumpIfEqual(jsgraph()->FalseConstant()); BuildJumpIfEqual(jsgraph()->FalseConstant());
} }
void BytecodeGraphBuilder::VisitJumpIfFalseConstantWide() {
void BytecodeGraphBuilder::VisitJumpIfFalseConstantWide(
const interpreter::BytecodeArrayIterator& iterator) {
BuildJumpIfEqual(jsgraph()->FalseConstant()); BuildJumpIfEqual(jsgraph()->FalseConstant());
} }
void BytecodeGraphBuilder::VisitJumpIfToBooleanTrue() {
void BytecodeGraphBuilder::VisitJumpIfToBooleanTrue(
const interpreter::BytecodeArrayIterator& iterator) {
BuildJumpIfToBooleanEqual(jsgraph()->TrueConstant()); BuildJumpIfToBooleanEqual(jsgraph()->TrueConstant());
} }
void BytecodeGraphBuilder::VisitJumpIfToBooleanTrueConstant() {
void BytecodeGraphBuilder::VisitJumpIfToBooleanTrueConstant(
const interpreter::BytecodeArrayIterator& iterator) {
BuildJumpIfToBooleanEqual(jsgraph()->TrueConstant()); BuildJumpIfToBooleanEqual(jsgraph()->TrueConstant());
} }
void BytecodeGraphBuilder::VisitJumpIfToBooleanTrueConstantWide() {
void BytecodeGraphBuilder::VisitJumpIfToBooleanTrueConstantWide(
const interpreter::BytecodeArrayIterator& iterator) {
BuildJumpIfToBooleanEqual(jsgraph()->TrueConstant()); BuildJumpIfToBooleanEqual(jsgraph()->TrueConstant());
} }
void BytecodeGraphBuilder::VisitJumpIfToBooleanFalse() {
void BytecodeGraphBuilder::VisitJumpIfToBooleanFalse(
const interpreter::BytecodeArrayIterator& iterator) {
BuildJumpIfToBooleanEqual(jsgraph()->FalseConstant()); BuildJumpIfToBooleanEqual(jsgraph()->FalseConstant());
} }
void BytecodeGraphBuilder::VisitJumpIfToBooleanFalseConstant() {
void BytecodeGraphBuilder::VisitJumpIfToBooleanFalseConstant(
const interpreter::BytecodeArrayIterator& iterator) {
BuildJumpIfToBooleanEqual(jsgraph()->FalseConstant()); BuildJumpIfToBooleanEqual(jsgraph()->FalseConstant());
} }
void BytecodeGraphBuilder::VisitJumpIfToBooleanFalseConstantWide() {
void BytecodeGraphBuilder::VisitJumpIfToBooleanFalseConstantWide(
const interpreter::BytecodeArrayIterator& iterator) {
BuildJumpIfToBooleanEqual(jsgraph()->FalseConstant()); BuildJumpIfToBooleanEqual(jsgraph()->FalseConstant());
} }
void BytecodeGraphBuilder::VisitJumpIfNull() {
void BytecodeGraphBuilder::VisitJumpIfNull(
const interpreter::BytecodeArrayIterator& iterator) {
BuildJumpIfEqual(jsgraph()->NullConstant()); BuildJumpIfEqual(jsgraph()->NullConstant());
} }
void BytecodeGraphBuilder::VisitJumpIfNullConstant() {
void BytecodeGraphBuilder::VisitJumpIfNullConstant(
const interpreter::BytecodeArrayIterator& iterator) {
BuildJumpIfEqual(jsgraph()->NullConstant()); BuildJumpIfEqual(jsgraph()->NullConstant());
} }
void BytecodeGraphBuilder::VisitJumpIfNullConstantWide() {
void BytecodeGraphBuilder::VisitJumpIfNullConstantWide(
const interpreter::BytecodeArrayIterator& iterator) {
BuildJumpIfEqual(jsgraph()->NullConstant()); BuildJumpIfEqual(jsgraph()->NullConstant());
} }
void BytecodeGraphBuilder::VisitJumpIfUndefined() {
void BytecodeGraphBuilder::VisitJumpIfUndefined(
const interpreter::BytecodeArrayIterator& iterator) {
BuildJumpIfEqual(jsgraph()->UndefinedConstant()); BuildJumpIfEqual(jsgraph()->UndefinedConstant());
} }
void BytecodeGraphBuilder::VisitJumpIfUndefinedConstant() {
void BytecodeGraphBuilder::VisitJumpIfUndefinedConstant(
const interpreter::BytecodeArrayIterator& iterator) {
BuildJumpIfEqual(jsgraph()->UndefinedConstant()); BuildJumpIfEqual(jsgraph()->UndefinedConstant());
} }
void BytecodeGraphBuilder::VisitJumpIfUndefinedConstantWide() {
void BytecodeGraphBuilder::VisitJumpIfUndefinedConstantWide(
const interpreter::BytecodeArrayIterator& iterator) {
BuildJumpIfEqual(jsgraph()->UndefinedConstant()); BuildJumpIfEqual(jsgraph()->UndefinedConstant());
} }
void BytecodeGraphBuilder::VisitReturn() {
void BytecodeGraphBuilder::VisitReturn(
const interpreter::BytecodeArrayIterator& iterator) {
Node* control = Node* control =
NewNode(common()->Return(), environment()->LookupAccumulator()); NewNode(common()->Return(), environment()->LookupAccumulator());
UpdateControlDependencyToLeaveFunction(control); UpdateControlDependencyToLeaveFunction(control);
set_environment(nullptr); set_environment(nullptr);
} }
void BytecodeGraphBuilder::BuildForInPrepare() {
void BytecodeGraphBuilder::BuildForInPrepare( FrameStateBeforeAndAfter states(this);
const interpreter::BytecodeArrayIterator& iterator) {
FrameStateBeforeAndAfter states(this, iterator);
Node* receiver = environment()->LookupAccumulator(); Node* receiver = environment()->LookupAccumulator();
Node* prepare = NewNode(javascript()->ForInPrepare(), receiver); Node* prepare = NewNode(javascript()->ForInPrepare(), receiver);
environment()->BindRegistersToProjections(iterator.GetRegisterOperand(0), environment()->BindRegistersToProjections(
prepare, &states); bytecode_iterator().GetRegisterOperand(0), prepare, &states);
} }
void BytecodeGraphBuilder::VisitForInPrepare() { BuildForInPrepare(); }
void BytecodeGraphBuilder::VisitForInPrepare( void BytecodeGraphBuilder::VisitForInPrepareWide() { BuildForInPrepare(); }
const interpreter::BytecodeArrayIterator& iterator) {
BuildForInPrepare(iterator);
}
void BytecodeGraphBuilder::VisitForInPrepareWide(
const interpreter::BytecodeArrayIterator& iterator) {
BuildForInPrepare(iterator);
}
void BytecodeGraphBuilder::VisitForInDone( void BytecodeGraphBuilder::VisitForInDone() {
const interpreter::BytecodeArrayIterator& iterator) { FrameStateBeforeAndAfter states(this);
FrameStateBeforeAndAfter states(this, iterator); Node* index =
Node* index = environment()->LookupRegister(iterator.GetRegisterOperand(0)); environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0));
Node* cache_length = Node* cache_length =
environment()->LookupRegister(iterator.GetRegisterOperand(1)); environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(1));
Node* exit_cond = NewNode(javascript()->ForInDone(), index, cache_length); Node* exit_cond = NewNode(javascript()->ForInDone(), index, cache_length);
environment()->BindAccumulator(exit_cond, &states); environment()->BindAccumulator(exit_cond, &states);
} }
void BytecodeGraphBuilder::BuildForInNext() {
void BytecodeGraphBuilder::BuildForInNext( FrameStateBeforeAndAfter states(this);
const interpreter::BytecodeArrayIterator& iterator) {
FrameStateBeforeAndAfter states(this, iterator);
Node* receiver = Node* receiver =
environment()->LookupRegister(iterator.GetRegisterOperand(0)); environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0));
Node* index = environment()->LookupRegister(iterator.GetRegisterOperand(1)); Node* index =
int catch_reg_pair_index = iterator.GetRegisterOperand(2).index(); environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(1));
int catch_reg_pair_index = bytecode_iterator().GetRegisterOperand(2).index();
Node* cache_type = environment()->LookupRegister( Node* cache_type = environment()->LookupRegister(
interpreter::Register(catch_reg_pair_index)); interpreter::Register(catch_reg_pair_index));
Node* cache_array = environment()->LookupRegister( Node* cache_array = environment()->LookupRegister(
...@@ -1915,23 +1590,14 @@ void BytecodeGraphBuilder::BuildForInNext( ...@@ -1915,23 +1590,14 @@ void BytecodeGraphBuilder::BuildForInNext(
environment()->BindAccumulator(value, &states); environment()->BindAccumulator(value, &states);
} }
void BytecodeGraphBuilder::VisitForInNext() { BuildForInNext(); }
void BytecodeGraphBuilder::VisitForInNext( void BytecodeGraphBuilder::VisitForInNextWide() { BuildForInNext(); }
const interpreter::BytecodeArrayIterator& iterator) {
BuildForInNext(iterator);
}
void BytecodeGraphBuilder::VisitForInNextWide(
const interpreter::BytecodeArrayIterator& iterator) {
BuildForInNext(iterator);
}
void BytecodeGraphBuilder::VisitForInStep( void BytecodeGraphBuilder::VisitForInStep() {
const interpreter::BytecodeArrayIterator& iterator) { FrameStateBeforeAndAfter states(this);
FrameStateBeforeAndAfter states(this, iterator); Node* index =
Node* index = environment()->LookupRegister(iterator.GetRegisterOperand(0)); environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0));
index = NewNode(javascript()->ForInStep(), index); index = NewNode(javascript()->ForInStep(), index);
environment()->BindAccumulator(index, &states); environment()->BindAccumulator(index, &states);
} }
...@@ -2004,18 +1670,18 @@ void BytecodeGraphBuilder::BuildJump(int source_offset, int target_offset) { ...@@ -2004,18 +1670,18 @@ void BytecodeGraphBuilder::BuildJump(int source_offset, int target_offset) {
void BytecodeGraphBuilder::BuildJump() { void BytecodeGraphBuilder::BuildJump() {
int source_offset = bytecode_iterator()->current_offset(); int source_offset = bytecode_iterator().current_offset();
int target_offset = bytecode_iterator()->GetJumpTargetOffset(); int target_offset = bytecode_iterator().GetJumpTargetOffset();
BuildJump(source_offset, target_offset); BuildJump(source_offset, target_offset);
} }
void BytecodeGraphBuilder::BuildConditionalJump(Node* condition) { void BytecodeGraphBuilder::BuildConditionalJump(Node* condition) {
int source_offset = bytecode_iterator()->current_offset(); int source_offset = bytecode_iterator().current_offset();
NewBranch(condition); NewBranch(condition);
Environment* if_false_environment = environment()->CopyForConditional(); Environment* if_false_environment = environment()->CopyForConditional();
NewIfTrue(); NewIfTrue();
BuildJump(source_offset, bytecode_iterator()->GetJumpTargetOffset()); BuildJump(source_offset, bytecode_iterator().GetJumpTargetOffset());
set_environment(if_false_environment); set_environment(if_false_environment);
NewIfFalse(); NewIfFalse();
} }
...@@ -2131,7 +1797,7 @@ Node* BytecodeGraphBuilder::MakeNode(const Operator* op, int value_input_count, ...@@ -2131,7 +1797,7 @@ Node* BytecodeGraphBuilder::MakeNode(const Operator* op, int value_input_count,
} }
// Add implicit exception continuation for throwing nodes. // Add implicit exception continuation for throwing nodes.
if (!result->op()->HasProperty(Operator::kNoThrow) && inside_handler) { if (!result->op()->HasProperty(Operator::kNoThrow) && inside_handler) {
int throw_offset = bytecode_iterator()->current_offset(); int throw_offset = bytecode_iterator().current_offset();
int handler_offset = exception_handlers_.top().handler_offset_; int handler_offset = exception_handlers_.top().handler_offset_;
// TODO(mstarzinger): Thread through correct prediction! // TODO(mstarzinger): Thread through correct prediction!
IfExceptionHint hint = IfExceptionHint::kLocallyCaught; IfExceptionHint hint = IfExceptionHint::kLocallyCaught;
......
...@@ -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