summaryrefslogtreecommitdiff
path: root/tool/mk_builtin_loader.rb
Commit message (Collapse)AuthorAgeFilesLines
* YJIT: Introduce no_gc attribute (#7511)Takashi Kokubun2023-03-141-1/+1
|
* RJIT: Introduce constants under RubyVM::RJIT::CTakashi Kokubun2023-03-111-1/+2
|
* Rename builtin attr :inline to :leafTakashi Kokubun2023-03-111-4/+1
|
* Support multiple attributes with Primitive.attr!Takashi Kokubun2023-03-111-7/+12
|
* Change the syntax of Primitive.attr! to Symbol (#7501)Takashi Kokubun2023-03-101-4/+22
|
* Remove MJIT's builtin function compilerTakashi Kokubun2023-03-071-40/+2
|
* s/mjit/rjit/Takashi Kokubun2023-03-061-2/+2
|
* Use class methods of `File` over `Kernel.open` and `IO.read`Nobuyoshi Nakada2022-12-011-3/+3
|
* MJIT: Use a String buffer in builtin compilersTakashi Kokubun2022-11-271-9/+9
| | | | | | | instead of FILE*. Using C.fprintf is slower than String manipulation on memory. I'm going to change the way MJIT writes files, and this is a prerequisite for it.
* Fix the trailing comma comment for builtin [ci skip]Takashi Kokubun2022-09-201-1/+1
| | | | so that it's clear why not args.last but args[1]
* Support trailing commas in builtinTakashi Kokubun2022-09-201-1/+6
| | | | `foo(Primitive.cexpr!('Qnil'),)` causes SEGV without this change.
* Support sub-library in builtin-loaderNobuyoshi Nakada2022-09-091-0/+36
| | | | | Previously, it was supported in prelude.c, but has not followed up the builtin-loader system.
* Add ISEQ_BODY macroPeter Zhu2022-03-241-1/+1
| | | | | | Use ISEQ_BODY macro to get the rb_iseq_constant_body of the ISeq. Using this macro will make it easier for us to change the allocation strategy of rb_iseq_constant_body when using Variable Width Allocation.
* `Primitive.mandatory_only?` for fast pathKoichi Sasada2021-11-151-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Compare with the C methods, A built-in methods written in Ruby is slower if only mandatory parameters are given because it needs to check the argumens and fill default values for optional and keyword parameters (C methods can check the number of parameters with `argc`, so there are no overhead). Passing mandatory arguments are common (optional arguments are exceptional, in many cases) so it is important to provide the fast path for such common cases. `Primitive.mandatory_only?` is a special builtin function used with `if` expression like that: ```ruby def self.at(time, subsec = false, unit = :microsecond, in: nil) if Primitive.mandatory_only? Primitive.time_s_at1(time) else Primitive.time_s_at(time, subsec, unit, Primitive.arg!(:in)) end end ``` and it makes two ISeq, ``` def self.at(time, subsec = false, unit = :microsecond, in: nil) Primitive.time_s_at(time, subsec, unit, Primitive.arg!(:in)) end def self.at(time) Primitive.time_s_at1(time) end ``` and (2) is pointed by (1). Note that `Primitive.mandatory_only?` should be used only in a condition of an `if` statement and the `if` statement should be equal to the methdo body (you can not put any expression before and after the `if` statement). A method entry with `mandatory_only?` (`Time.at` on the above case) is marked as `iseq_overload`. When the method will be dispatch only with mandatory arguments (`Time.at(0)` for example), make another method entry with ISeq (2) as mandatory only method entry and it will be cached in an inline method cache. The idea is similar discussed in https://bugs.ruby-lang.org/issues/16254 but it only checks mandatory parameters or more, because many cases only mandatory parameters are given. If we find other cases (optional or keyword parameters are used frequently and it hurts performance), we can extend the feature.
* Use `VALUE` instead of `intptr_t`Nobuyoshi Nakada2021-08-161-1/+1
| | | | | On emscripten `intptr_t`, `uintptr_t`, `ptrdiff_t` and so on are defined as `long`, but `PRIdPTR` and so on defined as `int`.
* Fix trivial -Wundef warningsBenoit Daloze2021-05-041-1/+1
| | | | | | * See [Feature #17752] Co-authored-by: xtkoba (Tee KOBAYASHI) <xtkoba+ruby@gmail.com>
* Method ID of call and fcall can be const not only identNobuyoshi Nakada2021-01-011-1/+1
|
* Access to reserved word parameter like as `__builtin.arg!(:if)`Nobuyoshi Nakada2020-12-311-0/+6
|
* tool/mk_builtin_loader.rb: prevent "assigned but unused variable"Yusuke Endoh2020-12-121-2/+2
|
* skip inlining cexpr! that are not attr! inline卜部昌平2020-07-161-22/+26
| | | | Requested by ko1.
* mk_builtin_loader.rb: STACK_ADDR_FROM_TOP unusable卜部昌平2020-07-131-2/+2
| | | | | | 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
* %p is not portable accross platforms卜部昌平2020-07-131-1/+1
| | | | | | | 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
* add comments卜部昌平2020-07-131-1/+1
|
* fix typo卜部昌平2020-07-131-1/+1
|
* inline Primitive.cexpr!卜部昌平2020-07-131-27/+54
| | | | | We can obtain the verbatim source code of Primitive.cexpr!. Why not paste that content into the JITed program.
* precalc invokebuiltin destinations卜部昌平2020-07-131-2/+21
| | | | | | 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.
* fix up Primitive.cinit! codeKoichi Sasada2020-07-051-2/+2
| | | | Recent changes break Primitive.cinit!(c_code) so fix it.
* support all locals for cexpr!, cstmt!Koichi Sasada2020-07-041-27/+50
| | | | | | | | | | | | | | | | | 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
* Calculate header line count instead of hardcodingNobuyoshi Nakada2020-06-281-1/+2
|
* Replace separators in input file name in header tooNobuyoshi Nakada2020-06-281-4/+4
|
* Replace ALT_SEPARATOR with SEPARATOR also in output file nameNobuyoshi Nakada2020-06-281-1/+5
| | | | | | | | 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 ```
* Introduce Primitive.attr! to annotate 'inline' (#3242)Takashi Kokubun2020-06-201-0/+6
| | | [Feature #15589]
* [Feature #16254] Allow `Primitive.func` styleNobuyoshi Nakada2020-06-191-0/+5
|
* [Feature #16254] Allow `__builtin.func` styleNobuyoshi Nakada2020-06-191-3/+20
|
* Support arguments of singleton methodNobuyoshi Nakada2020-06-141-0/+1
|
* Fixed up rest, keywords, keyword rest and block argumentsNobuyoshi Nakada2020-06-141-2/+9
|
* Make __builtin_cexpr! and __builtin_cstmt! work againTakashi Kokubun2020-06-131-2/+17
| | | | | | | | | | | 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.
* Make builtin loader sources by RipperNobuyoshi Nakada2020-05-191-44/+70
|
* Also scan `rescue` clausesNobuyoshi Nakada2020-04-041-1/+1
|
* Separate builtin initialization callsNobuyoshi Nakada2019-12-291-1/+1
|
* decouple internal.h headers卜部昌平2019-12-261-2/+7
| | | | | | | | | | | | | | | | | | 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).
* Fixed a typo in an exception class nameNobuyoshi Nakada2019-12-231-1/+1
|
* readable function names for inline functions.Koichi Sasada2019-12-131-20/+52
| | | | | | | 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.
* rename __builtin_inline!(code) and introduce others.Koichi Sasada2019-11-271-22/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Write rbinc files to the source directoryNobuyoshi Nakada2019-11-261-3/+11
| | | | | Update the target file itself of the dependency on this script. Fall back to the current working directory if unwritable.
* Strip the last line which become trailing spacesNobuyoshi Nakada2019-11-121-1/+1
|
* Get rid of `__` prefix which is presereved by C standardNobuyoshi Nakada2019-11-121-1/+1
|
* __builtin_inline!Koichi Sasada2019-11-111-5/+53
| | | | | | | | | | | | | | | | | 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.
* Full-path of builtin scripts no longer neededNobuyoshi Nakada2019-11-091-4/+2
|
* Revert "don't embed full-path."Koichi Sasada2019-11-091-1/+2
| | | | | | This reverts commit dfac2e9eb3d697e56d91151584f1d3cf9d2c79c9. It does not work if cwd is different from builddir...