summaryrefslogtreecommitdiff
path: root/yjit/src/backend
AgeCommit message (Collapse)Author
2022-08-29Fix a bus error on regenerate_branch (https://github.com/Shopify/ruby/pull/408)Takashi Kokubun
* Fix a bus error on regenerate_branch * Fix pad_size Notes: Merged: https://github.com/ruby/ruby/pull/6289
2022-08-29Even more prep for instruction enum (https://github.com/Shopify/ruby/pull/413)Kevin Newton
* Mutate in place for register allocation Currently we allocate a new instruction every time when we're doing register allocation by first splitting up the instruction into its component parts, mapping the operands and the output, and then pushing all of its parts onto the new assembler. Since we don't need the old instruction, we can mutate the existing one in place. While it's not that big of a win in and of itself, it matches much more closely to what we're going to have to do when we switch the instruction from being a struct to being an enum, because it's much easier for the instruction to modify itself since it knows its own shape than it is to push a new instruction that very closely matches. * Mutate in place for arm64 split When we're splitting instructions for the arm64 backend, we map all of the operands for a given instruction when it has an Opnd::Value. We can do this in place with the existing operand instead of allocating a new vector each time. This enables us to pattern match against the entire instruction instead of just the opcode, which is much closer to matching against an enum. * Match against entire instruction in arm64_emit Instead of matching against the opcode and then accessing all of the various fields on the instruction when emitting bytecode for arm64, we should instead match against the entire instruction. This makes it much closer to what's going to happen when we switch it over to being an enum. * Match against entire instruction in x86_64 backend When we're splitting or emitting code for x86_64, we should match against the entire instruction instead of matching against just the opcode. This gets us closer to matching against an enum instead of a struct. * Reuse instructions for arm64_split When we're splitting, the default behavior was previously to split up the instruction into its component parts and then reassemble them in a new instruction. Instead, we can reuse the existing instruction. Notes: Merged: https://github.com/ruby/ruby/pull/6289
2022-08-29Build output operands explicitly (https://github.com/Shopify/ruby/pull/411)Kevin Newton
When we're pushing instructions onto the assembler, we previously would iterate through the instruction's operands and then assign the output operand to it through the push_insn function. This is easy when all instructions have a vector of operands, but is much more difficult when the shape differs in an enum. This commit changes it so that we explicitly define the output operand for each instruction before it gets pushed onto the assembler. This has the added benefit of changing the definition of push_insn to no longer require a mutable instruction. This paves the way to make the out field on the instructions an Option<Opnd> instead which is going to more accurately reflect the behavior we're going to have once we switch the instructions over to an enum instead of a struct.
2022-08-29Instruction builders for backend IR (https://github.com/Shopify/ruby/pull/410)Kevin Newton
Currently we use macros to define the shape of each of the instruction building methods. This works while all of the instructions share the same fields, but is really hard to get working when they're an enum with different shapes. This is an incremental step toward a bigger refactor of changing the Insn from a struct to an enum.
2022-08-29Fix issue with expandarray, add missing jl, enable tests ↵Maxime Chevalier-Boisvert
(https://github.com/Shopify/ruby/pull/409)
2022-08-29AArch64 Ruby immediates (https://github.com/Shopify/ruby/pull/400)Kevin Newton
2022-08-29Op::Xor for backend IR (https://github.com/Shopify/ruby/pull/397)Kevin Newton
2022-08-29Handle out of memory tests (https://github.com/Shopify/ruby/pull/393)Maxime Chevalier-Boisvert
2022-08-29Iterator (https://github.com/Shopify/ruby/pull/372)Kevin Newton
* Iterator * Use the new iterator for the X86 backend split * Use iterator for reg alloc, remove forward pass * Fix up iterator usage on AArch64 * Update yjit/src/backend/ir.rs Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com> * Various PR feedback for iterators for IR * Use a local mutable reference for a64_split * Move tests from ir.rs to tests.rs in backend * Fix x86 shift instructions live range calculation * Iterator * Use the new iterator for the X86 backend split * Fix up x86 iterator usage * Fix ARM iterator usage * Remove unintentionally duplicated tests
2022-08-29Fix tests on yjit_backend_ir for AArch64 backend ↵Kevin Newton
(https://github.com/Shopify/ruby/pull/383)
2022-08-29Load mem displacement when necessary on AArch64 ↵Kevin Newton
(https://github.com/Shopify/ruby/pull/382) * LDR instruction for AArch64 * Split loads in arm64_split when memory address displacements do not fit
2022-08-29Update flags for data processing on ARM ↵Kevin Newton
(https://github.com/Shopify/ruby/pull/380) * Update flags for data processing on ARM * Update yjit/src/backend/arm64/mod.rs Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>
2022-08-29Port invokebuiltin* insns to the new backend IR ↵Takashi Kokubun
(https://github.com/Shopify/ruby/pull/375) * Port invokebuiltin* insns to the new backend IR * Fix the C_ARG_OPNDS check boundary
2022-08-29Left and right shift for IR (https://github.com/Shopify/ruby/pull/374)Kevin Newton
* Left and right shift for IR * Update yjit/src/backend/x86_64/mod.rs Co-authored-by: Alan Wu <XrXr@users.noreply.github.com> Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>
2022-08-29x86 TEST should do a load for mem opnds first ↵Noah Gibbs
(https://github.com/Shopify/ruby/pull/368)
2022-08-29Port opt_minus, opt_or, and opt_and to the new IR ↵Takashi Kokubun
(https://github.com/Shopify/ruby/pull/364) * Port opt_minus, opt_or, and opt_and to the new IR * Fix the Op::Or issue with push_insn * Prefer asm.store for clarity
2022-08-29Add Opnd::None error message to x86 backend as wellMaxime Chevalier-Boisvert
2022-08-29Opnd::Value fixes (https://github.com/Shopify/ruby/pull/354)Alan Wu
* Fix asm.load(VALUE) - `<VALUE as impl Into<Opnd>>` didn't track that the value is a value - `Iterator::map` doesn't evaluate the closure you give it until you call `collect`. Use a for loop instead so we put the gc offsets into the compiled block properly. * x64: Mov(mem, VALUE) should load the value first Tripped in codegen for putobject now that we are actually feeding `Opnd::Value` into the backend. * x64 split: Canonicallize VALUE loads * Update yjit/src/backend/x86_64/mod.rs
2022-08-29Fix forward_pass usage in arm backend following John's PRMaxime Chevalier-Boisvert
2022-08-29Fix live_ranges idx calculation (https://github.com/Shopify/ruby/pull/353)John Hawthorn
forward_pass adjusts the indexes of our opnds to reflect the new instructions as they are generated in the forward pass. However, we were using the old live_ranges array, for which the new indexes are incorrect. This caused us to previously generate an IR which contained unnecessary trivial load instructions (ex. mov rax, rax), because it was looking at the wrong lifespans. Presumably this could also cause bugs because the lifespan of the incorrectly considered operand idx could be short. We've added an assert which would have failed on the previous trivial case (but not necessarily all cases). Co-authored-by: Matthew Draper <matthew@trebex.net>
2022-08-29Convert getinstancevariable to new backend IR ↵Takashi Kokubun
(https://github.com/Shopify/ruby/pull/352) * Convert getinstancevariable to new backend IR * Support mem-based mem * Use more into() * Add tests for getivar * Just load obj_opnd to a register * Apply another into() * Flip the nil-out condition * Fix duplicated counts of side_exit
2022-08-29Binary OR instruction for the IR (https://github.com/Shopify/ruby/pull/355)Kevin Newton
2022-08-29Add 1 more allocatable reg on armMaxime Chevalier-Boisvert
2022-08-29Fix C call reg alloc bug reported by Noah & KokubunMaxime Chevalier-Boisvert
2022-08-29Implement iterators and double-linked list for IR SSAKevin Newton
2022-08-29Push first pass at SSA IR sketchMaxime Chevalier-Boisvert
2022-08-29Minor cleanups (https://github.com/Shopify/ruby/pull/345)Alan Wu
* Move allocation into Assembler::pos_marker We wanted to do this to begin with but didn't because we were confused about the lifetime parameter. It's actually talking about the lifetime of the references that the closure captures. Since all of our usages capture no references (they use `move`), it's fine to put a `+ 'static` here. * Use optional token syntax for calling convention macro * Explicitly request C ABI on ARM It looks like the Rust calling convention for functions are the same as the C ABI for now and it's unlikely to change, but it's easy for us to be explicit here. I also tried saying `extern "aapcs"` but that unfortunately doesn't work.
2022-08-29Port the YJIT defined opcode; fix C_ARG_REGS ↵Noah Gibbs
(https://github.com/Shopify/ruby/pull/342)
2022-08-29A64: Fix off by one in offset encoding for BL ↵Alan Wu
(https://github.com/Shopify/ruby/pull/344) * A64: Fix off by one in offset encoding for BL It's relative to the address of the instruction not the end of it. * A64: Fix off by one when encoding B It's relative to the start of the instruction not the end. * A64: Add some tests for boundary offsets
2022-08-29Fix a bug in the x86 backend wrt large integer values, enable more testsMaxime Chevalier-Boisvert
2022-08-29Fix IncrCounter on ARMAlan Wu
The order of operands to LDADDAL were flipped and the destination pointer was dereferenced instead of passed as an address.
2022-08-29Add LiveReg IR instruction to fix stats leave exit code ↵Alan Wu
(https://github.com/Shopify/ruby/pull/341) It allows for reserving a specific register and prevents the register allocator from clobbering it. Without this `./miniruby --yjit-stats --yjit-callthreshold=1 -e0` was crashing because the counter incrementing code was clobbering RAX incorrectly.
2022-08-29Fixes (https://github.com/Shopify/ruby/pull/340)Kevin Newton
* Fix conditional jumps to label * Bitmask immediates cannot be u64::MAX
2022-08-29Fixes for AArch64 (https://github.com/Shopify/ruby/pull/338)Kevin Newton
* Better splitting for Op::Add, Op::Sub, and Op::Cmp * Split stores if the displacement is too large * Use a shifted immediate argument * Split all places where shifted immediates are used * Add more tests to the cirrus workflow
2022-08-29Fix bug with opt_lt, csel on x86Maxime Chevalier-Boisvert
2022-08-29Work on opt_lt, fix x86 backend bug in cmp()Maxime Chevalier-Boisvert
2022-08-29Fixes (https://github.com/Shopify/ruby/pull/336)Kevin Newton
* Fix bitmask encoding to u32 * Fix splitting for Op::And to account for bitmask immediate
2022-08-29Better splitting for Op::Test on AArch64 ↵Kevin Newton
(https://github.com/Shopify/ruby/pull/335)
2022-08-29Fix crash in newhash ccallMaxime Chevalier-Boisvert
2022-08-29Fix corrupted X29 causing segfault, thanks Alan!Maxime Chevalier-Boisvert
2022-08-29Temporarily simplify code for emit_conditional_jump to fix a bugMaxime Chevalier-Boisvert
2022-08-29Refactor YJIT branches to use PosMarker ↵Maxime Chevalier-Boisvert
(https://github.com/Shopify/ruby/pull/333) * Refactor defer_compilation to use PosMarker * Port gen_direct_jump() to use PosMarker * Port gen_branch, branchunless * Port over gen_jump() * Port over branchif and branchnil * Fix use od record_boundary_patch_point in jump_to_next_insn
2022-08-29Update disasm to work on ARM (https://github.com/Shopify/ruby/pull/331)Noah Gibbs
2022-08-29Fix dupn (https://github.com/Shopify/ruby/pull/330)Noah Gibbs
* get_dupn was allocating and throwing away an Assembler object instead of using the one passed in * Uncomment remaining tests in codegen.rs, which seem to work now
2022-08-29Implement PosMarker instruction (https://github.com/Shopify/ruby/pull/328)Maxime Chevalier-Boisvert
* Implement PosMarker instruction * Implement PosMarker in the arm backend * Make bindgen run only for clang image * Fix if-else in cirrus CI file * Add missing semicolon * Try removing trailing semicolon * Try to fix shell/YAML syntax Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
2022-08-29A lot of fixes coming from our pairing session ↵Kevin Newton
(https://github.com/Shopify/ruby/pull/329) * Move to/from SP on AArch64 * Consolidate loads and stores * Implement LDR post-index and LDR pre-index for AArch64 * Implement STR post-index and STR pre-index for AArch64 * Module entrypoints for LDR pre/post -index and STR pre/post -index * Use STR (pre-index) and LDR (post-index) to implement push/pop * Go back to using MOV for to/from SP
2022-08-29Fix push/pop and frame setup/teardown with Kevin & AlanMaxime Chevalier-Boisvert
2022-08-29BLR instruction for AArch64 (https://github.com/Shopify/ruby/pull/325)Kevin Newton
2022-08-29AArch64 frames (https://github.com/Shopify/ruby/pull/324)Kevin Newton
2022-08-29ADR fixes for LeaLabel and callsMaxime Chevalier-Boisvert