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

Side by Side Diff: src/compiler/type-hints.cc

Issue 2228983002: [turbofan] Simplify BinaryOperationHints and CompareOperationHints. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix compile for realz Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « src/compiler/type-hints.h ('k') | src/ic/ic-state.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/type-hints.h" 5 #include "src/compiler/type-hints.h"
6 6
7 namespace v8 { 7 namespace v8 {
8 namespace internal { 8 namespace internal {
9 namespace compiler { 9 namespace compiler {
10 10
11 std::ostream& operator<<(std::ostream& os, BinaryOperationHints::Hint hint) { 11 std::ostream& operator<<(std::ostream& os, BinaryOperationHint hint) {
12 switch (hint) { 12 switch (hint) {
13 case BinaryOperationHints::kNone: 13 case BinaryOperationHint::kNone:
14 return os << "None"; 14 return os << "None";
15 case BinaryOperationHints::kSignedSmall: 15 case BinaryOperationHint::kSignedSmall:
16 return os << "SignedSmall"; 16 return os << "SignedSmall";
17 case BinaryOperationHints::kSigned32: 17 case BinaryOperationHint::kSigned32:
18 return os << "Signed32"; 18 return os << "Signed32";
19 case BinaryOperationHints::kNumberOrOddball: 19 case BinaryOperationHint::kNumberOrOddball:
20 return os << "NumberOrOddball"; 20 return os << "NumberOrOddball";
21 case BinaryOperationHints::kString: 21 case BinaryOperationHint::kAny:
22 return os << "String";
23 case BinaryOperationHints::kAny:
24 return os << "Any"; 22 return os << "Any";
25 } 23 }
26 UNREACHABLE(); 24 UNREACHABLE();
27 return os; 25 return os;
28 } 26 }
29 27
30 std::ostream& operator<<(std::ostream& os, BinaryOperationHints hints) { 28 std::ostream& operator<<(std::ostream& os, CompareOperationHint hint) {
31 return os << hints.left() << "*" << hints.right() << "->" << hints.result();
32 }
33
34 std::ostream& operator<<(std::ostream& os, CompareOperationHints::Hint hint) {
35 switch (hint) { 29 switch (hint) {
36 case CompareOperationHints::kNone: 30 case CompareOperationHint::kNone:
37 return os << "None"; 31 return os << "None";
38 case CompareOperationHints::kBoolean: 32 case CompareOperationHint::kSignedSmall:
39 return os << "Boolean";
40 case CompareOperationHints::kSignedSmall:
41 return os << "SignedSmall"; 33 return os << "SignedSmall";
42 case CompareOperationHints::kNumber: 34 case CompareOperationHint::kNumber:
43 return os << "Number"; 35 return os << "Number";
44 case CompareOperationHints::kNumberOrOddball: 36 case CompareOperationHint::kNumberOrOddball:
45 return os << "NumberOrOddball"; 37 return os << "NumberOrOddball";
46 case CompareOperationHints::kString: 38 case CompareOperationHint::kAny:
47 return os << "String";
48 case CompareOperationHints::kInternalizedString:
49 return os << "InternalizedString";
50 case CompareOperationHints::kUniqueName:
51 return os << "UniqueName";
52 case CompareOperationHints::kReceiver:
53 return os << "Receiver";
54 case CompareOperationHints::kAny:
55 return os << "Any"; 39 return os << "Any";
56 } 40 }
57 UNREACHABLE(); 41 UNREACHABLE();
58 return os; 42 return os;
59 } 43 }
60 44
61 std::ostream& operator<<(std::ostream& os, CompareOperationHints hints) {
62 return os << hints.left() << "*" << hints.right() << " (" << hints.combined()
63 << ")";
64 }
65
66 std::ostream& operator<<(std::ostream& os, ToBooleanHint hint) { 45 std::ostream& operator<<(std::ostream& os, ToBooleanHint hint) {
67 switch (hint) { 46 switch (hint) {
68 case ToBooleanHint::kNone: 47 case ToBooleanHint::kNone:
69 return os << "None"; 48 return os << "None";
70 case ToBooleanHint::kUndefined: 49 case ToBooleanHint::kUndefined:
71 return os << "Undefined"; 50 return os << "Undefined";
72 case ToBooleanHint::kBoolean: 51 case ToBooleanHint::kBoolean:
73 return os << "Boolean"; 52 return os << "Boolean";
74 case ToBooleanHint::kNull: 53 case ToBooleanHint::kNull:
75 return os << "Null"; 54 return os << "Null";
(...skipping 13 matching lines...) Expand all
89 return os << "Any"; 68 return os << "Any";
90 } 69 }
91 UNREACHABLE(); 70 UNREACHABLE();
92 return os; 71 return os;
93 } 72 }
94 73
95 std::ostream& operator<<(std::ostream& os, ToBooleanHints hints) { 74 std::ostream& operator<<(std::ostream& os, ToBooleanHints hints) {
96 if (hints == ToBooleanHint::kAny) return os << "Any"; 75 if (hints == ToBooleanHint::kAny) return os << "Any";
97 if (hints == ToBooleanHint::kNone) return os << "None"; 76 if (hints == ToBooleanHint::kNone) return os << "None";
98 bool first = true; 77 bool first = true;
99 for (ToBooleanHints::mask_type i = 0; i < sizeof(i) * CHAR_BIT; ++i) { 78 for (ToBooleanHints::mask_type i = 0; i < sizeof(i) * 8; ++i) {
100 ToBooleanHint const hint = static_cast<ToBooleanHint>(1u << i); 79 ToBooleanHint const hint = static_cast<ToBooleanHint>(1u << i);
101 if (hints & hint) { 80 if (hints & hint) {
102 if (!first) os << "|"; 81 if (!first) os << "|";
103 first = false; 82 first = false;
104 os << hint; 83 os << hint;
105 } 84 }
106 } 85 }
107 return os; 86 return os;
108 } 87 }
109 88
110 // static
111 bool BinaryOperationHints::Is(Hint h1, Hint h2) {
112 if (h1 == h2) return true;
113 switch (h1) {
114 case kNone:
115 return true;
116 case kSignedSmall:
117 return h2 == kSigned32 || h2 == kNumberOrOddball || h2 == kAny;
118 case kSigned32:
119 return h2 == kNumberOrOddball || h2 == kAny;
120 case kNumberOrOddball:
121 return h2 == kAny;
122 case kString:
123 return h2 == kAny;
124 case kAny:
125 return false;
126 }
127 UNREACHABLE();
128 return false;
129 }
130
131 // static
132 BinaryOperationHints::Hint BinaryOperationHints::Combine(Hint h1, Hint h2) {
133 if (Is(h1, h2)) return h2;
134 if (Is(h2, h1)) return h1;
135 return kAny;
136 }
137
138 } // namespace compiler 89 } // namespace compiler
139 } // namespace internal 90 } // namespace internal
140 } // namespace v8 91 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/type-hints.h ('k') | src/ic/ic-state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698