Chromium Code Reviews| 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(end, trace_node_id); | |
| 148 ranges_.insert(RangeMap::value_type(start, new_range)); | |
|
alph
2014/03/06 14:43:18
I have a feeling that using the 'end' address as a
yurys
2014/03/06 15:38:49
Good point, thank you! I rewrote this part to use
| |
| 149 } | |
| 150 | |
| 151 | |
| 152 unsigned AddressToTraceMap::GetTraceNodeId(Address addr) { | |
| 153 RangeMap::const_iterator it = ranges_.lower_bound(addr); | |
| 154 if (it == ranges_.end()) { | |
| 155 if (it == ranges_.begin()) return 0; | |
| 156 --it; | |
| 157 if (it->first <= addr && addr < it->second.end) { | |
|
alph
2014/03/06 14:43:18
it->first <= addr seems to be always true.
yurys
2014/03/06 15:38:49
This code is gone.
| |
| 158 return it->second.trace_node_id; | |
| 159 } | |
| 160 return 0; | |
| 161 } | |
| 162 | |
| 163 if (it->first == addr) return it->second.trace_node_id; | |
|
alph
2014/03/06 14:43:18
if you use upper_bound instead you won't need to d
yurys
2014/03/06 15:38:49
Done.
| |
| 164 if (it == ranges_.begin()) return 0; | |
| 165 --it; | |
| 166 if (it->first <= addr && addr < it->second.end) { | |
|
alph
2014/03/06 14:43:18
ditto for it->first <= addr
yurys
2014/03/06 15:38:49
Done.
| |
| 167 return it->second.trace_node_id; | |
| 168 } | |
| 169 return 0; | |
| 170 } | |
| 171 | |
| 172 | |
| 173 void AddressToTraceMap::MoveObject(Address from, Address to, int size) { | |
| 174 unsigned trace_node_id = GetTraceNodeId(from); | |
| 175 if (trace_node_id == 0) return; | |
| 176 RemoveRange(from, from + size); | |
| 177 AddRange(to, size, trace_node_id); | |
| 178 } | |
| 179 | |
| 180 | |
| 181 void AddressToTraceMap::Clear() { | |
| 182 ranges_.clear(); | |
| 183 } | |
| 184 | |
| 185 | |
| 186 void AddressToTraceMap::Print() { | |
| 187 PrintF("[AddressToTraceMap (%lu): \n", ranges_.size()); | |
| 188 for (RangeMap::iterator it = ranges_.begin(); it != ranges_.end(); ++it) { | |
| 189 PrintF("[%p - %p] => %u\n", it->first, it->second.end, | |
| 190 it->second.trace_node_id); | |
| 191 } | |
| 192 PrintF("]\n"); | |
| 193 } | |
| 194 | |
| 195 | |
| 196 void AddressToTraceMap::RemoveRange(Address start, Address end) { | |
| 197 RangeMap::iterator it = ranges_.upper_bound(start); | |
| 198 | |
| 199 Address next_range_start = 0; | |
| 200 RangeStack next_range(0, 0); | |
| 201 | |
| 202 RangeMap::iterator to_remove_begin = it; | |
| 203 if (it != ranges_.begin()) { | |
| 204 --it; | |
| 205 RangeStack& value = it->second; | |
| 206 if (value.end > start) { | |
| 207 if (value.end > end) { | |
| 208 next_range_start = end; | |
| 209 next_range = value; | |
| 210 } | |
| 211 if (it->first == start) { | |
| 212 to_remove_begin = it; | |
| 213 } else { | |
| 214 value.end = start; | |
| 215 } | |
| 216 } | |
| 217 ++it; | |
| 218 } | |
| 219 | |
| 220 while (it != ranges_.end() && it->first < end) { | |
|
alph
2014/03/06 14:43:18
extra space
yurys
2014/03/06 15:38:49
Done.
| |
| 221 if (it->second.end > end) { | |
| 222 next_range_start = end; | |
| 223 next_range = it->second; | |
| 224 } | |
| 225 ++it; | |
| 226 } | |
| 227 ranges_.erase(to_remove_begin, it); | |
| 228 | |
| 229 if (next_range_start != 0) { | |
| 230 ranges_.insert(RangeMap::value_type(next_range_start, next_range)); | |
| 231 } | |
| 232 } | |
| 233 | |
| 234 | |
| 142 static bool AddressesMatch(void* key1, void* key2) { | 235 static bool AddressesMatch(void* key1, void* key2) { |
| 143 return key1 == key2; | 236 return key1 == key2; |
| 144 } | 237 } |
| 145 | 238 |
| 146 | 239 |
| 147 void AllocationTracker::DeleteFunctionInfo(FunctionInfo** info) { | 240 void AllocationTracker::DeleteFunctionInfo(FunctionInfo** info) { |
| 148 delete *info; | 241 delete *info; |
| 149 } | 242 } |
| 150 | 243 |
| 151 | 244 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 201 } | 294 } |
| 202 if (length == 0) { | 295 if (length == 0) { |
| 203 unsigned index = functionInfoIndexForVMState(isolate->current_vm_state()); | 296 unsigned index = functionInfoIndexForVMState(isolate->current_vm_state()); |
| 204 if (index != 0) { | 297 if (index != 0) { |
| 205 allocation_trace_buffer_[length++] = index; | 298 allocation_trace_buffer_[length++] = index; |
| 206 } | 299 } |
| 207 } | 300 } |
| 208 AllocationTraceNode* top_node = trace_tree_.AddPathFromEnd( | 301 AllocationTraceNode* top_node = trace_tree_.AddPathFromEnd( |
| 209 Vector<unsigned>(allocation_trace_buffer_, length)); | 302 Vector<unsigned>(allocation_trace_buffer_, length)); |
| 210 top_node->AddAllocation(size); | 303 top_node->AddAllocation(size); |
| 304 | |
| 305 address_to_trace_.AddRange(addr, size, top_node->id()); | |
| 211 } | 306 } |
| 212 | 307 |
| 213 | 308 |
| 214 static uint32_t SnapshotObjectIdHash(SnapshotObjectId id) { | 309 static uint32_t SnapshotObjectIdHash(SnapshotObjectId id) { |
| 215 return ComputeIntegerHash(static_cast<uint32_t>(id), | 310 return ComputeIntegerHash(static_cast<uint32_t>(id), |
| 216 v8::internal::kZeroHashSeed); | 311 v8::internal::kZeroHashSeed); |
| 217 } | 312 } |
| 218 | 313 |
| 219 | 314 |
| 220 unsigned AllocationTracker::AddFunctionInfo(SharedFunctionInfo* shared, | 315 unsigned AllocationTracker::AddFunctionInfo(SharedFunctionInfo* shared, |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 288 void AllocationTracker::UnresolvedLocation::HandleWeakScript( | 383 void AllocationTracker::UnresolvedLocation::HandleWeakScript( |
| 289 const v8::WeakCallbackData<v8::Value, void>& data) { | 384 const v8::WeakCallbackData<v8::Value, void>& data) { |
| 290 UnresolvedLocation* loc = | 385 UnresolvedLocation* loc = |
| 291 reinterpret_cast<UnresolvedLocation*>(data.GetParameter()); | 386 reinterpret_cast<UnresolvedLocation*>(data.GetParameter()); |
| 292 GlobalHandles::Destroy(reinterpret_cast<Object**>(loc->script_.location())); | 387 GlobalHandles::Destroy(reinterpret_cast<Object**>(loc->script_.location())); |
| 293 loc->script_ = Handle<Script>::null(); | 388 loc->script_ = Handle<Script>::null(); |
| 294 } | 389 } |
| 295 | 390 |
| 296 | 391 |
| 297 } } // namespace v8::internal | 392 } } // namespace v8::internal |
| OLD | NEW |