Changeset 32286 in webkit


Ignore:
Timestamp:
Apr 20, 2008, 10:16:28 PM (17 years ago)
Author:
ggaren@apple.com
Message:

2008-04-20 Geoffrey Garen <ggaren@apple.com>

Reviewed by Maciej Stachowiak.


Removed Machine.cpp from AllInOneFile.cpp, and manually inlined a few
things that used to be inlined automatically.


1.9% speedup on SunSpider.


My hope is that we'll face fewer surprises in Machine.cpp codegen, now
that GCC is making fewer decisions. The speedup seems to confirm that.

Location:
branches/squirrelfish/JavaScriptCore
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • branches/squirrelfish/JavaScriptCore/ChangeLog

    r32285 r32286  
     12008-04-20  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Reviewed by Maciej Stachowiak.
     4       
     5        Removed Machine.cpp from AllInOneFile.cpp, and manually inlined a few
     6        things that used to be inlined automatically.
     7       
     8        1.9% speedup on SunSpider.
     9       
     10        My hope is that we'll face fewer surprises in Machine.cpp codegen, now
     11        that GCC is making fewer decisions. The speedup seems to confirm that.
     12
    1132008-04-20  Oliver Hunt  <oliver@apple.com>
    214
  • branches/squirrelfish/JavaScriptCore/JavaScriptCore.exp

    r32188 r32286  
    8989__ZN3KJS11Interpreter8evaluateEPNS_9ExecStateERKNS_7UStringEiPKtiPNS_7JSValueE
    9090__ZN3KJS11Interpreter8evaluateEPNS_9ExecStateERKNS_7UStringEiS5_PNS_7JSValueE
    91 __ZN3KJS11JSImmediate4typeEPKNS_7JSValueE
    9291__ZN3KJS11JSImmediate8toObjectEPKNS_7JSValueEPNS_9ExecStateE
    9392__ZN3KJS11JSImmediate8toStringEPKNS_7JSValueE
     
    202201__ZN3KJS8jsStringEPKc
    203202__ZN3KJS8jsStringERKNS_7UStringE
     203__ZN3KJS9Collector12heapAllocateILNS0_8HeapTypeE1EEEPvm
    204204__ZN3KJS9Collector15recordExtraCostEm
    205205__ZN3KJS9Collector17globalObjectCountEv
     
    278278__ZNK3KJS8JSObject21getPropertyAttributesERKNS_10IdentifierERj
    279279__ZNK3KJS8JSObject21implementsHasInstanceEv
    280 __ZNK3KJS8JSObject3getEPNS_9ExecStateERKNS_10IdentifierE
    281 __ZNK3KJS8JSObject3getEPNS_9ExecStateEj
    282280__ZNK3KJS8JSObject4typeEv
    283281__ZNK3KJS8JSObject8toNumberEPNS_9ExecStateE
     
    297295__ZTVN3KJS19InternalFunctionImpE
    298296__ZTVN3KJS8JSObjectE
     297__ZTVN3KJS9NumberImpE
    299298_jscore_collector_introspection
    300299_jscore_fastmalloc_introspection
  • branches/squirrelfish/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r32196 r32286  
    102102                14DA81900D99FD2000B0A4FB /* JSActivation.h in Headers */ = {isa = PBXBuildFile; fileRef = 14DA818E0D99FD2000B0A4FB /* JSActivation.h */; };
    103103                14DE0D690D02431400AACCA2 /* JSGlobalObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14DE0D680D02431400AACCA2 /* JSGlobalObject.cpp */; };
     104                14E0FF120DBAAED00007C0AB /* Machine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 149B15E70D81F986009CB8C7 /* Machine.cpp */; };
    104105                14F252570D08DD8D004ECFFF /* JSVariableObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 14F252560D08DD8D004ECFFF /* JSVariableObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
    105106                14F252610D08DF2F004ECFFF /* JSVariableObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14F252600D08DF2F004ECFFF /* JSVariableObject.cpp */; };
     
    15051506                                14BD5A320A3E91F600BAF59C /* JSValueRef.cpp in Sources */,
    15061507                                14F252610D08DF2F004ECFFF /* JSVariableObject.cpp in Sources */,
     1508                                14E0FF120DBAAED00007C0AB /* Machine.cpp in Sources */,
    15071509                                E1EF79AA0CE97BA60088D500 /* UTF8.cpp in Sources */,
    15081510                                930754C108B0F68000AB3056 /* pcre_compile.cpp in Sources */,
  • branches/squirrelfish/JavaScriptCore/VM/Machine.cpp

    r32283 r32286  
    3737#include "JSLock.h"
    3838#include "JSPropertyNameIterator.h"
     39#include "Parser.h"
    3940#include "Register.h"
    4041#include "internal.h"
  • branches/squirrelfish/JavaScriptCore/kjs/AllInOneFile.cpp

    r32137 r32286  
    7171#include "wtf/FastMalloc.cpp"
    7272#include "wtf/TCSystemAlloc.cpp"
    73 #include "VM/Machine.cpp"
    7473#include "VM/CodeGenerator.cpp"
    7574#include "VM/RegisterFile.cpp"
  • branches/squirrelfish/JavaScriptCore/kjs/JSImmediate.cpp

    r32157 r32286  
    6464}
    6565
    66 JSType JSImmediate::type(const JSValue *v)
    67 {
    68     ASSERT(isImmediate(v));
    69    
    70     uintptr_t tag = getTag(v);
    71     if (tag == UndefinedType)
    72         return v == jsUndefined() ? UndefinedType : NullType;
    73     return static_cast<JSType>(tag);
    74 }
    75 
    7666} // namespace KJS
  • branches/squirrelfish/JavaScriptCore/kjs/JSImmediate.h

    r32103 r32286  
    279279}
    280280
     281ALWAYS_INLINE JSType JSImmediate::type(const JSValue* v)
     282{
     283    ASSERT(isImmediate(v));
     284   
     285    uintptr_t tag = getTag(v);
     286    if (tag == UndefinedType)
     287        return v == undefinedImmediate() ? UndefinedType : NullType;
     288    return static_cast<JSType>(tag);
     289}
     290
    281291} // namespace KJS
    282292
  • branches/squirrelfish/JavaScriptCore/kjs/collector.cpp

    r31787 r32286  
    286286
    287287  return newCell;
    288 }
    289 
    290 void* Collector::allocate(size_t s)
    291 {
    292     return heapAllocate<PrimaryHeap>(s);
    293 }
    294 
    295 void* Collector::allocateNumber(size_t s)
    296 {
    297     return heapAllocate<NumberHeap>(s);
    298288}
    299289
  • branches/squirrelfish/JavaScriptCore/kjs/collector.h

    r32073 r32286  
    3636  class Collector {
    3737  public:
    38     static void* allocate(size_t s);
    39     static void* allocateNumber(size_t s);
     38    class Thread;
     39    enum HeapType { PrimaryHeap, NumberHeap };
     40
     41    static void* allocate(size_t s)
     42    {
     43        return heapAllocate<PrimaryHeap>(s);
     44    }
     45
     46    static void* allocateNumber(size_t s)
     47    {
     48        return heapAllocate<NumberHeap>(s);
     49    }
     50
    4051    static bool collect();
    4152    static bool isBusy(); // true if an allocation or collection is in progress
     
    5768    static HashCountedSet<const char*>* protectedObjectTypeCounts();
    5869
    59     class Thread;
    6070    static void registerThread();
    6171   
     
    6474    static bool isCellMarked(const JSCell*);
    6575    static void markCell(JSCell*);
    66 
    67     enum HeapType { PrimaryHeap, NumberHeap };
    6876
    6977    static void markStackObjectsConservatively(void* start, void* end);
  • branches/squirrelfish/JavaScriptCore/kjs/internal.cpp

    r32188 r32286  
    9292// ------------------------------ NumberImp ------------------------------------
    9393
     94JSType NumberImp::type() const
     95{
     96    return NumberType;
     97}
     98
    9499JSValue* NumberImp::toPrimitive(ExecState*, JSType) const
    95100{
  • branches/squirrelfish/JavaScriptCore/kjs/internal.h

    r32188 r32286  
    6565  };
    6666
    67   class NumberImp : public JSCell {
    68     friend class ConstantValues;
    69     friend JSValue *jsNumberCell(double);
    70   public:
    71     double value() const { return val; }
    72 
    73     virtual JSType type() const { return NumberType; }
    74 
    75     virtual JSValue* toPrimitive(ExecState*, JSType preferred = UnspecifiedType) const;
    76     virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value);
    77     virtual bool toBoolean(ExecState *exec) const;
    78     virtual double toNumber(ExecState *exec) const;
    79     virtual double toNumber(ExecState* exec, Instruction* normalExitPC, Instruction* exceptionExitPC, Instruction*& resultPC) const;
    80     virtual UString toString(ExecState *exec) const;
    81     virtual JSObject *toObject(ExecState *exec) const;
    82    
    83     void* operator new(size_t size)
    84     {
    85         return Collector::allocateNumber(size);
    86     }
    87   private:
    88     NumberImp(double v) : val(v) { }
    89 
    90     virtual bool getUInt32(uint32_t&) const;
    91     virtual bool getTruncatedInt32(int32_t&) const;
    92     virtual bool getTruncatedUInt32(uint32_t&) const;
    93 
    94     double val;
    95   };
    96 
    97 
    9867  // ---------------------------------------------------------------------------
    9968  //                            Evaluation
  • branches/squirrelfish/JavaScriptCore/kjs/object.cpp

    r32188 r32286  
    165165    return ci->className;
    166166  return "Object";
    167 }
    168 
    169 JSValue *JSObject::get(ExecState *exec, const Identifier &propertyName) const
    170 {
    171   PropertySlot slot;
    172 
    173   if (const_cast<JSObject *>(this)->getPropertySlot(exec, propertyName, slot))
    174     return slot.getValue(exec, const_cast<JSObject *>(this), propertyName);
    175    
    176   return jsUndefined();
    177 }
    178 
    179 JSValue *JSObject::get(ExecState *exec, unsigned propertyName) const
    180 {
    181   PropertySlot slot;
    182   if (const_cast<JSObject *>(this)->getPropertySlot(exec, propertyName, slot))
    183     return slot.getValue(exec, const_cast<JSObject *>(this), propertyName);
    184    
    185   return jsUndefined();
    186 }
    187 
    188 bool JSObject::getPropertySlot(ExecState *exec, unsigned propertyName, PropertySlot& slot)
    189 {
    190   JSObject *imp = this;
    191  
    192   while (true) {
    193     if (imp->getOwnPropertySlot(exec, propertyName, slot))
    194       return true;
    195    
    196     JSValue *proto = imp->_proto;
    197     if (!proto->isObject())
    198       break;
    199    
    200     imp = static_cast<JSObject *>(proto);
    201   }
    202  
    203   return false;
    204167}
    205168
     
    306269}
    307270
    308 // ECMA 8.6.2.4
    309271bool JSObject::hasProperty(ExecState *exec, const Identifier &propertyName) const
    310272{
  • branches/squirrelfish/JavaScriptCore/kjs/object.h

    r32188 r32286  
    518518}
    519519
     520inline JSValue *JSObject::get(ExecState *exec, const Identifier &propertyName) const
     521{
     522  PropertySlot slot;
     523
     524  if (const_cast<JSObject *>(this)->getPropertySlot(exec, propertyName, slot))
     525    return slot.getValue(exec, const_cast<JSObject *>(this), propertyName);
     526   
     527  return jsUndefined();
     528}
     529
     530inline JSValue *JSObject::get(ExecState *exec, unsigned propertyName) const
     531{
     532  PropertySlot slot;
     533  if (const_cast<JSObject *>(this)->getPropertySlot(exec, propertyName, slot))
     534    return slot.getValue(exec, const_cast<JSObject *>(this), propertyName);
     535   
     536  return jsUndefined();
     537}
     538
    520539// It may seem crazy to inline a function this large but it makes a big difference
    521540// since this is function very hot in variable lookup
     
    533552        object = static_cast<JSObject *>(proto);
    534553    }
     554}
     555
     556inline bool JSObject::getPropertySlot(ExecState *exec, unsigned propertyName, PropertySlot& slot)
     557{
     558  JSObject *imp = this;
     559 
     560  while (true) {
     561    if (imp->getOwnPropertySlot(exec, propertyName, slot))
     562      return true;
     563   
     564    JSValue *proto = imp->_proto;
     565    if (!proto->isObject())
     566      break;
     567   
     568    imp = static_cast<JSObject *>(proto);
     569  }
     570 
     571  return false;
    535572}
    536573
  • branches/squirrelfish/JavaScriptCore/kjs/value.cpp

    r32158 r32286  
    233233}
    234234
    235 // This method includes a PIC branch to set up the NumberImp's vtable, so we quarantine
    236 // it in a separate function to keep the normal case speedy.
    237 JSValue *jsNumberCell(double d)
    238 {
    239     return new NumberImp(d);
    240 }
    241 
    242235} // namespace KJS
  • branches/squirrelfish/JavaScriptCore/kjs/value.h

    r32188 r32286  
    181181};
    182182
    183 JSValue *jsNumberCell(double);
     183class NumberImp : public JSCell {
     184  friend JSValue* jsNumberCell(double);
     185
     186public:
     187  double value() const { return val; }
     188
     189  virtual JSType type() const;
     190
     191  virtual JSValue* toPrimitive(ExecState*, JSType preferred = UnspecifiedType) const;
     192  virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value);
     193  virtual bool toBoolean(ExecState* exec) const;
     194  virtual double toNumber(ExecState* exec) const;
     195  virtual double toNumber(ExecState* exec, Instruction* normalExitPC, Instruction* exceptionExitPC, Instruction*& resultPC) const;
     196  virtual UString toString(ExecState* exec) const;
     197  virtual JSObject* toObject(ExecState* exec) const;
     198 
     199  void* operator new(size_t size)
     200  {
     201      return Collector::allocateNumber(size);
     202  }
     203
     204private:
     205  NumberImp(double v) : val(v) { }
     206
     207  virtual bool getUInt32(uint32_t&) const;
     208  virtual bool getTruncatedInt32(int32_t&) const;
     209  virtual bool getTruncatedUInt32(uint32_t&) const;
     210
     211  double val;
     212};
    184213
    185214JSCell *jsString(const UString&); // returns empty string if passed null string
     
    193222extern const double NaN;
    194223extern const double Inf;
     224
     225// Beware marking this function ALWAYS_INLINE: It takes a PIC branch, so
     226// inlining it may not always be a win.
     227inline JSValue* jsNumberCell(double d)
     228{
     229    return new NumberImp(d);
     230}
    195231
    196232ALWAYS_INLINE JSValue *jsUndefined()
Note: See TracChangeset for help on using the changeset viewer.