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

Unified Diff: src/compiler/common-operator.h

Issue 539933002: [turbofan] Make sure Operator is really immutable. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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 | « no previous file | src/compiler/graph-replay.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/common-operator.h
diff --git a/src/compiler/common-operator.h b/src/compiler/common-operator.h
index aa1aac7de82a19abab4da6baad9cbfdebcf62017..2ef178b8386fdb66db6fec0c520c9c447e4a636c 100644
--- a/src/compiler/common-operator.h
+++ b/src/compiler/common-operator.h
@@ -191,37 +191,37 @@ class CommonOperatorBuilder {
template <typename T>
struct CommonOperatorTraits {
static inline bool Equals(T a, T b);
- static inline bool HasValue(Operator* op);
- static inline T ValueOf(Operator* op);
+ static inline bool HasValue(const Operator* op);
+ static inline T ValueOf(const Operator* op);
};
template <>
struct CommonOperatorTraits<int32_t> {
static inline bool Equals(int32_t a, int32_t b) { return a == b; }
- static inline bool HasValue(Operator* op) {
+ static inline bool HasValue(const Operator* op) {
return op->opcode() == IrOpcode::kInt32Constant ||
op->opcode() == IrOpcode::kNumberConstant;
}
- static inline int32_t ValueOf(Operator* op) {
+ static inline int32_t ValueOf(const Operator* op) {
if (op->opcode() == IrOpcode::kNumberConstant) {
// TODO(titzer): cache the converted int32 value in NumberConstant.
- return FastD2I(reinterpret_cast<Operator1<double>*>(op)->parameter());
+ return FastD2I(OpParameter<double>(op));
}
CHECK_EQ(IrOpcode::kInt32Constant, op->opcode());
- return static_cast<Operator1<int32_t>*>(op)->parameter();
+ return OpParameter<int32_t>(op);
}
};
template <>
struct CommonOperatorTraits<uint32_t> {
static inline bool Equals(uint32_t a, uint32_t b) { return a == b; }
- static inline bool HasValue(Operator* op) {
+ static inline bool HasValue(const Operator* op) {
return CommonOperatorTraits<int32_t>::HasValue(op);
}
- static inline uint32_t ValueOf(Operator* op) {
+ static inline uint32_t ValueOf(const Operator* op) {
if (op->opcode() == IrOpcode::kNumberConstant) {
// TODO(titzer): cache the converted uint32 value in NumberConstant.
- return FastD2UI(reinterpret_cast<Operator1<double>*>(op)->parameter());
+ return FastD2UI(OpParameter<double>(op));
}
return static_cast<uint32_t>(CommonOperatorTraits<int32_t>::ValueOf(op));
}
@@ -230,27 +230,27 @@ struct CommonOperatorTraits<uint32_t> {
template <>
struct CommonOperatorTraits<int64_t> {
static inline bool Equals(int64_t a, int64_t b) { return a == b; }
- static inline bool HasValue(Operator* op) {
+ static inline bool HasValue(const Operator* op) {
return op->opcode() == IrOpcode::kInt32Constant ||
op->opcode() == IrOpcode::kInt64Constant ||
op->opcode() == IrOpcode::kNumberConstant;
}
- static inline int64_t ValueOf(Operator* op) {
+ static inline int64_t ValueOf(const Operator* op) {
if (op->opcode() == IrOpcode::kInt32Constant) {
return static_cast<int64_t>(CommonOperatorTraits<int32_t>::ValueOf(op));
}
CHECK_EQ(IrOpcode::kInt64Constant, op->opcode());
- return static_cast<Operator1<int64_t>*>(op)->parameter();
+ return OpParameter<int64_t>(op);
}
};
template <>
struct CommonOperatorTraits<uint64_t> {
static inline bool Equals(uint64_t a, uint64_t b) { return a == b; }
- static inline bool HasValue(Operator* op) {
+ static inline bool HasValue(const Operator* op) {
return CommonOperatorTraits<int64_t>::HasValue(op);
}
- static inline uint64_t ValueOf(Operator* op) {
+ static inline uint64_t ValueOf(const Operator* op) {
return static_cast<uint64_t>(CommonOperatorTraits<int64_t>::ValueOf(op));
}
};
@@ -260,15 +260,15 @@ struct CommonOperatorTraits<double> {
static inline bool Equals(double a, double b) {
return DoubleRepresentation(a).bits == DoubleRepresentation(b).bits;
}
- static inline bool HasValue(Operator* op) {
+ static inline bool HasValue(const Operator* op) {
return op->opcode() == IrOpcode::kFloat64Constant ||
op->opcode() == IrOpcode::kInt32Constant ||
op->opcode() == IrOpcode::kNumberConstant;
}
- static inline double ValueOf(Operator* op) {
+ static inline double ValueOf(const Operator* op) {
if (op->opcode() == IrOpcode::kFloat64Constant ||
op->opcode() == IrOpcode::kNumberConstant) {
- return reinterpret_cast<Operator1<double>*>(op)->parameter();
+ return OpParameter<double>(op);
}
return static_cast<double>(CommonOperatorTraits<int32_t>::ValueOf(op));
}
@@ -279,43 +279,44 @@ struct CommonOperatorTraits<ExternalReference> {
static inline bool Equals(ExternalReference a, ExternalReference b) {
return a == b;
}
- static inline bool HasValue(Operator* op) {
+ static inline bool HasValue(const Operator* op) {
return op->opcode() == IrOpcode::kExternalConstant;
}
- static inline ExternalReference ValueOf(Operator* op) {
+ static inline ExternalReference ValueOf(const Operator* op) {
CHECK_EQ(IrOpcode::kExternalConstant, op->opcode());
- return static_cast<Operator1<ExternalReference>*>(op)->parameter();
+ return OpParameter<ExternalReference>(op);
}
};
template <typename T>
struct CommonOperatorTraits<PrintableUnique<T> > {
- static inline bool HasValue(Operator* op) {
+ static inline bool HasValue(const Operator* op) {
return op->opcode() == IrOpcode::kHeapConstant;
}
- static inline PrintableUnique<T> ValueOf(Operator* op) {
+ static inline PrintableUnique<T> ValueOf(const Operator* op) {
CHECK_EQ(IrOpcode::kHeapConstant, op->opcode());
- return static_cast<Operator1<PrintableUnique<T> >*>(op)->parameter();
+ return OpParameter<PrintableUnique<T> >(op);
}
};
template <typename T>
struct CommonOperatorTraits<Handle<T> > {
- static inline bool HasValue(Operator* op) {
+ static inline bool HasValue(const Operator* op) {
return CommonOperatorTraits<PrintableUnique<T> >::HasValue(op);
}
- static inline Handle<T> ValueOf(Operator* op) {
+ static inline Handle<T> ValueOf(const Operator* op) {
return CommonOperatorTraits<PrintableUnique<T> >::ValueOf(op).handle();
}
};
template <typename T>
-inline T ValueOf(Operator* op) {
+inline T ValueOf(const Operator* op) {
return CommonOperatorTraits<T>::ValueOf(op);
}
-}
-}
-} // namespace v8::internal::compiler
+
+} // namespace compiler
+} // namespace internal
+} // namespace v8
#endif // V8_COMPILER_COMMON_OPERATOR_H_
« no previous file with comments | « no previous file | src/compiler/graph-replay.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698