Source/WebCore/ChangeLog

 12012-08-01 Ulan Degenbaev <ulan@chromium.org>
 2
 3 [chromium] Improve garbage collector hint if page uses Canvas contexts
 4 https://bugs.webkit.org/show_bug.cgi?id=92856
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Request GC by sending context disposed and idle notification to V8 instead
 9 of sending low memory notification. It is faster as it causes one GC
 10 instead of seven GCs caused by low memory notification.
 11
 12 * bindings/v8/V8Binding.cpp:
 13 (WebCore::V8BindingPerIsolateData::V8BindingPerIsolateData):
 14 * bindings/v8/V8Binding.h:
 15 (V8BindingPerIsolateData):
 16 (WebCore::V8BindingPerIsolateData::setGarbageCollectionHint):
 17 (WebCore::V8BindingPerIsolateData::clearGarbageCollectionHint):
 18 (WebCore::V8BindingPerIsolateData::isGarbageCollectionHint):
 19 * bindings/v8/V8Proxy.cpp:
 20 (WebCore::V8Proxy::hintForGCIfNecessary):
 21 * bindings/v8/custom/V8HTMLCanvasElementCustom.cpp:
 22 (WebCore::V8HTMLCanvasElement::getContextCallback):
 23
1242012-07-31 Raul Hudea <rhudea@adobe.com>
225
326 Inspector crashes when trying to inspect a page with CSS region styling

Source/WebCore/bindings/v8/V8Binding.cpp

@@V8BindingPerIsolateData::V8BindingPerIsolateData(v8::Isolate* isolate)
6060#ifndef NDEBUG
6161 , m_internalScriptRecursionLevel(0)
6262#endif
63  , m_lowMemoryNotificationHint(false)
 63 , m_garbageCollectionHint(false)
6464{
6565}
6666

Source/WebCore/bindings/v8/V8Binding.h

@@namespace WebCore {
220220
221221 void reportMemoryUsage(MemoryObjectInfo*) const;
222222
223  // Gives the system a hint that we should send a low memory
224  // notification upon the next close or navigation event,
225  // because some expensive objects have been allocated that we
226  // want to take every opportunity to collect.
227  void setLowMemoryNotificationHint() { m_lowMemoryNotificationHint = true; }
228  void clearLowMemoryNotificationHint() { m_lowMemoryNotificationHint = false; }
229  bool isLowMemoryNotificationHint() const { return m_lowMemoryNotificationHint; }
 223 // Gives the system a hint that we should request garbage collection
 224 // upon the next close or navigation event, because some expensive
 225 // objects have been allocated that we want to take every opportunity
 226 // to collect.
 227 void setGarbageCollectionHint() { m_garbageCollectionHint = true; }
 228 void clearGarbageCollectionHint() { m_garbageCollectionHint = false; }
 229 bool isGarbageCollectionHint() const { return m_garbageCollectionHint; }
230230
231231 private:
232232 explicit V8BindingPerIsolateData(v8::Isolate*);

@@namespace WebCore {
257257#endif
258258 GCEventData m_gcEventData;
259259
260  bool m_lowMemoryNotificationHint;
 260 bool m_garbageCollectionHint;
261261 };
262262
263263 class ConstructorMode {

Source/WebCore/bindings/v8/V8Proxy.cpp

@@void V8Proxy::resetIsolatedWorlds()
562562void V8Proxy::hintForGCIfNecessary()
563563{
564564 V8BindingPerIsolateData* data = V8BindingPerIsolateData::current();
565  if (data->isLowMemoryNotificationHint()) {
566  data->clearLowMemoryNotificationHint();
567  v8::V8::LowMemoryNotification();
 565 if (data->isGarbageCollectionHint()) {
 566 const int longIdlePauseInMs = 1000;
 567 data->clearGarbageCollectionHint();
 568 v8::V8::ContextDisposedNotification();
 569 v8::V8::IdleNotification(longIdlePauseInMs);
568570 }
569571}
570572

Source/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp

@@v8::Handle<v8::Value> V8HTMLCanvasElement::getContextCallback(const v8::Argument
9191 // want to take an opportunity to get rid of them as soon as possible when we
9292 // navigate away from pages using them.
9393 V8BindingPerIsolateData* perIsolateData = V8BindingPerIsolateData::current(args.GetIsolate());
94  perIsolateData->setLowMemoryNotificationHint();
 94 perIsolateData->setGarbageCollectionHint();
9595
9696 if (result->is2d())
9797 return toV8(static_cast<CanvasRenderingContext2D*>(result), args.GetIsolate());