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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 } | 465 } |
466 | 466 |
467 void V8GCController::CollectAllGarbageForTesting(v8::Isolate* isolate) { | 467 void V8GCController::CollectAllGarbageForTesting(v8::Isolate* isolate) { |
468 for (unsigned i = 0; i < 5; i++) | 468 for (unsigned i = 0; i < 5; i++) |
469 isolate->RequestGarbageCollectionForTesting( | 469 isolate->RequestGarbageCollectionForTesting( |
470 v8::Isolate::kFullGarbageCollection); | 470 v8::Isolate::kFullGarbageCollection); |
471 } | 471 } |
472 | 472 |
473 class DOMWrapperTracer : public v8::PersistentHandleVisitor { | 473 class DOMWrapperTracer : public v8::PersistentHandleVisitor { |
474 public: | 474 public: |
475 explicit DOMWrapperTracer(Visitor* visitor) : visitor_(visitor) {} | 475 explicit DOMWrapperTracer(Visitor* visitor) : visitor_(visitor) { |
| 476 DCHECK(visitor_); |
| 477 } |
476 | 478 |
477 void VisitPersistentHandle(v8::Persistent<v8::Value>* value, | 479 void VisitPersistentHandle(v8::Persistent<v8::Value>* value, |
478 uint16_t class_id) override { | 480 uint16_t class_id) override { |
479 if (class_id != WrapperTypeInfo::kNodeClassId && | 481 if (class_id != WrapperTypeInfo::kNodeClassId && |
480 class_id != WrapperTypeInfo::kObjectClassId) | 482 class_id != WrapperTypeInfo::kObjectClassId) |
481 return; | 483 return; |
482 | 484 |
483 const v8::Persistent<v8::Object>& wrapper = | 485 const v8::Persistent<v8::Object>& wrapper = |
484 v8::Persistent<v8::Object>::Cast(*value); | 486 v8::Persistent<v8::Object>::Cast(*value); |
485 | 487 |
486 if (visitor_) | 488 if (ScriptWrappable* script_wrappable = ToScriptWrappable(wrapper)) |
487 ToWrapperTypeInfo(wrapper)->Trace(visitor_, ToScriptWrappable(wrapper)); | 489 ToWrapperTypeInfo(wrapper)->Trace(visitor_, script_wrappable); |
488 } | 490 } |
489 | 491 |
490 private: | 492 private: |
491 Visitor* visitor_; | 493 Visitor* visitor_; |
492 }; | 494 }; |
493 | 495 |
494 void V8GCController::TraceDOMWrappers(v8::Isolate* isolate, Visitor* visitor) { | 496 void V8GCController::TraceDOMWrappers(v8::Isolate* isolate, Visitor* visitor) { |
495 DOMWrapperTracer tracer(visitor); | 497 DOMWrapperTracer tracer(visitor); |
496 isolate->VisitHandlesWithClassIds(&tracer); | 498 isolate->VisitHandlesWithClassIds(&tracer); |
497 } | 499 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 double start_time = WTF::CurrentTimeMS(); | 553 double start_time = WTF::CurrentTimeMS(); |
552 v8::HandleScope scope(isolate); | 554 v8::HandleScope scope(isolate); |
553 PendingActivityVisitor visitor(isolate, execution_context); | 555 PendingActivityVisitor visitor(isolate, execution_context); |
554 ToIsolate(execution_context)->VisitHandlesWithClassIds(&visitor); | 556 ToIsolate(execution_context)->VisitHandlesWithClassIds(&visitor); |
555 scan_pending_activity_histogram.Count( | 557 scan_pending_activity_histogram.Count( |
556 static_cast<int>(WTF::CurrentTimeMS() - start_time)); | 558 static_cast<int>(WTF::CurrentTimeMS() - start_time)); |
557 return visitor.PendingActivityFound(); | 559 return visitor.PendingActivityFound(); |
558 } | 560 } |
559 | 561 |
560 } // namespace blink | 562 } // namespace blink |
OLD | NEW |