OLD | NEW |
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 = rBit | rWord8 | rWord16 | rWord32; |
75 | 33 |
76 Node* GetRepresentationFor(Node* node, RepTypeUnion output_type, | 34 Node* GetRepresentationFor(Node* node, MachineTypeUnion output_type, |
77 RepTypeUnion use_type) { | 35 MachineTypeUnion use_type) { |
78 if (!IsPowerOf2(output_type & rMask)) { | 36 if (!IsPowerOf2(output_type & rMask)) { |
79 // There should be only one output representation. | 37 // There should be only one output representation. |
80 return TypeError(node, output_type, use_type); | 38 return TypeError(node, output_type, use_type); |
81 } | 39 } |
82 if ((use_type & rMask) == (output_type & rMask)) { | 40 if ((use_type & rMask) == (output_type & rMask)) { |
83 // Representations are the same. That's a no-op. | 41 // Representations are the same. That's a no-op. |
84 return node; | 42 return node; |
85 } | 43 } |
| 44 if ((use_type & rWord) && (output_type & rWord)) { |
| 45 // Both are words less than or equal to 32-bits. |
| 46 // Since loads of integers from memory implicitly sign or zero extend the |
| 47 // value to the full machine word size and stores implicitly truncate, |
| 48 // no representation change is necessary. |
| 49 return node; |
| 50 } |
86 if (use_type & rTagged) { | 51 if (use_type & rTagged) { |
87 return GetTaggedRepresentationFor(node, output_type); | 52 return GetTaggedRepresentationFor(node, output_type); |
88 } else if (use_type & rFloat64) { | 53 } else if (use_type & rFloat64) { |
89 return GetFloat64RepresentationFor(node, output_type); | 54 return GetFloat64RepresentationFor(node, output_type); |
90 } else if (use_type & rWord32) { | |
91 return GetWord32RepresentationFor(node, output_type, use_type & tUint32); | |
92 } else if (use_type & rBit) { | 55 } else if (use_type & rBit) { |
93 return GetBitRepresentationFor(node, output_type); | 56 return GetBitRepresentationFor(node, output_type); |
| 57 } else if (use_type & rWord) { |
| 58 return GetWord32RepresentationFor(node, output_type, use_type & tUint32); |
94 } else if (use_type & rWord64) { | 59 } else if (use_type & rWord64) { |
95 return GetWord64RepresentationFor(node, output_type); | 60 return GetWord64RepresentationFor(node, output_type); |
96 } else { | 61 } else { |
97 return node; | 62 return node; |
98 } | 63 } |
99 } | 64 } |
100 | 65 |
101 Node* GetTaggedRepresentationFor(Node* node, RepTypeUnion output_type) { | 66 Node* GetTaggedRepresentationFor(Node* node, MachineTypeUnion output_type) { |
102 // Eagerly fold representation changes for constants. | 67 // Eagerly fold representation changes for constants. |
103 switch (node->opcode()) { | 68 switch (node->opcode()) { |
104 case IrOpcode::kNumberConstant: | 69 case IrOpcode::kNumberConstant: |
105 case IrOpcode::kHeapConstant: | 70 case IrOpcode::kHeapConstant: |
106 return node; // No change necessary. | 71 return node; // No change necessary. |
107 case IrOpcode::kInt32Constant: | 72 case IrOpcode::kInt32Constant: |
108 if (output_type & tUint32) { | 73 if (output_type & tUint32) { |
109 uint32_t value = ValueOf<uint32_t>(node->op()); | 74 uint32_t value = ValueOf<uint32_t>(node->op()); |
110 return jsgraph()->Constant(static_cast<double>(value)); | 75 return jsgraph()->Constant(static_cast<double>(value)); |
111 } else if (output_type & tInt32) { | 76 } else if (output_type & tInt32) { |
112 int32_t value = ValueOf<int32_t>(node->op()); | 77 int32_t value = ValueOf<int32_t>(node->op()); |
113 return jsgraph()->Constant(value); | 78 return jsgraph()->Constant(value); |
114 } else if (output_type & rBit) { | 79 } else if (output_type & rBit) { |
115 return ValueOf<int32_t>(node->op()) == 0 ? jsgraph()->FalseConstant() | 80 return ValueOf<int32_t>(node->op()) == 0 ? jsgraph()->FalseConstant() |
116 : jsgraph()->TrueConstant(); | 81 : jsgraph()->TrueConstant(); |
117 } else { | 82 } else { |
118 return TypeError(node, output_type, rTagged); | 83 return TypeError(node, output_type, rTagged); |
119 } | 84 } |
120 case IrOpcode::kFloat64Constant: | 85 case IrOpcode::kFloat64Constant: |
121 return jsgraph()->Constant(ValueOf<double>(node->op())); | 86 return jsgraph()->Constant(ValueOf<double>(node->op())); |
122 default: | 87 default: |
123 break; | 88 break; |
124 } | 89 } |
125 // Select the correct X -> Tagged operator. | 90 // Select the correct X -> Tagged operator. |
126 Operator* op; | 91 Operator* op; |
127 if (output_type & rBit) { | 92 if (output_type & rBit) { |
128 op = simplified()->ChangeBitToBool(); | 93 op = simplified()->ChangeBitToBool(); |
129 } else if (output_type & rWord32) { | 94 } else if (output_type & rWord) { |
130 if (output_type & tUint32) { | 95 if (output_type & tUint32) { |
131 op = simplified()->ChangeUint32ToTagged(); | 96 op = simplified()->ChangeUint32ToTagged(); |
132 } else if (output_type & tInt32) { | 97 } else if (output_type & tInt32) { |
133 op = simplified()->ChangeInt32ToTagged(); | 98 op = simplified()->ChangeInt32ToTagged(); |
134 } else { | 99 } else { |
135 return TypeError(node, output_type, rTagged); | 100 return TypeError(node, output_type, rTagged); |
136 } | 101 } |
137 } else if (output_type & rFloat64) { | 102 } else if (output_type & rFloat64) { |
138 op = simplified()->ChangeFloat64ToTagged(); | 103 op = simplified()->ChangeFloat64ToTagged(); |
139 } else { | 104 } else { |
140 return TypeError(node, output_type, rTagged); | 105 return TypeError(node, output_type, rTagged); |
141 } | 106 } |
142 return jsgraph()->graph()->NewNode(op, node); | 107 return jsgraph()->graph()->NewNode(op, node); |
143 } | 108 } |
144 | 109 |
145 Node* GetFloat64RepresentationFor(Node* node, RepTypeUnion output_type) { | 110 Node* GetFloat64RepresentationFor(Node* node, MachineTypeUnion output_type) { |
146 // Eagerly fold representation changes for constants. | 111 // Eagerly fold representation changes for constants. |
147 switch (node->opcode()) { | 112 switch (node->opcode()) { |
148 case IrOpcode::kNumberConstant: | 113 case IrOpcode::kNumberConstant: |
149 return jsgraph()->Float64Constant(ValueOf<double>(node->op())); | 114 return jsgraph()->Float64Constant(ValueOf<double>(node->op())); |
150 case IrOpcode::kInt32Constant: | 115 case IrOpcode::kInt32Constant: |
151 if (output_type & tUint32) { | 116 if (output_type & tUint32) { |
152 uint32_t value = ValueOf<uint32_t>(node->op()); | 117 uint32_t value = ValueOf<uint32_t>(node->op()); |
153 return jsgraph()->Float64Constant(static_cast<double>(value)); | 118 return jsgraph()->Float64Constant(static_cast<double>(value)); |
154 } else { | 119 } else { |
155 int32_t value = ValueOf<int32_t>(node->op()); | 120 int32_t value = ValueOf<int32_t>(node->op()); |
156 return jsgraph()->Float64Constant(value); | 121 return jsgraph()->Float64Constant(value); |
157 } | 122 } |
158 case IrOpcode::kFloat64Constant: | 123 case IrOpcode::kFloat64Constant: |
159 return node; // No change necessary. | 124 return node; // No change necessary. |
160 default: | 125 default: |
161 break; | 126 break; |
162 } | 127 } |
163 // Select the correct X -> Float64 operator. | 128 // Select the correct X -> Float64 operator. |
164 Operator* op; | 129 Operator* op; |
165 if (output_type & rWord32) { | 130 if (output_type & rBit) { |
| 131 return TypeError(node, output_type, rFloat64); |
| 132 } else if (output_type & rWord) { |
166 if (output_type & tUint32) { | 133 if (output_type & tUint32) { |
167 op = machine()->ChangeUint32ToFloat64(); | 134 op = machine()->ChangeUint32ToFloat64(); |
168 } else { | 135 } else { |
169 op = machine()->ChangeInt32ToFloat64(); | 136 op = machine()->ChangeInt32ToFloat64(); |
170 } | 137 } |
171 } else if (output_type & rTagged) { | 138 } else if (output_type & rTagged) { |
172 op = simplified()->ChangeTaggedToFloat64(); | 139 op = simplified()->ChangeTaggedToFloat64(); |
173 } else { | 140 } else { |
174 return TypeError(node, output_type, rFloat64); | 141 return TypeError(node, output_type, rFloat64); |
175 } | 142 } |
176 return jsgraph()->graph()->NewNode(op, node); | 143 return jsgraph()->graph()->NewNode(op, node); |
177 } | 144 } |
178 | 145 |
179 Node* GetWord32RepresentationFor(Node* node, RepTypeUnion output_type, | 146 Node* GetWord32RepresentationFor(Node* node, MachineTypeUnion output_type, |
180 bool use_unsigned) { | 147 bool use_unsigned) { |
181 // Eagerly fold representation changes for constants. | 148 // Eagerly fold representation changes for constants. |
182 switch (node->opcode()) { | 149 switch (node->opcode()) { |
183 case IrOpcode::kInt32Constant: | 150 case IrOpcode::kInt32Constant: |
184 return node; // No change necessary. | 151 return node; // No change necessary. |
185 case IrOpcode::kNumberConstant: | 152 case IrOpcode::kNumberConstant: |
186 case IrOpcode::kFloat64Constant: { | 153 case IrOpcode::kFloat64Constant: { |
187 double value = ValueOf<double>(node->op()); | 154 double value = ValueOf<double>(node->op()); |
188 if (value < 0) { | 155 if (value < 0) { |
189 DCHECK(IsInt32Double(value)); | 156 DCHECK(IsInt32Double(value)); |
(...skipping 15 matching lines...) Expand all Loading... |
205 op = machine()->ChangeFloat64ToUint32(); | 172 op = machine()->ChangeFloat64ToUint32(); |
206 } else { | 173 } else { |
207 op = machine()->ChangeFloat64ToInt32(); | 174 op = machine()->ChangeFloat64ToInt32(); |
208 } | 175 } |
209 } else if (output_type & rTagged) { | 176 } else if (output_type & rTagged) { |
210 if (output_type & tUint32 || use_unsigned) { | 177 if (output_type & tUint32 || use_unsigned) { |
211 op = simplified()->ChangeTaggedToUint32(); | 178 op = simplified()->ChangeTaggedToUint32(); |
212 } else { | 179 } else { |
213 op = simplified()->ChangeTaggedToInt32(); | 180 op = simplified()->ChangeTaggedToInt32(); |
214 } | 181 } |
215 } else if (output_type & rBit) { | |
216 return node; // Sloppy comparison -> word32. | |
217 } else { | 182 } else { |
218 return TypeError(node, output_type, rWord32); | 183 return TypeError(node, output_type, rWord32); |
219 } | 184 } |
220 return jsgraph()->graph()->NewNode(op, node); | 185 return jsgraph()->graph()->NewNode(op, node); |
221 } | 186 } |
222 | 187 |
223 Node* GetBitRepresentationFor(Node* node, RepTypeUnion output_type) { | 188 Node* GetBitRepresentationFor(Node* node, MachineTypeUnion output_type) { |
224 // Eagerly fold representation changes for constants. | 189 // Eagerly fold representation changes for constants. |
225 switch (node->opcode()) { | 190 switch (node->opcode()) { |
226 case IrOpcode::kInt32Constant: { | 191 case IrOpcode::kInt32Constant: { |
227 int32_t value = ValueOf<int32_t>(node->op()); | 192 int32_t value = ValueOf<int32_t>(node->op()); |
228 if (value == 0 || value == 1) return node; | 193 if (value == 0 || value == 1) return node; |
229 return jsgraph()->OneConstant(); // value != 0 | 194 return jsgraph()->OneConstant(); // value != 0 |
230 } | 195 } |
231 case IrOpcode::kHeapConstant: { | 196 case IrOpcode::kHeapConstant: { |
232 Handle<Object> handle = ValueOf<Handle<Object> >(node->op()); | 197 Handle<Object> handle = ValueOf<Handle<Object> >(node->op()); |
233 DCHECK(*handle == isolate()->heap()->true_value() || | 198 DCHECK(*handle == isolate()->heap()->true_value() || |
234 *handle == isolate()->heap()->false_value()); | 199 *handle == isolate()->heap()->false_value()); |
235 return jsgraph()->Int32Constant( | 200 return jsgraph()->Int32Constant( |
236 *handle == isolate()->heap()->true_value() ? 1 : 0); | 201 *handle == isolate()->heap()->true_value() ? 1 : 0); |
237 } | 202 } |
238 default: | 203 default: |
239 break; | 204 break; |
240 } | 205 } |
241 // Select the correct X -> Bit operator. | 206 // Select the correct X -> Bit operator. |
242 Operator* op; | 207 Operator* op; |
243 if (output_type & rWord32) { | 208 if (output_type & rWord) { |
244 return node; // No change necessary. | 209 return node; // No change necessary. |
245 } else if (output_type & rWord64) { | 210 } else if (output_type & rWord64) { |
246 return node; // TODO(titzer): No change necessary, on 64-bit. | 211 return node; // TODO(titzer): No change necessary, on 64-bit. |
247 } else if (output_type & rTagged) { | 212 } else if (output_type & rTagged) { |
248 op = simplified()->ChangeBoolToBit(); | 213 op = simplified()->ChangeBoolToBit(); |
249 } else { | 214 } else { |
250 return TypeError(node, output_type, rBit); | 215 return TypeError(node, output_type, rBit); |
251 } | 216 } |
252 return jsgraph()->graph()->NewNode(op, node); | 217 return jsgraph()->graph()->NewNode(op, node); |
253 } | 218 } |
254 | 219 |
255 Node* GetWord64RepresentationFor(Node* node, RepTypeUnion output_type) { | 220 Node* GetWord64RepresentationFor(Node* node, MachineTypeUnion output_type) { |
256 if (output_type & rBit) { | 221 if (output_type & rBit) { |
257 return node; // Sloppy comparison -> word64 | 222 return node; // Sloppy comparison -> word64 |
258 } | 223 } |
259 // Can't really convert Word64 to anything else. Purported to be internal. | 224 // Can't really convert Word64 to anything else. Purported to be internal. |
260 return TypeError(node, output_type, rWord64); | 225 return TypeError(node, output_type, rWord64); |
261 } | 226 } |
262 | 227 |
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 } | |
283 | |
284 Operator* Int32OperatorFor(IrOpcode::Value opcode) { | 228 Operator* Int32OperatorFor(IrOpcode::Value opcode) { |
285 switch (opcode) { | 229 switch (opcode) { |
286 case IrOpcode::kNumberAdd: | 230 case IrOpcode::kNumberAdd: |
287 return machine()->Int32Add(); | 231 return machine()->Int32Add(); |
288 case IrOpcode::kNumberSubtract: | 232 case IrOpcode::kNumberSubtract: |
289 return machine()->Int32Sub(); | 233 return machine()->Int32Sub(); |
290 case IrOpcode::kNumberEqual: | 234 case IrOpcode::kNumberEqual: |
291 return machine()->Word32Equal(); | 235 return machine()->Word32Equal(); |
292 case IrOpcode::kNumberLessThan: | 236 case IrOpcode::kNumberLessThan: |
293 return machine()->Int32LessThan(); | 237 return machine()->Int32LessThan(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 case IrOpcode::kNumberLessThan: | 278 case IrOpcode::kNumberLessThan: |
335 return machine()->Float64LessThan(); | 279 return machine()->Float64LessThan(); |
336 case IrOpcode::kNumberLessThanOrEqual: | 280 case IrOpcode::kNumberLessThanOrEqual: |
337 return machine()->Float64LessThanOrEqual(); | 281 return machine()->Float64LessThanOrEqual(); |
338 default: | 282 default: |
339 UNREACHABLE(); | 283 UNREACHABLE(); |
340 return NULL; | 284 return NULL; |
341 } | 285 } |
342 } | 286 } |
343 | 287 |
344 RepType TypeForField(const FieldAccess& access) { | 288 MachineType TypeForBasePointer(const FieldAccess& access) { |
345 RepType tElement = static_cast<RepType>(0); // TODO(titzer) | 289 return access.tag() != 0 ? mAnyTagged : mPtr; |
346 RepType rElement = TypeForMachineType(access.representation); | |
347 return static_cast<RepType>(tElement | rElement); | |
348 } | 290 } |
349 | 291 |
350 RepType TypeForElement(const ElementAccess& access) { | 292 MachineType TypeForBasePointer(const ElementAccess& access) { |
351 RepType tElement = static_cast<RepType>(0); // TODO(titzer) | 293 return access.tag() != 0 ? mAnyTagged : mPtr; |
352 RepType rElement = TypeForMachineType(access.representation); | |
353 return static_cast<RepType>(tElement | rElement); | |
354 } | 294 } |
355 | 295 |
356 RepType TypeForBasePointer(const FieldAccess& access) { | 296 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())) | 297 if (type->Is(Type::None())) |
368 return tAny; // TODO(titzer): should be an error | 298 return tAny; // TODO(titzer): should be an error |
369 if (type->Is(Type::Signed32())) return tInt32; | 299 if (type->Is(Type::Signed32())) return tInt32; |
370 if (type->Is(Type::Unsigned32())) return tUint32; | 300 if (type->Is(Type::Unsigned32())) return tUint32; |
371 if (type->Is(Type::Number())) return tNumber; | 301 if (type->Is(Type::Number())) return tNumber; |
372 if (type->Is(Type::Boolean())) return tBool; | 302 if (type->Is(Type::Boolean())) return tBool; |
373 return tAny; | 303 return tAny; |
374 } | 304 } |
375 | 305 |
376 private: | 306 private: |
377 JSGraph* jsgraph_; | 307 JSGraph* jsgraph_; |
378 SimplifiedOperatorBuilder* simplified_; | 308 SimplifiedOperatorBuilder* simplified_; |
379 MachineOperatorBuilder* machine_; | 309 MachineOperatorBuilder* machine_; |
380 Isolate* isolate_; | 310 Isolate* isolate_; |
381 | 311 |
382 friend class RepresentationChangerTester; // accesses the below fields. | 312 friend class RepresentationChangerTester; // accesses the below fields. |
383 | 313 |
384 bool testing_type_errors_; // If {true}, don't abort on a type error. | 314 bool testing_type_errors_; // If {true}, don't abort on a type error. |
385 bool type_error_; // Set when a type error is detected. | 315 bool type_error_; // Set when a type error is detected. |
386 | 316 |
387 Node* TypeError(Node* node, RepTypeUnion output_type, RepTypeUnion use) { | 317 Node* TypeError(Node* node, MachineTypeUnion output_type, |
| 318 MachineTypeUnion use) { |
388 type_error_ = true; | 319 type_error_ = true; |
389 if (!testing_type_errors_) { | 320 if (!testing_type_errors_) { |
390 char buf1[REP_TYPE_STRLEN]; | 321 OStringStream out_str; |
391 char buf2[REP_TYPE_STRLEN]; | 322 PrintMachineTypeUnionTo(out_str, output_type); |
392 RenderRepTypeUnion(buf1, output_type); | 323 |
393 RenderRepTypeUnion(buf2, use); | 324 OStringStream use_str; |
| 325 PrintMachineTypeUnionTo(use_str, use); |
| 326 |
394 V8_Fatal(__FILE__, __LINE__, | 327 V8_Fatal(__FILE__, __LINE__, |
395 "RepresentationChangerError: node #%d:%s of rep" | 328 "RepresentationChangerError: node #%d:%s of " |
396 "%s cannot be changed to rep%s", | 329 "%s cannot be changed to %s", |
397 node->id(), node->op()->mnemonic(), buf1, buf2); | 330 node->id(), node->op()->mnemonic(), out_str.c_str(), |
| 331 use_str.c_str()); |
398 } | 332 } |
399 return node; | 333 return node; |
400 } | 334 } |
401 | 335 |
402 JSGraph* jsgraph() { return jsgraph_; } | 336 JSGraph* jsgraph() { return jsgraph_; } |
403 Isolate* isolate() { return isolate_; } | 337 Isolate* isolate() { return isolate_; } |
404 SimplifiedOperatorBuilder* simplified() { return simplified_; } | 338 SimplifiedOperatorBuilder* simplified() { return simplified_; } |
405 MachineOperatorBuilder* machine() { return machine_; } | 339 MachineOperatorBuilder* machine() { return machine_; } |
406 }; | 340 }; |
407 } | 341 } |
408 } | 342 } |
409 } // namespace v8::internal::compiler | 343 } // namespace v8::internal::compiler |
410 | 344 |
411 #endif // V8_COMPILER_REPRESENTATION_CHANGE_H_ | 345 #endif // V8_COMPILER_REPRESENTATION_CHANGE_H_ |
OLD | NEW |