Ignore:
Timestamp:
Jun 7, 2016, 7:53:32 PM (9 years ago)
Author:
[email protected]
Message:

Need an exception check after constructEmptyArray().
https://bugs.webkit.org/show_bug.cgi?id=158411

Reviewed by Saam Barati.

Source/JavaScriptCore:

Added an exception check after each call to constructEmptyArray().

  • inspector/JSInjectedScriptHost.cpp:

(Inspector::JSInjectedScriptHost::getInternalProperties):
(Inspector::JSInjectedScriptHost::weakMapEntries):
(Inspector::JSInjectedScriptHost::weakSetEntries):
(Inspector::JSInjectedScriptHost::iteratorEntries):

  • interpreter/ShadowChicken.cpp:

(JSC::ShadowChicken::functionsOnStack):

  • profiler/ProfilerBytecodeSequence.cpp:

(JSC::Profiler::BytecodeSequence::addSequenceProperties):

  • profiler/ProfilerCompilation.cpp:

(JSC::Profiler::Compilation::toJS):

  • profiler/ProfilerDatabase.cpp:

(JSC::Profiler::Database::toJS):

  • profiler/ProfilerOSRExitSite.cpp:

(JSC::Profiler::OSRExitSite::toJS):

  • profiler/ProfilerOriginStack.cpp:

(JSC::Profiler::OriginStack::toJS):

  • runtime/ArrayPrototype.cpp:

(JSC::arrayProtoFuncConcat):
(JSC::arrayProtoFuncSlice):
(JSC::arrayProtoFuncSplice):

  • runtime/LiteralParser.cpp:

(JSC::LiteralParser<CharType>::parse):

  • runtime/ModuleLoaderObject.cpp:

(JSC::moduleLoaderObjectRequestedModules):

  • runtime/ObjectConstructor.cpp:

(JSC::ownPropertyKeys):

  • runtime/RegExpObject.cpp:

(JSC::collectMatches):

  • runtime/RegExpPrototype.cpp:

(JSC::regExpProtoFuncSplitFast):

  • runtime/StringPrototype.cpp:

(JSC::stringProtoFuncSplitFast):

  • runtime/TemplateRegistry.cpp:

(JSC::TemplateRegistry::getTemplateObject):

  • tests/stress/regress-158411.js: Added.

Source/WebCore:

A stress test for this was added in JavaScriptCore.

  • bindings/js/IDBBindingUtilities.cpp:

(WebCore::toJS):

  • bindings/js/JSCommandLineAPIHostCustom.cpp:

(WebCore::getJSListenerFunctions):

  • bindings/js/JSCryptoKeySerializationJWK.cpp:

(WebCore::buildJSONForRSAComponents):
(WebCore::addBoolToJSON):
(WebCore::addUsagesToJSON):
(WebCore::JSCryptoKeySerializationJWK::serialize):

  • bindings/js/JSDOMBinding.h:

(WebCore::toJS):

  • bindings/js/SerializedScriptValue.cpp:

(WebCore::CloneDeserializer::deserialize):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/profiler/ProfilerCompilation.cpp

    r200658 r201787  
    115115JSValue Compilation::toJS(ExecState* exec) const
    116116{
     117    VM& vm = exec->vm();
    117118    JSObject* result = constructEmptyObject(exec);
    118    
    119     result->putDirect(exec->vm(), exec->propertyNames().bytecodesID, jsNumber(m_bytecodes->id()));
    120     result->putDirect(exec->vm(), exec->propertyNames().compilationKind, jsString(exec, String::fromUTF8(toCString(m_kind))));
     119    if (UNLIKELY(vm.exception()))
     120        return jsUndefined();
     121    result->putDirect(vm, exec->propertyNames().bytecodesID, jsNumber(m_bytecodes->id()));
     122    result->putDirect(vm, exec->propertyNames().compilationKind, jsString(exec, String::fromUTF8(toCString(m_kind))));
    121123   
    122124    JSArray* profiledBytecodes = constructEmptyArray(exec, 0);
     125    if (UNLIKELY(vm.exception()))
     126        return jsUndefined();
    123127    for (unsigned i = 0; i < m_profiledBytecodes.size(); ++i)
    124128        profiledBytecodes->putDirectIndex(exec, i, m_profiledBytecodes[i].toJS(exec));
    125     result->putDirect(exec->vm(), exec->propertyNames().profiledBytecodes, profiledBytecodes);
     129    result->putDirect(vm, exec->propertyNames().profiledBytecodes, profiledBytecodes);
    126130   
    127131    JSArray* descriptions = constructEmptyArray(exec, 0);
     132    if (UNLIKELY(vm.exception()))
     133        return jsUndefined();
    128134    for (unsigned i = 0; i < m_descriptions.size(); ++i)
    129135        descriptions->putDirectIndex(exec, i, m_descriptions[i].toJS(exec));
    130     result->putDirect(exec->vm(), exec->propertyNames().descriptions, descriptions);
     136    result->putDirect(vm, exec->propertyNames().descriptions, descriptions);
    131137   
    132138    JSArray* counters = constructEmptyArray(exec, 0);
     139    if (UNLIKELY(vm.exception()))
     140        return jsUndefined();
    133141    for (auto it = m_counters.begin(), end = m_counters.end(); it != end; ++it) {
    134142        JSObject* counterEntry = constructEmptyObject(exec);
    135         counterEntry->putDirect(exec->vm(), exec->propertyNames().origin, it->key.toJS(exec));
    136         counterEntry->putDirect(exec->vm(), exec->propertyNames().executionCount, jsNumber(it->value->count()));
     143        counterEntry->putDirect(vm, exec->propertyNames().origin, it->key.toJS(exec));
     144        counterEntry->putDirect(vm, exec->propertyNames().executionCount, jsNumber(it->value->count()));
    137145        counters->push(exec, counterEntry);
    138146    }
    139     result->putDirect(exec->vm(), exec->propertyNames().counters, counters);
     147    result->putDirect(vm, exec->propertyNames().counters, counters);
    140148   
    141149    JSArray* exitSites = constructEmptyArray(exec, 0);
     150    if (UNLIKELY(vm.exception()))
     151        return jsUndefined();
    142152    for (unsigned i = 0; i < m_osrExitSites.size(); ++i)
    143153        exitSites->putDirectIndex(exec, i, m_osrExitSites[i].toJS(exec));
    144     result->putDirect(exec->vm(), exec->propertyNames().osrExitSites, exitSites);
     154    result->putDirect(vm, exec->propertyNames().osrExitSites, exitSites);
    145155   
    146156    JSArray* exits = constructEmptyArray(exec, 0);
     157    if (UNLIKELY(vm.exception()))
     158        return jsUndefined();
    147159    for (unsigned i = 0; i < m_osrExits.size(); ++i)
    148160        exits->putDirectIndex(exec, i, m_osrExits[i].toJS(exec));
    149     result->putDirect(exec->vm(), exec->propertyNames().osrExits, exits);
     161    result->putDirect(vm, exec->propertyNames().osrExits, exits);
    150162   
    151     result->putDirect(exec->vm(), exec->propertyNames().numInlinedGetByIds, jsNumber(m_numInlinedGetByIds));
    152     result->putDirect(exec->vm(), exec->propertyNames().numInlinedPutByIds, jsNumber(m_numInlinedPutByIds));
    153     result->putDirect(exec->vm(), exec->propertyNames().numInlinedCalls, jsNumber(m_numInlinedCalls));
    154     result->putDirect(exec->vm(), exec->propertyNames().jettisonReason, jsString(exec, String::fromUTF8(toCString(m_jettisonReason))));
     163    result->putDirect(vm, exec->propertyNames().numInlinedGetByIds, jsNumber(m_numInlinedGetByIds));
     164    result->putDirect(vm, exec->propertyNames().numInlinedPutByIds, jsNumber(m_numInlinedPutByIds));
     165    result->putDirect(vm, exec->propertyNames().numInlinedCalls, jsNumber(m_numInlinedCalls));
     166    result->putDirect(vm, exec->propertyNames().jettisonReason, jsString(exec, String::fromUTF8(toCString(m_jettisonReason))));
    155167    if (!m_additionalJettisonReason.isNull())
    156         result->putDirect(exec->vm(), exec->propertyNames().additionalJettisonReason, jsString(exec, String::fromUTF8(m_additionalJettisonReason)));
     168        result->putDirect(vm, exec->propertyNames().additionalJettisonReason, jsString(exec, String::fromUTF8(m_additionalJettisonReason)));
    157169   
    158     result->putDirect(exec->vm(), exec->propertyNames().uid, m_uid.toJS(exec));
     170    result->putDirect(vm, exec->propertyNames().uid, m_uid.toJS(exec));
    159171   
    160172    return result;
Note: See TracChangeset for help on using the changeset viewer.