Commit 8662c390 authored by akling@apple.com's avatar akling@apple.com

Pass VM instead of JSGlobalObject to RegExp constructor.

<https://webkit.org/b/122113>

Reviewed by Darin Adler.

RegExps don't need anything from the global object during their
construction and only use it to get to the VM. Reduce loads by
simply passing the VM around instead.

JSC release binary size -= 120 bytes(!)


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156668 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a5926ef4
2013-09-30 Andreas Kling <akling@apple.com>
Pass VM instead of JSGlobalObject to RegExp constructor.
<https://webkit.org/b/122113>
Reviewed by Darin Adler.
RegExps don't need anything from the global object during their
construction and only use it to get to the VM. Reduce loads by
simply passing the VM around instead.
JSC release binary size -= 120 bytes(!)
2013-09-30 Patrick Gansterer <paroga@webkit.org>
Fix compilation for COMPILER(MSVC) && !CPU(X86) after r156490.
......@@ -751,11 +751,11 @@ EncodedJSValue JIT_OPERATION operationNewRegexp(ExecState* exec, void* regexpPtr
NativeCallFrameTracer tracer(&vm, exec);
RegExp* regexp = static_cast<RegExp*>(regexpPtr);
if (!regexp->isValid()) {
exec->vm().throwException(exec, createSyntaxError(exec, "Invalid flags supplied to RegExp constructor."));
vm.throwException(exec, createSyntaxError(exec, "Invalid flags supplied to RegExp constructor."));
return JSValue::encode(jsUndefined());
}
return JSValue::encode(RegExpObject::create(exec->vm(), exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->regExpStructure(), regexp));
return JSValue::encode(RegExpObject::create(vm, exec->lexicalGlobalObject()->regExpStructure(), regexp));
}
JSCell* JIT_OPERATION operationCreateActivation(ExecState* exec)
......
......@@ -1948,7 +1948,7 @@ DEFINE_STUB_FUNCTION(JSObject*, op_new_regexp)
VM_THROW_EXCEPTION();
}
return RegExpObject::create(*stackFrame.vm, stackFrame.callFrame->lexicalGlobalObject(), stackFrame.callFrame->lexicalGlobalObject()->regExpStructure(), regExp);
return RegExpObject::create(*stackFrame.vm, stackFrame.callFrame->lexicalGlobalObject()->regExpStructure(), regExp);
}
DEFINE_STUB_FUNCTION(EncodedJSValue, op_call_eval)
......
......@@ -476,7 +476,7 @@ LLINT_SLOW_PATH_DECL(slow_path_new_regexp)
RegExp* regExp = exec->codeBlock()->regexp(pc[2].u.operand);
if (!regExp->isValid())
LLINT_THROW(createSyntaxError(exec, "Invalid flag supplied to RegExp constructor."));
LLINT_RETURN(RegExpObject::create(vm, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->regExpStructure(), regExp));
LLINT_RETURN(RegExpObject::create(vm, exec->lexicalGlobalObject()->regExpStructure(), regExp));
}
LLINT_SLOW_PATH_DECL(slow_path_check_has_instance)
......
......@@ -298,7 +298,7 @@ void JSGlobalObject::reset(JSValue prototype)
RegExp* emptyRegex = RegExp::create(vm, "", NoFlags);
m_regExpPrototype.set(vm, this, RegExpPrototype::create(exec, this, RegExpPrototype::createStructure(vm, this, m_objectPrototype.get()), emptyRegex));
m_regExpPrototype.set(vm, this, RegExpPrototype::create(vm, RegExpPrototype::createStructure(vm, this, m_objectPrototype.get()), emptyRegex));
m_regExpStructure.set(vm, this, RegExpObject::createStructure(vm, this, m_regExpPrototype.get()));
#if ENABLE(PROMISES)
......
......@@ -260,7 +260,7 @@ JSObject* constructRegExp(ExecState* exec, JSGlobalObject* globalObject, const A
// If called as a function, this just returns the first argument (see 15.10.3.1).
if (callAsConstructor) {
RegExp* regExp = static_cast<RegExpObject*>(asObject(arg0))->regExp();
return RegExpObject::create(exec, globalObject, globalObject->regExpStructure(), regExp);
return RegExpObject::create(exec->vm(), globalObject->regExpStructure(), regExp);
}
return asObject(arg0);
}
......@@ -278,10 +278,11 @@ JSObject* constructRegExp(ExecState* exec, JSGlobalObject* globalObject, const A
return exec->vm().throwException(exec, createSyntaxError(exec, ASCIILiteral("Invalid flags supplied to RegExp constructor.")));
}
RegExp* regExp = RegExp::create(exec->vm(), pattern, flags);
VM& vm = exec->vm();
RegExp* regExp = RegExp::create(vm, pattern, flags);
if (!regExp->isValid())
return exec->vm().throwException(exec, createSyntaxError(exec, regExp->errorMessage()));
return RegExpObject::create(exec, exec->lexicalGlobalObject(), globalObject->regExpStructure(), regExp);
return vm.throwException(exec, createSyntaxError(exec, regExp->errorMessage()));
return RegExpObject::create(vm, globalObject->regExpStructure(), regExp);
}
static EncodedJSValue JSC_HOST_CALL constructWithRegExpConstructor(ExecState* exec)
......
......@@ -63,17 +63,17 @@ const ClassInfo RegExpObject::s_info = { "RegExp", &Base::s_info, 0, ExecState::
@end
*/
RegExpObject::RegExpObject(JSGlobalObject* globalObject, Structure* structure, RegExp* regExp)
: JSNonFinalObject(globalObject->vm(), structure)
, m_regExp(globalObject->vm(), this, regExp)
RegExpObject::RegExpObject(VM& vm, Structure* structure, RegExp* regExp)
: JSNonFinalObject(vm, structure)
, m_regExp(vm, this, regExp)
, m_lastIndexIsWritable(true)
{
m_lastIndex.setWithoutWriteBarrier(jsNumber(0));
}
void RegExpObject::finishCreation(JSGlobalObject* globalObject)
void RegExpObject::finishCreation(VM& vm)
{
Base::finishCreation(globalObject->vm());
Base::finishCreation(vm);
ASSERT(inherits(info()));
}
......
......@@ -30,17 +30,10 @@ namespace JSC {
public:
typedef JSNonFinalObject Base;
static RegExpObject* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, RegExp* regExp)
static RegExpObject* create(VM& vm, Structure* structure, RegExp* regExp)
{
RegExpObject* object = new (NotNull, allocateCell<RegExpObject>(*exec->heap())) RegExpObject(globalObject, structure, regExp);
object->finishCreation(globalObject);
return object;
}
static RegExpObject* create(VM& vm, JSGlobalObject* globalObject, Structure* structure, RegExp* regExp)
{
RegExpObject* object = new (NotNull, allocateCell<RegExpObject>(vm.heap)) RegExpObject(globalObject, structure, regExp);
object->finishCreation(globalObject);
RegExpObject* object = new (NotNull, allocateCell<RegExpObject>(vm.heap)) RegExpObject(vm, structure, regExp);
object->finishCreation(vm);
return object;
}
......@@ -81,8 +74,8 @@ namespace JSC {
}
protected:
JS_EXPORT_PRIVATE RegExpObject(JSGlobalObject*, Structure*, RegExp*);
JS_EXPORT_PRIVATE void finishCreation(JSGlobalObject*);
JS_EXPORT_PRIVATE RegExpObject(VM&, Structure*, RegExp*);
JS_EXPORT_PRIVATE void finishCreation(VM&);
static const unsigned StructureFlags = OverridesVisitChildren | OverridesGetOwnPropertySlot | Base::StructureFlags;
......
......@@ -60,8 +60,8 @@ const ClassInfo RegExpPrototype::s_info = { "RegExp", &RegExpObject::s_info, 0,
@end
*/
RegExpPrototype::RegExpPrototype(JSGlobalObject* globalObject, Structure* structure, RegExp* regExp)
: RegExpObject(globalObject, structure, regExp)
RegExpPrototype::RegExpPrototype(VM& vm, Structure* structure, RegExp* regExp)
: RegExpObject(vm, structure, regExp)
{
}
......
......@@ -30,10 +30,10 @@ namespace JSC {
public:
typedef RegExpObject Base;
static RegExpPrototype* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, RegExp* regExp)
static RegExpPrototype* create(VM& vm, Structure* structure, RegExp* regExp)
{
RegExpPrototype* prototype = new (NotNull, allocateCell<RegExpPrototype>(*exec->heap())) RegExpPrototype(globalObject, structure, regExp);
prototype->finishCreation(globalObject);
RegExpPrototype* prototype = new (NotNull, allocateCell<RegExpPrototype>(vm.heap)) RegExpPrototype(vm, structure, regExp);
prototype->finishCreation(vm);
return prototype;
}
......@@ -45,7 +45,7 @@ namespace JSC {
}
protected:
RegExpPrototype(JSGlobalObject*, Structure*, RegExp*);
RegExpPrototype(VM&, Structure*, RegExp*);
static const unsigned StructureFlags = OverridesGetOwnPropertySlot | RegExpObject::StructureFlags;
private:
......
......@@ -1609,8 +1609,9 @@ private:
return JSValue();
RegExpFlags reFlags = regExpFlags(flags->string());
ASSERT(reFlags != InvalidFlags);
RegExp* regExp = RegExp::create(m_exec->vm(), pattern->string(), reFlags);
return RegExpObject::create(m_exec, m_exec->lexicalGlobalObject(), m_globalObject->regExpStructure(), regExp);
VM& vm = m_exec->vm();
RegExp* regExp = RegExp::create(vm, pattern->string(), reFlags);
return RegExpObject::create(vm, m_globalObject->regExpStructure(), regExp);
}
case ObjectReferenceTag: {
unsigned index = 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment