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 2884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2895 heap_->MoveBlockToOldSpaceAndUpdateRegionMarks(new_addr, | 2895 heap_->MoveBlockToOldSpaceAndUpdateRegionMarks(new_addr, |
2896 old_addr, | 2896 old_addr, |
2897 obj_size); | 2897 obj_size); |
2898 } | 2898 } |
2899 } | 2899 } |
2900 | 2900 |
2901 ASSERT(!HeapObject::FromAddress(new_addr)->IsCode()); | 2901 ASSERT(!HeapObject::FromAddress(new_addr)->IsCode()); |
2902 | 2902 |
2903 HeapObject* copied_to = HeapObject::FromAddress(new_addr); | 2903 HeapObject* copied_to = HeapObject::FromAddress(new_addr); |
2904 if (copied_to->IsSharedFunctionInfo()) { | 2904 if (copied_to->IsSharedFunctionInfo()) { |
2905 PROFILE(SFIMoveEvent(old_addr, new_addr)); | 2905 PROFILE(heap_->isolate(),SFIMoveEvent(old_addr, new_addr)); |
2906 } | 2906 } |
2907 HEAP_PROFILE(heap_, ObjectMoveEvent(old_addr, new_addr)); | 2907 HEAP_PROFILE(heap_, ObjectMoveEvent(old_addr, new_addr)); |
2908 | 2908 |
2909 return obj_size; | 2909 return obj_size; |
2910 } | 2910 } |
2911 | 2911 |
2912 | 2912 |
2913 int MarkCompactCollector::RelocateOldPointerObject(HeapObject* obj) { | 2913 int MarkCompactCollector::RelocateOldPointerObject(HeapObject* obj) { |
2914 return RelocateOldNonCodeObject(obj, heap_->old_pointer_space()); | 2914 return RelocateOldNonCodeObject(obj, heap_->old_pointer_space()); |
2915 } | 2915 } |
(...skipping 26 matching lines...) Expand all Loading... |
2942 if (new_addr != old_addr) { | 2942 if (new_addr != old_addr) { |
2943 // Move contents. | 2943 // Move contents. |
2944 heap_->MoveBlock(new_addr, old_addr, obj_size); | 2944 heap_->MoveBlock(new_addr, old_addr, obj_size); |
2945 } | 2945 } |
2946 | 2946 |
2947 HeapObject* copied_to = HeapObject::FromAddress(new_addr); | 2947 HeapObject* copied_to = HeapObject::FromAddress(new_addr); |
2948 if (copied_to->IsCode()) { | 2948 if (copied_to->IsCode()) { |
2949 // May also update inline cache target. | 2949 // May also update inline cache target. |
2950 Code::cast(copied_to)->Relocate(new_addr - old_addr); | 2950 Code::cast(copied_to)->Relocate(new_addr - old_addr); |
2951 // Notify the logger that compiled code has moved. | 2951 // Notify the logger that compiled code has moved. |
2952 PROFILE(CodeMoveEvent(old_addr, new_addr)); | 2952 PROFILE(heap_->isolate(),CodeMoveEvent(old_addr, new_addr)); |
2953 } | 2953 } |
2954 HEAP_PROFILE(heap_, ObjectMoveEvent(old_addr, new_addr)); | 2954 HEAP_PROFILE(heap_, ObjectMoveEvent(old_addr, new_addr)); |
2955 | 2955 |
2956 return obj_size; | 2956 return obj_size; |
2957 } | 2957 } |
2958 | 2958 |
2959 | 2959 |
2960 int MarkCompactCollector::RelocateNewObject(HeapObject* obj) { | 2960 int MarkCompactCollector::RelocateNewObject(HeapObject* obj) { |
2961 int obj_size = obj->Size(); | 2961 int obj_size = obj->Size(); |
2962 | 2962 |
(...skipping 24 matching lines...) Expand all Loading... |
2987 } | 2987 } |
2988 | 2988 |
2989 #ifdef DEBUG | 2989 #ifdef DEBUG |
2990 if (FLAG_gc_verbose) { | 2990 if (FLAG_gc_verbose) { |
2991 PrintF("relocate %p -> %p\n", old_addr, new_addr); | 2991 PrintF("relocate %p -> %p\n", old_addr, new_addr); |
2992 } | 2992 } |
2993 #endif | 2993 #endif |
2994 | 2994 |
2995 HeapObject* copied_to = HeapObject::FromAddress(new_addr); | 2995 HeapObject* copied_to = HeapObject::FromAddress(new_addr); |
2996 if (copied_to->IsSharedFunctionInfo()) { | 2996 if (copied_to->IsSharedFunctionInfo()) { |
2997 PROFILE(SFIMoveEvent(old_addr, new_addr)); | 2997 PROFILE(heap_->isolate(),SFIMoveEvent(old_addr, new_addr)); |
2998 } | 2998 } |
2999 HEAP_PROFILE(heap_, ObjectMoveEvent(old_addr, new_addr)); | 2999 HEAP_PROFILE(heap_, ObjectMoveEvent(old_addr, new_addr)); |
3000 | 3000 |
3001 return obj_size; | 3001 return obj_size; |
3002 } | 3002 } |
3003 | 3003 |
3004 | 3004 |
3005 void MarkCompactCollector::EnableCodeFlushing(bool enable) { | 3005 void MarkCompactCollector::EnableCodeFlushing(bool enable) { |
3006 if (enable) { | 3006 if (enable) { |
3007 if (code_flusher_ != NULL) return; | 3007 if (code_flusher_ != NULL) return; |
3008 code_flusher_ = new CodeFlusher(heap_->isolate()); | 3008 code_flusher_ = new CodeFlusher(heap_->isolate()); |
3009 } else { | 3009 } else { |
3010 if (code_flusher_ == NULL) return; | 3010 if (code_flusher_ == NULL) return; |
3011 delete code_flusher_; | 3011 delete code_flusher_; |
3012 code_flusher_ = NULL; | 3012 code_flusher_ = NULL; |
3013 } | 3013 } |
3014 } | 3014 } |
3015 | 3015 |
3016 | 3016 |
3017 void MarkCompactCollector::ReportDeleteIfNeeded(HeapObject* obj) { | 3017 void MarkCompactCollector::ReportDeleteIfNeeded(HeapObject* obj) { |
3018 #ifdef ENABLE_GDB_JIT_INTERFACE | 3018 #ifdef ENABLE_GDB_JIT_INTERFACE |
3019 if (obj->IsCode()) { | 3019 if (obj->IsCode()) { |
3020 GDBJITInterface::RemoveCode(reinterpret_cast<Code*>(obj)); | 3020 GDBJITInterface::RemoveCode(reinterpret_cast<Code*>(obj)); |
3021 } | 3021 } |
3022 #endif | 3022 #endif |
3023 #ifdef ENABLE_LOGGING_AND_PROFILING | 3023 #ifdef ENABLE_LOGGING_AND_PROFILING |
3024 if (obj->IsCode()) { | 3024 if (obj->IsCode()) { |
3025 PROFILE(CodeDeleteEvent(obj->address())); | 3025 PROFILE(ISOLATE, CodeDeleteEvent(obj->address())); |
3026 } | 3026 } |
3027 #endif | 3027 #endif |
3028 } | 3028 } |
3029 | 3029 |
3030 | 3030 |
3031 int MarkCompactCollector::SizeOfMarkedObject(HeapObject* obj) { | 3031 int MarkCompactCollector::SizeOfMarkedObject(HeapObject* obj) { |
3032 MapWord map_word = obj->map_word(); | 3032 MapWord map_word = obj->map_word(); |
3033 map_word.ClearMark(); | 3033 map_word.ClearMark(); |
3034 return obj->SizeFromMap(map_word.ToMap()); | 3034 return obj->SizeFromMap(map_word.ToMap()); |
3035 } | 3035 } |
3036 | 3036 |
3037 | 3037 |
3038 void MarkCompactCollector::Initialize() { | 3038 void MarkCompactCollector::Initialize() { |
3039 StaticPointersToNewGenUpdatingVisitor::Initialize(); | 3039 StaticPointersToNewGenUpdatingVisitor::Initialize(); |
3040 StaticMarkingVisitor::Initialize(); | 3040 StaticMarkingVisitor::Initialize(); |
3041 } | 3041 } |
3042 | 3042 |
3043 | 3043 |
3044 } } // namespace v8::internal | 3044 } } // namespace v8::internal |
OLD | NEW |