Changeset 65302 in webkit for trunk/JavaScriptCore/runtime


Ignore:
Timestamp:
Aug 12, 2010, 11:42:16 PM (15 years ago)
Author:
Csaba Osztrogonác
Message:

2010-08-12 Sheriff Bot <[email protected]>

Unreviewed, rolling out r65295.
http://trac.webkit.org/changeset/65295
https://bugs.webkit.org/show_bug.cgi?id=43950

It broke 4 sputnik tests (Requested by Ossy on #webkit).

  • JavaScriptCore.exp:
  • bytecode/CodeBlock.cpp: (JSC::constantName): (JSC::idName): (JSC::CodeBlock::registerName): (JSC::regexpName): (JSC::printGlobalResolveInfo): (JSC::printStructureStubInfo): (JSC::CodeBlock::printStructure): (JSC::CodeBlock::printStructures):
  • jsc.cpp: (functionPrint): (functionDebug): (runInteractive): (fillBufferWithContentsOfFile):
  • pcre/pcre_exec.cpp: (Histogram::~Histogram):
  • profiler/CallIdentifier.h: (JSC::CallIdentifier::c_str):
  • profiler/Profile.cpp: (JSC::Profile::debugPrintDataSampleStyle):
  • profiler/ProfileGenerator.cpp: (JSC::ProfileGenerator::willExecute): (JSC::ProfileGenerator::didExecute):
  • profiler/ProfileNode.cpp: (JSC::ProfileNode::debugPrintData): (JSC::ProfileNode::debugPrintDataSampleStyle):
  • runtime/Arguments.cpp: (JSC::Arguments::getOwnPropertySlot): (JSC::Arguments::getOwnPropertyDescriptor): (JSC::Arguments::put): (JSC::Arguments::deleteProperty):
  • runtime/DateConversion.cpp: (JSC::parseDate):
  • runtime/Identifier.h: (JSC::Identifier::Identifier): (JSC::Identifier::toArrayIndex):
  • runtime/JSArray.cpp: (JSC::JSArray::getOwnPropertySlot): (JSC::JSArray::getOwnPropertyDescriptor): (JSC::JSArray::put): (JSC::JSArray::deleteProperty):
  • runtime/JSArray.h:
  • runtime/JSGlobalObjectFunctions.cpp: (JSC::encode): (JSC::parseInt): (JSC::globalFuncJSCPrint):
  • runtime/JSString.h: (JSC::RopeBuilder::JSString):
  • runtime/UString.cpp: (JSC::UString::toDouble): (JSC::UString::UTF8String):
  • runtime/UString.h: (JSC::UString::isNull): (JSC::UString::isEmpty): (JSC::UString::impl): (JSC::UString::cost): (JSC::UString::~UString): (JSC::UString::toArrayIndex):
  • wtf/text/WTFString.cpp: (WTF::String::utf8):
  • wtf/text/WTFString.h: (WTF::String::String): (WTF::String::isHashTableDeletedValue): (WTF::String::length): (WTF::String::operator[]): (WTF::String::isNull): (WTF::String::isEmpty): (WTF::String::impl):

2010-08-12 Sheriff Bot <[email protected]>

Unreviewed, rolling out r65295.
http://trac.webkit.org/changeset/65295
https://bugs.webkit.org/show_bug.cgi?id=43950

It broke 4 sputnik tests (Requested by Ossy on #webkit).

  • WebFrame.cpp: (wxWebFrame::RunScript):

2010-08-12 Sheriff Bot <[email protected]>

Unreviewed, rolling out r65295.
http://trac.webkit.org/changeset/65295
https://bugs.webkit.org/show_bug.cgi?id=43950

It broke 4 sputnik tests (Requested by Ossy on #webkit).

  • Plugins/Hosted/NetscapePluginInstanceProxy.mm: (WebKit::NetscapePluginInstanceProxy::enumerate):

2010-08-12 Sheriff Bot <[email protected]>

Unreviewed, rolling out r65295.
http://trac.webkit.org/changeset/65295
https://bugs.webkit.org/show_bug.cgi?id=43950

It broke 4 sputnik tests (Requested by Ossy on #webkit).

  • WebCore.xcodeproj/project.pbxproj:
  • bindings/js/JSDOMWindowCustom.cpp: (WebCore::JSDOMWindow::getOwnPropertySlot): (WebCore::JSDOMWindow::getOwnPropertyDescriptor):
  • bridge/NP_jsobject.cpp: (_NPN_Enumerate):
  • bridge/c/c_utility.cpp: (JSC::Bindings::convertValueToNPVariant):
  • bridge/jni/JNIBridge.cpp: (JavaParameter::JavaParameter): (JavaMethod::JavaMethod): (JavaMethod::signature): (JavaMethod::methodID):
  • bridge/jni/JNIBridge.h: (JSC::Bindings::JavaString::UTF8String): (JSC::Bindings::JavaParameter::type): (JSC::Bindings::JavaMethod::returnType):
  • bridge/jni/jni_jsobject.mm: (JavaJSObject::call): (JavaJSObject::eval): (JavaJSObject::getMember): (JavaJSObject::setMember): (JavaJSObject::removeMember): (JavaJSObject::convertJObjectToValue):
  • bridge/jni/jsc/JNIBridgeJSC.cpp: (JavaField::JavaField): (JavaField::valueFromInstance): (JavaField::setValueToInstance):
  • bridge/jni/jsc/JNIBridgeJSC.h: (JSC::Bindings::JavaField::type):
  • bridge/jni/jsc/JavaInstanceJSC.cpp: (JavaInstance::invokeMethod):
  • bridge/jni/jsc/JavaStringJSC.h: (JSC::Bindings::JavaStringImpl::UTF8String):
  • bridge/runtime_array.cpp: (JSC::RuntimeArray::getOwnPropertySlot): (JSC::RuntimeArray::getOwnPropertyDescriptor): (JSC::RuntimeArray::put):

2010-08-12 Sheriff Bot <[email protected]>

Unreviewed, rolling out r65295.
http://trac.webkit.org/changeset/65295
https://bugs.webkit.org/show_bug.cgi?id=43950

It broke 4 sputnik tests (Requested by Ossy on #webkit).

  • WebProcess/Plugins/JSNPObject.cpp: (WebKit::npIdentifierFromIdentifier):
  • WebProcess/Plugins/NPJSObject.cpp: (WebKit::NPJSObject::enumerate):
  • WebProcess/Plugins/NPRuntimeObjectMap.cpp: (WebKit::NPRuntimeObjectMap::convertJSValueToNPVariant):
Location:
trunk/JavaScriptCore/runtime
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/Arguments.cpp

    r65295 r65302  
    158158{
    159159    bool isArrayIndex;
    160     unsigned i = toArrayIndex(propertyName.ustring(), &isArrayIndex);
     160    unsigned i = propertyName.toArrayIndex(&isArrayIndex);
    161161    if (isArrayIndex && i < d->numArguments && (!d->deletedArguments || !d->deletedArguments[i])) {
    162162        if (i < d->numParameters) {
     
    183183{
    184184    bool isArrayIndex;
    185     unsigned i = toArrayIndex(propertyName.ustring(), &isArrayIndex);
     185    unsigned i = propertyName.toArrayIndex(&isArrayIndex);
    186186    if (isArrayIndex && i < d->numArguments && (!d->deletedArguments || !d->deletedArguments[i])) {
    187187        if (i < d->numParameters) {
     
    234234{
    235235    bool isArrayIndex;
    236     unsigned i = toArrayIndex(propertyName.ustring(), &isArrayIndex);
     236    unsigned i = propertyName.toArrayIndex(&isArrayIndex);
    237237    if (isArrayIndex && i < d->numArguments && (!d->deletedArguments || !d->deletedArguments[i])) {
    238238        if (i < d->numParameters)
     
    277277{
    278278    bool isArrayIndex;
    279     unsigned i = toArrayIndex(propertyName.ustring(), &isArrayIndex);
     279    unsigned i = propertyName.toArrayIndex(&isArrayIndex);
    280280    if (isArrayIndex && i < d->numArguments) {
    281281        if (!d->deletedArguments) {
  • trunk/JavaScriptCore/runtime/DateConversion.cpp

    r65295 r65302  
    5757    if (date == exec->globalData().cachedDateString)
    5858        return exec->globalData().cachedDateStringValue;
    59     double value = parseDateFromNullTerminatedCharacters(exec, date.utf8().data());
     59    double value = parseDateFromNullTerminatedCharacters(exec, date.UTF8String().data());
    6060    exec->globalData().cachedDateString = date;
    6161    exec->globalData().cachedDateStringValue = value;
  • trunk/JavaScriptCore/runtime/Identifier.h

    r65295 r65302  
    4545        Identifier(JSGlobalData* globalData, const UString& s) : m_string(add(globalData, s.impl())) { }
    4646
     47        // Special constructor for cases where we overwrite an object in place.
     48        Identifier(PlacementNewAdoptType) : m_string(PlacementNewAdopt) { }
     49       
    4750        const UString& ustring() const { return m_string; }
    4851        StringImpl* impl() const { return m_string.impl(); }
     
    6669        uint32_t toUInt32(bool* ok, bool tolerateEmptyString) const { return m_string.toUInt32(ok, tolerateEmptyString); };
    6770        uint32_t toStrictUInt32(bool* ok) const { return m_string.toStrictUInt32(ok); }
     71        unsigned toArrayIndex(bool* ok) const { return m_string.toArrayIndex(ok); }
    6872        double toDouble() const { return m_string.toDouble(); }
    6973       
  • trunk/JavaScriptCore/runtime/JSArray.cpp

    r65295 r65302  
    274274
    275275    bool isArrayIndex;
    276     unsigned i = toArrayIndex(propertyName.ustring(), &isArrayIndex);
     276    unsigned i = propertyName.toArrayIndex(&isArrayIndex);
    277277    if (isArrayIndex)
    278278        return JSArray::getOwnPropertySlot(exec, i, slot);
     
    291291   
    292292    bool isArrayIndex;
    293     unsigned i = toArrayIndex(propertyName.ustring(), &isArrayIndex);
     293    unsigned i = propertyName.toArrayIndex(&isArrayIndex);
    294294    if (isArrayIndex) {
    295295        if (i >= storage->m_length)
     
    318318{
    319319    bool isArrayIndex;
    320     unsigned i = toArrayIndex(propertyName.ustring(), &isArrayIndex);
     320    unsigned i = propertyName.toArrayIndex(&isArrayIndex);
    321321    if (isArrayIndex) {
    322322        put(exec, i, value);
     
    476476{
    477477    bool isArrayIndex;
    478     unsigned i = toArrayIndex(propertyName.ustring(), &isArrayIndex);
     478    unsigned i = propertyName.toArrayIndex(&isArrayIndex);
    479479    if (isArrayIndex)
    480480        return deleteProperty(exec, i);
  • trunk/JavaScriptCore/runtime/JSArray.h

    r65295 r65302  
    262262        }
    263263    }
    264 
    265     // Rule from ECMA 15.2 about what an array index is.
    266     // Must exactly match string form of an unsigned integer, and be less than 2^32 - 1.
    267     inline unsigned toArrayIndex(const UString& string, bool* ok)
    268     {
    269         unsigned i = string.toStrictUInt32(ok);
    270         if (ok && i >= 0xFFFFFFFFU)
    271             *ok = false;
    272         return i;
    273     }
    274 
     264   
    275265} // namespace JSC
    276266
  • trunk/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp

    r65295 r65302  
    5454{
    5555    UString str = exec->argument(0).toString(exec);
    56     CString cstr = str.utf8(true);
     56    CString cstr = str.UTF8String(true);
    5757    if (!cstr.data())
    5858        return throwError(exec, createURIError(exec, "String contained an illegal UTF-16 sequence."));
     
    266266    if (number >= mantissaOverflowLowerBound) {
    267267        if (radix == 10)
    268             number = WTF::strtod(s.substr(firstDigitPosition, p - firstDigitPosition).utf8().data(), 0);
     268            number = WTF::strtod(s.substr(firstDigitPosition, p - firstDigitPosition).UTF8String().data(), 0);
    269269        else if (radix == 2 || radix == 4 || radix == 8 || radix == 16 || radix == 32)
    270             number = parseIntOverflow(s.substr(firstDigitPosition, p - firstDigitPosition).utf8().data(), p - firstDigitPosition, radix);
     270            number = parseIntOverflow(s.substr(firstDigitPosition, p - firstDigitPosition).UTF8String().data(), p - firstDigitPosition, radix);
    271271    }
    272272
     
    454454EncodedJSValue JSC_HOST_CALL globalFuncJSCPrint(ExecState* exec)
    455455{
    456     CString string = exec->argument(0).toString(exec).utf8();
     456    CString string = exec->argument(0).toString(exec).UTF8String();
    457457    puts(string.data());
    458458    return JSValue::encode(jsUndefined());
  • trunk/JavaScriptCore/runtime/JSString.h

    r65295 r65302  
    192192        {
    193193            ASSERT(!m_value.isNull());
    194             Heap::heap(this)->reportExtraMemoryCost(value.impl()->cost());
     194            Heap::heap(this)->reportExtraMemoryCost(value.cost());
    195195        }
    196196
     
    309309            m_other.m_finalizerCallback = finalizer;
    310310            m_other.m_finalizerContext = context;
    311             Heap::heap(this)->reportExtraMemoryCost(value.impl()->cost());
     311            Heap::heap(this)->reportExtraMemoryCost(value.cost());
    312312        }
    313313
  • trunk/JavaScriptCore/runtime/UString.cpp

    r65295 r65302  
    258258    }
    259259
     260    // FIXME: If tolerateTrailingJunk is true, then we want to tolerate junk
     261    // after the number, even if it contains invalid UTF-16 sequences. So we
     262    // shouldn't use the UTF8String function, which returns null when it
     263    // encounters invalid UTF-16. Further, we have no need to convert the
     264    // non-ASCII characters to UTF-8, so the UTF8String does quite a bit of
     265    // unnecessary work.
     266
     267    // FIXME: The space skipping code below skips only ASCII spaces, but callers
     268    // need to skip all StrWhiteSpace. The isStrWhiteSpace function does the
     269    // right thing but requires UChar, not char, for its argument.
     270
    260271    const UChar* data = this->characters();
    261272    const UChar* end = data + size;
     
    584595}
    585596
    586 // Helper to write a three-byte UTF-8 code point to the buffer, caller must check room is available.
    587 static inline void putUTF8Triple(char*& buffer, UChar ch)
    588 {
    589     ASSERT(ch >= 0x0800);
    590     *buffer++ = static_cast<char>(((ch >> 12) & 0x0F) | 0xE0);
    591     *buffer++ = static_cast<char>(((ch >> 6) & 0x3F) | 0x80);
    592     *buffer++ = static_cast<char>((ch & 0x3F) | 0x80);
    593 }
    594 
    595 CString UString::utf8(bool strict) const
    596 {
    597     unsigned length = this->length();
    598     const UChar* characters = this->characters();
    599 
    600     // Allocate a buffer big enough to hold all the characters
    601     // (an individual UTF-16 UChar can only expand to 3 UTF-8 bytes).
    602     // Optimization ideas, if we find this function is hot:
    603     //  * We could speculatively create a CStringBuffer to contain 'length'
    604     //    characters, and resize if necessary (i.e. if the buffer contains
    605     //    non-ascii characters). (Alternatively, scan the buffer first for
    606     //    ascii characters, so we know this will be sufficient).
    607     //  * We could allocate a CStringBuffer with an appropriate size to
    608     //    have a good chance of being able to write the string into the
    609     //    buffer without reallocing (say, 1.5 x length).
    610     Vector<char, 1024> bufferVector(length * 3);
    611 
    612     char* buffer = bufferVector.data();
    613     ConversionResult result = convertUTF16ToUTF8(&characters, characters + length, &buffer, buffer + bufferVector.size(), strict);
    614     ASSERT(result != targetExhausted); // (length * 3) should be sufficient for any conversion
    615 
    616     if (result == sourceIllegal) // Only produced from strict conversion.
     597CString UString::UTF8String(bool strict) const
     598{
     599    // Allocate a buffer big enough to hold all the characters.
     600    const unsigned len = length();
     601    Vector<char, 1024> buffer(len * 3);
     602
     603    // Convert to runs of 8-bit characters.
     604    char* p = buffer.data();
     605    const UChar* d = reinterpret_cast<const UChar*>(&characters()[0]);
     606    ConversionResult result = convertUTF16ToUTF8(&d, d + len, &p, p + buffer.size(), strict);
     607    if (result != conversionOK)
    617608        return CString();
    618609
    619     // If a high surrogate is left unconverted, treat it the same was as an unpaired high surrogate
    620     // would have been handled in the middle of a string with non-strict conversion - which is to say,
    621     // simply encode it to UTF-8.
    622     if (result == sourceExhausted) {
    623         // This should be one unpaired high surrogate.
    624         ASSERT((characters + 1) == (this->characters() + length));
    625         ASSERT((*characters >= 0xD800) && (*characters <= 0xDBFF));
    626         // There should be room left, since one UChar hasn't been converted.
    627         ASSERT((buffer + 3) <= (buffer + bufferVector.size()));
    628         putUTF8Triple(buffer, *characters);
    629     }
    630 
    631     return CString(bufferVector.data(), buffer - bufferVector.data());
     610    return CString(buffer.data(), p - buffer.data());
    632611}
    633612
  • trunk/JavaScriptCore/runtime/UString.h

    r65295 r65302  
    3939namespace JSC {
    4040
     41using WTF::PlacementNewAdoptType;
     42using WTF::PlacementNewAdopt;
     43
    4144class UString {
    4245public:
     
    6164    UString(RefPtr<StringImpl> impl) : m_impl(impl) { }
    6265
    63     // Inline the destructor.
    64     ALWAYS_INLINE ~UString() { }
    65 
    6666    void swap(UString& o) { m_impl.swap(o.m_impl); }
    6767
     
    6969    static UString adopt(Vector<UChar, inlineCapacity>& vector) { return StringImpl::adopt(vector); }
    7070
    71     bool isNull() const { return !m_impl; }
    72     bool isEmpty() const { return !m_impl || !m_impl->length(); }
    73 
    74     StringImpl* impl() const { return m_impl.get(); }
    75 
    76     unsigned length() const
    77     {
    78         if (!m_impl)
    79             return 0;
    80         return m_impl->length();
    81     }
    82 
    83     const UChar* characters() const
    84     {
    85         if (!m_impl)
    86             return 0;
    87         return m_impl->characters();
    88     }
    89 
    90     CString utf8(bool strict = false) const;
    91 
    92     UChar operator[](unsigned index) const
    93     {
    94         if (!m_impl || index >= m_impl->length())
    95             return 0;
    96         return m_impl->characters()[index];
    97     }
    98 
    9971    static UString number(int);
     72    static UString number(long long);
    10073    static UString number(unsigned);
    10174    static UString number(long);
    102     static UString number(long long);
    10375    static UString number(double);
    10476
    105 
     77    // NOTE: This method should only be used for *debugging* purposes as it
     78    // is neither Unicode safe nor free from side effects nor thread-safe.
     79    char* ascii() const;
     80
     81    /**
     82     * Convert the string to UTF-8, assuming it is UTF-16 encoded.
     83     * In non-strict mode, this function is tolerant of badly formed UTF-16, it
     84     * can create UTF-8 strings that are invalid because they have characters in
     85     * the range U+D800-U+DDFF, U+FFFE, or U+FFFF, but the UTF-8 string is
     86     * guaranteed to be otherwise valid.
     87     * In strict mode, error is returned as null CString.
     88     */
     89    CString UTF8String(bool strict = false) const;
     90
     91    unsigned length() const
     92    {
     93        if (!m_impl)
     94            return 0;
     95        return m_impl->length();
     96    }
     97
     98    const UChar* characters() const
     99    {
     100        if (!m_impl)
     101            return 0;
     102        return m_impl->characters();
     103    }
     104
     105    UChar operator[](unsigned index) const
     106    {
     107        if (!m_impl || index >= m_impl->length())
     108            return 0;
     109        return m_impl->characters()[index];
     110    }
    106111
    107112    double toDouble(bool tolerateTrailingJunk, bool tolerateEmptyString) const;
     
    112117    uint32_t toUInt32(bool* ok, bool tolerateEmptyString) const;
    113118    uint32_t toStrictUInt32(bool* ok = 0) const;
     119
     120    unsigned toArrayIndex(bool* ok = 0) const;
    114121
    115122    static const unsigned NotFound = 0xFFFFFFFFu;
     
    121128    UString substr(unsigned pos = 0, unsigned len = 0xFFFFFFFF) const;
    122129
    123     // NOTE: This method should only be used for *debugging* purposes as it
    124     // is neither Unicode safe nor free from side effects nor thread-safe.
    125     char* ascii() const;
    126 
     130    bool isNull() const { return !m_impl; }
     131    bool isEmpty() const { return !m_impl || !m_impl->length(); }
     132
     133    StringImpl* impl() const { return m_impl.get(); }
     134
     135    size_t cost() const
     136    {
     137        if (!m_impl)
     138            return 0;
     139        return m_impl->cost();
     140    }
     141
     142    ALWAYS_INLINE ~UString() { }
    127143private:
    128144    RefPtr<StringImpl> m_impl;
     
    202218}
    203219
     220// Rule from ECMA 15.2 about what an array index is.
     221// Must exactly match string form of an unsigned integer, and be less than 2^32 - 1.
     222inline unsigned UString::toArrayIndex(bool* ok) const
     223{
     224    unsigned i = toStrictUInt32(ok);
     225    if (ok && i >= 0xFFFFFFFFU)
     226        *ok = false;
     227    return i;
     228}
     229
    204230// We'd rather not do shared substring append for small strings, since
    205231// this runs too much risk of a tiny initial string holding down a
Note: See TracChangeset for help on using the changeset viewer.