Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Unified Diff: src/compiler/js-operator.cc

Issue 1144183004: [strong] Refactor ObjectStrength into a replacement for strong boolean args (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/compiler/js-operator.cc
diff --git a/src/compiler/js-operator.cc b/src/compiler/js-operator.cc
index a360a279acb29116f8a6c4df027c8b162134268b..8f7db2d5d01e92ca7b130543a92da4a3aa5a8a6c 100644
--- a/src/compiler/js-operator.cc
+++ b/src/compiler/js-operator.cc
@@ -334,7 +334,7 @@ const CreateClosureParameters& CreateClosureParametersOf(const Operator* op) {
V(CreateScriptContext, Operator::kNoProperties, 2, 1)
-#define CACHED_OP_LIST_WITH_LANGUAGE_MODE(V) \
+#define CACHED_OP_LIST_WITH_STRENGTH(V) \
V(LessThan, Operator::kNoProperties, 2, 1) \
V(GreaterThan, Operator::kNoProperties, 2, 1) \
V(LessThanOrEqual, Operator::kNoProperties, 2, 1) \
@@ -349,8 +349,7 @@ const CreateClosureParameters& CreateClosureParametersOf(const Operator* op) {
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)
+ V(Modulus, Operator::kNoProperties, 2, 1)
struct JSOperatorGlobalCache final {
@@ -368,23 +367,34 @@ struct JSOperatorGlobalCache final {
#undef CACHED
-#define CACHED_WITH_LANGUAGE_MODE(Name, properties, value_input_count, \
- value_output_count) \
- template <LanguageMode kLanguageMode> \
- struct Name##Operator final : public Operator1<LanguageMode> { \
+#define CACHED_WITH_STRENGTH(Name, properties, value_input_count, \
+ value_output_count) \
+ template <Strength kStrength> \
+ struct Name##Operator final : public Operator1<Strength> { \
Name##Operator() \
- : Operator1<LanguageMode>( \
+ : Operator1<Strength>( \
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) {} \
+ Operator::ZeroIfNoThrow(properties), kStrength) {} \
}; \
- 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
+ Name##Operator<Strength::NORMAL> k##Name##SloppyOperator; \
+ Name##Operator<Strength::STRONG> k##Name##StrongOperator;
+ CACHED_OP_LIST_WITH_STRENGTH(CACHED_WITH_STRENGTH)
+#undef CACHED_WITH_STRENGTH
+
+
+ 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;
+ StorePropertyOperator<STRONG> kStorePropertyStrongOperator;
};
@@ -404,24 +414,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; \
+#define CACHED_WITH_STRENGTH(Name, properties, value_input_count, \
+ value_output_count) \
+ const Operator* JSOperatorBuilder::Name(Strength strength) { \
+ if (is_strong(strength)) { \
+ return &cache_.k##Name##StrongOperator; \
+ } \
+ return &cache_.k##Name##SloppyOperator; \
}
-CACHED_OP_LIST_WITH_LANGUAGE_MODE(CACHED_WITH_LANGUAGE_MODE)
-#undef CACHED_WITH_LANGUAGE_MODE
+CACHED_OP_LIST_WITH_STRENGTH(CACHED_WITH_STRENGTH)
+#undef CACHED_WITH_STRENGTH
+
+const Operator* JSOperatorBuilder::StoreProperty(LanguageMode language_mode) {
+ switch (language_mode) {
+ case SLOPPY:
+ return &cache_.kStorePropertySloppyOperator;
+ case STRICT:
+ return &cache_.kStorePropertyStrictOperator;
+ case STRONG:
+ return &cache_.kStorePropertyStrongOperator;
+ default:
+ UNREACHABLE();
+ return nullptr;
+ }
+}
const Operator* JSOperatorBuilder::CallFunction(size_t arity,

Powered by Google App Engine
This is Rietveld 408576698