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

Side by Side 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 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef V8_COMPILER_TYPE_HINTS_H_
6 #define V8_COMPILER_TYPE_HINTS_H_
7
8 #include "src/utils.h"
9
10 namespace v8 {
11 namespace internal {
12 namespace compiler {
13
14 // Type hints for an binary operation.
15 class BinaryOperationHints final {
16 public:
17 enum Hint { kNone, kSignedSmall, kSigned32, kNumber, kString, kAny };
18
19 BinaryOperationHints() : BinaryOperationHints(kNone, kNone, kNone) {}
20 BinaryOperationHints(Hint left, Hint right, Hint result)
21 : bit_field_(LeftField::encode(left) | RightField::encode(right) |
22 ResultField::encode(result)) {}
23
24 static BinaryOperationHints Any() {
25 return BinaryOperationHints(kAny, kAny, kAny);
26 }
27
28 Hint left() const { return LeftField::decode(bit_field_); }
29 Hint right() const { return RightField::decode(bit_field_); }
30 Hint result() const { return ResultField::decode(bit_field_); }
31
32 bool operator==(BinaryOperationHints const& that) const {
33 return this->bit_field_ == that.bit_field_;
34 }
35 bool operator!=(BinaryOperationHints const& that) const {
36 return !(*this == that);
37 }
38
39 friend size_t hash_value(BinaryOperationHints const& hints) {
40 return hints.bit_field_;
41 }
42
43 private:
44 typedef BitField<Hint, 0, 3> LeftField;
45 typedef BitField<Hint, 3, 3> RightField;
46 typedef BitField<Hint, 6, 3> ResultField;
47
48 uint32_t bit_field_;
49 };
50
51 std::ostream& operator<<(std::ostream&, BinaryOperationHints::Hint);
52 std::ostream& operator<<(std::ostream&, BinaryOperationHints);
53
54 } // namespace compiler
55 } // namespace internal
56 } // namespace v8
57
58 #endif // V8_COMPILER_TYPE_HINTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698