OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 AllocationTracker::FunctionInfo::FunctionInfo() | 132 AllocationTracker::FunctionInfo::FunctionInfo() |
133 : name(""), | 133 : name(""), |
134 function_id(0), | 134 function_id(0), |
135 script_name(""), | 135 script_name(""), |
136 script_id(0), | 136 script_id(0), |
137 line(-1), | 137 line(-1), |
138 column(-1) { | 138 column(-1) { |
139 } | 139 } |
140 | 140 |
141 | 141 |
| 142 void AddressToTraceMap::AddRange(Address start, int size, |
| 143 unsigned trace_node_id) { |
| 144 Address end = start + size; |
| 145 RemoveRange(start, end); |
| 146 |
| 147 RangeStack new_range(start, trace_node_id); |
| 148 ranges_.insert(RangeMap::value_type(end, new_range)); |
| 149 } |
| 150 |
| 151 |
| 152 unsigned AddressToTraceMap::GetTraceNodeId(Address addr) { |
| 153 RangeMap::const_iterator it = ranges_.upper_bound(addr); |
| 154 if (it == ranges_.end()) return 0; |
| 155 if (it->second.start <= addr) { |
| 156 return it->second.trace_node_id; |
| 157 } |
| 158 return 0; |
| 159 } |
| 160 |
| 161 |
| 162 void AddressToTraceMap::MoveObject(Address from, Address to, int size) { |
| 163 unsigned trace_node_id = GetTraceNodeId(from); |
| 164 if (trace_node_id == 0) return; |
| 165 RemoveRange(from, from + size); |
| 166 AddRange(to, size, trace_node_id); |
| 167 } |
| 168 |
| 169 |
| 170 void AddressToTraceMap::Clear() { |
| 171 ranges_.clear(); |
| 172 } |
| 173 |
| 174 |
| 175 void AddressToTraceMap::Print() { |
| 176 PrintF("[AddressToTraceMap (%lu): \n", ranges_.size()); |
| 177 for (RangeMap::iterator it = ranges_.begin(); it != ranges_.end(); ++it) { |
| 178 PrintF("[%p - %p] => %u\n", it->second.start, it->first, |
| 179 it->second.trace_node_id); |
| 180 } |
| 181 PrintF("]\n"); |
| 182 } |
| 183 |
| 184 |
| 185 void AddressToTraceMap::RemoveRange(Address start, Address end) { |
| 186 RangeMap::iterator it = ranges_.upper_bound(start); |
| 187 if (it == ranges_.end()) return; |
| 188 |
| 189 RangeStack prev_range(0, 0); |
| 190 |
| 191 RangeMap::iterator to_remove_begin = it; |
| 192 if (it->second.start < start) { |
| 193 prev_range = it->second; |
| 194 } |
| 195 do { |
| 196 if (it->first > end) { |
| 197 if (it->second.start < end) { |
| 198 it->second.start = end; |
| 199 } |
| 200 break; |
| 201 } |
| 202 ++it; |
| 203 } |
| 204 while (it != ranges_.end()); |
| 205 |
| 206 ranges_.erase(to_remove_begin, it); |
| 207 |
| 208 if (prev_range.start != 0) { |
| 209 ranges_.insert(RangeMap::value_type(start, prev_range)); |
| 210 } |
| 211 } |
| 212 |
| 213 |
142 static bool AddressesMatch(void* key1, void* key2) { | 214 static bool AddressesMatch(void* key1, void* key2) { |
143 return key1 == key2; | 215 return key1 == key2; |
144 } | 216 } |
145 | 217 |
146 | 218 |
147 void AllocationTracker::DeleteFunctionInfo(FunctionInfo** info) { | 219 void AllocationTracker::DeleteFunctionInfo(FunctionInfo** info) { |
148 delete *info; | 220 delete *info; |
149 } | 221 } |
150 | 222 |
151 | 223 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 } | 273 } |
202 if (length == 0) { | 274 if (length == 0) { |
203 unsigned index = functionInfoIndexForVMState(isolate->current_vm_state()); | 275 unsigned index = functionInfoIndexForVMState(isolate->current_vm_state()); |
204 if (index != 0) { | 276 if (index != 0) { |
205 allocation_trace_buffer_[length++] = index; | 277 allocation_trace_buffer_[length++] = index; |
206 } | 278 } |
207 } | 279 } |
208 AllocationTraceNode* top_node = trace_tree_.AddPathFromEnd( | 280 AllocationTraceNode* top_node = trace_tree_.AddPathFromEnd( |
209 Vector<unsigned>(allocation_trace_buffer_, length)); | 281 Vector<unsigned>(allocation_trace_buffer_, length)); |
210 top_node->AddAllocation(size); | 282 top_node->AddAllocation(size); |
| 283 |
| 284 address_to_trace_.AddRange(addr, size, top_node->id()); |
211 } | 285 } |
212 | 286 |
213 | 287 |
214 static uint32_t SnapshotObjectIdHash(SnapshotObjectId id) { | 288 static uint32_t SnapshotObjectIdHash(SnapshotObjectId id) { |
215 return ComputeIntegerHash(static_cast<uint32_t>(id), | 289 return ComputeIntegerHash(static_cast<uint32_t>(id), |
216 v8::internal::kZeroHashSeed); | 290 v8::internal::kZeroHashSeed); |
217 } | 291 } |
218 | 292 |
219 | 293 |
220 unsigned AllocationTracker::AddFunctionInfo(SharedFunctionInfo* shared, | 294 unsigned AllocationTracker::AddFunctionInfo(SharedFunctionInfo* shared, |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 void AllocationTracker::UnresolvedLocation::HandleWeakScript( | 362 void AllocationTracker::UnresolvedLocation::HandleWeakScript( |
289 const v8::WeakCallbackData<v8::Value, void>& data) { | 363 const v8::WeakCallbackData<v8::Value, void>& data) { |
290 UnresolvedLocation* loc = | 364 UnresolvedLocation* loc = |
291 reinterpret_cast<UnresolvedLocation*>(data.GetParameter()); | 365 reinterpret_cast<UnresolvedLocation*>(data.GetParameter()); |
292 GlobalHandles::Destroy(reinterpret_cast<Object**>(loc->script_.location())); | 366 GlobalHandles::Destroy(reinterpret_cast<Object**>(loc->script_.location())); |
293 loc->script_ = Handle<Script>::null(); | 367 loc->script_ = Handle<Script>::null(); |
294 } | 368 } |
295 | 369 |
296 | 370 |
297 } } // namespace v8::internal | 371 } } // namespace v8::internal |
OLD | NEW |