@@ -1785,19 +1785,50 @@ class emitter
1785
1785
void emitHandleMemOp (GenTreeIndir* indir, instrDesc* id, insFormat fmt, instruction ins);
1786
1786
void spillIntArgRegsToShadowSlots ();
1787
1787
1788
- /* ***********************************************************************/
1789
- /* The logic that creates and keeps track of instruction groups */
1790
- /* ***********************************************************************/
1788
+ /* ***********************************************************************/
1789
+ /* The logic that creates and keeps track of instruction groups */
1790
+ /* ***********************************************************************/
1791
+
1792
+ // SC_IG_BUFFER_SIZE defines the size, in bytes, of the single, global instruction group buffer.
1793
+ // When a label is reached, or the buffer is filled, the precise amount of the buffer that was
1794
+ // used is copied to a newly allocated, precisely sized buffer, and the global buffer is reset
1795
+ // for use with the next set of instructions (see emitSavIG). If the buffer was filled before
1796
+ // reaching a label, the next instruction group will be an "overflow", or "extension" group
1797
+ // (marked with IGF_EXTEND). Thus, the size of the global buffer shouldn't matter (as long as it
1798
+ // can hold at least one of the largest instruction descriptor forms), since we can always overflow
1799
+ // to subsequent instruction groups.
1800
+ //
1801
+ // The only place where this fixed instruction group size is a problem is in the main function prolog,
1802
+ // where we only support a single instruction group, and no extension groups. We should really fix that.
1803
+ // Thus, the buffer size needs to be large enough to hold the maximum number of instructions that
1804
+ // can possibly be generated into the prolog instruction group. That is difficult to statically determine.
1805
+ //
1806
+ // If we do generate an overflow prolog group, we will hit a NOWAY assert and fall back to MinOpts.
1807
+ // This should reduce the number of instructions generated into the prolog.
1808
+ //
1809
+ // Note that OSR prologs require additional code not seen in normal prologs.
1810
+ //
1811
+ // Also, note that DEBUG and non-DEBUG builds have different instrDesc sizes, and there are multiple
1812
+ // sizes of instruction descriptors, so the number of instructions that will fit in the largest
1813
+ // instruction group depends on the instruction mix as well as DEBUG/non-DEBUG build type. See the
1814
+ // EMITTER_STATS output for various statistics related to this.
1815
+ //
1816
+ CLANG_FORMAT_COMMENT_ANCHOR;
1791
1817
1792
1818
#ifdef TARGET_ARMARCH
1793
- // The only place where this limited instruction group size is a problem is
1794
- // in the prolog, where we only support a single instruction group. We should really fix that.
1795
1819
// ARM32 and ARM64 both can require a bigger prolog instruction group. One scenario is where
1796
1820
// a function uses all the incoming integer and single-precision floating-point arguments,
1797
1821
// and must store them all to the frame on entry. If the frame is very large, we generate
1798
- // ugly code like "movw r10, 0x488; add r10, sp; vstr s0, [r10]" for each store, which
1799
- // eats up our insGroup buffer.
1800
- #define SC_IG_BUFFER_SIZE (100 * sizeof (emitter::instrDesc) + 14 * SMALL_IDSC_SIZE)
1822
+ // ugly code like:
1823
+ // movw r10, 0x488
1824
+ // add r10, sp
1825
+ // vstr s0, [r10]
1826
+ // for each store, or, to load arguments into registers:
1827
+ // movz xip1, #0x6cd0
1828
+ // movk xip1, #2 LSL #16
1829
+ // ldr w8, [fp, xip1] // [V10 arg10]
1830
+ // which eats up our insGroup buffer.
1831
+ #define SC_IG_BUFFER_SIZE (200 * sizeof (emitter::instrDesc))
1801
1832
#else // !TARGET_ARMARCH
1802
1833
#define SC_IG_BUFFER_SIZE (50 * sizeof (emitter::instrDesc) + 14 * SMALL_IDSC_SIZE)
1803
1834
#endif // !TARGET_ARMARCH
0 commit comments