diff options
author | Andy Wingo <wingo@pobox.com> | 2020-07-23 12:05:14 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2020-07-23 12:24:11 +0200 |
commit | bb7fa5bdc24e35927d3450343ee23879dc556745 (patch) | |
tree | 682b098eee947bee2bee4e66d6969d76d1b37532 /libguile/jit.c | |
parent | 5e1748f75128107e3a0707b66df5adb95d98437e (diff) | |
download | guile-bb7fa5bdc24e35927d3450343ee23879dc556745.tar.gz |
Add jtable instruction
* doc/ref/vm.texi (Instruction Set): Document new v32-x8-l24 instruction
kind.
(Branch Instructions): Document jtable.
* libguile/instructions.c (FOR_EACH_INSTRUCTION_WORD_TYPE): Add
V32_X8_L24.
* libguile/jit.c (compile_jtable, compile_jtable_slow):
(COMPILE_X8_S24__V32_X8_L24, analyze): Add stub JIT compiler
implementation.
* libguile/vm-engine.c (jtable): New instruction.
* module/language/bytecode.scm (instruction-arity): Deprecate.
* module/system/vm/assembler.scm (encoder, assembler): Add V32_X8_L24
case.
* module/system/vm/disassembler.scm (u32-ref, s32-ref): Move definitions
to expansion-time only.
(define-op-handlers): New definition, replacing visit-opcodes.
(disassemblers, jump-parsers, stack-effect-parsers, clobber-parsers):
Rework in terms of define-op-handlers. Default case becomes #f, and
add support for jtable.
(disassemble-one, instruction-relative-jump-targets)
(instruction-stack-size-after, instruction-slot-clobbers): Inline
default case in the lookup procedure, not copied in the handler
vector.
(compute-labels): Add jtable case.
(instruction-lengths-vector, instruction-length): Rework to allow
variable-length instructions, and mark jtable as being
variable-length.
(instruction-has-fallthrough?): Add jtable to the no-fallthrough
set.
Diffstat (limited to 'libguile/jit.c')
-rw-r--r-- | libguile/jit.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/libguile/jit.c b/libguile/jit.c index e32b859a4..0299b43b0 100644 --- a/libguile/jit.c +++ b/libguile/jit.c @@ -4340,6 +4340,22 @@ compile_jnge_slow (scm_jit_state *j, const uint32_t *vcode) } static void +compile_jtable (scm_jit_state *j, uint32_t idx, uint32_t len, + const uint32_t *offsets) +{ + // Not yet implemented. + UNREACHABLE (); + //jit_reloc_t jmp; + //jmp = jit_jmp (j->jit); + //add_inter_instruction_patch (j, jmp, vcode); +} +static void +compile_jtable_slow (scm_jit_state *j, uint32_t idx, uint32_t len, + const uint32_t *offsets) +{ +} + +static void compile_heap_numbers_equal (scm_jit_state *j, uint16_t a, uint16_t b) { jit_reloc_t k; @@ -5338,6 +5354,15 @@ compile_s64_to_f64_slow (scm_jit_state *j, uint16_t dst, uint16_t src) #define COMPILE_X8_S8_C8_S8__C32(j, comp) \ COMPILE_X8_S8_S8_C8__C32(j, comp) +#define COMPILE_X8_S24__V32_X8_L24(j, comp) \ + { \ + uint32_t a, len; \ + UNPACK_24 (j->ip[0], a); \ + len = j->ip[1]; \ + j->next_ip += len; \ + comp (j, a, len, j->ip + 2); \ + } + #define COMPILE_X32__LO32__L32(j, comp) \ { \ int32_t a = j->ip[1], b = j->ip[2]; \ @@ -5559,6 +5584,22 @@ analyze (scm_jit_state *j) j->op_attrs[target - j->start] |= OP_ATTR_BLOCK; break; + case scm_op_jtable: + { + uint32_t len = j->ip[1]; + const uint32_t *offsets = j->ip + 2; + for (uint32_t i = 0; i < len; i++) + { + int32_t offset = offsets[i]; + offset >>= 8; /* Sign-extending shift. */ + target = j->ip + offset; + ASSERT(j->start <= target && target < j->end); + j->op_attrs[target - j->start] |= OP_ATTR_BLOCK; + } + j->next_ip += len; + break; + } + case scm_op_call: case scm_op_call_label: attrs = OP_ATTR_BLOCK; |