Skip to content

Conversation

@SupunS
Copy link
Member

@SupunS SupunS commented Nov 10, 2025

Work towards #3691

Description

Includes only the changes to related to the subtype-check "generation". This doesn't integrate the generated function to the runtime. I have opened a separate PR #4322 to integrate the generated function.


  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

@SupunS SupunS self-assigned this Nov 10, 2025
@github-actions
Copy link

github-actions bot commented Nov 10, 2025

Benchstat comparison

  • Base branch: onflow:feature/subtype-gen
  • Base commit: 3a91a73
Results

old.txtnew.txt
time/opdelta
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ContractFunctionInvocation-4411µs ± 0%409µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
Emit-44.19ms ± 0%4.09ms ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ExportType/composite_type-4277ns ± 0%261ns ± 0%~(p=1.000 n=1+1)
ExportType/simple_type-477.8ns ± 0%79.0ns ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ImperativeFib-421.1µs ± 0%21.1µs ± 0%~(p=1.000 n=1+1)
InterpretRecursionFib-42.30ms ± 0%2.33ms ± 0%~(p=1.000 n=1+1)
NewInterpreter/new_interpreter-41.03µs ± 0%1.03µs ± 0%~(p=1.000 n=1+1)
NewInterpreter/new_sub-interpreter-4319ns ± 0%316ns ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/sema goos:linux goarch:amd64
QualifiedIdentifierCreation/One_level-42.19ns ± 0%2.21ns ± 0%~(p=1.000 n=1+1)
QualifiedIdentifierCreation/Three_levels-482.6ns ± 0%86.0ns ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
RuntimeFungibleTokenTransferInterpreter-4586µs ± 0%589µs ± 0%~(p=1.000 n=1+1)
RuntimeFungibleTokenTransferVM-4629µs ± 0%645µs ± 0%~(p=1.000 n=1+1)
RuntimeResourceDictionaryValues-42.71ms ± 0%2.65ms ± 0%~(p=1.000 n=1+1)
RuntimeResourceTracking-412.9ms ± 0%12.1ms ± 0%~(p=1.000 n=1+1)
RuntimeScriptNoop-414.9µs ± 0%14.9µs ± 0%~(p=1.000 n=1+1)
RuntimeVMInvokeContractImperativeFib-427.7µs ± 0%27.9µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/sema goos:linux goarch:amd64
SuperTypeInference/arrays-4218ns ± 0%218ns ± 0%~(all equal)
SuperTypeInference/composites-490.2ns ± 0%90.1ns ± 0%~(p=1.000 n=1+1)
SuperTypeInference/integers-4303ns ± 0%304ns ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ValueIsSubtypeOfSemaType-466.5ns ± 0%69.9ns ± 0%~(p=1.000 n=1+1)
 
alloc/opdelta
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ContractFunctionInvocation-4153kB ± 0%153kB ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
Emit-41.48MB ± 0%1.48MB ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ExportType/composite_type-4120B ± 0%120B ± 0%~(all equal)
ExportType/simple_type-40.00B 0.00B ~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ImperativeFib-48.30kB ± 0%8.30kB ± 0%~(all equal)
InterpretRecursionFib-41.19MB ± 0%1.19MB ± 0%~(all equal)
NewInterpreter/new_interpreter-4976B ± 0%976B ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-4232B ± 0%232B ± 0%~(all equal)
pkg:github.com/onflow/cadence/sema goos:linux goarch:amd64
QualifiedIdentifierCreation/One_level-40.00B 0.00B ~(all equal)
QualifiedIdentifierCreation/Three_levels-464.0B ± 0%64.0B ± 0%~(all equal)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
RuntimeFungibleTokenTransferInterpreter-4159kB ± 0%159kB ± 0%~(p=1.000 n=1+1)
RuntimeFungibleTokenTransferVM-4173kB ± 0%173kB ± 0%~(p=1.000 n=1+1)
RuntimeResourceDictionaryValues-41.76MB ± 0%1.76MB ± 0%~(p=1.000 n=1+1)
RuntimeResourceTracking-49.28MB ± 0%9.27MB ± 0%~(p=1.000 n=1+1)
RuntimeScriptNoop-48.04kB ± 0%8.04kB ± 0%~(p=1.000 n=1+1)
RuntimeVMInvokeContractImperativeFib-49.80kB ± 0%9.80kB ± 0%~(all equal)
pkg:github.com/onflow/cadence/sema goos:linux goarch:amd64
SuperTypeInference/arrays-496.0B ± 0%96.0B ± 0%~(all equal)
SuperTypeInference/composites-40.00B 0.00B ~(all equal)
SuperTypeInference/integers-40.00B 0.00B ~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ValueIsSubtypeOfSemaType-448.0B ± 0%48.0B ± 0%~(all equal)
 
allocs/opdelta
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ContractFunctionInvocation-42.46k ± 0%2.46k ± 0%~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
Emit-439.0k ± 0%39.0k ± 0%~(all equal)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ExportType/composite_type-43.00 ± 0%3.00 ± 0%~(all equal)
ExportType/simple_type-40.00 0.00 ~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ImperativeFib-4176 ± 0%176 ± 0%~(all equal)
InterpretRecursionFib-417.7k ± 0%17.7k ± 0%~(all equal)
NewInterpreter/new_interpreter-415.0 ± 0%15.0 ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-44.00 ± 0%4.00 ± 0%~(all equal)
pkg:github.com/onflow/cadence/sema goos:linux goarch:amd64
QualifiedIdentifierCreation/One_level-40.00 0.00 ~(all equal)
QualifiedIdentifierCreation/Three_levels-42.00 ± 0%2.00 ± 0%~(all equal)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
RuntimeFungibleTokenTransferInterpreter-42.98k ± 0%2.98k ± 0%~(all equal)
RuntimeFungibleTokenTransferVM-43.00k ± 0%3.00k ± 0%~(all equal)
RuntimeResourceDictionaryValues-436.7k ± 0%36.7k ± 0%~(all equal)
RuntimeResourceTracking-4159k ± 0%159k ± 0%~(p=1.000 n=1+1)
RuntimeScriptNoop-4113 ± 0%113 ± 0%~(all equal)
RuntimeVMInvokeContractImperativeFib-4197 ± 0%197 ± 0%~(all equal)
pkg:github.com/onflow/cadence/sema goos:linux goarch:amd64
SuperTypeInference/arrays-43.00 ± 0%3.00 ± 0%~(all equal)
SuperTypeInference/composites-40.00 0.00 ~(all equal)
SuperTypeInference/integers-40.00 0.00 ~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ValueIsSubtypeOfSemaType-41.00 ± 0%1.00 ± 0%~(all equal)
 

@SupunS SupunS marked this pull request as ready for review November 10, 2025 19:30
@codecov
Copy link

codecov bot commented Nov 13, 2025

Copy link
Member

@turbolent turbolent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! 👏

Just to clarify the currently generated code falls back to converting to sema types when necessary (e.g. to determine if a type is resource-typed, which isn't known at the static type level), right?

@SupunS
Copy link
Member Author

SupunS commented Nov 13, 2025

Just to clarify the currently generated code falls back to converting to sema types when necessary (e.g. to determine if a type is resource-typed, which isn't known at the static type level), right?

@turbolent Yes, that's correct.

@SupunS SupunS force-pushed the supun/subtype-gen-statictypes branch from 8c8dbfe to ee38b06 Compare November 13, 2025 22:30
@SupunS SupunS merged commit 3b54e67 into feature/subtype-gen Nov 14, 2025
10 of 12 checks passed
@SupunS SupunS deleted the supun/subtype-gen-statictypes branch November 14, 2025 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants