Ignore:
Timestamp:
Dec 7, 2009, 3:14:04 PM (15 years ago)
Author:
[email protected]
Message:

https://bugs.webkit.org/show_bug.cgi?id=32184
Handle out-of-memory conditions with JSC Ropes with a JS exception, rather than crashing.
Switch from using fastMalloc to tryFastMalloc, pass an ExecState to record the exception on.

Reviewed by Oliver Hunt.

JavaScriptCore:

  • API/JSCallbackObjectFunctions.h:

(JSC::::toString):

  • API/JSValueRef.cpp:

(JSValueIsStrictEqual):

(JSC::BytecodeGenerator::emitEqualityOp):

  • debugger/DebuggerCallFrame.cpp:

(JSC::DebuggerCallFrame::functionName):
(JSC::DebuggerCallFrame::calculatedFunctionName):

  • interpreter/Interpreter.cpp:

(JSC::Interpreter::callEval):
(JSC::Interpreter::privateExecute):

  • jit/JITStubs.cpp:

(JSC::DEFINE_STUB_FUNCTION):

  • profiler/ProfileGenerator.cpp:

(JSC::ProfileGenerator::addParentForConsoleStart):

  • profiler/Profiler.cpp:

(JSC::Profiler::willExecute):
(JSC::Profiler::didExecute):
(JSC::Profiler::createCallIdentifier):
(JSC::createCallIdentifierFromFunctionImp):

  • profiler/Profiler.h:
  • runtime/ArrayPrototype.cpp:

(JSC::arrayProtoFuncIndexOf):
(JSC::arrayProtoFuncLastIndexOf):

  • runtime/DateConstructor.cpp:

(JSC::constructDate):

  • runtime/FunctionPrototype.cpp:

(JSC::functionProtoFuncToString):

  • runtime/InternalFunction.cpp:

(JSC::InternalFunction::name):
(JSC::InternalFunction::displayName):
(JSC::InternalFunction::calculatedDisplayName):

  • runtime/InternalFunction.h:
  • runtime/JSCell.cpp:

(JSC::JSCell::getString):

  • runtime/JSCell.h:

(JSC::JSValue::getString):

  • runtime/JSONObject.cpp:

(JSC::gap):
(JSC::Stringifier::Stringifier):
(JSC::Stringifier::appendStringifiedValue):

  • runtime/JSObject.cpp:

(JSC::JSObject::putDirectFunction):
(JSC::JSObject::putDirectFunctionWithoutTransition):
(JSC::JSObject::defineOwnProperty):

  • runtime/JSObject.h:
  • runtime/JSPropertyNameIterator.cpp:

(JSC::JSPropertyNameIterator::get):

  • runtime/JSString.cpp:

(JSC::JSString::Rope::~Rope):
(JSC::JSString::resolveRope):
(JSC::JSString::getPrimitiveNumber):
(JSC::JSString::toNumber):
(JSC::JSString::toString):
(JSC::JSString::toThisString):
(JSC::JSString::getStringPropertyDescriptor):

  • runtime/JSString.h:

(JSC::JSString::Rope::createOrNull):
(JSC::JSString::Rope::operator new):
(JSC::JSString::value):
(JSC::JSString::tryGetValue):
(JSC::JSString::getIndex):
(JSC::JSString::getStringPropertySlot):
(JSC::JSValue::toString):

  • runtime/JSValue.h:
  • runtime/NativeErrorConstructor.cpp:

(JSC::NativeErrorConstructor::NativeErrorConstructor):

  • runtime/Operations.cpp:

(JSC::JSValue::strictEqualSlowCase):

  • runtime/Operations.h:

(JSC::JSValue::equalSlowCaseInline):
(JSC::JSValue::strictEqualSlowCaseInline):
(JSC::JSValue::strictEqual):
(JSC::jsLess):
(JSC::jsLessEq):
(JSC::jsAdd):
(JSC::concatenateStrings):

  • runtime/PropertyDescriptor.cpp:

(JSC::PropertyDescriptor::equalTo):

  • runtime/PropertyDescriptor.h:
  • runtime/StringPrototype.cpp:

(JSC::stringProtoFuncReplace):
(JSC::stringProtoFuncToLowerCase):
(JSC::stringProtoFuncToUpperCase):

WebCore:

  • bindings/ScriptControllerBase.cpp:

(WebCore::ScriptController::executeIfJavaScriptURL):

  • bindings/js/JSCanvasRenderingContext2DCustom.cpp:

(WebCore::toHTMLCanvasStyle):
(WebCore::JSCanvasRenderingContext2D::setFillColor):
(WebCore::JSCanvasRenderingContext2D::setStrokeColor):
(WebCore::JSCanvasRenderingContext2D::setShadow):

  • bindings/js/ScriptCallStack.cpp:

(WebCore::ScriptCallStack::ScriptCallStack):
(WebCore::ScriptCallStack::initialize):

  • bindings/js/ScriptValue.cpp:

(WebCore::ScriptValue::getString):

  • bindings/js/ScriptValue.h:
  • bindings/js/SerializedScriptValue.cpp:

(WebCore::SerializingTreeWalker::convertIfTerminal):

  • bindings/objc/WebScriptObject.mm:

(+[WebScriptObject _convertValueToObjcValue:originRootObject:rootObject:]):

  • page/Console.cpp:

(WebCore::Console::addMessage):

WebKit/mac:

  • WebView/WebView.mm:

(aeDescFromJSValue):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/Operations.h

    r51671 r51801  
    5454            bool s2 = v2.isString();
    5555            if (s1 && s2)
    56                 return asString(v1)->value() == asString(v2)->value();
     56                return asString(v1)->value(exec) == asString(v2)->value(exec);
    5757
    5858            if (v1.isUndefinedOrNull()) {
     
    111111
    112112    // ECMA 11.9.3
    113     ALWAYS_INLINE bool JSValue::strictEqualSlowCaseInline(JSValue v1, JSValue v2)
     113    ALWAYS_INLINE bool JSValue::strictEqualSlowCaseInline(ExecState* exec, JSValue v1, JSValue v2)
    114114    {
    115115        ASSERT(v1.isCell() && v2.isCell());
    116116
    117117        if (v1.asCell()->isString() && v2.asCell()->isString())
    118             return asString(v1)->value() == asString(v2)->value();
     118            return asString(v1)->value(exec) == asString(v2)->value(exec);
    119119
    120120        return v1 == v2;
    121121    }
    122122
    123     inline bool JSValue::strictEqual(JSValue v1, JSValue v2)
     123    inline bool JSValue::strictEqual(ExecState* exec, JSValue v1, JSValue v2)
    124124    {
    125125        if (v1.isInt32() && v2.isInt32())
     
    132132            return v1 == v2;
    133133
    134         return strictEqualSlowCaseInline(v1, v2);
     134        return strictEqualSlowCaseInline(exec, v1, v2);
    135135    }
    136136
     
    147147        JSGlobalData* globalData = &callFrame->globalData();
    148148        if (isJSString(globalData, v1) && isJSString(globalData, v2))
    149             return asString(v1)->value() < asString(v2)->value();
     149            return asString(v1)->value(callFrame) < asString(v2)->value(callFrame);
    150150
    151151        JSValue p1;
     
    157157            return n1 < n2;
    158158
    159         return asString(p1)->value() < asString(p2)->value();
     159        return asString(p1)->value(callFrame) < asString(p2)->value(callFrame);
    160160    }
    161161
     
    172172        JSGlobalData* globalData = &callFrame->globalData();
    173173        if (isJSString(globalData, v1) && isJSString(globalData, v2))
    174             return !(asString(v2)->value() < asString(v1)->value());
     174            return !(asString(v2)->value(callFrame) < asString(v1)->value(callFrame));
    175175
    176176        JSValue p1;
     
    182182            return n1 <= n2;
    183183
    184         return !(asString(p2)->value() < asString(p1)->value());
     184        return !(asString(p2)->value(callFrame) < asString(p1)->value(callFrame));
    185185    }
    186186
     
    206206        if (leftIsString && v2.isString()) {
    207207            if (asString(v1)->isRope() || asString(v2)->isRope()) {
    208                 RefPtr<JSString::Rope> rope = JSString::Rope::create(2);
     208                RefPtr<JSString::Rope> rope = JSString::Rope::createOrNull(2);
     209                if (UNLIKELY(!rope))
     210                    return throwOutOfMemoryError(callFrame);
    209211                rope->initializeFiber(0, asString(v1));
    210212                rope->initializeFiber(1, asString(v2));
     
    213215            }
    214216
    215             RefPtr<UString::Rep> value = concatenate(asString(v1)->value().rep(), asString(v2)->value().rep());
     217            RefPtr<UString::Rep> value = concatenate(asString(v1)->value(callFrame).rep(), asString(v2)->value(callFrame).rep());
    216218            if (!value)
    217219                return throwOutOfMemoryError(callFrame);
     
    221223        if (rightIsNumber & leftIsString) {
    222224            RefPtr<UString::Rep> value = v2.isInt32() ?
    223                 concatenate(asString(v1)->value().rep(), v2.asInt32()) :
    224                 concatenate(asString(v1)->value().rep(), right);
     225                concatenate(asString(v1)->value(callFrame).rep(), v2.asInt32()) :
     226                concatenate(asString(v1)->value(callFrame).rep(), right);
    225227
    226228            if (!value)
     
    307309        ASSERT(count >= 3);
    308310
    309         RefPtr<JSString::Rope> rope = JSString::Rope::create(count);
     311        RefPtr<JSString::Rope> rope = JSString::Rope::createOrNull(count);
     312        if (UNLIKELY(!rope))
     313            return throwOutOfMemoryError(callFrame);
    310314
    311315        for (unsigned i = 0; i < count; ++i) {
Note: See TracChangeset for help on using the changeset viewer.