summaryrefslogtreecommitdiff
path: root/tool/mk_builtin_loader.rb
AgeCommit message (Collapse)Author
2020-12-12tool/mk_builtin_loader.rb: prevent "assigned but unused variable"Yusuke Endoh
2020-07-16skip inlining cexpr! that are not attr! inline卜部昌平
Requested by ko1. Notes: Merged: https://github.com/ruby/ruby/pull/3314
2020-07-13mk_builtin_loader.rb: STACK_ADDR_FROM_TOP unusable卜部昌平
Stacks are emulated in MJIT, must not touch the original VM stack. See also http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/3061353
2020-07-13%p is not portable accross platforms卜部昌平
This commit fixes compiler error on MSVC. %p on that platform is not suitable to represent a compile-time constant. https://ci.appveyor.com/project/ruby/ruby/builds/34017163/job/vj2a8uk3gwv9yxak#L24381 Notes: Merged: https://github.com/ruby/ruby/pull/3305
2020-07-13add comments卜部昌平
Notes: Merged: https://github.com/ruby/ruby/pull/3305
2020-07-13fix typo卜部昌平
Notes: Merged: https://github.com/ruby/ruby/pull/3305
2020-07-13inline Primitive.cexpr!卜部昌平
We can obtain the verbatim source code of Primitive.cexpr!. Why not paste that content into the JITed program. Notes: Merged: https://github.com/ruby/ruby/pull/3305
2020-07-13precalc invokebuiltin destinations卜部昌平
Noticed that struct rb_builtin_function is a purely compile-time constant. MJIT can eliminate some runtime calculations by statically generate dedicated C code generator for each builtin functions. Notes: Merged: https://github.com/ruby/ruby/pull/3305
2020-07-05fix up Primitive.cinit! codeKoichi Sasada
Recent changes break Primitive.cinit!(c_code) so fix it.
2020-07-04support all locals for cexpr!, cstmt!Koichi Sasada
Primitve.cexpr! and .cstmt! can access Ruby's parameter and *local variables* (note that local parameters are also local variables). However recent changes only allow to access parameters. This patch fix it. For example, the following code can work: def foo a, b, k: :kw, **kwrest c = a + b d = k e = kwrest p Primitive.cstmt!(%q(rb_p(rb_ary_new_from_args(5, a, b, c, d, e)); return Qnil;)) end
2020-06-28Calculate header line count instead of hardcodingNobuyoshi Nakada
2020-06-28Replace separators in input file name in header tooNobuyoshi Nakada
2020-06-28Replace ALT_SEPARATOR with SEPARATOR also in output file nameNobuyoshi Nakada
To suppress warnings by Visual C. ``` ./integer.rb(5) : warning C4129: 'i' : unrecognized character escape sequence ./kernel.rb(21) : warning C4129: 'k' : unrecognized character escape sequence ```
2020-06-20Introduce Primitive.attr! to annotate 'inline' (#3242)Takashi Kokubun
[Feature #15589] Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2020-06-19[Feature #16254] Allow `Primitive.func` styleNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/3165
2020-06-19[Feature #16254] Allow `__builtin.func` styleNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/3165
2020-06-14Support arguments of singleton methodNobuyoshi Nakada
2020-06-14Fixed up rest, keywords, keyword rest and block argumentsNobuyoshi Nakada
2020-06-13Make __builtin_cexpr! and __builtin_cstmt! work againTakashi Kokubun
with Ripper. a3e6f52c17061f012c4e638b3343b57752ed7603 introduced __builtin_cexpr! and __builtin_cstmt!, but nobody has used them and then they broke on 79292b30884ebcd8be028a7f3c9ccafd7759f2ae by undefined `params`. This patch fixes the undefined `params`, but still we're not using them yet.
2020-05-19Make builtin loader sources by RipperNobuyoshi Nakada
2020-04-04Also scan `rescue` clausesNobuyoshi Nakada
2019-12-29Separate builtin initialization callsNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/2792
2019-12-26decouple internal.h headers卜部昌平
Saves comitters' daily life by avoid #include-ing everything from internal.h to make each file do so instead. This would significantly speed up incremental builds. We take the following inclusion order in this changeset: 1. "ruby/config.h", where _GNU_SOURCE is defined (must be the very first thing among everything). 2. RUBY_EXTCONF_H if any. 3. Standard C headers, sorted alphabetically. 4. Other system headers, maybe guarded by #ifdef 5. Everything else, sorted alphabetically. Exceptions are those win32-related headers, which tend not be self- containing (headers have inclusion order dependencies). Notes: Merged: https://github.com/ruby/ruby/pull/2711
2019-12-23Fixed a typo in an exception class nameNobuyoshi Nakada
2019-12-13readable function names for inline functions.Koichi Sasada
Now, C functions written by __builtin_cexpr!(code) and others are named as "__builtin_inline#{n}". However, it is difficult to know what the function is. This patch rename them into "__builtin_foo_#{lineno}" when cexpr! is in 'foo' method.
2019-11-27rename __builtin_inline!(code) and introduce others.Koichi Sasada
rename __builtin_inline!(code) to __builtin_cstmt(code). Also this commit introduce the following inlining C code features. * __builtin_cstmt!(STMT) (renamed from __builtin_inline!) Define a function which run STMT implicitly and call this function at evatuation time. Note that you need to return some value in STMT. If there is a local variables (includes method parameters), you can read these values. static VALUE func(ec, self) { VALUE x = ...; STMT } Usage: def double a # a is readable from C code. __builtin_cstmt! 'return INT2FIX(FIX2INT(a) * 2);' end * __builtin_cexpr!(EXPR) Define a function which invoke EXPR implicitly like `__builtin_cstmt!`. Different from cstmt!, which compiled with `return EXPR;`. (`return` and `;` are added implicitly) static VALUE func(ec, self) { VALUE x = ...; return EXPPR; } Usage: def double a __builtin_cexpr! 'INT2FIX(FIX2INT(a) * 2)' end * __builtin_cconst!(EXPR) Define a function which invoke EXPR implicitly like cexpr!. However, the function is called once at compile time, not evaluated time. Any local variables are not accessible (because there is no local variable at compile time). Usage: GCC = __builtin_cconst! '__GNUC__' * __builtin_cinit!(STMT) STMT are writtein in auto-generated code. This code does not return any value. Usage: __builtin_cinit! '#include <zlib.h>' def no_compression? __builtin_cconst! 'Z_NO_COMPRESSION ? Qtrue : Qfalse' end
2019-11-26Write rbinc files to the source directoryNobuyoshi Nakada
Update the target file itself of the dependency on this script. Fall back to the current working directory if unwritable.
2019-11-12Strip the last line which become trailing spacesNobuyoshi Nakada
2019-11-12Get rid of `__` prefix which is presereved by C standardNobuyoshi Nakada
2019-11-11__builtin_inline!Koichi Sasada
Add an experimental `__builtin_inline!(c_expression)` special intrinsic which run a C code snippet. In `c_expression`, you can access the following variables: * ec (rb_execution_context_t *) * self (const VALUE) * local variables (const VALUE) Not that you can read these variables, but you can not write them. You need to return from this expression and return value will be a result of __builtin_inline!(). Examples: `def foo(x) __builtin_inline!('return rb_p(x);'); end` calls `p(x)`. `def double(x) __builtin_inline!('return INT2NUM(NUM2INT(x) * 2);')` returns x*2.
2019-11-09Full-path of builtin scripts no longer neededNobuyoshi Nakada
2019-11-09Revert "don't embed full-path."Koichi Sasada
This reverts commit dfac2e9eb3d697e56d91151584f1d3cf9d2c79c9. It does not work if cwd is different from builddir...
2019-11-09don't embed full-path.Koichi Sasada
miniruby load *.rb from srcdir. To specify file path, tool/mk_builtin_loader.rb embed full path of each *.rb file. However it prevent to pre-generation of required files for tarball. This patch generate srcdir/*.rb from __FILE__ information.
2019-11-08tool/mk_builtin_loader.rb: check if op is an array or notYusuke Endoh
The insn array includes not only an array but also some literal objects.
2019-11-08Add file mode to generated files [ci skip]Nobuyoshi Nakada
2019-11-08Renamed `load_*.inc` as `*.rbinc` to utilize a suffix ruleNobuyoshi Nakada
2019-11-08Stop compiling if type mismatch was found.Koichi Sasada
If there is a type mismatch between expected builtin function type and actual function type, C compiler shows warning. For example, `__builtin_func(1, 2)` expects `func(rb_ec_t*, VALUE self, VALUE p1, VALUE p2)` function definition. However, it is easy to overlook "warning" messages. So this patch changes to stop compiling as an error if there is a mismatch.
2019-11-08support builtin features with Ruby and C.Koichi Sasada
Support loading builtin features written in Ruby, which implement with C builtin functions. [Feature #16254] Several features: (1) Load .rb file at boottime with native binary. Now, prelude.rb is loaded at boottime. However, this file is contained into the interpreter as a text format and we need to compile it. This patch contains a feature to load from binary format. (2) __builtin_func() in Ruby call func() written in C. In Ruby file, we can write `__builtin_func()` like method call. However this is not a method call, but special syntax to call a function `func()` written in C. C functions should be defined in a file (same compile unit) which load this .rb file. Functions (`func` in above example) should be defined with (a) 1st parameter: rb_execution_context_t *ec (b) rest parameters (0 to 15). (c) VALUE return type. This is very similar requirements for functions used by rb_define_method(), however `rb_execution_context_t *ec` is new requirement. (3) automatic C code generation from .rb files. tool/mk_builtin_loader.rb creates a C code to load .rb files needed by miniruby and ruby command. This script is run by BASERUBY, so *.rb should be written in BASERUBY compatbile syntax. This script load a .rb file and find all of __builtin_ prefix method calls, and generate a part of C code to export functions. tool/mk_builtin_binary.rb creates a C code which contains binary compiled Ruby files needed by ruby command. Notes: Merged: https://github.com/ruby/ruby/pull/2655