Changeset 209030 in webkit


Ignore:
Timestamp:
Nov 28, 2016 3:23:40 PM (7 years ago)
Author:
mark.lam@apple.com
Message:

Fix exception scope verification failures in runtime/Operations.cpp/h.
https://bugs.webkit.org/show_bug.cgi?id=165046

Reviewed by Saam Barati.

Also switched to using returning { } instead of JSValue().

  • runtime/Operations.cpp:

(JSC::jsAddSlowCase):
(JSC::jsIsObjectTypeOrNull):

  • runtime/Operations.h:

(JSC::jsStringFromRegisterArray):
(JSC::jsStringFromArguments):
(JSC::jsLess):
(JSC::jsLessEq):

Location:
trunk/Source/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r209028 r209030  
     12016-11-28  Mark Lam  <mark.lam@apple.com>
     2
     3        Fix exception scope verification failures in runtime/Operations.cpp/h.
     4        https://bugs.webkit.org/show_bug.cgi?id=165046
     5
     6        Reviewed by Saam Barati.
     7
     8        Also switched to using returning { } instead of JSValue().
     9
     10        * runtime/Operations.cpp:
     11        (JSC::jsAddSlowCase):
     12        (JSC::jsIsObjectTypeOrNull):
     13        * runtime/Operations.h:
     14        (JSC::jsStringFromRegisterArray):
     15        (JSC::jsStringFromArguments):
     16        (JSC::jsLess):
     17        (JSC::jsLessEq):
     18
    1192016-11-28  Mark Lam  <mark.lam@apple.com>
    220
  • trunk/Source/JavaScriptCore/runtime/Operations.cpp

    r206386 r209030  
    4747    auto scope = DECLARE_THROW_SCOPE(vm);
    4848    JSValue p1 = v1.toPrimitive(callFrame);
    49     RETURN_IF_EXCEPTION(scope, JSValue());
     49    RETURN_IF_EXCEPTION(scope, { });
    5050    JSValue p2 = v2.toPrimitive(callFrame);
    51     RETURN_IF_EXCEPTION(scope, JSValue());
     51    RETURN_IF_EXCEPTION(scope, { });
    5252
    53     if (p1.isString())
    54         return jsString(callFrame, asString(p1), p2.toString(callFrame));
     53    if (p1.isString()) {
     54        JSString* p2String = p2.toString(callFrame);
     55        RETURN_IF_EXCEPTION(scope, { });
     56        scope.release();
     57        return jsString(callFrame, asString(p1), p2String);
     58    }
    5559
    56     if (p2.isString())
    57         return jsString(callFrame, p1.toString(callFrame), asString(p2));
     60    if (p2.isString()) {
     61        JSString* p1String = p1.toString(callFrame);
     62        RETURN_IF_EXCEPTION(scope, { });
     63        scope.release();
     64        return jsString(callFrame, p1String, asString(p2));
     65    }
    5866
    59     return jsNumber(p1.toNumber(callFrame) + p2.toNumber(callFrame));
     67    double p1Number = p1.toNumber(callFrame);
     68    RETURN_IF_EXCEPTION(scope, { });
     69    scope.release();
     70    return jsNumber(p1Number + p2.toNumber(callFrame));
    6071}
    6172
     
    97108bool jsIsObjectTypeOrNull(CallFrame* callFrame, JSValue v)
    98109{
     110    VM& vm = callFrame->vm();
    99111    if (!v.isCell())
    100112        return v.isNull();
     
    104116        return false;
    105117    if (type >= ObjectType) {
    106         if (asObject(v)->structure(callFrame->vm())->masqueradesAsUndefined(callFrame->lexicalGlobalObject()))
     118        if (asObject(v)->structure(vm)->masqueradesAsUndefined(callFrame->lexicalGlobalObject()))
    107119            return false;
    108120        CallData callData;
    109121        JSObject* object = asObject(v);
    110         if (object->methodTable(callFrame->vm())->getCallData(object, callData) != CallType::None)
     122        if (object->methodTable(vm)->getCallData(object, callData) != CallType::None)
    111123            return false;
    112124    }
  • trunk/Source/JavaScriptCore/runtime/Operations.h

    r206525 r209030  
    127127    for (unsigned i = 0; i < count; ++i) {
    128128        JSValue v = strings[-static_cast<int>(i)].jsValue();
    129         if (!ropeBuilder.append(v.toString(exec)))
     129        JSString* string = v.toString(exec);
     130        RETURN_IF_EXCEPTION(scope, { });
     131        if (!ropeBuilder.append(string))
    130132            return throwOutOfMemoryError(exec, scope);
    131133    }
     
    139141    auto scope = DECLARE_THROW_SCOPE(*vm);
    140142    JSRopeString::RopeBuilder ropeBuilder(*vm);
    141     ropeBuilder.append(thisValue.toString(exec));
     143    JSString* str = thisValue.toString(exec);
     144    RETURN_IF_EXCEPTION(scope, { });
     145    ropeBuilder.append(str);
    142146
    143147    for (unsigned i = 0; i < exec->argumentCount(); ++i) {
    144148        JSValue v = exec->argument(i);
    145         if (!ropeBuilder.append(v.toString(exec)))
     149        JSString* str = v.toString(exec);
     150        RETURN_IF_EXCEPTION(scope, { });
     151        if (UNLIKELY(!ropeBuilder.append(str)))
    146152            return throwOutOfMemoryError(exec, scope);
    147153    }
     
    156162ALWAYS_INLINE bool jsLess(CallFrame* callFrame, JSValue v1, JSValue v2)
    157163{
     164    VM& vm = callFrame->vm();
     165    auto scope = DECLARE_THROW_SCOPE(vm);
     166
    158167    if (v1.isInt32() && v2.isInt32())
    159168        return v1.asInt32() < v2.asInt32();
     
    173182    if (leftFirst) {
    174183        wasNotString1 = v1.getPrimitiveNumber(callFrame, n1, p1);
     184        RETURN_IF_EXCEPTION(scope, false);
    175185        wasNotString2 = v2.getPrimitiveNumber(callFrame, n2, p2);
    176186    } else {
    177187        wasNotString2 = v2.getPrimitiveNumber(callFrame, n2, p2);
    178         wasNotString1 = v1.getPrimitiveNumber(callFrame, n1, p1);
    179     }
     188        RETURN_IF_EXCEPTION(scope, false);
     189        wasNotString1 = v1.getPrimitiveNumber(callFrame, n1, p1);
     190    }
     191    RETURN_IF_EXCEPTION(scope, false);
    180192
    181193    if (wasNotString1 | wasNotString2)
     
    190202ALWAYS_INLINE bool jsLessEq(CallFrame* callFrame, JSValue v1, JSValue v2)
    191203{
     204    VM& vm = callFrame->vm();
     205    auto scope = DECLARE_THROW_SCOPE(vm);
     206
    192207    if (v1.isInt32() && v2.isInt32())
    193208        return v1.asInt32() <= v2.asInt32();
     
    207222    if (leftFirst) {
    208223        wasNotString1 = v1.getPrimitiveNumber(callFrame, n1, p1);
     224        RETURN_IF_EXCEPTION(scope, false);
    209225        wasNotString2 = v2.getPrimitiveNumber(callFrame, n2, p2);
    210226    } else {
    211227        wasNotString2 = v2.getPrimitiveNumber(callFrame, n2, p2);
    212         wasNotString1 = v1.getPrimitiveNumber(callFrame, n1, p1);
    213     }
     228        RETURN_IF_EXCEPTION(scope, false);
     229        wasNotString1 = v1.getPrimitiveNumber(callFrame, n1, p1);
     230    }
     231    RETURN_IF_EXCEPTION(scope, false);
    214232
    215233    if (wasNotString1 | wasNotString2)
Note: See TracChangeset for help on using the changeset viewer.