2008-05-21 Maciej Stachowiak <mjs@apple.com>
Reviewed by Oliver and Sam.
- fixed <rdar://problem/
5815631> REGRESSION (r31239): Multiscope optimisation of function calls results in incorrect this value (breaks tvtv.de)
Track global this value in the scope chain so we can retrieve it
efficiently but it follows lexical scope properly.
* kjs/ExecState.h:
(KJS::ExecState::globalThisValue):
* kjs/JSGlobalObject.h:
(KJS::JSGlobalObject::JSGlobalObjectData::JSGlobalObjectData):
* kjs/function_object.cpp:
(KJS::FunctionObjectImp::construct):
* kjs/scope_chain.h:
(KJS::ScopeChainNode::ScopeChainNode):
(KJS::ScopeChainNode::globalThisObject):
(KJS::ScopeChainNode::push):
(KJS::ScopeChain::ScopeChain):
LayoutTests:
2008-05-21 Maciej Stachowiak <mjs@apple.com>
Reviewed by Oliver and Sam.
- tests for <rdar://problem/
5815631> REGRESSION (r31239): Multiscope optimisation of function calls results in incorrect this value (breaks tvtv.de)
* fast/frames/cross-site-this-expected.txt: Added.
* fast/frames/cross-site-this.html: Added.
* fast/frames/resources/cross-site-this-helper.html: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@34007
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2008-05-21 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Oliver and Sam.
+
+ - fixed <rdar://problem/5815631> REGRESSION (r31239): Multiscope optimisation of function calls results in incorrect this value (breaks tvtv.de)
+
+ Track global this value in the scope chain so we can retrieve it
+ efficiently but it follows lexical scope properly.
+
+ * kjs/ExecState.h:
+ (KJS::ExecState::globalThisValue):
+ * kjs/JSGlobalObject.h:
+ (KJS::JSGlobalObject::JSGlobalObjectData::JSGlobalObjectData):
+ * kjs/function_object.cpp:
+ (KJS::FunctionObjectImp::construct):
+ * kjs/scope_chain.h:
+ (KJS::ScopeChainNode::ScopeChainNode):
+ (KJS::ScopeChainNode::globalThisObject):
+ (KJS::ScopeChainNode::push):
+ (KJS::ScopeChain::ScopeChain):
+
2008-05-21 Kevin McCullough <kmccullough@apple.com>
Sadness :(
return m_scopeChain->globalObject();
}
- JSObject* globalThisValue() const { return m_globalThisValue; }
+ JSObject* globalThisValue() const { return m_scopeChain->globalThisObject(); }
Machine* machine() const { return m_machine; }
struct JSGlobalObjectData : public JSVariableObjectData {
JSGlobalObjectData(JSGlobalObject* globalObject, JSObject* thisValue)
: JSVariableObjectData(&symbolTable, registerFileStack.globalBasePointer(), 0)
- , globalScopeChain(globalObject)
+ , globalScopeChain(globalObject, thisValue)
, globalExec(new ExecState(globalObject, thisValue, globalScopeChain.node()))
{
}
return throwError(exec, SyntaxError, errMsg, errLine, sourceId, sourceURL);
functionBody->setSource(SourceRange(source, 0, source->length()));
- ScopeChain scopeChain(exec->lexicalGlobalObject());
+ ScopeChain scopeChain(exec->lexicalGlobalObject(), exec->globalThisValue());
FunctionImp* fimp = new FunctionImp(exec, functionName, functionBody.get(), scopeChain.node());
class ScopeChainNode {
public:
- ScopeChainNode(ScopeChainNode* n, JSObject* o)
+ ScopeChainNode(ScopeChainNode* n, JSObject* o, JSObject* gt)
: next(n)
, object(o)
+ , globalThis(gt)
, refCount(1)
{
}
ScopeChainNode* next;
JSObject* object;
+ JSObject* globalThis;
int refCount;
void deref() { if (--refCount == 0) release(); }
ScopeChainIterator end() const;
JSGlobalObject* globalObject() const; // defined in JSGlobalObject.h
+ JSObject* globalThisObject() const { return globalThis; }
#ifndef NDEBUG
void print() const;
inline ScopeChainNode* ScopeChainNode::push(JSObject* o)
{
ASSERT(o);
- return new ScopeChainNode(this, o);
+ return new ScopeChainNode(this, o, globalThis);
}
inline ScopeChainNode* ScopeChainNode::pop()
class ScopeChain {
public:
- ScopeChain(JSObject* o)
- : _node(new ScopeChainNode(0, o))
+ ScopeChain(JSObject* o, JSObject* globalThis)
+ : _node(new ScopeChainNode(0, o, globalThis))
{
}
+2008-05-21 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Oliver and Sam.
+
+ - tests for <rdar://problem/5815631> REGRESSION (r31239): Multiscope optimisation of function calls results in incorrect this value (breaks tvtv.de)
+
+ * fast/frames/cross-site-this-expected.txt: Added.
+ * fast/frames/cross-site-this.html: Added.
+ * fast/frames/resources/cross-site-this-helper.html: Added.
+
2008-05-21 Adele Peterson <adele@apple.com>
Reviewed by Adam.