Changeset 2783 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Nov 20, 2002, 1:12:14 PM (23 years ago)
Author:
darin
Message:
  • decrease ref/deref -- 5% speedup in iBench
  • JavaScriptCore.pbproj/project.pbxproj: Added array_instance.h
  • kjs/array_instance.h: Added so it can be shared by function.h.
  • kjs/array_object.cpp:
  • kjs/array_object.h:
  • kjs/bool_object.cpp:
  • kjs/bool_object.h:
  • kjs/collector.cpp:
  • kjs/date_object.cpp:
  • kjs/date_object.h:
  • kjs/error_object.cpp:
  • kjs/function.cpp:
  • kjs/function.h:
  • kjs/function_object.cpp:
  • kjs/internal.cpp:
  • kjs/internal.h:
  • kjs/math_object.cpp:
  • kjs/nodes.cpp:
  • kjs/number_object.cpp:
  • kjs/object.cpp:
  • kjs/object.h:
  • kjs/object_object.cpp:
  • kjs/property_map.cpp:
  • kjs/reference.cpp:
  • kjs/reference.h:
  • kjs/regexp_object.cpp:
  • kjs/string_object.cpp:
  • kjs/string_object.h:
  • kjs/value.cpp:
  • kjs/value.h: Switched lots of interfaces so they don't require ref/deref.
Location:
trunk/JavaScriptCore
Files:
1 added
31 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r2781 r2783  
     12002-11-20  Darin Adler  <[email protected]>
     2
     3        - decrease ref/deref -- 5% speedup in iBench
     4
     5        * JavaScriptCore.pbproj/project.pbxproj: Added array_instance.h
     6        * kjs/array_instance.h: Added so it can be shared by function.h.
     7
     8        * kjs/array_object.cpp:
     9        * kjs/array_object.h:
     10        * kjs/bool_object.cpp:
     11        * kjs/bool_object.h:
     12        * kjs/collector.cpp:
     13        * kjs/date_object.cpp:
     14        * kjs/date_object.h:
     15        * kjs/error_object.cpp:
     16        * kjs/function.cpp:
     17        * kjs/function.h:
     18        * kjs/function_object.cpp:
     19        * kjs/internal.cpp:
     20        * kjs/internal.h:
     21        * kjs/math_object.cpp:
     22        * kjs/nodes.cpp:
     23        * kjs/number_object.cpp:
     24        * kjs/object.cpp:
     25        * kjs/object.h:
     26        * kjs/object_object.cpp:
     27        * kjs/property_map.cpp:
     28        * kjs/reference.cpp:
     29        * kjs/reference.h:
     30        * kjs/regexp_object.cpp:
     31        * kjs/string_object.cpp:
     32        * kjs/string_object.h:
     33        * kjs/value.cpp:
     34        * kjs/value.h:
     35        Switched lots of interfaces so they don't require ref/deref.
     36
    1372002-11-20  Maciej Stachowiak  <[email protected]>
    238
  • trunk/JavaScriptCore/ChangeLog-2002-12-03

    r2781 r2783  
     12002-11-20  Darin Adler  <[email protected]>
     2
     3        - decrease ref/deref -- 5% speedup in iBench
     4
     5        * JavaScriptCore.pbproj/project.pbxproj: Added array_instance.h
     6        * kjs/array_instance.h: Added so it can be shared by function.h.
     7
     8        * kjs/array_object.cpp:
     9        * kjs/array_object.h:
     10        * kjs/bool_object.cpp:
     11        * kjs/bool_object.h:
     12        * kjs/collector.cpp:
     13        * kjs/date_object.cpp:
     14        * kjs/date_object.h:
     15        * kjs/error_object.cpp:
     16        * kjs/function.cpp:
     17        * kjs/function.h:
     18        * kjs/function_object.cpp:
     19        * kjs/internal.cpp:
     20        * kjs/internal.h:
     21        * kjs/math_object.cpp:
     22        * kjs/nodes.cpp:
     23        * kjs/number_object.cpp:
     24        * kjs/object.cpp:
     25        * kjs/object.h:
     26        * kjs/object_object.cpp:
     27        * kjs/property_map.cpp:
     28        * kjs/reference.cpp:
     29        * kjs/reference.h:
     30        * kjs/regexp_object.cpp:
     31        * kjs/string_object.cpp:
     32        * kjs/string_object.h:
     33        * kjs/value.cpp:
     34        * kjs/value.h:
     35        Switched lots of interfaces so they don't require ref/deref.
     36
    1372002-11-20  Maciej Stachowiak  <[email protected]>
    238
  • trunk/JavaScriptCore/ChangeLog-2003-10-25

    r2781 r2783  
     12002-11-20  Darin Adler  <[email protected]>
     2
     3        - decrease ref/deref -- 5% speedup in iBench
     4
     5        * JavaScriptCore.pbproj/project.pbxproj: Added array_instance.h
     6        * kjs/array_instance.h: Added so it can be shared by function.h.
     7
     8        * kjs/array_object.cpp:
     9        * kjs/array_object.h:
     10        * kjs/bool_object.cpp:
     11        * kjs/bool_object.h:
     12        * kjs/collector.cpp:
     13        * kjs/date_object.cpp:
     14        * kjs/date_object.h:
     15        * kjs/error_object.cpp:
     16        * kjs/function.cpp:
     17        * kjs/function.h:
     18        * kjs/function_object.cpp:
     19        * kjs/internal.cpp:
     20        * kjs/internal.h:
     21        * kjs/math_object.cpp:
     22        * kjs/nodes.cpp:
     23        * kjs/number_object.cpp:
     24        * kjs/object.cpp:
     25        * kjs/object.h:
     26        * kjs/object_object.cpp:
     27        * kjs/property_map.cpp:
     28        * kjs/reference.cpp:
     29        * kjs/reference.h:
     30        * kjs/regexp_object.cpp:
     31        * kjs/string_object.cpp:
     32        * kjs/string_object.h:
     33        * kjs/value.cpp:
     34        * kjs/value.h:
     35        Switched lots of interfaces so they don't require ref/deref.
     36
    1372002-11-20  Maciej Stachowiak  <[email protected]>
    238
  • trunk/JavaScriptCore/JavaScriptCore.pbproj/project.pbxproj

    r2760 r2783  
    224224                                F5BB2BC7030F772101FCFE1D,
    225225                                933A349C038AE7C6008635CE,
     226                                938772E6038BFE19008635CE,
    226227                        );
    227228                        isa = PBXHeadersBuildPhase;
     
    319320                08FB77AEFE84172EC02AAC07 = {
    320321                        children = (
     322                                938772E5038BFE19008635CE,
    321323                                F692A84D0255597D01FF60F7,
    322324                                F692A84E0255597D01FF60F7,
     
    472474                        };
    473475                };
     476                938772E5038BFE19008635CE = {
     477                        fileEncoding = 4;
     478                        isa = PBXFileReference;
     479                        path = array_instance.h;
     480                        refType = 4;
     481                };
     482                938772E6038BFE19008635CE = {
     483                        fileRef = 938772E5038BFE19008635CE;
     484                        isa = PBXBuildFile;
     485                        settings = {
     486                        };
     487                };
    474488//930
    475489//931
  • trunk/JavaScriptCore/kjs/array_object.cpp

    r2777 r2783  
    4040const ClassInfo ArrayInstanceImp::info = {"Array", 0, 0, 0};
    4141
    42 ArrayInstanceImp::ArrayInstanceImp(const Object &proto, unsigned initialLength)
     42ArrayInstanceImp::ArrayInstanceImp(ObjectImp *proto, unsigned initialLength)
    4343  : ObjectImp(proto)
    4444  , length(initialLength)
     
    4848}
    4949
    50 ArrayInstanceImp::ArrayInstanceImp(const Object &proto, const List &list)
     50ArrayInstanceImp::ArrayInstanceImp(ObjectImp *proto, const List &list)
    5151  : ObjectImp(proto)
    5252  , length(list.size())
     
    290290ArrayPrototypeImp::ArrayPrototypeImp(ExecState *exec,
    291291                                     ObjectPrototypeImp *objProto)
    292   : ArrayInstanceImp(Object(objProto), 0)
     292  : ArrayInstanceImp(objProto, 0)
    293293{
    294294  Value protect(this);
     
    665665  // a single numeric argument denotes the array size (!)
    666666  if (args.size() == 1 && args[0].type() == NumberType)
    667     return Object(new ArrayInstanceImp(exec->interpreter()->builtinArrayPrototype(), args[0].toUInt32(exec)));
     667    return Object(new ArrayInstanceImp(exec->interpreter()->builtinArrayPrototype().imp(), args[0].toUInt32(exec)));
    668668
    669669  // otherwise the array is constructed with the arguments in it
    670   return Object(new ArrayInstanceImp(exec->interpreter()->builtinArrayPrototype(), args));
     670  return Object(new ArrayInstanceImp(exec->interpreter()->builtinArrayPrototype().imp(), args));
    671671}
    672672
     
    682682  return construct(exec,args);
    683683}
    684 
  • trunk/JavaScriptCore/kjs/array_object.h

    r2760 r2783  
    2727
    2828namespace KJS {
    29 
    30   class ArrayInstanceImp : public ObjectImp {
    31   public:
    32     ArrayInstanceImp(const Object &proto, unsigned initialLength);
    33     ArrayInstanceImp(const Object &proto, const List &initialValues);
    34     ~ArrayInstanceImp();
    35 
    36     virtual Value get(ExecState *exec, const Identifier &propertyName) const;
    37     virtual Value get(ExecState *exec, unsigned propertyName) const;
    38     virtual void put(ExecState *exec, const Identifier &propertyName, const Value &value, int attr = None);
    39     virtual void put(ExecState *exec, unsigned propertyName, const Value &value, int attr = None);
    40     virtual bool hasProperty(ExecState *exec, const Identifier &propertyName) const;
    41     virtual bool hasProperty(ExecState *exec, unsigned propertyName) const;
    42     virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
    43     virtual bool deleteProperty(ExecState *exec, unsigned propertyName);
    44 
    45     virtual void mark();
    46 
    47     virtual const ClassInfo *classInfo() const { return &info; }
    48     static const ClassInfo info;
    49    
    50     unsigned getLength() const { return length; }
    51    
    52     void sort(ExecState *exec);
    53     void sort(ExecState *exec, Object &compareFunction);
    54    
    55   private:
    56     void setLength(unsigned newLength);
    57    
    58     unsigned pushUndefinedObjectsToEnd();
    59    
    60     unsigned length;
    61     unsigned capacity;
    62     ValueImp **storage;
    63   };
    6429
    6530 class ArrayPrototypeImp : public ArrayInstanceImp {
  • trunk/JavaScriptCore/kjs/bool_object.cpp

    r1824 r2783  
    3636const ClassInfo BooleanInstanceImp::info = {"Boolean", 0, 0, 0};
    3737
    38 BooleanInstanceImp::BooleanInstanceImp(const Object &proto)
     38BooleanInstanceImp::BooleanInstanceImp(ObjectImp *proto)
    3939  : ObjectImp(proto)
    4040{
     
    4848                                         ObjectPrototypeImp *objectProto,
    4949                                         FunctionPrototypeImp *funcProto)
    50   : BooleanInstanceImp(Object(objectProto))
     50  : BooleanInstanceImp(objectProto)
    5151{
    5252  Value protect(this);
    5353  // The constructor will be added later by InterpreterImp::InterpreterImp()
    5454
    55   put(exec,toStringPropertyName, Object(new BooleanProtoFuncImp(exec,funcProto,BooleanProtoFuncImp::ToString,0)), DontEnum);
    56   put(exec,valueOfPropertyName,  Object(new BooleanProtoFuncImp(exec,funcProto,BooleanProtoFuncImp::ValueOf,0)),  DontEnum);
     55  putDirect(toStringPropertyName, new BooleanProtoFuncImp(exec,funcProto,BooleanProtoFuncImp::ToString,0), DontEnum);
     56  putDirect(valueOfPropertyName,  new BooleanProtoFuncImp(exec,funcProto,BooleanProtoFuncImp::ValueOf,0),  DontEnum);
    5757  setInternalValue(Boolean(false));
    5858}
     
    6666{
    6767  Value protect(this);
    68   put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
     68  putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
    6969}
    7070
     
    105105{
    106106  Value protect(this);
    107   put(exec,prototypePropertyName, Object(booleanProto),DontEnum|DontDelete|ReadOnly);
     107  putDirect(prototypePropertyName, booleanProto, DontEnum|DontDelete|ReadOnly);
    108108
    109109  // no. of arguments for constructor
    110   put(exec,lengthPropertyName, Number(1), ReadOnly|DontDelete|DontEnum);
     110  putDirect(lengthPropertyName, NumberImp::one(), ReadOnly|DontDelete|DontEnum);
    111111}
    112112
     
    120120Object BooleanObjectImp::construct(ExecState *exec, const List &args)
    121121{
    122   Object proto = exec->interpreter()->builtinBooleanPrototype();
    123   Object obj(new BooleanInstanceImp(proto));
     122  Object obj(new BooleanInstanceImp(exec->interpreter()->builtinBooleanPrototype().imp()));
    124123
    125124  Boolean b;
  • trunk/JavaScriptCore/kjs/bool_object.h

    r1024 r2783  
    3030  class BooleanInstanceImp : public ObjectImp {
    3131  public:
    32     BooleanInstanceImp(const Object &proto);
     32    BooleanInstanceImp(ObjectImp *proto);
    3333
    3434    virtual const ClassInfo *classInfo() const { return &info; }
  • trunk/JavaScriptCore/kjs/collector.cpp

    r2781 r2783  
    100100    heap.oversizeCells[heap.usedOversizeCells] = (CollectorCell *)newCell;
    101101    heap.usedOversizeCells++;
     102    heap.numLiveObjects++;
    102103   
    103104    return (void *)newCell;
     
    141142          targetBlock->bitmap[wordInBitmap] |= (1 << bitInWord);
    142143          targetBlock->usedCells++;
     144          heap.numLiveObjects++;
    143145          return (void *)(targetBlock->cells + cellPos);
    144146        }
     
    293295
    294296#if APPLE_CHANGES
     297
    295298int Collector::numInterpreters()
    296299{
     
    343346       
    344347        if ((word & (1 << bitInWord)) &&
    345             imp->refcount == 0) {
     348            imp->refcount != 0) {
    346349          ++count;
    347350        }
     
    352355  for (int cell = 0; cell < heap.usedOversizeCells; cell++) {
    353356    ValueImp *imp = (ValueImp *)heap.oversizeCells[cell];
    354       if (imp->refcount == 0) {
     357      if (imp->refcount != 0) {
    355358        ++count;
    356359      }
     
    360363}
    361364
     365// FIXME: Rename. Root object classes are more useful than live object classes.
    362366CFSetRef Collector::liveObjectClasses()
    363367{
     
    370374        ValueImp *imp = (ValueImp *)(heap.blocks[block]->cells + BITS_PER_WORD * wordInBitmap + bitInWord);
    371375       
    372         if (word & (1 << bitInWord)) {
     376        if (word & (1 << bitInWord)
     377                && ((imp->_flags & ValueImp::VI_GCALLOWED) == 0 || imp->refcount != 0)) {
    373378          const char *mangled_name = typeid(*imp).name();
    374379          int status;
     
    386391  for (int cell = 0; cell < heap.usedOversizeCells; cell++) {
    387392    ValueImp *imp = (ValueImp *)heap.oversizeCells[cell];
    388 
    389     const char *mangled_name = typeid(*imp).name();
    390     int status;
    391     char *demangled_name = __cxxabiv1::__cxa_demangle (mangled_name, NULL, NULL, &status);
    392    
    393     CFStringRef className = CFStringCreateWithCString(NULL, demangled_name, kCFStringEncodingASCII);
    394     free(demangled_name);
    395     CFSetAddValue(classes, className);
    396     CFRelease(className);
     393   
     394    if ((imp->_flags & ValueImp::VI_GCALLOWED) == 0 || imp->refcount != 0) {
     395        const char *mangled_name = typeid(*imp).name();
     396        int status;
     397        char *demangled_name = __cxxabiv1::__cxa_demangle (mangled_name, NULL, NULL, &status);
     398       
     399        CFStringRef className = CFStringCreateWithCString(NULL, demangled_name, kCFStringEncodingASCII);
     400        free(demangled_name);
     401        CFSetAddValue(classes, className);
     402        CFRelease(className);
     403    }
    397404  }
    398405
     
    400407}
    401408
    402 #endif
     409#endif // APPLE_CHANGES
  • trunk/JavaScriptCore/kjs/date_object.cpp

    r2760 r2783  
    210210const ClassInfo DateInstanceImp::info = {"Date", 0, 0, 0};
    211211
    212 DateInstanceImp::DateInstanceImp(const Object &proto)
     212DateInstanceImp::DateInstanceImp(ObjectImp *proto)
    213213  : ObjectImp(proto)
    214214{
     
    272272DatePrototypeImp::DatePrototypeImp(ExecState *,
    273273                                   ObjectPrototypeImp *objectProto)
    274   : DateInstanceImp(Object(objectProto))
     274  : DateInstanceImp(objectProto)
    275275{
    276276  Value protect(this);
    277   setInternalValue(Number(NaN));
     277  setInternalValue(NumberImp::create(NaN));
    278278  // The constructor will be added later, after DateObjectImp has been built
    279279}
     
    293293{
    294294  Value protect(this);
    295   put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
     295  putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
    296296}
    297297
     
    524524{
    525525  Value protect(this);
     526 
    526527  // ECMA 15.9.4.1 Date.prototype
    527   put(exec,prototypePropertyName, Object(dateProto), DontEnum|DontDelete|ReadOnly);
    528 
    529   put(exec,"parse", Object(new DateObjectFuncImp(exec,funcProto,DateObjectFuncImp::Parse, 1)), DontEnum);
    530   put(exec,"UTC",   Object(new DateObjectFuncImp(exec,funcProto,DateObjectFuncImp::UTC,   7)),   DontEnum);
     528  putDirect(prototypePropertyName, dateProto, DontEnum|DontDelete|ReadOnly);
     529
     530  static const Identifier parsePropertyName("parse");
     531  putDirect(parsePropertyName, new DateObjectFuncImp(exec,funcProto,DateObjectFuncImp::Parse, 1), DontEnum);
     532  static const Identifier UTCPropertyName("UTC");
     533  putDirect("UTC",   new DateObjectFuncImp(exec,funcProto,DateObjectFuncImp::UTC,   7),   DontEnum);
    531534
    532535  // no. of arguments for constructor
    533   put(exec,lengthPropertyName, Number(7), ReadOnly|DontDelete|DontEnum);
     536  putDirect(lengthPropertyName, 7, ReadOnly|DontDelete|DontEnum);
    534537}
    535538
     
    602605
    603606  Object proto = exec->interpreter()->builtinDatePrototype();
    604   Object ret(new DateInstanceImp(proto));
     607  Object ret(new DateInstanceImp(proto.imp()));
    605608  ret.setInternalValue(timeClip(value));
    606609  return ret;
     
    637640{
    638641  Value protect(this);
    639   put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
     642  putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
    640643}
    641644
  • trunk/JavaScriptCore/kjs/date_object.h

    r2760 r2783  
    3232  class DateInstanceImp : public ObjectImp {
    3333  public:
    34     DateInstanceImp(const Object &proto);
     34    DateInstanceImp(ObjectImp *proto);
    3535
    3636    virtual const ClassInfo *classInfo() const { return &info; }
  • trunk/JavaScriptCore/kjs/error_object.cpp

    r2772 r2783  
    3636                                     ObjectPrototypeImp *objectProto,
    3737                                     FunctionPrototypeImp *funcProto)
    38   : ObjectImp(Object(objectProto))
     38  : ObjectImp(objectProto)
    3939{
    4040  Value protect(this);
     
    4444  put(exec, namePropertyName,     String("Error"), DontEnum);
    4545  put(exec, messagePropertyName,  String("Unknown error"), DontEnum);
    46   put(exec, toStringPropertyName, Object(new ErrorProtoFuncImp(exec,funcProto)), DontEnum);
     46  putDirect(toStringPropertyName, new ErrorProtoFuncImp(exec,funcProto), DontEnum);
    4747}
    4848
     
    5353{
    5454  Value protect(this);
    55   put(exec,lengthPropertyName,Number(0),DontDelete|ReadOnly|DontEnum);
     55  putDirect(lengthPropertyName, NumberImp::zero(), DontDelete|ReadOnly|DontEnum);
    5656}
    5757
     
    8787  Value protect(this);
    8888  // ECMA 15.11.3.1 Error.prototype
    89   put(exec, prototypePropertyName, Object(errorProto), DontEnum|DontDelete|ReadOnly);
    90   //put(exec, namePropertyName, String(n));
     89  putDirect(prototypePropertyName, errorProto, DontEnum|DontDelete|ReadOnly);
     90  //putDirect(namePropertyName, String(n));
    9191}
    9292
     
    100100{
    101101  Object proto = Object::dynamicCast(exec->interpreter()->builtinErrorPrototype());
    102   Object obj(new ObjectImp(proto));
     102  ObjectImp *imp = new ObjectImp(proto);
     103  Object obj(imp);
    103104
    104105  if (!args.isEmpty() && args[0].type() != UndefinedType) {
    105     obj.put(exec, messagePropertyName, String(args[0].toString(exec)));
     106    imp->putDirect(messagePropertyName, new StringImp(args[0].toString(exec)));
    106107  }
    107108
     
    125126NativeErrorPrototypeImp::NativeErrorPrototypeImp(ExecState *exec, ErrorPrototypeImp *errorProto,
    126127                                                 ErrorType et, UString name, UString message)
    127   : ObjectImp(Object(errorProto))
     128  : ObjectImp(errorProto)
    128129{
    129130  Value protect(this);
    130131  errType = et;
    131   put(exec, namePropertyName, String(name));
    132   put(exec, messagePropertyName, String(message));
     132  putDirect(namePropertyName, new StringImp(name), 0);
     133  putDirect(messagePropertyName, new StringImp(message), 0);
    133134}
    134135
     
    144145  proto = static_cast<ObjectImp*>(prot.imp());
    145146
    146   put(exec,lengthPropertyName,Number(1),DontDelete|ReadOnly|DontEnum); // ECMA 15.11.7.5
    147   put(exec,prototypePropertyName,prot);
     147  putDirect(lengthPropertyName, NumberImp::one(), DontDelete|ReadOnly|DontEnum); // ECMA 15.11.7.5
     148  putDirect(prototypePropertyName, proto, 0);
    148149}
    149150
     
    155156Object NativeErrorImp::construct(ExecState *exec, const List &args)
    156157{
    157   Object obj(new ObjectImp(Object(proto)));
     158  ObjectImp *imp = new ObjectImp(proto);
     159  Object obj(imp);
    158160  if (args[0].type() != UndefinedType)
    159     obj.put(exec, messagePropertyName, String(args[0].toString(exec)));
     161    imp->putDirect(messagePropertyName, new StringImp(args[0].toString(exec)));
    160162  return obj;
    161163}
     
    177179    proto->mark();
    178180}
    179 
  • trunk/JavaScriptCore/kjs/function.cpp

    r2779 r2783  
    319319// ECMA 10.1.8
    320320ArgumentsImp::ArgumentsImp(ExecState *exec, FunctionImp *func, const List &args)
    321   : ObjectImp(exec->interpreter()->builtinObjectPrototype())
     321  : ArrayInstanceImp(exec->interpreter()->builtinObjectPrototype().imp(), args)
    322322{
    323323  Value protect(this);
    324   put(exec,calleePropertyName, Object(func), DontEnum);
    325   put(exec,lengthPropertyName, Number(args.size()), DontEnum);
    326   if (!args.isEmpty()) {
    327     ListIterator arg = args.begin();
    328     for (int i = 0; arg != args.end(); arg++, i++) {
    329       put(exec,i, *arg, DontEnum);
    330     }
    331   }
     324  putDirect(calleePropertyName, func, DontEnum);
    332325}
    333326
     
    338331// ECMA 10.1.6
    339332ActivationImp::ActivationImp(ExecState *exec, FunctionImp *f, const List &args)
    340   : _function(f)
     333  : _function(f), _arguments(args)
    341334{
    342335  Value protect(this);
    343   arguments = new ArgumentsImp(exec,f, args);
    344   arguments->setGcAllowed();
    345   put(exec, argumentsPropertyName, Object(arguments), Internal|DontDelete);
     336  _argumentsObject = new ArgumentsImp(exec, f, args);
     337  putDirect(argumentsPropertyName, _argumentsObject, Internal|DontDelete);
    346338}
    347339
     
    353345{
    354346  Value protect(this);
    355   put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
     347  putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
    356348}
    357349
  • trunk/JavaScriptCore/kjs/function.h

    r2779 r2783  
    2525
    2626#include "internal.h"
     27#include "array_instance.h"
    2728
    2829namespace KJS {
     
    9192
    9293
    93   class ArgumentsImp : public ObjectImp {
     94  class ArgumentsImp : public ArrayInstanceImp {
    9495  public:
    9596    ArgumentsImp(ExecState *exec, FunctionImp *func, const List &args);
     
    103104    ActivationImp(ExecState *exec, FunctionImp *f, const List &args);
    104105
    105     Object argumentsObject() { return Object(arguments); }
    106 
    107106    virtual const ClassInfo *classInfo() const { return &info; }
    108107    static const ClassInfo info;
     
    112111  private:
    113112    FunctionImp *_function;
    114     ObjectImp* arguments;
     113    List _arguments;
     114    ObjectImp *_argumentsObject;
    115115  };
    116116
  • trunk/JavaScriptCore/kjs/function_object.cpp

    r2778 r2783  
    4141{
    4242  Value protect(this);
    43   put(exec, toStringPropertyName, Object(new FunctionProtoFuncImp(exec, this, FunctionProtoFuncImp::ToString, 0)), DontEnum);
    44   put(exec, "apply",    Object(new FunctionProtoFuncImp(exec, this, FunctionProtoFuncImp::Apply,    2)), DontEnum);
    45   put(exec, "call",     Object(new FunctionProtoFuncImp(exec, this, FunctionProtoFuncImp::Call,     1)), DontEnum);
     43  putDirect(toStringPropertyName, new FunctionProtoFuncImp(exec, this, FunctionProtoFuncImp::ToString, 0), DontEnum);
     44  static const Identifier applyPropertyName("apply");
     45  putDirect(applyPropertyName,    new FunctionProtoFuncImp(exec, this, FunctionProtoFuncImp::Apply,    2), DontEnum);
     46  static const Identifier callPropertyName("call");
     47  putDirect(callPropertyName,     new FunctionProtoFuncImp(exec, this, FunctionProtoFuncImp::Call,     1), DontEnum);
    4648}
    4749
     
    6870{
    6971  Value protect(this);
    70   put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
     72  putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
    7173}
    7274
     
    175177{
    176178  Value protect(this);
    177   put(exec,prototypePropertyName, Object(funcProto), DontEnum|DontDelete|ReadOnly);
     179  putDirect(prototypePropertyName, funcProto, DontEnum|DontDelete|ReadOnly);
    178180
    179181  // no. of arguments for constructor
    180   put(exec,lengthPropertyName, Number(1), ReadOnly|DontDelete|DontEnum);
     182  putDirect(lengthPropertyName, NumberImp::one(), ReadOnly|DontDelete|DontEnum);
    181183}
    182184
     
    276278  }
    277279
    278   fimp->put(exec,lengthPropertyName, Number(params),ReadOnly|DontDelete|DontEnum);
    279280  List consArgs;
    280281
    281282  Object objCons = exec->interpreter()->builtinObject();
    282283  Object prototype = objCons.construct(exec,List::empty());
    283   prototype.put(exec, constructorPropertyName,
    284                 Object(fimp), DontEnum|DontDelete|ReadOnly);
    285   fimp->put(exec,prototypePropertyName,prototype,DontEnum|DontDelete|ReadOnly);
     284  prototype.put(exec, constructorPropertyName, Value(fimp), DontEnum|DontDelete|ReadOnly);
     285  fimp->put(exec, prototypePropertyName, prototype, DontEnum|DontDelete|ReadOnly);
    286286  return ret;
    287287}
  • trunk/JavaScriptCore/kjs/internal.cpp

    r2760 r2783  
    222222// ------------------------------ NumberImp ------------------------------------
    223223
     224NumberImp *NumberImp::staticNaN;
     225
     226ValueImp *NumberImp::create(int i)
     227{
     228    if (SimpleNumber::fits(i))
     229        return SimpleNumber::make(i);
     230    NumberImp *imp = new NumberImp(static_cast<double>(i));
     231    imp->setGcAllowedFast();
     232    return imp;
     233}
     234
     235ValueImp *NumberImp::create(double d)
     236{
     237    if (SimpleNumber::fits(d))
     238        return SimpleNumber::make((int)d);
     239    if (isNaN(d))
     240        return staticNaN;
     241    NumberImp *imp = new NumberImp(d);
     242    imp->setGcAllowedFast();
     243    return imp;
     244}
     245
    224246Value NumberImp::toPrimitive(ExecState *, Type) const
    225247{
     
    453475  BooleanImp::staticFalse = new BooleanImp(false);
    454476  BooleanImp::staticFalse->ref();
     477  NumberImp::staticNaN = new NumberImp(NaN);
     478  NumberImp::staticNaN->ref();
    455479}
    456480
     
    470494  BooleanImp::staticFalse->setGcAllowed();
    471495  BooleanImp::staticFalse = 0L;
     496  NumberImp::staticNaN->deref();
     497  NumberImp::staticNaN->setGcAllowed();
     498  NumberImp::staticNaN = 0;
    472499}
    473500
     
    787814
    788815InternalFunctionImp::InternalFunctionImp(FunctionPrototypeImp *funcProto)
    789   : ObjectImp(Object(funcProto))
     816  : ObjectImp(funcProto)
    790817{
    791818}
  • trunk/JavaScriptCore/kjs/internal.h

    r2778 r2783  
    119119
    120120  class NumberImp : public ValueImp {
    121   public:
    122     NumberImp(double v) : val(v) { }
     121    friend class Number;
     122    friend class InterpreterImp;
     123  public:
     124    static ValueImp *create(int);
     125    static ValueImp *create(double);
     126    static ValueImp *zero() { return SimpleNumber::make(0); }
     127    static ValueImp *one() { return SimpleNumber::make(1); }
     128    static ValueImp *two() { return SimpleNumber::make(2); }
     129   
    123130    double value() const { return val; }
    124131
     
    131138    Object toObject(ExecState *exec) const;
    132139
    133   private:
     140    static NumberImp *staticNaN;
     141
     142  private:
     143    NumberImp(double v) : val(v) { }
     144
    134145    virtual bool toUInt32(unsigned&) const;
    135146
  • trunk/JavaScriptCore/kjs/math_object.cpp

    r2760 r2783  
    7777MathObjectImp::MathObjectImp(ExecState * /*exec*/,
    7878                             ObjectPrototypeImp *objProto)
    79   : ObjectImp(Object(objProto))
     79  : ObjectImp(objProto)
    8080{
    8181}
     
    131131{
    132132  Value protect(this);
    133   put(exec,lengthPropertyName,Number(l),DontDelete|ReadOnly|DontEnum);
     133  putDirect(lengthPropertyName, l, DontDelete|ReadOnly|DontEnum);
    134134}
    135135
  • trunk/JavaScriptCore/kjs/nodes.cpp

    r2778 r2783  
    229229      //cout << "Resolve: FOUND '" << ident.ascii() << "'"
    230230      //     << " in " << (void*)o << " " << o->classInfo()->className << endl;
    231       return Reference(Object(o), ident);
     231      return Reference(o, ident);
    232232    }
    233233    scope++;
  • trunk/JavaScriptCore/kjs/number_object.cpp

    r2772 r2783  
    5151{
    5252  Value protect(this);
    53   setInternalValue(Number(0));
     53  setInternalValue(NumberImp::zero());
    5454
    5555  // The constructor will be added later, after NumberObjectImp has been constructed
    5656
    57   put(exec,toStringPropertyName,       Object(new NumberProtoFuncImp(exec,funcProto,NumberProtoFuncImp::ToString,       1)), DontEnum);
    58   put(exec,toLocaleStringPropertyName, Object(new NumberProtoFuncImp(exec,funcProto,NumberProtoFuncImp::ToLocaleString, 0)), DontEnum);
    59   put(exec,valueOfPropertyName,        Object(new NumberProtoFuncImp(exec,funcProto,NumberProtoFuncImp::ValueOf,        0)), DontEnum);
     57  putDirect(toStringPropertyName,       new NumberProtoFuncImp(exec,funcProto,NumberProtoFuncImp::ToString,       1), DontEnum);
     58  putDirect(toLocaleStringPropertyName, new NumberProtoFuncImp(exec,funcProto,NumberProtoFuncImp::ToLocaleString, 0), DontEnum);
     59  putDirect(valueOfPropertyName,        new NumberProtoFuncImp(exec,funcProto,NumberProtoFuncImp::ValueOf,        0), DontEnum);
    6060}
    6161
     
    6868{
    6969  Value protect(this);
    70   put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
     70  putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
    7171}
    7272
     
    125125  Value protect(this);
    126126  // Number.Prototype
    127   put(exec,prototypePropertyName, Value(numberProto),DontEnum|DontDelete|ReadOnly);
     127  putDirect(prototypePropertyName, numberProto,DontEnum|DontDelete|ReadOnly);
    128128
    129129  // no. of arguments for constructor
    130   put(exec,lengthPropertyName, Number(1), ReadOnly|DontDelete|DontEnum);
     130  putDirect(lengthPropertyName, NumberImp::one(), ReadOnly|DontDelete|DontEnum);
    131131}
    132132
  • trunk/JavaScriptCore/kjs/object.cpp

    r2772 r2783  
    5959}
    6060
     61ObjectImp::ObjectImp(ObjectImp *proto)
     62  : _proto(proto), _internalValue(0L), _scope(true)
     63{
     64  //fprintf(stderr,"ObjectImp::ObjectImp %p\n",(void*)this);
     65}
     66
    6167ObjectImp::ObjectImp() :
    6268  _scope(true)
     
    153159}
    154160
    155 // This get method only looks at the property map.
    156 // A bit like hasProperty(recursive=false), this doesn't go to the prototype.
    157 // This is used e.g. by lookupOrCreateFunction (to cache a function, we don't want
    158 // to look up in the prototype, it might already exist there)
    159 ValueImp* ObjectImp::getDirect(const Identifier& propertyName) const
    160 {
    161   return _prop.get(propertyName);
    162 }
    163 
    164161// ECMA 8.6.2.2
    165162void ObjectImp::put(ExecState *exec, const Identifier &propertyName,
     
    168165  assert(!value.isNull());
    169166  assert(value.type() != ListType);
     167
     168  // non-standard netscape extension
     169  if (propertyName == specialPrototypePropertyName) {
     170    setPrototype(value);
     171    return;
     172  }
    170173
    171174  /* TODO: check for write permissions directly w/o this call */
     
    178181    fprintf( stderr, "WARNING: canPut %s said NO\n", propertyName.ascii() );
    179182#endif
    180     return;
    181   }
    182 
    183   // non-standard netscape extension
    184   if (propertyName == specialPrototypePropertyName) {
    185     setPrototype(value);
    186183    return;
    187184  }
     
    395392      for (int i = 0; i < size; ++i, ++e) {
    396393        if ( e->s && !(e->attr & DontEnum) )
    397           list.append(Reference(Object(this), e->s)); /// ######### check for duplicates with the propertymap
     394          list.append(Reference(this, e->s)); /// ######### check for duplicates with the propertymap
    398395      }
    399396    }
     
    412409{
    413410  _internalValue = v.imp();
     411}
     412
     413void ObjectImp::setInternalValue(ValueImp *v)
     414{
     415  v->setGcAllowed();
     416  _internalValue = v;
    414417}
    415418
     
    445448}
    446449
     450void ObjectImp::putDirect(const Identifier &propertyName, ValueImp *value, int attr)
     451{
     452    value->setGcAllowed();
     453    _prop.put(propertyName, value, attr);
     454}
     455
     456void ObjectImp::putDirect(const Identifier &propertyName, int value, int attr)
     457{
     458    _prop.put(propertyName, NumberImp::create(value), attr);
     459}
    447460
    448461// ------------------------------ Error ----------------------------------------
  • trunk/JavaScriptCore/kjs/object.h

    r2772 r2783  
    370370     */
    371371    ObjectImp(const Object &proto);
     372    ObjectImp(ObjectImp *proto);
    372373
    373374    /**
     
    525526     * It's simply a quick way to remove everything before destroying.
    526527     */
    527     void deleteAllProperties( ExecState * );
     528    void deleteAllProperties(ExecState *);
    528529
    529530    /**
     
    572573    Value internalValue() const;
    573574    void setInternalValue(const Value &v);
     575    void setInternalValue(ValueImp *v);
    574576
    575577    Value toPrimitive(ExecState *exec,
     
    580582    Object toObject(ExecState *exec) const;
    581583
    582     ValueImp* getDirect(const Identifier& propertyName) const;
     584    // This get method only looks at the property map.
     585    // A bit like hasProperty(recursive=false), this doesn't go to the prototype.
     586    // This is used e.g. by lookupOrCreateFunction (to cache a function, we don't want
     587    // to look up in the prototype, it might already exist there)
     588    ValueImp *getDirect(const Identifier& propertyName) const
     589        { return _prop.get(propertyName); }
     590    void putDirect(const Identifier &propertyName, ValueImp *value, int attr = 0);
     591    void putDirect(const Identifier &propertyName, int value, int attr = 0);
     592
    583593  private:
    584594    const HashEntry* findPropertyHashEntry( const Identifier& propertyName ) const;
  • trunk/JavaScriptCore/kjs/object_object.cpp

    r1799 r2783  
    3939{
    4040  Value protect(this);
    41   put(exec,toStringPropertyName, Object(new ObjectProtoFuncImp(exec,funcProto,ObjectProtoFuncImp::ToString, 0)), DontEnum);
    42   put(exec,valueOfPropertyName,  Object(new ObjectProtoFuncImp(exec,funcProto,ObjectProtoFuncImp::ValueOf,  0)), DontEnum);
     41  putDirect(toStringPropertyName, new ObjectProtoFuncImp(exec,funcProto,ObjectProtoFuncImp::ToString, 0), DontEnum);
     42  putDirect(valueOfPropertyName,  new ObjectProtoFuncImp(exec,funcProto,ObjectProtoFuncImp::ValueOf,  0), DontEnum);
    4343}
    4444
     
    5252{
    5353  Value protect(this);
    54   put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
     54  putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
    5555}
    5656
     
    8080  Value protect(this);
    8181  // ECMA 15.2.3.1
    82   put(exec,prototypePropertyName, Object(objProto), DontEnum|DontDelete|ReadOnly);
     82  putDirect(prototypePropertyName, objProto, DontEnum|DontDelete|ReadOnly);
    8383
    8484  // no. of arguments for constructor
    85   put(exec,lengthPropertyName, Number(1), ReadOnly|DontDelete|DontEnum);
     85  putDirect(lengthPropertyName, NumberImp::one(), ReadOnly|DontDelete|DontEnum);
    8686}
    8787
  • trunk/JavaScriptCore/kjs/property_map.cpp

    r2777 r2783  
    127127{
    128128    UString::Rep *rep = name._ustring.rep;
    129 
     129   
    130130#if USE_SINGLE_ENTRY
    131131    if (!_table) {
  • trunk/JavaScriptCore/kjs/reference.cpp

    r2766 r2783  
    3737
    3838Reference::Reference(const Object& b, unsigned p)
     39  : base(b),
     40    propertyNameAsNumber(p),
     41    baseIsValue(false),
     42    propertyNameIsNumber(true)
     43{
     44}
     45
     46Reference::Reference(ObjectImp *b, const Identifier& p)
     47  : base(b),
     48    baseIsValue(false),
     49    propertyNameIsNumber(false),
     50    prop(p)
     51{
     52}
     53
     54Reference::Reference(ObjectImp *b, unsigned p)
    3955  : base(b),
    4056    propertyNameAsNumber(p),
  • trunk/JavaScriptCore/kjs/reference.h

    r2760 r2783  
    3535    Reference(const Object& b, const Identifier& p);
    3636    Reference(const Object& b, unsigned p);
     37    Reference(ObjectImp *b, const Identifier& p);
     38    Reference(ObjectImp *b, unsigned p);
    3739    Reference(const Null& b, const Identifier& p);
    3840    Reference(const Null& b, unsigned p);
  • trunk/JavaScriptCore/kjs/regexp_object.cpp

    r2766 r2783  
    4141                                       ObjectPrototypeImp *objProto,
    4242                                       FunctionPrototypeImp *funcProto)
    43   : ObjectImp(Object(objProto))
     43  : ObjectImp(objProto)
    4444{
    4545  Value protect(this);
     
    4848  // The constructor will be added later in RegExpObject's constructor (?)
    4949
    50   put(exec, "exec",     Object(new RegExpProtoFuncImp(exec,funcProto,RegExpProtoFuncImp::Exec,     0)), DontEnum);
    51   put(exec, "test",     Object(new RegExpProtoFuncImp(exec,funcProto,RegExpProtoFuncImp::Test,     0)), DontEnum);
    52   put(exec, toStringPropertyName, Object(new RegExpProtoFuncImp(exec,funcProto,RegExpProtoFuncImp::ToString, 0)), DontEnum);
     50  static const Identifier execPropertyName("exec");
     51  putDirect(execPropertyName,     new RegExpProtoFuncImp(exec,funcProto,RegExpProtoFuncImp::Exec,     0), DontEnum);
     52  static const Identifier testPropertyName("test");
     53  putDirect(testPropertyName,     new RegExpProtoFuncImp(exec,funcProto,RegExpProtoFuncImp::Test,     0), DontEnum);
     54  putDirect(toStringPropertyName, new RegExpProtoFuncImp(exec,funcProto,RegExpProtoFuncImp::ToString, 0), DontEnum);
    5355}
    5456
     
    6062{
    6163  Value protect(this);
    62   put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
     64  putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
    6365}
    6466
     
    138140
    139141RegExpImp::RegExpImp(RegExpPrototypeImp *regexpProto)
    140   : ObjectImp(Object(regexpProto)), reg(0L)
     142  : ObjectImp(regexpProto), reg(0L)
    141143{
    142144}
     
    157159  Value protect(this);
    158160  // ECMA 15.10.5.1 RegExp.prototype
    159   put(exec,prototypePropertyName, Object(regProto), DontEnum|DontDelete|ReadOnly);
     161  putDirect(prototypePropertyName, regProto, DontEnum|DontDelete|ReadOnly);
    160162
    161163  // no. of arguments for constructor
    162   put(exec,lengthPropertyName, Number(2), ReadOnly|DontDelete|DontEnum);
     164  putDirect(lengthPropertyName, NumberImp::two(), ReadOnly|DontDelete|DontEnum);
    163165}
    164166
     
    222224Object RegExpObjectImp::construct(ExecState *exec, const List &args)
    223225{
    224   String p = args.isEmpty() ? UString("") : args[0].toString(exec);
     226  UString p = args.isEmpty() ? UString("") : args[0].toString(exec);
    225227  UString flags = args[1].toString(exec);
    226228
     
    234236  // TODO: throw a syntax error on invalid flags
    235237
    236   dat->put(exec, "global", Boolean(global));
    237   dat->put(exec, "ignoreCase", Boolean(ignoreCase));
    238   dat->put(exec, "multiline", Boolean(multiline));
    239 
    240   dat->put(exec, "source", p);
    241   dat->put(exec, "lastIndex", Number(0), DontDelete | DontEnum);
     238  dat->putDirect("global", global ? BooleanImp::staticTrue : BooleanImp::staticFalse);
     239  dat->putDirect("ignoreCase", ignoreCase ? BooleanImp::staticTrue : BooleanImp::staticFalse);
     240  dat->putDirect("multiline", multiline ? BooleanImp::staticTrue : BooleanImp::staticFalse);
     241
     242  dat->putDirect("source", new StringImp(p));
     243  dat->putDirect("lastIndex", NumberImp::zero(), DontDelete | DontEnum);
    242244
    243245  int reflags = RegExp::None;
     
    248250  if (multiline)
    249251      reflags |= RegExp::Multiline;
    250   dat->setRegExp(new RegExp(p.value(), reflags));
     252  dat->setRegExp(new RegExp(p, reflags));
    251253
    252254  return obj;
  • trunk/JavaScriptCore/kjs/string_object.cpp

    r2772 r2783  
    3838const ClassInfo StringInstanceImp::info = {"String", 0, 0, 0};
    3939
    40 StringInstanceImp::StringInstanceImp(const Object &proto)
     40StringInstanceImp::StringInstanceImp(ObjectImp *proto)
    4141  : ObjectImp(proto)
    4242{
     
    4444}
    4545
    46 StringInstanceImp::StringInstanceImp(const Object &proto, const UString &string)
     46StringInstanceImp::StringInstanceImp(ObjectImp *proto, const UString &string)
    4747  : ObjectImp(proto)
    4848{
     
    120120StringPrototypeImp::StringPrototypeImp(ExecState *exec,
    121121                                       ObjectPrototypeImp *objProto)
    122   : StringInstanceImp(Object(objProto))
     122  : StringInstanceImp(objProto)
    123123{
    124124  Value protect(this);
    125125  // The constructor will be added later, after StringObjectImp has been built
    126   put(exec,lengthPropertyName,Number(0),DontDelete|ReadOnly|DontEnum);
     126  putDirect(lengthPropertyName, NumberImp::zero(), DontDelete|ReadOnly|DontEnum);
    127127
    128128}
     
    141141{
    142142  Value protect(this);
    143   put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
     143  putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
    144144}
    145145
     
    532532  Value protect(this);
    533533  // ECMA 15.5.3.1 String.prototype
    534   put(exec,prototypePropertyName, Object(stringProto), DontEnum|DontDelete|ReadOnly);
     534  putDirect(prototypePropertyName, stringProto, DontEnum|DontDelete|ReadOnly);
    535535
    536536  static Identifier fromCharCode("fromCharCode");
    537   put(exec,fromCharCode, Object(new StringObjectFuncImp(exec,funcProto)), DontEnum);
     537  putDirect(fromCharCode, new StringObjectFuncImp(exec,funcProto), DontEnum);
    538538
    539539  // no. of arguments for constructor
    540   put(exec,lengthPropertyName, Number(1), ReadOnly|DontDelete|DontEnum);
     540  putDirect(lengthPropertyName, NumberImp::one(), ReadOnly|DontDelete|DontEnum);
    541541}
    542542
     
    550550Object StringObjectImp::construct(ExecState *exec, const List &args)
    551551{
    552   Object proto = exec->interpreter()->builtinStringPrototype();
     552  ObjectImp *proto = exec->interpreter()->builtinStringPrototype().imp();
    553553  if (args.size() == 0)
    554554    return Object(new StringInstanceImp(proto));
     
    579579{
    580580  Value protect(this);
    581   put(exec,lengthPropertyName,Number(1),DontDelete|ReadOnly|DontEnum);
     581  putDirect(lengthPropertyName, NumberImp::one(), DontDelete|ReadOnly|DontEnum);
    582582}
    583583
  • trunk/JavaScriptCore/kjs/string_object.h

    r2760 r2783  
    3030  class StringInstanceImp : public ObjectImp {
    3131  public:
    32     StringInstanceImp(const Object &proto);
    33     StringInstanceImp(const Object &proto, const UString &string);
     32    StringInstanceImp(ObjectImp *proto);
     33    StringInstanceImp(ObjectImp *proto, const UString &string);
    3434
    3535    virtual Value get(ExecState *exec, const Identifier &propertyName) const;
  • trunk/JavaScriptCore/kjs/value.cpp

    r1850 r2783  
    203203{
    204204  rep = v;
    205   if (rep)
     205  if (v)
    206206  {
    207     rep->ref();
     207    v->ref();
    208208    //fprintf(stderr, "Value::Value(%p) imp=%p ref=%d\n", this, rep, rep->refcount);
    209209    v->setGcAllowed();
     
    296296// ------------------------------ String ---------------------------------------
    297297
    298 String::String(const UString &s) : Value(new StringImp(UString(s)))
     298String::String(const UString &s) : Value(new StringImp(s))
    299299{
    300300}
     
    323323
    324324Number::Number(double d)
    325   : Value(SimpleNumber::fits(d) ? SimpleNumber::make((long)d) : new NumberImp(d)) { }
     325  : Value(SimpleNumber::fits(d) ? SimpleNumber::make((long)d) : (KJS::isNaN(d) ? NumberImp::staticNaN : new NumberImp(d))) { }
    326326
    327327Number::Number(long int l)
     
    349349int Number::intValue() const
    350350{
    351   return int(value());
     351  if (SimpleNumber::is(rep))
     352    return SimpleNumber::value(rep);
     353  return (int)((NumberImp*)rep)->value();
    352354}
    353355
    354356bool Number::isNaN() const
    355357{
    356   return KJS::isNaN(value());
     358  return rep == NumberImp::staticNaN;
    357359}
    358360
    359361bool Number::isInf() const
    360362{
    361   return KJS::isInf(value());
    362 }
     363  if (SimpleNumber::is(rep))
     364    return false;
     365  return KJS::isInf(((NumberImp*)rep)->value());
     366}
  • trunk/JavaScriptCore/kjs/value.h

    r1861 r2783  
    109109     */
    110110    void setGcAllowed();
     111   
     112    // Will crash if called on a simple number.
     113    void setGcAllowedFast() { _flags |= VI_GCALLOWED; }
    111114
    112115    int toInteger(ExecState *exec) const;
Note: See TracChangeset for help on using the changeset viewer.