Commit 5dea615d authored by oliver@apple.com's avatar oliver@apple.com

2010-05-21 Oliver Hunt <oliver@apple.com>

        Reviewed by Geoffrey Garen.

        All callable objects should have a global object reference
        https://bugs.webkit.org/show_bug.cgi?id=39495

        All objects that may ever return a value other CallTypeNone
        or ConstructTypeNone now get a global object in their constructor
        and store that in their first anonymous slot.  We add a new type
        JSObjectWithGlobalObject to allow us to share this logic as much
        as possible, however some objects have specific inheritance
        requirements so we can't just use it universally.

        To enforce this requirement JSValue::getCallData and getConstructData
        make use of a new "isValidCallee" function to assert that any object
        that returns a value other than CallType/ConstructTypeNone has a
        global object in anonymous slot 0.

        In order to ensure that static function slots are converted into
        function objects with the correct global object, all prototype objects
        and other classes with static function slots also gain a global object
        reference.  Happily this fixes the long standing issue where host
        function objects get a prototype from the lexical global object of the
        first function that calls them, instead of the global object that they
        are defined on.

        * API/JSCallbackConstructor.cpp:
        (JSC::JSCallbackConstructor::JSCallbackConstructor):
        * API/JSCallbackConstructor.h:
        * API/JSCallbackFunction.cpp:
        (JSC::JSCallbackFunction::JSCallbackFunction):
        * API/JSCallbackFunction.h:
        * API/JSCallbackObject.cpp:
        (JSC::):
        * API/JSCallbackObject.h:
        * API/JSCallbackObjectFunctions.h:
        (JSC::::JSCallbackObject):
        (JSC::::staticFunctionGetter):
        * API/JSClassRef.cpp:
        (OpaqueJSClass::prototype):
        * API/JSContextRef.cpp:
        * API/JSObjectRef.cpp:
        (JSObjectMake):
        (JSObjectMakeFunctionWithCallback):
        (JSObjectMakeConstructor):
        (JSObjectGetPrivate):
        (JSObjectSetPrivate):
        (JSObjectGetPrivateProperty):
        (JSObjectSetPrivateProperty):
        (JSObjectDeletePrivateProperty):
        * API/JSValueRef.cpp:
        (JSValueIsObjectOfClass):
        * API/JSWeakObjectMapRefPrivate.cpp:
        * CMakeLists.txt:
        * GNUmakefile.am:
        * JavaScriptCore.exp:
        * JavaScriptCore.gypi:
        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
        * JavaScriptCore.xcodeproj/project.pbxproj:
        * interpreter/Interpreter.cpp:
        (JSC::Interpreter::privateExecute):
        * jit/JITStubs.cpp:
        (JSC::DEFINE_STUB_FUNCTION):
        * jsc.cpp:
        (GlobalObject::GlobalObject):
        * runtime/ArrayConstructor.cpp:
        (JSC::ArrayConstructor::ArrayConstructor):
        * runtime/ArrayConstructor.h:
        * runtime/ArrayPrototype.cpp:
        (JSC::ArrayPrototype::ArrayPrototype):
        * runtime/ArrayPrototype.h:
        (JSC::ArrayPrototype::createStructure):
        * runtime/BooleanConstructor.cpp:
        (JSC::BooleanConstructor::BooleanConstructor):
        * runtime/BooleanConstructor.h:
        * runtime/BooleanPrototype.cpp:
        (JSC::BooleanPrototype::BooleanPrototype):
        * runtime/BooleanPrototype.h:
        * runtime/DateConstructor.cpp:
        (JSC::DateConstructor::DateConstructor):
        * runtime/DateConstructor.h:
        * runtime/DatePrototype.cpp:
        (JSC::DatePrototype::DatePrototype):
        * runtime/DatePrototype.h:
        * runtime/ErrorConstructor.cpp:
        (JSC::ErrorConstructor::ErrorConstructor):
        * runtime/ErrorConstructor.h:
        * runtime/ErrorPrototype.cpp:
        (JSC::ErrorPrototype::ErrorPrototype):
        * runtime/ErrorPrototype.h:
        * runtime/FunctionConstructor.cpp:
        (JSC::FunctionConstructor::FunctionConstructor):
        * runtime/FunctionConstructor.h:
        * runtime/FunctionPrototype.cpp:
        (JSC::FunctionPrototype::FunctionPrototype):
        (JSC::FunctionPrototype::addFunctionProperties):
        * runtime/FunctionPrototype.h:
        * runtime/GlobalEvalFunction.cpp:
        (JSC::GlobalEvalFunction::GlobalEvalFunction):
        * runtime/GlobalEvalFunction.h:
        * runtime/InternalFunction.cpp:
        (JSC::InternalFunction::InternalFunction):
        * runtime/InternalFunction.h:
        * runtime/JSCell.h:
        (JSC::JSValue::getCallData):
        (JSC::JSValue::getConstructData):
        * runtime/JSFunction.cpp:
        (JSC::JSFunction::JSFunction):
        * runtime/JSFunction.h:
        * runtime/JSGlobalObject.cpp:
        (JSC::JSGlobalObject::reset):
        * runtime/JSGlobalObject.h:
        (JSC::JSGlobalObject::JSGlobalObject):
        * runtime/JSONObject.cpp:
        (JSC::JSONObject::JSONObject):
        * runtime/JSONObject.h:
        * runtime/JSObject.h:
        * runtime/JSObjectWithGlobalObject.cpp: Added.
        (JSC::JSObjectWithGlobalObject::JSObjectWithGlobalObject):
        * runtime/JSObjectWithGlobalObject.h: Added.
        (JSC::JSObjectWithGlobalObject::createStructure):
        (JSC::JSObjectWithGlobalObject::JSObjectWithGlobalObject):
        * runtime/JSValue.cpp:
        (JSC::JSValue::isValidCallee):
        * runtime/JSValue.h:
        * runtime/Lookup.cpp:
        (JSC::setUpStaticFunctionSlot):
        * runtime/MathObject.cpp:
        (JSC::MathObject::MathObject):
        * runtime/MathObject.h:
        * runtime/NativeErrorConstructor.cpp:
        (JSC::NativeErrorConstructor::NativeErrorConstructor):
        * runtime/NativeErrorConstructor.h:
        * runtime/NativeErrorPrototype.cpp:
        (JSC::NativeErrorPrototype::NativeErrorPrototype):
        * runtime/NativeErrorPrototype.h:
        * runtime/NumberConstructor.cpp:
        (JSC::NumberConstructor::NumberConstructor):
        * runtime/NumberConstructor.h:
        * runtime/NumberPrototype.cpp:
        (JSC::NumberPrototype::NumberPrototype):
        * runtime/NumberPrototype.h:
        * runtime/ObjectConstructor.cpp:
        (JSC::ObjectConstructor::ObjectConstructor):
        * runtime/ObjectConstructor.h:
        * runtime/ObjectPrototype.cpp:
        (JSC::ObjectPrototype::ObjectPrototype):
        * runtime/ObjectPrototype.h:
        * runtime/PrototypeFunction.cpp:
        (JSC::PrototypeFunction::PrototypeFunction):
        * runtime/PrototypeFunction.h:
        * runtime/RegExpConstructor.cpp:
        (JSC::RegExpConstructor::RegExpConstructor):
        (JSC::constructRegExp):
        * runtime/RegExpConstructor.h:
        * runtime/RegExpObject.cpp:
        (JSC::RegExpObject::RegExpObject):
        * runtime/RegExpObject.h:
        * runtime/RegExpPrototype.cpp:
        (JSC::RegExpPrototype::RegExpPrototype):
        * runtime/RegExpPrototype.h:
        * runtime/StringConstructor.cpp:
        (JSC::StringConstructor::StringConstructor):
        * runtime/StringConstructor.h:
        * runtime/StringPrototype.cpp:
        (JSC::StringPrototype::StringPrototype):
        * runtime/StringPrototype.h:
2010-05-21  Oliver Hunt  <oliver@apple.com>

        Reviewed by Geoffrey Garen.

        All callable objects should have a global object reference
        https://bugs.webkit.org/show_bug.cgi?id=39495

        Update expected results as we now give all function objects
        get their prototypes from the correct global object.

        * fast/dom/prototype-inheritance-expected.txt:
2010-05-21  Oliver Hunt  <oliver@apple.com>

        Reviewed by Geoffrey Garen.

        All callable objects should have a global object reference
        https://bugs.webkit.org/show_bug.cgi?id=39495

        Update the bindings generator to give prototype objects a
        global object.  Update all the manually written JSObject
        subclasses to pass a global object.

        * ForwardingHeaders/runtime/JSObjectWithGlobalObject.h: Added.
        * WebCore.PluginHostProcess.exp:
        * bindings/js/JSDOMBinding.cpp:
        (WebCore::objectToStringFunctionGetter):
        * bindings/js/JSDOMWindowCustom.cpp:
        (WebCore::nonCachingStaticFunctionGetter):
        * bindings/js/JSDOMWindowShell.cpp:
        (WebCore::JSDOMWindowShell::setWindow):
        * bindings/js/JSHistoryCustom.cpp:
        (WebCore::nonCachingStaticBackFunctionGetter):
        (WebCore::nonCachingStaticForwardFunctionGetter):
        (WebCore::nonCachingStaticGoFunctionGetter):
        * bindings/js/JSLocationCustom.cpp:
        (WebCore::nonCachingStaticReplaceFunctionGetter):
        (WebCore::nonCachingStaticReloadFunctionGetter):
        (WebCore::nonCachingStaticAssignFunctionGetter):
        * bindings/js/WorkerScriptController.cpp:
        (WebCore::WorkerScriptController::initScript):
        * bindings/scripts/CodeGeneratorJS.pm:
        * bridge/c/CRuntimeObject.cpp:
        (JSC::Bindings::CRuntimeObject::CRuntimeObject):
        * bridge/c/CRuntimeObject.h:
        * bridge/c/c_instance.cpp:
        (JSC::Bindings::CInstance::newRuntimeObject):
        (JSC::Bindings::CRuntimeMethod::CRuntimeMethod):
        (JSC::Bindings::CInstance::getMethod):
        * bridge/jni/jsc/JavaInstanceJSC.cpp:
        (JavaInstance::newRuntimeObject):
        (JavaRuntimeMethod::JavaRuntimeMethod):
        (JavaInstance::getMethod):
        * bridge/jni/jsc/JavaRuntimeObject.cpp:
        (JSC::Bindings::JavaRuntimeObject::JavaRuntimeObject):
        * bridge/jni/jsc/JavaRuntimeObject.h:
        * bridge/jsc/BridgeJSC.cpp:
        (JSC::Bindings::Instance::newRuntimeObject):
        * bridge/objc/ObjCRuntimeObject.h:
        * bridge/objc/ObjCRuntimeObject.mm:
        (JSC::Bindings::ObjCRuntimeObject::ObjCRuntimeObject):
        * bridge/objc/objc_class.mm:
        (JSC::Bindings::ObjcClass::fallbackObject):
        * bridge/objc/objc_instance.mm:
        (ObjcInstance::newRuntimeObject):
        (ObjCRuntimeMethod::ObjCRuntimeMethod):
        (ObjcInstance::getMethod):
        * bridge/objc/objc_runtime.h:
        * bridge/objc/objc_runtime.mm:
        (JSC::Bindings::ObjcFallbackObjectImp::ObjcFallbackObjectImp):
        * bridge/runtime_method.cpp:
        (JSC::RuntimeMethod::RuntimeMethod):
        * bridge/runtime_method.h:
        * bridge/runtime_object.cpp:
        (JSC::Bindings::RuntimeObject::RuntimeObject):
        * bridge/runtime_object.h:
2010-05-21  Oliver Hunt  <oliver@apple.com>

        Reviewed by Geoffrey Garen.

        All callable objects should have a global object reference
        https://bugs.webkit.org/show_bug.cgi?id=39495

        Update the plugin proxy to handle the need for global object.

        * Plugins/Hosted/ProxyInstance.mm:
        (WebKit::ProxyInstance::newRuntimeObject):
        (WebKit::ProxyRuntimeMethod::ProxyRuntimeMethod):
        (WebKit::ProxyInstance::getMethod):
        * Plugins/Hosted/ProxyRuntimeObject.h:
        * Plugins/Hosted/ProxyRuntimeObject.mm:
        (WebKit::ProxyRuntimeObject::ProxyRuntimeObject):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@59941 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1f6b7861
......@@ -37,8 +37,8 @@ namespace JSC {
const ClassInfo JSCallbackConstructor::info = { "CallbackConstructor", 0, 0, 0 };
JSCallbackConstructor::JSCallbackConstructor(NonNullPassRefPtr<Structure> structure, JSClassRef jsClass, JSObjectCallAsConstructorCallback callback)
: JSObject(structure)
JSCallbackConstructor::JSCallbackConstructor(JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, JSClassRef jsClass, JSObjectCallAsConstructorCallback callback)
: JSObjectWithGlobalObject(globalObject, structure)
, m_class(jsClass)
, m_callback(callback)
{
......
......@@ -27,13 +27,13 @@
#define JSCallbackConstructor_h
#include "JSObjectRef.h"
#include <runtime/JSObject.h>
#include <runtime/JSObjectWithGlobalObject.h>
namespace JSC {
class JSCallbackConstructor : public JSObject {
class JSCallbackConstructor : public JSObjectWithGlobalObject {
public:
JSCallbackConstructor(NonNullPassRefPtr<Structure>, JSClassRef, JSObjectCallAsConstructorCallback);
JSCallbackConstructor(JSGlobalObject*, NonNullPassRefPtr<Structure>, JSClassRef, JSObjectCallAsConstructorCallback);
virtual ~JSCallbackConstructor();
JSClassRef classRef() const { return m_class; }
JSObjectCallAsConstructorCallback callback() const { return m_callback; }
......
......@@ -41,8 +41,8 @@ ASSERT_CLASS_FITS_IN_CELL(JSCallbackFunction);
const ClassInfo JSCallbackFunction::info = { "CallbackFunction", &InternalFunction::info, 0, 0 };
JSCallbackFunction::JSCallbackFunction(ExecState* exec, JSObjectCallAsFunctionCallback callback, const Identifier& name)
: InternalFunction(&exec->globalData(), exec->lexicalGlobalObject()->callbackFunctionStructure(), name)
JSCallbackFunction::JSCallbackFunction(ExecState* exec, JSGlobalObject* globalObject, JSObjectCallAsFunctionCallback callback, const Identifier& name)
: InternalFunction(&exec->globalData(), globalObject, globalObject->callbackFunctionStructure(), name)
, m_callback(callback)
{
}
......
......@@ -33,7 +33,7 @@ namespace JSC {
class JSCallbackFunction : public InternalFunction {
public:
JSCallbackFunction(ExecState*, JSObjectCallAsFunctionCallback, const Identifier& name);
JSCallbackFunction(ExecState*, JSGlobalObject*, JSObjectCallAsFunctionCallback, const Identifier& name);
static const ClassInfo info;
......
......@@ -32,11 +32,11 @@
namespace JSC {
ASSERT_CLASS_FITS_IN_CELL(JSCallbackObject<JSObject>);
ASSERT_CLASS_FITS_IN_CELL(JSCallbackObject<JSObjectWithGlobalObject>);
ASSERT_CLASS_FITS_IN_CELL(JSCallbackObject<JSGlobalObject>);
// Define the two types of JSCallbackObjects we support.
template <> const ClassInfo JSCallbackObject<JSObject>::info = { "CallbackObject", 0, 0, 0 };
template <> const ClassInfo JSCallbackObject<JSObjectWithGlobalObject>::info = { "CallbackObject", 0, 0, 0 };
template <> const ClassInfo JSCallbackObject<JSGlobalObject>::info = { "CallbackGlobalObject", 0, 0, 0 };
} // namespace JSC
......@@ -114,8 +114,8 @@ struct JSCallbackObjectData {
template <class Base>
class JSCallbackObject : public Base {
public:
JSCallbackObject(ExecState*, NonNullPassRefPtr<Structure>, JSClassRef, void* data);
JSCallbackObject(JSClassRef);
JSCallbackObject(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, JSClassRef, void* data);
JSCallbackObject(JSClassRef, NonNullPassRefPtr<Structure>);
virtual ~JSCallbackObject();
void setPrivate(void* data);
......
......@@ -48,8 +48,8 @@ inline JSCallbackObject<Base>* JSCallbackObject<Base>::asCallbackObject(JSValue
}
template <class Base>
JSCallbackObject<Base>::JSCallbackObject(ExecState* exec, NonNullPassRefPtr<Structure> structure, JSClassRef jsClass, void* data)
: Base(structure)
JSCallbackObject<Base>::JSCallbackObject(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, JSClassRef jsClass, void* data)
: Base(globalObject, structure)
, m_callbackObjectData(new JSCallbackObjectData(data, jsClass))
{
init(exec);
......@@ -58,8 +58,8 @@ JSCallbackObject<Base>::JSCallbackObject(ExecState* exec, NonNullPassRefPtr<Stru
// Global object constructor.
// FIXME: Move this into a separate JSGlobalCallbackObject class derived from this one.
template <class Base>
JSCallbackObject<Base>::JSCallbackObject(JSClassRef jsClass)
: Base()
JSCallbackObject<Base>::JSCallbackObject(JSClassRef jsClass, NonNullPassRefPtr<Structure> structure)
: Base(structure)
, m_callbackObjectData(new JSCallbackObjectData(0, jsClass))
{
ASSERT(Base::isGlobalObject());
......@@ -560,7 +560,8 @@ JSValue JSCallbackObject<Base>::staticFunctionGetter(ExecState* exec, JSValue sl
if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) {
if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.ustring().rep())) {
if (JSObjectCallAsFunctionCallback callAsFunction = entry->callAsFunction) {
JSObject* o = new (exec) JSCallbackFunction(exec, callAsFunction, propertyName);
JSObject* o = new (exec) JSCallbackFunction(exec, asGlobalObject(thisObj->getAnonymousValue(0)), callAsFunction, propertyName);
thisObj->putDirect(propertyName, o, entry->attributes);
return o;
}
......
......@@ -256,7 +256,7 @@ JSObject* OpaqueJSClass::prototype(ExecState* exec)
if (!jsClassData.cachedPrototype) {
// Recursive, but should be good enough for our purposes
jsClassData.cachedPrototype = new (exec) JSCallbackObject<JSObject>(exec, exec->lexicalGlobalObject()->callbackObjectStructure(), prototypeClass, &jsClassData); // set jsClassData as the object's private data, so it can clear our reference on destruction
jsClassData.cachedPrototype = new (exec) JSCallbackObject<JSObjectWithGlobalObject>(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->callbackObjectStructure(), prototypeClass, &jsClassData); // set jsClassData as the object's private data, so it can clear our reference on destruction
if (parentClass) {
if (JSObject* prototype = parentClass->prototype(exec))
jsClassData.cachedPrototype->setPrototype(prototype);
......
......@@ -97,7 +97,7 @@ JSGlobalContextRef JSGlobalContextCreateInGroup(JSContextGroupRef group, JSClass
return JSGlobalContextRetain(toGlobalRef(globalObject->globalExec()));
}
JSGlobalObject* globalObject = new (globalData.get()) JSCallbackObject<JSGlobalObject>(globalObjectClass);
JSGlobalObject* globalObject = new (globalData.get()) JSCallbackObject<JSGlobalObject>(globalObjectClass, JSCallbackObject<JSGlobalObject>::createStructure(jsNull()));
ExecState* exec = globalObject->globalExec();
JSValue prototype = globalObjectClass->prototype(exec);
if (!prototype)
......
......@@ -81,7 +81,7 @@ JSObjectRef JSObjectMake(JSContextRef ctx, JSClassRef jsClass, void* data)
if (!jsClass)
return toRef(new (exec) JSObject(exec->lexicalGlobalObject()->emptyObjectStructure())); // slightly more efficient
JSCallbackObject<JSObject>* object = new (exec) JSCallbackObject<JSObject>(exec, exec->lexicalGlobalObject()->callbackObjectStructure(), jsClass, data);
JSCallbackObject<JSObjectWithGlobalObject>* object = new (exec) JSCallbackObject<JSObjectWithGlobalObject>(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->callbackObjectStructure(), jsClass, data);
if (JSObject* prototype = jsClass->prototype(exec))
object->setPrototype(prototype);
......@@ -95,7 +95,7 @@ JSObjectRef JSObjectMakeFunctionWithCallback(JSContextRef ctx, JSStringRef name,
Identifier nameID = name ? name->identifier(&exec->globalData()) : Identifier(exec, "anonymous");
return toRef(new (exec) JSCallbackFunction(exec, callAsFunction, nameID));
return toRef(new (exec) JSCallbackFunction(exec, exec->lexicalGlobalObject(), callAsFunction, nameID));
}
JSObjectRef JSObjectMakeConstructor(JSContextRef ctx, JSClassRef jsClass, JSObjectCallAsConstructorCallback callAsConstructor)
......@@ -107,7 +107,7 @@ JSObjectRef JSObjectMakeConstructor(JSContextRef ctx, JSClassRef jsClass, JSObje
if (!jsPrototype)
jsPrototype = exec->lexicalGlobalObject()->objectPrototype();
JSCallbackConstructor* constructor = new (exec) JSCallbackConstructor(exec->lexicalGlobalObject()->callbackConstructorStructure(), jsClass, callAsConstructor);
JSCallbackConstructor* constructor = new (exec) JSCallbackConstructor(exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->callbackConstructorStructure(), jsClass, callAsConstructor);
constructor->putDirect(exec->propertyNames().prototype, jsPrototype, DontEnum | DontDelete | ReadOnly);
return toRef(constructor);
}
......@@ -343,8 +343,8 @@ void* JSObjectGetPrivate(JSObjectRef object)
if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::info))
return static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->getPrivate();
else if (jsObject->inherits(&JSCallbackObject<JSObject>::info))
return static_cast<JSCallbackObject<JSObject>*>(jsObject)->getPrivate();
else if (jsObject->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::info))
return static_cast<JSCallbackObject<JSObjectWithGlobalObject>*>(jsObject)->getPrivate();
return 0;
}
......@@ -356,8 +356,8 @@ bool JSObjectSetPrivate(JSObjectRef object, void* data)
if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::info)) {
static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->setPrivate(data);
return true;
} else if (jsObject->inherits(&JSCallbackObject<JSObject>::info)) {
static_cast<JSCallbackObject<JSObject>*>(jsObject)->setPrivate(data);
} else if (jsObject->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::info)) {
static_cast<JSCallbackObject<JSObjectWithGlobalObject>*>(jsObject)->setPrivate(data);
return true;
}
......@@ -373,8 +373,8 @@ JSValueRef JSObjectGetPrivateProperty(JSContextRef ctx, JSObjectRef object, JSSt
Identifier name(propertyName->identifier(&exec->globalData()));
if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::info))
result = static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->getPrivateProperty(name);
else if (jsObject->inherits(&JSCallbackObject<JSObject>::info))
result = static_cast<JSCallbackObject<JSObject>*>(jsObject)->getPrivateProperty(name);
else if (jsObject->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::info))
result = static_cast<JSCallbackObject<JSObjectWithGlobalObject>*>(jsObject)->getPrivateProperty(name);
return toRef(exec, result);
}
......@@ -389,8 +389,8 @@ bool JSObjectSetPrivateProperty(JSContextRef ctx, JSObjectRef object, JSStringRe
static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->setPrivateProperty(name, jsValue);
return true;
}
if (jsObject->inherits(&JSCallbackObject<JSObject>::info)) {
static_cast<JSCallbackObject<JSObject>*>(jsObject)->setPrivateProperty(name, jsValue);
if (jsObject->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::info)) {
static_cast<JSCallbackObject<JSObjectWithGlobalObject>*>(jsObject)->setPrivateProperty(name, jsValue);
return true;
}
return false;
......@@ -406,8 +406,8 @@ bool JSObjectDeletePrivateProperty(JSContextRef ctx, JSObjectRef object, JSStrin
static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->deletePrivateProperty(name);
return true;
}
if (jsObject->inherits(&JSCallbackObject<JSObject>::info)) {
static_cast<JSCallbackObject<JSObject>*>(jsObject)->deletePrivateProperty(name);
if (jsObject->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::info)) {
static_cast<JSCallbackObject<JSObjectWithGlobalObject>*>(jsObject)->deletePrivateProperty(name);
return true;
}
return false;
......
......@@ -131,8 +131,8 @@ bool JSValueIsObjectOfClass(JSContextRef ctx, JSValueRef value, JSClassRef jsCla
if (JSObject* o = jsValue.getObject()) {
if (o->inherits(&JSCallbackObject<JSGlobalObject>::info))
return static_cast<JSCallbackObject<JSGlobalObject>*>(o)->inherits(jsClass);
else if (o->inherits(&JSCallbackObject<JSObject>::info))
return static_cast<JSCallbackObject<JSObject>*>(o)->inherits(jsClass);
else if (o->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::info))
return static_cast<JSCallbackObject<JSObjectWithGlobalObject>*>(o)->inherits(jsClass);
}
return false;
}
......
......@@ -58,7 +58,7 @@ void JSWeakObjectMapSet(JSContextRef ctx, JSWeakObjectMapRef map, void* key, JSO
JSObject* obj = toJS(object);
if (!obj)
return;
ASSERT(obj->inherits(&JSCallbackObject<JSGlobalObject>::info) || obj->inherits(&JSCallbackObject<JSObject>::info));
ASSERT(obj->inherits(&JSCallbackObject<JSGlobalObject>::info) || obj->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::info));
map->map().set(key, obj);
}
......
......@@ -122,6 +122,7 @@ SET(JavaScriptCore_SOURCES
runtime/JSNotAnObject.cpp
runtime/JSNumberCell.cpp
runtime/JSObject.cpp
runtime/JSObjectWithGlobalObject.cpp
runtime/JSONObject.cpp
runtime/JSPropertyNameIterator.cpp
runtime/JSStaticScopeObject.cpp
......
2010-05-21 Oliver Hunt <oliver@apple.com>
Reviewed by Geoffrey Garen.
All callable objects should have a global object reference
https://bugs.webkit.org/show_bug.cgi?id=39495
All objects that may ever return a value other CallTypeNone
or ConstructTypeNone now get a global object in their constructor
and store that in their first anonymous slot. We add a new type
JSObjectWithGlobalObject to allow us to share this logic as much
as possible, however some objects have specific inheritance
requirements so we can't just use it universally.
To enforce this requirement JSValue::getCallData and getConstructData
make use of a new "isValidCallee" function to assert that any object
that returns a value other than CallType/ConstructTypeNone has a
global object in anonymous slot 0.
In order to ensure that static function slots are converted into
function objects with the correct global object, all prototype objects
and other classes with static function slots also gain a global object
reference. Happily this fixes the long standing issue where host
function objects get a prototype from the lexical global object of the
first function that calls them, instead of the global object that they
are defined on.
* API/JSCallbackConstructor.cpp:
(JSC::JSCallbackConstructor::JSCallbackConstructor):
* API/JSCallbackConstructor.h:
* API/JSCallbackFunction.cpp:
(JSC::JSCallbackFunction::JSCallbackFunction):
* API/JSCallbackFunction.h:
* API/JSCallbackObject.cpp:
(JSC::):
* API/JSCallbackObject.h:
* API/JSCallbackObjectFunctions.h:
(JSC::::JSCallbackObject):
(JSC::::staticFunctionGetter):
* API/JSClassRef.cpp:
(OpaqueJSClass::prototype):
* API/JSContextRef.cpp:
* API/JSObjectRef.cpp:
(JSObjectMake):
(JSObjectMakeFunctionWithCallback):
(JSObjectMakeConstructor):
(JSObjectGetPrivate):
(JSObjectSetPrivate):
(JSObjectGetPrivateProperty):
(JSObjectSetPrivateProperty):
(JSObjectDeletePrivateProperty):
* API/JSValueRef.cpp:
(JSValueIsObjectOfClass):
* API/JSWeakObjectMapRefPrivate.cpp:
* CMakeLists.txt:
* GNUmakefile.am:
* JavaScriptCore.exp:
* JavaScriptCore.gypi:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
* JavaScriptCore.xcodeproj/project.pbxproj:
* interpreter/Interpreter.cpp:
(JSC::Interpreter::privateExecute):
* jit/JITStubs.cpp:
(JSC::DEFINE_STUB_FUNCTION):
* jsc.cpp:
(GlobalObject::GlobalObject):
* runtime/ArrayConstructor.cpp:
(JSC::ArrayConstructor::ArrayConstructor):
* runtime/ArrayConstructor.h:
* runtime/ArrayPrototype.cpp:
(JSC::ArrayPrototype::ArrayPrototype):
* runtime/ArrayPrototype.h:
(JSC::ArrayPrototype::createStructure):
* runtime/BooleanConstructor.cpp:
(JSC::BooleanConstructor::BooleanConstructor):
* runtime/BooleanConstructor.h:
* runtime/BooleanPrototype.cpp:
(JSC::BooleanPrototype::BooleanPrototype):
* runtime/BooleanPrototype.h:
* runtime/DateConstructor.cpp:
(JSC::DateConstructor::DateConstructor):
* runtime/DateConstructor.h:
* runtime/DatePrototype.cpp:
(JSC::DatePrototype::DatePrototype):
* runtime/DatePrototype.h:
* runtime/ErrorConstructor.cpp:
(JSC::ErrorConstructor::ErrorConstructor):
* runtime/ErrorConstructor.h:
* runtime/ErrorPrototype.cpp:
(JSC::ErrorPrototype::ErrorPrototype):
* runtime/ErrorPrototype.h:
* runtime/FunctionConstructor.cpp:
(JSC::FunctionConstructor::FunctionConstructor):
* runtime/FunctionConstructor.h:
* runtime/FunctionPrototype.cpp:
(JSC::FunctionPrototype::FunctionPrototype):
(JSC::FunctionPrototype::addFunctionProperties):
* runtime/FunctionPrototype.h:
* runtime/GlobalEvalFunction.cpp:
(JSC::GlobalEvalFunction::GlobalEvalFunction):
* runtime/GlobalEvalFunction.h:
* runtime/InternalFunction.cpp:
(JSC::InternalFunction::InternalFunction):
* runtime/InternalFunction.h:
* runtime/JSCell.h:
(JSC::JSValue::getCallData):
(JSC::JSValue::getConstructData):
* runtime/JSFunction.cpp:
(JSC::JSFunction::JSFunction):
* runtime/JSFunction.h:
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::reset):
* runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::JSGlobalObject):
* runtime/JSONObject.cpp:
(JSC::JSONObject::JSONObject):
* runtime/JSONObject.h:
* runtime/JSObject.h:
* runtime/JSObjectWithGlobalObject.cpp: Added.
(JSC::JSObjectWithGlobalObject::JSObjectWithGlobalObject):
* runtime/JSObjectWithGlobalObject.h: Added.
(JSC::JSObjectWithGlobalObject::createStructure):
(JSC::JSObjectWithGlobalObject::JSObjectWithGlobalObject):
* runtime/JSValue.cpp:
(JSC::JSValue::isValidCallee):
* runtime/JSValue.h:
* runtime/Lookup.cpp:
(JSC::setUpStaticFunctionSlot):
* runtime/MathObject.cpp:
(JSC::MathObject::MathObject):
* runtime/MathObject.h:
* runtime/NativeErrorConstructor.cpp:
(JSC::NativeErrorConstructor::NativeErrorConstructor):
* runtime/NativeErrorConstructor.h:
* runtime/NativeErrorPrototype.cpp:
(JSC::NativeErrorPrototype::NativeErrorPrototype):
* runtime/NativeErrorPrototype.h:
* runtime/NumberConstructor.cpp:
(JSC::NumberConstructor::NumberConstructor):
* runtime/NumberConstructor.h:
* runtime/NumberPrototype.cpp:
(JSC::NumberPrototype::NumberPrototype):
* runtime/NumberPrototype.h:
* runtime/ObjectConstructor.cpp:
(JSC::ObjectConstructor::ObjectConstructor):
* runtime/ObjectConstructor.h:
* runtime/ObjectPrototype.cpp:
(JSC::ObjectPrototype::ObjectPrototype):
* runtime/ObjectPrototype.h:
* runtime/PrototypeFunction.cpp:
(JSC::PrototypeFunction::PrototypeFunction):
* runtime/PrototypeFunction.h:
* runtime/RegExpConstructor.cpp:
(JSC::RegExpConstructor::RegExpConstructor):
(JSC::constructRegExp):
* runtime/RegExpConstructor.h:
* runtime/RegExpObject.cpp:
(JSC::RegExpObject::RegExpObject):
* runtime/RegExpObject.h:
* runtime/RegExpPrototype.cpp:
(JSC::RegExpPrototype::RegExpPrototype):
* runtime/RegExpPrototype.h:
* runtime/StringConstructor.cpp:
(JSC::StringConstructor::StringConstructor):
* runtime/StringConstructor.h:
* runtime/StringPrototype.cpp:
(JSC::StringPrototype::StringPrototype):
* runtime/StringPrototype.h:
2010-05-21 Geoffrey Garen <ggaren@apple.com>
Reviewed by Oliver Hunt.
......
......@@ -463,6 +463,7 @@ javascriptcore_sources += \
JavaScriptCore/runtime/JSNumberCell.cpp \
JavaScriptCore/runtime/JSNumberCell.h \
JavaScriptCore/runtime/JSObject.cpp \
JavaScriptCore/runtime/JSObjectWithGlobalObject.cpp \
JavaScriptCore/runtime/JSObject.h \
JavaScriptCore/runtime/JSStaticScopeObject.cpp \
JavaScriptCore/runtime/JSStaticScopeObject.h \
......
......@@ -101,6 +101,7 @@ __Z12jsRegExpFreeP8JSRegExp
__Z15jsRegExpCompilePKti24JSRegExpIgnoreCaseOption23JSRegExpMultilineOptionPjPPKc
__Z15jsRegExpExecutePK8JSRegExpPKtiiPii
__ZN14OpaqueJSString6createERKN3JSC7UStringE
__ZN3JSC10JSFunctionC1EPNS_9ExecStateEPNS_14JSGlobalObjectEN3WTF17NonNullPassRefPtrINS_9StructureEEEiRKNS_10IdentifierEPFNS_7JSValueES2_PNS_8JSObjectESC_RKNS_7ArgListEE
__ZN3JSC10Identifier11addSlowCaseEPNS_12JSGlobalDataEPN7WebCore10StringImplE
__ZN3JSC10Identifier11addSlowCaseEPNS_9ExecStateEPN7WebCore10StringImplE
__ZN3JSC10Identifier27checkCurrentIdentifierTableEPNS_12JSGlobalDataE
......@@ -111,7 +112,6 @@ __ZN3JSC10Identifier4fromEPNS_9ExecStateEj
__ZN3JSC10Identifier5equalEPKN7WebCore10StringImplEPKc
__ZN3JSC10JSFunction4infoE
__ZN3JSC10JSFunction4nameEPNS_9ExecStateE
__ZN3JSC10JSFunctionC1EPNS_9ExecStateEN3WTF17NonNullPassRefPtrINS_9StructureEEEiRKNS_10IdentifierEPFNS_7JSValueES2_PNS_8JSObjectESA_RKNS_7ArgListEE
__ZN3JSC10throwErrorEPNS_9ExecStateENS_9ErrorTypeE
__ZN3JSC10throwErrorEPNS_9ExecStateENS_9ErrorTypeEPKc
__ZN3JSC10throwErrorEPNS_9ExecStateENS_9ErrorTypeERKNS_7UStringE
......@@ -169,15 +169,14 @@ __ZN3JSC15createTypeErrorEPNS_9ExecStateEPKc
__ZN3JSC15toInt32SlowCaseEdRb
__ZN3JSC16InternalFunction4infoE
__ZN3JSC16InternalFunction4nameEPNS_9ExecStateE
__ZN3JSC16InternalFunctionC2EPNS_12JSGlobalDataEN3WTF17NonNullPassRefPtrINS_9StructureEEERKNS_10IdentifierE
__ZN3JSC16InternalFunctionC2EPNS_12JSGlobalDataEPNS_14JSGlobalObjectEN3WTF17NonNullPassRefPtrINS_9StructureEEERKNS_10IdentifierE
__ZN3JSC16JSVariableObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
__ZN3JSC16JSVariableObject14symbolTableGetERKNS_10IdentifierERNS_18PropertyDescriptorE
__ZN3JSC16JSVariableObject19getOwnPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayENS_15EnumerationModeE
__ZN3JSC16toUInt32SlowCaseEdRb
__ZN3JSC17BytecodeGenerator21setDumpsGeneratedCodeEb
__ZN3JSC17PropertyNameArray3addEPN7WebCore10StringImplE
__ZN3JSC17PrototypeFunctionC1EPNS_9ExecStateEN3WTF17NonNullPassRefPtrINS_9StructureEEEiRKNS_10IdentifierEPFNS_7JSValueES2_PNS_8JSObjectESA_RKNS_7ArgListEE
__ZN3JSC17PrototypeFunctionC1EPNS_9ExecStateEiRKNS_10IdentifierEPFNS_7JSValueES2_PNS_8JSObjectES6_RKNS_7ArgListEE
__ZN3JSC17PrototypeFunctionC1EPNS_9ExecStateEPNS_14JSGlobalObjectEN3WTF17NonNullPassRefPtrINS_9StructureEEEiRKNS_10IdentifierEPFNS_7JSValueES2_PNS_8JSObjectESC_RKNS_7ArgListEE
__ZN3JSC17constructFunctionEPNS_9ExecStateERKNS_7ArgListERKNS_10IdentifierERKNS_7UStringEi
__ZN3JSC18DebuggerActivationC1EPNS_8JSObjectE
__ZN3JSC18PropertyDescriptor11setWritableEb
......@@ -195,6 +194,7 @@ __ZN3JSC23AbstractSamplingCounter4dumpEv
__ZN3JSC23objectProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectENS_7JSValueERKNS_7ArgListE
__ZN3JSC23setUpStaticFunctionSlotEPNS_9ExecStateEPKNS_9HashEntryEPNS_8JSObjectERKNS_10IdentifierERNS_12PropertySlotE
__ZN3JSC24createStackOverflowErrorEPNS_9ExecStateE
__ZN3JSC24JSObjectWithGlobalObjectC2EPNS_14JSGlobalObjectEN3WTF17NonNullPassRefPtrINS_9StructureEEE
__ZN3JSC25evaluateInGlobalCallFrameERKNS_7UStringERNS_7JSValueEPNS_14JSGlobalObjectE
__ZN3JSC35createInterruptedExecutionExceptionEPNS_12JSGlobalDataE
__ZN3JSC3NaNE
......@@ -240,6 +240,7 @@ __ZN3JSC7JSArrayC1EN3WTF17NonNullPassRefPtrINS_9StructureEEE
__ZN3JSC7JSArrayC1EN3WTF17NonNullPassRefPtrINS_9StructureEEERKNS_7ArgListE
__ZN3JSC7JSArrayC2EN3WTF17NonNullPassRefPtrINS_9StructureEEE
__ZN3JSC7JSArrayD2Ev
__ZN3JSC7JSValue13isValidCalleeEv
__ZN3JSC7Profile10restoreAllEv
__ZN3JSC7Profile5focusEPKNS_11ProfileNodeE
__ZN3JSC7Profile7excludeEPKNS_11ProfileNodeE
......
......@@ -247,6 +247,8 @@
'runtime/JSNumberCell.h',
'runtime/JSObject.cpp',
'runtime/JSObject.h',
'runtime/JSObjectWithGlobalObject.cpp',
'runtime/JSObjectWithGlobalObject.h',
'runtime/JSONObject.cpp',
'runtime/JSONObject.h',
'runtime/JSPropertyNameIterator.cpp',
......
......@@ -852,6 +852,14 @@
RelativePath="..\..\runtime\JSObject.h"
>
</File>
<File
RelativePath="..\..\runtime\JSObjectWithGlobalObject.cpp"
>
</File>
<File
RelativePath="..\..\runtime\JSObjectWithGlobalObject.h"
>
</File>
<File
RelativePath="..\..\runtime\JSONObject.cpp"
>
......
......@@ -309,6 +309,8 @@
A76EE6590FAE59D5003F069A /* NativeFunctionWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = A76EE6580FAE59D5003F069A /* NativeFunctionWrapper.h */; settings = {ATTRIBUTES = (Private, ); }; };
A7795590101A74D500114E55 /* MarkStack.h in Headers */ = {isa = PBXBuildFile; fileRef = A779558F101A74D500114E55 /* MarkStack.h */; settings = {ATTRIBUTES = (Private, ); }; };
A782F1A50EEC9FA20036273F /* ExecutableAllocatorPosix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A782F1A40EEC9FA20036273F /* ExecutableAllocatorPosix.cpp */; };
A783A0D111A36DCA00563D20 /* JSObjectWithGlobalObject.h in Headers */ = {isa = PBXBuildFile; fileRef = A783A0D011A36DCA00563D20 /* JSObjectWithGlobalObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
A783A2AB11A5BE8400563D20 /* JSObjectWithGlobalObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A783A2AA11A5BE8400563D20 /* JSObjectWithGlobalObject.cpp */; };
A791EF280F11E07900AE1F68 /* JSByteArray.h in Headers */ = {isa = PBXBuildFile; fileRef = A791EF260F11E07900AE1F68 /* JSByteArray.h */; settings = {ATTRIBUTES = (Private, ); }; };
A791EF290F11E07900AE1F68 /* JSByteArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A791EF270F11E07900AE1F68 /* JSByteArray.cpp */; };
A7A1F7AC0F252B3C00E184E2 /* ByteArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7A1F7AA0F252B3C00E184E2 /* ByteArray.cpp */; };
......@@ -898,6 +900,8 @@
A76EE6580FAE59D5003F069A /* NativeFunctionWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeFunctionWrapper.h; sourceTree = "<group>"; };
A779558F101A74D500114E55 /* MarkStack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MarkStack.h; sourceTree = "<group>"; };
A782F1A40EEC9FA20036273F /* ExecutableAllocatorPosix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExecutableAllocatorPosix.cpp; sourceTree = "<group>"; };
A783A0D011A36DCA00563D20 /* JSObjectWithGlobalObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSObjectWithGlobalObject.h; sourceTree = "<group>"; };
A783A2AA11A5BE8400563D20 /* JSObjectWithGlobalObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSObjectWithGlobalObject.cpp; sourceTree = "<group>"; };
A791EF260F11E07900AE1F68 /* JSByteArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSByteArray.h; sourceTree = "<group>"; };
A791EF270F11E07900AE1F68 /* JSByteArray.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSByteArray.cpp; sourceTree = "<group>"; };
A79EDB0811531CD60019E912 /* JSObjectRefPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSObjectRefPrivate.h; sourceTree = "<group>"; };
......@@ -1710,6 +1714,8 @@
14BFCE6810CDB1FC00364CCE /* WeakGCMap.h */,
14035DB010DBFB2A00FFFFE7 /* WeakGCPtr.h */,
1420BE7A10AA6DDB00F455D2 /* WeakRandom.h */,
A783A0D011A36DCA00563D20 /* JSObjectWithGlobalObject.h */,
A783A2AA11A5BE8400563D20 /* JSObjectWithGlobalObject.cpp */,
);
path = runtime;
sourceTree = "<group>";
......@@ -2147,6 +2153,7 @@
869D04AF1193B54D00803475 /* CachedTranscendentalFunction.h in Headers */,
86C568E111A213EE0007F7F0 /* MacroAssemblerMIPS.h in Headers */,
86C568E211A213EE0007F7F0 /* MIPSAssembler.h in Headers */,
A783A0D111A36DCA00563D20 /* JSObjectWithGlobalObject.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -2600,6 +2607,7 @@
8626BECF11928E3900782FAB /* StringStatics.cpp in Sources */,
A71236E51195F33C00BD2174 /* JITOpcodes32_64.cpp in Sources */,
86C568E011A213EE0007F7F0 /* MacroAssemblerARM.cpp in Sources */,
A783A2AB11A5BE8400563D20 /* JSObjectWithGlobalObject.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
......@@ -2959,7 +2959,7 @@ DEFINE_STUB_FUNCTION(JSObject*, op_new_regexp)
{
STUB_INIT_STACK_FRAME(stackFrame);
return new (stackFrame.globalData) RegExpObject(stackFrame.callFrame->lexicalGlobalObject()->regExpStructure(), stackFrame.args[0].regExp());
return new (stackFrame.globalData) RegExpObject(stackFrame.callFrame->lexicalGlobalObject(), stackFrame.callFrame->lexicalGlobalObject()->regExpStructure(), stackFrame.args[0].regExp());
}
DEFINE_STUB_FUNCTION(EncodedJSValue, op_bitor)
......
......@@ -150,19 +150,19 @@ ASSERT_CLASS_FITS_IN_CELL(GlobalObject);
GlobalObject::GlobalObject(const Vector<UString>& arguments)
: JSGlobalObject()
{
putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), prototypeFunctionStructure(), 1, Identifier(globalExec(), "debug"), functionDebug));
putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), prototypeFunctionStructure(), 1, Identifier(globalExec(), "print"), functionPrint));
putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), prototypeFunctionStructure(), 0, Identifier(globalExec(), "quit"), functionQuit));
putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), prototypeFunctionStructure(), 0, Identifier(globalExec(), "gc"), functionGC));
putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), prototypeFunctionStructure(), 1, Identifier(globalExec(), "version"), functionVersion));
putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), prototypeFunctionStructure(), 1, Identifier(globalExec(), "run"), functionRun));
putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), prototypeFunctionStructure(), 1, Identifier(globalExec(), "load"), functionLoad));
putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), prototypeFunctionStructure(), 1, Identifier(globalExec(), "checkSyntax"), functionCheckSyntax));
putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), prototypeFunctionStructure(), 0, Identifier(globalExec(), "readline"), functionReadline));
putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), this, prototypeFunctionStructure(), 1, Identifier(globalExec(), "debug"), functionDebug));
putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), this, prototypeFunctionStructure(), 1, Identifier(globalExec(), "print"), functionPrint));
putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), this, prototypeFunctionStructure(), 0, Identifier(globalExec(), "quit"), functionQuit));