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

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

Issue 15294004: Implement V8ScriptRunner::compileAndRunInternalScript() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 7 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
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 16 matching lines...) Expand all
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698