From 957de0c8fb109ad6938d7a8673164cc94f346ecc Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 19 Oct 2017 15:21:08 +0200 Subject: Refactor Call/Construct instructions Give them a pointer to argc and argv instead of a pointer to a full callData. Like this we can construct the callData at the end of the JS stack and avoid the need to create an additional copy in VME::exec(). This also opens up the option of completely avoiding all copies for calls into runtime methods. Also make sure that the calldata we pass into other functions is always at the top of the JS stack. Change-Id: I3d0eb49f7bfd7adb9ddabb213422087c66e5a520 Reviewed-by: Erik Verbruggen --- src/qml/jsruntime/qv4stringobject.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/qml/jsruntime/qv4stringobject.cpp') diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp index 9e03913730..b1ce0b0115 100644 --- a/src/qml/jsruntime/qv4stringobject.cpp +++ b/src/qml/jsruntime/qv4stringobject.cpp @@ -405,14 +405,17 @@ ReturnedValue StringPrototype::method_match(const BuiltinFunction *b, CallData * if (callData->thisObject.isNullOrUndefined()) return v4->throwTypeError(); - Scope scope(v4); - callData->thisObject = callData->thisObject.toString(scope.engine); + callData->thisObject = callData->thisObject.toString(v4); if (v4->hasException) return Encode::undefined(); + Q_ASSERT(v4->jsStackTop == callData->args + callData->argc()); if (!callData->argc()) callData->args[0] = Encode::undefined(); callData->setArgc(1); + v4->jsStackTop = callData->args + 1; + + Scope scope(v4); if (!callData->args[0].as()) { // convert args[0] to a regexp @@ -579,10 +582,10 @@ ReturnedValue StringPrototype::method_replace(const BuiltinFunction *b, CallData ScopedFunctionObject searchCallback(scope, replaceValue); if (!!searchCallback) { result.reserve(string.length() + 10*numStringMatches); + ScopedValue entry(scope); JSCall jsCall(scope, searchCallback, numCaptures + 2); jsCall->thisObject = Primitive::undefinedValue(); int lastEnd = 0; - ScopedValue entry(scope); for (int i = 0; i < numStringMatches; ++i) { for (int k = 0; k < numCaptures; ++k) { int idx = (i * numCaptures + k) * 2; -- cgit v1.2.3