Ignore:
Timestamp:
Aug 26, 2009, 4:00:39 PM (16 years ago)
Author:
[email protected]
Message:

A bit of Collector refatoring.

Patch by Geoffrey Garen <[email protected]> on 2009-08-26
Reviewed by Oliver Hunt.

SunSpider says no change. v8 says 1.003x faster (1.02x faster on splay).

  • runtime/JSCell.cpp:

(JSC::JSCell::toPrimitive):
(JSC::JSCell::getPrimitiveNumber):
(JSC::JSCell::toBoolean):
(JSC::JSCell::toNumber):
(JSC::JSCell::toString):
(JSC::JSCell::toObject): Removed pure virtual functions from
JSCell, so the collector can construct one. This allowed
me to remove a bunch of ASSERT_NOT_REACHED throughout the
code, too.

  • runtime/JSCell.h:

(JSC::JSCell::JSCell): ditto
(JSC::Heap::heap): Inlined this function because it's trivial.

  • runtime/Collector.cpp:

(JSC::Heap::destroy):
(JSC::Heap::allocateBlock):
(JSC::Heap::freeBlock):
(JSC::Heap::freeBlocks): Renamed freeHeap to freeBlocks, since
it doesn't actually free the Heap object.
(JSC::Heap::heapAllocate):
(JSC::Heap::sweep):

  • runtime/Collector.h: Refactored block allocation and destruction

into helper functions.

  • runtime/GetterSetter.cpp:
  • runtime/JSAPIValueWrapper.cpp:
  • runtime/JSPropertyNameIterator.cpp: Removed dummy implementations

of pure virtual functions. (See above.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/JSCell.h

    r47622 r47799  
    4646    private:
    4747        explicit JSCell(Structure*);
     48        JSCell(); // Only used for initializing Collector blocks.
    4849        virtual ~JSCell();
    4950
     
    7576
    7677        // Basic conversions.
    77         virtual JSValue toPrimitive(ExecState*, PreferredPrimitiveType) const = 0;
    78         virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue&) = 0;
    79         virtual bool toBoolean(ExecState*) const = 0;
    80         virtual double toNumber(ExecState*) const = 0;
    81         virtual UString toString(ExecState*) const = 0;
    82         virtual JSObject* toObject(ExecState*) const = 0;
     78        virtual JSValue toPrimitive(ExecState*, PreferredPrimitiveType) const;
     79        virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue&);
     80        virtual bool toBoolean(ExecState*) const;
     81        virtual double toNumber(ExecState*) const;
     82        virtual UString toString(ExecState*) const;
     83        virtual JSObject* toObject(ExecState*) const;
    8384
    8485        // Garbage collection.
     
    122123    inline JSCell::JSCell(Structure* structure)
    123124        : m_structure(structure)
     125    {
     126    }
     127
     128    // Only used for initializing Collector blocks.
     129    inline JSCell::JSCell()
    124130    {
    125131    }
     
    362368            m_values.append(cell);
    363369    }
     370
     371    inline Heap* Heap::heap(JSValue v)
     372    {
     373        if (!v.isCell())
     374            return 0;
     375        return heap(v.asCell());
     376    }
     377
     378    inline Heap* Heap::heap(JSCell* c)
     379    {
     380        return cellBlock(c)->heap;
     381    }
     382
    364383} // namespace JSC
    365384
Note: See TracChangeset for help on using the changeset viewer.