Ignore:
Timestamp:
Jul 1, 2008, 10:39:23 PM (17 years ago)
Author:
[email protected]
Message:

2008-07-01 Geoffrey Garen <[email protected]>

Reviewed by Oliver Hunt.


Removed and/or reordered exception checks in array-style a[n] access.


SunSpider says 1.4% faster.

  • VM/Machine.cpp: (KJS::Machine::privateExecute): No need to check for exceptions before calling toString, toNumber and/or get. If the call ends up being observable through toString, valueOf, or a getter, we short-circuit it there, instead. In the op_del_by_val case, I removed the incorrect comment without actually removing the code, since I didn't want to tempt the GCC fates!
  • kjs/JSObject.cpp: (KJS::callDefaultValueFunction): Added exception check to prevent toString and valueOf functions from observing execution after an exception has been thrown. This removes some of the burden of exception checking from the machine.

(KJS::JSObject::defaultValue): Removed redundant exception check here.

  • kjs/PropertySlot.cpp: (KJS::PropertySlot::functionGetter): Added exception check to prevent getter functions from observing execution after an exception has been thrown. This removes some of the burden of exception checking from the machine.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/JSObject.cpp

    r34878 r34945  
    227227    CallType callType = function->getCallData(callData);
    228228    if (callType == CallTypeNone)
    229         return 0;
     229        return exec->exception();
     230
     231    // Prevent "toString" and "valueOf" from observing execution if an exception
     232    // is pending.
     233    if (exec->hadException())
     234        return exec->exception();
     235
    230236    JSValue* result = call(exec, function, callType, callData, const_cast<JSObject*>(object), exec->emptyList());
    231237    ASSERT(result->type() != GetterSetterType);
     
    247253JSValue* JSObject::defaultValue(ExecState* exec, JSType hint) const
    248254{
    249     // We need this check to guard against the case where this object is rhs of
    250     // a binary expression where lhs threw an exception in its conversion to
    251     // primitive.
    252     if (exec->hadException())
    253         return exec->exception();
    254 
    255255    // Must call toString first for Date objects.
    256256    if ((hint == StringType) || (hint != NumberType && _proto == exec->lexicalGlobalObject()->datePrototype())) {
Note: See TracChangeset for help on using the changeset viewer.