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

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

Issue 554403003: [turbofan] Most simplified operators are globally shared singletons. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Style fixes. Created 6 years, 3 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
« no previous file with comments | « src/compiler/simplified-operator.h ('k') | src/compiler/simplified-operator-reducer-unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/simplified-operator.cc
diff --git a/src/compiler/simplified-operator.cc b/src/compiler/simplified-operator.cc
index 12d56a916418c15a3768031c95f19dcfb66e8d79..16ae8ff3e4bb6483070084eab8345960be456d8e 100644
--- a/src/compiler/simplified-operator.cc
+++ b/src/compiler/simplified-operator.cc
@@ -3,28 +3,145 @@
// found in the LICENSE file.
#include "src/compiler/simplified-operator.h"
+
+#include "src/base/lazy-instance.h"
+#include "src/compiler/opcodes.h"
+#include "src/compiler/operator.h"
#include "src/types-inl.h"
namespace v8 {
namespace internal {
namespace compiler {
-// static
-bool StaticParameterTraits<FieldAccess>::Equals(const FieldAccess& lhs,
- const FieldAccess& rhs) {
- return lhs.base_is_tagged == rhs.base_is_tagged && lhs.offset == rhs.offset &&
- lhs.machine_type == rhs.machine_type && lhs.type->Is(rhs.type);
+const FieldAccess& FieldAccessOf(const Operator* op) {
+ DCHECK_NOT_NULL(op);
+ DCHECK(op->opcode() == IrOpcode::kLoadField ||
+ op->opcode() == IrOpcode::kStoreField);
+ return OpParameter<FieldAccess>(op);
+}
+
+
+const ElementAccess& ElementAccessOf(const Operator* op) {
+ DCHECK_NOT_NULL(op);
+ DCHECK(op->opcode() == IrOpcode::kLoadElement ||
+ op->opcode() == IrOpcode::kStoreElement);
+ return OpParameter<ElementAccess>(op);
}
-// static
-bool StaticParameterTraits<ElementAccess>::Equals(const ElementAccess& lhs,
- const ElementAccess& rhs) {
- return lhs.base_is_tagged == rhs.base_is_tagged &&
- lhs.header_size == rhs.header_size &&
- lhs.machine_type == rhs.machine_type && lhs.type->Is(rhs.type);
+// Specialization for static parameters of type {FieldAccess}.
+template <>
+struct StaticParameterTraits<FieldAccess> {
+ static OStream& PrintTo(OStream& os, const FieldAccess& val) {
+ return os << val.offset;
+ }
+ static int HashCode(const FieldAccess& val) {
+ return (val.offset < 16) | (val.machine_type & 0xffff);
+ }
+ static bool Equals(const FieldAccess& lhs, const FieldAccess& rhs) {
+ return lhs.base_is_tagged == rhs.base_is_tagged &&
+ lhs.offset == rhs.offset && lhs.machine_type == rhs.machine_type &&
+ lhs.type->Is(rhs.type);
+ }
+};
+
+
+// Specialization for static parameters of type {ElementAccess}.
+template <>
+struct StaticParameterTraits<ElementAccess> {
+ static OStream& PrintTo(OStream& os, const ElementAccess& val) {
+ return os << val.header_size;
+ }
+ static int HashCode(const ElementAccess& val) {
+ return (val.header_size < 16) | (val.machine_type & 0xffff);
+ }
+ static bool Equals(const ElementAccess& lhs, const ElementAccess& rhs) {
+ return lhs.base_is_tagged == rhs.base_is_tagged &&
+ lhs.header_size == rhs.header_size &&
+ lhs.machine_type == rhs.machine_type && lhs.type->Is(rhs.type);
+ }
+};
+
+
+#define PURE_OP_LIST(V) \
+ V(BooleanNot, Operator::kNoProperties, 1) \
+ V(NumberEqual, Operator::kCommutative, 2) \
+ V(NumberLessThan, Operator::kNoProperties, 2) \
+ V(NumberLessThanOrEqual, Operator::kNoProperties, 2) \
+ V(NumberAdd, Operator::kCommutative, 2) \
+ V(NumberSubtract, Operator::kNoProperties, 2) \
+ V(NumberMultiply, Operator::kCommutative, 2) \
+ V(NumberDivide, Operator::kNoProperties, 2) \
+ V(NumberModulus, Operator::kNoProperties, 2) \
+ V(NumberToInt32, Operator::kNoProperties, 1) \
+ V(NumberToUint32, Operator::kNoProperties, 1) \
+ V(StringEqual, Operator::kCommutative, 2) \
+ V(StringLessThan, Operator::kNoProperties, 2) \
+ V(StringLessThanOrEqual, Operator::kNoProperties, 2) \
+ V(StringAdd, Operator::kNoProperties, 2) \
+ V(ChangeTaggedToInt32, Operator::kNoProperties, 1) \
+ V(ChangeTaggedToUint32, Operator::kNoProperties, 1) \
+ V(ChangeTaggedToFloat64, Operator::kNoProperties, 1) \
+ V(ChangeInt32ToTagged, Operator::kNoProperties, 1) \
+ V(ChangeUint32ToTagged, Operator::kNoProperties, 1) \
+ V(ChangeFloat64ToTagged, Operator::kNoProperties, 1) \
+ V(ChangeBoolToBit, Operator::kNoProperties, 1) \
+ V(ChangeBitToBool, Operator::kNoProperties, 1)
+
+
+#define ACCESS_OP_LIST(V) \
+ V(LoadField, FieldAccess, Operator::kNoWrite, 1, 1) \
+ V(StoreField, FieldAccess, Operator::kNoRead, 2, 0) \
+ V(LoadElement, ElementAccess, Operator::kNoWrite, 2, 1) \
+ V(StoreElement, ElementAccess, Operator::kNoRead, 3, 0)
+
+
+struct SimplifiedOperatorBuilderImpl FINAL {
+#define PURE(Name, properties, input_count) \
+ struct Name##Operator FINAL : public SimpleOperator { \
+ Name##Operator() \
+ : SimpleOperator(IrOpcode::k##Name, Operator::kPure | properties, \
+ input_count, 1, #Name) {} \
+ }; \
+ Name##Operator k##Name;
+ PURE_OP_LIST(PURE)
+#undef PURE
+};
+
+
+static base::LazyInstance<SimplifiedOperatorBuilderImpl>::type kImpl =
+ LAZY_INSTANCE_INITIALIZER;
+
+
+SimplifiedOperatorBuilder::SimplifiedOperatorBuilder(Zone* zone)
+ : impl_(kImpl.Get()), zone_(zone) {}
+
+
+#define PURE(Name, properties, input_count) \
+ const Operator* SimplifiedOperatorBuilder::Name() const { \
+ return &impl_.k##Name; \
+ }
+PURE_OP_LIST(PURE)
+#undef PURE
+
+
+const Operator* SimplifiedOperatorBuilder::ReferenceEqual(Type* type) const {
+ // TODO(titzer): What about the type parameter?
+ return new (zone()) SimpleOperator(IrOpcode::kReferenceEqual,
+ Operator::kCommutative | Operator::kPure,
+ 2, 1, "ReferenceEqual");
}
+
+#define ACCESS(Name, Type, properties, input_count, output_count) \
+ const Operator* SimplifiedOperatorBuilder::Name(const Type& access) const { \
+ return new (zone()) \
+ Operator1<Type>(IrOpcode::k##Name, Operator::kNoThrow | properties, \
+ input_count, output_count, #Name, access); \
+ }
+ACCESS_OP_LIST(ACCESS)
+#undef ACCESS
+
} // namespace compiler
} // namespace internal
} // namespace v8
« no previous file with comments | « src/compiler/simplified-operator.h ('k') | src/compiler/simplified-operator-reducer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698