Ignore:
Timestamp:
Sep 16, 2012, 12:22:46 AM (13 years ago)
Author:
[email protected]
Message:

JSObject.cpp and JSArray.cpp have inconsistent tests for the invalid array index case
https://bugs.webkit.org/show_bug.cgi?id=96878

Reviewed by Sam Weinig.

Removed the uses of UNLIKELY() because I don't believe they are buying us anything,
since we're already on the slow path. Also found other places where we're testing for
the invalid array index case using unusual predicates rather than just using
MAX_ARRAY_INDEX. With this change, I believe that all of our tests for invalid
array indices (i.e. indices that should be treated as non-indexed properties)
uniformly use MAX_ARRAY_INDEX and PropertyName::NotAnIndex.

  • runtime/JSArray.cpp:

(JSC::JSArray::push):

  • runtime/JSObject.cpp:

(JSC::JSObject::putByIndex):
(JSC::JSObject::defineOwnIndexedProperty):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/JSArray.cpp

    r128680 r128706  
    478478        }
    479479
    480         // Pushing to an array of length 2^32-1 stores the property, but throws a range error.
    481         if (UNLIKELY(storage->length() == 0xFFFFFFFFu)) {
     480        // Pushing to an array of invalid length (2^31-1) stores the property, but throws a range error.
     481        if (storage->length() > MAX_ARRAY_INDEX) {
    482482            methodTable()->putByIndex(this, exec, storage->length(), value, true);
    483483            // Per ES5.1 15.4.4.7 step 6 & 15.4.5.1 step 3.d.
Note: See TracChangeset for help on using the changeset viewer.