Ignore:
Timestamp:
Sep 8, 2008, 11:55:39 PM (17 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

2008-09-08 Sam Weinig <[email protected]>

Reviewed by Maciej Stachowiak and Oliver Hunt.

Split storage of properties out of the PropertyMap and into the JSObject
to allow sharing PropertyMap on the StructureID. In order to get this
function correctly, the StructureID's transition mappings were changed to
transition based on property name and attribute pairs, instead of just
property name.

  • Removes the single property optimization now that the PropertyMap is shared. This will be replaced by in-lining some values on the JSObject.

This is a wash on Sunspider and a 6.7% win on the v8 test suite.

  • JavaScriptCore.base.exp:
  • VM/CTI.cpp: (JSC::CTI::privateCompileGetByIdSelf): Get the storage directly off the JSObject. (JSC::CTI::privateCompileGetByIdProto): Ditto. (JSC::CTI::privateCompileGetByIdChain): Ditto. (JSC::CTI::privateCompilePutByIdReplace): Ditto.
  • kjs/JSObject.cpp: (JSC::JSObject::mark): Mark the PropertyStorage. (JSC::JSObject::put): Update to get the propertyMap of the StructureID. (JSC::JSObject::deleteProperty): Ditto. (JSC::JSObject::defineGetter): Return early if the property is already a getter/setter. (JSC::JSObject::defineSetter): Ditto. (JSC::JSObject::getPropertyAttributes): Update to get the propertyMap of the StructureID (JSC::JSObject::getPropertyNames): Ditto. (JSC::JSObject::removeDirect): Ditto.
  • kjs/JSObject.h: Remove PropertyMap and add PropertyStorage. (JSC::JSObject::propertyStorage): return the PropertyStorage. (JSC::JSObject::getDirect): Update to get the propertyMap of the StructureID. (JSC::JSObject::getDirectLocation): Ditto. (JSC::JSObject::offsetForLocation): Compute location directly. (JSC::JSObject::hasCustomProperties): Update to get the propertyMap of the StructureID. (JSC::JSObject::hasGetterSetterProperties): Ditto. (JSC::JSObject::getDirectOffset): Get by indexing into PropertyStorage. (JSC::JSObject::putDirectOffset): Put by indexing into PropertyStorage. (JSC::JSObject::getOwnPropertySlotForWrite): Update to get the propertyMap of the StructureID. (JSC::JSObject::getOwnPropertySlot): Ditto. (JSC::JSObject::putDirect): Move putting into the StructureID unless the property already exists.
  • kjs/PropertyMap.cpp: Use the propertyStorage as the storage for the JSValues. (JSC::PropertyMap::checkConsistency): (JSC::PropertyMap::operator=): (JSC::PropertyMap::~PropertyMap): (JSC::PropertyMap::get): (JSC::PropertyMap::getLocation): (JSC::PropertyMap::put): (JSC::PropertyMap::getOffset): (JSC::PropertyMap::insert): (JSC::PropertyMap::expand): (JSC::PropertyMap::rehash): (JSC::PropertyMap::createTable): (JSC::PropertyMap::resizePropertyStorage): Resize the storage to match the size of the map (JSC::PropertyMap::remove): (JSC::PropertyMap::getEnumerablePropertyNames):
  • kjs/PropertyMap.h: (JSC::PropertyMapEntry::PropertyMapEntry): (JSC::PropertyMap::isEmpty): (JSC::PropertyMap::size): (JSC::PropertyMap::makingCount): (JSC::PropertyMap::PropertyMap):
  • kjs/StructureID.cpp: (JSC::StructureID::addPropertyTransition): Transitions now are based off the property name and attributes. (JSC::StructureID::toDictionaryTransition): Copy the map. (JSC::StructureID::changePrototypeTransition): Copy the map. (JSC::StructureID::getterSetterTransition): Copy the map. (JSC::StructureID::~StructureID):
  • kjs/StructureID.h: (JSC::TransitionTableHash::hash): Custom hash for transition map. (JSC::TransitionTableHash::equal): Ditto. (JSC::TransitionTableHashTraits::emptyValue): Custom traits for transition map (JSC::TransitionTableHashTraits::constructDeletedValue): Ditto. (JSC::TransitionTableHashTraits::isDeletedValue): Ditto. (JSC::StructureID::propertyMap): Added.

JavaScriptGlue:

2008-09-08 Sam Weinig <[email protected]>

Reviewed by Maciej Stachowiak and Oliver Hunt.

Add forwarding headers.

  • ForwardingHeaders/wtf/HashFunctions.h: Added.
  • ForwardingHeaders/wtf/HashTraits.h: Added.

WebCore:

2008-09-08 Sam Weinig <[email protected]>

Reviewed by Maciej Stachowiak and Oliver Hunt.

Add forwarding headers.

  • ForwardingHeaders/wtf/HashFunctions.h: Added.
File:
1 edited

Legend:

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

    r36263 r36285  
    1 // -*- mode: c++; c-basic-offset: 4 -*-
    21/*
    32 * Copyright (C) 2008 Apple Inc. All rights reserved.
     
    2827#define StructureID_h
    2928
     29#include "JSValue.h"
     30#include "PropertyMap.h"
     31#include "ustring.h"
     32#include <wtf/HashFunctions.h>
     33#include <wtf/HashTraits.h>
    3034#include <wtf/OwnArrayPtr.h>
    3135#include <wtf/PassRefPtr.h>
    3236#include <wtf/RefCounted.h>
    33 #include "JSValue.h"
    34 #include "ustring.h"
    3537
    3638namespace JSC {
     
    3840    class JSValue;
    3941    class StructureIDChain;
     42
     43    struct TransitionTableHash {
     44        typedef std::pair<RefPtr<UString::Rep>, unsigned> TransitionTableKey;
     45        static unsigned hash(const TransitionTableKey& p)
     46        {
     47            return p.first->computedHash();
     48        }
     49
     50        static bool equal(const TransitionTableKey& a, const TransitionTableKey& b)
     51        {
     52            return a == b;
     53        }
     54
     55        static const bool safeToCompareToEmptyOrDeleted = true;
     56    };
     57
     58    struct TransitionTableHashTraits {
     59        typedef WTF::HashTraits<RefPtr<UString::Rep> > FirstTraits;
     60        typedef WTF::GenericHashTraits<unsigned> SecondTraits;
     61        typedef std::pair<FirstTraits::TraitType, SecondTraits::TraitType> TraitType;
     62
     63        static const bool emptyValueIsZero = FirstTraits::emptyValueIsZero && SecondTraits::emptyValueIsZero;
     64        static TraitType emptyValue() { return std::make_pair(FirstTraits::emptyValue(), SecondTraits::emptyValue()); }
     65
     66        static const bool needsDestruction = FirstTraits::needsDestruction || SecondTraits::needsDestruction;
     67
     68        static void constructDeletedValue(TraitType& slot) { FirstTraits::constructDeletedValue(slot.first); }
     69        static bool isDeletedValue(const TraitType& value) { return FirstTraits::isDeletedValue(value.first); }
     70    };
    4071
    4172    class StructureID : public RefCounted<StructureID> {
     
    4576            return adoptRef(new StructureID(prototype));
    4677        }
    47        
     78
    4879        static PassRefPtr<StructureID> changePrototypeTransition(StructureID*, JSValue* prototype);
    49         static PassRefPtr<StructureID> addPropertyTransition(StructureID*, const Identifier& name);
     80        static PassRefPtr<StructureID> addPropertyTransition(StructureID*, const Identifier& propertyName, JSValue*, unsigned attributes, bool checkReadOnly, JSObject* slotBase, PutPropertySlot&, PropertyStorage&);
    5081        static PassRefPtr<StructureID> getterSetterTransition(StructureID*);
    5182        static PassRefPtr<StructureID> toDictionaryTransition(StructureID*);
     
    6394
    6495        JSValue* prototype() const { return m_prototype; }
    65        
     96
    6697        void setCachedPrototypeChain(PassRefPtr<StructureIDChain> cachedPrototypeChain) { m_cachedPrototypeChain = cachedPrototypeChain; }
    6798        StructureIDChain* cachedPrototypeChain() const { return m_cachedPrototypeChain.get(); }
    6899
     100        const PropertyMap& propertyMap() const { return m_propertyMap; }
     101        PropertyMap& propertyMap() { return m_propertyMap; }
     102
    69103    private:
    70         typedef HashMap<RefPtr<UString::Rep>, StructureID*, IdentifierRepHash, HashTraits<RefPtr<UString::Rep> > > TransitionTable;
    71        
     104        typedef std::pair<RefPtr<UString::Rep>, unsigned> TransitionTableKey;
     105        typedef HashMap<TransitionTableKey, StructureID*, TransitionTableHash, TransitionTableHashTraits> TransitionTable;
     106
    72107        StructureID(JSValue* prototype);
    73108       
     
    81116        RefPtr<StructureID> m_previous;
    82117        UString::Rep* m_nameInPrevious;
     118        unsigned m_attributesInPrevious;
    83119
    84120        size_t m_transitionCount;
    85121        TransitionTable m_transitionTable;
     122
     123        PropertyMap m_propertyMap;
    86124    };
    87125
Note: See TracChangeset for help on using the changeset viewer.