Changeset 33344

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

JavaScriptCore:

2008-05-05 Geoffrey Garen <ggaren@apple.com>

Reviewed by Maciej Stachowiak.

Fixed ecma_3/Object/8.6.2.6-001.js, and similar bugs.

SunSpider reports a .4% speedup. Not sure what that's about.

  • VM/Machine.cpp: (KJS::Machine::privateExecute): Check for exception return from equal, since toPrimitive can throw.
  • kjs/operations.cpp: (KJS::strictEqual): In response to an error I made in an earlier version of this patch, I changed strictEqual to make clear the fact that it performs no conversions and can't throw, making it slightly more efficient in the process.

LayoutTests:

2008-05-05 Geoffrey Garen <ggaren@apple.com>

Reviewed by Maciej Stachowiak.

Layout test for exceptions thrown from equality comparisons.

  • fast/js/exception-thrown-from-equal-expected.txt: Added.
  • fast/js/exception-thrown-from-equal.html: Added.
Location:
branches/squirrelfish
Files:
2 added
8 modified

Legend:

Unmodified
Added
Removed
  • branches/squirrelfish/JavaScriptCore/API/JSValueRef.cpp

    r33038 r33344  
    135135bool JSValueIsStrictEqual(JSContextRef ctx, JSValueRef a, JSValueRef b) 
    136136{ 
    137     JSLock lock; 
    138     ExecState* exec = toJS(ctx); 
     137    UNUSED_PARAM(ctx); 
     138 
     139    JSLock lock; 
    139140    JSValue* jsA = toJS(a); 
    140141    JSValue* jsB = toJS(b); 
    141142     
    142     bool result = strictEqual(exec, jsA, jsB); // can't throw because it doesn't perform value conversion 
    143     ASSERT(!exec->hadException()); 
     143    bool result = strictEqual(jsA, jsB); 
    144144    return result; 
    145145} 
  • branches/squirrelfish/JavaScriptCore/ChangeLog

    r33343 r33344  
     12008-05-05  Geoffrey Garen  <ggaren@apple.com> 
     2 
     3        Reviewed by Maciej Stachowiak. 
     4         
     5        Fixed ecma_3/Object/8.6.2.6-001.js, and similar bugs. 
     6         
     7        SunSpider reports a .4% speedup. Not sure what that's about. 
     8 
     9        * VM/Machine.cpp: 
     10        (KJS::Machine::privateExecute): Check for exception return from equal, 
     11        since toPrimitive can throw. 
     12 
     13        * kjs/operations.cpp: 
     14        (KJS::strictEqual): In response to an error I made in an earlier version 
     15        of this patch, I changed strictEqual to make clear the fact that it 
     16        performs no conversions and can't throw, making it slightly more efficient 
     17        in the process. 
     18 
    1192008-05-05  Maciej Stachowiak  <mjs@apple.com> 
    220 
  • branches/squirrelfish/JavaScriptCore/VM/Machine.cpp

    r33343 r33344  
    831831        int src1 = (++vPC)->u.operand; 
    832832        int src2 = (++vPC)->u.operand; 
    833         r[dst].u.jsValue = jsBoolean(equal(exec, r[src1].u.jsValue, r[src2].u.jsValue)); 
     833        JSValue* result = jsBoolean(equal(exec, r[src1].u.jsValue, r[src2].u.jsValue)); 
     834        VM_CHECK_EXCEPTION(); 
     835        r[dst].u.jsValue = result; 
    834836 
    835837        ++vPC; 
     
    846848        int src1 = (++vPC)->u.operand; 
    847849        int src2 = (++vPC)->u.operand; 
    848         r[dst].u.jsValue = jsBoolean(!equal(exec, r[src1].u.jsValue, r[src2].u.jsValue)); 
     850        JSValue* result = jsBoolean(!equal(exec, r[src1].u.jsValue, r[src2].u.jsValue)); 
     851        VM_CHECK_EXCEPTION(); 
     852        r[dst].u.jsValue = result; 
    849853 
    850854        ++vPC; 
     
    861865        int src1 = (++vPC)->u.operand; 
    862866        int src2 = (++vPC)->u.operand; 
    863         r[dst].u.jsValue = jsBoolean(strictEqual(exec, r[src1].u.jsValue, r[src2].u.jsValue)); 
    864  
     867        r[dst].u.jsValue = jsBoolean(strictEqual(r[src1].u.jsValue, r[src2].u.jsValue)); 
     868         
    865869        ++vPC; 
    866870        NEXT_OPCODE; 
     
    876880        int src1 = (++vPC)->u.operand; 
    877881        int src2 = (++vPC)->u.operand; 
    878         r[dst].u.jsValue = jsBoolean(!strictEqual(exec, r[src1].u.jsValue, r[src2].u.jsValue)); 
     882        r[dst].u.jsValue = jsBoolean(!strictEqual(r[src1].u.jsValue, r[src2].u.jsValue)); 
    879883 
    880884        ++vPC; 
  • branches/squirrelfish/JavaScriptCore/kjs/array_object.cpp

    r33188 r33344  
    675675        if (!e) 
    676676            continue; 
    677         if (strictEqual(exec, searchElement, e)) 
     677        if (strictEqual(searchElement, e)) 
    678678            return jsNumber(index); 
    679679    } 
     
    704704        if (!e) 
    705705            continue; 
    706         if (strictEqual(exec, searchElement, e)) 
     706        if (strictEqual(searchElement, e)) 
    707707            return jsNumber(index); 
    708708    } 
  • branches/squirrelfish/JavaScriptCore/kjs/nodes.cpp

    r33342 r33344  
    37173717    KJS_CHECKEXCEPTIONBOOLEAN 
    37183718 
    3719     return strictEqual(exec,v1, v2); 
     3719    return strictEqual(v1, v2); 
    37203720} 
    37213721 
     
    37513751    KJS_CHECKEXCEPTIONBOOLEAN 
    37523752 
    3753     return !strictEqual(exec,v1, v2); 
     3753    return !strictEqual(v1, v2); 
    37543754} 
    37553755 
     
    54865486        JSValue* v = clause->evaluate(exec); 
    54875487        KJS_CHECKEXCEPTION 
    5488         if (strictEqual(exec, input, v)) { 
     5488        if (strictEqual(input, v)) { 
    54895489            JSValue* res = clause->executeStatements(exec); 
    54905490            if (exec->completionType() != Normal) 
     
    55055505        JSValue* v = clause->evaluate(exec); 
    55065506        KJS_CHECKEXCEPTION 
    5507         if (strictEqual(exec, input, v)) { 
     5507        if (strictEqual(input, v)) { 
    55085508            JSValue* res = clause->executeStatements(exec); 
    55095509            if (exec->completionType() != Normal) 
  • branches/squirrelfish/JavaScriptCore/kjs/operations.cpp

    r33199 r33344  
    9999} 
    100100 
    101 bool strictEqual(ExecState *exec, JSValue *v1, JSValue *v2) 
     101bool strictEqual(JSValue* v1, JSValue* v2) 
    102102{ 
    103103    JSType t1 = v1->type(); 
     
    106106    if (t1 != t2) 
    107107        return false; 
    108     if (t1 == UndefinedType || t1 == NullType) 
    109         return true; 
    110     if (t1 == NumberType) { 
    111         double n1 = v1->toNumber(exec); 
    112         double n2 = v2->toNumber(exec); 
    113         if (n1 == n2) 
    114             return true; 
    115         return false; 
    116     } else if (t1 == StringType) 
    117         return v1->toString(exec) == v2->toString(exec); 
    118     else if (t2 == BooleanType) 
    119         return v1->toBoolean(exec) == v2->toBoolean(exec); 
     108 
     109    if (t1 == NumberType) 
     110        return v1->getNumber() == v2->getNumber(); 
    120111     
    121     if (v1 == v2) 
    122         return true; 
    123     /* TODO: joined objects */ 
     112    if (t1 == StringType) 
     113        return static_cast<StringImp*>(v1)->value() == static_cast<StringImp*>(v2)->value(); 
    124114     
    125     return false; 
     115    return v1 == v2; // covers object, boolean, null, and undefined types 
    126116} 
    127117 
  • branches/squirrelfish/JavaScriptCore/kjs/operations.h

    r33199 r33344  
    3030 
    3131  bool equal(ExecState *exec, JSValue *v1, JSValue *v2); 
    32   bool strictEqual(ExecState *exec, JSValue *v1, JSValue *v2); 
     32  bool strictEqual(JSValue*, JSValue*); 
    3333  JSValue* throwOutOfMemoryError(ExecState*); 
    3434} 
  • branches/squirrelfish/LayoutTests/ChangeLog

    r33334 r33344  
     12008-05-05  Geoffrey Garen  <ggaren@apple.com> 
     2 
     3        Reviewed by Maciej Stachowiak. 
     4         
     5        Layout test for exceptions thrown from equality comparisons. 
     6 
     7        * fast/js/exception-thrown-from-equal-expected.txt: Added. 
     8        * fast/js/exception-thrown-from-equal.html: Added. 
     9 
    1102008-05-04  Oliver Hunt  <oliver@apple.com> 
    211