OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1999 kVisitStruct, | 1999 kVisitStruct, |
2000 kVisitStructGeneric>(); | 2000 kVisitStructGeneric>(); |
2001 } | 2001 } |
2002 | 2002 |
2003 static VisitorDispatchTable<ScavengingCallback>* GetTable() { | 2003 static VisitorDispatchTable<ScavengingCallback>* GetTable() { |
2004 return &table_; | 2004 return &table_; |
2005 } | 2005 } |
2006 | 2006 |
2007 private: | 2007 private: |
2008 enum ObjectContents { DATA_OBJECT, POINTER_OBJECT }; | 2008 enum ObjectContents { DATA_OBJECT, POINTER_OBJECT }; |
2009 enum SizeRestriction { SMALL, UNKNOWN_SIZE }; | |
2010 | 2009 |
2011 static void RecordCopiedObject(Heap* heap, HeapObject* obj) { | 2010 static void RecordCopiedObject(Heap* heap, HeapObject* obj) { |
2012 bool should_record = false; | 2011 bool should_record = false; |
2013 #ifdef DEBUG | 2012 #ifdef DEBUG |
2014 should_record = FLAG_heap_stats; | 2013 should_record = FLAG_heap_stats; |
2015 #endif | 2014 #endif |
2016 should_record = should_record || FLAG_log_gc; | 2015 should_record = should_record || FLAG_log_gc; |
2017 if (should_record) { | 2016 if (should_record) { |
2018 if (heap->new_space()->Contains(obj)) { | 2017 if (heap->new_space()->Contains(obj)) { |
2019 heap->new_space()->RecordAllocation(obj); | 2018 heap->new_space()->RecordAllocation(obj); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2051 } | 2050 } |
2052 | 2051 |
2053 if (marks_handling == TRANSFER_MARKS) { | 2052 if (marks_handling == TRANSFER_MARKS) { |
2054 if (Marking::TransferColor(source, target)) { | 2053 if (Marking::TransferColor(source, target)) { |
2055 MemoryChunk::IncrementLiveBytesFromGC(target->address(), size); | 2054 MemoryChunk::IncrementLiveBytesFromGC(target->address(), size); |
2056 } | 2055 } |
2057 } | 2056 } |
2058 } | 2057 } |
2059 | 2058 |
2060 | 2059 |
2061 template<ObjectContents object_contents, | 2060 template<ObjectContents object_contents, int alignment> |
2062 SizeRestriction size_restriction, | |
2063 int alignment> | |
2064 static inline void EvacuateObject(Map* map, | 2061 static inline void EvacuateObject(Map* map, |
2065 HeapObject** slot, | 2062 HeapObject** slot, |
2066 HeapObject* object, | 2063 HeapObject* object, |
2067 int object_size) { | 2064 int object_size) { |
2068 SLOW_ASSERT((size_restriction != SMALL) || | 2065 SLOW_ASSERT(object_size <= Page::kMaxNonCodeHeapObjectSize); |
2069 (object_size <= Page::kMaxNonCodeHeapObjectSize)); | |
2070 SLOW_ASSERT(object->Size() == object_size); | 2066 SLOW_ASSERT(object->Size() == object_size); |
2071 | 2067 |
2072 int allocation_size = object_size; | 2068 int allocation_size = object_size; |
2073 if (alignment != kObjectAlignment) { | 2069 if (alignment != kObjectAlignment) { |
2074 ASSERT(alignment == kDoubleAlignment); | 2070 ASSERT(alignment == kDoubleAlignment); |
2075 allocation_size += kPointerSize; | 2071 allocation_size += kPointerSize; |
2076 } | 2072 } |
2077 | 2073 |
2078 Heap* heap = map->GetHeap(); | 2074 Heap* heap = map->GetHeap(); |
2079 if (heap->ShouldBePromoted(object->address(), object_size)) { | 2075 if (heap->ShouldBePromoted(object->address(), object_size)) { |
2080 MaybeObject* maybe_result; | 2076 MaybeObject* maybe_result; |
2081 | 2077 |
2082 if ((size_restriction != SMALL) && | 2078 if (object_contents == DATA_OBJECT) { |
2083 (allocation_size > Page::kMaxNonCodeHeapObjectSize)) { | 2079 maybe_result = heap->old_data_space()->AllocateRaw(allocation_size); |
2084 maybe_result = heap->lo_space()->AllocateRaw(allocation_size, | |
2085 NOT_EXECUTABLE); | |
2086 } else { | 2080 } else { |
2087 if (object_contents == DATA_OBJECT) { | 2081 maybe_result = |
2088 maybe_result = heap->old_data_space()->AllocateRaw(allocation_size); | 2082 heap->old_pointer_space()->AllocateRaw(allocation_size); |
2089 } else { | |
2090 maybe_result = | |
2091 heap->old_pointer_space()->AllocateRaw(allocation_size); | |
2092 } | |
2093 } | 2083 } |
2094 | 2084 |
2095 Object* result = NULL; // Initialization to please compiler. | 2085 Object* result = NULL; // Initialization to please compiler. |
2096 if (maybe_result->ToObject(&result)) { | 2086 if (maybe_result->ToObject(&result)) { |
2097 HeapObject* target = HeapObject::cast(result); | 2087 HeapObject* target = HeapObject::cast(result); |
2098 | 2088 |
2099 if (alignment != kObjectAlignment) { | 2089 if (alignment != kObjectAlignment) { |
2100 target = EnsureDoubleAligned(heap, target, allocation_size); | 2090 target = EnsureDoubleAligned(heap, target, allocation_size); |
2101 } | 2091 } |
2102 | 2092 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2156 map->GetHeap()->mark_compact_collector()-> | 2146 map->GetHeap()->mark_compact_collector()-> |
2157 RecordCodeEntrySlot(code_entry_slot, code); | 2147 RecordCodeEntrySlot(code_entry_slot, code); |
2158 } | 2148 } |
2159 } | 2149 } |
2160 | 2150 |
2161 | 2151 |
2162 static inline void EvacuateFixedArray(Map* map, | 2152 static inline void EvacuateFixedArray(Map* map, |
2163 HeapObject** slot, | 2153 HeapObject** slot, |
2164 HeapObject* object) { | 2154 HeapObject* object) { |
2165 int object_size = FixedArray::BodyDescriptor::SizeOf(map, object); | 2155 int object_size = FixedArray::BodyDescriptor::SizeOf(map, object); |
2166 EvacuateObject<POINTER_OBJECT, UNKNOWN_SIZE, kObjectAlignment>(map, | 2156 EvacuateObject<POINTER_OBJECT, kObjectAlignment>( |
2167 slot, | 2157 map, slot, object, object_size); |
2168 object, | |
2169 object_size); | |
2170 } | 2158 } |
2171 | 2159 |
2172 | 2160 |
2173 static inline void EvacuateFixedDoubleArray(Map* map, | 2161 static inline void EvacuateFixedDoubleArray(Map* map, |
2174 HeapObject** slot, | 2162 HeapObject** slot, |
2175 HeapObject* object) { | 2163 HeapObject* object) { |
2176 int length = reinterpret_cast<FixedDoubleArray*>(object)->length(); | 2164 int length = reinterpret_cast<FixedDoubleArray*>(object)->length(); |
2177 int object_size = FixedDoubleArray::SizeFor(length); | 2165 int object_size = FixedDoubleArray::SizeFor(length); |
2178 EvacuateObject<DATA_OBJECT, UNKNOWN_SIZE, kDoubleAlignment>( | 2166 EvacuateObject<DATA_OBJECT, kDoubleAlignment>( |
2179 map, | 2167 map, slot, object, object_size); |
2180 slot, | |
2181 object, | |
2182 object_size); | |
2183 } | 2168 } |
2184 | 2169 |
2185 | 2170 |
2186 static inline void EvacuateByteArray(Map* map, | 2171 static inline void EvacuateByteArray(Map* map, |
2187 HeapObject** slot, | 2172 HeapObject** slot, |
2188 HeapObject* object) { | 2173 HeapObject* object) { |
2189 int object_size = reinterpret_cast<ByteArray*>(object)->ByteArraySize(); | 2174 int object_size = reinterpret_cast<ByteArray*>(object)->ByteArraySize(); |
2190 EvacuateObject<DATA_OBJECT, UNKNOWN_SIZE, kObjectAlignment>( | 2175 EvacuateObject<DATA_OBJECT, kObjectAlignment>( |
2191 map, slot, object, object_size); | 2176 map, slot, object, object_size); |
2192 } | 2177 } |
2193 | 2178 |
2194 | 2179 |
2195 static inline void EvacuateSeqOneByteString(Map* map, | 2180 static inline void EvacuateSeqOneByteString(Map* map, |
2196 HeapObject** slot, | 2181 HeapObject** slot, |
2197 HeapObject* object) { | 2182 HeapObject* object) { |
2198 int object_size = SeqOneByteString::cast(object)-> | 2183 int object_size = SeqOneByteString::cast(object)-> |
2199 SeqOneByteStringSize(map->instance_type()); | 2184 SeqOneByteStringSize(map->instance_type()); |
2200 EvacuateObject<DATA_OBJECT, UNKNOWN_SIZE, kObjectAlignment>( | 2185 EvacuateObject<DATA_OBJECT, kObjectAlignment>( |
2201 map, slot, object, object_size); | 2186 map, slot, object, object_size); |
2202 } | 2187 } |
2203 | 2188 |
2204 | 2189 |
2205 static inline void EvacuateSeqTwoByteString(Map* map, | 2190 static inline void EvacuateSeqTwoByteString(Map* map, |
2206 HeapObject** slot, | 2191 HeapObject** slot, |
2207 HeapObject* object) { | 2192 HeapObject* object) { |
2208 int object_size = SeqTwoByteString::cast(object)-> | 2193 int object_size = SeqTwoByteString::cast(object)-> |
2209 SeqTwoByteStringSize(map->instance_type()); | 2194 SeqTwoByteStringSize(map->instance_type()); |
2210 EvacuateObject<DATA_OBJECT, UNKNOWN_SIZE, kObjectAlignment>( | 2195 EvacuateObject<DATA_OBJECT, kObjectAlignment>( |
2211 map, slot, object, object_size); | 2196 map, slot, object, object_size); |
2212 } | 2197 } |
2213 | 2198 |
2214 | 2199 |
2215 static inline bool IsShortcutCandidate(int type) { | 2200 static inline bool IsShortcutCandidate(int type) { |
2216 return ((type & kShortcutTypeMask) == kShortcutTypeTag); | 2201 return ((type & kShortcutTypeMask) == kShortcutTypeTag); |
2217 } | 2202 } |
2218 | 2203 |
2219 static inline void EvacuateShortcutCandidate(Map* map, | 2204 static inline void EvacuateShortcutCandidate(Map* map, |
2220 HeapObject** slot, | 2205 HeapObject** slot, |
(...skipping 23 matching lines...) Expand all Loading... |
2244 object->set_map_word(MapWord::FromForwardingAddress(target)); | 2229 object->set_map_word(MapWord::FromForwardingAddress(target)); |
2245 return; | 2230 return; |
2246 } | 2231 } |
2247 | 2232 |
2248 heap->DoScavengeObject(first->map(), slot, first); | 2233 heap->DoScavengeObject(first->map(), slot, first); |
2249 object->set_map_word(MapWord::FromForwardingAddress(*slot)); | 2234 object->set_map_word(MapWord::FromForwardingAddress(*slot)); |
2250 return; | 2235 return; |
2251 } | 2236 } |
2252 | 2237 |
2253 int object_size = ConsString::kSize; | 2238 int object_size = ConsString::kSize; |
2254 EvacuateObject<POINTER_OBJECT, SMALL, kObjectAlignment>( | 2239 EvacuateObject<POINTER_OBJECT, kObjectAlignment>( |
2255 map, slot, object, object_size); | 2240 map, slot, object, object_size); |
2256 } | 2241 } |
2257 | 2242 |
2258 template<ObjectContents object_contents> | 2243 template<ObjectContents object_contents> |
2259 class ObjectEvacuationStrategy { | 2244 class ObjectEvacuationStrategy { |
2260 public: | 2245 public: |
2261 template<int object_size> | 2246 template<int object_size> |
2262 static inline void VisitSpecialized(Map* map, | 2247 static inline void VisitSpecialized(Map* map, |
2263 HeapObject** slot, | 2248 HeapObject** slot, |
2264 HeapObject* object) { | 2249 HeapObject* object) { |
2265 EvacuateObject<object_contents, SMALL, kObjectAlignment>( | 2250 EvacuateObject<object_contents, kObjectAlignment>( |
2266 map, slot, object, object_size); | 2251 map, slot, object, object_size); |
2267 } | 2252 } |
2268 | 2253 |
2269 static inline void Visit(Map* map, | 2254 static inline void Visit(Map* map, |
2270 HeapObject** slot, | 2255 HeapObject** slot, |
2271 HeapObject* object) { | 2256 HeapObject* object) { |
2272 int object_size = map->instance_size(); | 2257 int object_size = map->instance_size(); |
2273 EvacuateObject<object_contents, SMALL, kObjectAlignment>( | 2258 EvacuateObject<object_contents, kObjectAlignment>( |
2274 map, slot, object, object_size); | 2259 map, slot, object, object_size); |
2275 } | 2260 } |
2276 }; | 2261 }; |
2277 | 2262 |
2278 static VisitorDispatchTable<ScavengingCallback> table_; | 2263 static VisitorDispatchTable<ScavengingCallback> table_; |
2279 }; | 2264 }; |
2280 | 2265 |
2281 | 2266 |
2282 template<MarksHandling marks_handling, | 2267 template<MarksHandling marks_handling, |
2283 LoggingAndProfiling logging_and_profiling_mode> | 2268 LoggingAndProfiling logging_and_profiling_mode> |
(...skipping 5752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8036 if (FLAG_parallel_recompilation) { | 8021 if (FLAG_parallel_recompilation) { |
8037 heap_->relocation_mutex_->Lock(); | 8022 heap_->relocation_mutex_->Lock(); |
8038 #ifdef DEBUG | 8023 #ifdef DEBUG |
8039 heap_->relocation_mutex_locked_by_optimizer_thread_ = | 8024 heap_->relocation_mutex_locked_by_optimizer_thread_ = |
8040 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); | 8025 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); |
8041 #endif // DEBUG | 8026 #endif // DEBUG |
8042 } | 8027 } |
8043 } | 8028 } |
8044 | 8029 |
8045 } } // namespace v8::internal | 8030 } } // namespace v8::internal |
OLD | NEW |