-
Notifications
You must be signed in to change notification settings - Fork 0
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
Implement emit_apply_fun_shared #12
base: arm32-jit
Are you sure you want to change the base?
Changes from 8 commits
1d4c7ab
c708cf7
5f84fe3
83b6c88
5585f3c
f6b9197
c2f65f7
64b68b0
fec174f
113cb38
4b4dbb5
6daae65
b975285
4ec3b1c
db0127b
83c8c08
e148e74
12dc47a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,8 +81,79 @@ void BeamModuleAssembler::emit_i_make_fun3(const ArgLambda &Lambda, | |
} | ||
|
||
void BeamGlobalAssembler::emit_apply_fun_shared() { | ||
// TODO | ||
ASSERT(false); | ||
// TODO this is the first called emitter | ||
Label finished = a.newLabel(); | ||
|
||
/* Put the arity and fun into the right registers for `call_fun`, and stash | ||
* the argument list in ARG2 for the error path. We'll bump the arity as | ||
* we go through the argument list. */ | ||
mov_imm(ARG3, 0); | ||
a.ldr(ARG4, getXRef(0)); | ||
a.ldr(ARG2, getXRef(1)); | ||
{ | ||
Label unpack_next = a.newLabel(), malformed_list = a.newLabel(), | ||
raise_error = a.newLabel(); | ||
|
||
auto x_register = getXRef(0); | ||
|
||
ASSERT(x_register.shift() == 0); | ||
x_register.setIndex(ARG3); | ||
x_register.setShift(3); | ||
|
||
a.mov(ARG1, ARG2); | ||
a.bind(unpack_next); | ||
{ | ||
a.cmp(ARG1, imm(NIL)); | ||
a.b_eq(finished); | ||
|
||
ERTS_CT_ASSERT(_TAG_PRIMARY_MASK - TAG_PRIMARY_LIST == (1 << 1)); | ||
a.tst(ARG1, imm(1)), | ||
a.b_ne(malformed_list), | ||
|
||
emit_ptr_val(ARG1, ARG1); | ||
a.sub(ARG1, ARG1, imm(TAG_PRIMARY_LIST)); | ||
a.ldmia(arm::Mem(ARG1), a32::GpList({TMP, ARG1})); | ||
a.str(TMP, x_register); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this fails emission.... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Passing a Mem object is fine and emission succeeds wiht getXRef(0) but it fails if the operand has been setup with setIndex and setShift. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to ChatGPT we need another register to use
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this code the register used as base register is inside x_register memory object operator. It is defined at creation using one of the available constructors of class There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't get the steps anyway. The return of getCARRef is type arm:mem and x_register is type arm:mem. Can we just directly put the return of getCARRef in x_register? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This fails because getXReg adds an offset and we want to use a scale and an index register. We cannot use everything. |
||
|
||
/* We bail at MAX_REG-1 rather than MAX_REG as the highest register | ||
* is reserved for the loader. */ | ||
//a.add(ARG3, ARG3, imm(1)); | ||
//a.cmp(ARG3, imm(MAX_REG - 1)); | ||
//a.b_lo(unpack_next); | ||
} | ||
|
||
a.mov(ARG1, imm(SYSTEM_LIMIT)); | ||
a.b(raise_error); | ||
|
||
a.bind(malformed_list); | ||
a.mov(ARG1, imm(BADARG)); | ||
|
||
a.bind(raise_error); | ||
{ | ||
static const ErtsCodeMFA apply_mfa = {am_erlang, am_apply, 2}; | ||
// TODO | ||
ASSERT(false); | ||
|
||
//a.mov(XREG0, ARG4); | ||
//a.mov(XREG1, ARG5); | ||
|
||
//a.str(TMP1, arm::Mem(c_p, offsetof(Process, freason))); | ||
//mov_imm(ARG4, &apply_mfa); | ||
//a.b(labels[raise_exception]); | ||
} | ||
} | ||
|
||
a.bind(finished); | ||
{ | ||
/* Make the lower 16 bits of ARG3 equal those of the header word of all | ||
* funs with the same arity. */ | ||
a.lsl(ARG3, ARG3, imm(FUN_HEADER_ARITY_OFFS)); | ||
a.add(ARG3, ARG3, imm(FUN_SUBTAG)); | ||
|
||
// TODO | ||
ASSERT(false); | ||
// a.ret(a32::r14); | ||
} | ||
} | ||
|
||
void BeamModuleAssembler::emit_i_apply_fun() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are there commas and not semicolon at the end of the two lines above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
omg... just my erlang braincells adding chaos