Last active
April 19, 2019 13:58
-
-
Save frsyuki/ce9d9715309cdd20787026954a6eb31f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
./configure \ | |
$(ruby -e "puts RbConfig::CONFIG['configure_args']") \ | |
CFLAGS=$(ruby -e "puts RbConfig::CONFIG['CFLAGS'] + ' -flto'") \ | |
LDFLAGS=$(ruby -e "puts RbConfig::CONFIG['LDFLAGS'] + ' -flto'") \ | |
--enable-shared \ | |
--prefix=$(pwd)/install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/mjit_compile.c b/mjit_compile.c | |
index 07e417e75b..59a288941b 100644 | |
--- a/mjit_compile.c | |
+++ b/mjit_compile.c | |
@@ -20,6 +20,7 @@ | |
#include "insns.inc" | |
#include "insns_info.inc" | |
#include "vm_insnhelper.h" | |
+#include <dlfcn.h> | |
/* Macros to check if a position is already compiled using compile_status.stack_size_for_pos */ | |
#define NOT_COMPILED_STACK_SIZE -1 | |
diff --git a/mjit_worker.c b/mjit_worker.c | |
index d4ff92ed29..bc8a3f8f6c 100644 | |
--- a/mjit_worker.c | |
+++ b/mjit_worker.c | |
@@ -661,7 +661,7 @@ static int | |
compile_c_to_so(const char *c_file, const char *so_file) | |
{ | |
int exit_code; | |
- const char *files[] = { NULL, NULL, NULL, NULL, NULL, NULL, "-link", libruby_pathflag, NULL }; | |
+ const char *files[] = { NULL, NULL, NULL, NULL, NULL, NULL, "-link", libruby_pathflag, "-flto", NULL }; | |
char **args; | |
char *p, *obj_file; | |
@@ -743,6 +743,7 @@ make_pch(void) | |
// -nodefaultlibs is a linker flag, but it may affect cc1 behavior on Gentoo, which should NOT be changed on pch: | |
// https://gitweb.gentoo.org/proj/gcc-patches.git/tree/7.3.0/gentoo/13_all_default-ssp-fix.patch | |
GCC_NOSTDLIB_FLAGS | |
+ "-flto", | |
"-o", NULL, NULL, | |
NULL, | |
}; | |
@@ -787,7 +788,7 @@ compile_c_to_o(const char *c_file, const char *o_file) | |
# ifdef __clang__ | |
"-include-pch", NULL, | |
# endif | |
- "-c", NULL | |
+ "-c", "-flto", NULL | |
}; | |
char **args; | |
@@ -818,7 +819,7 @@ link_o_to_so(const char **o_files, const char *so_file) | |
# ifdef _WIN32 | |
libruby_pathflag, | |
# endif | |
- NULL | |
+ "-flto", NULL | |
}; | |
char **args; | |
diff --git a/tool/ruby_vm/views/_mjit_compile_insn.erb b/tool/ruby_vm/views/_mjit_compile_insn.erb | |
index a52c928abf..53e1199be2 100644 | |
--- a/tool/ruby_vm/views/_mjit_compile_insn.erb | |
+++ b/tool/ruby_vm/views/_mjit_compile_insn.erb | |
@@ -51,7 +51,28 @@ | |
<%= render 'mjit_compile_pc_and_sp', locals: { insn: insn } -%> | |
% | |
% # JIT: Print insn body in insns.def | |
+% if insn.name == 'send' | |
+ Dl_info in; | |
+ if (dladdr(((CALL_CACHE)operands[1])->call, &in) != 0) { | |
+ fprintf(f, " {\n"); | |
+ fprintf(f, " struct rb_calling_info calling;\n\n"); | |
+ fprintf(f, " calling.block_handler = vm_caller_setup_arg_block(ec, reg_cfp, ci, blockiseq, FALSE);\n"); | |
+ fprintf(f, " calling.recv = TOPN(calling.argc = ci->orig_argc);\n"); | |
+ fprintf(f, " vm_search_method(ci, cc, calling.recv);\n"); | |
+ fprintf(f, " VALUE v = %s(ec, GET_CFP(), &calling, ci, cc);\n", in.dli_sname); | |
+ fprintf(f, " if (v == Qundef) {\n"); | |
+ fprintf(f, " EXEC_EC_CFP(val);\n"); | |
+ fprintf(f, " } else {\n"); | |
+ fprintf(f, " val = v;\n"); | |
+ fprintf(f, " }\n"); | |
+ fprintf(f, " }\n"); | |
+ } | |
+ else { | |
+% end | |
<%= render 'mjit_compile_insn_body', locals: { insn: insn } -%> | |
+% if insn.name == 'send' | |
+ } | |
+% end | |
% | |
% # JIT: Set return values | |
% insn.rets.reverse_each.with_index do |ret, i| |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment