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/base/bits.h" |
8 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
9 #include "src/compiler/machine-operator.h" | 10 #include "src/compiler/machine-operator.h" |
10 #include "src/compiler/node-properties-inl.h" | 11 #include "src/compiler/node-properties-inl.h" |
11 #include "src/compiler/simplified-operator.h" | 12 #include "src/compiler/simplified-operator.h" |
12 | 13 |
13 namespace v8 { | 14 namespace v8 { |
14 namespace internal { | 15 namespace internal { |
15 namespace compiler { | 16 namespace compiler { |
16 | 17 |
17 // Contains logic related to changing the representation of values for constants | 18 // Contains logic related to changing the representation of values for constants |
18 // and other nodes, as well as lowering Simplified->Machine operators. | 19 // and other nodes, as well as lowering Simplified->Machine operators. |
19 // Eagerly folds any representation changes for constants. | 20 // Eagerly folds any representation changes for constants. |
20 class RepresentationChanger { | 21 class RepresentationChanger { |
21 public: | 22 public: |
22 RepresentationChanger(JSGraph* jsgraph, SimplifiedOperatorBuilder* simplified, | 23 RepresentationChanger(JSGraph* jsgraph, SimplifiedOperatorBuilder* simplified, |
23 MachineOperatorBuilder* machine, Isolate* isolate) | 24 MachineOperatorBuilder* machine, Isolate* isolate) |
24 : jsgraph_(jsgraph), | 25 : jsgraph_(jsgraph), |
25 simplified_(simplified), | 26 simplified_(simplified), |
26 machine_(machine), | 27 machine_(machine), |
27 isolate_(isolate), | 28 isolate_(isolate), |
28 testing_type_errors_(false), | 29 testing_type_errors_(false), |
29 type_error_(false) {} | 30 type_error_(false) {} |
30 | 31 |
31 // TODO(titzer): should Word64 also be implicitly convertable to others? | 32 // TODO(titzer): should Word64 also be implicitly convertable to others? |
32 static const MachineTypeUnion rWord = | 33 static const MachineTypeUnion rWord = |
33 kRepBit | kRepWord8 | kRepWord16 | kRepWord32; | 34 kRepBit | kRepWord8 | kRepWord16 | kRepWord32; |
34 | 35 |
35 Node* GetRepresentationFor(Node* node, MachineTypeUnion output_type, | 36 Node* GetRepresentationFor(Node* node, MachineTypeUnion output_type, |
36 MachineTypeUnion use_type) { | 37 MachineTypeUnion use_type) { |
37 if (!IsPowerOf2(output_type & kRepMask)) { | 38 if (!base::bits::IsPowerOfTwo32(output_type & kRepMask)) { |
38 // There should be only one output representation. | 39 // There should be only one output representation. |
39 return TypeError(node, output_type, use_type); | 40 return TypeError(node, output_type, use_type); |
40 } | 41 } |
41 if ((use_type & kRepMask) == (output_type & kRepMask)) { | 42 if ((use_type & kRepMask) == (output_type & kRepMask)) { |
42 // Representations are the same. That's a no-op. | 43 // Representations are the same. That's a no-op. |
43 return node; | 44 return node; |
44 } | 45 } |
45 if ((use_type & rWord) && (output_type & rWord)) { | 46 if ((use_type & rWord) && (output_type & rWord)) { |
46 // Both are words less than or equal to 32-bits. | 47 // Both are words less than or equal to 32-bits. |
47 // Since loads of integers from memory implicitly sign or zero extend the | 48 // Since loads of integers from memory implicitly sign or zero extend the |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 JSGraph* jsgraph() { return jsgraph_; } | 339 JSGraph* jsgraph() { return jsgraph_; } |
339 Isolate* isolate() { return isolate_; } | 340 Isolate* isolate() { return isolate_; } |
340 SimplifiedOperatorBuilder* simplified() { return simplified_; } | 341 SimplifiedOperatorBuilder* simplified() { return simplified_; } |
341 MachineOperatorBuilder* machine() { return machine_; } | 342 MachineOperatorBuilder* machine() { return machine_; } |
342 }; | 343 }; |
343 } | 344 } |
344 } | 345 } |
345 } // namespace v8::internal::compiler | 346 } // namespace v8::internal::compiler |
346 | 347 |
347 #endif // V8_COMPILER_REPRESENTATION_CHANGE_H_ | 348 #endif // V8_COMPILER_REPRESENTATION_CHANGE_H_ |
OLD | NEW |