martinmcclure / asmjit Goto Github PK
View Code? Open in Web Editor NEWFork of http://www.squeaksource.com/AsmJit
Fork of http://www.squeaksource.com/AsmJit
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.
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.
13 tests fail trying to bit-or integers with #|, which is not implemented.
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.
Because it has an argument (asm -- illegal, see issue 7) testRegistersOf: is not being run.
If converted to testRegisters it does not run, errors with MNU nReg:.
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.
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.
AJInstruction>>printSelfOn: sends #padRightTo:, which is not implemented in Pharo 1.4.
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.
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.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.