Diff
Modified: trunk/JSTests/ChangeLog (231989 => 231990)
--- trunk/JSTests/ChangeLog 2018-05-18 23:07:51 UTC (rev 231989)
+++ trunk/JSTests/ChangeLog 2018-05-18 23:16:09 UTC (rev 231990)
@@ -1,3 +1,15 @@
+2018-05-18 Keith Miller <[email protected]>
+
+ op_in should mark if it sees out of bounds accesses
+ https://bugs.webkit.org/show_bug.cgi?id=185792
+
+ Reviewed by Filip Pizlo.
+
+ * stress/has-indexed-property-array-storage-ftl.js:
+ (test2):
+ * stress/has-indexed-property-slow-put-array-storage-ftl.js:
+ (test2):
+
2018-05-18 Mark Lam <[email protected]>
Add missing exception check.
Modified: trunk/JSTests/stress/has-indexed-property-array-storage-ftl.js (231989 => 231990)
--- trunk/JSTests/stress/has-indexed-property-array-storage-ftl.js 2018-05-18 23:07:51 UTC (rev 231989)
+++ trunk/JSTests/stress/has-indexed-property-array-storage-ftl.js 2018-05-18 23:16:09 UTC (rev 231990)
@@ -32,11 +32,11 @@
function test2(array)
{
didFTLCompile = ftlTrue();
- return 2 in array;
+ return 13 in array;
}
noInline(test2);
-var array1 = [1, 2, 3, 4];
+var array1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14];
ensureArrayStorage(array1);
var array2 = [1, 2];
ensureArrayStorage(array2);
Modified: trunk/JSTests/stress/has-indexed-property-slow-put-array-storage-ftl.js (231989 => 231990)
--- trunk/JSTests/stress/has-indexed-property-slow-put-array-storage-ftl.js 2018-05-18 23:07:51 UTC (rev 231989)
+++ trunk/JSTests/stress/has-indexed-property-slow-put-array-storage-ftl.js 2018-05-18 23:16:09 UTC (rev 231990)
@@ -43,11 +43,11 @@
function test2(array)
{
didFTLCompile = ftlTrue();
- return 2 in array;
+ return 9 in array;
}
noInline(test2);
-var array1 = [1, 2, 3, 4];
+var array1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
array1.__proto__ = object;
ensureArrayStorage(array1);
var array2 = [1, 2];
Modified: trunk/Source/_javascript_Core/ChangeLog (231989 => 231990)
--- trunk/Source/_javascript_Core/ChangeLog 2018-05-18 23:07:51 UTC (rev 231989)
+++ trunk/Source/_javascript_Core/ChangeLog 2018-05-18 23:16:09 UTC (rev 231990)
@@ -1,3 +1,19 @@
+2018-05-18 Keith Miller <[email protected]>
+
+ op_in should mark if it sees out of bounds accesses
+ https://bugs.webkit.org/show_bug.cgi?id=185792
+
+ Reviewed by Filip Pizlo.
+
+ This would used to cause us to OSR loop since we would always speculate
+ we were in bounds in HasIndexedProperty.
+
+ * bytecode/ArrayProfile.cpp:
+ (JSC::ArrayProfile::observeIndexedRead):
+ * bytecode/ArrayProfile.h:
+ * runtime/CommonSlowPaths.h:
+ (JSC::CommonSlowPaths::opIn):
+
2018-05-18 Mark Lam <[email protected]>
Add missing exception check.
Modified: trunk/Source/_javascript_Core/bytecode/ArrayProfile.cpp (231989 => 231990)
--- trunk/Source/_javascript_Core/bytecode/ArrayProfile.cpp 2018-05-18 23:07:51 UTC (rev 231989)
+++ trunk/Source/_javascript_Core/bytecode/ArrayProfile.cpp 2018-05-18 23:16:09 UTC (rev 231990)
@@ -121,6 +121,23 @@
m_usesOriginalArrayStructures = false;
}
+void ArrayProfile::observeIndexedRead(VM& vm, JSCell* cell, unsigned index)
+{
+ m_lastSeenStructureID = cell->structureID();
+
+ if (JSObject* object = jsDynamicCast<JSObject*>(vm, cell)) {
+ if (hasAnyArrayStorage(object->indexingType()) && index >= object->getVectorLength())
+ setOutOfBounds();
+ else if (index >= object->getArrayLength())
+ setOutOfBounds();
+ }
+
+ if (JSString* string = jsDynamicCast<JSString*>(vm, cell)) {
+ if (index >= string->length())
+ setOutOfBounds();
+ }
+}
+
CString ArrayProfile::briefDescription(const ConcurrentJSLocker& locker, CodeBlock* codeBlock)
{
computeUpdatedPrediction(locker, codeBlock);
Modified: trunk/Source/_javascript_Core/bytecode/ArrayProfile.h (231989 => 231990)
--- trunk/Source/_javascript_Core/bytecode/ArrayProfile.h 2018-05-18 23:07:51 UTC (rev 231989)
+++ trunk/Source/_javascript_Core/bytecode/ArrayProfile.h 2018-05-18 23:16:09 UTC (rev 231990)
@@ -214,11 +214,13 @@
{
m_lastSeenStructureID = structure->id();
}
-
+
void computeUpdatedPrediction(const ConcurrentJSLocker&, CodeBlock*);
void computeUpdatedPrediction(const ConcurrentJSLocker&, CodeBlock*, Structure* lastSeenStructure);
void observeArrayMode(ArrayModes mode) { m_observedArrayModes |= mode; }
+ void observeIndexedRead(VM&, JSCell*, unsigned index);
+
ArrayModes observedArrayModes(const ConcurrentJSLocker&) const { return m_observedArrayModes; }
bool mayInterceptIndexedAccesses(const ConcurrentJSLocker&) const { return m_mayInterceptIndexedAccesses; }
Modified: trunk/Source/_javascript_Core/runtime/CommonSlowPaths.h (231989 => 231990)
--- trunk/Source/_javascript_Core/runtime/CommonSlowPaths.h 2018-05-18 23:07:51 UTC (rev 231989)
+++ trunk/Source/_javascript_Core/runtime/CommonSlowPaths.h 2018-05-18 23:16:09 UTC (rev 231990)
@@ -100,6 +100,8 @@
uint32_t i;
if (propName.getUInt32(i)) {
+ if (arrayProfile)
+ arrayProfile->observeIndexedRead(vm, baseObj, i);
scope.release();
return baseObj->hasProperty(exec, i);
}