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

Failed to get the argument #2

Open
Syntacticlosure opened this issue Jun 21, 2017 · 1 comment
Open

Failed to get the argument #2

Syntacticlosure opened this issue Jun 21, 2017 · 1 comment

Comments

@Syntacticlosure
Copy link

Syntacticlosure commented Jun 21, 2017

There is a mistake in example. When I try to write an identity function f(x)=x such as this :

(define test-obj
  (assemble (prolog)
            (getarg r2 (arg 0))
            (mov r0 r2)
            (epilog)
            (ret r0)))

(define test (object->proc test-obj (_fun _int -> _int)))

It always returns zero no matter what the argument is.
solution: change (arg 0) into (arg 3)

The problem may only happens on windows.

@lwhjp
Copy link
Owner

lwhjp commented Jul 16, 2017

Thanks for the report!

I think this is due to the difference between Sys-V and Microsoft calling conventions on x86-64 (Microsoft uses RCX as the first argument, whereas this is the fourth on Sys-V). I have a generic solution planned for this, so I'll leave this issue open for now.

If you need to fix this urgently, you can change arg-regs in generic-x86-unit.rkt to be rcx rdx r8 r9 (see X86 calling conventions)

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

No branches or pull requests

2 participants