Title: [128706] trunk/Source/_javascript_Core
- Revision
- 128706
- Author
- [email protected]
- Date
- 2012-09-16 00:22:46 -0700 (Sun, 16 Sep 2012)
Log 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):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (128705 => 128706)
--- trunk/Source/_javascript_Core/ChangeLog 2012-09-16 06:20:32 UTC (rev 128705)
+++ trunk/Source/_javascript_Core/ChangeLog 2012-09-16 07:22:46 UTC (rev 128706)
@@ -1,3 +1,23 @@
+2012-09-16 Filip Pizlo <[email protected]>
+
+ 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):
+
2012-09-15 Filip Pizlo <[email protected]>
Following the Butterfly refactoring, the comment for lastArraySize was not updated
Modified: trunk/Source/_javascript_Core/runtime/JSArray.cpp (128705 => 128706)
--- trunk/Source/_javascript_Core/runtime/JSArray.cpp 2012-09-16 06:20:32 UTC (rev 128705)
+++ trunk/Source/_javascript_Core/runtime/JSArray.cpp 2012-09-16 07:22:46 UTC (rev 128706)
@@ -477,8 +477,8 @@
return;
}
- // Pushing to an array of length 2^32-1 stores the property, but throws a range error.
- if (UNLIKELY(storage->length() == 0xFFFFFFFFu)) {
+ // Pushing to an array of invalid length (2^31-1) stores the property, but throws a range error.
+ if (storage->length() > MAX_ARRAY_INDEX) {
methodTable()->putByIndex(this, exec, storage->length(), value, true);
// Per ES5.1 15.4.4.7 step 6 & 15.4.5.1 step 3.d.
if (!exec->hadException())
Modified: trunk/Source/_javascript_Core/runtime/JSObject.cpp (128705 => 128706)
--- trunk/Source/_javascript_Core/runtime/JSObject.cpp 2012-09-16 06:20:32 UTC (rev 128705)
+++ trunk/Source/_javascript_Core/runtime/JSObject.cpp 2012-09-16 07:22:46 UTC (rev 128706)
@@ -347,7 +347,7 @@
JSObject* thisObject = jsCast<JSObject*>(cell);
thisObject->checkIndexingConsistency();
- if (UNLIKELY(propertyName > MAX_ARRAY_INDEX)) {
+ if (propertyName > MAX_ARRAY_INDEX) {
PutPropertySlot slot(shouldThrow);
thisObject->methodTable()->put(thisObject, exec, Identifier::from(exec, propertyName), value, slot);
return;
@@ -980,7 +980,7 @@
// Defined in ES5.1 8.12.9
bool JSObject::defineOwnIndexedProperty(ExecState* exec, unsigned index, PropertyDescriptor& descriptor, bool throwException)
{
- ASSERT(index != 0xFFFFFFFF);
+ ASSERT(index <= MAX_ARRAY_INDEX);
if (!inSparseIndexingMode()) {
// Fast case: we're putting a regular property to a regular array
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes