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

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: rebase :( 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..f50330c766fea03ada6e6fbe1bfe5a2c3f9dd2fe 100644
--- a/src/compiler/js-operator.cc
+++ b/src/compiler/js-operator.cc
@@ -213,22 +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) \
V(ToString, Operator::kNoProperties, 1, 1) \
@@ -246,6 +230,24 @@ const StoreNamedParameters& StoreNamedParametersOf(const Operator* op) {
V(CreateModuleContext, Operator::kNoProperties, 2, 1) \
V(CreateScriptContext, Operator::kNoProperties, 2, 1)
+#define CACHED_OP_LIST_WITH_STRONG(V) \
Michael Starzinger 2015/04/23 13:47:51 nit: s/WITH_STRONG/WITH_LANGUAGE_MODE/
conradw 2015/04/23 14:51:54 These operators are specifically associated with a
Michael Starzinger 2015/04/23 15:20:53 Yep, the implementation only provides caches for S
conradw 2015/04/23 16:08:02 I'd like to keep something in the code drawing att
+ 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)
+
struct JSOperatorGlobalCache final {
#define CACHED(Name, properties, value_input_count, value_output_count) \
@@ -261,6 +263,21 @@ struct JSOperatorGlobalCache final {
CACHED_OP_LIST(CACHED)
#undef CACHED
+#define CACHED(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_STRONG(CACHED)
+#undef CACHED
+
template <LanguageMode kLanguageMode>
struct StorePropertyOperator final : public Operator1<LanguageMode> {
StorePropertyOperator()
@@ -288,6 +305,18 @@ JSOperatorBuilder::JSOperatorBuilder(Zone* zone)
CACHED_OP_LIST(CACHED)
#undef CACHED
+#define CACHED(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_STRONG(CACHED)
+#undef CACHED
const Operator* JSOperatorBuilder::CallFunction(size_t arity,
CallFunctionFlags flags) {

Powered by Google App Engine
This is Rietveld 408576698