| 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 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 return MapWord(reinterpret_cast<uintptr_t>(map)); | 620 return MapWord(reinterpret_cast<uintptr_t>(map)); |
| 621 } | 621 } |
| 622 | 622 |
| 623 | 623 |
| 624 Map* MapWord::ToMap() { | 624 Map* MapWord::ToMap() { |
| 625 return reinterpret_cast<Map*>(value_); | 625 return reinterpret_cast<Map*>(value_); |
| 626 } | 626 } |
| 627 | 627 |
| 628 | 628 |
| 629 bool MapWord::IsForwardingAddress() { | 629 bool MapWord::IsForwardingAddress() { |
| 630 // This function only works for map words that are heap object pointers. | 630 return HAS_SMI_TAG(reinterpret_cast<Object*>(value_)); |
| 631 // Since it is a heap object, it has a map. We use that map's instance | |
| 632 // type to detect if this map word is not actually a map (ie, it is a | |
| 633 // forwarding address during a scavenge collection). | |
| 634 return reinterpret_cast<HeapObject*>(value_)->map()->instance_type() != | |
| 635 MAP_TYPE; | |
| 636 } | 631 } |
| 637 | 632 |
| 638 | 633 |
| 639 MapWord MapWord::FromForwardingAddress(HeapObject* object) { | 634 MapWord MapWord::FromForwardingAddress(HeapObject* object) { |
| 640 return MapWord(reinterpret_cast<uintptr_t>(object)); | 635 Address raw = reinterpret_cast<Address>(object) - kHeapObjectTag; |
| 636 return MapWord(reinterpret_cast<uintptr_t>(raw)); |
| 641 } | 637 } |
| 642 | 638 |
| 643 | 639 |
| 644 HeapObject* MapWord::ToForwardingAddress() { | 640 HeapObject* MapWord::ToForwardingAddress() { |
| 645 ASSERT(IsForwardingAddress()); | 641 ASSERT(IsForwardingAddress()); |
| 646 return reinterpret_cast<HeapObject*>(value_); | 642 return HeapObject::FromAddress(reinterpret_cast<Address>(value_)); |
| 647 } | 643 } |
| 648 | 644 |
| 649 | 645 |
| 650 bool MapWord::IsMarked() { | 646 bool MapWord::IsMarked() { |
| 651 return (value_ & kMarkingMask) == 0; | 647 return (value_ & kMarkingMask) == 0; |
| 652 } | 648 } |
| 653 | 649 |
| 654 | 650 |
| 655 void MapWord::SetMark() { | 651 void MapWord::SetMark() { |
| 656 value_ &= ~kMarkingMask; | 652 value_ &= ~kMarkingMask; |
| (...skipping 1658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2315 #undef WRITE_INT_FIELD | 2311 #undef WRITE_INT_FIELD |
| 2316 #undef READ_SHORT_FIELD | 2312 #undef READ_SHORT_FIELD |
| 2317 #undef WRITE_SHORT_FIELD | 2313 #undef WRITE_SHORT_FIELD |
| 2318 #undef READ_BYTE_FIELD | 2314 #undef READ_BYTE_FIELD |
| 2319 #undef WRITE_BYTE_FIELD | 2315 #undef WRITE_BYTE_FIELD |
| 2320 | 2316 |
| 2321 | 2317 |
| 2322 } } // namespace v8::internal | 2318 } } // namespace v8::internal |
| 2323 | 2319 |
| 2324 #endif // V8_OBJECTS_INL_H_ | 2320 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |