Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(321)

Side by Side Diff: Source/bindings/v8/V8GCController.cpp

Issue 23444025: Remove calls to to-be-deprecated Persistent functions. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/bindings/v8/ScriptWrappable.h ('k') | Source/bindings/v8/V8ValueCache.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 if (nodeIterator == nodeIteratorEnd) 202 if (nodeIterator == nodeIteratorEnd)
203 return; 203 return;
204 v8::UniqueId id(reinterpret_cast<intptr_t>((*nodeIterator)->unsafePersis tent().value())); 204 v8::UniqueId id(reinterpret_cast<intptr_t>((*nodeIterator)->unsafePersis tent().value()));
205 for (; nodeIterator != nodeIteratorEnd; ++nodeIterator) { 205 for (; nodeIterator != nodeIteratorEnd; ++nodeIterator) {
206 // This is safe because we know that GC won't happen before we 206 // This is safe because we know that GC won't happen before we
207 // dispose the UnsafePersistent (we're just preparing a GC). Though, 207 // dispose the UnsafePersistent (we're just preparing a GC). Though,
208 // we need to keep the UnsafePersistent alive until we're done with 208 // we need to keep the UnsafePersistent alive until we're done with
209 // v8::Persistent. 209 // v8::Persistent.
210 UnsafePersistent<v8::Object> unsafeWrapper = (*nodeIterator)->unsafe Persistent(); 210 UnsafePersistent<v8::Object> unsafeWrapper = (*nodeIterator)->unsafe Persistent();
211 v8::Persistent<v8::Object>* wrapper = unsafeWrapper.persistent(); 211 v8::Persistent<v8::Object>* wrapper = unsafeWrapper.persistent();
212 wrapper->MarkPartiallyDependent(isolate); 212 wrapper->MarkPartiallyDependent();
213 // FIXME: update this to use the upcasting function which v8 will pr ovide 213 // FIXME: update this to use the upcasting function which v8 will pr ovide
214 v8::Persistent<v8::Value>* value = reinterpret_cast<v8::Persistent<v 8::Value>*>(wrapper); 214 v8::Persistent<v8::Value>* value = reinterpret_cast<v8::Persistent<v 8::Value>*>(wrapper);
215 isolate->SetObjectGroupId(*value, id); 215 isolate->SetObjectGroupId(*value, id);
216 } 216 }
217 } 217 }
218 218
219 Vector<Node*> m_nodesInNewSpace; 219 Vector<Node*> m_nodesInNewSpace;
220 v8::Isolate* m_isolate; 220 v8::Isolate* m_isolate;
221 }; 221 };
222 222
(...skipping 12 matching lines...) Expand all
235 // during the GC prologue. 235 // during the GC prologue.
236 ASSERT((*reinterpret_cast<v8::Handle<v8::Value>*>(value))->IsObject()); 236 ASSERT((*reinterpret_cast<v8::Handle<v8::Value>*>(value))->IsObject());
237 237
238 if (classId != v8DOMNodeClassId && classId != v8DOMObjectClassId) 238 if (classId != v8DOMNodeClassId && classId != v8DOMObjectClassId)
239 return; 239 return;
240 240
241 v8::Handle<v8::Object>* wrapper = reinterpret_cast<v8::Handle<v8::Object >*>(value); 241 v8::Handle<v8::Object>* wrapper = reinterpret_cast<v8::Handle<v8::Object >*>(value);
242 242
243 ASSERT(V8DOMWrapper::maybeDOMWrapper(*wrapper)); 243 ASSERT(V8DOMWrapper::maybeDOMWrapper(*wrapper));
244 244
245 if (value->IsIndependent(m_isolate)) 245 if (value->IsIndependent())
246 return; 246 return;
247 247
248 WrapperTypeInfo* type = toWrapperTypeInfo(*wrapper); 248 WrapperTypeInfo* type = toWrapperTypeInfo(*wrapper);
249 void* object = toNative(*wrapper); 249 void* object = toNative(*wrapper);
250 250
251 if (V8MessagePort::info.equals(type)) { 251 if (V8MessagePort::info.equals(type)) {
252 // Mark each port as in-use if it's entangled. For simplicity's sake , 252 // Mark each port as in-use if it's entangled. For simplicity's sake ,
253 // we assume all ports are remotely entangled, since the Chromium po rt 253 // we assume all ports are remotely entangled, since the Chromium po rt
254 // implementation can't tell the difference. 254 // implementation can't tell the difference.
255 MessagePort* port = static_cast<MessagePort*>(object); 255 MessagePort* port = static_cast<MessagePort*>(object);
256 if (port->isEntangled() || port->hasPendingActivity()) 256 if (port->isEntangled() || port->hasPendingActivity())
257 m_isolate->SetObjectGroupId(*value, liveRootId()); 257 m_isolate->SetObjectGroupId(*value, liveRootId());
258 } else if (V8MutationObserver::info.equals(type)) { 258 } else if (V8MutationObserver::info.equals(type)) {
259 // FIXME: Allow opaqueRootForGC to operate on multiple roots and mov e this logic into V8MutationObserverCustom. 259 // FIXME: Allow opaqueRootForGC to operate on multiple roots and mov e this logic into V8MutationObserverCustom.
260 MutationObserver* observer = static_cast<MutationObserver*>(object); 260 MutationObserver* observer = static_cast<MutationObserver*>(object);
261 HashSet<Node*> observedNodes = observer->getObservedNodes(); 261 HashSet<Node*> observedNodes = observer->getObservedNodes();
262 for (HashSet<Node*>::iterator it = observedNodes.begin(); it != obse rvedNodes.end(); ++it) { 262 for (HashSet<Node*>::iterator it = observedNodes.begin(); it != obse rvedNodes.end(); ++it) {
263 v8::UniqueId id(reinterpret_cast<intptr_t>(V8GCController::opaqu eRootForGC(*it, m_isolate))); 263 v8::UniqueId id(reinterpret_cast<intptr_t>(V8GCController::opaqu eRootForGC(*it, m_isolate)));
264 m_isolate->SetReferenceFromGroup(id, *value); 264 m_isolate->SetReferenceFromGroup(id, *value);
265 } 265 }
266 } else { 266 } else {
267 ActiveDOMObject* activeDOMObject = type->toActiveDOMObject(*wrapper) ; 267 ActiveDOMObject* activeDOMObject = type->toActiveDOMObject(*wrapper) ;
268 if (activeDOMObject && activeDOMObject->hasPendingActivity()) 268 if (activeDOMObject && activeDOMObject->hasPendingActivity())
269 m_isolate->SetObjectGroupId(*value, liveRootId()); 269 m_isolate->SetObjectGroupId(*value, liveRootId());
270 } 270 }
271 271
272 if (classId == v8DOMNodeClassId) { 272 if (classId == v8DOMNodeClassId) {
273 UNUSED_PARAM(m_isolate); 273 UNUSED_PARAM(m_isolate);
274 ASSERT(V8Node::HasInstanceInAnyWorld(*wrapper, m_isolate)); 274 ASSERT(V8Node::HasInstanceInAnyWorld(*wrapper, m_isolate));
275 ASSERT(!value->IsIndependent(m_isolate)); 275 ASSERT(!value->IsIndependent());
276 276
277 Node* node = static_cast<Node*>(object); 277 Node* node = static_cast<Node*>(object);
278 278
279 if (node->hasEventListeners()) 279 if (node->hasEventListeners())
280 addReferencesForNodeWithEventListeners(m_isolate, node, v8::Pers istent<v8::Object>::Cast(*value)); 280 addReferencesForNodeWithEventListeners(m_isolate, node, v8::Pers istent<v8::Object>::Cast(*value));
281 Node* root = V8GCController::opaqueRootForGC(node, m_isolate); 281 Node* root = V8GCController::opaqueRootForGC(node, m_isolate);
282 m_isolate->SetObjectGroupId(*value, v8::UniqueId(reinterpret_cast<in tptr_t>(root))); 282 m_isolate->SetObjectGroupId(*value, v8::UniqueId(reinterpret_cast<in tptr_t>(root)));
283 if (m_constructRetainedObjectInfos) 283 if (m_constructRetainedObjectInfos)
284 m_groupsWhichNeedRetainerInfo.append(root); 284 m_groupsWhichNeedRetainerInfo.append(root);
285 } else if (classId == v8DOMObjectClassId) { 285 } else if (classId == v8DOMObjectClassId) {
286 ASSERT(!value->IsIndependent(m_isolate)); 286 ASSERT(!value->IsIndependent());
287 void* root = type->opaqueRootForGC(object, m_isolate); 287 void* root = type->opaqueRootForGC(object, m_isolate);
288 m_isolate->SetObjectGroupId(*value, v8::UniqueId(reinterpret_cast<in tptr_t>(root))); 288 m_isolate->SetObjectGroupId(*value, v8::UniqueId(reinterpret_cast<in tptr_t>(root)));
289 } else { 289 } else {
290 ASSERT_NOT_REACHED(); 290 ASSERT_NOT_REACHED();
291 } 291 }
292 } 292 }
293 293
294 void notifyFinished() 294 void notifyFinished()
295 { 295 {
296 if (!m_constructRetainedObjectInfos) 296 if (!m_constructRetainedObjectInfos)
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 { 414 {
415 v8::HandleScope handleScope(isolate); 415 v8::HandleScope handleScope(isolate);
416 v8::Local<v8::Context> context = v8::Context::New(isolate); 416 v8::Local<v8::Context> context = v8::Context::New(isolate);
417 if (context.IsEmpty()) 417 if (context.IsEmpty())
418 return; 418 return;
419 v8::Context::Scope contextScope(context); 419 v8::Context::Scope contextScope(context);
420 V8ScriptRunner::compileAndRunInternalScript(v8String("if (gc) gc();", isolat e), isolate); 420 V8ScriptRunner::compileAndRunInternalScript(v8String("if (gc) gc();", isolat e), isolate);
421 } 421 }
422 422
423 } // namespace WebCore 423 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/ScriptWrappable.h ('k') | Source/bindings/v8/V8ValueCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698