aboutsummaryrefslogtreecommitdiffstats
path: root/string.c
Commit message (Collapse)AuthorAgeFilesLines
* string.c: grapheme cluster regexp failurenobu2018-10-161-2/+5
| | | | | | | * string.c (get_reg_grapheme_cluster): show error info and relax to rb_fatal from rb_bug. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: [DOC] add example code for String#strip!stomar2018-10-131-0/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: small doc improvementstomar2018-10-131-1/+1
| | | | | | | * string.c: [DOC] move unaltered case for String#strip to the end, similar to other strip methods. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65067 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Prefer `rb_fstring_lit` over `rb_fstring_cstr`nobu2018-10-131-2/+2
| | | | | | | The former states explicitly that the argument must be a literal, and can optimize away `strlen` on all compilers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Added comments to rb_setup_fake_str and rb_fstring_new [ci skip]nobu2018-10-131-0/+8
| | | | | | | | `ptr` for these functions must refer constant string literals. Otherwise, the result string's content can be modified/discarded unexpectedly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [DOC] Improve String#strip documentation.marcandre2018-09-161-0/+1
| | | | | | Patch by Josh Goldberg. [Fix GH-1933] [ci skip] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64757 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* move function declarations from insns.def to internal.hshyouhei2018-06-271-2/+0
| | | | | | | Just avoid being loose. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: [DOC] grammar fixesstomar2018-06-111-7/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63632 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [Docs] Improve documentation of String#linesnobu2018-06-081-2/+8
| | | | | | | | | | * Document about optional getline arguments * Add examples, especially for the demonstration of `chomp: true` [Fix GH-1886] From: Koki Takahashi <hakatasiloving@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* String#uminus dedupes unconditionallynormal2018-06-041-9/+5
| | | | | | | | [Feature #14478] [ruby-core:85669] Thanks-to: Sam Saffron <sam.saffron@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63566 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: trivial optimizationsnobu2018-06-011-9/+6
| | | | | | | | | | * string.c (rb_str_aset): prefer BUILTIN_TYPE over TYPE after SPECIAL_CONST_P check. * string.c (rb_str_start_with): prefer RB_TYPE_P over switch by TYPE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: doc for [Feature #13712]nobu2018-06-011-0/+2
| | | | | | | * string.c (rb_str_start_with): [DOC] start_with? example with regexp. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63541 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: MAYBE_UNUSED to suppress warnings for `old`normal2018-05-221-2/+2
| | | | | | | Building with HAVE_MALLOC_USABLE_SIZE currently makes SIZED_REALLOC_N ignore the old size arg. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63487 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: size hints for free and realloc callsnormal2018-05-221-8/+13
| | | | | | | Another part of the plan to reduce dependencies on malloc_usable_size: https://bugs.ruby-lang.org/issues/10238 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: adjust to rb_str_upto_eachnobu2018-04-281-10/+8
| | | | | | | | | | * range.c (range_each_func): adjust the signature of the callback function to rb_str_upto_each, and exit the loop if the callback returned non-zero. * string.c (rb_str_upto_endless_each): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63290 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: fix scanned substring with `\K`nobu2018-04-241-0/+1
| | | | | | | | * string.c (scan_once): fix the matched substring with `\K`, the beginning of that string may differ from the matched position. [ruby-core:86663] [Bug #14707] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63252 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Introduce endless range [Feature#12912]mame2018-04-191-0/+44
| | | | | | | | | | Typical usages: ``` p ary[1..] # drop the first element; identical to ary[1..-1] (1..).each {|n|...} # iterate forever from 1; identical to 1.step{...} ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: suppress warningnobu2018-04-171-1/+1
| | | | | | * string.c (str_undump): get rid of warning C4129 by VC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63170 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: fix dumped suffixnobu2018-04-161-3/+9
| | | | | | | * string.c (rb_str_dump): get rid of an error on evaling with frozen-string-literal enabled. [ruby-core:86539] [Bug #14687] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63164 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: fix checking ordernobu2018-04-161-4/+4
| | | | | | | | * string.c (str_undump): check for suffix before if Unicode escape conflicts with it. the message "but used force_encoding" sounds strange when it is not used. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: [DOC] fix typostomar2018-04-141-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63160 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Factor out get_reg_grapheme_clusternaruse2018-03-221-42/+24
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62893 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* fix each_grapheme_cluster's size [Bug #14363]naruse2018-03-221-1/+51
| | | | | | From: Hugo Peixoto <hugo.peixoto@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Revert "each_grapheme_cluster shouldn't return size [Bug #14363]"naruse2018-03-221-1/+1
| | | | | | This reverts commit r62887. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62891 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* each_grapheme_cluster shouldn't return size [Bug #14363]naruse2018-03-221-1/+1
| | | | | | From: Stefan Schüßler <mail@stefanschuessler.de> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Improve documentation for 'text '.splitnobu2018-03-211-4/+4
| | | | | | | | | | The documentation didn't mention trailing spaces and the example only demonstrated the case with leading spaces. [Fix GH-1845] From: Rodrigo Rosenfeld Rosas <rr.rosas@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62881 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: [DOC] split with block [ci skip]nobu2018-03-171-1/+5
| | | | | | | * string.c (rb_str_split_m): [DOC] about split with block. [Feature #4780] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62790 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: split with blocknobu2018-03-151-31/+51
| | | | | | | * string.c (rb_str_split_m): yield each split substrings if the block is given, instead of returing the array. [Feature #4780] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62763 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* quote symbolsnobu2018-03-141-2/+6
| | | | | | | | * sprintf.c (ruby__sfvextra): quote symbols as identifiers. * string.c (rb_id_quote_unprintable): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Export some missing symbols for MJITk0kubun2018-02-081-1/+1
| | | | | | | | | | | | | | | tool/ruby_vm/views/_insn_name_info.erb: on Linux, rb_vm_insn_name_offset was needed to compile with --jit-debug (Usually --jit-debug requires more symbols than the situation without --jit-debug because -O2 skips some functions to compile). vm.c: when running transform_mjit_header.rb with --jit-wait, rb_source_location_cstr was repoted to be missing. string.c: ditto, for rb_str_eql numeric.c: ditto, for rb_float_eql git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62313 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* mjit_compile.c: merge initial JIT compilerk0kubun2018-02-041-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* string.c (rb_str_format_m): Fix the example code of the docmame2018-01-291-1/+1
| | | | | | | | | | | Change `%08x` to `%016x` because of two reasons: * `%016x` demonstrates that we can use two or more digits here. * Currently, many people uses 64-bit environment. (I'm unsure if object_id is a good example here, though...) I'm unsure if git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62091 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: clear substring code rangenobu2018-01-251-0/+1
| | | | | | | | * string.c (str_substr): substring of broken code range string may be valid or broken. patch by tommy (Masahiro Tomita) at [ruby-dev:50430] [Bug #14388]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* sizeof(uintptr_t) != sizeof(uintptr_t *)shyouhei2018-01-161-1/+1
| | | | | | | Reported by mame. Thanks. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* __builtin_assume_aligned for *(foo *) castsshyouhei2018-01-151-2/+9
| | | | | | These casts are guarded. Must be safe to assume alignments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61829 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* exclude flexible array size with old compilersnobu2018-01-141-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61814 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c (struct mapping_buffer): Use FLEX_ARY_LENmame2018-01-131-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* should cause preprocess error as other casesusa2018-01-101-0/+2
| | | | | | | | * string.c (NONASCII_MASK): should cause preprocess error immediately if the compiler does not satisfy our assumptions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61756 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h: remove dependecy on ruby/encoding.hnobu2018-01-091-1/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h: remove dependecy on ruby/io.hnobu2018-01-091-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61712 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: out-of-bounds accessnobu2018-01-061-1/+2
| | | | | | | * string.c (rb_str_enumerate_lines): fix out-of-bounds access when record separator is longer than the last element. [Bug #14257] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61636 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ULL suffix is a C99ismshyouhei2018-01-041-4/+15
| | | | | | | | | | Don't assume long long == 8 bytes. If you can assume C99, there are macros named UINT64_C and such for appropriate integer literal suffixes. If you can't, no way but do a bitwise or. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fix doc typo in Symbol#to_proc [Fix GH-1785]nobu2018-01-041-1/+1
| | | | | | | | [ci skip] From: Dimitris Zorbas <dimitrisplusplus@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61588 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: chomp rs at the endnobu2017-12-291-1/+6
| | | | | | | | | * string.c (rb_str_enumerate_lines): should chomp record separator only, but not a newline, at the end of the receiver as well as middle, if the separator is given. [ruby-core:84552] [Bug #14257] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61513 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [DOC] Fix typos in downcase [ci skip]kazu2017-12-271-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61488 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* encoding.c: rb_enc_find_index2nobu2017-12-221-13/+4
| | | | | | | * string.c (str_undump): use rb_enc_find_index2 to find encoding by unterminated string. check the format before encoding name. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61396 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: fix memory leaknobu2017-12-211-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61386 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Don't allow mixed escapenaruse2017-12-211-2/+10
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61381 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* move dump format validation into parsing epiloguenaruse2017-12-211-99/+68
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61380 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* fix escapes in undumpnaruse2017-12-211-38/+37
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61379 b2dd03c8-39d4-4d8f-98ff-823fe69b080e