Changeset 31072 in webkit for trunk/JavaScriptCore/kjs/nodes.cpp


Ignore:
Timestamp:
Mar 14, 2008, 6:05:55 PM (17 years ago)
Author:
[email protected]
Message:

Add logic to track whether a function uses a locally scoped eval or requires a closure

Reviewed by Maciej

Now that we limit eval we can track those uses of eval that operate
in the local scope and functions that require a closure. We track
this information during initial parsing to avoid yet another tree
walk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/nodes.cpp

    r30871 r31072  
    4747class FunctionBodyNodeWithDebuggerHooks : public FunctionBodyNode {
    4848public:
    49     FunctionBodyNodeWithDebuggerHooks(SourceElements*, VarStack*, FunctionStack*) KJS_FAST_CALL;
     49    FunctionBodyNodeWithDebuggerHooks(SourceElements*, VarStack*, FunctionStack*, bool usesEval, bool needsClosure) KJS_FAST_CALL;
    5050    virtual JSValue* execute(ExecState*) KJS_FAST_CALL;
    5151};
     
    43464346// ------------------------------ FunctionBodyNode -----------------------------
    43474347
    4348 ScopeNode::ScopeNode(SourceElements* children, VarStack* varStack, FunctionStack* funcStack)
     4348ScopeNode::ScopeNode(SourceElements* children, VarStack* varStack, FunctionStack* funcStack, bool usesEval, bool needsClosure)
    43494349    : BlockNode(children)
    43504350    , m_sourceURL(parser().sourceURL())
    43514351    , m_sourceId(parser().sourceId())
     4352    , m_usesEval(usesEval)
     4353    , m_needsClosure(needsClosure)
    43524354{
    43534355    if (varStack)
     
    43594361// ------------------------------ ProgramNode -----------------------------
    43604362
    4361 ProgramNode::ProgramNode(SourceElements* children, VarStack* varStack, FunctionStack* funcStack)
    4362     : ScopeNode(children, varStack, funcStack)
    4363 {
    4364 }
    4365 
    4366 ProgramNode* ProgramNode::create(SourceElements* children, VarStack* varStack, FunctionStack* funcStack)
    4367 {
    4368     return new ProgramNode(children, varStack, funcStack);
     4363ProgramNode::ProgramNode(SourceElements* children, VarStack* varStack, FunctionStack* funcStack, bool usesEval, bool needsClosure)
     4364    : ScopeNode(children, varStack, funcStack, usesEval, needsClosure)
     4365{
     4366}
     4367
     4368ProgramNode* ProgramNode::create(SourceElements* children, VarStack* varStack, FunctionStack* funcStack, bool usesEval, bool needsClosure)
     4369{
     4370    return new ProgramNode(children, varStack, funcStack, usesEval, needsClosure);
    43694371}
    43704372
    43714373// ------------------------------ EvalNode -----------------------------
    43724374
    4373 EvalNode::EvalNode(SourceElements* children, VarStack* varStack, FunctionStack* funcStack)
    4374     : ScopeNode(children, varStack, funcStack)
    4375 {
    4376 }
    4377 
    4378 EvalNode* EvalNode::create(SourceElements* children, VarStack* varStack, FunctionStack* funcStack)
    4379 {
    4380     return new EvalNode(children, varStack, funcStack);
     4375EvalNode::EvalNode(SourceElements* children, VarStack* varStack, FunctionStack* funcStack, bool usesEval, bool needsClosure)
     4376    : ScopeNode(children, varStack, funcStack, usesEval, needsClosure)
     4377{
     4378}
     4379
     4380EvalNode* EvalNode::create(SourceElements* children, VarStack* varStack, FunctionStack* funcStack, bool usesEval, bool needsClosure)
     4381{
     4382    return new EvalNode(children, varStack, funcStack, usesEval, needsClosure);
    43814383}
    43824384
    43834385// ------------------------------ FunctionBodyNode -----------------------------
    43844386
    4385 FunctionBodyNode::FunctionBodyNode(SourceElements* children, VarStack* varStack, FunctionStack* funcStack)
    4386     : ScopeNode(children, varStack, funcStack)
     4387FunctionBodyNode::FunctionBodyNode(SourceElements* children, VarStack* varStack, FunctionStack* funcStack, bool usesEval, bool needsClosure)
     4388    : ScopeNode(children, varStack, funcStack, usesEval, needsClosure)
    43874389    , m_initialized(false)
    43884390{
    43894391}
    43904392
    4391 FunctionBodyNode* FunctionBodyNode::create(SourceElements* children, VarStack* varStack, FunctionStack* funcStack)
     4393FunctionBodyNode* FunctionBodyNode::create(SourceElements* children, VarStack* varStack, FunctionStack* funcStack, bool usesEval, bool needsClosure)
    43924394{
    43934395    if (Debugger::debuggersPresent)
    4394         return new FunctionBodyNodeWithDebuggerHooks(children, varStack, funcStack);
    4395     return new FunctionBodyNode(children, varStack, funcStack);
     4396        return new FunctionBodyNodeWithDebuggerHooks(children, varStack, funcStack, usesEval, needsClosure);
     4397    return new FunctionBodyNode(children, varStack, funcStack, usesEval, needsClosure);
    43964398}
    43974399
     
    46484650// ------------------------------ FunctionBodyNodeWithDebuggerHooks ---------------------------------
    46494651
    4650 FunctionBodyNodeWithDebuggerHooks::FunctionBodyNodeWithDebuggerHooks(SourceElements* children, DeclarationStacks::VarStack* varStack, DeclarationStacks::FunctionStack* funcStack)
    4651     : FunctionBodyNode(children, varStack, funcStack)
     4652FunctionBodyNodeWithDebuggerHooks::FunctionBodyNodeWithDebuggerHooks(SourceElements* children, DeclarationStacks::VarStack* varStack, DeclarationStacks::FunctionStack* funcStack, bool usesEval, bool needsClosure)
     4653    : FunctionBodyNode(children, varStack, funcStack, usesEval, needsClosure)
    46524654{
    46534655}
Note: See TracChangeset for help on using the changeset viewer.