Changeset 57019 in webkit for trunk/JavaScriptCore/runtime


Ignore:
Timestamp:
Apr 2, 2010, 1:15:53 PM (15 years ago)
Author:
[email protected]
Message:

Inlined toThisString and toThisJSString to avoid virtual function call overhead
https://bugs.webkit.org/show_bug.cgi?id=37039

Reviewed by Oliver Hunt.

Maybe a 1% speedup on iBench JS.

  • runtime/JSCell.cpp:
  • runtime/JSCell.h:
  • runtime/JSNumberCell.cpp:
  • runtime/JSNumberCell.h:
  • runtime/JSString.cpp:
  • runtime/JSString.h:
  • runtime/JSValue.h:
  • runtime/JSZombie.h:

(JSC::JSZombie::toThisObject): Nixed the old virtual-type implementation.

  • runtime/JSObject.h:

(JSC::JSValue::toThisString):
(JSC::JSValue::toThisJSString): Added the inlined implementation.

Location:
trunk/JavaScriptCore/runtime
Files:
9 edited

Legend:

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

    r52731 r57019  
    164164}
    165165
    166 UString JSCell::toThisString(ExecState* exec) const
    167 {
    168     return toThisObject(exec)->toString(exec);
    169 }
    170 
    171 JSString* JSCell::toThisJSString(ExecState* exec)
    172 {
    173     return jsString(exec, toThisString(exec));
    174 }
    175 
    176166const ClassInfo* JSCell::classInfo() const
    177167{
  • trunk/JavaScriptCore/runtime/JSCell.h

    r54022 r57019  
    108108
    109109        virtual JSObject* toThisObject(ExecState*) const;
    110         virtual UString toThisString(ExecState*) const;
    111         virtual JSString* toThisJSString(ExecState*);
    112110        virtual JSValue getJSNumber();
    113111        void* vptr() { return *reinterpret_cast<void**>(this); }
     
    302300    }
    303301
    304     inline UString JSValue::toThisString(ExecState* exec) const
    305     {
    306         return isCell() ? asCell()->toThisString(exec) : toString(exec);
    307     }
    308 
    309302    inline JSValue JSValue::getJSNumber()
    310303    {
  • trunk/JavaScriptCore/runtime/JSNumberCell.cpp

    r47622 r57019  
    5858}
    5959
    60 UString JSNumberCell::toThisString(ExecState*) const
    61 {
    62     return UString::from(m_value);
    63 }
    64 
    6560JSObject* JSNumberCell::toObject(ExecState* exec) const
    6661{
  • trunk/JavaScriptCore/runtime/JSNumberCell.h

    r54050 r57019  
    6363        virtual JSObject* toObject(ExecState*) const;
    6464
    65         virtual UString toThisString(ExecState*) const;
    6665        virtual JSObject* toThisObject(ExecState*) const;
    6766        virtual JSValue getJSNumber();
  • trunk/JavaScriptCore/runtime/JSObject.h

    r55521 r57019  
    3636#include "Structure.h"
    3737#include "JSGlobalData.h"
     38#include "JSString.h"
    3839#include <wtf/StdLibExtras.h>
    3940
     
    710711}
    711712
     713// --- JSValue inlines ----------------------------
     714
     715ALWAYS_INLINE UString JSValue::toThisString(ExecState* exec) const
     716{
     717    return isString() ? static_cast<JSString*>(asCell())->value(exec) : toThisObject(exec)->toString(exec);
     718}
     719
     720inline JSString* JSValue::toThisJSString(ExecState* exec) const
     721{
     722    return isString() ? static_cast<JSString*>(asCell()) : jsString(exec, toThisObject(exec)->toString(exec));
     723}
     724
    712725} // namespace JSC
    713726
  • trunk/JavaScriptCore/runtime/JSString.cpp

    r56021 r57019  
    144144}
    145145
    146 UString JSString::toThisString(ExecState* exec) const
    147 {
    148     return value(exec);
    149 }
    150 
    151 JSString* JSString::toThisJSString(ExecState*)
    152 {
    153     return this;
    154 }
    155 
    156146inline StringObject* StringObject::create(ExecState* exec, JSString* string)
    157147{
  • trunk/JavaScriptCore/runtime/JSString.h

    r56021 r57019  
    298298
    299299        virtual JSObject* toThisObject(ExecState*) const;
    300         virtual UString toThisString(ExecState*) const;
    301         virtual JSString* toThisJSString(ExecState*);
    302300
    303301        // Actually getPropertySlot, not getOwnPropertySlot (see JSCell).
     
    485483
    486484    // --- JSValue inlines ----------------------------
    487 
    488     inline JSString* JSValue::toThisJSString(ExecState* exec)
    489     {
    490         return isCell() ? asCell()->toThisJSString(exec) : jsString(exec, toString(exec));
    491     }
    492485
    493486    inline UString JSValue::toString(ExecState* exec) const
  • trunk/JavaScriptCore/runtime/JSValue.h

    r52731 r57019  
    189189        JSObject* toThisObject(ExecState*) const;
    190190        UString toThisString(ExecState*) const;
    191         JSString* toThisJSString(ExecState*);
     191        JSString* toThisJSString(ExecState*) const;
    192192
    193193        static bool equal(ExecState* exec, JSValue v1, JSValue v2);
  • trunk/JavaScriptCore/runtime/JSZombie.h

    r51625 r57019  
    6161    virtual bool deleteProperty(ExecState*, unsigned) { ASSERT_NOT_REACHED(); return false; }
    6262    virtual JSObject* toThisObject(ExecState*) const { ASSERT_NOT_REACHED(); return 0; }
    63     virtual UString toThisString(ExecState*) const { ASSERT_NOT_REACHED(); return ""; }
    64     virtual JSString* toThisJSString(ExecState*) { ASSERT_NOT_REACHED(); return 0; }
    6563    virtual JSValue getJSNumber() { ASSERT_NOT_REACHED(); return jsNull(); }
    6664    virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&) { ASSERT_NOT_REACHED(); return false; }
Note: See TracChangeset for help on using the changeset viewer.