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

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

Issue 6691008: Merge 80842 - 2011-03-11 Anton Muhin <antonm@chromium.org>... (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/648/
Patch Set: Created 9 years, 9 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
« no previous file with comments | « Source/WebCore/ChangeLog ('k') | no next file » | 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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 void addDOMObjectToGroup(DOMDataStore* store, uintptr_t groupId, void* objec t) 321 void addDOMObjectToGroup(DOMDataStore* store, uintptr_t groupId, void* objec t)
322 { 322 {
323 if (!object) 323 if (!object)
324 return; 324 return;
325 v8::Persistent<v8::Object> wrapper = store->domObjectMap().get(object); 325 v8::Persistent<v8::Object> wrapper = store->domObjectMap().get(object);
326 if (!wrapper.IsEmpty()) 326 if (!wrapper.IsEmpty())
327 m_grouper.append(GrouperItem(groupId, wrapper)); 327 m_grouper.append(GrouperItem(groupId, wrapper));
328 } 328 }
329 }; 329 };
330 330
331 static uintptr_t calculateGroupId(StyleBase* styleBase)
332 {
333 ASSERT(styleBase);
334 StyleBase* current = styleBase;
335 StyleSheet* styleSheet = 0;
336 while (true) {
337 // Special case: CSSStyleDeclarations should have CSSRule as a parent
338 // to proceed with parent traversal, otherwise they are coming from
339 // inlined style declaration and should be treated as a root.
340 if (current->isMutableStyleDeclaration()) {
341 CSSMutableStyleDeclaration* cssMutableStyleDeclaration = static_cast <CSSMutableStyleDeclaration*>(current);
342 if (CSSRule* parentRule = cssMutableStyleDeclaration->parentRule())
343 current = parentRule;
344 else
345 return reinterpret_cast<uintptr_t>(cssMutableStyleDeclaration);
346 }
347
348 if (current->isStyleSheet())
349 styleSheet = static_cast<StyleSheet*>(current);
350
351 StyleBase* parent = current->parent();
352 if (!parent)
353 break;
354 current = parent;
355 }
356
357 if (styleSheet)
358 return reinterpret_cast<uintptr_t>(styleSheet);
359
360 return reinterpret_cast<uintptr_t>(current);
361 }
362
331 class DOMObjectGrouperVisitor : public DOMWrapperMap<void>::Visitor { 363 class DOMObjectGrouperVisitor : public DOMWrapperMap<void>::Visitor {
332 public: 364 public:
333 DOMObjectGrouperVisitor() 365 DOMObjectGrouperVisitor()
334 { 366 {
335 } 367 }
336 368
337 void startMap() 369 void startMap()
338 { 370 {
339 m_grouper.shrink(0); 371 m_grouper.shrink(0);
340 } 372 }
(...skipping 11 matching lines...) Expand all
352 // FIXME: check if there are other StyleBase wrappers we should care of. 384 // FIXME: check if there are other StyleBase wrappers we should care of.
353 if (V8CSSStyleSheet::info.equals(typeInfo) 385 if (V8CSSStyleSheet::info.equals(typeInfo)
354 || V8CSSStyleDeclaration::info.equals(typeInfo) 386 || V8CSSStyleDeclaration::info.equals(typeInfo)
355 || V8CSSCharsetRule::info.equals(typeInfo) 387 || V8CSSCharsetRule::info.equals(typeInfo)
356 || V8CSSFontFaceRule::info.equals(typeInfo) 388 || V8CSSFontFaceRule::info.equals(typeInfo)
357 || V8CSSStyleRule::info.equals(typeInfo) 389 || V8CSSStyleRule::info.equals(typeInfo)
358 || V8CSSImportRule::info.equals(typeInfo) 390 || V8CSSImportRule::info.equals(typeInfo)
359 || V8CSSMediaRule::info.equals(typeInfo)) { 391 || V8CSSMediaRule::info.equals(typeInfo)) {
360 StyleBase* styleBase = static_cast<StyleBase*>(object); 392 StyleBase* styleBase = static_cast<StyleBase*>(object);
361 393
362 // We put the whole tree of style elements into a single object grou p. 394 uintptr_t groupId = calculateGroupId(styleBase);
363 // To achieve that we group elements by the roots of their trees.
364 StyleBase* root = styleBase;
365 ASSERT(root);
366 while (true) {
367 StyleBase* parent = root->parent();
368 if (!parent)
369 break;
370 root = parent;
371 }
372 // Group id is an address of the root.
373 uintptr_t groupId = reinterpret_cast<uintptr_t>(root);
374 m_grouper.append(GrouperItem(groupId, wrapper)); 395 m_grouper.append(GrouperItem(groupId, wrapper));
375 396
376 if (V8CSSStyleDeclaration::info.equals(typeInfo)) { 397 if (V8CSSStyleDeclaration::info.equals(typeInfo)) {
377 CSSStyleDeclaration* cssStyleDeclaration = static_cast<CSSStyleD eclaration*>(styleBase); 398 CSSStyleDeclaration* cssStyleDeclaration = static_cast<CSSStyleD eclaration*>(styleBase);
378 if (cssStyleDeclaration->isMutableStyleDeclaration()) { 399 if (cssStyleDeclaration->isMutableStyleDeclaration()) {
379 CSSMutableStyleDeclaration* cssMutableStyleDeclaration = sta tic_cast<CSSMutableStyleDeclaration*>(cssStyleDeclaration); 400 CSSMutableStyleDeclaration* cssMutableStyleDeclaration = sta tic_cast<CSSMutableStyleDeclaration*>(cssStyleDeclaration);
380 CSSMutableStyleDeclaration::const_iterator end = cssMutableS tyleDeclaration->end(); 401 CSSMutableStyleDeclaration::const_iterator end = cssMutableS tyleDeclaration->end();
381 for (CSSMutableStyleDeclaration::const_iterator it = cssMuta bleStyleDeclaration->begin(); it != end; ++it) { 402 for (CSSMutableStyleDeclaration::const_iterator it = cssMuta bleStyleDeclaration->begin(); it != end; ++it) {
382 wrapper = store->domObjectMap().get(it->value()); 403 wrapper = store->domObjectMap().get(it->value());
383 if (!wrapper.IsEmpty()) 404 if (!wrapper.IsEmpty())
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 return; 532 return;
512 #endif 533 #endif
513 534
514 int memoryUsageMB = getMemoryUsageInMB(); 535 int memoryUsageMB = getMemoryUsageInMB();
515 if ((memoryUsageMB > lowUsageMB && memoryUsageMB > 2 * workingSetEstimateMB) || (memoryUsageMB > highUsageMB && memoryUsageMB > workingSetEstimateMB + highU sageDeltaMB)) 536 if ((memoryUsageMB > lowUsageMB && memoryUsageMB > 2 * workingSetEstimateMB) || (memoryUsageMB > highUsageMB && memoryUsageMB > workingSetEstimateMB + highU sageDeltaMB))
516 v8::V8::LowMemoryNotification(); 537 v8::V8::LowMemoryNotification();
517 } 538 }
518 539
519 540
520 } // namespace WebCore 541 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/WebCore/ChangeLog ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698