| 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/profiler/allocation-tracker.h" | 5 #include "src/profiler/allocation-tracker.h" |
| 6 | 6 |
| 7 #include "src/frames-inl.h" | 7 #include "src/frames-inl.h" |
| 8 #include "src/objects-inl.h" | 8 #include "src/objects-inl.h" |
| 9 #include "src/profiler/heap-snapshot-generator-inl.h" | 9 #include "src/profiler/heap-snapshot-generator-inl.h" |
| 10 | 10 |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 return info_index_for_other_state_; | 299 return info_index_for_other_state_; |
| 300 } | 300 } |
| 301 | 301 |
| 302 | 302 |
| 303 AllocationTracker::UnresolvedLocation::UnresolvedLocation( | 303 AllocationTracker::UnresolvedLocation::UnresolvedLocation( |
| 304 Script* script, int start, FunctionInfo* info) | 304 Script* script, int start, FunctionInfo* info) |
| 305 : start_position_(start), | 305 : start_position_(start), |
| 306 info_(info) { | 306 info_(info) { |
| 307 script_ = Handle<Script>::cast( | 307 script_ = Handle<Script>::cast( |
| 308 script->GetIsolate()->global_handles()->Create(script)); | 308 script->GetIsolate()->global_handles()->Create(script)); |
| 309 GlobalHandles::MakeWeak(reinterpret_cast<Object**>(script_.location()), | 309 GlobalHandles::MakeWeak(reinterpret_cast<Object**>(script_.location()), this, |
| 310 this, | 310 &HandleWeakScript, v8::WeakCallbackType::kParameter); |
| 311 &HandleWeakScript); | |
| 312 } | 311 } |
| 313 | 312 |
| 314 | 313 |
| 315 AllocationTracker::UnresolvedLocation::~UnresolvedLocation() { | 314 AllocationTracker::UnresolvedLocation::~UnresolvedLocation() { |
| 316 if (!script_.is_null()) { | 315 if (!script_.is_null()) { |
| 317 GlobalHandles::Destroy(reinterpret_cast<Object**>(script_.location())); | 316 GlobalHandles::Destroy(reinterpret_cast<Object**>(script_.location())); |
| 318 } | 317 } |
| 319 } | 318 } |
| 320 | 319 |
| 321 | 320 |
| 322 void AllocationTracker::UnresolvedLocation::Resolve() { | 321 void AllocationTracker::UnresolvedLocation::Resolve() { |
| 323 if (script_.is_null()) return; | 322 if (script_.is_null()) return; |
| 324 HandleScope scope(script_->GetIsolate()); | 323 HandleScope scope(script_->GetIsolate()); |
| 325 info_->line = Script::GetLineNumber(script_, start_position_); | 324 info_->line = Script::GetLineNumber(script_, start_position_); |
| 326 info_->column = Script::GetColumnNumber(script_, start_position_); | 325 info_->column = Script::GetColumnNumber(script_, start_position_); |
| 327 } | 326 } |
| 328 | 327 |
| 329 | |
| 330 void AllocationTracker::UnresolvedLocation::HandleWeakScript( | 328 void AllocationTracker::UnresolvedLocation::HandleWeakScript( |
| 331 const v8::WeakCallbackData<v8::Value, void>& data) { | 329 const v8::WeakCallbackInfo<void>& data) { |
| 332 UnresolvedLocation* loc = | 330 UnresolvedLocation* loc = |
| 333 reinterpret_cast<UnresolvedLocation*>(data.GetParameter()); | 331 reinterpret_cast<UnresolvedLocation*>(data.GetParameter()); |
| 334 GlobalHandles::Destroy(reinterpret_cast<Object**>(loc->script_.location())); | 332 GlobalHandles::Destroy(reinterpret_cast<Object**>(loc->script_.location())); |
| 335 loc->script_ = Handle<Script>::null(); | 333 loc->script_ = Handle<Script>::null(); |
| 336 } | 334 } |
| 337 | 335 |
| 338 | 336 |
| 339 } // namespace internal | 337 } // namespace internal |
| 340 } // namespace v8 | 338 } // namespace v8 |
| OLD | NEW |