Changeset 1859 in webkit for trunk/JavaScriptCore/kjs


Ignore:
Timestamp:
Aug 18, 2002, 12:21:26 AM (23 years ago)
Author:
mjs
Message:

Separated Completion from Value and made it a pure stack
object. This removed another 160,000 of the remaining 580,000
garbage collected object allocations.

6% speed increas on cvs-js-performance test.

  • kjs/completion.cpp: Added. New implementation that doesn't require a ValueImp *. (Completion::Completion): (Completion::complType): (Completion::value): (Completion::target): (Completion::isValueCompletion):
  • kjs/completion.h: Added.
  • kjs/function.cpp: (GlobalFuncImp::call): Removed some (apparently mistaken) uses of Completion as a Value.
  • kjs/internal.cpp:
  • kjs/internal.h:
  • kjs/types.cpp: Removed Completion stuff.
  • kjs/types.h: Removed Completion stuff.
  • JavaScriptCore.pbproj/project.pbxproj: Added new header.
Location:
trunk/JavaScriptCore/kjs
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/function.cpp

    r1799 r1859  
    417417          delete progNode;
    418418      if (c.complType() == ReturnValue)
    419           return c;
     419          return c.value();
    420420      // ### setException() on throw?
    421421      else if (c.complType() == Normal) {
     
    425425              return Undefined();
    426426      } else {
    427           return c;
     427          return Undefined();
    428428      }
    429429    }
  • trunk/JavaScriptCore/kjs/internal.cpp

    r1850 r1859  
    330330    tos = prev;
    331331  }
    332 }
    333 
    334 // ------------------------------ CompletionImp --------------------------------
    335 
    336 CompletionImp::CompletionImp(ComplType c, const Value& v, const UString& t)
    337   : comp(c), val(v.imp()), tar(t)
    338 {
    339 }
    340 
    341 CompletionImp::~CompletionImp()
    342 {
    343 }
    344 
    345 void CompletionImp::mark()
    346 {
    347   ValueImp::mark();
    348 
    349   if (val && !val->marked())
    350     val->mark();
    351 }
    352 
    353 Value CompletionImp::toPrimitive(ExecState */*exec*/, Type /*preferredType*/) const
    354 {
    355   // invalid for Completion
    356   assert(false);
    357   return Value();
    358 }
    359 
    360 bool CompletionImp::toBoolean(ExecState */*exec*/) const
    361 {
    362   // invalid for Completion
    363   assert(false);
    364   return false;
    365 }
    366 
    367 double CompletionImp::toNumber(ExecState */*exec*/) const
    368 {
    369   // invalid for Completion
    370   assert(false);
    371   return 0;
    372 }
    373 
    374 UString CompletionImp::toString(ExecState */*exec*/) const
    375 {
    376   // invalid for Completion
    377   assert(false);
    378   return UString::null;
    379 }
    380 
    381 Object CompletionImp::toObject(ExecState */*exec*/) const
    382 {
    383   // invalid for Completion
    384   assert(false);
    385   return Object();
    386332}
    387333
  • trunk/JavaScriptCore/kjs/internal.h

    r1850 r1859  
    143143  // ---------------------------------------------------------------------------
    144144
    145   class CompletionImp : public ValueImp {
    146   public:
    147     Type type() const { return CompletionType; }
    148 
    149     CompletionImp(ComplType c, const Value& v, const UString& t);
    150     virtual ~CompletionImp();
    151     virtual void mark();
    152 
    153     Value toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const;
    154     bool toBoolean(ExecState *exec) const;
    155     double toNumber(ExecState *exec) const;
    156     UString toString(ExecState *exec) const;
    157     Object toObject(ExecState *exec) const;
    158 
    159     ComplType complType() const { return comp; }
    160     Value value() const { return Value(val); }
    161     UString target() const { return tar; }
    162 
    163   private:
    164     ComplType comp;
    165     ValueImp * val;
    166     UString tar;
    167   };
    168 
    169   inline Completion::Completion(CompletionImp *imp) : Value(imp) { }
    170 
    171145  /**
    172146   * @internal
  • trunk/JavaScriptCore/kjs/types.cpp

    r1841 r1859  
    204204#endif
    205205
    206 
    207 // ------------------------------ Completion -----------------------------------
    208 
    209 Completion::Completion(ComplType c, const Value& v, const UString &t)
    210   : Value(new CompletionImp(c,v,t))
    211 {
    212 }
    213 
    214 Completion Completion::dynamicCast(const Value &v)
    215 {
    216   if (v.isNull() || v.type() != CompletionType)
    217     return 0;
    218 
    219   return static_cast<CompletionImp*>(v.imp());
    220 }
    221 
    222 ComplType Completion::complType() const
    223 {
    224   return static_cast<CompletionImp*>(rep)->complType();
    225 }
    226 
    227 Value Completion::value() const
    228 {
    229   return static_cast<CompletionImp*>(rep)->value();
    230 }
    231 
    232 UString Completion::target() const
    233 {
    234   return static_cast<CompletionImp*>(rep)->target();
    235 }
    236 
    237 bool Completion::isValueCompletion() const
    238 {
    239   return !value().isNull();
    240 }
  • trunk/JavaScriptCore/kjs/types.h

    r1841 r1859  
    2828
    2929#include "value.h"
     30#include "reference.h"
     31#include "completion.h"
    3032
    3133namespace KJS {
     
    200202  };
    201203
    202   /**
    203    * Completion types.
    204    */
    205   enum ComplType { Normal, Break, Continue, ReturnValue, Throw };
    206 
    207   /**
    208    * Completion objects are used to convey the return status and value
    209    * from functions.
    210    *
    211    * See @ref FunctionImp::execute()
    212    *
    213    * @see FunctionImp
    214    *
    215    * @short Handle for a Completion type.
    216    */
    217   class Completion : public Value {
    218   public:
    219     Completion(ComplType c = Normal, const Value& v = Value(),
    220                const UString &t = UString::null);
    221     Completion(CompletionImp *v);
    222 
    223     /**
    224      * Converts a Value into an Completion. If the value's type is not
    225      * CompletionType, a null object will be returned (i.e. one with it's
    226      * internal pointer set to 0). If you do not know for sure whether the
    227      * value is of type CompletionType, you should check the @ref isNull()
    228      * methods afterwards before calling any methods on the returned value.
    229      *
    230      * @return The value converted to an Completion
    231      */
    232     static Completion dynamicCast(const Value &v);
    233 
    234     ComplType complType() const;
    235     Value value() const;
    236     UString target() const;
    237     bool isValueCompletion() const;
    238   };
    239 
    240204}; // namespace
    241205
Note: See TracChangeset for help on using the changeset viewer.