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

jit(arm64): support call instruction #221

Merged
merged 32 commits into from
Feb 14, 2022
Merged

jit(arm64): support call instruction #221

merged 32 commits into from
Feb 14, 2022

Conversation

mathetake
Copy link
Member

@mathetake mathetake commented Feb 10, 2022

part of #187

Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
@mathetake
Copy link
Member Author

ok cool passed tests

Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
@mathetake mathetake marked this pull request as ready for review February 14, 2022 00:33
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
@mathetake
Copy link
Member Author

this is kind of a first milestone as this enables arm64 JIT to run fibonacci function!

Copy link
Contributor

@codefromthecrypt codefromthecrypt left a comment

Choose a reason for hiding this comment

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

Looks good. cc @summerwind so you can become more acclimated to the type of feedback on compiler stuff

wasm/jit/jit_arm64.go Outdated Show resolved Hide resolved
wasm/jit/jit_arm64.go Outdated Show resolved Hide resolved
wasm/jit/jit_arm64.go Outdated Show resolved Hide resolved
wasm/jit/jit_arm64.go Outdated Show resolved Hide resolved
wasm/jit/jit_amd64.go Outdated Show resolved Hide resolved
// For example, if beforeTargetInst == RET and we have the instruction sequence like
// ADR -> X -> Y -> ... -> RET -> MOV, then the ADR instruction emitted by this function set the absolute
// address of MOV instruction into the destination register.
func (c *arm64Compiler) readInstructionAddress(beforeTargetInst obj.As, destinationRegister int16) {
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be compileXXX?

Copy link
Member Author

Choose a reason for hiding this comment

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

nope, this is arm64 specific and don't need to be exposed as compiler interface

Copy link
Contributor

Choose a reason for hiding this comment

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

well we add the XX implements XXX when it is part of the interface, we can still use a common prefix when there are functions that do the same sort of things. That was actually part of why I suggested we enforce the interface in the first place, so that we can tell the difference between naming conventions vs what are common across

Copy link
Member Author

@mathetake mathetake Feb 14, 2022

Choose a reason for hiding this comment

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

no I don't think so, this could be re-written and removed in anyway after #233 and I don't think we need this for other archs (e.g. RISC V). Having methods on interface which are not used anywhere seems weird to me, so let me leave it as-is.

Copy link
Contributor

Choose a reason for hiding this comment

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

you misunderstood. but the outcome is fine. What I meant is that naming convention != interface. we can re-use a naming convention for things that add instructions without adding them to the interface. put another way no reason for us to require adding an interface just to prefix "compileX".

Copy link
Member Author

Choose a reason for hiding this comment

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

so then in what way compile* (or whatever prefix) common prefix convention helps here?

Copy link
Member Author

Choose a reason for hiding this comment

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

example would help

Copy link
Contributor

Choose a reason for hiding this comment

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

compileXXX is used currently for operations that end up adding instructions, effecting state via c.addInstruction(inst). I don't see a point using different prefixes to begin describing things that end up doing that. I have been looking at things and if I see compileXXX I think first this is going to add instructions, then I look at what it is doing if it matches the intent either via inherited doc from the interface or what's on the non-shared thing. I look to see if there's an "addInstruction" as formerly "compile" was a keyword for me to look for state changes vs ancillary functions that do not generate instructions. Does this make sense?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah make sense esp this

effecting state via c.addInstruction(inst).

Copy link
Member Author

Choose a reason for hiding this comment

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

actually I've been thinking about this but too lazy to get started.. lemme fix

wasm/jit/jit_arm64.go Show resolved Hide resolved
err := compiler.emitPreamble()
require.NoError(t, err)
compiler.returnFunction()
// Build code.
Copy link
Contributor

Choose a reason for hiding this comment

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

It is my guess eventually we'll have a test util that self-describes when when/where we do preamble, returnFunction, etc. so I'll hold off repetitive comment nits till then, as the test util would centralize such explanations

wasm/jit/jit_arm64_test.go Outdated Show resolved Hide resolved
wasm/jit/jit_arm64_test.go Outdated Show resolved Hide resolved
Co-authored-by: Crypt Keeper <64215+codefromthecrypt@users.noreply.github.com>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
@@ -368,7 +368,7 @@ func (c *arm64Compiler) returnFunction() error {
// At this point, we have
//
// [......., ra.caller, rb.caller, rc.caller, _, ra.current, rb.current, rc.current, _, ...] <- call frame stack's data region (somewhere in the memory)
// ^
// ^
Copy link
Member Author

Choose a reason for hiding this comment

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

actually this should be on comma as this points to the address of a struct, not any specific field.

Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
@mathetake mathetake merged commit e60eda6 into main Feb 14, 2022
@mathetake mathetake deleted the call branch February 14, 2022 02:50
r8d8 pushed a commit to r8d8/wazero that referenced this pull request Feb 14, 2022
Signed-off-by: r8d8 <ckryvomaz@gmail.com>
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