+IndexingType toIndexingShape(Array::Type type)
+{
+ switch (type) {
+ case Array::Int32:
+ return Int32Shape;
+ case Array::Double:
+ return DoubleShape;
+ case Array::Contiguous:
+ return ContiguousShape;
+ case Array::ArrayStorage:
+ return ArrayStorageShape;
+ case Array::SlowPutArrayStorage:
+ return SlowPutArrayStorageShape;
+ default:
+ return NoIndexingShape;
+ }
+}
+
+TypedArrayType toTypedArrayType(Array::Type type)
+{
+ switch (type) {
+ case Array::Int8Array:
+ return TypeInt8;
+ case Array::Int16Array:
+ return TypeInt16;
+ case Array::Int32Array:
+ return TypeInt32;
+ case Array::Uint8Array:
+ return TypeUint8;
+ case Array::Uint8ClampedArray:
+ return TypeUint8Clamped;
+ case Array::Uint16Array:
+ return TypeUint16;
+ case Array::Uint32Array:
+ return TypeUint32;
+ case Array::Float32Array:
+ return TypeFloat32;
+ case Array::Float64Array:
+ return TypeFloat64;
+ default:
+ return NotTypedArray;
+ }
+}
+
+Array::Type toArrayType(TypedArrayType type)
+{
+ switch (type) {
+ case TypeInt8:
+ return Array::Int8Array;
+ case TypeInt16:
+ return Array::Int16Array;
+ case TypeInt32:
+ return Array::Int32Array;
+ case TypeUint8:
+ return Array::Uint8Array;
+ case TypeUint8Clamped:
+ return Array::Uint8ClampedArray;
+ case TypeUint16:
+ return Array::Uint16Array;
+ case TypeUint32:
+ return Array::Uint32Array;
+ case TypeFloat32:
+ return Array::Float32Array;
+ case TypeFloat64:
+ return Array::Float64Array;
+ default:
+ return Array::Generic;
+ }
+}
+
+bool permitsBoundsCheckLowering(Array::Type type)
+{
+ switch (type) {
+ case Array::Int32:
+ case Array::Double:
+ case Array::Contiguous:
+ case Array::Int8Array:
+ case Array::Int16Array:
+ case Array::Int32Array:
+ case Array::Uint8Array:
+ case Array::Uint8ClampedArray:
+ case Array::Uint16Array:
+ case Array::Uint32Array:
+ case Array::Float32Array:
+ case Array::Float64Array:
+ return true;
+ default:
+ // These don't allow for bounds check lowering either because the bounds
+ // check involves something other than GetArrayLength (like ArrayStorage),
+ // or because the bounds check isn't a speculation (like String, sort of),
+ // or because the type implies an impure access.
+ return false;
+ }
+}
+
+bool ArrayMode::permitsBoundsCheckLowering() const
+{
+ return DFG::permitsBoundsCheckLowering(type()) && isInBounds();
+}
+