Ignore:
Timestamp:
Sep 2, 2008, 7:31:45 PM (17 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

2008-09-02 Geoffrey Garen <[email protected]>

Reviewed by Sam Weinig.


Implemented the rest of Darin's review comments for the 09-01 inline
caching patch.


SunSpider says 0.5% faster, but that seems like noise.

  • JavaScriptCore.xcodeproj/project.pbxproj: Put PutPropertySlot into its own file, and added BatchedTransitionOptimizer.
  • VM/CodeBlock.cpp: (KJS::CodeBlock::~CodeBlock): Use array indexing instead of a pointer iterator.
  • VM/CodeGenerator.cpp: (KJS::CodeGenerator::CodeGenerator): Used BatchedTransitionOptimizer to make batched put and remove for declared variables fast, without forever pessimizing the global object. Removed the old getDirect/removeDirect hack that tried to do the same in a more limited way.
  • VM/CodeGenerator.h: Moved IdentifierRepHash to the KJS namespace since it doesn't specialize anything in WTF.
  • VM/Machine.cpp: (KJS::Machine::Machine): Nixed the DummyConstruct tag because it was confusingly named.

(KJS::Machine::execute): Used BatchedTransitionOptimizer, as above. Fixed
up some comments.

(KJS::cachePrototypeChain): Cast to JSObject*, since it's more specific.

(KJS::Machine::tryCachePutByID): Use isNull() instead of comparing to
jsNull(), since isNull() leaves more options open for the future.
(KJS::Machine::tryCacheGetByID): ditto
(KJS::Machine::privateExecute): ditto

  • VM/SamplingTool.cpp: (KJS::SamplingTool::dump): Use C++-style cast, to match our style guidelines.
  • kjs/BatchedTransitionOptimizer.h: Added. New class that allows host code to add a batch of properties to an object in an efficient way.
  • kjs/JSActivation.cpp: Use isNull(), as above.
  • kjs/JSArray.cpp: Get rid of DummyConstruct tag, as above.
  • kjs/JSArray.h:
  • kjs/JSGlobalData.cpp: Nixed two unused StructureIDs.
  • kjs/JSGlobalData.h:
  • kjs/JSImmediate.cpp: Use isNull(), as above.
  • kjs/JSObject.cpp: (KJS::JSObject::mark): Moved mark tracing code elsewhere, to make this function more readable.

(KJS::JSObject::put): Use isNull(), as above.

(KJS::JSObject::createInheritorID): Return a raw pointer, since the
object is owned by a data member, not necessarily the caller.

  • kjs/JSObject.h:
  • kjs/JSString.cpp: Use isNull(), as above.
  • kjs/PropertyMap.h: Updated to use PropertySlot::invalidOffset.
  • kjs/PropertySlot.h: Changed KJS_INVALID_OFFSET to WTF::notFound because C macros are so 80's.
  • kjs/PutPropertySlot.h: Added. Split out of PropertySlot.h. Also renamed PutPropertySlot::SlotType to PutPropertySlot::Type, and slotBase to base, since "slot" was redundant.
  • kjs/StructureID.cpp: Added a new transition *away* from dictionary status, to support BatchedTransitionOptimizer.

(KJS::StructureIDChain::StructureIDChain): No need to store m_size as
a data member, so keep it in a local, which might be faster.

  • kjs/StructureID.h:
  • kjs/SymbolTable.h: Moved IdentifierRepHash to KJS namespace, as above.
  • kjs/ustring.h:

JavaScriptGlue:

2008-09-02 Geoffrey Garen <[email protected]>

Reviewed by Sam Weinig.


Implemented the rest of Darin's review comments for the 09-01 inline
caching patch.


  • ForwardingHeaders/kjs/PutPropertySlot.h: Added.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/StructureID.cpp

    r36018 r36032  
    2929
    3030#include "identifier.h"
    31 #include "JSCell.h"
     31#include "JSObject.h"
    3232#include <wtf/RefPtr.h>
    3333
     
    5454
    5555    if (structureID->m_transitionCount > s_maxTransitionLength)
    56         return dictionaryTransition(structureID);
     56        return toDictionaryTransition(structureID);
    5757
    5858    RefPtr<StructureID> transition = create(structureID->m_prototype);
     
    6666}
    6767
    68 PassRefPtr<StructureID> StructureID::dictionaryTransition(StructureID* structureID)
     68PassRefPtr<StructureID> StructureID::toDictionaryTransition(StructureID* structureID)
    6969{
    7070    ASSERT(!structureID->m_isDictionary);
     
    7272    RefPtr<StructureID> transition = create(structureID->m_prototype);
    7373    transition->m_isDictionary = true;
    74     transition->m_transitionCount = structureID->m_transitionCount + 1;
    7574    return transition.release();
     75}
     76
     77PassRefPtr<StructureID> StructureID::fromDictionaryTransition(StructureID* structureID)
     78{
     79    ASSERT(structureID->m_isDictionary);
     80
     81    // Since dictionary StructureIDs are not shared, and no opcodes specialize
     82    // for them, we don't need to allocate a new StructureID when transitioning
     83    // to non-dictionary status.
     84    structureID->m_isDictionary = false;
     85    return structureID;
    7686}
    7787
     
    99109
    100110StructureIDChain::StructureIDChain(StructureID* structureID)
    101     : m_size(0)
    102111{
     112    size_t size = 0;
     113
    103114    StructureID* tmp = structureID;
    104     while (tmp->prototype() != jsNull()) {
    105         ++m_size;
     115    while (!tmp->prototype()->isNull()) {
     116        ++size;
    106117        tmp = static_cast<JSCell*>(tmp->prototype())->structureID();
    107118    }
    108119
    109     m_vector.set(new RefPtr<StructureID>[m_size]);
     120    m_vector.set(new RefPtr<StructureID>[size]);
    110121
    111     for (size_t i = 0; i < m_size; ++i) {
     122    for (size_t i = 0; i < size; ++i) {
    112123        m_vector[i] = structureID;
    113         structureID = static_cast<JSCell*>(structureID->prototype())->structureID();
     124        structureID = static_cast<JSObject*>(structureID->prototype())->structureID();
    114125    }
    115126}
Note: See TracChangeset for help on using the changeset viewer.