dadhi / dadhi/FastExpressionCompiler

Do not support full CLR IL code if it is resonable for perfomance (256 params/variables/assignments in lambda but not 65k)

Aperta
#89 8 commenti 1 reazione 1 assegnatario Rivendicata da @dadhi Vedi su GitHub
performance
Lingua principale
C#
Stelle
1.4k
Fork
94
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

FEC may work only with 8 bit parameters. Just to consider. I got into this while working with byref. May be there are other CLR features cool for CLR but no reason in high performance code.

https://stackoverflow.com/questions/12658883/what-is-the-maximum-number-of-parameters-that-a-c-sharp-method-can-be-defined-as

```

Here is your theoretical answer:

In order to push method arguments onto the stack, compiled code has the following MSIL opcodes to choose from:

ldarg.0

ldarg.1

ldarg.2

ldarg.3

ldarg.S

ldarg

ldarg.0 to ldarg.3 is used to push the first 4 method arguments onto the stack (including this as the first argument for instance methods).

ldarg.S takes an 8 bit argument number, and so it can be used to push up to 256 arguments onto the stack.

That leaves us with plain old ldarg, which can handle the most method arguments: it takes an unsigned 16 bit argument number. So the largest number of arguments that can be successfully compiled into valid MSIL is 2^16 = 65,536.

As others have noted, however, there are various practical stack size limits that apply when actually trying to execute your method depending on the platform/architecture of the system. Based on rmiesen's answer, it looks like the current .NET implementation limits the maximum size of the stack at runtime to 2^14.

....

CIL also stores lengths of parameter arrays in unsigned shorts, so the length can't be more than 65,535.
```

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.