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

Unified Diff: src/compiler/type-hints.h

Issue 1487973002: [turbofan] Add binary operation hints for javascript operators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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/type-hints.h
diff --git a/src/compiler/type-hints.h b/src/compiler/type-hints.h
new file mode 100644
index 0000000000000000000000000000000000000000..be8f6f75829d2334188da5bac301662b233800a5
--- /dev/null
+++ b/src/compiler/type-hints.h
@@ -0,0 +1,58 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef V8_COMPILER_TYPE_HINTS_H_
+#define V8_COMPILER_TYPE_HINTS_H_
+
+#include "src/utils.h"
+
+namespace v8 {
+namespace internal {
+namespace compiler {
+
+// Type hints for an binary operation.
+class BinaryOperationHints final {
+ public:
+ enum Hint { kNone, kSignedSmall, kSigned32, kNumber, kString, kAny };
+
+ BinaryOperationHints() : BinaryOperationHints(kNone, kNone, kNone) {}
+ BinaryOperationHints(Hint left, Hint right, Hint result)
+ : bit_field_(LeftField::encode(left) | RightField::encode(right) |
+ ResultField::encode(result)) {}
+
+ static BinaryOperationHints Any() {
+ return BinaryOperationHints(kAny, kAny, kAny);
+ }
+
+ Hint left() const { return LeftField::decode(bit_field_); }
+ Hint right() const { return RightField::decode(bit_field_); }
+ Hint result() const { return ResultField::decode(bit_field_); }
+
+ bool operator==(BinaryOperationHints const& that) const {
+ return this->bit_field_ == that.bit_field_;
+ }
+ bool operator!=(BinaryOperationHints const& that) const {
+ return !(*this == that);
+ }
+
+ friend size_t hash_value(BinaryOperationHints const& hints) {
+ return hints.bit_field_;
+ }
+
+ private:
+ typedef BitField<Hint, 0, 3> LeftField;
+ typedef BitField<Hint, 3, 3> RightField;
+ typedef BitField<Hint, 6, 3> ResultField;
+
+ uint32_t bit_field_;
+};
+
+std::ostream& operator<<(std::ostream&, BinaryOperationHints::Hint);
+std::ostream& operator<<(std::ostream&, BinaryOperationHints);
+
+} // namespace compiler
+} // namespace internal
+} // namespace v8
+
+#endif // V8_COMPILER_TYPE_HINTS_H_

Powered by Google App Engine
This is Rietveld 408576698