- 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.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@13541
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2006-03-28 Darin Adler <darin@apple.com>
+
+ 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.
+
2006-03-28 Timothy Hatcher <timothy@apple.com>
Reviewed by Eric.
93F0B3AC09BB4DC00068FCE3 /* Parser.h in Headers */ = {isa = PBXBuildFile; fileRef = 93F0B3AA09BB4DC00068FCE3 /* Parser.h */; };
/* End PBXBuildFile section */
-/* Begin PBXBuildRule section */
- 937C34BA0868E21B006F4B22 /* PBXBuildRule */ = {
- isa = PBXBuildRule;
- compilerSpec = com.apple.compilers.proxy.script;
- fileType = sourcecode.yacc;
- isEditable = 1;
- outputFiles = (
- "$(DERIVED_FILE_DIR)/$(INPUT_FILE_BASE).h",
- "$(DERIVED_FILE_DIR)/$(INPUT_FILE_BASE).cpp",
- );
- script = "bison -d -p kjsyy \"$INPUT_FILE_PATH\" -o \"$DERIVED_FILE_DIR/$INPUT_FILE_BASE.cpp\"\ncat \"$DERIVED_FILE_DIR/$INPUT_FILE_BASE.cpp.h\" \"$DERIVED_FILE_DIR/$INPUT_FILE_BASE.hpp\" > \"$DERIVED_FILE_DIR/$INPUT_FILE_BASE.h\" 2> /dev/null || printf \"\"";
- };
-/* End PBXBuildRule section */
-
/* Begin PBXBuildStyle section */
014CEA440018CDF011CA2923 /* Development */ = {
isa = PBXBuildStyle;
buildPhases = (
932F5B3F0822A1C700736975 /* Headers */,
932F5B910822A1C700736975 /* Sources */,
+ 9319586B09D9F91A00A56FD4 /* Check For Global Initializers */,
932F5BD20822A1C700736975 /* Frameworks */,
);
buildRules = (
- 937C34BA0868E21B006F4B22 /* PBXBuildRule */,
);
buildSettings = {
DEBUG_DEFINES = NDEBUG;
shellPath = /bin/sh;
shellScript = "./generate-derived-sources\n";
};
+ 9319586B09D9F91A00A56FD4 /* Check For Global Initializers */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ name = "Check For Global Initializers";
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "if [ -f ../WebKitTools/Scripts/check-for-global-initializers ]; then\n ../WebKitTools/Scripts/check-for-global-initializers || exit $?\nfi";
+ };
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
const double minutesPerHour = 60;
const double secondsPerMinute = 60;
const double msPerSecond = 1000;
-const double msPerMinute = msPerSecond * secondsPerMinute;
-const double msPerHour = msPerMinute * minutesPerHour;
-const double msPerDay = msPerHour * hoursPerDay;
+const double msPerMinute = 60 * 1000;
+const double msPerHour = 60 * 60 * 1000;
+const double msPerDay = 24 * 60 * 60 * 1000;
+
static const char * const weekdayName[7] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" };
static const char * const monthName[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
-
+
static double makeTime(tm *, double ms, bool utc);
static double parseDate(const UString &);
static double timeClip(double);
#include "internal.h"
#include <algorithm>
-#include <kxmlcore/OwnArrayPtr.h>
#define DUMP_STATISTICS 0
{
ListImpState state;
int capacity;
- OwnArrayPtr<JSValue*> overflow;
+ JSValue** overflow;
union {
JSValue *values[inlineValuesSize];
imp->refCount = 1;
imp->valueRefCount = 1;
imp->capacity = 0;
+ imp->overflow = 0;
+
#if DUMP_STATISTICS
if (++numLists > numListsHighWaterMark)
numListsHighWaterMark = numLists;
imp->refCount = 1;
imp->valueRefCount = !needsMarking;
imp->capacity = 0;
+ imp->overflow = 0;
#if DUMP_STATISTICS
if (++numLists > numListsHighWaterMark)
++numListsBiggerThan[i];
#endif
- imp->overflow.clear();
+ delete [] imp->overflow;
+ imp->overflow = 0;
if (imp->state == usedInPool) {
imp->state = unusedInPool;
if (i >= imp->capacity) {
int newCapacity = i * 2;
- OwnArrayPtr<JSValue*> newOverflow(new JSValue* [newCapacity - inlineValuesSize]);
- JSValue** oldOverflow = imp->overflow.get();
+ JSValue** newOverflow = new JSValue* [newCapacity - inlineValuesSize];
+ JSValue** oldOverflow = imp->overflow;
int oldOverflowSize = i - inlineValuesSize;
for (int j = 0; j != oldOverflowSize; j++)
newOverflow[j] = oldOverflow[j];
- imp->overflow.swap(newOverflow);
+ delete [] oldOverflow;
+ imp->overflow = newOverflow;
imp->capacity = newCapacity;
}
for (int i = 0; i != inlineSize; ++i)
append(imp->values[i]);
- JSValue** overflow = imp->overflow.get();
+ JSValue** overflow = imp->overflow;
int overflowSize = size - inlineSize;
for (int i = 0; i != overflowSize; ++i)
append(overflow[i]);
for (int i = 1; i < inlineSize; ++i)
copy.append(imp->values[i]);
- JSValue** overflow = imp->overflow.get();
+ JSValue** overflow = imp->overflow;
int overflowSize = size - inlineSize;
for (int i = 0; i < overflowSize; ++i)
copy.append(overflow[i]);
// Hack here to avoid a global with a constructor; point to an unsigned short instead of a UChar.
static unsigned short almostUChar;
-static UChar *const nonNullUCharPointer = reinterpret_cast<UChar *>(&almostUChar);
UString::Rep UString::Rep::null = { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 };
-UString::Rep UString::Rep::empty = { 0, 0, 1, 0, 0, 0, nonNullUCharPointer, 0, 0, 0, 0 };
+UString::Rep UString::Rep::empty = { 0, 0, 1, 0, 0, 0, reinterpret_cast<UChar*>(&almostUChar), 0, 0, 0, 0 };
const int normalStatBufferSize = 4096;
static char *statBuffer = 0;
static int statBufferSize = 0;