Reviewed by Darin.
Bug 19346: REGRESSION: Mootools 1.2 Class inheritance broken in post-SquirrelFish merge
<https://bugs.webkit.org/show_bug.cgi?id=19346>
A check for whether a function's caller is eval code accidentally included
the case where the caller's caller is native code. Add a CodeType field to
CodeBlock and use this for the eval caller test instead.
JavaScriptCore:
* VM/CodeBlock.h:
(KJS::CodeBlock::CodeBlock):
(KJS::ProgramCodeBlock::ProgramCodeBlock):
(KJS::EvalCodeBlock::EvalCodeBlock):
* VM/Machine.cpp:
(KJS::getCallerFunctionOffset):
* kjs/nodes.cpp:
(KJS::FunctionBodyNode::generateCode):
(KJS::ProgramNode::generateCode):
LayoutTests:
* fast/js/function-dot-arguments-and-caller-expected.txt:
* fast/js/function-dot-arguments-and-caller.html:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@34457
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2008-06-08 Cameron Zwarich <cwzwarich@uwaterloo.ca>
+
+ Reviewed by Darin.
+
+ Bug 19346: REGRESSION: Mootools 1.2 Class inheritance broken in post-SquirrelFish merge
+ <https://bugs.webkit.org/show_bug.cgi?id=19346>
+
+ A check for whether a function's caller is eval code accidentally included
+ the case where the caller's caller is native code. Add a CodeType field to
+ CodeBlock and use this for the eval caller test instead.
+
+ * VM/CodeBlock.h:
+ (KJS::CodeBlock::CodeBlock):
+ (KJS::ProgramCodeBlock::ProgramCodeBlock):
+ (KJS::EvalCodeBlock::EvalCodeBlock):
+ * VM/Machine.cpp:
+ (KJS::getCallerFunctionOffset):
+ * kjs/nodes.cpp:
+ (KJS::FunctionBodyNode::generateCode):
+ (KJS::ProgramNode::generateCode):
+
2008-06-07 Cameron Zwarich <cwzwarich@uwaterloo.ca>
Reviewed by Dan Bernstein.
};
struct CodeBlock {
- CodeBlock(ScopeNode* ownerNode_)
+ CodeBlock(ScopeNode* ownerNode_, CodeType codeType_)
: ownerNode(ownerNode_)
, numTemporaries(0)
, numVars(0)
, numLocals(0)
, needsFullScopeChain(ownerNode_->usesEval() || ownerNode_->needsClosure())
, usesEval(ownerNode_->usesEval())
+ , codeType(codeType_)
{
}
int thisRegister;
bool needsFullScopeChain;
bool usesEval;
+ CodeType codeType;
Vector<Instruction> instructions;
// responsible for marking it.
struct ProgramCodeBlock : public CodeBlock {
- ProgramCodeBlock(ScopeNode* ownerNode, JSGlobalObject* globalObject_)
- : CodeBlock(ownerNode)
+ ProgramCodeBlock(ScopeNode* ownerNode_, CodeType codeType_, JSGlobalObject* globalObject_)
+ : CodeBlock(ownerNode_, codeType_)
, globalObject(globalObject_)
{
globalObject->codeBlocks().add(this);
};
struct EvalCodeBlock : public ProgramCodeBlock {
- EvalCodeBlock(ScopeNode* ownerNode, JSGlobalObject* globalObject_)
- : ProgramCodeBlock(ownerNode, globalObject_)
+ EvalCodeBlock(ScopeNode* ownerNode_, JSGlobalObject* globalObject_)
+ : ProgramCodeBlock(ownerNode_, EvalCode, globalObject_)
{
}
};
CodeBlock* callerCodeBlock = callFrame[Machine::CallerCodeBlock].u.codeBlock;
if (!callerCodeBlock) // test for top frame of re-entrant function call
return false;
-
+
+ if (callerCodeBlock->codeType == EvalCode)
+ return false;
+
callerOffset = callFrame[Machine::CallerRegisterOffset].u.i - callerCodeBlock->numLocals - Machine::CallFrameHeaderSize;
if (callerOffset < 0) // test for global frame
return false;
- Register* callerCallFrame = (*registerBase) + callerOffset;
- if (!callerCallFrame[Machine::CallerCodeBlock].u.codeBlock) // test for eval frame
- return false;
-
return true;
}
ScopeChain scopeChain(sc);
JSGlobalObject* globalObject = scopeChain.globalObject();
- m_code.set(new CodeBlock(this));
+ m_code.set(new CodeBlock(this, FunctionCode));
CodeGenerator generator(this, globalObject->debugger(), scopeChain, &m_symbolTable, m_code.get());
generator.generate();
ScopeChain scopeChain(sc);
JSGlobalObject* globalObject = scopeChain.globalObject();
- m_code.set(new ProgramCodeBlock(this, globalObject));
+ m_code.set(new ProgramCodeBlock(this, GlobalCode, globalObject));
CodeGenerator generator(this, globalObject->debugger(), scopeChain, &globalObject->symbolTable(), m_code.get(), m_varStack, m_functionStack, canCreateGlobals);
generator.generate();
+2008-06-08 Cameron Zwarich <cwzwarich@uwaterloo.ca>
+
+ Reviewed by Darin.
+
+ Test for:
+
+ Bug 19346: REGRESSION: Mootools 1.2 Class inheritance broken in post-SquirrelFish merge
+ <https://bugs.webkit.org/show_bug.cgi?id=19346>
+
+ * fast/js/function-dot-arguments-and-caller-expected.txt:
+ * fast/js/function-dot-arguments-and-caller.html:
+
2008-06-08 Vincent Ricard <magic@magicninja.org>
Reviewed by Darin.
If the test passes, you'll see a series of PASS messages below.
-PASS,PASS,PASS,PASS,PASS,PASS,PASS,PASS,PASS,PASS,PASS,PASS,PASS,PASS,PASS,PASS
+PASS,PASS,PASS,PASS,PASS,PASS,PASS,PASS,PASS,PASS,PASS,PASS,PASS,PASS,PASS,PASS,PASS
(function f() {
return String({ toString: function g() { return g.caller instanceof Object ? "FAIL" : "PASS"; } });
+})(),
+
+(function f() {
+ function g() { return h.apply(this); }
+ function h() { return k(); }
+ function k() { return k.caller instanceof Object ? "PASS" : "FAIL"; }
+
+ return g();
})()
];