Skip to content

Commit c9ffe75

Browse files
committed
delete unused functions
Looking at the list of symbols inside of libruby-static.a, I found hundreds of functions that are defined, but used from nowhere. There can be reasons for each of them (e.g. some functions are specific to some platform, some are useful when debugging, etc). However it seems the functions deleted here exist for no reason. This changeset reduces the size of ruby binary from 26,671,456 bytes to 26,592,864 bytes on my machine.
1 parent 4d615a0 commit c9ffe75

18 files changed

+7
-301
lines changed

Diff for: constant.h

-4
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,12 @@ VALUE rb_mod_private_constant(int argc, const VALUE *argv, VALUE obj);
3939
VALUE rb_mod_public_constant(int argc, const VALUE *argv, VALUE obj);
4040
VALUE rb_mod_deprecate_constant(int argc, const VALUE *argv, VALUE obj);
4141
void rb_free_const_table(struct rb_id_table *tbl);
42-
VALUE rb_public_const_get(VALUE klass, ID id);
4342
VALUE rb_public_const_get_at(VALUE klass, ID id);
4443
VALUE rb_public_const_get_from(VALUE klass, ID id);
45-
int rb_public_const_defined(VALUE klass, ID id);
46-
int rb_public_const_defined_at(VALUE klass, ID id);
4744
int rb_public_const_defined_from(VALUE klass, ID id);
4845
rb_const_entry_t *rb_const_lookup(VALUE klass, ID id);
4946
int rb_autoloading_value(VALUE mod, ID id, VALUE *value, rb_const_flag_t *flag);
5047
VALUE rb_const_source_location(VALUE, ID);
51-
VALUE rb_const_source_location_from(VALUE, ID);
5248
VALUE rb_const_source_location_at(VALUE, ID);
5349

5450
#endif /* CONSTANT_H */

Diff for: error.c

-7
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,6 @@ rb_syntax_error_append(VALUE exc, VALUE file, int line, int column,
127127
return exc;
128128
}
129129

130-
void
131-
ruby_deprecated_internal_feature(const char *func)
132-
{
133-
rb_print_backtrace();
134-
rb_fatal("%s is only for internal use and deprecated; do not use", func);
135-
}
136-
137130
/*
138131
* call-seq:
139132
* warn(msg) -> nil

Diff for: eval_intern.h

-3
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,6 @@ CREF_OMOD_SHARED_UNSET(rb_cref_t *cref)
250250
cref->flags &= ~CREF_FL_OMOD_SHARED;
251251
}
252252

253-
void rb_thread_cleanup(void);
254-
void rb_thread_wait_other_threads(void);
255-
256253
enum {
257254
RAISED_EXCEPTION = 1,
258255
RAISED_STACKOVERFLOW = 2,

Diff for: hash.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ RHASH_TABLE_EMPTY_P(VALUE hash)
544544
return RHASH_SIZE(hash) == 0;
545545
}
546546

547-
MJIT_FUNC_EXPORTED int
547+
int
548548
rb_hash_ar_table_p(VALUE hash)
549549
{
550550
if (FL_TEST_RAW((hash), RHASH_ST_TABLE_FLAG)) {
@@ -563,7 +563,7 @@ rb_hash_ar_table(VALUE hash)
563563
return RHASH(hash)->as.ar;
564564
}
565565

566-
MJIT_FUNC_EXPORTED st_table *
566+
st_table *
567567
rb_hash_st_table(VALUE hash)
568568
{
569569
HASH_ASSERT(!RHASH_AR_TABLE_P(hash));

Diff for: internal.h

+3-48
Original file line numberDiff line numberDiff line change
@@ -841,12 +841,12 @@ enum ruby_rhash_flags {
841841
#define RHASH_AR_TABLE_SIZE_RAW(h) \
842842
((unsigned int)((RBASIC(h)->flags & RHASH_AR_TABLE_SIZE_MASK) >> RHASH_AR_TABLE_SIZE_SHIFT))
843843

844-
int rb_hash_ar_table_p(VALUE hash);
845-
struct ar_table_struct *rb_hash_ar_table(VALUE hash);
846-
st_table *rb_hash_st_table(VALUE hash);
847844
void rb_hash_st_table_set(VALUE hash, st_table *st);
848845

849846
#if 0 /* for debug */
847+
int rb_hash_ar_table_p(VALUE hash);
848+
struct ar_table_struct *rb_hash_ar_table(VALUE hash);
849+
st_table *rb_hash_st_table(VALUE hash);
850850
#define RHASH_AR_TABLE_P(hash) rb_hash_ar_table_p(hash)
851851
#define RHASH_AR_TABLE(h) rb_hash_ar_table(h)
852852
#define RHASH_ST_TABLE(h) rb_hash_st_table(h)
@@ -1520,16 +1520,9 @@ VALUE rb_check_backtrace(VALUE);
15201520
NORETURN(void rb_async_bug_errno(const char *,int));
15211521
const char *rb_builtin_type_name(int t);
15221522
const char *rb_builtin_class_name(VALUE x);
1523-
PRINTF_ARGS(void rb_sys_warn(const char *fmt, ...), 1, 2);
1524-
PRINTF_ARGS(void rb_syserr_warn(int err, const char *fmt, ...), 2, 3);
1525-
PRINTF_ARGS(void rb_sys_warning(const char *fmt, ...), 1, 2);
1526-
PRINTF_ARGS(void rb_syserr_warning(int err, const char *fmt, ...), 2, 3);
15271523
#ifdef RUBY_ENCODING_H
15281524
VALUE rb_syntax_error_append(VALUE, VALUE, int, int, rb_encoding*, const char*, va_list);
15291525
PRINTF_ARGS(void rb_enc_warn(rb_encoding *enc, const char *fmt, ...), 2, 3);
1530-
PRINTF_ARGS(void rb_sys_enc_warn(rb_encoding *enc, const char *fmt, ...), 2, 3);
1531-
PRINTF_ARGS(void rb_syserr_enc_warn(int err, rb_encoding *enc, const char *fmt, ...), 3, 4);
1532-
PRINTF_ARGS(void rb_enc_warning(rb_encoding *enc, const char *fmt, ...), 2, 3);
15331526
PRINTF_ARGS(void rb_sys_enc_warning(rb_encoding *enc, const char *fmt, ...), 2, 3);
15341527
PRINTF_ARGS(void rb_syserr_enc_warning(int err, rb_encoding *enc, const char *fmt, ...), 3, 4);
15351528
#endif
@@ -1548,9 +1541,6 @@ VALUE rb_nomethod_err_new(VALUE mesg, VALUE recv, VALUE method, VALUE args, int
15481541
VALUE rb_key_err_new(VALUE mesg, VALUE recv, VALUE name);
15491542
#define rb_key_err_raise(mesg, recv, name) \
15501543
rb_exc_raise(rb_key_err_new(mesg, recv, name))
1551-
NORETURN(void ruby_deprecated_internal_feature(const char *));
1552-
#define DEPRECATED_INTERNAL_FEATURE(func) \
1553-
(ruby_deprecated_internal_feature(func), UNREACHABLE)
15541544
VALUE rb_warning_warn(VALUE mod, VALUE str);
15551545
PRINTF_ARGS(VALUE rb_warning_string(const char *fmt, ...), 1, 2);
15561546
NORETURN(void rb_vraise(VALUE, const char *, va_list));
@@ -1694,9 +1684,7 @@ int rb_hash_stlike_update(VALUE hash, st_data_t key, st_update_callback_func fun
16941684
void rb_call_inits(void);
16951685

16961686
/* io.c */
1697-
const char *ruby_get_inplace_mode(void);
16981687
void ruby_set_inplace_mode(const char *);
1699-
ssize_t rb_io_bufread(VALUE io, void *buf, size_t size);
17001688
void rb_stdio_set_default_encoding(void);
17011689
VALUE rb_io_flush_raw(VALUE, int);
17021690
#ifdef RUBY_IO_H
@@ -1707,7 +1695,6 @@ void rb_io_fptr_finalize_internal(void *ptr);
17071695
#define rb_io_fptr_finalize rb_io_fptr_finalize_internal
17081696

17091697
/* load.c */
1710-
VALUE rb_get_load_path(void);
17111698
VALUE rb_get_expanded_load_path(void);
17121699
int rb_require_internal(VALUE fname, int safe);
17131700
NORETURN(void rb_load_fail(VALUE, const char*));
@@ -1973,31 +1960,19 @@ struct RBasicRaw {
19731960
#ifndef USE_SYMBOL_GC
19741961
#define USE_SYMBOL_GC 1
19751962
#endif
1976-
VALUE rb_parser_get_yydebug(VALUE);
19771963
VALUE rb_parser_set_yydebug(VALUE, VALUE);
19781964
RUBY_SYMBOL_EXPORT_BEGIN
19791965
VALUE rb_parser_set_context(VALUE, const struct rb_iseq_struct *, int);
19801966
RUBY_SYMBOL_EXPORT_END
19811967
void *rb_parser_load_file(VALUE parser, VALUE name);
19821968
int rb_is_const_name(VALUE name);
19831969
int rb_is_class_name(VALUE name);
1984-
int rb_is_global_name(VALUE name);
19851970
int rb_is_instance_name(VALUE name);
1986-
int rb_is_attrset_name(VALUE name);
19871971
int rb_is_local_name(VALUE name);
1988-
int rb_is_method_name(VALUE name);
1989-
int rb_is_junk_name(VALUE name);
19901972
PUREFUNC(int rb_is_const_sym(VALUE sym));
1991-
PUREFUNC(int rb_is_class_sym(VALUE sym));
1992-
PUREFUNC(int rb_is_global_sym(VALUE sym));
1993-
PUREFUNC(int rb_is_instance_sym(VALUE sym));
19941973
PUREFUNC(int rb_is_attrset_sym(VALUE sym));
1995-
PUREFUNC(int rb_is_local_sym(VALUE sym));
1996-
PUREFUNC(int rb_is_method_sym(VALUE sym));
1997-
PUREFUNC(int rb_is_junk_sym(VALUE sym));
19981974
ID rb_make_internal_id(void);
19991975
void rb_gc_free_dsymbol(VALUE);
2000-
ID rb_id_attrget(ID id);
20011976

20021977
/* proc.c */
20031978
VALUE rb_proc_location(VALUE self);
@@ -2130,14 +2105,6 @@ VALUE rb_fstring_cstr(const char *str);
21302105
VALUE rb_fstring_enc_new(const char *ptr, long len, rb_encoding *enc);
21312106
#define rb_fstring_enc_lit(str, enc) rb_fstring_enc_new((str), rb_strlen_lit(str), (enc))
21322107
#define rb_fstring_enc_literal(str, enc) rb_fstring_enc_lit(str, enc)
2133-
VALUE rb_fstring_enc_cstr(const char *ptr, rb_encoding *enc);
2134-
# ifdef HAVE_BUILTIN___BUILTIN_CONSTANT_P
2135-
# define rb_fstring_enc_cstr(str, enc) RB_GNUC_EXTENSION_BLOCK( \
2136-
(__builtin_constant_p(str)) ? \
2137-
rb_fstring_enc_new((str), (long)strlen(str), (enc)) : \
2138-
rb_fstring_enc_cstr(str, enc) \
2139-
)
2140-
# endif
21412108
#endif
21422109
int rb_str_buf_cat_escaped_char(VALUE result, unsigned int c, int unicode_p);
21432110
int rb_str_symname_p(VALUE);
@@ -2190,15 +2157,6 @@ rb_str_eql_internal(const VALUE str1, const VALUE str2)
21902157
/* symbol.c */
21912158
#ifdef RUBY_ENCODING_H
21922159
VALUE rb_sym_intern(const char *ptr, long len, rb_encoding *enc);
2193-
VALUE rb_sym_intern_cstr(const char *ptr, rb_encoding *enc);
2194-
#ifdef __GNUC__
2195-
#define rb_sym_intern_cstr(ptr, enc) __extension__ ( \
2196-
{ \
2197-
(__builtin_constant_p(ptr)) ? \
2198-
rb_sym_intern((ptr), (long)strlen(ptr), (enc)) : \
2199-
rb_sym_intern_cstr((ptr), (enc)); \
2200-
})
2201-
#endif
22022160
#endif
22032161
VALUE rb_sym_intern_ascii(const char *ptr, long len);
22042162
VALUE rb_sym_intern_ascii_cstr(const char *ptr);
@@ -2296,9 +2254,6 @@ void rb_vm_mark(void *ptr);
22962254
void Init_BareVM(void);
22972255
void Init_vm_objects(void);
22982256
PUREFUNC(VALUE rb_vm_top_self(void));
2299-
void rb_thread_recycle_stack_release(VALUE *);
2300-
VALUE *rb_thread_recycle_stack(size_t);
2301-
void rb_vm_change_state(void);
23022257
void rb_vm_inc_const_missing_count(void);
23032258
const void **rb_vm_get_insns_address_table(void);
23042259
VALUE rb_source_location(int *pline);

Diff for: io.c

-16
Original file line numberDiff line numberDiff line change
@@ -2493,16 +2493,6 @@ io_fread(VALUE str, long offset, long size, rb_io_t *fptr)
24932493
return len;
24942494
}
24952495

2496-
ssize_t
2497-
rb_io_bufread(VALUE io, void *buf, size_t size)
2498-
{
2499-
rb_io_t *fptr;
2500-
2501-
GetOpenFile(io, fptr);
2502-
rb_io_check_readable(fptr);
2503-
return (ssize_t)io_bufread(buf, (long)size, fptr);
2504-
}
2505-
25062496
static long
25072497
remain_size(rb_io_t *fptr)
25082498
{
@@ -12870,12 +12860,6 @@ opt_i_set(VALUE val, ID id, VALUE *var)
1287012860
argf_inplace_mode_set(*var, val);
1287112861
}
1287212862

12873-
const char *
12874-
ruby_get_inplace_mode(void)
12875-
{
12876-
return RSTRING_PTR(ARGF.inplace);
12877-
}
12878-
1287912863
void
1288012864
ruby_set_inplace_mode(const char *suffix)
1288112865
{

Diff for: iseq.c

-14
Original file line numberDiff line numberDiff line change
@@ -1012,12 +1012,6 @@ rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE realpath, VALUE line, V
10121012
return iseq;
10131013
}
10141014

1015-
rb_iseq_t *
1016-
rb_iseq_compile(VALUE src, VALUE file, VALUE line)
1017-
{
1018-
return rb_iseq_compile_with_option(src, file, Qnil, line, Qnil);
1019-
}
1020-
10211015
VALUE
10221016
rb_iseq_path(const rb_iseq_t *iseq)
10231017
{
@@ -3308,14 +3302,6 @@ rb_iseq_trace_set_all(rb_event_flag_t turnon_events)
33083302
rb_objspace_each_objects(trace_set_i, &turnon_events);
33093303
}
33103304

3311-
/* This is exported since Ruby 2.5 but not internally used for now. If you're going to use this, please
3312-
update `ruby_vm_event_enabled_global_flags` and set `mjit_call_p = FALSE` as well to cancel MJIT code. */
3313-
void
3314-
rb_iseq_trace_on_all(void)
3315-
{
3316-
rb_iseq_trace_set_all(RUBY_EVENT_TRACEPOINT_ALL);
3317-
}
3318-
33193305
VALUE
33203306
rb_iseqw_local_variables(VALUE iseqval)
33213307
{

Diff for: iseq.h

-2
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,9 @@ void rb_iseq_mark_insn_storage(struct iseq_compile_data_storage *arena);
182182
/* iseq.c */
183183
VALUE rb_iseq_load(VALUE data, VALUE parent, VALUE opt);
184184
VALUE rb_iseq_parameters(const rb_iseq_t *iseq, int is_proc);
185-
struct st_table *ruby_insn_make_insn_table(void);
186185
unsigned int rb_iseq_line_no(const rb_iseq_t *iseq, size_t pos);
187186
void rb_iseq_trace_set(const rb_iseq_t *iseq, rb_event_flag_t turnon_events);
188187
void rb_iseq_trace_set_all(rb_event_flag_t turnon_events);
189-
void rb_iseq_trace_on_all(void);
190188
void rb_iseq_insns_info_encode_positions(const rb_iseq_t *iseq);
191189

192190
VALUE rb_iseqw_new(const rb_iseq_t *iseq);

Diff for: load.c

-7
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@ static const char *const loadable_ext[] = {
2828
0
2929
};
3030

31-
VALUE
32-
rb_get_load_path(void)
33-
{
34-
VALUE load_path = GET_VM()->load_path;
35-
return load_path;
36-
}
37-
3831
enum expand_type {
3932
EXPAND_ALL,
4033
EXPAND_RELATIVE,

Diff for: method.h

-3
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,8 @@ int rb_method_entry_eq(const rb_method_entry_t *m1, const rb_method_entry_t *m2)
215215
st_index_t rb_hash_method_entry(st_index_t hash, const rb_method_entry_t *me);
216216

217217
VALUE rb_method_entry_location(const rb_method_entry_t *me);
218-
VALUE rb_mod_method_location(VALUE mod, ID id);
219-
VALUE rb_obj_method_location(VALUE obj, ID id);
220218

221219
void rb_free_method_entry(const rb_method_entry_t *me);
222-
void rb_sweep_method_entry(void *vm);
223220

224221
const rb_method_entry_t *rb_method_entry_clone(const rb_method_entry_t *me);
225222
const rb_callable_method_entry_t *rb_method_entry_complement_defined_class(const rb_method_entry_t *src_me, ID called_id, VALUE defined_class);

Diff for: mjit.h

-4
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ RUBY_SYMBOL_EXPORT_END
7979

8080
extern bool mjit_compile(FILE *f, const rb_iseq_t *iseq, const char *funcname);
8181
extern void mjit_init(struct mjit_options *opts);
82-
extern void mjit_postponed_job_register_start_hook(void);
83-
extern void mjit_postponed_job_register_finish_hook(void);
8482
extern void mjit_gc_start_hook(void);
8583
extern void mjit_gc_exit_hook(void);
8684
extern void mjit_free_iseq(const rb_iseq_t *iseq);
@@ -164,8 +162,6 @@ void mjit_child_after_fork(void);
164162
#else // USE_MJIT
165163
static inline struct mjit_cont *mjit_cont_new(rb_execution_context_t *ec){return NULL;}
166164
static inline void mjit_cont_free(struct mjit_cont *cont){}
167-
static inline void mjit_postponed_job_register_start_hook(void){}
168-
static inline void mjit_postponed_job_register_finish_hook(void){}
169165
static inline void mjit_gc_start_hook(void){}
170166
static inline void mjit_gc_exit_hook(void){}
171167
static inline void mjit_free_iseq(const rb_iseq_t *iseq){}

Diff for: node.h

-7
Original file line numberDiff line numberDiff line change
@@ -414,22 +414,15 @@ void rb_ast_delete_node(rb_ast_t*, NODE *n);
414414
VALUE rb_parser_new(void);
415415
VALUE rb_parser_end_seen_p(VALUE);
416416
VALUE rb_parser_encoding(VALUE);
417-
VALUE rb_parser_get_yydebug(VALUE);
418417
VALUE rb_parser_set_yydebug(VALUE, VALUE);
419418
VALUE rb_parser_dump_tree(const NODE *node, int comment);
420419
void rb_parser_set_options(VALUE, int, int, int, int);
421420

422-
rb_ast_t *rb_parser_compile_cstr(VALUE, const char*, const char*, int, int);
423421
rb_ast_t *rb_parser_compile_string(VALUE, const char*, VALUE, int);
424-
rb_ast_t *rb_parser_compile_file(VALUE, const char*, VALUE, int);
425422
rb_ast_t *rb_parser_compile_string_path(VALUE vparser, VALUE fname, VALUE src, int line);
426423
rb_ast_t *rb_parser_compile_file_path(VALUE vparser, VALUE fname, VALUE input, int line);
427424
rb_ast_t *rb_parser_compile_generic(VALUE vparser, VALUE (*lex_gets)(VALUE, int), VALUE fname, VALUE input, int line);
428425

429-
rb_ast_t *rb_compile_cstr(const char*, const char*, int, int);
430-
rb_ast_t *rb_compile_string(const char*, VALUE, int);
431-
rb_ast_t *rb_compile_file(const char*, VALUE, int);
432-
433426
void rb_node_init(NODE *n, enum node_type type, VALUE a0, VALUE a1, VALUE a2);
434427
const char *ruby_node_name(int node);
435428

0 commit comments

Comments
 (0)