summaryrefslogtreecommitdiff
path: root/re.c
AgeCommit message (Collapse)Author
2018-12-13re.c: [DOC] fix typosstomar
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66387 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-13[DOC] Fix typos [ci skip]kazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-12Enchance MatchData docs [Bug #14450]naruse
From: Victor Shepelev <zverok.offline@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66350 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-04Prefer rb_check_arity when 0 or 1 argumentsnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66179 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-21char is not unsignedshyouhei
It seems that decades ago, ruby was written under assumption that char is unsigned. Which is of course a false assumption. We need to explicitly store a numeric value into an unsigned char variable to tell we expect 0..255 value. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65900 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-12char is neither signed nor unsignedshyouhei
read_escaped_byte() returns values of range -1...256. -1 indicates error. So the function basically expects char to be 0..255 range. There is no such guarantee. `char` is not always unsigned. We need to explicitly declare chbuf to be unsigned char. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-07Fix call-seq [ci skip]kazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-29no-op if it is T_STRINGnaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64887 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-29* expand tabs.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-29Remove unnecessary use of function pointernaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-21Remove -Wno-parentheses flag.nobu
[Fix GH-1958] From: Jun Aruga <jaruga@redhat.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64806 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-16re.c: do not escape terminator in Regexp.unionnobu
* re.c (rb_reg_str_with_term): change terminator. * re.c (rb_reg_s_union): terminator in source string does not need to be escaped. terminators are outside of regexp source itself. [ruby-core:86149] [Bug #14608] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62779 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-11re.c: fixed escaped multibyte charnobu
* re.c (unescape_nonascii): escaped multibyte character should be copied as-is, just with checking if the encoding matches. https://twitter.com/sakuro/status/972014409986883584 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62718 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-04mjit_compile.c: merge initial JIT compilerk0kubun
which has been developed by Takashi Kokubun <takashikkbn@gmail> as YARV-MJIT. Many of its bugs are fixed by wanabe <s.wanabe@gmail.com>. This JIT compiler is designed to be a safe migration path to introduce JIT compiler to MRI. So this commit does not include any bytecode changes or dynamic instruction modifications, which are done in original MJIT. This commit even strips off some aggressive optimizations from YARV-MJIT, and thus it's slower than YARV-MJIT too. But it's still fairly faster than Ruby 2.5 in some benchmarks (attached below). Note that this JIT compiler passes `make test`, `make test-all`, `make test-spec` without JIT, and even with JIT. Not only it's perfectly safe with JIT disabled because it does not replace VM instructions unlike MJIT, but also with JIT enabled it stably runs Ruby applications including Rails applications. I'm expecting this version as just "initial" JIT compiler. I have many optimization ideas which are skipped for initial merging, and you may easily replace this JIT compiler with a faster one by just replacing mjit_compile.c. `mjit_compile` interface is designed for the purpose. common.mk: update dependencies for mjit_compile.c. internal.h: declare `rb_vm_insn_addr2insn` for MJIT. vm.c: exclude some definitions if `-DMJIT_HEADER` is provided to compiler. This avoids to include some functions which take a long time to compile, e.g. vm_exec_core. Some of the purpose is achieved in transform_mjit_header.rb (see `IGNORED_FUNCTIONS`) but others are manually resolved for now. Load mjit_helper.h for MJIT header. mjit_helper.h: New. This is a file used only by JIT-ed code. I'll refactor `mjit_call_cfunc` later. vm_eval.c: add some #ifdef switches to skip compiling some functions like Init_vm_eval. win32/mkexports.rb: export thread/ec functions, which are used by MJIT. include/ruby/defines.h: add MJIT_FUNC_EXPORTED macro alis to clarify that a function is exported only for MJIT. array.c: export a function used by MJIT. bignum.c: ditto. class.c: ditto. compile.c: ditto. error.c: ditto. gc.c: ditto. hash.c: ditto. iseq.c: ditto. numeric.c: ditto. object.c: ditto. proc.c: ditto. re.c: ditto. st.c: ditto. string.c: ditto. thread.c: ditto. variable.c: ditto. vm_backtrace.c: ditto. vm_insnhelper.c: ditto. vm_method.c: ditto. I would like to improve maintainability of function exports, but I believe this way is acceptable as initial merging if we clarify the new exports are for MJIT (so that we can use them as TODO list to fix) and add unit tests to detect unresolved symbols. I'll add unit tests of JIT compilations in succeeding commits. Author: Takashi Kokubun <takashikkbn@gmail.com> Contributor: wanabe <s.wanabe@gmail.com> Part of [Feature #14235] --- * Known issues * Code generated by gcc is faster than clang. The benchmark may be worse in macOS. Following benchmark result is provided by gcc w/ Linux. * Performance is decreased when Google Chrome is running * JIT can work on MinGW, but it doesn't improve performance at least in short running benchmark. * Currently it doesn't perform well with Rails. We'll try to fix this before release. --- * Benchmark reslts Benchmarked with: Intel 4.0GHz i7-4790K with 16GB memory under x86-64 Ubuntu 8 Cores - 2.0.0-p0: Ruby 2.0.0-p0 - r62186: Ruby trunk (early 2.6.0), before MJIT changes - JIT off: On this commit, but without `--jit` option - JIT on: On this commit, and with `--jit` option ** Optcarrot fps Benchmark: https://github.com/mame/optcarrot | |2.0.0-p0 |r62186 |JIT off |JIT on | |:--------|:--------|:--------|:--------|:--------| |fps |37.32 |51.46 |51.31 |58.88 | |vs 2.0.0 |1.00x |1.38x |1.37x |1.58x | ** MJIT benchmarks Benchmark: https://github.com/benchmark-driver/mjit-benchmarks (Original: https://github.com/vnmakarov/ruby/tree/rtl_mjit_branch/MJIT-benchmarks) | |2.0.0-p0 |r62186 |JIT off |JIT on | |:----------|:--------|:--------|:--------|:--------| |aread |1.00 |1.09 |1.07 |2.19 | |aref |1.00 |1.13 |1.11 |2.22 | |aset |1.00 |1.50 |1.45 |2.64 | |awrite |1.00 |1.17 |1.13 |2.20 | |call |1.00 |1.29 |1.26 |2.02 | |const2 |1.00 |1.10 |1.10 |2.19 | |const |1.00 |1.11 |1.10 |2.19 | |fannk |1.00 |1.04 |1.02 |1.00 | |fib |1.00 |1.32 |1.31 |1.84 | |ivread |1.00 |1.13 |1.12 |2.43 | |ivwrite |1.00 |1.23 |1.21 |2.40 | |mandelbrot |1.00 |1.13 |1.16 |1.28 | |meteor |1.00 |2.97 |2.92 |3.17 | |nbody |1.00 |1.17 |1.15 |1.49 | |nest-ntimes|1.00 |1.22 |1.20 |1.39 | |nest-while |1.00 |1.10 |1.10 |1.37 | |norm |1.00 |1.18 |1.16 |1.24 | |nsvb |1.00 |1.16 |1.16 |1.17 | |red-black |1.00 |1.02 |0.99 |1.12 | |sieve |1.00 |1.30 |1.28 |1.62 | |trees |1.00 |1.14 |1.13 |1.19 | |while |1.00 |1.12 |1.11 |2.41 | ** Discourse's script/bench.rb Benchmark: https://github.com/discourse/discourse/blob/v1.8.7/script/bench.rb NOTE: Rails performance was somehow a little degraded with JIT for now. We should fix this. (At least I know opt_aref is performing badly in JIT and I have an idea to fix it. Please wait for the fix.) *** JIT off Your Results: (note for timings- percentile is first, duration is second in millisecs) categories_admin: 50: 17 75: 18 90: 22 99: 29 home_admin: 50: 21 75: 21 90: 27 99: 40 topic_admin: 50: 17 75: 18 90: 22 99: 32 categories: 50: 35 75: 41 90: 43 99: 77 home: 50: 39 75: 46 90: 49 99: 95 topic: 50: 46 75: 52 90: 56 99: 101 *** JIT on Your Results: (note for timings- percentile is first, duration is second in millisecs) categories_admin: 50: 19 75: 21 90: 25 99: 33 home_admin: 50: 24 75: 26 90: 30 99: 35 topic_admin: 50: 19 75: 20 90: 25 99: 30 categories: 50: 40 75: 44 90: 48 99: 76 home: 50: 42 75: 48 90: 51 99: 89 topic: 50: 49 75: 55 90: 58 99: 99 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-18rb_reg_raise_str marked as NORETURNshyouhei
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-18rb_enc_reg_raise marked as NORETURNshyouhei
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61919 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-18rb_reg_enc_error marked as NORETURNshyouhei
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61918 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-18rb_reg_raise marked as NORETURNshyouhei
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61917 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09internal.h: remove dependecy on ruby/encoding.hnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-04ULL suffix is a C99ismshyouhei
... and why not just use ~0 instead? git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61593 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-13[DOC] Fix exception class [ci skip]kazu
ref https://github.com/rurema/doctree/pull/816 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-16Regexp#===: Use `\A` and `\z` instead of `^` and `$`kazu
[ci skip] ref https://github.com/rurema/doctree/pull/812 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21[Feature #13712] String#start_with? supports regexpnaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-02use rb_hash_new_with_size()nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60101 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-18re.c: remove unused rb_memcmp() functionrhe
It is no longer used or exported as of r13641. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59953 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-11re.c: options for sub-regexpnobu
* re.c (rb_reg_to_s): needs embedded options to check syntax of sub-regexp. [ruby-core:82328] [Bug #13798] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59574 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-02refine a warning message.akr
The "n" option for regexp, /.../n, is historical. It doesn't mean the regexp works as binary match since Ruby 1.9. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57759 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-22refine warning message for binary regexp /.../n.akr
Reported by Herwin W. [ruby-core:78592] [Bug #13024] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57684 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-20re.c: consider the case of RMatch::regexp is nilrhe
Follow r49675, r57098 and r57110. Don't assume RMatch::regexp always contains a valid Regexp instance; it will be Qnil if the MatchData is created by rb_backref_set_string(). [ruby-core:78741] [Bug #13054] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57123 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-19re.c: RB_TYPE_Pnobu
* re.c (match_backref_number, namev_to_backref_number): use RB_TYPE_P instead of switching by TYPE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57114 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-19re.c: NAME_TO_NUMBERnobu
* re.c (namev_to_backref_number, rb_reg_regsub): extract name to backref number check as NAME_TO_NUMBER. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-18re.c: use name_to_backref_numbernobu
* re.c (match_backref_number): use name_to_backref_number for casts. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57110 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-17re.c: non-regexp name referencenobu
* re.c (rb_reg_regsub): other than regexp has no name references. [ruby-core:78686] [Bug #13042] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-12String#match? and Symbol#match?nobu
* string.c (rb_str_match_m_p): inverse of Regexp#match?. based on the patch by Herwin Weststrate <herwin@snt.utwente.nl>. [Fix GH-1483] [Feature #12898] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-12re.c: char boundarynobu
* re.c (rb_reg_match_m_p): consider char boundary. rb_str_subpos does not adjust to the boundary if len == 0. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57051 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-10Merge Onigmo 6.0.0naruse
* https://github.com/k-takata/Onigmo/blob/Onigmo-6.0.0/HISTORY * fix for ruby 2.4: https://github.com/k-takata/Onigmo/pull/78 * suppress warning: https://github.com/k-takata/Onigmo/pull/79 * include/ruby/oniguruma.h: include onigmo.h. * template/encdb.h.tmpl: ignore duplicated definition of EUC-CN in enc/euc_kr.c. It is defined in enc/gb2313.c with CRuby macro. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57045 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-06re.c: check that MatchData is initializedrhe
Follow r16757 ("* re.c: fix SEGV by Regexp.allocate.names, Match.allocate.names, etc.", 2008-06-02). Don't do null dereference if MatchData#hash or #== is called against an uninitialized instance. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-02re.c: count associated Regexp object in MatchData#hashrhe
Don't discard the hash value computed for the regexp object. It seems it was simply missed out in r24754, when MatchData#hash was initially implemented. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-26[DOC] replace Fixnum with Integer [ci skip]nobu
* numeric.c: [DOC] update document for Integer class. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-04* internal.h (ST2FIX): new macro to convert st_index_t to Fixnum.usa
a hash value of Object might be Bignum, but it causes many troubles expecially the Object is used as a key of a hash. so I've gave up to do so. * array.c (rb_ary_hash): use above macro. * bignum.c (rb_big_hash): ditto. * hash.c (rb_obj_hash, rb_hash_hash): ditto. * numeric.c (rb_dbl_hash): ditto. * proc.c (proc_hash): ditto. * re.c (rb_reg_hash, match_hash): ditto. * string.c (rb_str_hash_m): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56340 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-08replace fixnum by integer in documents.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-25* re.c (unescape_nonascii): scan hex up to only 3 characters.naruse
[Bug #12420] [Bug #12423] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-19fix document of Regexp#match?kazu
* re.c (rb_reg_match_m_p): [DOC] fix return value in rdoc. * test/ruby/test_regexp.rb (TestRegexp#test_match_p): add some tests from document. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55075 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-19re.c: fix match?nobu
* re.c (rb_reg_match_m_p): fix match against empty string. rb_str_offset returns the end when the position exceeds the length. fix the range parameter of onig_search. [ruby-core:75604] [Bug #12394] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55069 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-19re.c: match? should return nil if no matchnobu
* re.c (rb_reg_match_m_p): should return nil if no match, as the document says. [Feature #8110] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55067 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-18* re.c (reg_names_iter): specify capacifynaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55065 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-18re.c: fix typenobu
* re.c (rb_reg_match_m_p): fix type of variable for onig_search result. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55062 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-18* re.c (rb_reg_match_m_p): Introduce Regexp#match?, which returnsnaruse
bool and doesn't save backref. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55061 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-18* re.c (match_ary_subseq): get subseq of match array without creatingnaruse
temporary array. * re.c (match_ary_aref): get element(s) of match array without creating temporary array. * re.c (match_aref): Use match_ary_subseq with handling irregulars. * re.c (match_values_at): Use match_ary_aref. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-17re.c: fix up r55036nobu
* re.c (match_values_at): fix regression at r55036. MatchData#values_at accepts Range. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55039 b2dd03c8-39d4-4d8f-98ff-823fe69b080e