OLD | NEW |
---|---|
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/allocation-tracker.h" | 7 #include "src/allocation-tracker.h" |
8 #include "src/frames-inl.h" | 8 #include "src/frames-inl.h" |
9 #include "src/heap-snapshot-generator.h" | 9 #include "src/heap-snapshot-generator.h" |
10 | 10 |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
214 List<UnresolvedLocation*> copy(unresolved_locations_.length()); | 214 List<UnresolvedLocation*> copy(unresolved_locations_.length()); |
215 copy.AddAll(unresolved_locations_); | 215 copy.AddAll(unresolved_locations_); |
216 unresolved_locations_.Clear(); | 216 unresolved_locations_.Clear(); |
217 for (int i = 0; i < copy.length(); i++) { | 217 for (int i = 0; i < copy.length(); i++) { |
218 copy[i]->Resolve(); | 218 copy[i]->Resolve(); |
219 delete copy[i]; | 219 delete copy[i]; |
220 } | 220 } |
221 } | 221 } |
222 | 222 |
223 | 223 |
224 #ifdef DEBUG | |
225 bool IsFillerOrFreeListNode(HeapObject* object) { | |
Hannes Payer (out of office)
2015/01/27 08:05:49
Rename to IsFillerOrFreeSpace
Yang
2015/01/27 08:49:48
Acknowledged.
| |
226 Map* map = object->map(); | |
227 Heap* heap = object->GetHeap(); | |
228 return map == heap->raw_unchecked_free_space_map() || | |
229 map == heap->raw_unchecked_one_pointer_filler_map() || | |
230 map == heap->raw_unchecked_two_pointer_filler_map(); | |
231 } | |
232 #endif // DEBUG | |
233 | |
234 | |
224 void AllocationTracker::AllocationEvent(Address addr, int size) { | 235 void AllocationTracker::AllocationEvent(Address addr, int size) { |
225 DisallowHeapAllocation no_allocation; | 236 DisallowHeapAllocation no_allocation; |
226 Heap* heap = ids_->heap(); | 237 Heap* heap = ids_->heap(); |
227 | 238 |
228 // Mark the new block as FreeSpace to make sure the heap is iterable | 239 // Mark the new block as FreeSpace to make sure the heap is iterable |
229 // while we are capturing stack trace. | 240 // while we are capturing stack trace. |
230 FreeListNode::FromAddress(addr)->set_size(heap, size); | 241 heap->CreateFillerObjectAt(addr, size); |
231 DCHECK_EQ(HeapObject::FromAddress(addr)->Size(), size); | 242 DCHECK_EQ(HeapObject::FromAddress(addr)->Size(), size); |
232 DCHECK(FreeListNode::IsFreeListNode(HeapObject::FromAddress(addr))); | 243 DCHECK(IsFillerOrFreeListNode(HeapObject::FromAddress(addr))); |
Hannes Payer (out of office)
2015/01/27 08:05:49
I don't think the two DCHECKs above are useful. We
Yang
2015/01/27 08:49:49
Done.
| |
233 | 244 |
234 Isolate* isolate = heap->isolate(); | 245 Isolate* isolate = heap->isolate(); |
235 int length = 0; | 246 int length = 0; |
236 StackTraceFrameIterator it(isolate); | 247 StackTraceFrameIterator it(isolate); |
237 while (!it.done() && length < kMaxAllocationTraceLength) { | 248 while (!it.done() && length < kMaxAllocationTraceLength) { |
238 JavaScriptFrame* frame = it.frame(); | 249 JavaScriptFrame* frame = it.frame(); |
239 SharedFunctionInfo* shared = frame->function()->shared(); | 250 SharedFunctionInfo* shared = frame->function()->shared(); |
240 SnapshotObjectId id = ids_->FindOrAddEntry( | 251 SnapshotObjectId id = ids_->FindOrAddEntry( |
241 shared->address(), shared->Size(), false); | 252 shared->address(), shared->Size(), false); |
242 allocation_trace_buffer_[length++] = AddFunctionInfo(shared, id); | 253 allocation_trace_buffer_[length++] = AddFunctionInfo(shared, id); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
333 void AllocationTracker::UnresolvedLocation::HandleWeakScript( | 344 void AllocationTracker::UnresolvedLocation::HandleWeakScript( |
334 const v8::WeakCallbackData<v8::Value, void>& data) { | 345 const v8::WeakCallbackData<v8::Value, void>& data) { |
335 UnresolvedLocation* loc = | 346 UnresolvedLocation* loc = |
336 reinterpret_cast<UnresolvedLocation*>(data.GetParameter()); | 347 reinterpret_cast<UnresolvedLocation*>(data.GetParameter()); |
337 GlobalHandles::Destroy(reinterpret_cast<Object**>(loc->script_.location())); | 348 GlobalHandles::Destroy(reinterpret_cast<Object**>(loc->script_.location())); |
338 loc->script_ = Handle<Script>::null(); | 349 loc->script_ = Handle<Script>::null(); |
339 } | 350 } |
340 | 351 |
341 | 352 |
342 } } // namespace v8::internal | 353 } } // namespace v8::internal |
OLD | NEW |