Changeset 232070 in webkit for trunk/Source/JavaScriptCore/dfg/DFGArrayMode.cpp
- Timestamp:
- May 22, 2018, 11:04:31 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/dfg/DFGArrayMode.cpp
r230078 r232070 43 43 else 44 44 nonArray = Array::NonArray; 45 45 46 auto handleContiguousModes = [&] (Array::Type type, ArrayModes observed) { 47 Array::Class isArray; 48 Array::Conversion converts; 49 50 RELEASE_ASSERT((observed & (asArrayModes(toIndexingShape(type)) | asArrayModes(toIndexingShape(type) | ArrayClass) | asArrayModes(toIndexingShape(type) | ArrayClass | CopyOnWrite))) == observed); 51 52 if (observed & asArrayModes(toIndexingShape(type))) { 53 if ((observed & asArrayModes(toIndexingShape(type))) == observed) 54 isArray = nonArray; 55 else 56 isArray = Array::PossiblyArray; 57 } else 58 isArray = Array::Array; 59 60 if (action == Array::Write && (observed & asArrayModes(toIndexingShape(type) | ArrayClass | CopyOnWrite))) 61 converts = Array::Convert; 62 else 63 converts = Array::AsIs; 64 65 return ArrayMode(type, isArray, converts, action).withProfile(locker, profile, makeSafe); 66 }; 67 46 68 ArrayModes observed = profile->observedArrayModes(locker); 47 69 switch (observed) { … … 50 72 case asArrayModes(NonArray): 51 73 if (action == Array::Write && !profile->mayInterceptIndexedAccesses(locker)) 52 return ArrayMode(Array::SelectUsingArguments, nonArray, Array::OutOfBounds, Array::Convert );53 return ArrayMode(Array::SelectUsingPredictions, nonArray ).withSpeculationFromProfile(locker, profile, makeSafe);74 return ArrayMode(Array::SelectUsingArguments, nonArray, Array::OutOfBounds, Array::Convert, action); 75 return ArrayMode(Array::SelectUsingPredictions, nonArray, action).withSpeculationFromProfile(locker, profile, makeSafe); 54 76 55 77 case asArrayModes(ArrayWithUndecided): 56 78 if (action == Array::Write) 57 return ArrayMode(Array::SelectUsingArguments, Array::Array, Array::OutOfBounds, Array::Convert );58 return ArrayMode(Array::Undecided, Array::Array, Array::OutOfBounds, Array::AsIs ).withProfile(locker, profile, makeSafe);79 return ArrayMode(Array::SelectUsingArguments, Array::Array, Array::OutOfBounds, Array::Convert, action); 80 return ArrayMode(Array::Undecided, Array::Array, Array::OutOfBounds, Array::AsIs, action).withProfile(locker, profile, makeSafe); 59 81 60 82 case asArrayModes(NonArray) | asArrayModes(ArrayWithUndecided): 61 83 if (action == Array::Write && !profile->mayInterceptIndexedAccesses(locker)) 62 return ArrayMode(Array::SelectUsingArguments, Array::PossiblyArray, Array::OutOfBounds, Array::Convert );63 return ArrayMode(Array::SelectUsingPredictions ).withSpeculationFromProfile(locker, profile, makeSafe);84 return ArrayMode(Array::SelectUsingArguments, Array::PossiblyArray, Array::OutOfBounds, Array::Convert, action); 85 return ArrayMode(Array::SelectUsingPredictions, action).withSpeculationFromProfile(locker, profile, makeSafe); 64 86 65 87 case asArrayModes(NonArrayWithInt32): 66 return ArrayMode(Array::Int32, nonArray, Array::AsIs).withProfile(locker, profile, makeSafe);67 88 case asArrayModes(ArrayWithInt32): 68 return ArrayMode(Array::Int32, Array::Array, Array::AsIs).withProfile(locker, profile, makeSafe);69 89 case asArrayModes(NonArrayWithInt32) | asArrayModes(ArrayWithInt32): 70 return ArrayMode(Array::Int32, Array::PossiblyArray, Array::AsIs).withProfile(locker, profile, makeSafe); 90 case asArrayModes(NonArrayWithInt32) | asArrayModes(CopyOnWriteArrayWithInt32): 91 case asArrayModes(ArrayWithInt32) | asArrayModes(CopyOnWriteArrayWithInt32): 92 case asArrayModes(NonArrayWithInt32) | asArrayModes(ArrayWithInt32) | asArrayModes(CopyOnWriteArrayWithInt32): 93 return handleContiguousModes(Array::Int32, observed); 71 94 72 95 case asArrayModes(NonArrayWithDouble): 73 return ArrayMode(Array::Double, nonArray, Array::AsIs).withProfile(locker, profile, makeSafe);74 96 case asArrayModes(ArrayWithDouble): 75 return ArrayMode(Array::Double, Array::Array, Array::AsIs).withProfile(locker, profile, makeSafe);76 97 case asArrayModes(NonArrayWithDouble) | asArrayModes(ArrayWithDouble): 77 return ArrayMode(Array::Double, Array::PossiblyArray, Array::AsIs).withProfile(locker, profile, makeSafe); 98 case asArrayModes(NonArrayWithDouble) | asArrayModes(CopyOnWriteArrayWithDouble): 99 case asArrayModes(ArrayWithDouble) | asArrayModes(CopyOnWriteArrayWithDouble): 100 case asArrayModes(NonArrayWithDouble) | asArrayModes(ArrayWithDouble) | asArrayModes(CopyOnWriteArrayWithDouble): 101 return handleContiguousModes(Array::Double, observed); 78 102 79 103 case asArrayModes(NonArrayWithContiguous): 80 return ArrayMode(Array::Contiguous, nonArray, Array::AsIs).withProfile(locker, profile, makeSafe);81 104 case asArrayModes(ArrayWithContiguous): 82 return ArrayMode(Array::Contiguous, Array::Array, Array::AsIs).withProfile(locker, profile, makeSafe);83 105 case asArrayModes(NonArrayWithContiguous) | asArrayModes(ArrayWithContiguous): 84 return ArrayMode(Array::Contiguous, Array::PossiblyArray, Array::AsIs).withProfile(locker, profile, makeSafe); 106 case asArrayModes(NonArrayWithContiguous) | asArrayModes(CopyOnWriteArrayWithContiguous): 107 case asArrayModes(ArrayWithContiguous) | asArrayModes(CopyOnWriteArrayWithContiguous): 108 case asArrayModes(NonArrayWithContiguous) | asArrayModes(ArrayWithContiguous) | asArrayModes(CopyOnWriteArrayWithContiguous): 109 return handleContiguousModes(Array::Contiguous, observed); 85 110 86 111 case asArrayModes(NonArrayWithArrayStorage): 87 return ArrayMode(Array::ArrayStorage, nonArray, Array::AsIs ).withProfile(locker, profile, makeSafe);112 return ArrayMode(Array::ArrayStorage, nonArray, Array::AsIs, action).withProfile(locker, profile, makeSafe); 88 113 case asArrayModes(NonArrayWithSlowPutArrayStorage): 89 114 case asArrayModes(NonArrayWithArrayStorage) | asArrayModes(NonArrayWithSlowPutArrayStorage): 90 return ArrayMode(Array::SlowPutArrayStorage, nonArray, Array::AsIs ).withProfile(locker, profile, makeSafe);115 return ArrayMode(Array::SlowPutArrayStorage, nonArray, Array::AsIs, action).withProfile(locker, profile, makeSafe); 91 116 case asArrayModes(ArrayWithArrayStorage): 92 return ArrayMode(Array::ArrayStorage, Array::Array, Array::AsIs ).withProfile(locker, profile, makeSafe);117 return ArrayMode(Array::ArrayStorage, Array::Array, Array::AsIs, action).withProfile(locker, profile, makeSafe); 93 118 case asArrayModes(ArrayWithSlowPutArrayStorage): 94 119 case asArrayModes(ArrayWithArrayStorage) | asArrayModes(ArrayWithSlowPutArrayStorage): 95 return ArrayMode(Array::SlowPutArrayStorage, Array::Array, Array::AsIs ).withProfile(locker, profile, makeSafe);120 return ArrayMode(Array::SlowPutArrayStorage, Array::Array, Array::AsIs, action).withProfile(locker, profile, makeSafe); 96 121 case asArrayModes(NonArrayWithArrayStorage) | asArrayModes(ArrayWithArrayStorage): 97 return ArrayMode(Array::ArrayStorage, Array::PossiblyArray, Array::AsIs ).withProfile(locker, profile, makeSafe);122 return ArrayMode(Array::ArrayStorage, Array::PossiblyArray, Array::AsIs, action).withProfile(locker, profile, makeSafe); 98 123 case asArrayModes(NonArrayWithSlowPutArrayStorage) | asArrayModes(ArrayWithSlowPutArrayStorage): 99 124 case asArrayModes(NonArrayWithArrayStorage) | asArrayModes(ArrayWithArrayStorage) | asArrayModes(NonArrayWithSlowPutArrayStorage) | asArrayModes(ArrayWithSlowPutArrayStorage): 100 return ArrayMode(Array::SlowPutArrayStorage, Array::PossiblyArray, Array::AsIs ).withProfile(locker, profile, makeSafe);125 return ArrayMode(Array::SlowPutArrayStorage, Array::PossiblyArray, Array::AsIs, action).withProfile(locker, profile, makeSafe); 101 126 case Int8ArrayMode: 102 return ArrayMode(Array::Int8Array, nonArray, Array::AsIs ).withProfile(locker, profile, makeSafe);127 return ArrayMode(Array::Int8Array, nonArray, Array::AsIs, action).withProfile(locker, profile, makeSafe); 103 128 case Int16ArrayMode: 104 return ArrayMode(Array::Int16Array, nonArray, Array::AsIs ).withProfile(locker, profile, makeSafe);129 return ArrayMode(Array::Int16Array, nonArray, Array::AsIs, action).withProfile(locker, profile, makeSafe); 105 130 case Int32ArrayMode: 106 return ArrayMode(Array::Int32Array, nonArray, Array::AsIs ).withProfile(locker, profile, makeSafe);131 return ArrayMode(Array::Int32Array, nonArray, Array::AsIs, action).withProfile(locker, profile, makeSafe); 107 132 case Uint8ArrayMode: 108 return ArrayMode(Array::Uint8Array, nonArray, Array::AsIs ).withProfile(locker, profile, makeSafe);133 return ArrayMode(Array::Uint8Array, nonArray, Array::AsIs, action).withProfile(locker, profile, makeSafe); 109 134 case Uint8ClampedArrayMode: 110 return ArrayMode(Array::Uint8ClampedArray, nonArray, Array::AsIs ).withProfile(locker, profile, makeSafe);135 return ArrayMode(Array::Uint8ClampedArray, nonArray, Array::AsIs, action).withProfile(locker, profile, makeSafe); 111 136 case Uint16ArrayMode: 112 return ArrayMode(Array::Uint16Array, nonArray, Array::AsIs ).withProfile(locker, profile, makeSafe);137 return ArrayMode(Array::Uint16Array, nonArray, Array::AsIs, action).withProfile(locker, profile, makeSafe); 113 138 case Uint32ArrayMode: 114 return ArrayMode(Array::Uint32Array, nonArray, Array::AsIs ).withProfile(locker, profile, makeSafe);139 return ArrayMode(Array::Uint32Array, nonArray, Array::AsIs, action).withProfile(locker, profile, makeSafe); 115 140 case Float32ArrayMode: 116 return ArrayMode(Array::Float32Array, nonArray, Array::AsIs ).withProfile(locker, profile, makeSafe);141 return ArrayMode(Array::Float32Array, nonArray, Array::AsIs, action).withProfile(locker, profile, makeSafe); 117 142 case Float64ArrayMode: 118 return ArrayMode(Array::Float64Array, nonArray, Array::AsIs ).withProfile(locker, profile, makeSafe);143 return ArrayMode(Array::Float64Array, nonArray, Array::AsIs, action).withProfile(locker, profile, makeSafe); 119 144 120 145 default: 121 146 // If we have seen multiple TypedArray types, or a TypedArray and non-typed array, it doesn't make sense to try to convert the object since you can't convert typed arrays. 122 147 if (observed & ALL_TYPED_ARRAY_MODES) 123 return ArrayMode(Array::Generic, nonArray, Array::AsIs ).withProfile(locker, profile, makeSafe);148 return ArrayMode(Array::Generic, nonArray, Array::AsIs, action).withProfile(locker, profile, makeSafe); 124 149 125 150 if ((observed & asArrayModes(NonArray)) && profile->mayInterceptIndexedAccesses(locker)) … … 151 176 arrayClass = Array::PossiblyArray; 152 177 153 return ArrayMode(type, arrayClass, Array::Convert ).withProfile(locker, profile, makeSafe);178 return ArrayMode(type, arrayClass, Array::Convert, action).withProfile(locker, profile, makeSafe); 154 179 } 155 180 } … … 172 197 // realized that the callsite could not have possibly executed. It may be worthwhile 173 198 // to fix that, but for now I'm leaving it as-is. 174 return ArrayMode(Array::ForceExit );199 return ArrayMode(Array::ForceExit, action()); 175 200 } 176 201 177 202 if (!isInt32Speculation(index)) 178 return ArrayMode(Array::Generic );203 return ArrayMode(Array::Generic, action()); 179 204 180 205 // If we had exited because of an exotic object behavior, then don't try to specialize. 181 206 if (graph.hasExitSite(node->origin.semantic, ExoticObjectMode)) 182 return ArrayMode(Array::Generic );207 return ArrayMode(Array::Generic, action()); 183 208 184 209 // Note: our profiling currently doesn't give us good information in case we have … … 197 222 // which we can't model as a simple store to the typed array since typed array indexed properties 198 223 // are non-configurable. 199 return ArrayMode(Array::Generic );224 return ArrayMode(Array::Generic, action()); 200 225 } 201 226 return result; … … 228 253 return withSpeculation(Array::SaneChain); 229 254 } 230 return ArrayMode(Array::Generic );255 return ArrayMode(Array::Generic, action()); 231 256 } 232 257 case Array::Int32: … … 273 298 // https://bugs.webkit.org/show_bug.cgi?id=179596 274 299 if (type == Array::DirectArguments) 275 return ArrayMode(type, Array::NonArray, Array::OutOfBounds, Array::AsIs );276 return ArrayMode(Array::Generic );300 return ArrayMode(type, Array::NonArray, Array::OutOfBounds, Array::AsIs, action()); 301 return ArrayMode(Array::Generic, action()); 277 302 } 278 303 if (isX86() && is32Bit() && isScopedArgumentsSpeculation(base)) 279 return ArrayMode(Array::Generic );304 return ArrayMode(Array::Generic, action()); 280 305 return withType(type); 281 306 } … … 323 348 324 349 if (type() == Array::Unprofiled) 325 return ArrayMode(Array::ForceExit );326 return ArrayMode(Array::Generic );350 return ArrayMode(Array::ForceExit, action()); 351 return ArrayMode(Array::Generic, action()); 327 352 } 328 353 … … 383 408 if ((structure->indexingType() & IndexingShapeMask) != shape) 384 409 return false; 410 if (isCopyOnWrite(structure->indexingMode()) && action() == Array::Write) 411 return false; 385 412 if (!(structure->indexingType() & IsArray)) 386 413 return false; … … 398 425 for (unsigned i = value.m_structure.size(); i--;) { 399 426 RegisteredStructure structure = value.m_structure[i]; 400 if ((structure->indexingType() & IndexingShapeMask) != shape) 427 if ((structure->indexingMode() & IndexingShapeMask) != shape) 428 return false; 429 if (isCopyOnWrite(structure->indexingMode()) && action() == Array::Write) 401 430 return false; 402 431 if (!(structure->indexingType() & IsArray)) … … 413 442 for (unsigned i = value.m_structure.size(); i--;) { 414 443 RegisteredStructure structure = value.m_structure[i]; 415 if ((structure->indexingType() & IndexingShapeMask) != shape) 444 if ((structure->indexingMode() & IndexingShapeMask) != shape) 445 return false; 446 if (isCopyOnWrite(structure->indexingMode()) && action() == Array::Write) 416 447 return false; 417 448 }
Note:
See TracChangeset
for help on using the changeset viewer.