Giter VIP home page Giter VIP logo

asmjit's Introduction

asmjit's People

Contributors

martinmcclure avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

asmjit's Issues

Missing syscall instruction

Mist needs the syscall instruction, which AsmJit does not know about. I suspect that other instructions are also missing, but if they're system instructions most aren't needed in userspace. So the fix will be to either add all system instructions, or to just add the syscall instruction.

Some 8-bit registers not available in 64-bit mode

The 8-bit registers SPL, BPL, SIL, and DIL, available only in 64-bit mode and when using a REX prefix, are not currently available in AsmJit.

Access to these registers requires that there be a REX prefix, but that REX.R be 0. There are cases where this would make the REX prefix be 16r40, in which case the REX prefix would normally be omitted.

Also should check that AsmJit rejects as illegal registers AH, CH, DH, and BH when a REX prefix is otherwise required, since those registers are not available when a REX prefix is used.

Missing Integer>>|

13 tests fail trying to bit-or integers with #|, which is not implemented.

Missing printAsMemBaseOn:

AJMem>>printOn: sends #printAsMemBaseOn: to the base register, but it is not implemented. AJx86GPRegister does implement #printAsMemBase, which answers a string, but that's not sent.

Add BaselineOfAsmJit

To fit in my workflow better, need to add a baseline for the newer Metacello scripting API. Also, I never really learned how to use the older Metacello. Not that I'm an expert in the newer Metacello, but I'm at least more familiar with it.

r8-r15 not supported as index registers

For r8-r15 to be used as index registers, rex.X must be set to 1. However, AsmJit always emits rex.X as 0. At least some of the senders of #emitRexPrefixW:R:X:B: need to actually compute X rather than just passing in false.

Add external labels to AsmJit

Since Mist puts each method's native code at a stable absolute address, it needs ways of referencing one method from another (jumps and calls, especially). Part of this will be Mist-specific, but it seems like some fits best into AsmJit. An initial specification:

Simple example of use:

| asm1 asm2 label routine1 routine2 firstFreeAddress |

asm1 := AJx64Assembler noStackFrame.
asm2 := AJx64Assembler noStackFrame.
label := AJExternalLabel new: 'MyRoutine'.

asm1 label: label.
asm1 < more instructions>.
...
asm1 ret.

routine1 := asm1 generatedCode.

asm2
asm2 call: label.
asm2 < more instructions>

routine2 := asm2 generatedCode.

firstFreeAddress := 16r400078.

{routine1. routine2}
do: [:code | code startAddress: firstFreeAddress.
firstFreeAddress := firstFreeAddress + code size].
"At this point, the call site has been patched with the correct displacement,
so once the bytes are installed in the given absolute addresses the call
will go to the right place."


API:

AJExternalLabel class (new class)

new: description

Answers a new external label that allows jumps and calls even across different instances of AJGeneratedCode. Description is a string used for printing only, it does not identify the label.

The instance side of this class has no public API.


AJAssembler subclasses

asm label: identifierOrLabel
Expanded to accept external labels.

asm call: label
asm jmp: label
asm jz: label
...

All jumps and calls (OK, only near calls and jumps -- I don't see any need to handle far calls) will accept external labels. What is put in the generatedCode in the externalLabel case is a 32-bit offset of 0. This will be patched later with the actual value.


AJGeneratedCode

startAddress: integer

Tells the generatedCode that it will be installed starting at the given absolute address. When both the generatedCode instance containing the label and the generatedCode instance containing a jump or call to the label have been sent #startAddress:, the jump or call site in the bytes of the generatedCode is automatically patched with the correct relative offset for the label. If the required offset will not fit in 32 bits, an error is signaled.


Fix AJReserveTemp breakage

The fix for issue 10 left a test of AJReserveTemp broken (and also reportedly breaks NativeBoost). I now believe I have enough information to fix this.

1 should be a valid index scale

AJMem>>scale: does not accept 1 as a valid scale. It does accept 0, which is not a valid scale. Instead of 0, it should accept 1 for a shift of 0.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.