summaryrefslogtreecommitdiff
path: root/iseq.c
diff options
context:
space:
mode:
authorMaxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>2020-09-11 15:36:40 -0400
committerAlan Wu <XrXr@users.noreply.github.com>2021-10-20 18:19:23 -0400
commit26fecc723699a56e27fefb6fef2b3a13d8a95e51 (patch)
tree442178f1d27404c376b7d692e5e1cd51da19ad1b /iseq.c
parent4929ba0a5ce2ea697bad4b8a33ce6047e99da04a (diff)
Removed native_pop_code, ported call with label
Diffstat (limited to 'iseq.c')
-rw-r--r--iseq.c61
1 files changed, 0 insertions, 61 deletions
diff --git a/iseq.c b/iseq.c
index 15e888670a..8684f2df00 100644
--- a/iseq.c
+++ b/iseq.c
@@ -43,9 +43,6 @@
#include "insns.inc"
#include "insns_info.inc"
#include <sys/mman.h>
-#include "ujit_examples.h"
-
-uint8_t *native_pop_code; // TODO: hack. see addr2insn
VALUE rb_cISeq;
static VALUE iseqw_new(const rb_iseq_t *iseq);
@@ -3217,52 +3214,6 @@ rb_vm_encoded_insn_data_table_init(void)
st_add_direct(rb_encoded_insn_data, key1, (st_data_t)&insn_data[insn]);
st_add_direct(rb_encoded_insn_data, key2, (st_data_t)&insn_data[insn]);
}
-
-
- /*
- native_pop_code = mmap(0, 4096, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_PRIVATE, 0, 0);
- if (native_pop_code == MAP_FAILED) rb_bug("mmap failed");
- uint8_t *head = native_pop_code;
- memcpy(head, ujit_pre_call_bytes, sizeof(ujit_pre_call_bytes));
- head += sizeof(ujit_pre_call_bytes);
- const uint8_t handmade_pop[] = { // TODO assmeble this from a separate file
- 0x48, 0x83, 0x6f, 0x08, 0x08, // subq $8, 8(%rdi)
- 0x48, 0x83, 0xc6, 0x08, // addq $8, %rsi
- 0x48, 0x89, 0x37, // movq %rsi, (%rdi)
- 0x48, 0x89, 0xf0 // movq %rsi, %rax
- };
- memcpy(head, handmade_pop, sizeof(handmade_pop));
- head += sizeof(handmade_pop);
- memcpy(head, ujit_post_call_bytes, sizeof(ujit_post_call_bytes));
- // TODO this is small enough to fit in the page we allocated but that can change
- */
-
-
-
- // I decided to start by replicating Alan's code above using the new assembler
- codeblock_t block;
- codeblock_t* cb = &block;
- cb_init(cb, 4096);
-
- // Write the pre call bytes
- cb_write_prologue(cb);
-
- sub(cb, mem_opnd(64, RDI, 8), imm_opnd(8)); // decrement SP
- add(cb, RSI, imm_opnd(8)); // increment PC
- mov(cb, mem_opnd(64, RDI, 0), RSI); // write new PC to EC object, not necessary for pop bytecode?
- mov(cb, RAX, RSI); // return new PC
-
- // Write the post call bytes
- cb_write_epilogue(cb);
-
- native_pop_code = cb_get_ptr(cb, 0);
-
-
-
-
-
-
-
}
int
@@ -3276,12 +3227,6 @@ rb_vm_insn_addr2insn(const void *addr)
return (int)e->insn;
}
- // TODO this is a hack. The proper way to do this is to refactor this so that it takes
- // the iseq body.
- if (addr && addr == native_pop_code) {
- return BIN(pop);
- }
-
rb_bug("rb_vm_insn_addr2insn: invalid insn address: %p", addr);
}
@@ -3312,12 +3257,6 @@ encoded_iseq_trace_instrument(VALUE *iseq_encoded_insn, rb_event_flag_t turnon,
return e->insn_len;
}
- // TODO this is a hack. The proper way to do this is to refactor this so that it takes
- // the iseq body.
- if (key && (uint8_t *)key == native_pop_code) {
- return insn_len(BIN(pop));
- }
-
rb_bug("trace_instrument: invalid insn address: %p", (void *)*iseq_encoded_insn);
}