Changeset 35533 in webkit for trunk/JavaScriptCore/VM/Machine.cpp


Ignore:
Timestamp:
Aug 3, 2008, 2:58:21 AM (17 years ago)
Author:
[email protected]
Message:

Bug 19359: JavaScriptCore behaves differently from FF2/3 and IE when handling context in catch statement
<https://bugs.webkit.org/show_bug.cgi?id=19359>

Reviewed by Cameron Zwarich

Make our catch behave like Firefox and IE, we do this by using a StaticScopeObject
instead of a generic JSObject for the scope node. We still don't make use of the
fact that we have a static scope inside the catch block, so the internal performance
of the catch block is not improved, even though technically it would be possible to
do so.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/VM/Machine.cpp

    r35454 r35533  
    4141#include "JSNotAnObject.h"
    4242#include "JSPropertyNameIterator.h"
     43#include "JSStaticScopeObject.h"
    4344#include "JSString.h"
    4445#include "ObjectPrototype.h"
     
    9991000}
    10001001
     1002static NEVER_INLINE ScopeChainNode* createExceptionScope(ExecState* exec, CodeBlock* codeBlock, const Instruction* vPC, Register* r, ScopeChainNode* scopeChain)
     1003{
     1004    int dst = (++vPC)->u.operand;
     1005    Identifier& property = codeBlock->identifiers[(++vPC)->u.operand];
     1006    JSValue* value = r[(++vPC)->u.operand].jsValue(exec);
     1007    JSObject* scope = new (exec) JSStaticScopeObject(property, value, DontDelete);
     1008    r[dst] = scope;
     1009    return scopeChain->push(scope);
     1010}
     1011
    10011012JSValue* Machine::privateExecute(ExecutionFlag flag, ExecState* exec, RegisterFile* registerFile, Register* r, ScopeChainNode* scopeChain, CodeBlock* codeBlock, JSValue** exception)
    10021013{
     
    26032614        NEXT_OPCODE;
    26042615    }
     2616#if HAVE(COMPUTED_GOTO)
     2617    // Appease GCC
     2618    goto *(&&skip_new_scope);
     2619#endif
     2620    BEGIN_OPCODE(op_push_new_scope) {
     2621        /* new_scope dst(r) property(id) value(r)
     2622         
     2623           Constructs a new StaticScopeObject with property set to value.  That scope
     2624           object is then pushed onto the ScopeChain.  The scope object is then stored
     2625           in dst for GC.
     2626         */
     2627        setScopeChain(exec, scopeChain, createExceptionScope(exec, codeBlock, vPC, r, scopeChain));
     2628        vPC += 4;
     2629        NEXT_OPCODE;
     2630    }
     2631#if HAVE(COMPUTED_GOTO)
     2632    skip_new_scope:
     2633#endif
    26052634    BEGIN_OPCODE(op_catch) {
    26062635        /* catch ex(r)
Note: See TracChangeset for help on using the changeset viewer.