| OLD | NEW |
| 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 16 matching lines...) Expand all Loading... |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "bindings/v8/V8GCController.h" | 32 #include "bindings/v8/V8GCController.h" |
| 33 | 33 |
| 34 #include "V8MessagePort.h" | 34 #include "V8MessagePort.h" |
| 35 #include "V8MutationObserver.h" | 35 #include "V8MutationObserver.h" |
| 36 #include "V8Node.h" | 36 #include "V8Node.h" |
| 37 #include "V8ScriptRunner.h" |
| 37 #include "bindings/v8/RetainedDOMInfo.h" | 38 #include "bindings/v8/RetainedDOMInfo.h" |
| 38 #include "bindings/v8/V8AbstractEventListener.h" | 39 #include "bindings/v8/V8AbstractEventListener.h" |
| 39 #include "bindings/v8/V8Binding.h" | 40 #include "bindings/v8/V8Binding.h" |
| 40 #include "bindings/v8/V8RecursionScope.h" | 41 #include "bindings/v8/V8RecursionScope.h" |
| 41 #include "bindings/v8/WrapperTypeInfo.h" | 42 #include "bindings/v8/WrapperTypeInfo.h" |
| 42 #include "core/dom/Attr.h" | 43 #include "core/dom/Attr.h" |
| 43 #include "core/html/HTMLImageElement.h" | 44 #include "core/html/HTMLImageElement.h" |
| 44 #include "core/platform/MemoryUsageSupport.h" | 45 #include "core/platform/MemoryUsageSupport.h" |
| 45 #include "core/platform/chromium/TraceEvent.h" | 46 #include "core/platform/chromium/TraceEvent.h" |
| 46 #include <algorithm> | 47 #include <algorithm> |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 { | 409 { |
| 409 V8PerIsolateData* data = V8PerIsolateData::current(); | 410 V8PerIsolateData* data = V8PerIsolateData::current(); |
| 410 if (!data->shouldCollectGarbageSoon()) | 411 if (!data->shouldCollectGarbageSoon()) |
| 411 return; | 412 return; |
| 412 const int longIdlePauseInMS = 1000; | 413 const int longIdlePauseInMS = 1000; |
| 413 data->clearShouldCollectGarbageSoon(); | 414 data->clearShouldCollectGarbageSoon(); |
| 414 v8::V8::ContextDisposedNotification(); | 415 v8::V8::ContextDisposedNotification(); |
| 415 v8::V8::IdleNotification(longIdlePauseInMS); | 416 v8::V8::IdleNotification(longIdlePauseInMS); |
| 416 } | 417 } |
| 417 | 418 |
| 418 void V8GCController::collectGarbage() | 419 void V8GCController::collectGarbage(v8::Isolate* isolate) |
| 419 { | 420 { |
| 420 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 421 V8ScriptRunner::compileAndRunInternalScript(v8String("if (gc) gc();", isolat
e), isolate); |
| 421 v8::HandleScope handleScope(isolate); | |
| 422 | |
| 423 ScopedPersistent<v8::Context> context; | |
| 424 context.set(v8::Context::New(isolate)); | |
| 425 if (context.isEmpty()) | |
| 426 return; | |
| 427 | |
| 428 { | |
| 429 v8::Context::Scope scope(context.get()); | |
| 430 v8::Local<v8::String> source = v8::String::New("if (gc) gc();"); | |
| 431 v8::Local<v8::String> name = v8::String::New("gc"); | |
| 432 v8::Handle<v8::Script> script = v8::Script::Compile(source, name); | |
| 433 if (!script.IsEmpty()) { | |
| 434 V8RecursionScope::MicrotaskSuppression scope; | |
| 435 script->Run(); | |
| 436 } | |
| 437 } | |
| 438 | |
| 439 context.clear(); | |
| 440 } | 422 } |
| 441 | 423 |
| 442 } // namespace WebCore | 424 } // namespace WebCore |
| OLD | NEW |