Changeset 33483 in webkit


Ignore:
Timestamp:
May 15, 2008 2:31:48 AM (16 years ago)
Author:
oliver@apple.com
Message:

Bug 18626: SQUIRRELFISH: support the "slow script" dialog
<https://bugs.webkit.org/show_bug.cgi?id=18626>

Reviewed by Maciej

Support the slow script dialog for for(;;), while, and do..while
loops.

Location:
branches/squirrelfish/JavaScriptCore
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • branches/squirrelfish/JavaScriptCore/ChangeLog

    r33481 r33483  
     12008-05-15  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Maciej.
     4
     5        Bug 18626: SQUIRRELFISH: support the "slow script" dialog
     6        <https://bugs.webkit.org/show_bug.cgi?id=18626>
     7
     8        Support the slow script dialog for for(;;), while, and do..while
     9        loops.
     10
     11        * VM/CodeBlock.cpp:
     12        (KJS::CodeBlock::dump):
     13        * VM/CodeGenerator.cpp:
     14        (KJS::CodeGenerator::emitLoopIfTrue):
     15        * VM/CodeGenerator.h:
     16        * VM/ExceptionHelpers.cpp:
     17        (KJS::InterruptedExecutionError::isWatchdogException):
     18        (KJS::createInterruptedExecutionException):
     19        * VM/ExceptionHelpers.h:
     20        * VM/Machine.cpp:
     21        (KJS::Machine::throwException):
     22        (KJS::Machine::privateExecute):
     23        * VM/Opcode.h:
     24        * kjs/interpreter.cpp:
     25        (KJS::Interpreter::evaluate):
     26        * kjs/nodes.cpp:
     27        (KJS::DoWhileNode::emitCode):
     28        (KJS::WhileNode::emitCode):
     29        (KJS::ForNode::emitCode):
     30        * kjs/object.h:
     31
    1322008-05-15  Geoffrey Garen  <ggaren@apple.com>
    233
  • branches/squirrelfish/JavaScriptCore/VM/CodeBlock.cpp

    r33480 r33483  
    427427            break;
    428428        }
     429        case op_loop_if_true: {
     430            printConditionalJump(begin, it, location, "loop_if_true");
     431            break;
     432        }
    429433        case op_jfalse: {
    430434            printConditionalJump(begin, it, location, "jfalse");
  • branches/squirrelfish/JavaScriptCore/VM/CodeGenerator.cpp

    r33480 r33483  
    378378}
    379379
     380PassRefPtr<LabelID> CodeGenerator::emitLoopIfTrue(RegisterID* cond, LabelID* target)
     381{
     382    instructions().append(machine().getOpcode(op_loop_if_true));
     383    instructions().append(cond->index());
     384    instructions().append(target->offsetFrom(instructions().size()));
     385    return target;
     386}
     387
    380388PassRefPtr<LabelID> CodeGenerator::emitJumpIfTrue(RegisterID* cond, LabelID* target)
    381389{
  • branches/squirrelfish/JavaScriptCore/VM/CodeGenerator.h

    r33480 r33483  
    221221        PassRefPtr<LabelID> emitLabel(LabelID*);
    222222        PassRefPtr<LabelID> emitJump(LabelID* target);
     223        PassRefPtr<LabelID> emitLoopIfTrue(RegisterID* cond, LabelID* target);
    223224        PassRefPtr<LabelID> emitJumpIfTrue(RegisterID* cond, LabelID* target);
    224225        PassRefPtr<LabelID> emitJumpIfFalse(RegisterID* cond, LabelID* target);
  • branches/squirrelfish/JavaScriptCore/VM/ExceptionHelpers.cpp

    r33295 r33483  
    7474}
    7575
     76class InterruptedExecutionError : public JSObject {
     77public:
     78    virtual bool isWatchdogException() const { return true; }
     79};
     80
     81JSValue* createInterruptedExecutionException(ExecState*)
     82{
     83    return new InterruptedExecutionError;
     84}
     85
    7686JSValue* createUndefinedVariableError(ExecState* exec, const Identifier& ident)
    7787{
  • branches/squirrelfish/JavaScriptCore/VM/ExceptionHelpers.h

    r33283 r33483  
    3939    JSValue* createNotAConstructorError(ExecState* exec, JSValue* value, Node* expr);
    4040    JSValue* createNotAFunctionError(ExecState* exec, JSValue* value, Node* expr);
     41    JSValue* createInterruptedExecutionException(ExecState* exec);
    4142}
    4243
  • branches/squirrelfish/JavaScriptCore/VM/Machine.cpp

    r33481 r33483  
    560560            exception->put(exec, "sourceURL", jsOwnedString(codeBlock->ownerNode->sourceURL()));
    561561        }
     562        if (exception->isWatchdogException())
     563            return 0;
    562564    }
    563565
     
    793795    Instruction* vPC = codeBlock->instructions.begin();
    794796    JSValue** k = codeBlock->jsValues.data();
    795    
     797
    796798    registerFile->setSafeForReentry(false);
    797799#define VM_CHECK_EXCEPTION() \
     
    16521654        NEXT_OPCODE;
    16531655    }
     1656    BEGIN_OPCODE(op_loop_if_true) {
     1657        /* loop_if_true cond(r) target(offset)
     1658
     1659          Does a JS timeout check, and immediately terminates execution and sets
     1660          an uncatchable exception on the ExecState.
     1661
     1662          Assuming the watchdog test indicates it is safe, this jumps to offset
     1663          target from the current instruction, if and only if register cond
     1664          converts to boolean as true.
     1665         */
     1666
     1667        if (UNLIKELY(exec->dynamicGlobalObject()->timedOut())) {
     1668            exceptionValue = createInterruptedExecutionException(exec);
     1669            goto vm_throw;
     1670        }
     1671
     1672        int cond = (++vPC)->u.operand;
     1673        int target = (++vPC)->u.operand;
     1674        if (r[cond].u.jsValue->toBoolean(exec)) {
     1675            vPC += target;
     1676            NEXT_OPCODE;
     1677        }
     1678       
     1679        ++vPC;
     1680        NEXT_OPCODE;
     1681    }
    16541682    BEGIN_OPCODE(op_jfalse) {
    16551683        /* jfalse cond(r) target(offset)
  • branches/squirrelfish/JavaScriptCore/VM/Opcode.h

    r33480 r33483  
    9191        \
    9292        macro(op_jmp) \
     93        macro(op_loop_if_true) \
    9394        macro(op_jtrue) \
    9495        macro(op_jfalse) \
  • branches/squirrelfish/JavaScriptCore/kjs/interpreter.cpp

    r33386 r33483  
    8989#endif
    9090
    91     return exception ? Completion(Throw, exception) : Completion(Normal, result);
     91    if (exception) {
     92        if (exception->isObject() && static_cast<JSObject*>(exception)->isWatchdogException())
     93            return Completion(Interrupted, result);
     94        return Completion(Throw, exception);
     95    }
     96    return Completion(Normal, result);
    9297}
    9398
  • branches/squirrelfish/JavaScriptCore/kjs/nodes.cpp

    r33480 r33483  
    48964896    generator.emitLabel(continueTarget.get());
    48974897    RegisterID* cond = generator.emitNode(m_expr.get());
    4898     generator.emitJumpIfTrue(cond, topOfLoop.get());
     4898    generator.emitLoopIfTrue(cond, topOfLoop.get());
    48994899    generator.emitLabel(breakTarget.get());
    49004900    return result.get();
     
    49584958    generator.emitLabel(continueTarget.get());
    49594959    RegisterID* cond = generator.emitNode(m_expr.get());
    4960     generator.emitJumpIfTrue(cond, topOfLoop.get());
     4960    generator.emitLoopIfTrue(cond, topOfLoop.get());
    49614961
    49624962    generator.emitLabel(breakTarget.get());
     
    50265026    generator.emitLabel(beforeCondition.get());
    50275027    RegisterID* cond = generator.emitNode(m_expr2.get());
    5028     generator.emitJumpIfTrue(cond, topOfLoop.get());
     5028    generator.emitLoopIfTrue(cond, topOfLoop.get());
    50295029    generator.emitLabel(breakTarget.get());
    50305030    return result.get();
  • branches/squirrelfish/JavaScriptCore/kjs/object.h

    r33421 r33483  
    432432    virtual bool isVariableObject() const { return false; }
    433433
     434    virtual bool isWatchdogException() const { return false; }
    434435  protected:
    435436    PropertyMap _prop;
Note: See TracChangeset for help on using the changeset viewer.