aboutsummaryrefslogtreecommitdiff
path: root/deps/v8/src/compiler/js-operator.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/compiler/js-operator.cc')
-rw-r--r--deps/v8/src/compiler/js-operator.cc190
1 files changed, 129 insertions, 61 deletions
diff --git a/deps/v8/src/compiler/js-operator.cc b/deps/v8/src/compiler/js-operator.cc
index 327da55bdd..f737b40865 100644
--- a/deps/v8/src/compiler/js-operator.cc
+++ b/deps/v8/src/compiler/js-operator.cc
@@ -14,25 +14,8 @@ namespace v8 {
namespace internal {
namespace compiler {
-bool operator==(CallFunctionParameters const& lhs,
- CallFunctionParameters const& rhs) {
- return lhs.arity() == rhs.arity() && lhs.flags() == rhs.flags();
-}
-
-
-bool operator!=(CallFunctionParameters const& lhs,
- CallFunctionParameters const& rhs) {
- return !(lhs == rhs);
-}
-
-
-size_t hash_value(CallFunctionParameters const& p) {
- return base::hash_combine(p.arity(), p.flags());
-}
-
-
std::ostream& operator<<(std::ostream& os, CallFunctionParameters const& p) {
- return os << p.arity() << ", " << p.flags();
+ return os << p.arity() << ", " << p.flags() << ", " << p.language_mode();
}
@@ -208,26 +191,42 @@ const StoreNamedParameters& StoreNamedParametersOf(const Operator* op) {
}
+bool operator==(CreateClosureParameters const& lhs,
+ CreateClosureParameters const& rhs) {
+ return lhs.pretenure() == rhs.pretenure() &&
+ lhs.shared_info().is_identical_to(rhs.shared_info());
+}
+
+
+bool operator!=(CreateClosureParameters const& lhs,
+ CreateClosureParameters const& rhs) {
+ return !(lhs == rhs);
+}
+
+
+size_t hash_value(CreateClosureParameters const& p) {
+ // TODO(mstarzinger): Include hash of the SharedFunctionInfo here.
+ base::hash<PretenureFlag> h;
+ return h(p.pretenure());
+}
+
+
+std::ostream& operator<<(std::ostream& os, CreateClosureParameters const& p) {
+ return os << p.pretenure() << ", " << Brief(*p.shared_info());
+}
+
+
+const CreateClosureParameters& CreateClosureParametersOf(const Operator* op) {
+ DCHECK_EQ(IrOpcode::kJSCreateClosure, op->opcode());
+ return OpParameter<CreateClosureParameters>(op);
+}
+
+
#define CACHED_OP_LIST(V) \
V(Equal, Operator::kNoProperties, 2, 1) \
V(NotEqual, Operator::kNoProperties, 2, 1) \
V(StrictEqual, Operator::kPure, 2, 1) \
V(StrictNotEqual, Operator::kPure, 2, 1) \
- V(LessThan, Operator::kNoProperties, 2, 1) \
- V(GreaterThan, Operator::kNoProperties, 2, 1) \
- V(LessThanOrEqual, Operator::kNoProperties, 2, 1) \
- V(GreaterThanOrEqual, Operator::kNoProperties, 2, 1) \
- V(BitwiseOr, Operator::kNoProperties, 2, 1) \
- V(BitwiseXor, Operator::kNoProperties, 2, 1) \
- V(BitwiseAnd, Operator::kNoProperties, 2, 1) \
- V(ShiftLeft, Operator::kNoProperties, 2, 1) \
- V(ShiftRight, Operator::kNoProperties, 2, 1) \
- V(ShiftRightLogical, Operator::kNoProperties, 2, 1) \
- V(Add, Operator::kNoProperties, 2, 1) \
- V(Subtract, Operator::kNoProperties, 2, 1) \
- V(Multiply, Operator::kNoProperties, 2, 1) \
- V(Divide, Operator::kNoProperties, 2, 1) \
- V(Modulus, Operator::kNoProperties, 2, 1) \
V(UnaryNot, Operator::kPure, 1, 1) \
V(ToBoolean, Operator::kPure, 1, 1) \
V(ToNumber, Operator::kNoProperties, 1, 1) \
@@ -247,9 +246,28 @@ const StoreNamedParameters& StoreNamedParametersOf(const Operator* op) {
V(CreateScriptContext, Operator::kNoProperties, 2, 1)
-struct JSOperatorGlobalCache FINAL {
+#define CACHED_OP_LIST_WITH_LANGUAGE_MODE(V) \
+ V(LessThan, Operator::kNoProperties, 2, 1) \
+ V(GreaterThan, Operator::kNoProperties, 2, 1) \
+ V(LessThanOrEqual, Operator::kNoProperties, 2, 1) \
+ V(GreaterThanOrEqual, Operator::kNoProperties, 2, 1) \
+ V(BitwiseOr, Operator::kNoProperties, 2, 1) \
+ V(BitwiseXor, Operator::kNoProperties, 2, 1) \
+ V(BitwiseAnd, Operator::kNoProperties, 2, 1) \
+ V(ShiftLeft, Operator::kNoProperties, 2, 1) \
+ V(ShiftRight, Operator::kNoProperties, 2, 1) \
+ V(ShiftRightLogical, Operator::kNoProperties, 2, 1) \
+ V(Add, Operator::kNoProperties, 2, 1) \
+ V(Subtract, Operator::kNoProperties, 2, 1) \
+ V(Multiply, Operator::kNoProperties, 2, 1) \
+ V(Divide, Operator::kNoProperties, 2, 1) \
+ V(Modulus, Operator::kNoProperties, 2, 1) \
+ V(StoreProperty, Operator::kNoProperties, 3, 0)
+
+
+struct JSOperatorGlobalCache final {
#define CACHED(Name, properties, value_input_count, value_output_count) \
- struct Name##Operator FINAL : public Operator { \
+ struct Name##Operator final : public Operator { \
Name##Operator() \
: Operator(IrOpcode::kJS##Name, properties, "JS" #Name, \
value_input_count, Operator::ZeroIfPure(properties), \
@@ -261,15 +279,24 @@ struct JSOperatorGlobalCache FINAL {
CACHED_OP_LIST(CACHED)
#undef CACHED
- template <LanguageMode kLanguageMode>
- struct StorePropertyOperator FINAL : public Operator1<LanguageMode> {
- StorePropertyOperator()
- : Operator1<LanguageMode>(IrOpcode::kJSStoreProperty,
- Operator::kNoProperties, "JSStoreProperty", 3,
- 1, 1, 0, 1, 2, kLanguageMode) {}
- };
- StorePropertyOperator<SLOPPY> kStorePropertySloppyOperator;
- StorePropertyOperator<STRICT> kStorePropertyStrictOperator;
+
+#define CACHED_WITH_LANGUAGE_MODE(Name, properties, value_input_count, \
+ value_output_count) \
+ template <LanguageMode kLanguageMode> \
+ struct Name##Operator final : public Operator1<LanguageMode> { \
+ Name##Operator() \
+ : Operator1<LanguageMode>( \
+ IrOpcode::kJS##Name, properties, "JS" #Name, value_input_count, \
+ Operator::ZeroIfPure(properties), \
+ Operator::ZeroIfEliminatable(properties), value_output_count, \
+ Operator::ZeroIfPure(properties), \
+ Operator::ZeroIfNoThrow(properties), kLanguageMode) {} \
+ }; \
+ Name##Operator<SLOPPY> k##Name##SloppyOperator; \
+ Name##Operator<STRICT> k##Name##StrictOperator; \
+ Name##Operator<STRONG> k##Name##StrongOperator;
+ CACHED_OP_LIST_WITH_LANGUAGE_MODE(CACHED_WITH_LANGUAGE_MODE)
+#undef CACHED_WITH_LANGUAGE_MODE
};
@@ -289,9 +316,30 @@ CACHED_OP_LIST(CACHED)
#undef CACHED
+#define CACHED_WITH_LANGUAGE_MODE(Name, properties, value_input_count, \
+ value_output_count) \
+ const Operator* JSOperatorBuilder::Name(LanguageMode language_mode) { \
+ switch (language_mode) { \
+ case SLOPPY: \
+ return &cache_.k##Name##SloppyOperator; \
+ case STRICT: \
+ return &cache_.k##Name##StrictOperator; \
+ case STRONG: \
+ return &cache_.k##Name##StrongOperator; \
+ case STRONG_BIT: \
+ break; /* %*!%^$#@ */ \
+ } \
+ UNREACHABLE(); \
+ return nullptr; \
+ }
+CACHED_OP_LIST_WITH_LANGUAGE_MODE(CACHED_WITH_LANGUAGE_MODE)
+#undef CACHED_WITH_LANGUAGE_MODE
+
+
const Operator* JSOperatorBuilder::CallFunction(size_t arity,
- CallFunctionFlags flags) {
- CallFunctionParameters parameters(arity, flags);
+ CallFunctionFlags flags,
+ LanguageMode language_mode) {
+ CallFunctionParameters parameters(arity, flags, language_mode);
return new (zone()) Operator1<CallFunctionParameters>( // --
IrOpcode::kJSCallFunction, Operator::kNoProperties, // opcode
"JSCallFunction", // name
@@ -324,8 +372,9 @@ const Operator* JSOperatorBuilder::CallConstruct(int arguments) {
const Operator* JSOperatorBuilder::LoadNamed(const Unique<Name>& name,
const VectorSlotPair& feedback,
- ContextualMode contextual_mode) {
- LoadNamedParameters parameters(name, feedback, contextual_mode);
+ ContextualMode contextual_mode,
+ PropertyICMode load_ic) {
+ LoadNamedParameters parameters(name, feedback, contextual_mode, load_ic);
return new (zone()) Operator1<LoadNamedParameters>( // --
IrOpcode::kJSLoadNamed, Operator::kNoProperties, // opcode
"JSLoadNamed", // name
@@ -345,20 +394,10 @@ const Operator* JSOperatorBuilder::LoadProperty(
}
-const Operator* JSOperatorBuilder::StoreProperty(LanguageMode language_mode) {
- if (is_strict(language_mode)) {
- return &cache_.kStorePropertyStrictOperator;
- } else {
- return &cache_.kStorePropertySloppyOperator;
- }
- UNREACHABLE();
- return nullptr;
-}
-
-
const Operator* JSOperatorBuilder::StoreNamed(LanguageMode language_mode,
- const Unique<Name>& name) {
- StoreNamedParameters parameters(language_mode, name);
+ const Unique<Name>& name,
+ PropertyICMode store_ic) {
+ StoreNamedParameters parameters(language_mode, name, store_ic);
return new (zone()) Operator1<StoreNamedParameters>( // --
IrOpcode::kJSStoreNamed, Operator::kNoProperties, // opcode
"JSStoreNamed", // name
@@ -399,6 +438,35 @@ const Operator* JSOperatorBuilder::StoreContext(size_t depth, size_t index) {
}
+const Operator* JSOperatorBuilder::CreateClosure(
+ Handle<SharedFunctionInfo> shared_info, PretenureFlag pretenure) {
+ CreateClosureParameters parameters(shared_info, pretenure);
+ return new (zone()) Operator1<CreateClosureParameters>( // --
+ IrOpcode::kJSCreateClosure, Operator::kNoThrow, // opcode
+ "JSCreateClosure", // name
+ 1, 1, 1, 1, 1, 0, // counts
+ parameters); // parameter
+}
+
+
+const Operator* JSOperatorBuilder::CreateLiteralArray(int literal_flags) {
+ return new (zone()) Operator1<int>( // --
+ IrOpcode::kJSCreateLiteralArray, Operator::kNoProperties, // opcode
+ "JSCreateLiteralArray", // name
+ 3, 1, 1, 1, 1, 2, // counts
+ literal_flags); // parameter
+}
+
+
+const Operator* JSOperatorBuilder::CreateLiteralObject(int literal_flags) {
+ return new (zone()) Operator1<int>( // --
+ IrOpcode::kJSCreateLiteralObject, Operator::kNoProperties, // opcode
+ "JSCreateLiteralObject", // name
+ 3, 1, 1, 1, 1, 2, // counts
+ literal_flags); // parameter
+}
+
+
const Operator* JSOperatorBuilder::CreateCatchContext(
const Unique<String>& name) {
return new (zone()) Operator1<Unique<String>>( // --