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 5329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5340 // CAUTION: The original code below: | 5340 // CAUTION: The original code below: |
5341 // bool result = ((value + 0x40000000) & 0x80000000) == 0; | 5341 // bool result = ((value + 0x40000000) & 0x80000000) == 0; |
5342 // may lead to incorrect results according to the C language spec, and | 5342 // may lead to incorrect results according to the C language spec, and |
5343 // in fact doesn't work correctly with gcc4.1.1 in some cases: The | 5343 // in fact doesn't work correctly with gcc4.1.1 in some cases: The |
5344 // compiler may produce undefined results in case of signed integer | 5344 // compiler may produce undefined results in case of signed integer |
5345 // overflow. The computation must be done w/ unsigned ints. | 5345 // overflow. The computation must be done w/ unsigned ints. |
5346 return static_cast<uintptr_t>(value + 0x40000000U) < 0x80000000U; | 5346 return static_cast<uintptr_t>(value + 0x40000000U) < 0x80000000U; |
5347 } | 5347 } |
5348 }; | 5348 }; |
5349 | 5349 |
5350 #if !V8_USE_31_BITS_SMI_VALUE | |
danno
2013/07/29 13:02:23
I also see no reason to put the SmiTagging<8> defi
haitao.feng
2013/07/30 08:56:43
Done.
| |
5350 // Smi constants for 64-bit systems. | 5351 // Smi constants for 64-bit systems. |
5351 template <> struct SmiTagging<8> { | 5352 template <> struct SmiTagging<8> { |
5352 static const int kSmiShiftSize = 31; | 5353 static const int kSmiShiftSize = 31; |
5353 static const int kSmiValueSize = 32; | 5354 static const int kSmiValueSize = 32; |
5354 V8_INLINE(static int SmiToInt(internal::Object* value)) { | 5355 V8_INLINE(static int SmiToInt(internal::Object* value)) { |
5355 int shift_bits = kSmiTagSize + kSmiShiftSize; | 5356 int shift_bits = kSmiTagSize + kSmiShiftSize; |
5356 // Shift down and throw away top 32 bits. | 5357 // Shift down and throw away top 32 bits. |
5357 return static_cast<int>(reinterpret_cast<intptr_t>(value) >> shift_bits); | 5358 return static_cast<int>(reinterpret_cast<intptr_t>(value) >> shift_bits); |
5358 } | 5359 } |
5359 V8_INLINE(static internal::Object* IntToSmi(int value)) { | 5360 V8_INLINE(static internal::Object* IntToSmi(int value)) { |
5360 return internal::IntToSmi<kSmiShiftSize>(value); | 5361 return internal::IntToSmi<kSmiShiftSize>(value); |
5361 } | 5362 } |
5362 V8_INLINE(static bool IsValidSmi(intptr_t value)) { | 5363 V8_INLINE(static bool IsValidSmi(intptr_t value)) { |
5363 // To be representable as a long smi, the value must be a 32-bit integer. | 5364 // To be representable as a long smi, the value must be a 32-bit integer. |
5364 return (value == static_cast<int32_t>(value)); | 5365 return (value == static_cast<int32_t>(value)); |
5365 } | 5366 } |
5366 }; | 5367 }; |
5367 | 5368 |
5368 typedef SmiTagging<kApiPointerSize> PlatformSmiTagging; | 5369 typedef SmiTagging<kApiPointerSize> PlatformSmiTagging; |
5370 #else | |
5371 typedef SmiTagging<4> PlatformSmiTagging; | |
5372 #endif | |
5373 | |
5369 const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize; | 5374 const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize; |
5370 const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize; | 5375 const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize; |
5371 | 5376 |
5372 /** | 5377 /** |
5373 * This class exports constants and functionality from within v8 that | 5378 * This class exports constants and functionality from within v8 that |
5374 * is necessary to implement inline functions in the v8 api. Don't | 5379 * is necessary to implement inline functions in the v8 api. Don't |
5375 * depend on functions and constants defined here. | 5380 * depend on functions and constants defined here. |
5376 */ | 5381 */ |
5377 class Internals { | 5382 class Internals { |
5378 public: | 5383 public: |
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6481 | 6486 |
6482 | 6487 |
6483 } // namespace v8 | 6488 } // namespace v8 |
6484 | 6489 |
6485 | 6490 |
6486 #undef V8EXPORT | 6491 #undef V8EXPORT |
6487 #undef TYPE_CHECK | 6492 #undef TYPE_CHECK |
6488 | 6493 |
6489 | 6494 |
6490 #endif // V8_H_ | 6495 #endif // V8_H_ |
OLD | NEW |