SVN commit 1121575 by orlovich: - Expand out list cells to LocalStorageEntry, to make passing in stuff from stack possible. - Some more variable pass-in tweaking. M +14 -2 function.cpp M +12 -14 list.cpp M +7 -4 list.h --- trunk/KDE/kdelibs/kjs/function.cpp #1121574:1121575 @@ -509,9 +509,12 @@ function->functionName().isEmpty() ? "(internal)" : function->functionName().ascii()); #endif size_t numParams = body->numParams(); - for (size_t pos = 0; pos < numParams; ++pos) { + size_t numPassedIn = min(numParams, static_cast(arguments->size())); + + size_t pos = 0; + for (; pos < numPassedIn; ++pos) { size_t symNum = pos + ActivationImp::NumReservedSlots; - JSValue* v = (*arguments)[pos]; + JSValue* v = arguments->atUnchecked(pos); entries[symNum].val.valueVal = v; @@ -521,7 +524,16 @@ #endif } + for (; pos < numParams; ++pos) { + size_t symNum = pos + ActivationImp::NumReservedSlots; + entries[symNum].val.valueVal = jsUndefined(); + #ifdef KJS_VERBOSE + fprintf(stderr, "%s setting parameter %s to undefined (not passed in)", ind(), body->paramName(pos).ascii()); +#endif + } + +#ifdef KJS_VERBOSE fprintf(stderr, "\n%s---------------------------------\n", ind()); fprintf(stderr, "%sBody:\n", ind()); fprintf(stderr, "%s---------------------------------\n", ind()); --- trunk/KDE/kdelibs/kjs/list.cpp #1121574:1121575 @@ -39,13 +39,14 @@ struct ListImp : ListImpBase { ListImpState state; - int capacity; // or 0 if data is inline union { - JSValue *values[inlineListValuesSize]; + int capacity; // or 0 if data is inline ListImp *nextInFreeList; }; + LocalStorageEntry values[inlineListValuesSize]; + #if DUMP_STATISTICS int sizeHighWaterMark; #endif @@ -101,8 +102,8 @@ inline void ListImp::markValues() { for (int i = 0; i != size; ++i) { - if (!data[i]->marked()) - data[i]->mark(); + if (!data[i].val.valueVal->marked()) + data[i].val.valueVal->mark(); } } @@ -163,17 +164,14 @@ #endif } - -void List::markValues() -{ - static_cast(_impBase)->markValues(); -} - void List::release() { ListImp *imp = static_cast(_impBase); #if DUMP_STATISTICS + if (imp->size > imp->sizeHighWaterMark) + imp->sizeHighWaterMark = imp->size; + --numLists; ++numListsDestroyed; for (int i = 0; i < 17; i++) @@ -227,7 +225,7 @@ if (i >= imp->capacity) { int newCapacity = i * 2; - JSValue** newBuffer = new JSValue*[newCapacity]; + LocalStorageEntry* newBuffer = new LocalStorageEntry[newCapacity]; // Copy everything over for (int c = 0; c < i; ++c) @@ -240,7 +238,7 @@ imp->capacity = newCapacity; } - imp->data[i] = v; + imp->data[i].val.valueVal = v; } List List::copy() const @@ -264,7 +262,7 @@ if (size > inlineListValuesSize) { // need an out-of-line buffer ourImp->capacity = size; - ourImp->data = new JSValue*[size]; + ourImp->data = new LocalStorageEntry[size]; } else { ourImp->capacity = 0; } @@ -287,7 +285,7 @@ if (size > inlineListValuesSize) { // need an out-of-line buffer ourImp->capacity = size; - ourImp->data = new JSValue*[size]; + ourImp->data = new LocalStorageEntry[size]; } else { ourImp->capacity = 0; } --- trunk/KDE/kdelibs/kjs/list.h #1121574:1121575 @@ -24,6 +24,7 @@ #define KJS_LIST_H #include "value.h" +#include "LocalStorage.h" namespace KJS { @@ -32,7 +33,7 @@ struct ListImpBase { int size; int refCount; - JSValue** data; // points either to inline or out-of-line buffer + LocalStorageEntry* data; // points either to inline or out-of-line buffer }; class ListIterator; @@ -111,6 +112,9 @@ */ JSValue *at(int i) const; + // As above but omits the range change + JSValue* atUnchecked(int i) const { return _impBase->data[i].val.valueVal; } + /** * Equivalent to at. */ @@ -136,12 +140,11 @@ void deref() { if (--_impBase->refCount == 0) release(); } void release(); - void markValues(); }; inline JSValue* List::at(int i) const { if (i < _impBase->size) - return _impBase->data[i]; + return _impBase->data[i].val.valueVal; else return jsUndefined(); } @@ -151,7 +154,7 @@ int newSize = size + 1; if (newSize < inlineListValuesSize) { // Can just write to the inline buffer - _impBase->data[size] = val; + _impBase->data[size].val.valueVal = val; _impBase->size = newSize; } else { appendSlowCase(val);