Changeset 33293

Show
Ignore:
Timestamp:
05/12/08 23:01:54 (6 months ago)
Author:
mrowe@apple.com
Message:

Bug 18736: SQUIRRELFISH: switch statements with no default have incorrect codegen
<https://bugs.webkit.org/show_bug.cgi?id=18736>

Reviewed by Geoff

Put a limit on the level of reentry recursion. 128 levels of re-entrant recursion
seems reasonable as it is greater than the old eval limit, and a long way short of
the reentry depth needed to overflow the stack.

Location:
branches/squirrelfish/JavaScriptCore
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • branches/squirrelfish/JavaScriptCore/ChangeLog

    r33292 r33293  
     12008-04-25  Oliver Hunt  <oliver@apple.com> 
     2 
     3        Reviewed by Geoff. 
     4 
     5        Bug 18736: SQUIRRELFISH: switch statements with no default have incorrect codegen 
     6        <https://bugs.webkit.org/show_bug.cgi?id=18736> 
     7 
     8        Put a limit on the level of reentry recursion.  128 levels of re-entrant recursion 
     9        seems reasonable as it is greater than the old eval limit, and a long way short of 
     10        the reentry depth needed to overflow the stack. 
     11 
     12        * VM/Machine.cpp: 
     13        (KJS::Machine::execute): 
     14        * VM/Machine.h: 
     15 
    1162008-04-25  Geoffrey Garen  <ggaren@apple.com> 
    217 
  • branches/squirrelfish/JavaScriptCore/VM/Machine.cpp

    r33292 r33293  
    240240 
    241241Machine::Machine() 
     242    : m_reentryDepth(0) 
    242243{ 
    243244    privateExecute(InitializeAndReturn); 
     
    549550JSValue* Machine::execute(ProgramNode* programNode, ExecState* exec, JSObject* thisObj, RegisterFileStack* registerFileStack, ScopeChainNode* scopeChain, JSValue** exception) 
    550551{ 
     552    if (m_reentryDepth >= MaxReentryDepth) { 
     553        *exception = createStackOverflowError(exec); 
     554        return 0; 
     555    } 
     556 
    551557    RegisterFile* registerFile = registerFileStack->pushRegisterFile(); 
    552558    CodeBlock* codeBlock = &programNode->code(scopeChain); 
     
    561567    if (codeBlock->needsFullScopeChain) 
    562568        scopeChain = scopeChain->copy(); 
    563  
     569    m_reentryDepth++; 
    564570    JSValue* result = privateExecute(Normal, exec, registerFile, r, scopeChain, codeBlock, exception); 
    565  
     571    m_reentryDepth--; 
    566572    registerFileStack->popRegisterFile(); 
    567573    return result; 
     
    570576JSValue* Machine::execute(FunctionBodyNode* functionBodyNode, ExecState* exec, FunctionImp* function, JSObject* thisObj, const List& args, RegisterFileStack* registerFileStack, ScopeChainNode* scopeChain, JSValue** exception) 
    571577{ 
     578    if (m_reentryDepth >= MaxReentryDepth) { 
     579        *exception = createStackOverflowError(exec); 
     580        return 0; 
     581    } 
     582 
    572583    RegisterFile* registerFile = registerFileStack->current(); 
    573584 
     
    606617    callFrame = (*registerBase) + callFrameOffset; // registerBase may have moved, recompute callFrame 
    607618    scopeChain = scopeChainForCall(newCodeBlock, scopeChain, function, callFrame, registerBase, r);             
    608  
     619    m_reentryDepth++; 
    609620    JSValue* result = privateExecute(Normal, exec, registerFile, r, scopeChain, newCodeBlock, exception); 
     621    m_reentryDepth--; 
    610622    registerFile->shrink(oldSize); 
    611623    return result; 
     
    615627JSValue* Machine::execute(EvalNode* evalNode, ExecState* exec, JSObject* thisObj, RegisterFile* registerFile, int registerOffset, ScopeChainNode* scopeChain, JSValue** exception, JSObject* variableObject) 
    616628{ 
     629    if (m_reentryDepth >= MaxReentryDepth) { 
     630        *exception = createStackOverflowError(exec); 
     631        return 0; 
     632    } 
    617633    EvalCodeBlock* codeBlock = &evalNode->code(scopeChain); 
    618634     
     
    648664    if (codeBlock->needsFullScopeChain) 
    649665        scopeChain = scopeChain->copy(); 
    650  
     666    m_reentryDepth++; 
    651667    JSValue* result = privateExecute(Normal, exec, registerFile, r, scopeChain, codeBlock, exception); 
    652      
     668    m_reentryDepth--; 
    653669    registerFile->shrink(oldSize); 
    654670     
  • branches/squirrelfish/JavaScriptCore/VM/Machine.h

    r33277 r33293  
    8989         
    9090    private: 
     91        enum { MaxReentryDepth = 128 }; 
    9192        typedef enum { Normal, InitializeAndReturn } ExecutionFlag; 
    9293 
     
    101102        bool isGlobalCallFrame(Register** registerBase, const Register* r) { return (*registerBase) == r; } 
    102103 
     104        int m_reentryDepth; 
    103105#if HAVE(COMPUTED_GOTO)         
    104106        Opcode m_opcodeTable[numOpcodeIDs]; // Maps OpcodeID => Opcode for compiling