OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 5801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5812 if (V8_LIKELY(I::IsValidSmi(i))) { | 5812 if (V8_LIKELY(I::IsValidSmi(i))) { |
5813 *value_ = I::IntToSmi(i); | 5813 *value_ = I::IntToSmi(i); |
5814 return; | 5814 return; |
5815 } | 5815 } |
5816 Set(Integer::New(i, GetIsolate())); | 5816 Set(Integer::New(i, GetIsolate())); |
5817 } | 5817 } |
5818 | 5818 |
5819 template<typename T> | 5819 template<typename T> |
5820 void ReturnValue<T>::Set(uint32_t i) { | 5820 void ReturnValue<T>::Set(uint32_t i) { |
5821 TYPE_CHECK(T, Integer); | 5821 TYPE_CHECK(T, Integer); |
5822 typedef internal::Internals I; | |
5823 // Can't simply use INT32_MAX here for whatever reason. | 5822 // Can't simply use INT32_MAX here for whatever reason. |
5824 bool fits_into_int32_t = (i & (1U << 31)) == 0; | 5823 bool fits_into_int32_t = (i & (1U << 31)) == 0; |
5825 if (V8_LIKELY(fits_into_int32_t)) { | 5824 if (V8_LIKELY(fits_into_int32_t)) { |
5826 Set(static_cast<int32_t>(i)); | 5825 Set(static_cast<int32_t>(i)); |
5827 return; | 5826 return; |
5828 } | 5827 } |
5829 Set(Integer::NewFromUnsigned(i, GetIsolate())); | 5828 Set(Integer::NewFromUnsigned(i, GetIsolate())); |
5830 } | 5829 } |
5831 | 5830 |
5832 template<typename T> | 5831 template<typename T> |
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6505 */ | 6504 */ |
6506 | 6505 |
6507 | 6506 |
6508 } // namespace v8 | 6507 } // namespace v8 |
6509 | 6508 |
6510 | 6509 |
6511 #undef TYPE_CHECK | 6510 #undef TYPE_CHECK |
6512 | 6511 |
6513 | 6512 |
6514 #endif // V8_H_ | 6513 #endif // V8_H_ |
OLD | NEW |