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

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

Issue 456683002: bindings: Introduces type-check for the internal pointers. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Synced. Created 6 years, 4 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/core/v8/V8DOMWrapper.cpp ('k') | Source/bindings/core/v8/V8NPObject.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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 // Casting to a Handle is safe here, since the Persistent doesn't get GC d 258 // Casting to a Handle is safe here, since the Persistent doesn't get GC d
259 // during the GC prologue. 259 // during the GC prologue.
260 ASSERT((*reinterpret_cast<v8::Handle<v8::Value>*>(value))->IsObject()); 260 ASSERT((*reinterpret_cast<v8::Handle<v8::Value>*>(value))->IsObject());
261 v8::Handle<v8::Object>* wrapper = reinterpret_cast<v8::Handle<v8::Object >*>(value); 261 v8::Handle<v8::Object>* wrapper = reinterpret_cast<v8::Handle<v8::Object >*>(value);
262 ASSERT(V8DOMWrapper::isDOMWrapper(*wrapper)); 262 ASSERT(V8DOMWrapper::isDOMWrapper(*wrapper));
263 263
264 if (value->IsIndependent()) 264 if (value->IsIndependent())
265 return; 265 return;
266 266
267 const WrapperTypeInfo* type = toWrapperTypeInfo(*wrapper); 267 const WrapperTypeInfo* type = toWrapperTypeInfo(*wrapper);
268 void* object = toNative(*wrapper);
269 268
270 ActiveDOMObject* activeDOMObject = type->toActiveDOMObject(*wrapper); 269 ActiveDOMObject* activeDOMObject = type->toActiveDOMObject(*wrapper);
271 if (activeDOMObject && activeDOMObject->hasPendingActivity()) 270 if (activeDOMObject && activeDOMObject->hasPendingActivity())
272 m_isolate->SetObjectGroupId(*value, liveRootId()); 271 m_isolate->SetObjectGroupId(*value, liveRootId());
273 272
274 if (classId == v8DOMNodeClassId) { 273 if (classId == v8DOMNodeClassId) {
275 ASSERT(V8Node::hasInstance(*wrapper, m_isolate)); 274 ASSERT(V8Node::hasInstance(*wrapper, m_isolate));
276 Node* node = static_cast<Node*>(object); 275 Node* node = V8Node::toNative(*wrapper);
277 if (node->hasEventListeners()) 276 if (node->hasEventListeners())
278 addReferencesForNodeWithEventListeners(m_isolate, node, v8::Pers istent<v8::Object>::Cast(*value)); 277 addReferencesForNodeWithEventListeners(m_isolate, node, v8::Pers istent<v8::Object>::Cast(*value));
279 Node* root = V8GCController::opaqueRootForGC(node, m_isolate); 278 Node* root = V8GCController::opaqueRootForGC(node, m_isolate);
280 m_isolate->SetObjectGroupId(*value, v8::UniqueId(reinterpret_cast<in tptr_t>(root))); 279 m_isolate->SetObjectGroupId(*value, v8::UniqueId(reinterpret_cast<in tptr_t>(root)));
281 if (m_constructRetainedObjectInfos) 280 if (m_constructRetainedObjectInfos)
282 m_groupsWhichNeedRetainerInfo.append(root); 281 m_groupsWhichNeedRetainerInfo.append(root);
283 } else if (classId == v8DOMObjectClassId) { 282 } else if (classId == v8DOMObjectClassId) {
284 type->visitDOMWrapper(object, v8::Persistent<v8::Object>::Cast(*valu e), m_isolate); 283 type->visitDOMWrapper(toInternalPointer(*wrapper), v8::Persistent<v8 ::Object>::Cast(*value), m_isolate);
285 } else { 284 } else {
286 ASSERT_NOT_REACHED(); 285 ASSERT_NOT_REACHED();
287 } 286 }
288 } 287 }
289 288
290 void notifyFinished() 289 void notifyFinished()
291 { 290 {
292 if (!m_constructRetainedObjectInfos) 291 if (!m_constructRetainedObjectInfos)
293 return; 292 return;
294 std::sort(m_groupsWhichNeedRetainerInfo.begin(), m_groupsWhichNeedRetain erInfo.end()); 293 std::sort(m_groupsWhichNeedRetainerInfo.begin(), m_groupsWhichNeedRetain erInfo.end());
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 static size_t lastUsageReportedToV8 = 0; 448 static size_t lastUsageReportedToV8 = 0;
450 449
451 size_t currentUsage = Partitions::currentDOMMemoryUsage(); 450 size_t currentUsage = Partitions::currentDOMMemoryUsage();
452 int64_t diff = static_cast<int64_t>(currentUsage) - static_cast<int64_t>(las tUsageReportedToV8); 451 int64_t diff = static_cast<int64_t>(currentUsage) - static_cast<int64_t>(las tUsageReportedToV8);
453 isolate->AdjustAmountOfExternalAllocatedMemory(diff); 452 isolate->AdjustAmountOfExternalAllocatedMemory(diff);
454 453
455 lastUsageReportedToV8 = currentUsage; 454 lastUsageReportedToV8 = currentUsage;
456 } 455 }
457 456
458 } // namespace blink 457 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/V8DOMWrapper.cpp ('k') | Source/bindings/core/v8/V8NPObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698