From 720d9c280a8e7415ed77ac846e955a8e163d834f Mon Sep 17 00:00:00 2001 From: yangguo Date: Thu, 21 May 2015 03:35:51 -0700 Subject: [PATCH] Debugger: use weak cells to implement ScriptCache. R=ulan@chromium.org Review URL: https://codereview.chromium.org/1145183004 Cr-Commit-Position: refs/heads/master@{#28539} --- src/debug.cc | 104 +++++++++++++++++------------------------------------- src/debug.h | 21 ++++------- src/objects-inl.h | 4 +++ src/objects.cc | 43 ++++++++++++++++++++++ src/objects.h | 27 ++++++++++++-- 5 files changed, 110 insertions(+), 89 deletions(-) diff --git a/src/debug.cc b/src/debug.cc index bcff35a..df8eab7 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -493,8 +493,7 @@ int Debug::ArchiveSpacePerThread() { } -ScriptCache::ScriptCache(Isolate* isolate) : HashMap(HashMap::PointersMatch), - isolate_(isolate) { +ScriptCache::ScriptCache(Isolate* isolate) : isolate_(isolate) { Heap* heap = isolate_->heap(); HandleScope scope(isolate_); @@ -502,92 +501,53 @@ ScriptCache::ScriptCache(Isolate* isolate) : HashMap(HashMap::PointersMatch), heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, "ScriptCache"); // Scan heap for Script objects. - HeapIterator iterator(heap); - DisallowHeapAllocation no_allocation; - - for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { - if (obj->IsScript() && Script::cast(obj)->HasValidSource()) { - Add(Handle