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 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 Failure* Failure::OutOfMemoryException() { | 588 Failure* Failure::OutOfMemoryException() { |
589 return Construct(OUT_OF_MEMORY_EXCEPTION); | 589 return Construct(OUT_OF_MEMORY_EXCEPTION); |
590 } | 590 } |
591 | 591 |
592 | 592 |
593 int Failure::value() const { | 593 int Failure::value() const { |
594 return reinterpret_cast<int>(this) >> kFailureTagSize; | 594 return reinterpret_cast<int>(this) >> kFailureTagSize; |
595 } | 595 } |
596 | 596 |
597 | 597 |
| 598 Failure* Failure::RetryAfterGC(int requested_bytes) { |
| 599 int requested = requested_bytes >> kObjectAlignmentBits; |
| 600 int value = (requested << kSpaceTagSize) | NEW_SPACE; |
| 601 ASSERT(value >> kSpaceTagSize == requested); |
| 602 ASSERT(Smi::IsValid(value)); |
| 603 ASSERT(value == ((value << kFailureTypeTagSize) >> kFailureTypeTagSize)); |
| 604 ASSERT(Smi::IsValid(value << kFailureTypeTagSize)); |
| 605 return Construct(RETRY_AFTER_GC, value); |
| 606 } |
| 607 |
| 608 |
598 Failure* Failure::Construct(Type type, int value) { | 609 Failure* Failure::Construct(Type type, int value) { |
599 int info = (value << kFailureTypeTagSize) | type; | 610 int info = (value << kFailureTypeTagSize) | type; |
600 ASSERT(Smi::IsValid(info)); // Same validation check as in Smi | 611 ASSERT(Smi::IsValid(info)); // Same validation check as in Smi |
601 return reinterpret_cast<Failure*>((info << kFailureTagSize) | kFailureTag); | 612 return reinterpret_cast<Failure*>((info << kFailureTagSize) | kFailureTag); |
602 } | 613 } |
603 | 614 |
604 | 615 |
605 bool Smi::IsValid(int value) { | 616 bool Smi::IsValid(int value) { |
606 #ifdef DEBUG | 617 #ifdef DEBUG |
607 bool in_range = (value >= kMinValue) && (value <= kMaxValue); | 618 bool in_range = (value >= kMinValue) && (value <= kMaxValue); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 v->VisitPointers(reinterpret_cast<Object**>(FIELD_ADDR(this, start)), | 795 v->VisitPointers(reinterpret_cast<Object**>(FIELD_ADDR(this, start)), |
785 reinterpret_cast<Object**>(FIELD_ADDR(this, end))); | 796 reinterpret_cast<Object**>(FIELD_ADDR(this, end))); |
786 } | 797 } |
787 | 798 |
788 | 799 |
789 void HeapObject::IteratePointer(ObjectVisitor* v, int offset) { | 800 void HeapObject::IteratePointer(ObjectVisitor* v, int offset) { |
790 v->VisitPointer(reinterpret_cast<Object**>(FIELD_ADDR(this, offset))); | 801 v->VisitPointer(reinterpret_cast<Object**>(FIELD_ADDR(this, offset))); |
791 } | 802 } |
792 | 803 |
793 | 804 |
794 void HeapObject::CopyBody(JSObject* from) { | |
795 ASSERT(map() == from->map()); | |
796 ASSERT(Size() == from->Size()); | |
797 int object_size = Size(); | |
798 for (int offset = kHeaderSize; | |
799 offset < object_size; | |
800 offset += kPointerSize) { | |
801 Object* value = READ_FIELD(from, offset); | |
802 // Note: WRITE_FIELD does not update the write barrier. | |
803 WRITE_FIELD(this, offset, value); | |
804 WRITE_BARRIER(this, offset); | |
805 } | |
806 } | |
807 | |
808 | |
809 bool HeapObject::IsMarked() { | 805 bool HeapObject::IsMarked() { |
810 return map_word().IsMarked(); | 806 return map_word().IsMarked(); |
811 } | 807 } |
812 | 808 |
813 | 809 |
814 void HeapObject::SetMark() { | 810 void HeapObject::SetMark() { |
815 ASSERT(!IsMarked()); | 811 ASSERT(!IsMarked()); |
816 MapWord first_word = map_word(); | 812 MapWord first_word = map_word(); |
817 first_word.SetMark(); | 813 first_word.SetMark(); |
818 set_map_word(first_word); | 814 set_map_word(first_word); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
956 WRITE_BARRIER(this, offset); | 952 WRITE_BARRIER(this, offset); |
957 } else { | 953 } else { |
958 ASSERT(index < properties()->length()); | 954 ASSERT(index < properties()->length()); |
959 properties()->set(index, value); | 955 properties()->set(index, value); |
960 } | 956 } |
961 return value; | 957 return value; |
962 } | 958 } |
963 | 959 |
964 | 960 |
965 void JSObject::InitializeBody(int object_size) { | 961 void JSObject::InitializeBody(int object_size) { |
| 962 Object* value = Heap::undefined_value(); |
966 for (int offset = kHeaderSize; offset < object_size; offset += kPointerSize) { | 963 for (int offset = kHeaderSize; offset < object_size; offset += kPointerSize) { |
967 WRITE_FIELD(this, offset, Heap::undefined_value()); | 964 WRITE_FIELD(this, offset, value); |
968 } | 965 } |
969 } | 966 } |
970 | 967 |
971 | 968 |
972 void Struct::InitializeBody(int object_size) { | 969 void Struct::InitializeBody(int object_size) { |
| 970 Object* value = Heap::undefined_value(); |
973 for (int offset = kHeaderSize; offset < object_size; offset += kPointerSize) { | 971 for (int offset = kHeaderSize; offset < object_size; offset += kPointerSize) { |
974 WRITE_FIELD(this, offset, Heap::undefined_value()); | 972 WRITE_FIELD(this, offset, value); |
975 } | 973 } |
976 } | 974 } |
977 | 975 |
978 | 976 |
979 bool JSObject::HasFastProperties() { | 977 bool JSObject::HasFastProperties() { |
980 return !properties()->IsDictionary(); | 978 return !properties()->IsDictionary(); |
981 } | 979 } |
982 | 980 |
983 | 981 |
984 bool Array::IndexFromObject(Object* object, uint32_t* index) { | 982 bool Array::IndexFromObject(Object* object, uint32_t* index) { |
(...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2334 #undef WRITE_INT_FIELD | 2332 #undef WRITE_INT_FIELD |
2335 #undef READ_SHORT_FIELD | 2333 #undef READ_SHORT_FIELD |
2336 #undef WRITE_SHORT_FIELD | 2334 #undef WRITE_SHORT_FIELD |
2337 #undef READ_BYTE_FIELD | 2335 #undef READ_BYTE_FIELD |
2338 #undef WRITE_BYTE_FIELD | 2336 #undef WRITE_BYTE_FIELD |
2339 | 2337 |
2340 | 2338 |
2341 } } // namespace v8::internal | 2339 } } // namespace v8::internal |
2342 | 2340 |
2343 #endif // V8_OBJECTS_INL_H_ | 2341 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |