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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 toWrapperTypeInfo(*wrapper)->trace(m_visitor, toScriptWrappableBase(*wra pper)); | |
477 } | |
478 | |
479 private: | |
480 Visitor* m_visitor; | |
481 }; | |
482 | |
483 void V8GCController::traceDOMWrappers(Visitor* visitor) | |
484 { | |
485 DOMWrapperTracer tracer(visitor); | |
486 v8::V8::VisitHandlesWithClassIds(&tracer); | |
haraken
2014/10/15 10:43:04
This is problematic... When doing an Oilpan's GC,
| |
487 } | |
488 | |
459 } // namespace blink | 489 } // namespace blink |
OLD | NEW |