Skip to content

Commit 3eae02c

Browse files
authored
Start pruning YJIT C code (ruby#172)
* Add constants from vm_core.h * Remove definitions now exported through bindgen * Start pruning YJIT C code
1 parent 3a6d316 commit 3eae02c

File tree

4 files changed

+47
-4315
lines changed

4 files changed

+47
-4315
lines changed

yjit.c

Lines changed: 46 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -112,116 +112,52 @@ rb_iseq_opcode_at_pc(const rb_iseq_t *iseq, const VALUE *pc)
112112
return rb_vm_insn_addr2opcode((const void *)at_pc);
113113
}
114114

115-
#if YJIT_STATS
116-
// Comments for generated code
117-
struct yjit_comment {
118-
uint32_t offset;
119-
const char *comment;
120-
};
121-
122-
typedef rb_darray(struct yjit_comment) yjit_comment_array_t;
123-
static yjit_comment_array_t yjit_code_comments;
124-
125-
// Counters for generated code
126-
#define YJIT_DECLARE_COUNTERS(...) struct rb_yjit_runtime_counters { \
127-
int64_t __VA_ARGS__; \
128-
}; \
129-
static char yjit_counter_names[] = #__VA_ARGS__;
130-
131-
YJIT_DECLARE_COUNTERS(
132-
exec_instruction,
133-
134-
send_keywords,
135-
send_kw_splat,
136-
send_args_splat,
137-
send_block_arg,
138-
send_ivar_set_method,
139-
send_zsuper_method,
140-
send_undef_method,
141-
send_optimized_method,
142-
send_optimized_method_send,
143-
send_optimized_method_call,
144-
send_optimized_method_block_call,
145-
send_missing_method,
146-
send_bmethod,
147-
send_refined_method,
148-
send_cfunc_ruby_array_varg,
149-
send_cfunc_argc_mismatch,
150-
send_cfunc_toomany_args,
151-
send_cfunc_tracing,
152-
send_cfunc_kwargs,
153-
send_attrset_kwargs,
154-
send_iseq_tailcall,
155-
send_iseq_arity_error,
156-
send_iseq_only_keywords,
157-
send_iseq_kwargs_req_and_opt_missing,
158-
send_iseq_kwargs_mismatch,
159-
send_iseq_complex_callee,
160-
send_not_implemented_method,
161-
send_getter_arity,
162-
send_se_cf_overflow,
163-
send_se_protected_check_failed,
164-
165-
traced_cfunc_return,
166-
167-
invokesuper_me_changed,
168-
invokesuper_block,
169-
170-
leave_se_interrupt,
171-
leave_interp_return,
172-
leave_start_pc_non_zero,
173-
174-
getivar_se_self_not_heap,
175-
getivar_idx_out_of_range,
176-
getivar_megamorphic,
177-
178-
setivar_se_self_not_heap,
179-
setivar_idx_out_of_range,
180-
setivar_val_heapobject,
181-
setivar_name_not_mapped,
182-
setivar_not_object,
183-
setivar_frozen,
184-
185-
oaref_argc_not_one,
186-
oaref_arg_not_fixnum,
187-
188-
opt_getinlinecache_miss,
189-
190-
binding_allocations,
191-
binding_set,
192-
193-
vm_insns_count,
194-
compiled_iseq_count,
195-
compiled_block_count,
196-
compilation_failure,
197-
198-
exit_from_branch_stub,
199-
200-
invalidation_count,
201-
invalidate_method_lookup,
202-
invalidate_bop_redefined,
203-
invalidate_ractor_spawn,
204-
invalidate_constant_state_bump,
205-
invalidate_constant_ic_fill,
206-
207-
constant_state_bumps,
208-
209-
expandarray_splat,
210-
expandarray_postarg,
211-
expandarray_not_array,
212-
expandarray_rhs_too_small,
213-
214-
gbpp_block_param_modified,
215-
gbpp_block_handler_not_iseq,
216-
217-
// Member with known name for iterating over counters
218-
last_member
219-
)
220-
221-
static struct rb_yjit_runtime_counters yjit_runtime_counters = { 0 };
222-
#undef YJIT_DECLARE_COUNTERS
223-
224-
#endif // YJIT_STATS
115+
// Query the instruction length in bytes for YARV opcode insn
116+
int
117+
rb_yarv_insn_len(VALUE insn)
118+
{
119+
return insn_len(insn);
120+
}
121+
122+
unsigned int
123+
get_iseq_body_local_table_size(rb_iseq_t* iseq) {
124+
return iseq->body->local_table_size;
125+
}
126+
127+
VALUE*
128+
get_iseq_body_iseq_encoded(rb_iseq_t* iseq) {
129+
return iseq->body->iseq_encoded;
130+
}
131+
132+
int
133+
get_iseq_flags_has_opt(rb_iseq_t* iseq) {
134+
return iseq->body->param.flags.has_opt;
135+
}
136+
137+
struct rb_control_frame_struct *
138+
ec_get_cfp(rb_execution_context_t *ec) {
139+
return ec->cfp;
140+
}
141+
142+
VALUE*
143+
cfp_get_pc(struct rb_control_frame_struct *cfp) {
144+
return cfp->pc;
145+
}
146+
147+
VALUE*
148+
cfp_get_sp(struct rb_control_frame_struct *cfp) {
149+
return cfp->sp;
150+
}
151+
152+
VALUE
153+
cfp_get_self(struct rb_control_frame_struct *cfp) {
154+
return cfp->self;
155+
}
156+
157+
VALUE*
158+
cfp_get_ep(struct rb_control_frame_struct *cfp) {
159+
return cfp->ep;
160+
}
225161

226162
// The number of bytes counting from the beginning of the inline code block
227163
// that should not be changed. After patching for global invalidation, no one

yjit.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ void rb_yjit_iseq_free(const struct rb_iseq_constant_body *body);
7979
void rb_yjit_before_ractor_spawn(void);
8080
void rb_yjit_constant_ic_update(const rb_iseq_t *const iseq, IC ic);
8181
void rb_yjit_tracing_invalidate_all(void);
82+
8283
#else
8384
// !YJIT_BUILD
8485
// In these builds, YJIT could never be turned on. Provide dummy implementations.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy