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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.cpp

Issue 2665733002: [wrapper-tracing] For a worker, mark relative to its wrapper map. (Closed)
Patch Set: Address comments Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.cpp b/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.cpp
index 9e6672465511eb4ba8ab3d079ed680d821684127..c92eb5f0e1ffdd7e3564d6acc47e2aeb0730faf1 100644
--- a/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.cpp
@@ -91,7 +91,11 @@ PassRefPtr<DOMWrapperWorld> DOMWrapperWorld::create(v8::Isolate* isolate,
DOMWrapperWorld::DOMWrapperWorld(v8::Isolate* isolate, int worldId)
: m_worldId(worldId),
m_domDataStore(
- WTF::wrapUnique(new DOMDataStore(isolate, isMainWorld()))) {}
+ WTF::wrapUnique(new DOMDataStore(isolate, isMainWorld()))) {
+ if (worldId == WorkerWorldId) {
sof 2017/02/01 22:05:19 nit: isWorkerWorld()
+ workerWorld() = this;
+ }
+}
DOMWrapperWorld& DOMWrapperWorld::mainWorld() {
ASSERT(isMainThread());
@@ -101,6 +105,12 @@ DOMWrapperWorld& DOMWrapperWorld::mainWorld() {
return *cachedMainWorld;
}
+DOMWrapperWorld*& DOMWrapperWorld::workerWorld() {
+ DEFINE_THREAD_SAFE_STATIC_LOCAL(ThreadSpecific<DOMWrapperWorld*>, workerWorld,
+ new ThreadSpecific<DOMWrapperWorld*>);
+ return *workerWorld;
+}
+
PassRefPtr<DOMWrapperWorld> DOMWrapperWorld::fromWorldId(v8::Isolate* isolate,
int worldId) {
if (worldId == MainWorldId)
@@ -128,15 +138,19 @@ void DOMWrapperWorld::allWorldsInMainThread(
void DOMWrapperWorld::markWrappersInAllWorlds(
ScriptWrappable* scriptWrappable,
const ScriptWrappableVisitor* visitor) {
- // TODO(hlopko): Currently wrapper in one world will keep wrappers in all
- // worlds alive (possibly holding on entire documents). This is neither
- // needed (there is no way to get from one wrapper to another), nor wanted
- // (big performance and memory overhead).
+ // Handle marking in per-worker wrapper worlds.
+ if (!isMainThread()) {
+ DCHECK(ThreadState::current()->isolate());
+ if (workerWorld()) {
+ DOMDataStore& dataStore = workerWorld()->domDataStore();
+ if (dataStore.containsWrapper(scriptWrappable)) {
+ dataStore.markWrapper(scriptWrappable);
+ }
+ }
+ return;
+ }
- // Marking for the main world
scriptWrappable->markWrapper(visitor);
- if (!isMainThread())
- return;
WorldMap& isolatedWorlds = isolatedWorldMap();
for (auto& world : isolatedWorlds.values()) {
DOMDataStore& dataStore = world->domDataStore();
@@ -173,6 +187,10 @@ DOMWrapperWorld::~DOMWrapperWorld() {
dispose();
+ if (m_worldId == WorkerWorldId) {
sof 2017/02/01 22:05:19 isWorkerWorld()
+ workerWorld() = nullptr;
+ }
+
if (!isIsolatedWorld())
return;
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698