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

Side by Side Diff: src/compiler/representation-change.h

Issue 470593002: Unify MachineType and RepType. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/compiler/machine-type.cc ('k') | src/compiler/simplified-lowering.cc » ('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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 #ifndef V8_COMPILER_REPRESENTATION_CHANGE_H_ 5 #ifndef V8_COMPILER_REPRESENTATION_CHANGE_H_
6 #define V8_COMPILER_REPRESENTATION_CHANGE_H_ 6 #define V8_COMPILER_REPRESENTATION_CHANGE_H_
7 7
8 #include "src/compiler/js-graph.h" 8 #include "src/compiler/js-graph.h"
9 #include "src/compiler/machine-operator.h" 9 #include "src/compiler/machine-operator.h"
10 #include "src/compiler/node-properties-inl.h" 10 #include "src/compiler/node-properties-inl.h"
11 #include "src/compiler/simplified-operator.h" 11 #include "src/compiler/simplified-operator.h"
12 12
13 namespace v8 { 13 namespace v8 {
14 namespace internal { 14 namespace internal {
15 namespace compiler { 15 namespace compiler {
16 16
17 // The types and representations tracked during representation inference
18 // and change insertion.
19 // TODO(titzer): First, merge MachineType and RepType.
20 // TODO(titzer): Second, Use the real type system instead of RepType.
21 enum RepType {
22 // Representations.
23 rBit = 1 << 0,
24 rWord32 = 1 << 1,
25 rWord64 = 1 << 2,
26 rFloat64 = 1 << 3,
27 rTagged = 1 << 4,
28
29 // Types.
30 tBool = 1 << 5,
31 tInt32 = 1 << 6,
32 tUint32 = 1 << 7,
33 tInt64 = 1 << 8,
34 tUint64 = 1 << 9,
35 tNumber = 1 << 10,
36 tAny = 1 << 11
37 };
38
39 #define REP_TYPE_STRLEN 24
40
41 typedef uint16_t RepTypeUnion;
42
43
44 inline void RenderRepTypeUnion(char* buf, RepTypeUnion info) {
45 base::OS::SNPrintF(buf, REP_TYPE_STRLEN, "{%s%s%s%s%s %s%s%s%s%s%s%s}",
46 (info & rBit) ? "k" : " ", (info & rWord32) ? "w" : " ",
47 (info & rWord64) ? "q" : " ",
48 (info & rFloat64) ? "f" : " ",
49 (info & rTagged) ? "t" : " ", (info & tBool) ? "Z" : " ",
50 (info & tInt32) ? "I" : " ", (info & tUint32) ? "U" : " ",
51 (info & tInt64) ? "L" : " ", (info & tUint64) ? "J" : " ",
52 (info & tNumber) ? "N" : " ", (info & tAny) ? "*" : " ");
53 }
54
55
56 const RepTypeUnion rMask = rBit | rWord32 | rWord64 | rFloat64 | rTagged;
57 const RepTypeUnion tMask =
58 tBool | tInt32 | tUint32 | tInt64 | tUint64 | tNumber | tAny;
59 const RepType rPtr = kPointerSize == 4 ? rWord32 : rWord64;
60
61 // Contains logic related to changing the representation of values for constants 17 // Contains logic related to changing the representation of values for constants
62 // and other nodes, as well as lowering Simplified->Machine operators. 18 // and other nodes, as well as lowering Simplified->Machine operators.
63 // Eagerly folds any representation changes for constants. 19 // Eagerly folds any representation changes for constants.
64 class RepresentationChanger { 20 class RepresentationChanger {
65 public: 21 public:
66 RepresentationChanger(JSGraph* jsgraph, SimplifiedOperatorBuilder* simplified, 22 RepresentationChanger(JSGraph* jsgraph, SimplifiedOperatorBuilder* simplified,
67 MachineOperatorBuilder* machine, Isolate* isolate) 23 MachineOperatorBuilder* machine, Isolate* isolate)
68 : jsgraph_(jsgraph), 24 : jsgraph_(jsgraph),
69 simplified_(simplified), 25 simplified_(simplified),
70 machine_(machine), 26 machine_(machine),
71 isolate_(isolate), 27 isolate_(isolate),
72 testing_type_errors_(false), 28 testing_type_errors_(false),
73 type_error_(false) {} 29 type_error_(false) {}
74 30
31 // TODO(titzer): should Word64 also be implicitly convertable to others?
32 static const MachineTypeUnion rWord =
33 kRepBit | kRepWord8 | kRepWord16 | kRepWord32;
75 34
76 Node* GetRepresentationFor(Node* node, RepTypeUnion output_type, 35 Node* GetRepresentationFor(Node* node, MachineTypeUnion output_type,
77 RepTypeUnion use_type) { 36 MachineTypeUnion use_type) {
78 if (!IsPowerOf2(output_type & rMask)) { 37 if (!IsPowerOf2(output_type & kRepMask)) {
79 // There should be only one output representation. 38 // There should be only one output representation.
80 return TypeError(node, output_type, use_type); 39 return TypeError(node, output_type, use_type);
81 } 40 }
82 if ((use_type & rMask) == (output_type & rMask)) { 41 if ((use_type & kRepMask) == (output_type & kRepMask)) {
83 // Representations are the same. That's a no-op. 42 // Representations are the same. That's a no-op.
84 return node; 43 return node;
85 } 44 }
86 if (use_type & rTagged) { 45 if ((use_type & rWord) && (output_type & rWord)) {
46 // Both are words less than or equal to 32-bits.
47 // Since loads of integers from memory implicitly sign or zero extend the
48 // value to the full machine word size and stores implicitly truncate,
49 // no representation change is necessary.
50 return node;
51 }
52 if (use_type & kRepTagged) {
87 return GetTaggedRepresentationFor(node, output_type); 53 return GetTaggedRepresentationFor(node, output_type);
88 } else if (use_type & rFloat64) { 54 } else if (use_type & kRepFloat64) {
89 return GetFloat64RepresentationFor(node, output_type); 55 return GetFloat64RepresentationFor(node, output_type);
90 } else if (use_type & rWord32) { 56 } else if (use_type & kRepBit) {
91 return GetWord32RepresentationFor(node, output_type, use_type & tUint32);
92 } else if (use_type & rBit) {
93 return GetBitRepresentationFor(node, output_type); 57 return GetBitRepresentationFor(node, output_type);
94 } else if (use_type & rWord64) { 58 } else if (use_type & rWord) {
59 return GetWord32RepresentationFor(node, output_type,
60 use_type & kTypeUint32);
61 } else if (use_type & kRepWord64) {
95 return GetWord64RepresentationFor(node, output_type); 62 return GetWord64RepresentationFor(node, output_type);
96 } else { 63 } else {
97 return node; 64 return node;
98 } 65 }
99 } 66 }
100 67
101 Node* GetTaggedRepresentationFor(Node* node, RepTypeUnion output_type) { 68 Node* GetTaggedRepresentationFor(Node* node, MachineTypeUnion output_type) {
102 // Eagerly fold representation changes for constants. 69 // Eagerly fold representation changes for constants.
103 switch (node->opcode()) { 70 switch (node->opcode()) {
104 case IrOpcode::kNumberConstant: 71 case IrOpcode::kNumberConstant:
105 case IrOpcode::kHeapConstant: 72 case IrOpcode::kHeapConstant:
106 return node; // No change necessary. 73 return node; // No change necessary.
107 case IrOpcode::kInt32Constant: 74 case IrOpcode::kInt32Constant:
108 if (output_type & tUint32) { 75 if (output_type & kTypeUint32) {
109 uint32_t value = ValueOf<uint32_t>(node->op()); 76 uint32_t value = ValueOf<uint32_t>(node->op());
110 return jsgraph()->Constant(static_cast<double>(value)); 77 return jsgraph()->Constant(static_cast<double>(value));
111 } else if (output_type & tInt32) { 78 } else if (output_type & kTypeInt32) {
112 int32_t value = ValueOf<int32_t>(node->op()); 79 int32_t value = ValueOf<int32_t>(node->op());
113 return jsgraph()->Constant(value); 80 return jsgraph()->Constant(value);
114 } else if (output_type & rBit) { 81 } else if (output_type & kRepBit) {
115 return ValueOf<int32_t>(node->op()) == 0 ? jsgraph()->FalseConstant() 82 return ValueOf<int32_t>(node->op()) == 0 ? jsgraph()->FalseConstant()
116 : jsgraph()->TrueConstant(); 83 : jsgraph()->TrueConstant();
117 } else { 84 } else {
118 return TypeError(node, output_type, rTagged); 85 return TypeError(node, output_type, kRepTagged);
119 } 86 }
120 case IrOpcode::kFloat64Constant: 87 case IrOpcode::kFloat64Constant:
121 return jsgraph()->Constant(ValueOf<double>(node->op())); 88 return jsgraph()->Constant(ValueOf<double>(node->op()));
122 default: 89 default:
123 break; 90 break;
124 } 91 }
125 // Select the correct X -> Tagged operator. 92 // Select the correct X -> Tagged operator.
126 Operator* op; 93 Operator* op;
127 if (output_type & rBit) { 94 if (output_type & kRepBit) {
128 op = simplified()->ChangeBitToBool(); 95 op = simplified()->ChangeBitToBool();
129 } else if (output_type & rWord32) { 96 } else if (output_type & rWord) {
130 if (output_type & tUint32) { 97 if (output_type & kTypeUint32) {
131 op = simplified()->ChangeUint32ToTagged(); 98 op = simplified()->ChangeUint32ToTagged();
132 } else if (output_type & tInt32) { 99 } else if (output_type & kTypeInt32) {
133 op = simplified()->ChangeInt32ToTagged(); 100 op = simplified()->ChangeInt32ToTagged();
134 } else { 101 } else {
135 return TypeError(node, output_type, rTagged); 102 return TypeError(node, output_type, kRepTagged);
136 } 103 }
137 } else if (output_type & rFloat64) { 104 } else if (output_type & kRepFloat64) {
138 op = simplified()->ChangeFloat64ToTagged(); 105 op = simplified()->ChangeFloat64ToTagged();
139 } else { 106 } else {
140 return TypeError(node, output_type, rTagged); 107 return TypeError(node, output_type, kRepTagged);
141 } 108 }
142 return jsgraph()->graph()->NewNode(op, node); 109 return jsgraph()->graph()->NewNode(op, node);
143 } 110 }
144 111
145 Node* GetFloat64RepresentationFor(Node* node, RepTypeUnion output_type) { 112 Node* GetFloat64RepresentationFor(Node* node, MachineTypeUnion output_type) {
146 // Eagerly fold representation changes for constants. 113 // Eagerly fold representation changes for constants.
147 switch (node->opcode()) { 114 switch (node->opcode()) {
148 case IrOpcode::kNumberConstant: 115 case IrOpcode::kNumberConstant:
149 return jsgraph()->Float64Constant(ValueOf<double>(node->op())); 116 return jsgraph()->Float64Constant(ValueOf<double>(node->op()));
150 case IrOpcode::kInt32Constant: 117 case IrOpcode::kInt32Constant:
151 if (output_type & tUint32) { 118 if (output_type & kTypeUint32) {
152 uint32_t value = ValueOf<uint32_t>(node->op()); 119 uint32_t value = ValueOf<uint32_t>(node->op());
153 return jsgraph()->Float64Constant(static_cast<double>(value)); 120 return jsgraph()->Float64Constant(static_cast<double>(value));
154 } else { 121 } else {
155 int32_t value = ValueOf<int32_t>(node->op()); 122 int32_t value = ValueOf<int32_t>(node->op());
156 return jsgraph()->Float64Constant(value); 123 return jsgraph()->Float64Constant(value);
157 } 124 }
158 case IrOpcode::kFloat64Constant: 125 case IrOpcode::kFloat64Constant:
159 return node; // No change necessary. 126 return node; // No change necessary.
160 default: 127 default:
161 break; 128 break;
162 } 129 }
163 // Select the correct X -> Float64 operator. 130 // Select the correct X -> Float64 operator.
164 Operator* op; 131 Operator* op;
165 if (output_type & rWord32) { 132 if (output_type & kRepBit) {
166 if (output_type & tUint32) { 133 return TypeError(node, output_type, kRepFloat64);
134 } else if (output_type & rWord) {
135 if (output_type & kTypeUint32) {
167 op = machine()->ChangeUint32ToFloat64(); 136 op = machine()->ChangeUint32ToFloat64();
168 } else { 137 } else {
169 op = machine()->ChangeInt32ToFloat64(); 138 op = machine()->ChangeInt32ToFloat64();
170 } 139 }
171 } else if (output_type & rTagged) { 140 } else if (output_type & kRepTagged) {
172 op = simplified()->ChangeTaggedToFloat64(); 141 op = simplified()->ChangeTaggedToFloat64();
173 } else { 142 } else {
174 return TypeError(node, output_type, rFloat64); 143 return TypeError(node, output_type, kRepFloat64);
175 } 144 }
176 return jsgraph()->graph()->NewNode(op, node); 145 return jsgraph()->graph()->NewNode(op, node);
177 } 146 }
178 147
179 Node* GetWord32RepresentationFor(Node* node, RepTypeUnion output_type, 148 Node* GetWord32RepresentationFor(Node* node, MachineTypeUnion output_type,
180 bool use_unsigned) { 149 bool use_unsigned) {
181 // Eagerly fold representation changes for constants. 150 // Eagerly fold representation changes for constants.
182 switch (node->opcode()) { 151 switch (node->opcode()) {
183 case IrOpcode::kInt32Constant: 152 case IrOpcode::kInt32Constant:
184 return node; // No change necessary. 153 return node; // No change necessary.
185 case IrOpcode::kNumberConstant: 154 case IrOpcode::kNumberConstant:
186 case IrOpcode::kFloat64Constant: { 155 case IrOpcode::kFloat64Constant: {
187 double value = ValueOf<double>(node->op()); 156 double value = ValueOf<double>(node->op());
188 if (value < 0) { 157 if (value < 0) {
189 DCHECK(IsInt32Double(value)); 158 DCHECK(IsInt32Double(value));
190 int32_t iv = static_cast<int32_t>(value); 159 int32_t iv = static_cast<int32_t>(value);
191 return jsgraph()->Int32Constant(iv); 160 return jsgraph()->Int32Constant(iv);
192 } else { 161 } else {
193 DCHECK(IsUint32Double(value)); 162 DCHECK(IsUint32Double(value));
194 int32_t iv = static_cast<int32_t>(static_cast<uint32_t>(value)); 163 int32_t iv = static_cast<int32_t>(static_cast<uint32_t>(value));
195 return jsgraph()->Int32Constant(iv); 164 return jsgraph()->Int32Constant(iv);
196 } 165 }
197 } 166 }
198 default: 167 default:
199 break; 168 break;
200 } 169 }
201 // Select the correct X -> Word32 operator. 170 // Select the correct X -> Word32 operator.
202 Operator* op = NULL; 171 Operator* op = NULL;
203 if (output_type & rFloat64) { 172 if (output_type & kRepFloat64) {
204 if (output_type & tUint32 || use_unsigned) { 173 if (output_type & kTypeUint32 || use_unsigned) {
205 op = machine()->ChangeFloat64ToUint32(); 174 op = machine()->ChangeFloat64ToUint32();
206 } else { 175 } else {
207 op = machine()->ChangeFloat64ToInt32(); 176 op = machine()->ChangeFloat64ToInt32();
208 } 177 }
209 } else if (output_type & rTagged) { 178 } else if (output_type & kRepTagged) {
210 if (output_type & tUint32 || use_unsigned) { 179 if (output_type & kTypeUint32 || use_unsigned) {
211 op = simplified()->ChangeTaggedToUint32(); 180 op = simplified()->ChangeTaggedToUint32();
212 } else { 181 } else {
213 op = simplified()->ChangeTaggedToInt32(); 182 op = simplified()->ChangeTaggedToInt32();
214 } 183 }
215 } else if (output_type & rBit) {
216 return node; // Sloppy comparison -> word32.
217 } else { 184 } else {
218 return TypeError(node, output_type, rWord32); 185 return TypeError(node, output_type, kRepWord32);
219 } 186 }
220 return jsgraph()->graph()->NewNode(op, node); 187 return jsgraph()->graph()->NewNode(op, node);
221 } 188 }
222 189
223 Node* GetBitRepresentationFor(Node* node, RepTypeUnion output_type) { 190 Node* GetBitRepresentationFor(Node* node, MachineTypeUnion output_type) {
224 // Eagerly fold representation changes for constants. 191 // Eagerly fold representation changes for constants.
225 switch (node->opcode()) { 192 switch (node->opcode()) {
226 case IrOpcode::kInt32Constant: { 193 case IrOpcode::kInt32Constant: {
227 int32_t value = ValueOf<int32_t>(node->op()); 194 int32_t value = ValueOf<int32_t>(node->op());
228 if (value == 0 || value == 1) return node; 195 if (value == 0 || value == 1) return node;
229 return jsgraph()->OneConstant(); // value != 0 196 return jsgraph()->OneConstant(); // value != 0
230 } 197 }
231 case IrOpcode::kHeapConstant: { 198 case IrOpcode::kHeapConstant: {
232 Handle<Object> handle = ValueOf<Handle<Object> >(node->op()); 199 Handle<Object> handle = ValueOf<Handle<Object> >(node->op());
233 DCHECK(*handle == isolate()->heap()->true_value() || 200 DCHECK(*handle == isolate()->heap()->true_value() ||
234 *handle == isolate()->heap()->false_value()); 201 *handle == isolate()->heap()->false_value());
235 return jsgraph()->Int32Constant( 202 return jsgraph()->Int32Constant(
236 *handle == isolate()->heap()->true_value() ? 1 : 0); 203 *handle == isolate()->heap()->true_value() ? 1 : 0);
237 } 204 }
238 default: 205 default:
239 break; 206 break;
240 } 207 }
241 // Select the correct X -> Bit operator. 208 // Select the correct X -> Bit operator.
242 Operator* op; 209 Operator* op;
243 if (output_type & rWord32) { 210 if (output_type & rWord) {
244 return node; // No change necessary. 211 return node; // No change necessary.
245 } else if (output_type & rWord64) { 212 } else if (output_type & kRepWord64) {
246 return node; // TODO(titzer): No change necessary, on 64-bit. 213 return node; // TODO(titzer): No change necessary, on 64-bit.
247 } else if (output_type & rTagged) { 214 } else if (output_type & kRepTagged) {
248 op = simplified()->ChangeBoolToBit(); 215 op = simplified()->ChangeBoolToBit();
249 } else { 216 } else {
250 return TypeError(node, output_type, rBit); 217 return TypeError(node, output_type, kRepBit);
251 } 218 }
252 return jsgraph()->graph()->NewNode(op, node); 219 return jsgraph()->graph()->NewNode(op, node);
253 } 220 }
254 221
255 Node* GetWord64RepresentationFor(Node* node, RepTypeUnion output_type) { 222 Node* GetWord64RepresentationFor(Node* node, MachineTypeUnion output_type) {
256 if (output_type & rBit) { 223 if (output_type & kRepBit) {
257 return node; // Sloppy comparison -> word64 224 return node; // Sloppy comparison -> word64
258 } 225 }
259 // Can't really convert Word64 to anything else. Purported to be internal. 226 // Can't really convert Word64 to anything else. Purported to be internal.
260 return TypeError(node, output_type, rWord64); 227 return TypeError(node, output_type, kRepWord64);
261 }
262
263 static RepType TypeForMachineType(MachineType rep) {
264 // TODO(titzer): merge MachineType and RepType.
265 switch (rep) {
266 case kMachineWord8:
267 return rWord32;
268 case kMachineWord16:
269 return rWord32;
270 case kMachineWord32:
271 return rWord32;
272 case kMachineWord64:
273 return rWord64;
274 case kMachineFloat64:
275 return rFloat64;
276 case kMachineTagged:
277 return rTagged;
278 default:
279 UNREACHABLE();
280 return static_cast<RepType>(0);
281 }
282 } 228 }
283 229
284 Operator* Int32OperatorFor(IrOpcode::Value opcode) { 230 Operator* Int32OperatorFor(IrOpcode::Value opcode) {
285 switch (opcode) { 231 switch (opcode) {
286 case IrOpcode::kNumberAdd: 232 case IrOpcode::kNumberAdd:
287 return machine()->Int32Add(); 233 return machine()->Int32Add();
288 case IrOpcode::kNumberSubtract: 234 case IrOpcode::kNumberSubtract:
289 return machine()->Int32Sub(); 235 return machine()->Int32Sub();
290 case IrOpcode::kNumberEqual: 236 case IrOpcode::kNumberEqual:
291 return machine()->Word32Equal(); 237 return machine()->Word32Equal();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 case IrOpcode::kNumberLessThan: 280 case IrOpcode::kNumberLessThan:
335 return machine()->Float64LessThan(); 281 return machine()->Float64LessThan();
336 case IrOpcode::kNumberLessThanOrEqual: 282 case IrOpcode::kNumberLessThanOrEqual:
337 return machine()->Float64LessThanOrEqual(); 283 return machine()->Float64LessThanOrEqual();
338 default: 284 default:
339 UNREACHABLE(); 285 UNREACHABLE();
340 return NULL; 286 return NULL;
341 } 287 }
342 } 288 }
343 289
344 RepType TypeForField(const FieldAccess& access) { 290 MachineType TypeForBasePointer(const FieldAccess& access) {
345 RepType tElement = static_cast<RepType>(0); // TODO(titzer) 291 return access.tag() != 0 ? kMachAnyTagged : kMachPtr;
346 RepType rElement = TypeForMachineType(access.representation);
347 return static_cast<RepType>(tElement | rElement);
348 } 292 }
349 293
350 RepType TypeForElement(const ElementAccess& access) { 294 MachineType TypeForBasePointer(const ElementAccess& access) {
351 RepType tElement = static_cast<RepType>(0); // TODO(titzer) 295 return access.tag() != 0 ? kMachAnyTagged : kMachPtr;
352 RepType rElement = TypeForMachineType(access.representation);
353 return static_cast<RepType>(tElement | rElement);
354 } 296 }
355 297
356 RepType TypeForBasePointer(const FieldAccess& access) { 298 MachineType TypeFromUpperBound(Type* type) {
357 if (access.tag() != 0) return static_cast<RepType>(tAny | rTagged);
358 return kPointerSize == 8 ? rWord64 : rWord32;
359 }
360
361 RepType TypeForBasePointer(const ElementAccess& access) {
362 if (access.tag() != 0) return static_cast<RepType>(tAny | rTagged);
363 return kPointerSize == 8 ? rWord64 : rWord32;
364 }
365
366 RepType TypeFromUpperBound(Type* type) {
367 if (type->Is(Type::None())) 299 if (type->Is(Type::None()))
368 return tAny; // TODO(titzer): should be an error 300 return kTypeAny; // TODO(titzer): should be an error
369 if (type->Is(Type::Signed32())) return tInt32; 301 if (type->Is(Type::Signed32())) return kTypeInt32;
370 if (type->Is(Type::Unsigned32())) return tUint32; 302 if (type->Is(Type::Unsigned32())) return kTypeUint32;
371 if (type->Is(Type::Number())) return tNumber; 303 if (type->Is(Type::Number())) return kTypeNumber;
372 if (type->Is(Type::Boolean())) return tBool; 304 if (type->Is(Type::Boolean())) return kTypeBool;
373 return tAny; 305 return kTypeAny;
374 } 306 }
375 307
376 private: 308 private:
377 JSGraph* jsgraph_; 309 JSGraph* jsgraph_;
378 SimplifiedOperatorBuilder* simplified_; 310 SimplifiedOperatorBuilder* simplified_;
379 MachineOperatorBuilder* machine_; 311 MachineOperatorBuilder* machine_;
380 Isolate* isolate_; 312 Isolate* isolate_;
381 313
382 friend class RepresentationChangerTester; // accesses the below fields. 314 friend class RepresentationChangerTester; // accesses the below fields.
383 315
384 bool testing_type_errors_; // If {true}, don't abort on a type error. 316 bool testing_type_errors_; // If {true}, don't abort on a type error.
385 bool type_error_; // Set when a type error is detected. 317 bool type_error_; // Set when a type error is detected.
386 318
387 Node* TypeError(Node* node, RepTypeUnion output_type, RepTypeUnion use) { 319 Node* TypeError(Node* node, MachineTypeUnion output_type,
320 MachineTypeUnion use) {
388 type_error_ = true; 321 type_error_ = true;
389 if (!testing_type_errors_) { 322 if (!testing_type_errors_) {
390 char buf1[REP_TYPE_STRLEN]; 323 OStringStream out_str;
391 char buf2[REP_TYPE_STRLEN]; 324 out_str << static_cast<MachineType>(output_type);
392 RenderRepTypeUnion(buf1, output_type); 325
393 RenderRepTypeUnion(buf2, use); 326 OStringStream use_str;
327 use_str << static_cast<MachineType>(use);
328
394 V8_Fatal(__FILE__, __LINE__, 329 V8_Fatal(__FILE__, __LINE__,
395 "RepresentationChangerError: node #%d:%s of rep" 330 "RepresentationChangerError: node #%d:%s of "
396 "%s cannot be changed to rep%s", 331 "%s cannot be changed to %s",
397 node->id(), node->op()->mnemonic(), buf1, buf2); 332 node->id(), node->op()->mnemonic(), out_str.c_str(),
333 use_str.c_str());
398 } 334 }
399 return node; 335 return node;
400 } 336 }
401 337
402 JSGraph* jsgraph() { return jsgraph_; } 338 JSGraph* jsgraph() { return jsgraph_; }
403 Isolate* isolate() { return isolate_; } 339 Isolate* isolate() { return isolate_; }
404 SimplifiedOperatorBuilder* simplified() { return simplified_; } 340 SimplifiedOperatorBuilder* simplified() { return simplified_; }
405 MachineOperatorBuilder* machine() { return machine_; } 341 MachineOperatorBuilder* machine() { return machine_; }
406 }; 342 };
407 } 343 }
408 } 344 }
409 } // namespace v8::internal::compiler 345 } // namespace v8::internal::compiler
410 346
411 #endif // V8_COMPILER_REPRESENTATION_CHANGE_H_ 347 #endif // V8_COMPILER_REPRESENTATION_CHANGE_H_
OLDNEW
« no previous file with comments | « src/compiler/machine-type.cc ('k') | src/compiler/simplified-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698