Ignore:
Timestamp:
Oct 31, 2008, 12:59:08 PM (17 years ago)
Author:
[email protected]
Message:

2008-10-30 Geoffrey Garen <[email protected]>

Reviewed by Oliver Hunt.


Fixed a small bit of https://bugs.webkit.org/show_bug.cgi?id=21962
AST uses way too much memory


Removed a word from StatementNode by nixing LabelStack and turning it
into a compile-time data structure managed by CodeGenerator.


v8 tests and SunSpider, run by Gavin, report no change.


  • VM/CodeGenerator.cpp: (JSC::CodeGenerator::CodeGenerator): (JSC::CodeGenerator::newLabelScope): (JSC::CodeGenerator::breakTarget): (JSC::CodeGenerator::continueTarget):
  • VM/CodeGenerator.h: Nixed the JumpContext system because it depended on a LabelStack in the AST, and it was a little cumbersome on the client side. Replaced with LabelScope, which tracks all break / continue information in the CodeGenerator, just like we track LabelIDs and other stacks of compile-time data.
  • kjs/LabelScope.h: Added. (JSC::LabelScope::): (JSC::LabelScope::LabelScope): (JSC::LabelScope::ref): (JSC::LabelScope::deref): (JSC::LabelScope::refCount): (JSC::LabelScope::breakTarget): (JSC::LabelScope::continueTarget): (JSC::LabelScope::type): (JSC::LabelScope::name): (JSC::LabelScope::scopeDepth): Simple abstraction for holding everything you might want to know about a break-able / continue-able scope.
  • kjs/LabelStack.cpp: Removed.
  • kjs/LabelStack.h: Removed.
  • kjs/grammar.y: No need to push labels at parse time -- we don't store LabelStacks in the AST anymore.
  • kjs/nodes.cpp: (JSC::DoWhileNode::emitCode): (JSC::WhileNode::emitCode): (JSC::ForNode::emitCode): (JSC::ForInNode::emitCode): (JSC::ContinueNode::emitCode): (JSC::BreakNode::emitCode): (JSC::SwitchNode::emitCode): (JSC::LabelNode::emitCode):
  • kjs/nodes.h: (JSC::StatementNode::): (JSC::LabelNode::): Use LabelScope where we used to use JumpContext. Simplified a bunch of code. Touched up label-related error messages a bit.
  • kjs/nodes2string.cpp: (JSC::LabelNode::streamTo): Updated for rename.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/VM/CodeGenerator.h

    r38027 r38047  
    3535#include "Instruction.h"
    3636#include "LabelID.h"
     37#include "LabelScope.h"
    3738#include "Machine.h"
    3839#include "RegisterID.h"
     
    4950    class ScopeChain;
    5051    class ScopeNode;
    51 
    52     // JumpContexts are used to track entry and exit points for javascript loops and switch statements
    53     struct JumpContext {
    54         LabelStack* labels;
    55         LabelID* continueTarget;
    56         LabelID* breakTarget;
    57         int scopeDepth;
    58         bool isValidUnlabeledBreakTarget;
    59     };
    6052
    6153    struct FinallyContext {
     
    158150        }
    159151
     152        PassRefPtr<LabelScope> newLabelScope(LabelScope::Type, const Identifier* = 0);
    160153        PassRefPtr<LabelID> newLabel();
    161154
     
    310303        void pushFinallyContext(LabelID* target, RegisterID* returnAddrDst);
    311304        void popFinallyContext();
    312         bool inContinueContext() { return m_continueDepth > 0; };
    313         bool inJumpContext() { return m_jumpContextStack.size() > 0; };
    314         void pushJumpContext(LabelStack*, LabelID* continueTarget, LabelID* breakTarget, bool isValidUnlabeledBreakTarget);
    315         void popJumpContext();
    316         JumpContext* jumpContextForContinue(const Identifier&);
    317         JumpContext* jumpContextForBreak(const Identifier&);
     305
     306        LabelScope* breakTarget(const Identifier&);
     307        LabelScope* continueTarget(const Identifier&);
    318308
    319309        void beginSwitch(RegisterID*, SwitchInfo::SwitchType);
     
    426416        SegmentedVector<RegisterID, 512> m_parameters;
    427417        SegmentedVector<RegisterID, 512> m_globals;
    428         SegmentedVector<LabelID, 512> m_labels;
     418        SegmentedVector<LabelScope, 256> m_labelScopes;
     419        SegmentedVector<LabelID, 256> m_labels;
    429420        RefPtr<RegisterID> m_lastConstant;
    430421        int m_finallyDepth;
     
    432423        CodeType m_codeType;
    433424
    434         Vector<JumpContext> m_jumpContextStack;
    435         int m_continueDepth;
    436425        Vector<ControlFlowContext> m_scopeContextStack;
    437426        Vector<SwitchInfo> m_switchContextStack;
Note: See TracChangeset for help on using the changeset viewer.