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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/V8GCController.cpp

Issue 2301213003: Add tests for trace wrappers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase master Created 4 years, 3 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
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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 384
385 // The conservative GC might have left floating garbage. Schedule 385 // The conservative GC might have left floating garbage. Schedule
386 // precise GC to ensure that we collect all available garbage. 386 // precise GC to ensure that we collect all available garbage.
387 currentThreadState->schedulePreciseGC(); 387 currentThreadState->schedulePreciseGC();
388 } 388 }
389 } 389 }
390 390
391 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update Counters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data( )); 391 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update Counters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data( ));
392 } 392 }
393 393
394 void V8GCController::collectGarbage(v8::Isolate* isolate) 394 void V8GCController::collectGarbage(v8::Isolate* isolate, bool onlyMinorGC)
395 { 395 {
396 v8::HandleScope handleScope(isolate); 396 v8::HandleScope handleScope(isolate);
397 RefPtr<ScriptState> scriptState = ScriptState::create(v8::Context::New(isola te), DOMWrapperWorld::create(isolate)); 397 RefPtr<ScriptState> scriptState = ScriptState::create(v8::Context::New(isola te), DOMWrapperWorld::create(isolate));
398 ScriptState::Scope scope(scriptState.get()); 398 ScriptState::Scope scope(scriptState.get());
399 V8ScriptRunner::compileAndRunInternalScript(v8String(isolate, "if (gc) gc(); "), isolate); 399 StringBuilder builder;
400 builder.append("if (gc) gc(");
401 builder.append(onlyMinorGC ? "true" : "false");
402 builder.append(")");
403 V8ScriptRunner::compileAndRunInternalScript(v8String(isolate, builder.toStri ng()), isolate);
400 scriptState->disposePerContextData(); 404 scriptState->disposePerContextData();
401 } 405 }
402 406
403 void V8GCController::collectAllGarbageForTesting(v8::Isolate* isolate) 407 void V8GCController::collectAllGarbageForTesting(v8::Isolate* isolate)
404 { 408 {
405 for (unsigned i = 0; i < 5; i++) 409 for (unsigned i = 0; i < 5; i++)
406 isolate->RequestGarbageCollectionForTesting(v8::Isolate::kFullGarbageCol lection); 410 isolate->RequestGarbageCollectionForTesting(v8::Isolate::kFullGarbageCol lection);
407 } 411 }
408 412
409 class DOMWrapperTracer : public v8::PersistentHandleVisitor { 413 class DOMWrapperTracer : public v8::PersistentHandleVisitor {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scanPendingActivityHis togram, new CustomCountHistogram("Blink.ScanPendingActivityDuration", 1, 1000, 5 0)); 495 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scanPendingActivityHis togram, new CustomCountHistogram("Blink.ScanPendingActivityDuration", 1, 1000, 5 0));
492 double startTime = WTF::currentTimeMS(); 496 double startTime = WTF::currentTimeMS();
493 v8::HandleScope scope(isolate); 497 v8::HandleScope scope(isolate);
494 PendingActivityVisitor visitor(isolate, executionContext); 498 PendingActivityVisitor visitor(isolate, executionContext);
495 toIsolate(executionContext)->VisitHandlesWithClassIds(&visitor); 499 toIsolate(executionContext)->VisitHandlesWithClassIds(&visitor);
496 scanPendingActivityHistogram.count(static_cast<int>(WTF::currentTimeMS() - s tartTime)); 500 scanPendingActivityHistogram.count(static_cast<int>(WTF::currentTimeMS() - s tartTime));
497 return visitor.pendingActivityFound(); 501 return visitor.pendingActivityFound();
498 } 502 }
499 503
500 } // namespace blink 504 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/V8GCController.h ('k') | third_party/WebKit/Source/core/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698