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