[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

darin darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 06:31:33 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit e434bcf6a1505f93ef4cf2732efb366519ed046c
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Aug 15 19:51:48 2002 +0000

    	Tweaks and small bug fixes to Maciej's excellent new fixnum optimization.
    	Also updated or removed comments that call it "fixnum" instead of "simple number".
    
            * kjs/simple_number.h: Change constant names so they don't SHOUT the way macro
    	names do. Added constants for shift, min, and max. Fixed off-by-1 error that
    	prevented us from using the extreme values on either end. Base the range of
    	numbers on a fixed 32 bits constant rather than the size of a long, because
    	code elsewhere depends on positive numbers fitting into both "unsigned" and
    	"UInt32" while assuming it doesn't need to check; we can easily change this
    	later. Used int types rather than long for essentially the same reason.
    	Fixed the value-extraction function so it will work for negative numbers even
            if the shift is logical, not arithmetic, by using division instead.
    	Renamed functions to be quite terse since they are inside a class.
    
            * kjs/value.h:
            * kjs/value.cpp:
            (ValueImp::dispatchToObject): Call NumberImp::toObject in a "non-virtual"
    	way rather than repeating the code here.
            (ValueImp::dispatchToUInt32): Handle the negative number case correctly.
            (ValueImp::dispatchGetBase): Call ValueImp::getBase in a "non-virtual"
    	way rather than repeating the code here.
            (ValueImp::dispatchGetPropertyName): Call ValueImp::getPropertyName in a
    	"non-virtual" way rather than repeating the code here.
            (ValueImp::dispatchPutValue): Call ValueImp::putValue in a "non-virtual"
    	way rather than repeating the code here.
            (ValueImp::dispatchDeleteValue): Call ValueImp::deleteValue in a "non-virtual"
    	way rather than repeating the code here.
            (Number::Number): Fixed a bug where the double-based constructor was casting
    	to long, so wouldn't do the "remainder" check.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1832 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 7630b33..e860af3 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,35 @@
+2002-08-15  Darin Adler  <darin at apple.com>
+
+	Tweaks and small bug fixes to Maciej's excellent new fixnum optimization.
+	Also updated or removed comments that call it "fixnum" instead of "simple number".
+
+        * kjs/simple_number.h: Change constant names so they don't SHOUT the way macro
+	names do. Added constants for shift, min, and max. Fixed off-by-1 error that
+	prevented us from using the extreme values on either end. Base the range of
+	numbers on a fixed 32 bits constant rather than the size of a long, because
+	code elsewhere depends on positive numbers fitting into both "unsigned" and
+	"UInt32" while assuming it doesn't need to check; we can easily change this
+	later. Used int types rather than long for essentially the same reason.
+	Fixed the value-extraction function so it will work for negative numbers even
+        if the shift is logical, not arithmetic, by using division instead.
+	Renamed functions to be quite terse since they are inside a class.
+
+        * kjs/value.h:
+        * kjs/value.cpp:
+        (ValueImp::dispatchToObject): Call NumberImp::toObject in a "non-virtual"
+	way rather than repeating the code here.
+        (ValueImp::dispatchToUInt32): Handle the negative number case correctly.
+        (ValueImp::dispatchGetBase): Call ValueImp::getBase in a "non-virtual"
+	way rather than repeating the code here.
+        (ValueImp::dispatchGetPropertyName): Call ValueImp::getPropertyName in a
+	"non-virtual" way rather than repeating the code here.
+        (ValueImp::dispatchPutValue): Call ValueImp::putValue in a "non-virtual"
+	way rather than repeating the code here.
+        (ValueImp::dispatchDeleteValue): Call ValueImp::deleteValue in a "non-virtual"
+	way rather than repeating the code here.
+        (Number::Number): Fixed a bug where the double-based constructor was casting
+	to long, so wouldn't do the "remainder" check.
+
 === Alexander-19 ===
 
 === Alexander-18 ===
diff --git a/JavaScriptCore/ChangeLog-2002-12-03 b/JavaScriptCore/ChangeLog-2002-12-03
index 7630b33..e860af3 100644
--- a/JavaScriptCore/ChangeLog-2002-12-03
+++ b/JavaScriptCore/ChangeLog-2002-12-03
@@ -1,3 +1,35 @@
+2002-08-15  Darin Adler  <darin at apple.com>
+
+	Tweaks and small bug fixes to Maciej's excellent new fixnum optimization.
+	Also updated or removed comments that call it "fixnum" instead of "simple number".
+
+        * kjs/simple_number.h: Change constant names so they don't SHOUT the way macro
+	names do. Added constants for shift, min, and max. Fixed off-by-1 error that
+	prevented us from using the extreme values on either end. Base the range of
+	numbers on a fixed 32 bits constant rather than the size of a long, because
+	code elsewhere depends on positive numbers fitting into both "unsigned" and
+	"UInt32" while assuming it doesn't need to check; we can easily change this
+	later. Used int types rather than long for essentially the same reason.
+	Fixed the value-extraction function so it will work for negative numbers even
+        if the shift is logical, not arithmetic, by using division instead.
+	Renamed functions to be quite terse since they are inside a class.
+
+        * kjs/value.h:
+        * kjs/value.cpp:
+        (ValueImp::dispatchToObject): Call NumberImp::toObject in a "non-virtual"
+	way rather than repeating the code here.
+        (ValueImp::dispatchToUInt32): Handle the negative number case correctly.
+        (ValueImp::dispatchGetBase): Call ValueImp::getBase in a "non-virtual"
+	way rather than repeating the code here.
+        (ValueImp::dispatchGetPropertyName): Call ValueImp::getPropertyName in a
+	"non-virtual" way rather than repeating the code here.
+        (ValueImp::dispatchPutValue): Call ValueImp::putValue in a "non-virtual"
+	way rather than repeating the code here.
+        (ValueImp::dispatchDeleteValue): Call ValueImp::deleteValue in a "non-virtual"
+	way rather than repeating the code here.
+        (Number::Number): Fixed a bug where the double-based constructor was casting
+	to long, so wouldn't do the "remainder" check.
+
 === Alexander-19 ===
 
 === Alexander-18 ===
diff --git a/JavaScriptCore/ChangeLog-2003-10-25 b/JavaScriptCore/ChangeLog-2003-10-25
index 7630b33..e860af3 100644
--- a/JavaScriptCore/ChangeLog-2003-10-25
+++ b/JavaScriptCore/ChangeLog-2003-10-25
@@ -1,3 +1,35 @@
+2002-08-15  Darin Adler  <darin at apple.com>
+
+	Tweaks and small bug fixes to Maciej's excellent new fixnum optimization.
+	Also updated or removed comments that call it "fixnum" instead of "simple number".
+
+        * kjs/simple_number.h: Change constant names so they don't SHOUT the way macro
+	names do. Added constants for shift, min, and max. Fixed off-by-1 error that
+	prevented us from using the extreme values on either end. Base the range of
+	numbers on a fixed 32 bits constant rather than the size of a long, because
+	code elsewhere depends on positive numbers fitting into both "unsigned" and
+	"UInt32" while assuming it doesn't need to check; we can easily change this
+	later. Used int types rather than long for essentially the same reason.
+	Fixed the value-extraction function so it will work for negative numbers even
+        if the shift is logical, not arithmetic, by using division instead.
+	Renamed functions to be quite terse since they are inside a class.
+
+        * kjs/value.h:
+        * kjs/value.cpp:
+        (ValueImp::dispatchToObject): Call NumberImp::toObject in a "non-virtual"
+	way rather than repeating the code here.
+        (ValueImp::dispatchToUInt32): Handle the negative number case correctly.
+        (ValueImp::dispatchGetBase): Call ValueImp::getBase in a "non-virtual"
+	way rather than repeating the code here.
+        (ValueImp::dispatchGetPropertyName): Call ValueImp::getPropertyName in a
+	"non-virtual" way rather than repeating the code here.
+        (ValueImp::dispatchPutValue): Call ValueImp::putValue in a "non-virtual"
+	way rather than repeating the code here.
+        (ValueImp::dispatchDeleteValue): Call ValueImp::deleteValue in a "non-virtual"
+	way rather than repeating the code here.
+        (Number::Number): Fixed a bug where the double-based constructor was casting
+	to long, so wouldn't do the "remainder" check.
+
 === Alexander-19 ===
 
 === Alexander-18 ===
diff --git a/JavaScriptCore/kjs/simple_number.h b/JavaScriptCore/kjs/simple_number.h
index 80c2918..766b093 100644
--- a/JavaScriptCore/kjs/simple_number.h
+++ b/JavaScriptCore/kjs/simple_number.h
@@ -31,18 +31,17 @@ namespace KJS {
 
     class SimpleNumber {
     public:
-	enum { TAG = 1, MASK = (1 + 2) };
+	enum { tag = 1, shift = 2, mask = (1 << shift) - 1, max = (1 << (31 - shift)) - 1, min = -max - 1 };
 
-	static inline bool isSimpleNumber(const ValueImp *imp) { return ((long)imp & MASK) == TAG; }
-	static inline long longValue(const ValueImp *imp) { return ((long)imp & ~MASK) >> 2; } 
-	static inline bool fitsInSimpleNumber(int i) { return i < (LONG_MAX >> 2) && i > (LONG_MIN >> 2); }
-	static inline bool fitsInSimpleNumber(unsigned i) { return i < (unsigned)(LONG_MAX >> 2); }
-	static inline bool fitsInSimpleNumber(double d) { return d < (LONG_MAX >> 2) && d > (LONG_MIN >> 2) && remainder(d, 1) == 0; }
+	static inline bool is(const ValueImp *imp) { return ((int)imp & mask) == tag; }
+	static inline int value(const ValueImp *imp) { return (int)imp / (1 << shift); }
 
-	static inline bool fitsInSimpleNumber(long i) { return i < (LONG_MAX >> 2) && i > (LONG_MIN >> 2); }
-	static inline bool fitsInSimpleNumber(unsigned long i) { return i < (unsigned)(LONG_MAX >> 2); }
-
-	static inline ValueImp *makeSimpleNumber(long i) { return (ValueImp *)((i << 2) | TAG); }
+	static inline bool fits(int i) { return i <= max && i >= min; }
+	static inline bool fits(unsigned i) { return i <= (unsigned)max; }
+	static inline bool fits(long i) { return i <= max && i >= min; }
+	static inline bool fits(unsigned long i) { return i <= (unsigned)max; }
+	static inline bool fits(double d) { return d <= max && d >= min && remainder(d, 1) == 0; }
+	static inline ValueImp *make(int i) { return (ValueImp *)((i << shift) | tag); }
     };
 }
 
diff --git a/JavaScriptCore/kjs/value.cpp b/JavaScriptCore/kjs/value.cpp
index 9fe9dd4..248130b 100644
--- a/JavaScriptCore/kjs/value.cpp
+++ b/JavaScriptCore/kjs/value.cpp
@@ -64,18 +64,17 @@ void ValueImp::mark()
 
 bool ValueImp::marked() const
 {
-  // simple numbers are always considered marked
-  return SimpleNumber::isSimpleNumber(this) || (_flags & VI_MARKED);
+  // Simple numbers are always considered marked.
+  return SimpleNumber::is(this) || (_flags & VI_MARKED);
 }
 
 void ValueImp::setGcAllowed()
 {
+  //fprintf(stderr,"ValueImp::setGcAllowed %p\n",(void*)this);
   // simple numbers are never seen by the collector so setting this
   // flag is irrelevant
-  if (!SimpleNumber::isSimpleNumber(this)) {
-    //fprintf(stderr,"ValueImp::setGcAllowed %p\n",(void*)this);
+  if (!SimpleNumber::is(this))
     _flags |= VI_GCALLOWED;
-  }
 }
 
 void* ValueImp::operator new(size_t s)
@@ -177,115 +176,89 @@ bool ValueImp::deleteValue(ExecState *exec)
   return false;
 }
 
-
-// Dispatchers for virtual functions, to special-case fixnums which
-// won't be real pointers
+// Dispatchers for virtual functions, to special-case simple numbers which
+// won't be real pointers.
 
 Type ValueImp::dispatchType() const
 {
-  if (SimpleNumber::isSimpleNumber(this)) {
+  if (SimpleNumber::is(this))
     return NumberType;
-  } else {
-    return this->type();
-  }
+  return type();
 }
 
 Value ValueImp::dispatchToPrimitive(ExecState *exec, Type preferredType) const
 {
-  if (SimpleNumber::isSimpleNumber(this)) {
-    return Number((NumberImp*)this);
-  } else {
-    return this->toPrimitive(exec, preferredType);
-  }
+  if (SimpleNumber::is(this))
+    return Value(const_cast<ValueImp *>(this));
+  return toPrimitive(exec, preferredType);
 }
 
 bool ValueImp::dispatchToBoolean(ExecState *exec) const
 {
-  if (SimpleNumber::isSimpleNumber(this)) {
-    return SimpleNumber::longValue(this);
-  } else {
-    return this->toBoolean(exec);
-  }
+  if (SimpleNumber::is(this))
+    return SimpleNumber::value(this);
+  return toBoolean(exec);
 }
 
 double ValueImp::dispatchToNumber(ExecState *exec) const
 {
-  if (SimpleNumber::isSimpleNumber(this)) {
-    return SimpleNumber::longValue(this);
-  } else {
-    return this->toNumber(exec);
-  }
+  if (SimpleNumber::is(this))
+    return SimpleNumber::value(this);
+  return toNumber(exec);
 }
 
 UString ValueImp::dispatchToString(ExecState *exec) const
 {
-  if (SimpleNumber::isSimpleNumber(this)) {
-    return UString::from(SimpleNumber::longValue(this));
-  } else {
-    return this->toString(exec);
-  }
+  if (SimpleNumber::is(this))
+    return UString::from(SimpleNumber::value(this));
+  return toString(exec);
 }
 
 Object ValueImp::dispatchToObject(ExecState *exec) const
 {
-  if (SimpleNumber::isSimpleNumber(this)) {
-      List args;
-      args.append(Number(static_cast<NumberImp*>(const_cast<ValueImp *>(this))));
-      return Object::dynamicCast(exec->interpreter()->builtinNumber().construct(exec,args));
-  } else {
-    return this->toObject(exec);
-  }
+  if (SimpleNumber::is(this))
+    return static_cast<const NumberImp *>(this)->NumberImp::toObject(exec);
+  return toObject(exec);
 }
 
 bool ValueImp::dispatchToUInt32(unsigned& result) const
 {
-  if (SimpleNumber::isSimpleNumber(this)) {
-    result = SimpleNumber::longValue(this);
+  if (SimpleNumber::is(this)) {
+    long i = SimpleNumber::value(this);
+    if (i < 0)
+      return false;
+    result = (unsigned)i;
     return true;
-  } else {
-    return this->toUInt32(result);
   }
+  return toUInt32(result);
 }
 
 Value ValueImp::dispatchGetBase(ExecState *exec) const
 {
-  if (SimpleNumber::isSimpleNumber(this)) {
-    Object err = Error::create(exec, ReferenceError, I18N_NOOP("Invalid reference base"));
-    exec->setException(err);
-    return err;
-  } else {
-    return this->getBase(exec);
-  }
+  if (SimpleNumber::is(this))
+    return ValueImp::getBase(exec);
+  return getBase(exec);
 }
 
 UString ValueImp::dispatchGetPropertyName(ExecState *exec) const
 {
-  if (SimpleNumber::isSimpleNumber(this)) {
-    return UString();
-  } else {
-    return this->getPropertyName(exec);
-  }
+  if (SimpleNumber::is(this))
+    return ValueImp::getPropertyName(exec);
+  return getPropertyName(exec);
 }
 
 void ValueImp::dispatchPutValue(ExecState *exec, const Value& w)
 {
-  if (SimpleNumber::isSimpleNumber(this)) {
-    Object err = Error::create(exec,ReferenceError);
-    exec->setException(err);
-  } else {
-    return this->putValue(exec, w);
-  }
+  if (SimpleNumber::is(this))
+    ValueImp::putValue(exec, w);
+  putValue(exec, w);
 }
 
 bool ValueImp::dispatchDeleteValue(ExecState *exec)
 {
-  if (SimpleNumber::isSimpleNumber(this)) {
-    Object err = Error::create(exec,ReferenceError);
-    exec->setException(err);
-    return false;
-  } else {
-    return this->deleteValue(exec);
-  }
+  if (SimpleNumber::is(this))
+    return ValueImp::deleteValue(exec);
+  return deleteValue(exec);
 }
 
 
@@ -408,19 +381,19 @@ String String::dynamicCast(const Value &v)
 // ------------------------------ Number ---------------------------------------
 
 Number::Number(int i)
-  : Value(SimpleNumber::fitsInSimpleNumber(i) ? SimpleNumber::makeSimpleNumber(i) : new NumberImp(static_cast<double>(i))) { }
+  : Value(SimpleNumber::fits(i) ? SimpleNumber::make(i) : new NumberImp(static_cast<double>(i))) { }
 
 Number::Number(unsigned int u)
-  : Value(SimpleNumber::fitsInSimpleNumber(u) ? SimpleNumber::makeSimpleNumber(u) : new NumberImp(static_cast<double>(u))) { }
+  : Value(SimpleNumber::fits(u) ? SimpleNumber::make(u) : new NumberImp(static_cast<double>(u))) { }
 
 Number::Number(double d)
-  : Value(SimpleNumber::fitsInSimpleNumber((long)d) ? SimpleNumber::makeSimpleNumber((long)d) : new NumberImp(d)) { }
+  : Value(SimpleNumber::fits(d) ? SimpleNumber::make((long)d) : new NumberImp(d)) { }
 
 Number::Number(long int l)
-  : Value(SimpleNumber::fitsInSimpleNumber(l) ? SimpleNumber::makeSimpleNumber(l) : new NumberImp(static_cast<double>(l))) { }
+  : Value(SimpleNumber::fits(l) ? SimpleNumber::make(l) : new NumberImp(static_cast<double>(l))) { }
 
 Number::Number(long unsigned int l)
-  : Value(SimpleNumber::fitsInSimpleNumber(l) ? SimpleNumber::makeSimpleNumber(l) : new NumberImp(static_cast<double>(l))) { }
+  : Value(SimpleNumber::fits(l) ? SimpleNumber::make(l) : new NumberImp(static_cast<double>(l))) { }
 
 Number Number::dynamicCast(const Value &v)
 {
@@ -432,12 +405,10 @@ Number Number::dynamicCast(const Value &v)
 
 double Number::value() const
 {
-  if (SimpleNumber::isSimpleNumber(rep)) {
-    return (double)SimpleNumber::longValue(rep);
-  } else {
-    assert(rep);
-    return ((NumberImp*)rep)->value();
-  }
+  if (SimpleNumber::is(rep))
+    return (double)SimpleNumber::value(rep);
+  assert(rep);
+  return ((NumberImp*)rep)->value();
 }
 
 int Number::intValue() const
diff --git a/JavaScriptCore/kjs/value.h b/JavaScriptCore/kjs/value.h
index f30bece..42bbe61 100644
--- a/JavaScriptCore/kjs/value.h
+++ b/JavaScriptCore/kjs/value.h
@@ -96,9 +96,8 @@ namespace KJS {
     ValueImp();
     virtual ~ValueImp();
 
-    inline ValueImp* ref() { if (!SimpleNumber::isSimpleNumber(this)) refcount++; return this; }
-    // FIXNUM: need special case for fixnums below (should be no-op)
-    inline bool deref() { if (SimpleNumber::isSimpleNumber(this)) return false; else return (!--refcount); }
+    ValueImp* ref() { if (!SimpleNumber::is(this)) refcount++; return this; }
+    bool deref() { if (SimpleNumber::is(this)) return false; else return (!--refcount); }
     unsigned int refcount;
 
     virtual void mark();
@@ -118,7 +117,7 @@ namespace KJS {
     unsigned int toUInt32(ExecState *exec) const;
     unsigned short toUInt16(ExecState *exec) const;
 
-    // Dispatch wrappers that handle the special fixnum case
+    // Dispatch wrappers that handle the special small number case
 
     Type dispatchType() const;
     Value dispatchToPrimitive(ExecState *exec, Type preferredType = UnspecifiedType) const;
@@ -430,12 +429,11 @@ namespace KJS {
     explicit Number(NumberImp *v);
   };
 
-  inline Value ValueImp::dispatchGetValue(ExecState *exec) const {
-    if (SimpleNumber::isSimpleNumber(this)) {
+  inline Value ValueImp::dispatchGetValue(ExecState *exec) const
+  {
+    if (SimpleNumber::is(this))
         return Value(const_cast<ValueImp*>(this));
-    } else {
-      return this->getValue(exec);
-    }
+    return getValue(exec);
   }
 
 }; // namespace

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list