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

Implement emit_apply_fun_shared #12

Draft
wants to merge 18 commits into
base: arm32-jit
Choose a base branch
from

Conversation

ziopio
Copy link

@ziopio ziopio commented Jan 23, 2025

Implementation line by line

@ziopio ziopio changed the title Implement part of mov_imm Implement emit_apply_fun_shared Jan 23, 2025
@ziopio ziopio force-pushed the ziopio/emit_apply_fun_shared branch from b079779 to 51e6f17 Compare January 23, 2025 15:30
@ziopio ziopio force-pushed the ziopio/emit_apply_fun_shared branch from cadf9a0 to 83b6c88 Compare January 27, 2025 09:08
@ziopio ziopio force-pushed the ziopio/emit_apply_fun_shared branch from 5318ced to c2f65f7 Compare January 27, 2025 14:57
@ziopio ziopio marked this pull request as ready for review January 28, 2025 08:30
@ziopio ziopio requested a review from maehjam January 28, 2025 08:30
@ziopio ziopio marked this pull request as draft January 28, 2025 09:01
@@ -113,7 +113,7 @@ void BeamGlobalAssembler::emit_apply_fun_shared() {
emit_ptr_val(ARG1, ARG1);
a.sub(ARG1, ARG1, imm(TAG_PRIMARY_LIST));
a.ldmia(arm::Mem(ARG1), a32::GpList({TMP, ARG1}));
//a.str(TMP3, arm::Mem(TMP2).post(sizeof(Eterm)));
a.str(TMP, x_register);
Copy link
Author

Choose a reason for hiding this comment

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

this fails emission....

Copy link
Author

Choose a reason for hiding this comment

The 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.

Copy link

Choose a reason for hiding this comment

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

According to ChatGPT we need another register to use STR:

    ; Load the address of 'var' into r1 (or any free register).
    LDR   r1, =var      ; r1 now has the address of var

    ; Store r0 (32 bits) into [r1].
    STR   r0, [r1]

Copy link
Author

Choose a reason for hiding this comment

The 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 arm::Mem

Copy link

Choose a reason for hiding this comment

The 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?

Copy link
Author

Choose a reason for hiding this comment

The 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.
A correct initialization would be auto x_register = arm::Mem(scheduler_registers);

On arm32 we will have an Eterm Size of 32 bit (unsigned long), so to address the next Eterm we need to scale with x4 instead of x8

ERTS_CT_ASSERT(_TAG_PRIMARY_MASK - TAG_PRIMARY_LIST == (1 << 1));
a.tst(ARG1, imm(1)),
a.b_ne(malformed_list),
Copy link

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?

Copy link
Author

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

getXRef would also add an offset and this is not compatible with Index * Scale
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