X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/f9bf01c6616d5ddcf65b13b33cedf9e387ff7a63..4e4e5a6f2694187498445a6ac6f1634ce8141119:/runtime/RegExpConstructor.cpp diff --git a/runtime/RegExpConstructor.cpp b/runtime/RegExpConstructor.cpp index 6f00142..5332a87 100644 --- a/runtime/RegExpConstructor.cpp +++ b/runtime/RegExpConstructor.cpp @@ -27,29 +27,31 @@ #include "JSArray.h" #include "JSFunction.h" #include "JSString.h" +#include "Lookup.h" #include "ObjectPrototype.h" #include "RegExpMatchesArray.h" #include "RegExpObject.h" #include "RegExpPrototype.h" #include "RegExp.h" +#include "RegExpCache.h" namespace JSC { -static JSValue regExpConstructorInput(ExecState*, const Identifier&, const PropertySlot&); -static JSValue regExpConstructorMultiline(ExecState*, const Identifier&, const PropertySlot&); -static JSValue regExpConstructorLastMatch(ExecState*, const Identifier&, const PropertySlot&); -static JSValue regExpConstructorLastParen(ExecState*, const Identifier&, const PropertySlot&); -static JSValue regExpConstructorLeftContext(ExecState*, const Identifier&, const PropertySlot&); -static JSValue regExpConstructorRightContext(ExecState*, const Identifier&, const PropertySlot&); -static JSValue regExpConstructorDollar1(ExecState*, const Identifier&, const PropertySlot&); -static JSValue regExpConstructorDollar2(ExecState*, const Identifier&, const PropertySlot&); -static JSValue regExpConstructorDollar3(ExecState*, const Identifier&, const PropertySlot&); -static JSValue regExpConstructorDollar4(ExecState*, const Identifier&, const PropertySlot&); -static JSValue regExpConstructorDollar5(ExecState*, const Identifier&, const PropertySlot&); -static JSValue regExpConstructorDollar6(ExecState*, const Identifier&, const PropertySlot&); -static JSValue regExpConstructorDollar7(ExecState*, const Identifier&, const PropertySlot&); -static JSValue regExpConstructorDollar8(ExecState*, const Identifier&, const PropertySlot&); -static JSValue regExpConstructorDollar9(ExecState*, const Identifier&, const PropertySlot&); +static JSValue regExpConstructorInput(ExecState*, JSValue, const Identifier&); +static JSValue regExpConstructorMultiline(ExecState*, JSValue, const Identifier&); +static JSValue regExpConstructorLastMatch(ExecState*, JSValue, const Identifier&); +static JSValue regExpConstructorLastParen(ExecState*, JSValue, const Identifier&); +static JSValue regExpConstructorLeftContext(ExecState*, JSValue, const Identifier&); +static JSValue regExpConstructorRightContext(ExecState*, JSValue, const Identifier&); +static JSValue regExpConstructorDollar1(ExecState*, JSValue, const Identifier&); +static JSValue regExpConstructorDollar2(ExecState*, JSValue, const Identifier&); +static JSValue regExpConstructorDollar3(ExecState*, JSValue, const Identifier&); +static JSValue regExpConstructorDollar4(ExecState*, JSValue, const Identifier&); +static JSValue regExpConstructorDollar5(ExecState*, JSValue, const Identifier&); +static JSValue regExpConstructorDollar6(ExecState*, JSValue, const Identifier&); +static JSValue regExpConstructorDollar7(ExecState*, JSValue, const Identifier&); +static JSValue regExpConstructorDollar8(ExecState*, JSValue, const Identifier&); +static JSValue regExpConstructorDollar9(ExecState*, JSValue, const Identifier&); static void setRegExpConstructorInput(ExecState*, JSObject*, JSValue); static void setRegExpConstructorMultiline(ExecState*, JSObject*, JSValue); @@ -113,17 +115,17 @@ RegExpMatchesArray::RegExpMatchesArray(ExecState* exec, RegExpConstructorPrivate memcpy(d->lastOvector().data(), data->lastOvector().data(), offsetVectorSize * sizeof(int)); // d->multiline is not needed, and remains uninitialized - setLazyCreationData(d); + setSubclassData(d); } RegExpMatchesArray::~RegExpMatchesArray() { - delete static_cast(lazyCreationData()); + delete static_cast(subclassData()); } void RegExpMatchesArray::fillArrayInstance(ExecState* exec) { - RegExpConstructorPrivate* d = static_cast(lazyCreationData()); + RegExpConstructorPrivate* d = static_cast(subclassData()); ASSERT(d); unsigned lastNumSubpatterns = d->lastNumSubPatterns; @@ -141,7 +143,7 @@ void RegExpMatchesArray::fillArrayInstance(ExecState* exec) JSArray::put(exec, exec->propertyNames().input, jsString(exec, d->input), slot); delete d; - setLazyCreationData(0); + setSubclassData(0); } JSObject* RegExpConstructor::arrayOfMatches(ExecState* exec) const @@ -195,79 +197,79 @@ bool RegExpConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifi return getStaticValueDescriptor(exec, ExecState::regExpConstructorTable(exec), this, propertyName, descriptor); } -JSValue regExpConstructorDollar1(ExecState* exec, const Identifier&, const PropertySlot& slot) +JSValue regExpConstructorDollar1(ExecState* exec, JSValue slotBase, const Identifier&) { - return asRegExpConstructor(slot.slotBase())->getBackref(exec, 1); + return asRegExpConstructor(slotBase)->getBackref(exec, 1); } -JSValue regExpConstructorDollar2(ExecState* exec, const Identifier&, const PropertySlot& slot) +JSValue regExpConstructorDollar2(ExecState* exec, JSValue slotBase, const Identifier&) { - return asRegExpConstructor(slot.slotBase())->getBackref(exec, 2); + return asRegExpConstructor(slotBase)->getBackref(exec, 2); } -JSValue regExpConstructorDollar3(ExecState* exec, const Identifier&, const PropertySlot& slot) +JSValue regExpConstructorDollar3(ExecState* exec, JSValue slotBase, const Identifier&) { - return asRegExpConstructor(slot.slotBase())->getBackref(exec, 3); + return asRegExpConstructor(slotBase)->getBackref(exec, 3); } -JSValue regExpConstructorDollar4(ExecState* exec, const Identifier&, const PropertySlot& slot) +JSValue regExpConstructorDollar4(ExecState* exec, JSValue slotBase, const Identifier&) { - return asRegExpConstructor(slot.slotBase())->getBackref(exec, 4); + return asRegExpConstructor(slotBase)->getBackref(exec, 4); } -JSValue regExpConstructorDollar5(ExecState* exec, const Identifier&, const PropertySlot& slot) +JSValue regExpConstructorDollar5(ExecState* exec, JSValue slotBase, const Identifier&) { - return asRegExpConstructor(slot.slotBase())->getBackref(exec, 5); + return asRegExpConstructor(slotBase)->getBackref(exec, 5); } -JSValue regExpConstructorDollar6(ExecState* exec, const Identifier&, const PropertySlot& slot) +JSValue regExpConstructorDollar6(ExecState* exec, JSValue slotBase, const Identifier&) { - return asRegExpConstructor(slot.slotBase())->getBackref(exec, 6); + return asRegExpConstructor(slotBase)->getBackref(exec, 6); } -JSValue regExpConstructorDollar7(ExecState* exec, const Identifier&, const PropertySlot& slot) +JSValue regExpConstructorDollar7(ExecState* exec, JSValue slotBase, const Identifier&) { - return asRegExpConstructor(slot.slotBase())->getBackref(exec, 7); + return asRegExpConstructor(slotBase)->getBackref(exec, 7); } -JSValue regExpConstructorDollar8(ExecState* exec, const Identifier&, const PropertySlot& slot) +JSValue regExpConstructorDollar8(ExecState* exec, JSValue slotBase, const Identifier&) { - return asRegExpConstructor(slot.slotBase())->getBackref(exec, 8); + return asRegExpConstructor(slotBase)->getBackref(exec, 8); } -JSValue regExpConstructorDollar9(ExecState* exec, const Identifier&, const PropertySlot& slot) +JSValue regExpConstructorDollar9(ExecState* exec, JSValue slotBase, const Identifier&) { - return asRegExpConstructor(slot.slotBase())->getBackref(exec, 9); + return asRegExpConstructor(slotBase)->getBackref(exec, 9); } -JSValue regExpConstructorInput(ExecState* exec, const Identifier&, const PropertySlot& slot) +JSValue regExpConstructorInput(ExecState* exec, JSValue slotBase, const Identifier&) { - return jsString(exec, asRegExpConstructor(slot.slotBase())->input()); + return jsString(exec, asRegExpConstructor(slotBase)->input()); } -JSValue regExpConstructorMultiline(ExecState*, const Identifier&, const PropertySlot& slot) +JSValue regExpConstructorMultiline(ExecState*, JSValue slotBase, const Identifier&) { - return jsBoolean(asRegExpConstructor(slot.slotBase())->multiline()); + return jsBoolean(asRegExpConstructor(slotBase)->multiline()); } -JSValue regExpConstructorLastMatch(ExecState* exec, const Identifier&, const PropertySlot& slot) +JSValue regExpConstructorLastMatch(ExecState* exec, JSValue slotBase, const Identifier&) { - return asRegExpConstructor(slot.slotBase())->getBackref(exec, 0); + return asRegExpConstructor(slotBase)->getBackref(exec, 0); } -JSValue regExpConstructorLastParen(ExecState* exec, const Identifier&, const PropertySlot& slot) +JSValue regExpConstructorLastParen(ExecState* exec, JSValue slotBase, const Identifier&) { - return asRegExpConstructor(slot.slotBase())->getLastParen(exec); + return asRegExpConstructor(slotBase)->getLastParen(exec); } -JSValue regExpConstructorLeftContext(ExecState* exec, const Identifier&, const PropertySlot& slot) +JSValue regExpConstructorLeftContext(ExecState* exec, JSValue slotBase, const Identifier&) { - return asRegExpConstructor(slot.slotBase())->getLeftContext(exec); + return asRegExpConstructor(slotBase)->getLeftContext(exec); } -JSValue regExpConstructorRightContext(ExecState* exec, const Identifier&, const PropertySlot& slot) +JSValue regExpConstructorRightContext(ExecState* exec, JSValue slotBase, const Identifier&) { - return asRegExpConstructor(slot.slotBase())->getRightContext(exec); + return asRegExpConstructor(slotBase)->getRightContext(exec); } void RegExpConstructor::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot) @@ -300,7 +302,7 @@ JSObject* constructRegExp(ExecState* exec, const ArgList& args) UString pattern = arg0.isUndefined() ? UString("") : arg0.toString(exec); UString flags = arg1.isUndefined() ? UString("") : arg1.toString(exec); - RefPtr regExp = RegExp::create(&exec->globalData(), pattern, flags); + RefPtr regExp = exec->globalData().regExpCache()->lookupOrCreate(pattern, flags); if (!regExp->isValid()) return throwError(exec, SyntaxError, makeString("Invalid regular expression: ", regExp->errorMessage())); return new (exec) RegExpObject(exec->lexicalGlobalObject()->regExpStructure(), regExp.release());