Commit 51bdc905 authored by barraclough@apple.com's avatar barraclough@apple.com
Browse files

Remove JSObject::unwrappedGlobalObject(), JSObject::unwrappedObject()

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

Reviewed by Geoff Garen.

../JavaScriptCore: 

unwrappedGlobalObject() was only needed because globalObject() doesn't always return a helpful result -
specifically for WebCore's window shell the structure's globalObject is set to null. We can fix this by
simply keeping the structure up to date as the window navigates, obviating the need for this function.

The only other use of unwrappedObject() came from globalFuncEval(), and this can be trivially removed
by flipping the way we perform this globalObject check (which we may also be able to remove!) - instead
of getting the globalObject from the provided this value & comparing to the expected globalObject, we
can get the this value from the expected globalObject, and compare to that provided.

* runtime/JSGlobalObject.cpp:
    - Call globalObject() instead of unwrappedGlobalObject().
* runtime/JSGlobalObjectFunctions.cpp:
(JSC::globalFuncEval):
    - Changed to compare this object values, instead of globalObjects -
      this means we only need to be able to map globalObject -> this,
      and not vice versa.
* runtime/JSObject.cpp:
(JSC::JSObject::allowsAccessFrom):
(JSC::JSObject::createInheritorID):
    - Call globalObject() instead of unwrappedGlobalObject().
* runtime/JSObject.h:
(JSObject):
    - Removed unwrappedGlobalObject(), unwrappedObject().

../WebCore: 

JSDOMWindowShell::setWindow should update the structure's globalObject.

* bindings/js/JSDOMWindowShell.h:
(WebCore::JSDOMWindowShell::setWindow):
    - Update the JSDOMWindowShell's structure's globalObject when the
      window changes.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@129456 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 72ec804c
2012-09-24 Gavin Barraclough <barraclough@apple.com>
Remove JSObject::unwrappedGlobalObject(), JSObject::unwrappedObject()
https://bugs.webkit.org/show_bug.cgi?id=97519
Reviewed by Geoff Garen.
unwrappedGlobalObject() was only needed because globalObject() doesn't always return a helpful result -
specifically for WebCore's window shell the structure's globalObject is set to null. We can fix this by
simply keeping the structure up to date as the window navigates, obviating the need for this function.
The only other use of unwrappedObject() came from globalFuncEval(), and this can be trivially removed
by flipping the way we perform this globalObject check (which we may also be able to remove!) - instead
of getting the globalObject from the provided this value & comparing to the expected globalObject, we
can get the this value from the expected globalObject, and compare to that provided.
* runtime/JSGlobalObject.cpp:
- Call globalObject() instead of unwrappedGlobalObject().
* runtime/JSGlobalObjectFunctions.cpp:
(JSC::globalFuncEval):
- Changed to compare this object values, instead of globalObjects -
this means we only need to be able to map globalObject -> this,
and not vice versa.
* runtime/JSObject.cpp:
(JSC::JSObject::allowsAccessFrom):
(JSC::JSObject::createInheritorID):
- Call globalObject() instead of unwrappedGlobalObject().
* runtime/JSObject.h:
(JSObject):
- Removed unwrappedGlobalObject(), unwrappedObject().
2012-09-24 Mark Lam <mark.lam@apple.com>
 
Deleting the classic interpreter and cleaning up some build options.
......
......@@ -373,7 +373,7 @@ void ObjectsWithBrokenIndexingFinder::operator()(JSCell* cell)
// a different global object that have prototypes from our global object.
bool foundGlobalObject = false;
for (JSObject* current = object; ;) {
if (current->unwrappedGlobalObject() == m_globalObject) {
if (current->globalObject() == m_globalObject) {
foundGlobalObject = true;
break;
}
......
......@@ -498,8 +498,8 @@ static double parseFloat(const String& s)
EncodedJSValue JSC_HOST_CALL globalFuncEval(ExecState* exec)
{
JSObject* thisObject = exec->hostThisValue().toThisObject(exec);
JSObject* unwrappedObject = thisObject->unwrappedObject();
if (!unwrappedObject->isGlobalObject() || jsCast<JSGlobalObject*>(unwrappedObject)->evalFunction() != exec->callee())
JSGlobalObject* calleeGlobalObject = exec->callee()->globalObject();
if (thisObject != exec->callee()->globalObject()->globalThis())
return throwVMError(exec, createEvalError(exec, ASCIILiteral("The \"this\" value passed to eval must be the global object from which eval originated")));
JSValue x = exec->argument(0);
......@@ -519,11 +519,11 @@ EncodedJSValue JSC_HOST_CALL globalFuncEval(ExecState* exec)
}
EvalExecutable* eval = EvalExecutable::create(exec, makeSource(s), false);
JSObject* error = eval->compile(exec, jsCast<JSGlobalObject*>(unwrappedObject));
JSObject* error = eval->compile(exec, calleeGlobalObject);
if (error)
return throwVMError(exec, error);
return JSValue::encode(exec->interpreter()->execute(eval, exec, thisObject, jsCast<JSGlobalObject*>(unwrappedObject)));
return JSValue::encode(exec->interpreter()->execute(eval, exec, thisObject, calleeGlobalObject));
}
EncodedJSValue JSC_HOST_CALL globalFuncParseInt(ExecState* exec)
......
......@@ -601,7 +601,7 @@ Structure* JSObject::inheritorID(JSGlobalData& globalData)
bool JSObject::allowsAccessFrom(ExecState* exec)
{
JSGlobalObject* globalObject = unwrappedGlobalObject();
JSGlobalObject* globalObject = this->globalObject();
return globalObject->globalObjectMethodTable()->allowsAccessFrom(globalObject, exec);
}
......@@ -924,13 +924,6 @@ JSObject* JSObject::toThisObject(JSCell* cell, ExecState*)
return jsCast<JSObject*>(cell);
}
JSObject* JSObject::unwrappedObject()
{
if (isGlobalThis())
return jsCast<JSGlobalThis*>(this)->unwrappedObject();
return this;
}
void JSObject::seal(JSGlobalData& globalData)
{
if (isSealed(globalData))
......@@ -954,13 +947,6 @@ void JSObject::preventExtensions(JSGlobalData& globalData)
setStructure(globalData, Structure::preventExtensionsTransition(globalData, structure()));
}
JSGlobalObject* JSObject::unwrappedGlobalObject()
{
if (isGlobalThis())
return jsCast<JSGlobalThis*>(this)->unwrappedObject();
return structure()->globalObject();
}
// This presently will flatten to an uncachable dictionary; this is suitable
// for use in delete, we may want to do something different elsewhere.
void JSObject::reifyStaticFunctionsForDelete(ExecState* exec)
......@@ -1052,7 +1038,7 @@ void JSObject::notifyUsedAsPrototype(JSGlobalData& globalData)
Structure* JSObject::createInheritorID(JSGlobalData& globalData)
{
Structure* inheritorID = createEmptyObjectStructure(globalData, unwrappedGlobalObject(), this);
Structure* inheritorID = createEmptyObjectStructure(globalData, globalObject(), this);
ASSERT(inheritorID->isEmpty());
PutPropertySlot slot;
......
......@@ -343,7 +343,6 @@ namespace JSC {
// NOTE: JSObject and its subclasses must be able to gracefully handle ExecState* = 0,
// because this call may come from inside the compiler.
JS_EXPORT_PRIVATE static JSObject* toThisObject(JSCell*, ExecState*);
JSObject* unwrappedObject();
bool getPropertySpecificValue(ExecState*, PropertyName, JSCell*& specificFunction) const;
......@@ -482,11 +481,6 @@ namespace JSC {
return structure()->globalObject();
}
// Does everything possible to return the global object. If it encounters an object
// that does not have a global object, it returns 0 instead (for example
// JSNotAnObject).
JSGlobalObject* unwrappedGlobalObject();
void switchToSlowPutArrayStorage(JSGlobalData&);
// The receiver is the prototype in this case. The following:
......
2012-09-24 Gavin Barraclough <barraclough@apple.com>
Remove JSObject::unwrappedGlobalObject(), JSObject::unwrappedObject()
https://bugs.webkit.org/show_bug.cgi?id=97519
Reviewed by Geoff Garen.
JSDOMWindowShell::setWindow should update the structure's globalObject.
* bindings/js/JSDOMWindowShell.h:
(WebCore::JSDOMWindowShell::setWindow):
- Update the JSDOMWindowShell's structure's globalObject when the
window changes.
2012-09-24 Yoshifumi Inoue <yosin@chromium.org>
 
[Forms] We should remove DateTimeEditElement::valueAsDouble()
......@@ -48,6 +48,7 @@ namespace WebCore {
{
ASSERT_ARG(window, window);
setUnwrappedObject(globalData, window);
structure()->setGlobalObject(*JSDOMWindow::commonJSGlobalData(), window);
}
void setWindow(PassRefPtr<DOMWindow>);
......
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