diff options
author | Leon Clarke <leonclarke@google.com> | 2010-06-03 14:33:32 +0100 |
---|---|---|
committer | Leon Clarke <leonclarke@google.com> | 2010-06-08 12:24:51 +0100 |
commit | 5af96e2c7b73ebc627c6894727826a7576d31758 (patch) | |
tree | f9d5e6f6175ccd7e3d14de9b290f08937a0d17ba /JavaScriptCore/runtime/ConstructData.cpp | |
parent | 8cc4fcf4f6adcbc0e0aebfc24fbad9a4cddf2cfb (diff) | |
download | external_webkit-5af96e2c7b73ebc627c6894727826a7576d31758.zip external_webkit-5af96e2c7b73ebc627c6894727826a7576d31758.tar.gz external_webkit-5af96e2c7b73ebc627c6894727826a7576d31758.tar.bz2 |
Merge webkit.org at r60469 : Initial merge by git.
Change-Id: I66a0047aa2af802f66bb0c7f2a8b02247a596234
Diffstat (limited to 'JavaScriptCore/runtime/ConstructData.cpp')
-rw-r--r-- | JavaScriptCore/runtime/ConstructData.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/JavaScriptCore/runtime/ConstructData.cpp b/JavaScriptCore/runtime/ConstructData.cpp index 7ee59d7..a7b97e6 100644 --- a/JavaScriptCore/runtime/ConstructData.cpp +++ b/JavaScriptCore/runtime/ConstructData.cpp @@ -26,7 +26,10 @@ #include "config.h" #include "ConstructData.h" +#include "Executable.h" +#include "Interpreter.h" #include "JSFunction.h" +#include "JSGlobalObject.h" namespace JSC { @@ -34,9 +37,23 @@ JSObject* construct(ExecState* exec, JSValue object, ConstructType constructType { if (constructType == ConstructTypeHost) return constructData.native.function(exec, asObject(object), args); + ASSERT(constructType == ConstructTypeJS); - // FIXME: Can this be done more efficiently using the constructData? - return asFunction(object)->construct(exec, args); + JSFunction* jsFunction = asFunction(object); + + ASSERT(!jsFunction->isHostFunction()); + Structure* structure; + JSValue prototype = jsFunction->get(exec, exec->propertyNames().prototype); + if (prototype.isObject()) + structure = asObject(prototype)->inheritorID(); + else + structure = exec->lexicalGlobalObject()->emptyObjectStructure(); + JSObject* thisObj = new (exec) JSObject(structure); + + JSValue result = exec->interpreter()->executeConstruct(jsFunction->jsExecutable(), exec, jsFunction, thisObj, args, jsFunction->scope().node(), exec->exceptionSlot()); + if (exec->hadException() || !result.isObject()) + return thisObj; + return asObject(result); } } // namespace JSC |