| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/profiler/sampling-heap-profiler.h" | 5 #include "src/profiler/sampling-heap-profiler.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include "src/api.h" | 9 #include "src/api.h" |
| 10 #include "src/base/ieee754.h" | 10 #include "src/base/ieee754.h" |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 for (auto it : node->children_) { | 252 for (auto it : node->children_) { |
| 253 current->children.push_back( | 253 current->children.push_back( |
| 254 TranslateAllocationNode(profile, it.second, scripts)); | 254 TranslateAllocationNode(profile, it.second, scripts)); |
| 255 } | 255 } |
| 256 node->pinned_ = false; | 256 node->pinned_ = false; |
| 257 return current; | 257 return current; |
| 258 } | 258 } |
| 259 | 259 |
| 260 v8::AllocationProfile* SamplingHeapProfiler::GetAllocationProfile() { | 260 v8::AllocationProfile* SamplingHeapProfiler::GetAllocationProfile() { |
| 261 if (flags_ & v8::HeapProfiler::kSamplingForceGC) { | 261 if (flags_ & v8::HeapProfiler::kSamplingForceGC) { |
| 262 isolate_->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 262 isolate_->heap()->CollectAllGarbage( |
| 263 "SamplingHeapProfiler"); | 263 Heap::kNoGCFlags, GarbageCollectionReason::kSamplingProfiler); |
| 264 } | 264 } |
| 265 // To resolve positions to line/column numbers, we will need to look up | 265 // To resolve positions to line/column numbers, we will need to look up |
| 266 // scripts. Build a map to allow fast mapping from script id to script. | 266 // scripts. Build a map to allow fast mapping from script id to script. |
| 267 std::map<int, Handle<Script>> scripts; | 267 std::map<int, Handle<Script>> scripts; |
| 268 { | 268 { |
| 269 Script::Iterator iterator(isolate_); | 269 Script::Iterator iterator(isolate_); |
| 270 while (Script* script = iterator.Next()) { | 270 while (Script* script = iterator.Next()) { |
| 271 scripts[script->id()] = handle(script); | 271 scripts[script->id()] = handle(script); |
| 272 } | 272 } |
| 273 } | 273 } |
| 274 auto profile = new v8::internal::AllocationProfile(); | 274 auto profile = new v8::internal::AllocationProfile(); |
| 275 TranslateAllocationNode(profile, &profile_root_, scripts); | 275 TranslateAllocationNode(profile, &profile_root_, scripts); |
| 276 return profile; | 276 return profile; |
| 277 } | 277 } |
| 278 | 278 |
| 279 | 279 |
| 280 } // namespace internal | 280 } // namespace internal |
| 281 } // namespace v8 | 281 } // namespace v8 |
| OLD | NEW |