- Revision
- 129456
- Author
- [email protected]
- Date
- 2012-09-24 21:52:26 -0700 (Mon, 24 Sep 2012)
Log Message
Remove JSObject::unwrappedGlobalObject(), JSObject::unwrappedObject()
https://bugs.webkit.org/show_bug.cgi?id=97519
Reviewed by Geoff Garen.
../_javascript_Core:
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.
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (129455 => 129456)
--- trunk/Source/_javascript_Core/ChangeLog 2012-09-25 04:40:48 UTC (rev 129455)
+++ trunk/Source/_javascript_Core/ChangeLog 2012-09-25 04:52:26 UTC (rev 129456)
@@ -1,3 +1,34 @@
+2012-09-24 Gavin Barraclough <[email protected]>
+
+ 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 <[email protected]>
Deleting the classic interpreter and cleaning up some build options.
Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp (129455 => 129456)
--- trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp 2012-09-25 04:40:48 UTC (rev 129455)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp 2012-09-25 04:52:26 UTC (rev 129456)
@@ -373,7 +373,7 @@
// 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;
}
Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp (129455 => 129456)
--- trunk/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp 2012-09-25 04:40:48 UTC (rev 129455)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp 2012-09-25 04:52:26 UTC (rev 129456)
@@ -498,8 +498,8 @@
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 @@
}
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)
Modified: trunk/Source/_javascript_Core/runtime/JSObject.cpp (129455 => 129456)
--- trunk/Source/_javascript_Core/runtime/JSObject.cpp 2012-09-25 04:40:48 UTC (rev 129455)
+++ trunk/Source/_javascript_Core/runtime/JSObject.cpp 2012-09-25 04:52:26 UTC (rev 129456)
@@ -601,7 +601,7 @@
bool JSObject::allowsAccessFrom(ExecState* exec)
{
- JSGlobalObject* globalObject = unwrappedGlobalObject();
+ JSGlobalObject* globalObject = this->globalObject();
return globalObject->globalObjectMethodTable()->allowsAccessFrom(globalObject, exec);
}
@@ -924,13 +924,6 @@
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 @@
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 @@
Structure* JSObject::createInheritorID(JSGlobalData& globalData)
{
- Structure* inheritorID = createEmptyObjectStructure(globalData, unwrappedGlobalObject(), this);
+ Structure* inheritorID = createEmptyObjectStructure(globalData, globalObject(), this);
ASSERT(inheritorID->isEmpty());
PutPropertySlot slot;
Modified: trunk/Source/_javascript_Core/runtime/JSObject.h (129455 => 129456)
--- trunk/Source/_javascript_Core/runtime/JSObject.h 2012-09-25 04:40:48 UTC (rev 129455)
+++ trunk/Source/_javascript_Core/runtime/JSObject.h 2012-09-25 04:52:26 UTC (rev 129456)
@@ -343,7 +343,6 @@
// 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 @@
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:
Modified: trunk/Source/WebCore/ChangeLog (129455 => 129456)
--- trunk/Source/WebCore/ChangeLog 2012-09-25 04:40:48 UTC (rev 129455)
+++ trunk/Source/WebCore/ChangeLog 2012-09-25 04:52:26 UTC (rev 129456)
@@ -1,3 +1,17 @@
+2012-09-24 Gavin Barraclough <[email protected]>
+
+ 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 <[email protected]>
[Forms] We should remove DateTimeEditElement::valueAsDouble()
Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowShell.h (129455 => 129456)
--- trunk/Source/WebCore/bindings/js/JSDOMWindowShell.h 2012-09-25 04:40:48 UTC (rev 129455)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowShell.h 2012-09-25 04:52:26 UTC (rev 129456)
@@ -48,6 +48,7 @@
{
ASSERT_ARG(window, window);
setUnwrappedObject(globalData, window);
+ structure()->setGlobalObject(*JSDOMWindow::commonJSGlobalData(), window);
}
void setWindow(PassRefPtr<DOMWindow>);