From d966498bf832214b1308790c647147fc867dddd1 Mon Sep 17 00:00:00 2001 From: "mrowe@apple.com" Date: Wed, 7 Nov 2007 17:54:36 +0000 Subject: [PATCH] 2007-11-07 Mark Rowe Reviewed by Eric. Fix up initialization after being mangled in r27572, and remove the ternary expression as extraCost will always be zero for the numeric heap. * kjs/collector.cpp: (KJS::Collector::heapAllocate): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@27574 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- JavaScriptCore/ChangeLog | 11 +++++++++++ JavaScriptCore/kjs/collector.cpp | 7 ++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog index 26b31475a05b..52560b283d0c 100644 --- a/JavaScriptCore/ChangeLog +++ b/JavaScriptCore/ChangeLog @@ -1,3 +1,14 @@ +2007-11-07 Mark Rowe + + Reviewed by Eric. + + Fix up initialization after being mangled in r27572, and remove the + ternary expression as extraCost will always be zero for the numeric + heap. + + * kjs/collector.cpp: + (KJS::Collector::heapAllocate): + 2007-11-07 Mark Rowe Gtk build fix. diff --git a/JavaScriptCore/kjs/collector.cpp b/JavaScriptCore/kjs/collector.cpp index bdb3bc8b0837..7adfb8256a3a 100644 --- a/JavaScriptCore/kjs/collector.cpp +++ b/JavaScriptCore/kjs/collector.cpp @@ -203,6 +203,7 @@ template void* Collector::heapAllocate(size_t s) UNUSED_PARAM(s); // s is now only used for the above assert ASSERT(heap.operationInProgress == NoOperation); + ASSERT(heapType == PrimaryHeap || heap.extraCost == 0); // FIXME: If another global variable access here doesn't hurt performance // too much, we could abort() in NDEBUG builds, which could help ensure we // don't spend any time debugging cases where we allocate inside an object's @@ -217,7 +218,7 @@ template void* Collector::heapAllocate(size_t s) if (heapType == PrimaryHeap && heap.extraCost > ALLOCATIONS_PER_COLLECTION) { size_t numLiveObjectsAtLastCollect = heap.numLiveObjectsAtLastCollect; size_t numNewObjects = numLiveObjects - numLiveObjectsAtLastCollect; - const size_t newCost = heapType == numNewObjects + heap.extraCost; + const size_t newCost = numNewObjects + heap.extraCost; if (newCost >= ALLOCATIONS_PER_COLLECTION && newCost >= numLiveObjectsAtLastCollect) goto collect; } @@ -248,8 +249,8 @@ scan: collect: size_t numLiveObjectsAtLastCollect = heap.numLiveObjectsAtLastCollect; size_t numNewObjects = numLiveObjects - numLiveObjectsAtLastCollect; - const size_t newCost = heapType == PrimaryHeap ? numNewObjects + heap.extraCost : numNewObjects; - + const size_t newCost = numNewObjects + heap.extraCost; + if (newCost >= ALLOCATIONS_PER_COLLECTION && newCost >= numLiveObjectsAtLastCollect) { #ifndef NDEBUG heap.operationInProgress = NoOperation; -- 2.36.0