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

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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 { 411 {
411 V8PerIsolateData* data = V8PerIsolateData::current(); 412 V8PerIsolateData* data = V8PerIsolateData::current();
412 if (!data->shouldCollectGarbageSoon()) 413 if (!data->shouldCollectGarbageSoon())
413 return; 414 return;
414 const int longIdlePauseInMS = 1000; 415 const int longIdlePauseInMS = 1000;
415 data->clearShouldCollectGarbageSoon(); 416 data->clearShouldCollectGarbageSoon();
416 v8::V8::ContextDisposedNotification(); 417 v8::V8::ContextDisposedNotification();
417 v8::V8::IdleNotification(longIdlePauseInMS); 418 v8::V8::IdleNotification(longIdlePauseInMS);
418 } 419 }
419 420
420 void V8GCController::collectGarbage() 421 void V8GCController::collectGarbage(v8::Isolate* isolate)
421 { 422 {
422 v8::Isolate* isolate = v8::Isolate::GetCurrent();
423 v8::HandleScope handleScope(isolate); 423 v8::HandleScope handleScope(isolate);
424 424 V8ScriptRunner::compileAndRunInternalScript(v8String("if (gc) gc();", isolat e), isolate);
425 ScopedPersistent<v8::Context> context;
426 context.set(v8::Context::New(isolate));
427 if (context.isEmpty())
428 return;
429
430 {
431 v8::Context::Scope scope(context.get());
432 v8::Local<v8::String> source = v8::String::New("if (gc) gc();");
433 v8::Local<v8::String> name = v8::String::New("gc");
434 v8::Handle<v8::Script> script = v8::Script::Compile(source, name);
435 if (!script.IsEmpty()) {
436 V8RecursionScope::MicrotaskSuppression scope;
437 script->Run();
438 }
439 }
440
441 context.clear();
442 } 425 }
443 426
444 } // namespace WebCore 427 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698