summaryrefslogtreecommitdiffstats
path: root/src/3rdparty
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-08-11 11:53:04 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-08-12 13:15:23 (GMT)
commit45e2a19b4b75fe94a78161f26862bf3c6f727d74 (patch)
treea6e698eee514ad28815519f3b2ba5ac592941de3 /src/3rdparty
parente806a4e887b6584f1115ced3cb489bb0e9a2de36 (diff)
downloadQt-45e2a19b4b75fe94a78161f26862bf3c6f727d74.zip
Qt-45e2a19b4b75fe94a78161f26862bf3c6f727d74.tar.gz
Qt-45e2a19b4b75fe94a78161f26862bf3c6f727d74.tar.bz2
Refactor the way the JS stack are created for native function
The original JavaScriptCore doesn't create stack frame or scope for native function. JSC has been patched to support that. This commit revert our patches to JSC, and implement create the stack frame from QScript Reviewed-by: Kent Hansen
Diffstat (limited to 'src/3rdparty')
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/interpreter/Interpreter.cpp14
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/runtime/CallData.cpp27
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/runtime/ConstructData.cpp39
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/runtime/PropertySlot.cpp23
4 files changed, 3 insertions, 100 deletions
diff --git a/src/3rdparty/webkit/JavaScriptCore/interpreter/Interpreter.cpp b/src/3rdparty/webkit/JavaScriptCore/interpreter/Interpreter.cpp
index fe663ae..c78466e 100644
--- a/src/3rdparty/webkit/JavaScriptCore/interpreter/Interpreter.cpp
+++ b/src/3rdparty/webkit/JavaScriptCore/interpreter/Interpreter.cpp
@@ -3507,20 +3507,6 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
ScopeChainNode* scopeChain = callFrame->scopeChain();
- Structure* structure;
- JSValue prototype = callFrame->r(proto).jsValue();
- if (prototype.isObject())
- structure = asObject(prototype)->inheritorID();
- else
- structure = scopeChain->globalObject()->emptyObjectStructure();
-#ifdef QT_BUILD_SCRIPT_LIB
- // ### world-class hack
- QScriptObject* newObject = new (globalData) QScriptObject(structure);
-#else
- JSObject* newObject = new (globalData) JSObject(structure);
-#endif
- callFrame[thisRegister] = JSValue(newObject); // "this" value
-
CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + registerOffset);
newCallFrame->init(0, vPC + 7, scopeChain, callFrame, dst, argCount, asObject(v));
diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/CallData.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/CallData.cpp
index b33c8ba..c89ebf8 100644
--- a/src/3rdparty/webkit/JavaScriptCore/runtime/CallData.cpp
+++ b/src/3rdparty/webkit/JavaScriptCore/runtime/CallData.cpp
@@ -25,10 +25,6 @@
#include "config.h"
#include "CallData.h"
-#ifdef QT_BUILD_SCRIPT_LIB
-#include "ExceptionHelpers.h"
-#include "Interpreter.h"
-#endif
#include "JSFunction.h"
#include "JSGlobalObject.h"
@@ -59,29 +55,8 @@ JSValue JSC::NativeFuncWrapper::operator() (ExecState* exec, JSObject* jsobj, JS
JSValue call(ExecState* exec, JSValue functionObject, CallType callType, const CallData& callData, JSValue thisValue, const ArgList& args)
{
- if (callType == CallTypeHost) {
-#ifdef QT_BUILD_SCRIPT_LIB
- ScopeChainNode* scopeChain = exec->scopeChain();
- Interpreter *interp = exec->interpreter();
- Register *oldEnd = interp->registerFile().end();
- int argc = 1 + args.size(); // implicit "this" parameter
- if (!interp->registerFile().grow(oldEnd + argc + RegisterFile::CallFrameHeaderSize))
- return createStackOverflowError(exec);
- CallFrame* newCallFrame = CallFrame::create(oldEnd);
- newCallFrame[0] = thisValue;
- size_t dst = 0;
- ArgList::const_iterator it;
- for (it = args.begin(); it != args.end(); ++it)
- newCallFrame[++dst] = *it;
- newCallFrame += argc + RegisterFile::CallFrameHeaderSize;
- newCallFrame->init(0, /*vPC=*/0, scopeChain, exec, 0, argc, asObject(functionObject));
- JSValue result = callData.native.function(newCallFrame, asObject(functionObject), thisValue, args);
- interp->registerFile().shrink(oldEnd);
- return result;
-#else
+ if (callType == CallTypeHost)
return callData.native.function(exec, asObject(functionObject), thisValue, args);
-#endif
- }
ASSERT(callType == CallTypeJS);
// FIXME: Can this be done more efficiently using the callData?
return asFunction(functionObject)->call(exec, thisValue, args);
diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/ConstructData.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/ConstructData.cpp
index 5fe792f..d4eb307 100644
--- a/src/3rdparty/webkit/JavaScriptCore/runtime/ConstructData.cpp
+++ b/src/3rdparty/webkit/JavaScriptCore/runtime/ConstructData.cpp
@@ -25,12 +25,6 @@
#include "config.h"
#include "ConstructData.h"
-#ifdef QT_BUILD_SCRIPT_LIB
-#include "ExceptionHelpers.h"
-#include "Interpreter.h"
-#include "JSGlobalObject.h"
-#include "bridge/qscriptobject_p.h"
-#endif
#include "JSFunction.h"
@@ -60,39 +54,8 @@ JSObject* JSC::NativeConstrWrapper::operator() (ExecState* exec, JSObject* jsobj
JSObject* construct(ExecState* exec, JSValue callee, ConstructType constructType, const ConstructData& constructData, const ArgList& args)
{
- if (constructType == ConstructTypeHost) {
-#ifdef QT_BUILD_SCRIPT_LIB
- Structure* structure;
- JSValue prototype = callee.get(exec, exec->propertyNames().prototype);
- if (prototype.isObject())
- structure = asObject(prototype)->inheritorID();
- else
- structure = exec->lexicalGlobalObject()->emptyObjectStructure();
- JSObject* thisObj = new (exec) QScriptObject(structure);
-
- ScopeChainNode* scopeChain = exec->scopeChain();
- Interpreter *interp = exec->interpreter();
- Register *oldEnd = interp->registerFile().end();
- int argc = 1 + args.size(); // implicit "this" parameter
- if (!interp->registerFile().grow(oldEnd + argc + RegisterFile::CallFrameHeaderSize))
- return asObject(createStackOverflowError(exec));
- CallFrame* newCallFrame = CallFrame::create(oldEnd);
- size_t dst = 0;
- newCallFrame[0] = JSValue(thisObj);
- ArgList::const_iterator it;
- for (it = args.begin(); it != args.end(); ++it)
- newCallFrame[++dst] = *it;
- newCallFrame += argc + RegisterFile::CallFrameHeaderSize;
- newCallFrame->init(0, /*vPC=*/0, scopeChain, exec, 0, argc, asObject(callee));
- JSObject *result = constructData.native.function(newCallFrame, asObject(callee), args);
- if (!result)
- result = thisObj;
- interp->registerFile().shrink(oldEnd);
- return result;
-#else
+ if (constructType == ConstructTypeHost)
return constructData.native.function(exec, asObject(callee), args);
-#endif
- }
ASSERT(constructType == ConstructTypeJS);
// FIXME: Can this be done more efficiently using the constructData?
return asFunction(callee)->construct(exec, args);
diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/PropertySlot.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/PropertySlot.cpp
index 08f50b4..36fa5d8 100644
--- a/src/3rdparty/webkit/JavaScriptCore/runtime/PropertySlot.cpp
+++ b/src/3rdparty/webkit/JavaScriptCore/runtime/PropertySlot.cpp
@@ -19,10 +19,6 @@
*/
#include "config.h"
-#ifdef QT_BUILD_SCRIPT_LIB
-#include "ExceptionHelpers.h"
-#include "Interpreter.h"
-#endif
#include "PropertySlot.h"
#include "JSFunction.h"
@@ -39,25 +35,8 @@ JSValue PropertySlot::functionGetter(ExecState* exec, const Identifier&, const P
CallData callData;
CallType callType = slot.m_data.getterFunc->getCallData(callData);
- if (callType == CallTypeHost) {
-#ifdef QT_BUILD_SCRIPT_LIB
- ScopeChainNode* scopeChain = exec->scopeChain();
- Interpreter *interp = exec->interpreter();
- Register *oldEnd = interp->registerFile().end();
- int argc = 1; // implicit "this" parameter
- if (!interp->registerFile().grow(oldEnd + argc + RegisterFile::CallFrameHeaderSize))
- return createStackOverflowError(exec);
- JSC::CallFrame* newCallFrame = JSC::CallFrame::create(oldEnd);
- newCallFrame[0] = slot.slotBase(); // this
- newCallFrame += argc + JSC::RegisterFile::CallFrameHeaderSize;
- newCallFrame->init(0, /*vPC=*/0, scopeChain, exec, 0, argc, slot.m_data.getterFunc);
- JSValue result = callData.native.function(newCallFrame, slot.m_data.getterFunc, slot.slotBase(), exec->emptyList());
- interp->registerFile().shrink(oldEnd);
- return result;
-#else
+ if (callType == CallTypeHost)
return callData.native.function(exec, slot.m_data.getterFunc, slot.slotBase(), exec->emptyList());
-#endif
- }
ASSERT(callType == CallTypeJS);
// FIXME: Can this be done more efficiently using the callData?
return static_cast<JSFunction*>(slot.m_data.getterFunc)->call(exec, slot.slotBase(), exec->emptyList());