Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Systematic support for call-by-value vs call-by-reference in EVM backend #81

Open
11 tasks
kwannoel opened this issue Sep 22, 2021 · 36 comments
Open
11 tasks

Comments

@kwannoel
Copy link
Contributor

In GitLab by @fahree on Dec 15, 2020, 01:25

Description

We would like to support boxed types in addition the current support for unboxed types.

Example builtin non-immediate types:

  • Signature (65 bytes, r, s, v fields)

And then at some point we need to handle strings: immediate, non-immediate? A new kind of "indirect" values?

  • a ByteString has a length + an offset in memory.

What we need

  • Notion of immediate vs non-immediate types.
  • Provide the proper interface for marshaling values to the EVM.
    Type descriptors with methods for storing / loading etc...

Patches for gerbil-ethereum

Tracked here.

Patches for Glow

Type descriptors (See: https://gitlab.com/mukn/glow/-/merge_requests/158)

  • boxed/unboxed type descriptor
  • size descriptors
  • descriptors for conversion between objects, bytes.

Refactor current handling

Consensus code generator handles variables in the following way:

  1. Get type via lookup-type:
    (def type (lookup-type (.@ self program) argument-name))
    
  2. Get length via param-length:
    (def len (and type (param-length type)))
    
  3. Get static offset via lookup-variable-offset.
  4. Use mloadat / mstoreat to handle the variable's loading / storing.

Once EVM type descriptor interface is stabilized, we should use its methods instead.
In consensus code generator:

  • Update define-small-functions to use EVM type descriptor methods.
  • Update compile-consensus-statement to use EVM type descriptor methods.
  • Update load-immediate-variable to use EVM type descriptor methods.
  • Update add-local-variable-to-frame to use EVM type descriptor methods.
  • Update add-temporary-variable-offset to use EVM type descriptor methods.
  • Update trivial-expression to use EVM type descriptor methods.
  • Update setup-tail-call to use EVM type descriptor methods.
  • Update compute-variable-offsets to use EVM type descriptor methods.

TODO how to integrate with EVM type descriptor methods?
TODO any other areas we need to handle?

@kwannoel
Copy link
Contributor Author

In GitLab by @fahree on Dec 15, 2020, 01:44

  • In Ethereum types, have a notion of immediate vs non-immediate type
  • Immediate types are stored directly on the stack, e.g. integers less than 256 bits, objects that fit in 256 bits in general
  • Non-immediate objects are stored in memory, and only their 16- or 24-bit offset in passed on the EVM stack.
  • We want type descriptors, etc., to convert between objects and bytes, to generate the proper EVM code, etc.

Example builtin non-immediate types:

  • Signature (65 bytes, r, s, v fields)

And then at some point we need to handle strings: immediate, non-immediate? A new kind of "indirect" values?

  • a ByteString has a length + an offset in memory.

Methods?

  • Hashing
  • get to stack, store from stack, copy, etc., on the EVM backend.

@kwannoel
Copy link
Contributor Author

In GitLab by @fahree on Dec 15, 2020, 03:50

assigned to @fahree

@kwannoel
Copy link
Contributor Author

In GitLab by @fahree on Dec 15, 2020, 03:50

assigned to @AlexKnauth and @Akaa

@kwannoel
Copy link
Contributor Author

In GitLab by @kwanzknoel on May 10, 2021, 20:55

assigned to @kwanzknoel

@kwannoel
Copy link
Contributor Author

In GitLab by @kwanzknoel on May 11, 2021, 01:33

marked this issue as related to #68

@kwannoel
Copy link
Contributor Author

In GitLab by @kwanzknoel on May 11, 2021, 01:33

marked this issue as related to #115

@kwannoel
Copy link
Contributor Author

In GitLab by @kwanzknoel on May 11, 2021, 01:47

Note: as mentioned by @fahree, until we have user-defined data structures, the only data structure in need of references is Signature.

@kwannoel
Copy link
Contributor Author

In GitLab by @kwanzknoel on May 11, 2021, 16:34

Type descriptors are similar to typeclasses in Haskell.

@kwannoel
Copy link
Contributor Author

In GitLab by @kwanzknoel on May 11, 2021, 20:47

EVM backends and other similar backends define a predicate: immediate?. This enables us to discriminate between immediate and non-immediate entities, i.e. whether an entity can be represented in a way that fits into a single stack entry / register (depending on VM).

We will choose an indirect type representation for those which cannot fit.

@kwannoel
Copy link
Contributor Author

In GitLab by @kwanzknoel on May 11, 2021, 20:48

Task prerequisites: understanding of EVM, glow type descriptors, glow consensus code gen.

@kwannoel
Copy link
Contributor Author

In GitLab by @kwanzknoel on Jun 2, 2021, 03:55

marked this issue as related to #191

@kwannoel
Copy link
Contributor Author

In GitLab by @kwanzknoel on Jun 2, 2021, 16:25

changed the description

@kwannoel
Copy link
Contributor Author

In GitLab by @kwanzknoel on Jun 2, 2021, 16:31

changed the description

@kwannoel
Copy link
Contributor Author

In GitLab by @kwanzknoel on Jun 2, 2021, 19:03

changed the description

@kwannoel
Copy link
Contributor Author

In GitLab by @kwanzknoel on Jun 2, 2021, 21:10

changed the description

@kwannoel
Copy link
Contributor Author

In GitLab by @kwanzknoel on Jun 2, 2021, 21:12

changed the description

@kwannoel
Copy link
Contributor Author

In GitLab by @kwanzknoel on Jun 2, 2021, 21:13

changed the description

@kwannoel
Copy link
Contributor Author

In GitLab by @kwanzknoel on Jun 2, 2021, 21:15

changed the description

@kwannoel
Copy link
Contributor Author

In GitLab by @kwanzknoel on Jun 2, 2021, 21:17

changed the description

@kwannoel
Copy link
Contributor Author

In GitLab by @kwanzknoel on Jun 2, 2021, 21:17

marked the task boxed? method to discriminate between the two. as completed

@kwannoel
Copy link
Contributor Author

In GitLab by @kwanzknoel on Jun 2, 2021, 21:52

changed the description

@kwannoel
Copy link
Contributor Author

In GitLab by @kwanzknoel on Jun 2, 2021, 21:54

changed the description

@kwannoel
Copy link
Contributor Author

In GitLab by @kwanzknoel on Jun 25, 2021, 01:51

marked the task boxed? method to discriminate between the two. as incomplete

@kwannoel
Copy link
Contributor Author

In GitLab by @kwanzknoel on Jun 25, 2021, 03:17

changed the description

@kwannoel
Copy link
Contributor Author

In GitLab by @kwanzknoel on Jun 25, 2021, 03:18

changed the description

1 similar comment
@kwannoel
Copy link
Contributor Author

In GitLab by @kwanzknoel on Jun 25, 2021, 03:18

changed the description

@kwannoel
Copy link
Contributor Author

In GitLab by @kwanzknoel on Jul 7, 2021, 03:11

changed the description

@kwannoel
Copy link
Contributor Author

In GitLab by @kwanzknoel on Jul 7, 2021, 03:21

changed the description

@kwannoel
Copy link
Contributor Author

In GitLab by @kwanzknoel on Jul 7, 2021, 04:04

changed the description

@kwannoel
Copy link
Contributor Author

In GitLab by @kwanzknoel on Jul 7, 2021, 04:17

changed the description

@kwannoel
Copy link
Contributor Author

In GitLab by @kwanzknoel on Jul 7, 2021, 23:05

changed the description

@kwannoel
Copy link
Contributor Author

In GitLab by @kwanzknoel on Jul 10, 2021, 02:21

changed the description

@kwannoel
Copy link
Contributor Author

In GitLab by @kwanzknoel on Jul 10, 2021, 02:22

changed the description

@kwannoel
Copy link
Contributor Author

In GitLab by @kwanzknoel on Jul 10, 2021, 02:23

changed the description

1 similar comment
@kwannoel
Copy link
Contributor Author

In GitLab by @kwanzknoel on Jul 10, 2021, 02:23

changed the description

@kwannoel
Copy link
Contributor Author

In GitLab by @kwanzknoel on Jul 10, 2021, 02:52

changed the description

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant