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/JSString.h

    r51671 r51801  
    8787            // Creates a Rope comprising of 'ropeLength' Fibers.
    8888            // The Rope is constructed in an uninitialized state - initialize must be called for each Fiber in the Rope.
    89             static PassRefPtr<Rope> create(unsigned ropeLength) { return adoptRef(new (ropeLength) Rope(ropeLength)); }
     89            static PassRefPtr<Rope> createOrNull(unsigned ropeLength)
     90            {
     91                void* allocation;
     92                if (tryFastMalloc(sizeof(Rope) + (ropeLength - 1) * sizeof(Fiber)).getValue(allocation))
     93                    return adoptRef(new (allocation) Rope(ropeLength));
     94                return 0;
     95            }
    9096
    9197            ~Rope();
     
    117123        private:
    118124            Rope(unsigned ropeLength) : m_ropeLength(ropeLength), m_stringLength(0) {}
    119             void* operator new(size_t, unsigned ropeLength) { return fastMalloc(sizeof(Rope) + (ropeLength - 1) * sizeof(UString::Rep*)); }
     125            void* operator new(size_t, void* inPlace) { return inPlace; }
    120126           
    121127            unsigned m_ropeLength;
     
    151157        {
    152158        }
    153        
    154         const UString& value() const
     159
     160        const UString& value(ExecState* exec) const
    155161        {
    156162            if (m_rope)
    157                 resolveRope();
     163                resolveRope(exec);
     164            return m_value;
     165        }
     166        const UString tryGetValue() const
     167        {
     168            if (m_rope)
     169                UString();
    158170            return m_value;
    159171        }
     
    169181
    170182        bool canGetIndex(unsigned i) { return i < m_length; }
    171         JSString* getIndex(JSGlobalData*, unsigned);
     183        JSString* getIndex(ExecState*, unsigned);
    172184
    173185        static PassRefPtr<Structure> createStructure(JSValue proto) { return Structure::create(proto, TypeInfo(StringType, OverridesGetOwnPropertySlot | NeedsThisConversion)); }
     
    180192        }
    181193
    182         void resolveRope() const;
     194        void resolveRope(ExecState*) const;
    183195
    184196        virtual JSValue toPrimitive(ExecState*, PreferredPrimitiveType) const;
     
    247259    }
    248260
    249     inline JSString* JSString::getIndex(JSGlobalData* globalData, unsigned i)
     261    inline JSString* JSString::getIndex(ExecState* exec, unsigned i)
    250262    {
    251263        ASSERT(canGetIndex(i));
    252         return jsSingleCharacterSubstring(globalData, value(), i);
     264        return jsSingleCharacterSubstring(&exec->globalData(), value(exec), i);
    253265    }
    254266
     
    313325        unsigned i = propertyName.toStrictUInt32(&isStrictUInt32);
    314326        if (isStrictUInt32 && i < m_length) {
    315             slot.setValue(jsSingleCharacterSubstring(exec, value(), i));
     327            slot.setValue(jsSingleCharacterSubstring(exec, value(exec), i));
    316328            return true;
    317329        }
     
    323335    {
    324336        if (propertyName < m_length) {
    325             slot.setValue(jsSingleCharacterSubstring(exec, value(), propertyName));
     337            slot.setValue(jsSingleCharacterSubstring(exec, value(exec), propertyName));
    326338            return true;
    327339        }
     
    342354    {
    343355        if (isString())
    344             return static_cast<JSString*>(asCell())->value();
     356            return static_cast<JSString*>(asCell())->value(exec);
    345357        if (isInt32())
    346358            return exec->globalData().numericStrings.add(asInt32());
Note: See TracChangeset for help on using the changeset viewer.