summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-07-09 12:51:45 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-07-09 12:51:45 (GMT)
commit07d33b502578497a3e142d0d410b0a0b1acb12f1 (patch)
treebf052db112d64803d2e6bea1fd2e2b6318f0c9b7
parentd96bc6ba81465c5a82ca08ac68c2dac54a57700f (diff)
downloadQt-07d33b502578497a3e142d0d410b0a0b1acb12f1.zip
Qt-07d33b502578497a3e142d0d410b0a0b1acb12f1.tar.gz
Qt-07d33b502578497a3e142d0d410b0a0b1acb12f1.tar.bz2
create a new frame when calling native constructors
See commit 103439f4c8a70740d6475af1b1b58deede12d2c3
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/runtime/CallData.cpp2
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/runtime/ConstructData.cpp36
2 files changed, 33 insertions, 5 deletions
diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/CallData.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/CallData.cpp
index 0579b27..74ef191 100644
--- a/src/3rdparty/webkit/JavaScriptCore/runtime/CallData.cpp
+++ b/src/3rdparty/webkit/JavaScriptCore/runtime/CallData.cpp
@@ -47,7 +47,7 @@ JSValue call(ExecState* exec, JSValue functionObject, CallType callType, const C
ArgList::const_iterator it;
for (it = args.begin(); it != args.end(); ++it)
newCallFrame[++dst] = *it;
- newCallFrame += argc + JSC::RegisterFile::CallFrameHeaderSize;
+ 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);
diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/ConstructData.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/ConstructData.cpp
index 7ee59d7..b19ae04 100644
--- a/src/3rdparty/webkit/JavaScriptCore/runtime/ConstructData.cpp
+++ b/src/3rdparty/webkit/JavaScriptCore/runtime/ConstructData.cpp
@@ -25,18 +25,46 @@
#include "config.h"
#include "ConstructData.h"
+#include "ExceptionHelpers.h"
+#include "Interpreter.h"
#include "JSFunction.h"
+#include "JSGlobalObject.h"
namespace JSC {
-JSObject* construct(ExecState* exec, JSValue object, ConstructType constructType, const ConstructData& constructData, const ArgList& args)
+JSObject* construct(ExecState* exec, JSValue callee, ConstructType constructType, const ConstructData& constructData, const ArgList& args)
{
- if (constructType == ConstructTypeHost)
- return constructData.native.function(exec, asObject(object), args);
+ if (constructType == ConstructTypeHost) {
+ 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) JSObject(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);
+ interp->registerFile().shrink(oldEnd);
+ return result;
+ }
ASSERT(constructType == ConstructTypeJS);
// FIXME: Can this be done more efficiently using the constructData?
- return asFunction(object)->construct(exec, args);
+ return asFunction(callee)->construct(exec, args);
}
} // namespace JSC