diff options
Diffstat (limited to 'Source/JavaScriptCore/dfg/DFGArrayMode.h')
-rw-r--r-- | Source/JavaScriptCore/dfg/DFGArrayMode.h | 83 |
1 files changed, 59 insertions, 24 deletions
diff --git a/Source/JavaScriptCore/dfg/DFGArrayMode.h b/Source/JavaScriptCore/dfg/DFGArrayMode.h index 36a8637f5..2eb009be0 100644 --- a/Source/JavaScriptCore/dfg/DFGArrayMode.h +++ b/Source/JavaScriptCore/dfg/DFGArrayMode.h @@ -46,8 +46,12 @@ enum Mode { ForceExit, // Implies that we have no idea how to execute this operation, so we should just give up. Generic, String, - JSArray, - JSArrayOutOfBounds, + ArrayStorage, + ArrayStorageOutOfBounds, + ArrayWithArrayStorage, + ArrayWithArrayStorageOutOfBounds, + PossiblyArrayWithArrayStorage, + PossiblyArrayWithArrayStorageOutOfBounds, Arguments, Int8Array, Int16Array, @@ -61,6 +65,29 @@ enum Mode { }; } // namespace Array +// Helpers for 'case' statements. For example, saying "case AllArrayStorageModes:" +// is the same as having multiple case statements listing off all of the modes that +// have the word "ArrayStorage" in them. +#define NON_ARRAY_ARRAY_STORAGE_MODES \ + Array::ArrayStorage: \ + case Array::ArrayStorageOutOfBounds: \ + case Array::PossiblyArrayWithArrayStorage: \ + case Array::PossiblyArrayWithArrayStorageOutOfBounds +#define ARRAY_WITH_ARRAY_STORAGE_MODES \ + Array::ArrayWithArrayStorage: \ + case Array::ArrayWithArrayStorageOutOfBounds +#define ALL_ARRAY_STORAGE_MODES \ + NON_ARRAY_ARRAY_STORAGE_MODES: \ + case ARRAY_WITH_ARRAY_STORAGE_MODES +#define IN_BOUNDS_ARRAY_STORAGE_MODES \ + Array::ArrayStorage: \ + case Array::ArrayWithArrayStorage: \ + case Array::PossiblyArrayWithArrayStorage +#define OUT_OF_BOUNDS_ARRAY_STORAGE_MODES \ + Array::ArrayStorageOutOfBounds: \ + case Array::ArrayWithArrayStorageOutOfBounds: \ + case Array::PossiblyArrayWithArrayStorageOutOfBounds + Array::Mode fromObserved(ArrayModes modes, bool makeSafe); Array::Mode fromStructure(Structure*, bool makeSafe); @@ -71,11 +98,30 @@ bool modeAlreadyChecked(AbstractValue&, Array::Mode); const char* modeToString(Array::Mode); +inline bool modeUsesButterfly(Array::Mode arrayMode) +{ + switch (arrayMode) { + case ALL_ARRAY_STORAGE_MODES: + return true; + default: + return false; + } +} + inline bool modeIsJSArray(Array::Mode arrayMode) { switch (arrayMode) { - case Array::JSArray: - case Array::JSArrayOutOfBounds: + case ARRAY_WITH_ARRAY_STORAGE_MODES: + return true; + default: + return false; + } +} + +inline bool isInBoundsAccess(Array::Mode arrayMode) +{ + switch (arrayMode) { + case IN_BOUNDS_ARRAY_STORAGE_MODES: return true; default: return false; @@ -114,25 +160,6 @@ inline Array::Mode modeForPut(Array::Mode arrayMode) } } -inline bool modesCompatibleForStorageLoad(Array::Mode left, Array::Mode right) -{ - if (left == right) - return true; - - bool leftIsJSArray = - left == Array::JSArray - || left == Array::JSArrayOutOfBounds; - - bool rightIsJSArray = - right == Array::JSArray - || right == Array::JSArrayOutOfBounds; - - if (leftIsJSArray && rightIsJSArray) - return true; - - return false; -} - inline bool modeIsSpecific(Array::Mode mode) { switch (mode) { @@ -147,7 +174,15 @@ inline bool modeIsSpecific(Array::Mode mode) inline bool modeSupportsLength(Array::Mode mode) { - return modeIsSpecific(mode); + switch (mode) { + case Array::Undecided: + case Array::ForceExit: + case Array::Generic: + case NON_ARRAY_ARRAY_STORAGE_MODES: + return false; + default: + return true; + } } } } // namespace JSC::DFG |