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

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

Issue 1092353002: [strong] Disallow implicit conversions for binary arithmetic operations (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: cl feedback 5 Created 5 years, 8 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 aeb317bcc9c4f87685bd54b585f67c845041037a..716592bd972b3928bf7fccbba0baf08f7b8ef342 100644
--- a/src/compiler/js-operator.cc
+++ b/src/compiler/js-operator.cc
@@ -213,21 +213,6 @@ const StoreNamedParameters& StoreNamedParametersOf(const Operator* op) {
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,6 +232,24 @@ const StoreNamedParameters& StoreNamedParametersOf(const Operator* op) {
V(CreateScriptContext, Operator::kNoProperties, 2, 1)
+#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)
+
+
struct JSOperatorGlobalCache final {
#define CACHED(Name, properties, value_input_count, value_output_count) \
struct Name##Operator final : public Operator { \
@@ -261,6 +264,24 @@ struct JSOperatorGlobalCache final {
CACHED_OP_LIST(CACHED)
#undef CACHED
+
+#define CACHED_WITH_STRONG(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<STRONG> k##Name##StrongOperator;
+ CACHED_OP_LIST_WITH_LANGUAGE_MODE(CACHED_WITH_STRONG)
+#undef CACHED_WITH_STRONG
+
+
template <LanguageMode kLanguageMode>
struct StorePropertyOperator final : public Operator1<LanguageMode> {
StorePropertyOperator()
@@ -289,6 +310,21 @@ CACHED_OP_LIST(CACHED)
#undef CACHED
+#define CACHED_WITH_STRONG(Name, properties, value_input_count, \
+ value_output_count) \
+ const Operator* JSOperatorBuilder::Name(LanguageMode language_mode) { \
+ if (is_strong(language_mode)) { \
+ return &cache_.k##Name##StrongOperator; \
+ } else { \
+ return &cache_.k##Name##SloppyOperator; \
+ } \
+ UNREACHABLE(); \
+ return nullptr; \
+ }
+CACHED_OP_LIST_WITH_LANGUAGE_MODE(CACHED_WITH_STRONG)
+#undef CACHED_WITH_STRONG
+
+
const Operator* JSOperatorBuilder::CallFunction(size_t arity,
CallFunctionFlags flags) {
CallFunctionParameters parameters(arity, flags);
« no previous file with comments | « src/compiler/js-operator.h ('k') | src/compiler/js-typed-lowering.cc » ('j') | src/ic/ic.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698