OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 #define WRITE_BYTE_FIELD(p, offset, value) \ | 676 #define WRITE_BYTE_FIELD(p, offset, value) \ |
677 (*reinterpret_cast<byte*>(FIELD_ADDR(p, offset)) = value) | 677 (*reinterpret_cast<byte*>(FIELD_ADDR(p, offset)) = value) |
678 | 678 |
679 | 679 |
680 Object** HeapObject::RawField(HeapObject* obj, int byte_offset) { | 680 Object** HeapObject::RawField(HeapObject* obj, int byte_offset) { |
681 return &READ_FIELD(obj, byte_offset); | 681 return &READ_FIELD(obj, byte_offset); |
682 } | 682 } |
683 | 683 |
684 | 684 |
685 int Smi::value() { | 685 int Smi::value() { |
686 return reinterpret_cast<int>(this) >> kSmiTagSize; | 686 return static_cast<int>(reinterpret_cast<intptr_t>(this) >> kSmiTagSize); |
687 } | 687 } |
688 | 688 |
689 | 689 |
690 Smi* Smi::FromInt(int value) { | 690 Smi* Smi::FromInt(int value) { |
691 ASSERT(Smi::IsValid(value)); | 691 ASSERT(Smi::IsValid(value)); |
692 return reinterpret_cast<Smi*>((value << kSmiTagSize) | kSmiTag); | 692 return reinterpret_cast<Smi*>((value << kSmiTagSize) | kSmiTag); |
693 } | 693 } |
694 | 694 |
695 | 695 |
696 Failure::Type Failure::type() const { | 696 Failure::Type Failure::type() const { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 Failure* Failure::Exception() { | 732 Failure* Failure::Exception() { |
733 return Construct(EXCEPTION); | 733 return Construct(EXCEPTION); |
734 } | 734 } |
735 | 735 |
736 Failure* Failure::OutOfMemoryException() { | 736 Failure* Failure::OutOfMemoryException() { |
737 return Construct(OUT_OF_MEMORY_EXCEPTION); | 737 return Construct(OUT_OF_MEMORY_EXCEPTION); |
738 } | 738 } |
739 | 739 |
740 | 740 |
741 int Failure::value() const { | 741 int Failure::value() const { |
742 return reinterpret_cast<int>(this) >> kFailureTagSize; | 742 return static_cast<int>(reinterpret_cast<intptr_t>(this) >> kFailureTagSize); |
743 } | 743 } |
744 | 744 |
745 | 745 |
746 Failure* Failure::RetryAfterGC(int requested_bytes) { | 746 Failure* Failure::RetryAfterGC(int requested_bytes) { |
747 int requested = requested_bytes >> kObjectAlignmentBits; | 747 int requested = requested_bytes >> kObjectAlignmentBits; |
748 int value = (requested << kSpaceTagSize) | NEW_SPACE; | 748 int value = (requested << kSpaceTagSize) | NEW_SPACE; |
749 ASSERT(value >> kSpaceTagSize == requested); | 749 ASSERT(value >> kSpaceTagSize == requested); |
750 ASSERT(Smi::IsValid(value)); | 750 ASSERT(Smi::IsValid(value)); |
751 ASSERT(value == ((value << kFailureTypeTagSize) >> kFailureTypeTagSize)); | 751 ASSERT(value == ((value << kFailureTypeTagSize) >> kFailureTypeTagSize)); |
752 ASSERT(Smi::IsValid(value << kFailureTypeTagSize)); | 752 ASSERT(Smi::IsValid(value << kFailureTypeTagSize)); |
753 return Construct(RETRY_AFTER_GC, value); | 753 return Construct(RETRY_AFTER_GC, value); |
754 } | 754 } |
755 | 755 |
756 | 756 |
757 Failure* Failure::Construct(Type type, int value) { | 757 Failure* Failure::Construct(Type type, int value) { |
758 int info = (value << kFailureTypeTagSize) | type; | 758 int info = (value << kFailureTypeTagSize) | type; |
759 ASSERT(Smi::IsValid(info)); // Same validation check as in Smi | 759 ASSERT(Smi::IsValid(info)); // Same validation check as in Smi |
760 return reinterpret_cast<Failure*>((info << kFailureTagSize) | kFailureTag); | 760 return reinterpret_cast<Failure*>( |
| 761 static_cast<intptr_t>((info << kFailureTagSize) | kFailureTag)); |
761 } | 762 } |
762 | 763 |
763 | 764 |
764 bool Smi::IsValid(int value) { | 765 bool Smi::IsValid(int value) { |
765 #ifdef DEBUG | 766 #ifdef DEBUG |
766 bool in_range = (value >= kMinValue) && (value <= kMaxValue); | 767 bool in_range = (value >= kMinValue) && (value <= kMaxValue); |
767 #endif | 768 #endif |
768 // To be representable as an tagged small integer, the two | 769 // To be representable as an tagged small integer, the two |
769 // most-significant bits of 'value' must be either 00 or 11 due to | 770 // most-significant bits of 'value' must be either 00 or 11 due to |
770 // sign-extension. To check this we add 01 to the two | 771 // sign-extension. To check this we add 01 to the two |
(...skipping 1835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2606 #undef WRITE_INT_FIELD | 2607 #undef WRITE_INT_FIELD |
2607 #undef READ_SHORT_FIELD | 2608 #undef READ_SHORT_FIELD |
2608 #undef WRITE_SHORT_FIELD | 2609 #undef WRITE_SHORT_FIELD |
2609 #undef READ_BYTE_FIELD | 2610 #undef READ_BYTE_FIELD |
2610 #undef WRITE_BYTE_FIELD | 2611 #undef WRITE_BYTE_FIELD |
2611 | 2612 |
2612 | 2613 |
2613 } } // namespace v8::internal | 2614 } } // namespace v8::internal |
2614 | 2615 |
2615 #endif // V8_OBJECTS_INL_H_ | 2616 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |