| 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_MACHINE_TYPE_H_ | 5 #ifndef V8_COMPILER_MACHINE_TYPE_H_ |
| 6 #define V8_COMPILER_MACHINE_TYPE_H_ | 6 #define V8_COMPILER_MACHINE_TYPE_H_ |
| 7 | 7 |
| 8 #include "src/base/bits.h" |
| 8 #include "src/globals.h" | 9 #include "src/globals.h" |
| 9 | 10 |
| 10 namespace v8 { | 11 namespace v8 { |
| 11 namespace internal { | 12 namespace internal { |
| 12 | 13 |
| 13 class OStream; | 14 class OStream; |
| 14 | 15 |
| 15 namespace compiler { | 16 namespace compiler { |
| 16 | 17 |
| 17 // Machine-level types and representations. | 18 // Machine-level types and representations. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 76 |
| 76 // Gets only the type of the given type. | 77 // Gets only the type of the given type. |
| 77 inline MachineType TypeOf(MachineType machine_type) { | 78 inline MachineType TypeOf(MachineType machine_type) { |
| 78 int result = machine_type & kTypeMask; | 79 int result = machine_type & kTypeMask; |
| 79 return static_cast<MachineType>(result); | 80 return static_cast<MachineType>(result); |
| 80 } | 81 } |
| 81 | 82 |
| 82 // Gets only the representation of the given type. | 83 // Gets only the representation of the given type. |
| 83 inline MachineType RepresentationOf(MachineType machine_type) { | 84 inline MachineType RepresentationOf(MachineType machine_type) { |
| 84 int result = machine_type & kRepMask; | 85 int result = machine_type & kRepMask; |
| 85 CHECK(IsPowerOf2(result)); | 86 CHECK(base::bits::IsPowerOfTwo32(result)); |
| 86 return static_cast<MachineType>(result); | 87 return static_cast<MachineType>(result); |
| 87 } | 88 } |
| 88 | 89 |
| 89 // Gets the element size in bytes of the machine type. | 90 // Gets the element size in bytes of the machine type. |
| 90 inline int ElementSizeOf(MachineType machine_type) { | 91 inline int ElementSizeOf(MachineType machine_type) { |
| 91 switch (RepresentationOf(machine_type)) { | 92 switch (RepresentationOf(machine_type)) { |
| 92 case kRepBit: | 93 case kRepBit: |
| 93 case kRepWord8: | 94 case kRepWord8: |
| 94 return 1; | 95 return 1; |
| 95 case kRepWord16: | 96 case kRepWord16: |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 protected: | 133 protected: |
| 133 uint8_t return_count_; | 134 uint8_t return_count_; |
| 134 uint16_t param_count_; | 135 uint16_t param_count_; |
| 135 MachineType* reps_; | 136 MachineType* reps_; |
| 136 }; | 137 }; |
| 137 } // namespace compiler | 138 } // namespace compiler |
| 138 } // namespace internal | 139 } // namespace internal |
| 139 } // namespace v8 | 140 } // namespace v8 |
| 140 | 141 |
| 141 #endif // V8_COMPILER_MACHINE_TYPE_H_ | 142 #endif // V8_COMPILER_MACHINE_TYPE_H_ |
| OLD | NEW |