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

Side by Side Diff: third_party/WebKit/Source/platform/heap/Heap.cpp

Issue 1502093002: Improve ScriptForbiddenScope handling in cross-threaded code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove unnecessary include Created 5 years 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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 // See collectGarbageForTerminatingThread() comment on why a 390 // See collectGarbageForTerminatingThread() comment on why a
391 // safepoint scope isn't entered for it. 391 // safepoint scope isn't entered for it.
392 SafePointScope safePointScope(stackState, gcType != BlinkGC::ThreadTerminati onGC ? state : nullptr); 392 SafePointScope safePointScope(stackState, gcType != BlinkGC::ThreadTerminati onGC ? state : nullptr);
393 393
394 // Try to park the other threads. If we're unable to, bail out of the GC. 394 // Try to park the other threads. If we're unable to, bail out of the GC.
395 if (!gcScope.parkAllThreads(stackState, gcType)) 395 if (!gcScope.parkAllThreads(stackState, gcType))
396 return; 396 return;
397 397
398 // Resume all parked threads upon leaving this scope. 398 // Resume all parked threads upon leaving this scope.
399 ResumeThreadScope resumeThreads(gcType); 399 ResumeThreadScope resumeThreads(gcType);
400 400 ScriptForbiddenIfMainThreadScope scriptForbidden;
401 if (state->isMainThread())
402 ScriptForbiddenScope::enter();
403 401
404 TRACE_EVENT2("blink_gc", "Heap::collectGarbage", 402 TRACE_EVENT2("blink_gc", "Heap::collectGarbage",
405 "lazySweeping", gcType == BlinkGC::GCWithoutSweep, 403 "lazySweeping", gcType == BlinkGC::GCWithoutSweep,
406 "gcReason", gcReasonString(reason)); 404 "gcReason", gcReasonString(reason));
407 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink_gc", "BlinkGC"); 405 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink_gc", "BlinkGC");
408 double startTime = WTF::currentTimeMS(); 406 double startTime = WTF::currentTimeMS();
409 407
410 if (gcType == BlinkGC::TakeSnapshot) 408 if (gcType == BlinkGC::TakeSnapshot)
411 BlinkGCMemoryDumpProvider::instance()->clearProcessDumpForCurrentGC(); 409 BlinkGCMemoryDumpProvider::instance()->clearProcessDumpForCurrentGC();
412 410
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 WTF::Partitions::reportMemoryUsageHistogram(); 453 WTF::Partitions::reportMemoryUsageHistogram();
456 454
457 postGC(gcType); 455 postGC(gcType);
458 456
459 #if ENABLE(ASSERT) 457 #if ENABLE(ASSERT)
460 // 0 is used to figure non-assigned area, so avoid to use 0 in s_gcGeneratio n. 458 // 0 is used to figure non-assigned area, so avoid to use 0 in s_gcGeneratio n.
461 if (++s_gcGeneration == 0) { 459 if (++s_gcGeneration == 0) {
462 s_gcGeneration = 1; 460 s_gcGeneration = 1;
463 } 461 }
464 #endif 462 #endif
465
466 if (state->isMainThread())
467 ScriptForbiddenScope::exit();
468 } 463 }
469 464
470 void Heap::collectGarbageForTerminatingThread(ThreadState* state) 465 void Heap::collectGarbageForTerminatingThread(ThreadState* state)
471 { 466 {
472 { 467 {
473 // A thread-specific termination GC must not allow other global GCs to g o 468 // A thread-specific termination GC must not allow other global GCs to g o
474 // ahead while it is running, hence the termination GC does not enter a 469 // ahead while it is running, hence the termination GC does not enter a
475 // safepoint. GCScope will not enter also a safepoint scope for 470 // safepoint. GCScope will not enter also a safepoint scope for
476 // ThreadTerminationGC. 471 // ThreadTerminationGC.
477 GCScope gcScope(state, BlinkGC::NoHeapPointersOnStack, BlinkGC::ThreadTe rminationGC); 472 GCScope gcScope(state, BlinkGC::NoHeapPointersOnStack, BlinkGC::ThreadTe rminationGC);
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 size_t Heap::s_wrapperCount = 0; 765 size_t Heap::s_wrapperCount = 0;
771 size_t Heap::s_wrapperCountAtLastGC = 0; 766 size_t Heap::s_wrapperCountAtLastGC = 0;
772 size_t Heap::s_collectedWrapperCount = 0; 767 size_t Heap::s_collectedWrapperCount = 0;
773 size_t Heap::s_partitionAllocSizeAtLastGC = 0; 768 size_t Heap::s_partitionAllocSizeAtLastGC = 0;
774 double Heap::s_estimatedMarkingTimePerByte = 0.0; 769 double Heap::s_estimatedMarkingTimePerByte = 0.0;
775 #if ENABLE(ASSERT) 770 #if ENABLE(ASSERT)
776 uint16_t Heap::s_gcGeneration = 0; 771 uint16_t Heap::s_gcGeneration = 0;
777 #endif 772 #endif
778 773
779 } // namespace blink 774 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698