Commit 1bba3ce3 authored by barraclough@apple.com's avatar barraclough@apple.com

Proxy the global this in JSC

https://bugs.webkit.org/show_bug.cgi?id=97734

Reviewed by Oliver Hunt.

Having jsc diverge from WebCore here is not beneficial; it potentially masks bugs and/or performance
problems from command line testing.

* jsc.cpp:
(GlobalObject::create):
    - Create a this value proxy for the global object.
* runtime/JSGlobalObject.h:
(JSGlobalObject):
    - Make setGlobalThis protected.
* runtime/JSProxy.h:
(JSC::JSProxy::create):
(JSC::JSProxy::target):
(JSC::JSProxy::finishCreation):
(JSProxy):
    - Allow proxy target to be a JSObject, add target to create method.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@129711 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 419e2d42
2012-09-26 Gavin Barraclough <barraclough@apple.com>
Proxy the global this in JSC
https://bugs.webkit.org/show_bug.cgi?id=97734
Reviewed by Oliver Hunt.
Having jsc diverge from WebCore here is not beneficial; it potentially masks bugs and/or performance
problems from command line testing.
* jsc.cpp:
(GlobalObject::create):
- Create a this value proxy for the global object.
* runtime/JSGlobalObject.h:
(JSGlobalObject):
- Make setGlobalThis protected.
* runtime/JSProxy.h:
(JSC::JSProxy::create):
(JSC::JSProxy::target):
(JSC::JSProxy::finishCreation):
(JSProxy):
- Allow proxy target to be a JSObject, add target to create method.
2012-09-26 Gavin Barraclough <barraclough@apple.com>
Speculative Windows build fix.
......
......@@ -33,6 +33,7 @@
#include "JSCTypedArrayStubs.h"
#include "JSFunction.h"
#include "JSLock.h"
#include "JSProxy.h"
#include "JSString.h"
#include "SamplingTool.h"
#include <math.h>
......@@ -176,6 +177,7 @@ public:
{
GlobalObject* object = new (NotNull, allocateCell<GlobalObject>(globalData.heap)) GlobalObject(globalData, structure);
object->finishCreation(globalData, arguments);
object->setGlobalThis(globalData, JSProxy::create(globalData, JSProxy::createStructure(globalData, object), object));
return object;
}
......
......@@ -367,13 +367,14 @@ namespace JSC {
JS_EXPORT_PRIVATE static JSC::JSObject* toThisObject(JSC::JSCell*, JSC::ExecState*);
JS_EXPORT_PRIVATE void setGlobalThis(JSGlobalData&, JSObject* globalThis);
private:
friend class LLIntOffsetsExtractor;
// FIXME: Fold reset into init.
JS_EXPORT_PRIVATE void init(JSObject* thisValue);
void reset(JSValue prototype);
void setGlobalThis(JSGlobalData&, JSObject* globalThis);
void createThrowTypeError(ExecState*);
......
......@@ -34,10 +34,10 @@ class JSProxy : public JSNonFinalObject {
public:
typedef JSNonFinalObject Base;
static JSProxy* create(JSGlobalData& globalData, Structure* structure)
static JSProxy* create(JSGlobalData& globalData, Structure* structure, JSObject* target)
{
JSProxy* proxy = new (NotNull, allocateCell<JSProxy>(globalData.heap)) JSProxy(globalData, structure);
proxy->finishCreation(globalData);
proxy->finishCreation(globalData, target);
return proxy;
}
......@@ -48,7 +48,7 @@ public:
static JS_EXPORTDATA const ClassInfo s_info;
JSGlobalObject* target() const { return m_target.get(); }
JSObject* target() const { return m_target.get(); }
protected:
JSProxy(JSGlobalData& globalData, Structure* structure)
......@@ -61,6 +61,12 @@ protected:
Base::finishCreation(globalData);
}
void finishCreation(JSGlobalData& globalData, JSObject* target)
{
Base::finishCreation(globalData);
m_target.set(globalData, this, target);
}
static const unsigned StructureFlags = OverridesVisitChildren | OverridesGetOwnPropertySlot | OverridesGetPropertyNames | Base::StructureFlags;
JS_EXPORT_PRIVATE static void visitChildren(JSCell*, SlotVisitor&);
......@@ -81,7 +87,7 @@ protected:
JS_EXPORT_PRIVATE static bool defineOwnProperty(JSObject*, ExecState*, PropertyName, PropertyDescriptor&, bool shouldThrow);
private:
WriteBarrier<JSGlobalObject> m_target;
WriteBarrier<JSObject> m_target;
};
} // namespace JSC
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment