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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 } | 239 } |
240 } | 240 } |
241 | 241 |
242 | 242 |
243 AllocationTracker::UnresolvedLocation::UnresolvedLocation( | 243 AllocationTracker::UnresolvedLocation::UnresolvedLocation( |
244 Script* script, int start, FunctionInfo* info) | 244 Script* script, int start, FunctionInfo* info) |
245 : start_position_(start), | 245 : start_position_(start), |
246 info_(info) { | 246 info_(info) { |
247 script_ = Handle<Script>::cast( | 247 script_ = Handle<Script>::cast( |
248 script->GetIsolate()->global_handles()->Create(script)); | 248 script->GetIsolate()->global_handles()->Create(script)); |
249 GlobalHandles::MakeWeak( | 249 GlobalHandles::MakeWeak(reinterpret_cast<Object**>(script_.location()), |
250 reinterpret_cast<Object**>(script_.location()), | 250 this, |
251 this, &HandleWeakScript); | 251 &HandleWeakScript); |
252 } | 252 } |
253 | 253 |
254 | 254 |
255 AllocationTracker::UnresolvedLocation::~UnresolvedLocation() { | 255 AllocationTracker::UnresolvedLocation::~UnresolvedLocation() { |
256 if (!script_.is_null()) { | 256 if (!script_.is_null()) { |
257 script_->GetIsolate()->global_handles()->Destroy( | 257 GlobalHandles::Destroy(reinterpret_cast<Object**>(script_.location())); |
258 reinterpret_cast<Object**>(script_.location())); | |
259 } | 258 } |
260 } | 259 } |
261 | 260 |
262 | 261 |
263 void AllocationTracker::UnresolvedLocation::Resolve() { | 262 void AllocationTracker::UnresolvedLocation::Resolve() { |
264 if (script_.is_null()) return; | 263 if (script_.is_null()) return; |
265 info_->line = GetScriptLineNumber(script_, start_position_); | 264 info_->line = GetScriptLineNumber(script_, start_position_); |
266 info_->column = GetScriptColumnNumber(script_, start_position_); | 265 info_->column = GetScriptColumnNumber(script_, start_position_); |
267 } | 266 } |
268 | 267 |
269 | 268 |
270 void AllocationTracker::UnresolvedLocation::HandleWeakScript( | 269 void AllocationTracker::UnresolvedLocation::HandleWeakScript( |
271 v8::Isolate* isolate, | 270 const v8::WeakCallbackData<v8::Value, void>& data) { |
272 v8::Persistent<v8::Value>* obj, | 271 UnresolvedLocation* loc = |
273 void* data) { | 272 reinterpret_cast<UnresolvedLocation*>(data.GetParameter()); |
274 UnresolvedLocation* location = reinterpret_cast<UnresolvedLocation*>(data); | 273 GlobalHandles::Destroy(reinterpret_cast<Object**>(loc->script_.location())); |
275 location->script_ = Handle<Script>::null(); | 274 loc->script_ = Handle<Script>::null(); |
276 obj->Reset(); | |
277 } | 275 } |
278 | 276 |
279 | 277 |
280 } } // namespace v8::internal | 278 } } // namespace v8::internal |
OLD | NEW |