| 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 #include "src/compiler/operator.h" | 5 #include "src/compiler/operator.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 namespace v8 { | 9 namespace v8 { |
| 10 namespace internal { | 10 namespace internal { |
| 11 namespace compiler { | 11 namespace compiler { |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 template <typename N> | 15 template <typename N> |
| 16 V8_INLINE N CheckRange(size_t val) { | 16 V8_INLINE N CheckRange(size_t val) { |
| 17 CHECK_LE(val, std::numeric_limits<N>::max()); | 17 CHECK_LE(val, std::numeric_limits<N>::max()); |
| 18 return static_cast<N>(val); | 18 return static_cast<N>(val); |
| 19 } | 19 } |
| 20 | 20 |
| 21 } // namespace | 21 } // namespace |
| 22 | 22 |
| 23 | 23 |
| 24 // static | 24 // static |
| 25 STATIC_CONST_MEMBER_DEFINITION const size_t Operator::kMaxControlOutputCount; | 25 STATIC_CONST_MEMBER_DEFINITION const size_t Operator::kMaxControlOutputCount; |
| 26 | 26 |
| 27 | |
| 28 Operator::Operator(Opcode opcode, Properties properties, const char* mnemonic, | 27 Operator::Operator(Opcode opcode, Properties properties, const char* mnemonic, |
| 29 size_t value_in, size_t effect_in, size_t control_in, | 28 size_t value_in, size_t effect_in, size_t control_in, |
| 30 size_t value_out, size_t effect_out, size_t control_out) | 29 size_t value_out, size_t effect_out, size_t control_out) |
| 31 : opcode_(opcode), | 30 : opcode_(opcode), |
| 32 properties_(properties), | 31 properties_(properties), |
| 33 mnemonic_(mnemonic), | 32 mnemonic_(mnemonic), |
| 34 value_in_(CheckRange<uint32_t>(value_in)), | 33 value_in_(CheckRange<uint32_t>(value_in)), |
| 35 effect_in_(CheckRange<uint16_t>(effect_in)), | 34 effect_in_(CheckRange<uint16_t>(effect_in)), |
| 36 control_in_(CheckRange<uint16_t>(control_in)), | 35 control_in_(CheckRange<uint16_t>(control_in)), |
| 37 value_out_(CheckRange<uint16_t>(value_out)), | 36 value_out_(CheckRange<uint16_t>(value_out)), |
| 38 effect_out_(CheckRange<uint8_t>(effect_out)), | 37 effect_out_(CheckRange<uint8_t>(effect_out)), |
| 39 control_out_(CheckRange<uint16_t>(control_out)) {} | 38 control_out_(CheckRange<uint32_t>(control_out)) {} |
| 40 | |
| 41 | 39 |
| 42 std::ostream& operator<<(std::ostream& os, const Operator& op) { | 40 std::ostream& operator<<(std::ostream& os, const Operator& op) { |
| 43 op.PrintTo(os); | 41 op.PrintTo(os); |
| 44 return os; | 42 return os; |
| 45 } | 43 } |
| 46 | 44 |
| 47 void Operator::PrintToImpl(std::ostream& os, PrintVerbosity verbose) const { | 45 void Operator::PrintToImpl(std::ostream& os, PrintVerbosity verbose) const { |
| 48 os << mnemonic(); | 46 os << mnemonic(); |
| 49 } | 47 } |
| 50 | 48 |
| 51 void Operator::PrintPropsTo(std::ostream& os) const { | 49 void Operator::PrintPropsTo(std::ostream& os) const { |
| 52 std::string separator = ""; | 50 std::string separator = ""; |
| 53 | 51 |
| 54 #define PRINT_PROP_IF_SET(name) \ | 52 #define PRINT_PROP_IF_SET(name) \ |
| 55 if (HasProperty(Operator::k##name)) { \ | 53 if (HasProperty(Operator::k##name)) { \ |
| 56 os << separator; \ | 54 os << separator; \ |
| 57 os << #name; \ | 55 os << #name; \ |
| 58 separator = ", "; \ | 56 separator = ", "; \ |
| 59 } | 57 } |
| 60 OPERATOR_PROPERTY_LIST(PRINT_PROP_IF_SET) | 58 OPERATOR_PROPERTY_LIST(PRINT_PROP_IF_SET) |
| 61 #undef PRINT_PROP_IF_SET | 59 #undef PRINT_PROP_IF_SET |
| 62 } | 60 } |
| 63 | 61 |
| 64 } // namespace compiler | 62 } // namespace compiler |
| 65 } // namespace internal | 63 } // namespace internal |
| 66 } // namespace v8 | 64 } // namespace v8 |
| OLD | NEW |