Changeset 13541 in webkit for trunk/JavaScriptCore/kjs


Ignore:
Timestamp:
Mar 28, 2006, 4:09:20 PM (19 years ago)
Author:
darin
Message:

Reviewed by Geoff.

  • change some code that resulted in init routines on Mac OS X -- if the framework has init routines it will use memory and slow down applications that link with WebKit even in cases where those applications don't use WebKit
  • kjs/date_object.cpp: Changed constants that were derived by multiplying other constants to use immediate numbers instead. Apparently, double constant expressions of the type we had here are evaluated at load time.
  • kjs/list.cpp: Can't use OwnArrayPtr in ListImp because of the global instances of ListImp, so go back to using a plain old pointer. (KJS::List::List): Set overflow to 0 when initializing ListImp. (KJS::List::release): Replace a clear call with a delete and explicit set to 0. (KJS::List::append): Use raw pointers, and do a delete [] instead of finessing it with a swap of OwnArrayPtr. (KJS::List::copyFrom): Remove now-unneeded get(). (KJS::List::copyTail): Ditto.
  • kjs/ustring.cpp: Changed UString::Rep::empty initializer a bit so that it doesn't get a static initializer routine. Had to get rid of one level of constant to get the compiler to understand it could initialize without any code.
  • added a build step that checks for init routines
  • JavaScriptCore.xcodeproj/project.pbxproj: Deleted now-unused custom build rule that was replaced by the generate-derived-sources script a while back. Added a custom build phase that invokes the check-for-global-initializers script.
Location:
trunk/JavaScriptCore/kjs
Files:
3 edited

Legend:

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

    r13318 r13541  
    131131const double secondsPerMinute = 60;
    132132const double msPerSecond = 1000;
    133 const double msPerMinute = msPerSecond * secondsPerMinute;
    134 const double msPerHour = msPerMinute * minutesPerHour;
    135 const double msPerDay = msPerHour * hoursPerDay;
     133const double msPerMinute = 60 * 1000;
     134const double msPerHour = 60 * 60 * 1000;
     135const double msPerDay = 24 * 60 * 60 * 1000;
     136
    136137static const char * const weekdayName[7] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" };
    137138static const char * const monthName[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
    138    
     139
    139140static double makeTime(tm *, double ms, bool utc);
    140141static double parseDate(const UString &);
  • trunk/JavaScriptCore/kjs/list.cpp

    r12523 r13541  
    2525#include "internal.h"
    2626#include <algorithm>
    27 #include <kxmlcore/OwnArrayPtr.h>
    2827
    2928#define DUMP_STATISTICS 0
     
    4342    ListImpState state;
    4443    int capacity;
    45     OwnArrayPtr<JSValue*> overflow;
     44    JSValue** overflow;
    4645
    4746    union {
     
    172171    imp->valueRefCount = 1;
    173172    imp->capacity = 0;
     173    imp->overflow = 0;
     174
    174175#if DUMP_STATISTICS
    175176    if (++numLists > numListsHighWaterMark)
     
    186187    imp->valueRefCount = !needsMarking;
    187188    imp->capacity = 0;
     189    imp->overflow = 0;
    188190
    189191#if DUMP_STATISTICS
     
    211213#endif
    212214
    213     imp->overflow.clear();
     215    delete [] imp->overflow;
     216    imp->overflow = 0;
    214217
    215218    if (imp->state == usedInPool) {
     
    272275    if (i >= imp->capacity) {
    273276        int newCapacity = i * 2;
    274         OwnArrayPtr<JSValue*> newOverflow(new JSValue* [newCapacity - inlineValuesSize]);
    275         JSValue** oldOverflow = imp->overflow.get();
     277        JSValue** newOverflow = new JSValue* [newCapacity - inlineValuesSize];
     278        JSValue** oldOverflow = imp->overflow;
    276279        int oldOverflowSize = i - inlineValuesSize;
    277280        for (int j = 0; j != oldOverflowSize; j++)
    278281            newOverflow[j] = oldOverflow[j];
    279         imp->overflow.swap(newOverflow);
     282        delete [] oldOverflow;
     283        imp->overflow = newOverflow;
    280284        imp->capacity = newCapacity;
    281285    }
     
    301305        append(imp->values[i]);
    302306
    303     JSValue** overflow = imp->overflow.get();
     307    JSValue** overflow = imp->overflow;
    304308    int overflowSize = size - inlineSize;
    305309    for (int i = 0; i != overflowSize; ++i)
     
    320324        copy.append(imp->values[i]);
    321325
    322     JSValue** overflow = imp->overflow.get();
     326    JSValue** overflow = imp->overflow;
    323327    int overflowSize = size - inlineSize;
    324328    for (int i = 0; i < overflowSize; ++i)
  • trunk/JavaScriptCore/kjs/ustring.cpp

    r13365 r13541  
    137137// Hack here to avoid a global with a constructor; point to an unsigned short instead of a UChar.
    138138static unsigned short almostUChar;
    139 static UChar *const nonNullUCharPointer = reinterpret_cast<UChar *>(&almostUChar);
    140139UString::Rep UString::Rep::null = { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 };
    141 UString::Rep UString::Rep::empty = { 0, 0, 1, 0, 0, 0, nonNullUCharPointer, 0, 0, 0, 0 };
     140UString::Rep UString::Rep::empty = { 0, 0, 1, 0, 0, 0, reinterpret_cast<UChar*>(&almostUChar), 0, 0, 0, 0 };
    142141const int normalStatBufferSize = 4096;
    143142static char *statBuffer = 0;
Note: See TracChangeset for help on using the changeset viewer.