OLD | NEW |
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 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 } | 461 } |
462 | 462 |
463 void V8GCController::collectAllGarbageForTesting(v8::Isolate* isolate) { | 463 void V8GCController::collectAllGarbageForTesting(v8::Isolate* isolate) { |
464 for (unsigned i = 0; i < 5; i++) | 464 for (unsigned i = 0; i < 5; i++) |
465 isolate->RequestGarbageCollectionForTesting( | 465 isolate->RequestGarbageCollectionForTesting( |
466 v8::Isolate::kFullGarbageCollection); | 466 v8::Isolate::kFullGarbageCollection); |
467 } | 467 } |
468 | 468 |
469 class DOMWrapperTracer : public v8::PersistentHandleVisitor { | 469 class DOMWrapperTracer : public v8::PersistentHandleVisitor { |
470 public: | 470 public: |
471 explicit DOMWrapperTracer(Visitor* visitor) : m_visitor(visitor) {} | 471 explicit DOMWrapperTracer(Visitor* visitor) : m_visitor(visitor) { |
| 472 DCHECK(m_visitor); |
| 473 } |
472 | 474 |
473 void VisitPersistentHandle(v8::Persistent<v8::Value>* value, | 475 void VisitPersistentHandle(v8::Persistent<v8::Value>* value, |
474 uint16_t classId) override { | 476 uint16_t classId) override { |
475 if (classId != WrapperTypeInfo::NodeClassId && | 477 if (classId != WrapperTypeInfo::NodeClassId && |
476 classId != WrapperTypeInfo::ObjectClassId) | 478 classId != WrapperTypeInfo::ObjectClassId) |
477 return; | 479 return; |
478 | 480 |
479 const v8::Persistent<v8::Object>& wrapper = | 481 const v8::Persistent<v8::Object>& wrapper = |
480 v8::Persistent<v8::Object>::Cast(*value); | 482 v8::Persistent<v8::Object>::Cast(*value); |
481 | 483 |
482 if (m_visitor) | 484 if (ScriptWrappable* scriptWrappable = toScriptWrappable(wrapper)) |
483 toWrapperTypeInfo(wrapper)->trace(m_visitor, toScriptWrappable(wrapper)); | 485 toWrapperTypeInfo(wrapper)->trace(m_visitor, scriptWrappable); |
484 } | 486 } |
485 | 487 |
486 private: | 488 private: |
487 Visitor* m_visitor; | 489 Visitor* m_visitor; |
488 }; | 490 }; |
489 | 491 |
490 void V8GCController::traceDOMWrappers(v8::Isolate* isolate, Visitor* visitor) { | 492 void V8GCController::traceDOMWrappers(v8::Isolate* isolate, Visitor* visitor) { |
491 DOMWrapperTracer tracer(visitor); | 493 DOMWrapperTracer tracer(visitor); |
492 isolate->VisitHandlesWithClassIds(&tracer); | 494 isolate->VisitHandlesWithClassIds(&tracer); |
493 } | 495 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 double startTime = WTF::currentTimeMS(); | 549 double startTime = WTF::currentTimeMS(); |
548 v8::HandleScope scope(isolate); | 550 v8::HandleScope scope(isolate); |
549 PendingActivityVisitor visitor(isolate, executionContext); | 551 PendingActivityVisitor visitor(isolate, executionContext); |
550 toIsolate(executionContext)->VisitHandlesWithClassIds(&visitor); | 552 toIsolate(executionContext)->VisitHandlesWithClassIds(&visitor); |
551 scanPendingActivityHistogram.count( | 553 scanPendingActivityHistogram.count( |
552 static_cast<int>(WTF::currentTimeMS() - startTime)); | 554 static_cast<int>(WTF::currentTimeMS() - startTime)); |
553 return visitor.pendingActivityFound(); | 555 return visitor.pendingActivityFound(); |
554 } | 556 } |
555 | 557 |
556 } // namespace blink | 558 } // namespace blink |
OLD | NEW |