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

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

Issue 651713002: Oilpan: DOM wrappers don't need to keep persistent handles (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 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
« no previous file with comments | « Source/bindings/core/v8/V8GCController.h ('k') | Source/bindings/core/v8/WindowProxy.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 // Create object groups for DOM tree nodes. 361 // Create object groups for DOM tree nodes.
362 void V8GCController::majorGCPrologue(bool constructRetainedObjectInfos, v8::Isol ate* isolate) 362 void V8GCController::majorGCPrologue(bool constructRetainedObjectInfos, v8::Isol ate* isolate)
363 { 363 {
364 v8::HandleScope scope(isolate); 364 v8::HandleScope scope(isolate);
365 TRACE_EVENT_BEGIN0("v8", "majorGC"); 365 TRACE_EVENT_BEGIN0("v8", "majorGC");
366 if (isMainThread()) { 366 if (isMainThread()) {
367 ScriptForbiddenScope::enter(); 367 ScriptForbiddenScope::enter();
368 { 368 {
369 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "DOMMajorGC"); 369 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "DOMMajorGC");
370 MajorGCWrapperVisitor visitor(isolate, constructRetainedObjectInfos) ; 370 MajorGCWrapperVisitor visitor(isolate, constructRetainedObjectInfos) ;
371 v8::V8::VisitHandlesWithClassIds(&visitor); 371 v8::V8::VisitHandlesWithClassIds(isolate, &visitor);
372 visitor.notifyFinished(); 372 visitor.notifyFinished();
373 } 373 }
374 V8PerIsolateData::from(isolate)->setPreviousSamplingState(TRACE_EVENT_GE T_SAMPLING_STATE()); 374 V8PerIsolateData::from(isolate)->setPreviousSamplingState(TRACE_EVENT_GE T_SAMPLING_STATE());
375 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8MajorGC"); 375 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8MajorGC");
376 } else { 376 } else {
377 MajorGCWrapperVisitor visitor(isolate, constructRetainedObjectInfos); 377 MajorGCWrapperVisitor visitor(isolate, constructRetainedObjectInfos);
378 v8::V8::VisitHandlesWithClassIds(&visitor); 378 v8::V8::VisitHandlesWithClassIds(isolate, &visitor);
379 visitor.notifyFinished(); 379 visitor.notifyFinished();
380 } 380 }
381 } 381 }
382 382
383 void V8GCController::gcEpilogue(v8::GCType type, v8::GCCallbackFlags flags) 383 void V8GCController::gcEpilogue(v8::GCType type, v8::GCCallbackFlags flags)
384 { 384 {
385 // FIXME: It would be nice if the GC callbacks passed the Isolate directly.. .. 385 // FIXME: It would be nice if the GC callbacks passed the Isolate directly.. ..
386 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 386 v8::Isolate* isolate = v8::Isolate::GetCurrent();
387 if (type == v8::kGCTypeScavenge) 387 if (type == v8::kGCTypeScavenge)
388 minorGCEpilogue(isolate); 388 minorGCEpilogue(isolate);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 449
450 static size_t lastUsageReportedToV8 = 0; 450 static size_t lastUsageReportedToV8 = 0;
451 451
452 size_t currentUsage = Partitions::currentDOMMemoryUsage(); 452 size_t currentUsage = Partitions::currentDOMMemoryUsage();
453 int64_t diff = static_cast<int64_t>(currentUsage) - static_cast<int64_t>(las tUsageReportedToV8); 453 int64_t diff = static_cast<int64_t>(currentUsage) - static_cast<int64_t>(las tUsageReportedToV8);
454 isolate->AdjustAmountOfExternalAllocatedMemory(diff); 454 isolate->AdjustAmountOfExternalAllocatedMemory(diff);
455 455
456 lastUsageReportedToV8 = currentUsage; 456 lastUsageReportedToV8 = currentUsage;
457 } 457 }
458 458
459 class DOMWrapperTracer : public v8::PersistentHandleVisitor {
460 public:
461 explicit DOMWrapperTracer(Visitor* visitor)
462 : m_visitor(visitor)
463 {
464 }
465
466 virtual void VisitPersistentHandle(v8::Persistent<v8::Value>* value, uint16_ t classId) override
467 {
468 if (classId != WrapperTypeInfo::NodeClassId && classId != WrapperTypeInf o::ObjectClassId)
469 return;
470
471 // Casting to a Handle is safe here, since the Persistent doesn't get GC d
472 // during tracing.
473 ASSERT((*reinterpret_cast<v8::Handle<v8::Value>*>(value))->IsObject());
474 v8::Handle<v8::Object>* wrapper = reinterpret_cast<v8::Handle<v8::Object >*>(value);
475 ASSERT(V8DOMWrapper::isDOMWrapper(*wrapper));
476 if (m_visitor)
477 toWrapperTypeInfo(*wrapper)->trace(m_visitor, toScriptWrappableBase( *wrapper));
478 }
479
480 private:
481 Visitor* m_visitor;
482 };
483
484 void V8GCController::traceDOMWrappers(v8::Isolate* isolate, Visitor* visitor)
485 {
486 DOMWrapperTracer tracer(visitor);
487 v8::V8::VisitHandlesWithClassIds(isolate, &tracer);
488 }
489
459 } // namespace blink 490 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/V8GCController.h ('k') | Source/bindings/core/v8/WindowProxy.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698