Changeset 33319

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

Bug 18827: SquirrelFish: Prevent getters and setters from destroying the current RegisterFile
<https://bugs.webkit.org/show_bug.cgi?id=18827>

Reviewed by Maciej

This patch makes getters and setters work. It does this by
tracking whether the RegisterFile is "safe", that is whether
the interpreter is in a state that in which it can handle
the RegisterFile being reallocated.

Location:
branches/squirrelfish/JavaScriptCore
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • branches/squirrelfish/JavaScriptCore/ChangeLog

    r33318 r33319  
     12008-05-01  Oliver Hunt  <oliver@apple.com> 
     2 
     3        Reviewed by Maciej. 
     4 
     5        Bug 18827: SquirrelFish: Prevent getters and setters from destroying the current RegisterFile 
     6        <https://bugs.webkit.org/show_bug.cgi?id=18827> 
     7         
     8        This patch makes getters and setters work.  It does this by 
     9        tracking whether the RegisterFile is "safe", that is whether 
     10        the interpreter is in a state that in which it can handle 
     11        the RegisterFile being reallocated. 
     12 
     13        * VM/Machine.cpp: 
     14        (KJS::resolve): 
     15        (KJS::Machine::privateExecute): 
     16        * VM/RegisterFile.h: 
     17        * kjs/function.cpp: 
     18        (KJS::FunctionImp::callAsFunction): 
     19 
    1202008-04-30  Geoffrey Garen  <ggaren@apple.com> 
    221 
  • branches/squirrelfish/JavaScriptCore/VM/Machine.cpp

    r33317 r33319  
    270270        if (o->getPropertySlot(exec, ident, slot)) { 
    271271            r[dst].u.jsValue = slot.getValue(exec, o, ident); 
    272             return true; 
     272            exceptionValue = exec->exception(); 
     273            return !exceptionValue; 
    273274        } 
    274275    } while (++iter != end); 
     
    717718    JSValue** k = codeBlock->jsValues.data(); 
    718719     
     720    registerFile->setUnsafeForReentry(true); 
    719721#define VM_CHECK_EXCEPTION() \ 
    720722     do { \ 
     
    14231425            JSObject* thisObject = r[thisRegister].u.jsObject; 
    14241426 
     1427            registerFile->setUnsafeForReentry(false); 
    14251428            JSValue* result = eval(exec, thisObject, scopeChain, registerFile, r, argv, argc, exceptionValue); 
     1429            registerFile->setUnsafeForReentry(true); 
    14261430            r = (*registerBase) + registerOffset; 
    14271431 
     
    14941498            List args(&r[argv + 1].u.jsValue, argc - 1); 
    14951499 
     1500            registerFile->setUnsafeForReentry(false); 
    14961501            JSValue* returnValue = static_cast<JSObject*>(v)->callAsFunction(exec, thisObj, args); 
     1502            registerFile->setUnsafeForReentry(true); 
    14971503 
    14981504            r = (*registerBase) + registerOffset; 
     
    15961602 
    15971603            List args(&r[argv + 1].u.jsValue, argc - 1); 
     1604            registerFile->setUnsafeForReentry(false); 
    15981605            JSValue* returnValue = constructor->construct(exec, args); 
     1606            registerFile->setUnsafeForReentry(true); 
    15991607         
    16001608            r = (*registerBase) + registerOffset; 
     
    17411749    } 
    17421750    vm_throw: { 
     1751        exec->clearException(); 
    17431752        handlerVPC = throwException(exec, exceptionValue, registerBase, vPC, codeBlock, k, scopeChain, r); 
    17441753        if (!handlerVPC) { 
  • branches/squirrelfish/JavaScriptCore/VM/RegisterFile.h

    r33305 r33319  
    8989        enum { DefaultRegisterFileSize = 2 * 1024 * 1024 }; 
    9090        RegisterFile(RegisterFileStack* stack, size_t maxSize) 
    91             : m_isForImplicitCall(false) 
     91            : m_unsafeForReentry(false) 
     92            , m_isForImplicitCall(false) 
    9293            , m_size(0) 
    9394            , m_capacity(0) 
     
    150151            Collector::markStackObjectsConservatively(m_buffer, m_base + m_size); 
    151152        } 
    152          
     153        bool unsafeForReentry() { return m_unsafeForReentry; } 
     154        void setUnsafeForReentry(bool unsafeForReentry) { m_unsafeForReentry = unsafeForReentry; } 
    153155        void setIsForImplicitCall(bool isForImplicitCall) { m_isForImplicitCall = isForImplicitCall; } 
    154156        bool isForImplicitCall() { return m_isForImplicitCall; } 
     
    165167         
    166168        void setBase(Register*); 
    167          
     169        bool m_unsafeForReentry; 
    168170        bool m_isForImplicitCall; 
    169171        size_t m_size; 
  • branches/squirrelfish/JavaScriptCore/kjs/function.cpp

    r33314 r33319  
    8484{ 
    8585    JSValue* exception = 0; 
    86     JSValue* result = machine().execute(body.get(), exec, this, thisObj, args, &exec->dynamicGlobalObject()->registerFileStack(), _scope.node(), &exception); 
    87     exec->setException(exception); 
    88     return result; 
     86    RegisterFileStack* stack = &exec->dynamicGlobalObject()->registerFileStack(); 
     87    RegisterFile* current = stack->current(); 
     88    if (current->unsafeForReentry()) { 
     89        stack->pushFunctionRegisterFile(); 
     90        JSValue* result = machine().execute(body.get(), exec, this, thisObj, args, stack, _scope.node(), &exception); 
     91        stack->popFunctionRegisterFile(); 
     92        exec->setException(exception); 
     93        return result; 
     94    } else { 
     95        JSValue* result = machine().execute(body.get(), exec, this, thisObj, args, stack, _scope.node(), &exception); 
     96        current->setUnsafeForReentry(false); 
     97        exec->setException(exception); 
     98        return result; 
     99    } 
    89100} 
    90101