| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| (...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1044 VerifyPointer(READ_FIELD(this, offset)); | 1044 VerifyPointer(READ_FIELD(this, offset)); |
| 1045 } | 1045 } |
| 1046 | 1046 |
| 1047 void HeapObject::VerifySmiField(int offset) { | 1047 void HeapObject::VerifySmiField(int offset) { |
| 1048 ASSERT(READ_FIELD(this, offset)->IsSmi()); | 1048 ASSERT(READ_FIELD(this, offset)->IsSmi()); |
| 1049 } | 1049 } |
| 1050 #endif | 1050 #endif |
| 1051 | 1051 |
| 1052 | 1052 |
| 1053 Heap* HeapObject::GetHeap() { | 1053 Heap* HeapObject::GetHeap() { |
| 1054 // During GC, the map pointer in HeapObject is used in various ways that | 1054 return MemoryChunk::FromAddress(address())->heap(); |
| 1055 // prevent us from retrieving Heap from the map. | |
| 1056 // Assert that we are not in GC, implement GC code in a way that it doesn't | |
| 1057 // pull heap from the map. | |
| 1058 return map()->heap(); | |
| 1059 } | 1055 } |
| 1060 | 1056 |
| 1061 | 1057 |
| 1062 Isolate* HeapObject::GetIsolate() { | 1058 Isolate* HeapObject::GetIsolate() { |
| 1063 Isolate* i = GetHeap()->isolate(); | 1059 Isolate* isolate = MemoryChunk::FromAddress(address())->heap()->isolate(); |
| 1064 ASSERT(i == Isolate::Current()); | 1060 ASSERT(isolate == Isolate::Current()); |
| 1065 return i; | 1061 return isolate; |
| 1066 } | 1062 } |
| 1067 | 1063 |
| 1068 | 1064 |
| 1069 Map* HeapObject::map() { | 1065 Map* HeapObject::map() { |
| 1070 return map_word().ToMap(); | 1066 return map_word().ToMap(); |
| 1071 } | 1067 } |
| 1072 | 1068 |
| 1073 | 1069 |
| 1074 void HeapObject::set_map(Map* value) { | 1070 void HeapObject::set_map(Map* value) { |
| 1075 set_map_word(MapWord::FromMap(value)); | 1071 set_map_word(MapWord::FromMap(value)); |
| 1076 if (value != NULL) { | 1072 if (value != NULL) { |
| 1077 value->heap()->incremental_marking()->RecordWrite(this, value); | 1073 value->GetHeap()->incremental_marking()->RecordWrite(this, value); |
| 1078 } | 1074 } |
| 1079 } | 1075 } |
| 1080 | 1076 |
| 1081 | 1077 |
| 1082 MapWord HeapObject::map_word() { | 1078 MapWord HeapObject::map_word() { |
| 1083 return MapWord(reinterpret_cast<uintptr_t>(READ_FIELD(this, kMapOffset))); | 1079 return MapWord(reinterpret_cast<uintptr_t>(READ_FIELD(this, kMapOffset))); |
| 1084 } | 1080 } |
| 1085 | 1081 |
| 1086 | 1082 |
| 1087 void HeapObject::set_map_word(MapWord map_word) { | 1083 void HeapObject::set_map_word(MapWord map_word) { |
| (...skipping 1616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2704 HeapObject* code = HeapObject::FromAddress(address - Code::kHeaderSize); | 2700 HeapObject* code = HeapObject::FromAddress(address - Code::kHeaderSize); |
| 2705 // GetCodeFromTargetAddress might be called when marking objects during mark | 2701 // GetCodeFromTargetAddress might be called when marking objects during mark |
| 2706 // sweep. reinterpret_cast is therefore used instead of the more appropriate | 2702 // sweep. reinterpret_cast is therefore used instead of the more appropriate |
| 2707 // Code::cast. Code::cast does not work when the object's map is | 2703 // Code::cast. Code::cast does not work when the object's map is |
| 2708 // marked. | 2704 // marked. |
| 2709 Code* result = reinterpret_cast<Code*>(code); | 2705 Code* result = reinterpret_cast<Code*>(code); |
| 2710 return result; | 2706 return result; |
| 2711 } | 2707 } |
| 2712 | 2708 |
| 2713 | 2709 |
| 2714 Heap* Map::heap() { | |
| 2715 // NOTE: address() helper is not used to save one instruction. | |
| 2716 Heap* heap = Page::FromAddress(reinterpret_cast<Address>(this))->heap(); | |
| 2717 ASSERT(heap != NULL); | |
| 2718 ASSERT(heap->isolate() == Isolate::Current()); | |
| 2719 return heap; | |
| 2720 } | |
| 2721 | |
| 2722 | |
| 2723 Object* Code::GetObjectFromEntryAddress(Address location_of_address) { | 2710 Object* Code::GetObjectFromEntryAddress(Address location_of_address) { |
| 2724 return HeapObject:: | 2711 return HeapObject:: |
| 2725 FromAddress(Memory::Address_at(location_of_address) - Code::kHeaderSize); | 2712 FromAddress(Memory::Address_at(location_of_address) - Code::kHeaderSize); |
| 2726 } | 2713 } |
| 2727 | 2714 |
| 2728 | 2715 |
| 2729 Object* Map::prototype() { | 2716 Object* Map::prototype() { |
| 2730 return READ_FIELD(this, kPrototypeOffset); | 2717 return READ_FIELD(this, kPrototypeOffset); |
| 2731 } | 2718 } |
| 2732 | 2719 |
| (...skipping 1279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4012 #undef WRITE_INT_FIELD | 3999 #undef WRITE_INT_FIELD |
| 4013 #undef READ_SHORT_FIELD | 4000 #undef READ_SHORT_FIELD |
| 4014 #undef WRITE_SHORT_FIELD | 4001 #undef WRITE_SHORT_FIELD |
| 4015 #undef READ_BYTE_FIELD | 4002 #undef READ_BYTE_FIELD |
| 4016 #undef WRITE_BYTE_FIELD | 4003 #undef WRITE_BYTE_FIELD |
| 4017 | 4004 |
| 4018 | 4005 |
| 4019 } } // namespace v8::internal | 4006 } } // namespace v8::internal |
| 4020 | 4007 |
| 4021 #endif // V8_OBJECTS_INL_H_ | 4008 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |