Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 7, 2026

Changes

Source Generator Implementation

  • Added StackPushBytesGenerator and GenerateStackOpcodeGenerator to auto-generate optimized push methods for byte sizes 1-32
  • Eliminated runtime size checks and branching through compile-time specialization
  • Generated methods use [GenerateStackPushBytes(size, PadDirection)] attribute

SIMD Stack Operations

  • Replaced generic Span.CopyTo with direct Vector256<byte>/Vector128<byte> construction
  • Added CopyUpTo32 helper using unaligned SIMD reads for optimal byte copying
  • Single 32-byte stores replace multiple smaller writes
  • Specialized paths for common sizes (1, 2, 4, 8, 16 bytes)

VM Execution Loop

  • Simplified opcode dispatch using nuint indexing with function pointers
  • Removed special-case POP inlining (now uniform dispatch)
  • Moved opcode count tracking to exception paths only

API Changes

  • Push methods now return EvmExceptionType instead of void for unified error handling
  • Added PushBytesNullableRef for stack overflow detection without exceptions
  • Explicit PushZero/PushOne methods replace conditional pushes

Before:

stack.PushBytes<TTracingInst>(immediateData);  // Generic copy

After:

stack.Push8Bytes<TTracingInst>(ref bytes);  // Generated SIMD implementation

Types of changes

What types of changes does your code introduce?

  • Optimization

Testing

Requires testing

  • No

Documentation

Requires documentation update

  • Yes
  • No

Requires explanation in Release Notes

  • Yes
  • No

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Optimize stack push operations for better performance Optimize EVM stack push operations with SIMD and source generation Jan 7, 2026
Copilot AI requested a review from benaadams January 7, 2026 17:29
@benaadams
Copy link
Member

Seems excessive

@benaadams benaadams closed this Jan 7, 2026
@benaadams benaadams deleted the copilot/sub-pr-10120 branch January 7, 2026 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants