diff options
Diffstat (limited to 'deps/v8/src/compiler/js-operator.cc')
-rw-r--r-- | deps/v8/src/compiler/js-operator.cc | 388 |
1 files changed, 145 insertions, 243 deletions
diff --git a/deps/v8/src/compiler/js-operator.cc b/deps/v8/src/compiler/js-operator.cc index 37369f6970..c4500a50bb 100644 --- a/deps/v8/src/compiler/js-operator.cc +++ b/deps/v8/src/compiler/js-operator.cc @@ -16,7 +16,7 @@ namespace v8 { namespace internal { namespace compiler { -VectorSlotPair::VectorSlotPair() : slot_(FeedbackVectorICSlot::Invalid()) {} +VectorSlotPair::VectorSlotPair() {} int VectorSlotPair::index() const { @@ -40,11 +40,32 @@ size_t hash_value(VectorSlotPair const& p) { } -std::ostream& operator<<(std::ostream& os, CallFunctionParameters const& p) { - os << p.arity() << ", " << p.flags() << ", " << p.language_mode(); - if (p.AllowTailCalls()) { - os << ", ALLOW_TAIL_CALLS"; +ConvertReceiverMode ConvertReceiverModeOf(Operator const* op) { + DCHECK_EQ(IrOpcode::kJSConvertReceiver, op->opcode()); + return OpParameter<ConvertReceiverMode>(op); +} + + +size_t hash_value(TailCallMode mode) { + return base::hash_value(static_cast<unsigned>(mode)); +} + + +std::ostream& operator<<(std::ostream& os, TailCallMode mode) { + switch (mode) { + case TailCallMode::kAllow: + return os << "ALLOW_TAIL_CALLS"; + case TailCallMode::kDisallow: + return os << "DISALLOW_TAIL_CALLS"; } + UNREACHABLE(); + return os; +} + + +std::ostream& operator<<(std::ostream& os, CallFunctionParameters const& p) { + os << p.arity() << ", " << p.language_mode() << ", " << p.convert_mode() + << ", " << p.tail_call_mode(); return os; } @@ -121,156 +142,101 @@ ContextAccess const& ContextAccessOf(Operator const* op) { } -DynamicGlobalAccess::DynamicGlobalAccess(const Handle<String>& name, - uint32_t check_bitset, - const VectorSlotPair& feedback, - TypeofMode typeof_mode) - : name_(name), - check_bitset_(check_bitset), - feedback_(feedback), - typeof_mode_(typeof_mode) { - DCHECK(check_bitset == kFullCheckRequired || check_bitset < 0x80000000U); -} - - -bool operator==(DynamicGlobalAccess const& lhs, - DynamicGlobalAccess const& rhs) { - UNIMPLEMENTED(); - return true; -} - - -bool operator!=(DynamicGlobalAccess const& lhs, - DynamicGlobalAccess const& rhs) { - return !(lhs == rhs); -} - - -size_t hash_value(DynamicGlobalAccess const& access) { - UNIMPLEMENTED(); - return 0; -} - - -std::ostream& operator<<(std::ostream& os, DynamicGlobalAccess const& access) { - return os << Brief(*access.name()) << ", " << access.check_bitset() << ", " - << access.typeof_mode(); -} - +DynamicAccess::DynamicAccess(const Handle<String>& name, TypeofMode typeof_mode) + : name_(name), typeof_mode_(typeof_mode) {} -DynamicGlobalAccess const& DynamicGlobalAccessOf(Operator const* op) { - DCHECK_EQ(IrOpcode::kJSLoadDynamicGlobal, op->opcode()); - return OpParameter<DynamicGlobalAccess>(op); -} - -DynamicContextAccess::DynamicContextAccess(const Handle<String>& name, - uint32_t check_bitset, - const ContextAccess& context_access) - : name_(name), - check_bitset_(check_bitset), - context_access_(context_access) { - DCHECK(check_bitset == kFullCheckRequired || check_bitset < 0x80000000U); -} - - -bool operator==(DynamicContextAccess const& lhs, - DynamicContextAccess const& rhs) { +bool operator==(DynamicAccess const& lhs, DynamicAccess const& rhs) { UNIMPLEMENTED(); return true; } -bool operator!=(DynamicContextAccess const& lhs, - DynamicContextAccess const& rhs) { +bool operator!=(DynamicAccess const& lhs, DynamicAccess const& rhs) { return !(lhs == rhs); } -size_t hash_value(DynamicContextAccess const& access) { +size_t hash_value(DynamicAccess const& access) { UNIMPLEMENTED(); return 0; } -std::ostream& operator<<(std::ostream& os, DynamicContextAccess const& access) { - return os << Brief(*access.name()) << ", " << access.check_bitset() << ", " - << access.context_access(); +std::ostream& operator<<(std::ostream& os, DynamicAccess const& access) { + return os << Brief(*access.name()) << ", " << access.typeof_mode(); } -DynamicContextAccess const& DynamicContextAccessOf(Operator const* op) { - DCHECK_EQ(IrOpcode::kJSLoadDynamicContext, op->opcode()); - return OpParameter<DynamicContextAccess>(op); +DynamicAccess const& DynamicAccessOf(Operator const* op) { + DCHECK_EQ(IrOpcode::kJSLoadDynamic, op->opcode()); + return OpParameter<DynamicAccess>(op); } -bool operator==(LoadNamedParameters const& lhs, - LoadNamedParameters const& rhs) { +bool operator==(NamedAccess const& lhs, NamedAccess const& rhs) { return lhs.name().location() == rhs.name().location() && lhs.language_mode() == rhs.language_mode() && lhs.feedback() == rhs.feedback(); } -bool operator!=(LoadNamedParameters const& lhs, - LoadNamedParameters const& rhs) { +bool operator!=(NamedAccess const& lhs, NamedAccess const& rhs) { return !(lhs == rhs); } -size_t hash_value(LoadNamedParameters const& p) { +size_t hash_value(NamedAccess const& p) { return base::hash_combine(p.name().location(), p.language_mode(), p.feedback()); } -std::ostream& operator<<(std::ostream& os, LoadNamedParameters const& p) { +std::ostream& operator<<(std::ostream& os, NamedAccess const& p) { return os << Brief(*p.name()) << ", " << p.language_mode(); } -std::ostream& operator<<(std::ostream& os, LoadPropertyParameters const& p) { +NamedAccess const& NamedAccessOf(const Operator* op) { + DCHECK(op->opcode() == IrOpcode::kJSLoadNamed || + op->opcode() == IrOpcode::kJSStoreNamed); + return OpParameter<NamedAccess>(op); +} + + +std::ostream& operator<<(std::ostream& os, PropertyAccess const& p) { return os << p.language_mode(); } -bool operator==(LoadPropertyParameters const& lhs, - LoadPropertyParameters const& rhs) { +bool operator==(PropertyAccess const& lhs, PropertyAccess const& rhs) { return lhs.language_mode() == rhs.language_mode() && lhs.feedback() == rhs.feedback(); } -bool operator!=(LoadPropertyParameters const& lhs, - LoadPropertyParameters const& rhs) { +bool operator!=(PropertyAccess const& lhs, PropertyAccess const& rhs) { return !(lhs == rhs); } -const LoadPropertyParameters& LoadPropertyParametersOf(const Operator* op) { - DCHECK_EQ(IrOpcode::kJSLoadProperty, op->opcode()); - return OpParameter<LoadPropertyParameters>(op); +PropertyAccess const& PropertyAccessOf(const Operator* op) { + DCHECK(op->opcode() == IrOpcode::kJSLoadProperty || + op->opcode() == IrOpcode::kJSStoreProperty); + return OpParameter<PropertyAccess>(op); } -size_t hash_value(LoadPropertyParameters const& p) { +size_t hash_value(PropertyAccess const& p) { return base::hash_combine(p.language_mode(), p.feedback()); } -const LoadNamedParameters& LoadNamedParametersOf(const Operator* op) { - DCHECK_EQ(IrOpcode::kJSLoadNamed, op->opcode()); - return OpParameter<LoadNamedParameters>(op); -} - - bool operator==(LoadGlobalParameters const& lhs, LoadGlobalParameters const& rhs) { return lhs.name().location() == rhs.name().location() && lhs.feedback() == rhs.feedback() && - lhs.typeof_mode() == rhs.typeof_mode() && - lhs.slot_index() == rhs.slot_index(); + lhs.typeof_mode() == rhs.typeof_mode(); } @@ -281,14 +247,12 @@ bool operator!=(LoadGlobalParameters const& lhs, size_t hash_value(LoadGlobalParameters const& p) { - return base::hash_combine(p.name().location(), p.typeof_mode(), - p.slot_index()); + return base::hash_combine(p.name().location(), p.typeof_mode()); } std::ostream& operator<<(std::ostream& os, LoadGlobalParameters const& p) { - return os << Brief(*p.name()) << ", " << p.typeof_mode() - << ", slot: " << p.slot_index(); + return os << Brief(*p.name()) << ", " << p.typeof_mode(); } @@ -302,8 +266,7 @@ bool operator==(StoreGlobalParameters const& lhs, StoreGlobalParameters const& rhs) { return lhs.language_mode() == rhs.language_mode() && lhs.name().location() == rhs.name().location() && - lhs.feedback() == rhs.feedback() && - lhs.slot_index() == rhs.slot_index(); + lhs.feedback() == rhs.feedback(); } @@ -315,13 +278,12 @@ bool operator!=(StoreGlobalParameters const& lhs, size_t hash_value(StoreGlobalParameters const& p) { return base::hash_combine(p.language_mode(), p.name().location(), - p.feedback(), p.slot_index()); + p.feedback()); } std::ostream& operator<<(std::ostream& os, StoreGlobalParameters const& p) { - return os << p.language_mode() << ", " << Brief(*p.name()) - << ", slot: " << p.slot_index(); + return os << p.language_mode() << ", " << Brief(*p.name()); } @@ -331,66 +293,6 @@ const StoreGlobalParameters& StoreGlobalParametersOf(const Operator* op) { } -bool operator==(StoreNamedParameters const& lhs, - StoreNamedParameters const& rhs) { - return lhs.language_mode() == rhs.language_mode() && - lhs.name().location() == rhs.name().location() && - lhs.feedback() == rhs.feedback(); -} - - -bool operator!=(StoreNamedParameters const& lhs, - StoreNamedParameters const& rhs) { - return !(lhs == rhs); -} - - -size_t hash_value(StoreNamedParameters const& p) { - return base::hash_combine(p.language_mode(), p.name().location(), - p.feedback()); -} - - -std::ostream& operator<<(std::ostream& os, StoreNamedParameters const& p) { - return os << p.language_mode() << ", " << Brief(*p.name()); -} - - -const StoreNamedParameters& StoreNamedParametersOf(const Operator* op) { - DCHECK_EQ(IrOpcode::kJSStoreNamed, op->opcode()); - return OpParameter<StoreNamedParameters>(op); -} - - -bool operator==(StorePropertyParameters const& lhs, - StorePropertyParameters const& rhs) { - return lhs.language_mode() == rhs.language_mode() && - lhs.feedback() == rhs.feedback(); -} - - -bool operator!=(StorePropertyParameters const& lhs, - StorePropertyParameters const& rhs) { - return !(lhs == rhs); -} - - -size_t hash_value(StorePropertyParameters const& p) { - return base::hash_combine(p.language_mode(), p.feedback()); -} - - -std::ostream& operator<<(std::ostream& os, StorePropertyParameters const& p) { - return os << p.language_mode(); -} - - -const StorePropertyParameters& StorePropertyParametersOf(const Operator* op) { - DCHECK_EQ(IrOpcode::kJSStoreProperty, op->opcode()); - return OpParameter<StorePropertyParameters>(op); -} - - bool operator==(CreateArgumentsParameters const& lhs, CreateArgumentsParameters const& rhs) { return lhs.type() == rhs.type() && lhs.start_index() == rhs.start_index(); @@ -423,7 +325,7 @@ const CreateArgumentsParameters& CreateArgumentsParametersOf( bool operator==(CreateClosureParameters const& lhs, CreateClosureParameters const& rhs) { return lhs.pretenure() == rhs.pretenure() && - lhs.shared_info().is_identical_to(rhs.shared_info()); + lhs.shared_info().location() == rhs.shared_info().location(); } @@ -434,9 +336,7 @@ bool operator!=(CreateClosureParameters const& lhs, size_t hash_value(CreateClosureParameters const& p) { - // TODO(mstarzinger): Include hash of the SharedFunctionInfo here. - base::hash<PretenureFlag> h; - return h(p.pretenure()); + return base::hash_combine(p.pretenure(), p.shared_info().location()); } @@ -451,29 +351,30 @@ const CreateClosureParameters& CreateClosureParametersOf(const Operator* op) { } -#define CACHED_OP_LIST(V) \ - V(Equal, Operator::kNoProperties, 2, 1) \ - V(NotEqual, Operator::kNoProperties, 2, 1) \ - V(StrictEqual, Operator::kNoThrow, 2, 1) \ - V(StrictNotEqual, Operator::kNoThrow, 2, 1) \ - V(UnaryNot, Operator::kEliminatable, 1, 1) \ - V(ToBoolean, Operator::kEliminatable, 1, 1) \ - V(ToNumber, Operator::kNoProperties, 1, 1) \ - V(ToString, Operator::kNoProperties, 1, 1) \ - V(ToName, Operator::kNoProperties, 1, 1) \ - V(ToObject, Operator::kNoProperties, 1, 1) \ - V(Yield, Operator::kNoProperties, 1, 1) \ - V(Create, Operator::kEliminatable, 0, 1) \ - V(HasProperty, Operator::kNoProperties, 2, 1) \ - V(TypeOf, Operator::kEliminatable, 1, 1) \ - V(InstanceOf, Operator::kNoProperties, 2, 1) \ - V(ForInDone, Operator::kPure, 2, 1) \ - V(ForInNext, Operator::kNoProperties, 4, 1) \ - V(ForInPrepare, Operator::kNoProperties, 1, 3) \ - V(ForInStep, Operator::kPure, 1, 1) \ - V(StackCheck, Operator::kNoProperties, 0, 0) \ - V(CreateFunctionContext, Operator::kNoProperties, 1, 1) \ - V(CreateWithContext, Operator::kNoProperties, 2, 1) \ +#define CACHED_OP_LIST(V) \ + V(Equal, Operator::kNoProperties, 2, 1) \ + V(NotEqual, Operator::kNoProperties, 2, 1) \ + V(StrictEqual, Operator::kNoThrow, 2, 1) \ + V(StrictNotEqual, Operator::kNoThrow, 2, 1) \ + V(UnaryNot, Operator::kEliminatable, 1, 1) \ + V(ToBoolean, Operator::kEliminatable, 1, 1) \ + V(ToNumber, Operator::kNoProperties, 1, 1) \ + V(ToString, Operator::kNoProperties, 1, 1) \ + V(ToName, Operator::kNoProperties, 1, 1) \ + V(ToObject, Operator::kNoProperties, 1, 1) \ + V(Yield, Operator::kNoProperties, 1, 1) \ + V(Create, Operator::kEliminatable, 0, 1) \ + V(HasProperty, Operator::kNoProperties, 2, 1) \ + V(TypeOf, Operator::kEliminatable, 1, 1) \ + V(InstanceOf, Operator::kNoProperties, 2, 1) \ + V(ForInDone, Operator::kPure, 2, 1) \ + V(ForInNext, Operator::kNoProperties, 4, 1) \ + V(ForInPrepare, Operator::kNoProperties, 1, 3) \ + V(ForInStep, Operator::kPure, 1, 1) \ + V(LoadMessage, Operator::kNoThrow, 0, 1) \ + V(StoreMessage, Operator::kNoThrow, 1, 0) \ + V(StackCheck, Operator::kNoProperties, 0, 0) \ + V(CreateWithContext, Operator::kNoProperties, 2, 1) \ V(CreateModuleContext, Operator::kNoProperties, 2, 1) @@ -566,13 +467,11 @@ CACHED_OP_LIST_WITH_LANGUAGE_MODE(CACHED_WITH_LANGUAGE_MODE) #undef CACHED_WITH_LANGUAGE_MODE -const Operator* JSOperatorBuilder::CallFunction(size_t arity, - CallFunctionFlags flags, - LanguageMode language_mode, - VectorSlotPair const& feedback, - TailCallMode tail_call_mode) { - CallFunctionParameters parameters(arity, flags, language_mode, feedback, - tail_call_mode); +const Operator* JSOperatorBuilder::CallFunction( + size_t arity, LanguageMode language_mode, VectorSlotPair const& feedback, + ConvertReceiverMode convert_mode, TailCallMode tail_call_mode) { + CallFunctionParameters parameters(arity, language_mode, feedback, + tail_call_mode, convert_mode); return new (zone()) Operator1<CallFunctionParameters>( // -- IrOpcode::kJSCallFunction, Operator::kNoProperties, // opcode "JSCallFunction", // name @@ -603,49 +502,59 @@ const Operator* JSOperatorBuilder::CallConstruct(int arguments) { } -const Operator* JSOperatorBuilder::LoadNamed(const Handle<Name>& name, - const VectorSlotPair& feedback, - LanguageMode language_mode) { - LoadNamedParameters parameters(name, feedback, language_mode); - return new (zone()) Operator1<LoadNamedParameters>( // -- +const Operator* JSOperatorBuilder::ConvertReceiver( + ConvertReceiverMode convert_mode) { + return new (zone()) Operator1<ConvertReceiverMode>( // -- + IrOpcode::kJSConvertReceiver, Operator::kNoThrow, // opcode + "JSConvertReceiver", // name + 1, 1, 1, 1, 1, 0, // counts + convert_mode); // parameter +} + + +const Operator* JSOperatorBuilder::LoadNamed(LanguageMode language_mode, + Handle<Name> name, + const VectorSlotPair& feedback) { + NamedAccess access(language_mode, name, feedback); + return new (zone()) Operator1<NamedAccess>( // -- IrOpcode::kJSLoadNamed, Operator::kNoProperties, // opcode "JSLoadNamed", // name 2, 1, 1, 1, 1, 2, // counts - parameters); // parameter + access); // parameter } -const Operator* JSOperatorBuilder::LoadProperty(const VectorSlotPair& feedback, - LanguageMode language_mode) { - LoadPropertyParameters parameters(feedback, language_mode); - return new (zone()) Operator1<LoadPropertyParameters>( // -- +const Operator* JSOperatorBuilder::LoadProperty( + LanguageMode language_mode, VectorSlotPair const& feedback) { + PropertyAccess access(language_mode, feedback); + return new (zone()) Operator1<PropertyAccess>( // -- IrOpcode::kJSLoadProperty, Operator::kNoProperties, // opcode "JSLoadProperty", // name 3, 1, 1, 1, 1, 2, // counts - parameters); // parameter + access); // parameter } const Operator* JSOperatorBuilder::StoreNamed(LanguageMode language_mode, - const Handle<Name>& name, - const VectorSlotPair& feedback) { - StoreNamedParameters parameters(language_mode, feedback, name); - return new (zone()) Operator1<StoreNamedParameters>( // -- + Handle<Name> name, + VectorSlotPair const& feedback) { + NamedAccess access(language_mode, name, feedback); + return new (zone()) Operator1<NamedAccess>( // -- IrOpcode::kJSStoreNamed, Operator::kNoProperties, // opcode "JSStoreNamed", // name 3, 1, 1, 0, 1, 2, // counts - parameters); // parameter + access); // parameter } const Operator* JSOperatorBuilder::StoreProperty( - LanguageMode language_mode, const VectorSlotPair& feedback) { - StorePropertyParameters parameters(language_mode, feedback); - return new (zone()) Operator1<StorePropertyParameters>( // -- + LanguageMode language_mode, VectorSlotPair const& feedback) { + PropertyAccess access(language_mode, feedback); + return new (zone()) Operator1<PropertyAccess>( // -- IrOpcode::kJSStoreProperty, Operator::kNoProperties, // opcode "JSStoreProperty", // name 4, 1, 1, 0, 1, 2, // counts - parameters); // parameter + access); // parameter } @@ -660,26 +569,24 @@ const Operator* JSOperatorBuilder::DeleteProperty(LanguageMode language_mode) { const Operator* JSOperatorBuilder::LoadGlobal(const Handle<Name>& name, const VectorSlotPair& feedback, - TypeofMode typeof_mode, - int slot_index) { - LoadGlobalParameters parameters(name, feedback, typeof_mode, slot_index); + TypeofMode typeof_mode) { + LoadGlobalParameters parameters(name, feedback, typeof_mode); return new (zone()) Operator1<LoadGlobalParameters>( // -- IrOpcode::kJSLoadGlobal, Operator::kNoProperties, // opcode "JSLoadGlobal", // name - 3, 1, 1, 1, 1, 2, // counts + 1, 1, 1, 1, 1, 2, // counts parameters); // parameter } const Operator* JSOperatorBuilder::StoreGlobal(LanguageMode language_mode, const Handle<Name>& name, - const VectorSlotPair& feedback, - int slot_index) { - StoreGlobalParameters parameters(language_mode, feedback, name, slot_index); + const VectorSlotPair& feedback) { + StoreGlobalParameters parameters(language_mode, feedback, name); return new (zone()) Operator1<StoreGlobalParameters>( // -- IrOpcode::kJSStoreGlobal, Operator::kNoProperties, // opcode "JSStoreGlobal", // name - 4, 1, 1, 0, 1, 2, // counts + 2, 1, 1, 0, 1, 2, // counts parameters); // parameter } @@ -707,28 +614,14 @@ const Operator* JSOperatorBuilder::StoreContext(size_t depth, size_t index) { } -const Operator* JSOperatorBuilder::LoadDynamicGlobal( - const Handle<String>& name, uint32_t check_bitset, - const VectorSlotPair& feedback, TypeofMode typeof_mode) { - DynamicGlobalAccess access(name, check_bitset, feedback, typeof_mode); - return new (zone()) Operator1<DynamicGlobalAccess>( // -- - IrOpcode::kJSLoadDynamicGlobal, Operator::kNoProperties, // opcode - "JSLoadDynamicGlobal", // name - 2, 1, 1, 1, 1, 2, // counts - access); // parameter -} - - -const Operator* JSOperatorBuilder::LoadDynamicContext( - const Handle<String>& name, uint32_t check_bitset, size_t depth, - size_t index) { - ContextAccess context_access(depth, index, false); - DynamicContextAccess access(name, check_bitset, context_access); - return new (zone()) Operator1<DynamicContextAccess>( // -- - IrOpcode::kJSLoadDynamicContext, Operator::kNoProperties, // opcode - "JSLoadDynamicContext", // name - 1, 1, 1, 1, 1, 2, // counts - access); // parameter +const Operator* JSOperatorBuilder::LoadDynamic(const Handle<String>& name, + TypeofMode typeof_mode) { + DynamicAccess access(name, typeof_mode); + return new (zone()) Operator1<DynamicAccess>( // -- + IrOpcode::kJSLoadDynamic, Operator::kNoProperties, // opcode + "JSLoadDynamic", // name + 2, 1, 1, 1, 1, 2, // counts + access); // parameter } @@ -773,6 +666,15 @@ const Operator* JSOperatorBuilder::CreateLiteralObject(int literal_flags) { } +const Operator* JSOperatorBuilder::CreateFunctionContext(int slot_count) { + return new (zone()) Operator1<int>( // -- + IrOpcode::kJSCreateFunctionContext, Operator::kNoProperties, // opcode + "JSCreateFunctionContext", // name + 1, 1, 1, 1, 1, 2, // counts + slot_count); // parameter +} + + const Operator* JSOperatorBuilder::CreateCatchContext( const Handle<String>& name) { return new (zone()) Operator1<Handle<String>, Handle<String>::equal_to, |