summaryrefslogtreecommitdiff
path: root/test/ruby/test_optimization.rb
AgeCommit message (Collapse)Author
2019-11-18Warn on access/modify of $SAFE, and remove effects of modifying $SAFEJeremy Evans
This removes the security features added by $SAFE = 1, and warns for access or modification of $SAFE from Ruby-level, as well as warning when calling all public C functions related to $SAFE. This modifies some internal functions that took a safe level argument to no longer take the argument. rb_require_safe now warns, rb_require_string has been added as a version that takes a VALUE and does not warn. One public C function that still takes a safe level argument and that this doesn't warn for is rb_eval_cmd. We may want to consider adding an alternative method that does not take a safe level argument, and warn for rb_eval_cmd. Notes: Merged: https://github.com/ruby/ruby/pull/2476
2019-11-12Skip tailcall test for MJITTakashi Kokubun
failing in https://github.com/ruby/ruby/runs/300579218
2019-10-25retry tailcall optimization (#2529)wanabe
Sorry, f62f90367fc3bce6714e7c34cbd040e14e43fe07 is push miss.
2019-10-06Revert "tailcall optimization again (#2528)"Koichi Sasada
This reverts commit f62f90367fc3bce6714e7c34cbd040e14e43fe07.
2019-10-06tailcall optimization again (#2528)wanabe
This is follow up of r67315.
2019-09-27Drop eliminated catch-entriesNobuyoshi Nakada
Drop catch table entries used in eliminated block, as well as call_infos. [Bug #16184]
2019-08-30Fix keyword argument separation warnings in testJeremy Evans
Notes: Merged: https://github.com/ruby/ruby/pull/2395
2019-06-30Suppress "statement not reached" warningNobuyoshi Nakada
2019-06-30Suppress unused variable warningsNobuyoshi Nakada
2019-06-29Set file name and line numberNobuyoshi Nakada
2019-06-29Adjust caller's line number, expect the next line as here-docNobuyoshi Nakada
2019-06-07compile.c: Partially revert r63870 which caused wrong optimizationYusuke Endoh
[Bug #15906]
2018-12-30test_optimization.rb: increase timeout for RubyCIk0kubun
https://rubyci.org/logs/rubyci.s3.amazonaws.com/opensuseleap/ruby-trunk/log/20181230T040002Z.fail.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66649 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-28test_array.rb: increase timeout for RubyCIk0kubun
to prevent random failures. test/ruby/test_autoload.rb: ditto test/ruby/test_optimization.rb: ditto https://rubyci.org/logs/rubyci.s3.amazonaws.com/scw-9d6766/ruby-trunk/log/20181228T101706Z.fail.html.gz https://rubyci.org/logs/mswinci.japaneast.cloudapp.azure.com/vc12-x64/ruby-trunk/log/20181228T114549Z.fail.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-11Fix infinite loop by ensurenobu
* compile.c (iseq_insert_nop_between_end_and_cont): insert nop so that the end of rescue and continuing points are not same, to get rid of infinite loop. [Bug #15385] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66326 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-24compile.c: fix peephole optimizationnobu
* compile.c (iseq_peephole_optimize): should `pop` before jump instruction which succeeds to `newarray` of a literal object, not after. [ruby-core:89536] [Bug #15245] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65350 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-26revert r64847, r64846 and r64839k0kubun
because r64849 seems to fix issues which we were confused about. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-26revert r64838 and r64839k0kubun
because some build failures persisted git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-25Revert "Revert r64824 to fix build failure on AppVeyor"k0kubun
This reverts commit r64829. I'll prepare another temporary fix, but I'll separately commit that to make it easier to revert that later. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64838 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-25Revert r64824 to fix build failure on AppVeyork0kubun
AppVeyor msys2/MinGW build started to fail like: https://ci.appveyor.com/project/ruby/ruby/build/9722/job/b94kixi004klmye3 Until I can investigate that, I revert this for now. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64829 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-24insns.def: optimize & and | of Integer [experimental]k0kubun
not optimizing Array#& and Array#| because vm_insnhelper.c can't easily inline it (large amount of array.c code would be needed in vm_insnhelper.c) and the method body is a little complicated compared to Integer's ones. So I thought only Integer#& and Integer#| have a significant impact, and eliminating unnecessary branches would contribute to JIT's performance. vm_insnhelper.c: ditto tool/transform_mjit_header.rb: make sure these instructions are inlined on JIT. compile.c: compile vm_opt_and and vm_opt_or. id.def: define id for them to be used in compile.c and vm*.c vm.c: track redefinition of Integer#& and Integer#| vm_core.h: allow detecting redefinition of & and | test/ruby/test_jit.rb: test new insns test/ruby/test_optimization.rb: ditto * Optcarrot benchmark This is a kind of experimental thing but I'm committing this since the performance impact is significant especially on Optcarrot with JIT. $ benchmark-driver benchmark.yml --rbenv 'before::before --disable-gems;before+JIT::before --disable-gems --jit;after::after --disable-gems;after+JIT::after --disable-gems --jit' -v --repeat-count 24 before: ruby 2.6.0dev (2018-09-24 trunk 64821) [x86_64-linux] before+JIT: ruby 2.6.0dev (2018-09-24 trunk 64821) +JIT [x86_64-linux] after: ruby 2.6.0dev (2018-09-24 opt_and 64821) [x86_64-linux] last_commit=opt_or after+JIT: ruby 2.6.0dev (2018-09-24 opt_and 64821) +JIT [x86_64-linux] last_commit=opt_or Calculating ------------------------------------- before before+JIT after after+JIT Optcarrot Lan_Master.nes 51.460 66.315 53.023 71.173 fps Comparison: Optcarrot Lan_Master.nes after+JIT: 71.2 fps before+JIT: 66.3 fps - 1.07x slower after: 53.0 fps - 1.34x slower before: 51.5 fps - 1.38x slower [close https://github.com/ruby/ruby/pull/1963] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64824 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-06compile.c: remove unreachable jump onlynobu
* compile.c (iseq_peephole_optimize): remove unreachable jump instruction only. if it is labeled and referred from other instructions, it is reachable and must not be removed. [ruby-core:87830] [Bug #14897] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63870 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-05unrevert r63852 but keep SIGCHLD path disabled for win32normal
Reading win32/win32.c waitpid implementation, maybe waitpid(-1, ...) on that platform will never conflict with mjit use of waitpid. In any case, I've added WAITPID_USE_SIGCHLD macro to vm_core.h so it can be easy for Linux/BSD users to test (hopefully!) win32-compatible code. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63855 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-04Revert r63758 and related commitsnaruse
The change is unstable on Windows. Please re-commit it when it correctly supports Windows. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63852 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-30test/ruby/test_optimization.rb: increase timeoutnormal
For slow systems... git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63798 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-25compile.c: fix unconditional branch optimizationnobu
* compile.c (iseq_peephole_optimize): add dummy `putnil` after a `jump` replacing an unconditional branch, to adjust removed `dup`. [ruby-core:86666] [Bug #14708] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63255 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-14Extend timeoutnaruse
On armv7 environment, the timeout is too short http://rubyci.s3.amazonaws.com/scw-9d6766/ruby-trunk/log/20180319T191706Z.diff.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63151 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-30compile.c: do not dump unused callinfosnobu
* compile.c (compile_if): rewind callinfo indexes used in unreachable paths, to get rid of dumping unused callinfos. [ruby-core:86399] [Bug #14553] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-06vm_insnhelper.c: blockparamproxy in rescuenobu
* vm_insnhelper.c (vm_call_opt_block_call): get block handler from the method local frame. fix segfault at calling the proxy in rescue. http://twitter.com/wannabe53/status/970955247626567680 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-16test_rubyoptions.rb: assert_same to check identitynobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62417 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-14compile.c: drop freezestring insn on String#-@normal
Followup to r62039 and remove the redundant freezestring insn which was preventing deduplication from String#-@ * compile.c (iseq_peephole_optimize): drop freezestring insn on String#-@ [ruby-core:85542] [Bug #14475] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62407 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-14test/ruby/test_optimization.rb: fix compile kwargnormal
Fixes: r62177 ("compile.c: fix string Range optimization with FSL") git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62406 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-09compile.c: popped hashnobu
* compile.c (compile_array): skip creating new hash if preceeding elements are popped all. [ruby-core:85486] [Bug #14459] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-03compile.c: fix string Range optimization with FSLnormal
The optimization in [Feature #13355] needs to be detected differently to work with "frozen_string_literal: true" git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62177 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-05Extend timeout of test_clear_unreachable_keyword_argsnaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-28`$SAFE` as a process global state. [Feature #14250]ko1
* vm_core.h (rb_vm_t): move `rb_execution_context_t::safe_level` to `rb_vm_t::safe_level_` because `$SAFE` is a process (VM) global state. * vm_core.h (rb_proc_t): remove `rb_proc_t::safe_level` because `Proc` objects don't need to keep `$SAFE` at the creation. Also make `is_from_method` and `is_lambda` as 1 bit fields. * cont.c (cont_restore_thread): no need to keep `$SAFE` for Continuation. * eval.c (ruby_cleanup): use `rb_set_safe_level_force()` instead of access `vm->safe_level_` directly. * eval_jump.c: End procs `END{}` doesn't keep `$SAFE`. * proc.c (proc_dup): removed and introduce `rb_proc_dup` in vm.c. * safe.c (rb_set_safe_level): don't check `$SAFE` 1 -> 0 changes. * safe.c (safe_setter): use `rb_set_safe_level()`. * thread.c (rb_thread_safe_level): `Thread#safe_level` returns `$SAFE`. It should be obsolete. * transcode.c (load_transcoder_entry): `rb_safe_level()` only returns 0 or 1 so that this check is not needed. * vm.c (vm_proc_create_from_captured): don't need to keep `$SAFE` for Proc. * vm.c (rb_proc_create): renamed to `proc_create`. * vm.c (rb_proc_dup): moved from proc.c. * vm.c (vm_invoke_proc): do not need to set and restore `$SAFE` for `Proc#call`. * vm_eval.c (rb_eval_cmd): rename a local variable to represent clearer meaning. * lib/drb/drb.rb: restore `$SAFE`. * lib/erb.rb: restore `$SAFE`, too. * test/lib/leakchecker.rb: check `$SAFE == 0` at the end of tests. * test/rubygems/test_gem.rb: do not set `$SAFE = 1`. * bootstraptest/test_proc.rb: catch up this change. * spec/ruby/optional/capi/string_spec.rb: ditto. * test/bigdecimal/test_bigdecimal.rb: ditto. * test/fiddle/test_func.rb: ditto. * test/fiddle/test_handle.rb: ditto. * test/net/imap/test_imap_response_parser.rb: ditto. * test/pathname/test_pathname.rb: ditto. * test/readline/test_readline.rb: ditto. * test/ruby/test_file.rb: ditto. * test/ruby/test_optimization.rb: ditto. * test/ruby/test_proc.rb: ditto. * test/ruby/test_require.rb: ditto. * test/ruby/test_thread.rb: ditto. * test/rubygems/test_gem_specification.rb: ditto. * test/test_tempfile.rb: ditto. * test/test_tmpdir.rb: ditto. * test/win32ole/test_win32ole.rb: ditto. * test/win32ole/test_win32ole_event.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61510 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-21test for [Bug #14214]nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-19compile.c: side effect in splatnobu
* compile.c (compile_array): splat which may have side effects should be compiled even if the result will be popped. [ruby-core:84340] [Bug #14201] From: Nobuyoshi Nakada <nobu@ruby-lang.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-11Fix a method nameyui-knk
* test/ruby/test_optimization.rb (test_fixnum_ge): Fix a method name to suppress method redefinition warnings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61125 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-11remove vm_opt_binop_dispatch().ko1
* vm_insnhelper.c (vm_opt_binop_dispatch): removed because this function has several issues for micro-benchmark. Write conditions manually. The worst point is that we can't control value checking order. For example, we can assume FIXNUM arithmetic operations are most popular in Ruby, so that we need to check FIXNUM at first. * test/ruby/test_optimization.rb: also fix redef bug for LE/GT/GE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61123 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-15fix uninitialized memory reference.ko1
* compile.c (iseq_set_sequence): clear kwargs (in ci_entries) memory area. kwargs ci entries are initialized by compiler. However, sometimes these initializations are skipped because corresponding calls are eliminated by some optimizations (for example, `if true` syntax elimnates else code). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60771 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-09fix peephole optimization.ko1
* compile.c (iseq_peephole_optimize): do not need to put `pop` instruction. * test/ruby/test_optimization.rb (test_peephole_optimization_without_trace): This code "def foo; 1.times{|(a), &b| nil && a}; end" fails to compile by stack underflow because of above bug (fixed by this patch). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-24Lazy Proc allocation for block parametersko1
[Feature #14045] * insns.def (getblockparam, setblockparam): add special access instructions for block parameters. getblockparam checks VM_FRAME_FLAG_MODIFIED_BLOCK_PARAM and if it is not set this instruction creates a Proc object from a given blcok and set VM_FRAME_FLAG_MODIFIED_BLOCK_PARAM. setblockparam is similar to setlocal, but set VM_FRAME_FLAG_MODIFIED_BLOCK_PARAM. * compile.c: use get/setblockparm instead get/setlocal instructions. Note that they are used for method local block parameters (def m(&b)), not for block local method parameters (iter{|&b|). * proc.c (get_local_variable_ptr): creates Proc object for Binding#local_variable_get/set. * safe.c (safe_setter): we need to create Proc objects for postponed block parameters when $SAFE is changed. * vm_args.c (args_setup_block_parameter): used only for block local blcok parameters. * vm_args.c (vm_caller_setup_arg_block): if called with VM_CALL_ARGS_BLOCKARG_BLOCKPARAM flag then passed block values should be a block handler. * test/ruby/test_optimization.rb: add tests. * benchmark/bm_vm1_blockparam*: added. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60397 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-19revert r59359, r59356, r59355, r59354normal
These caused numerous CI failures I haven't been able to reproduce [ruby-core:82102] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59364 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-18newhash insn reuses existing keysnormal
This gives the newhash VM instruction the same string reuse capabilities as rb_hash_aset. * st.c (str_key): new wrapper function to call rb_fstring_existing (rb_hash_bulk_insert): use str_key * test/ruby/test_optimization.rb (test_hash_reuse_fstring): ensure key reuse for newhash instructions git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-18hash: keep fstrings of tainted strings for string keysnormal
The same hash keys may be loaded from tainted data sources frequently (e.g. parsing headers from socket or loading YAML data from a file). If a non-tainted fstring already exists (because the application expects the hash key), cache and deduplicate the tainted version in the new tainted_frozen_strings table. For non-embedded strings, this also allows sharing with the underlying malloc-ed data. * vm_core.h (rb_vm_struct): add tainted_frozen_strings * vm.c (ruby_vm_destruct): free tainted_frozen_strings (Init_vm_objects): initialize tainted_frozen_strings (rb_vm_tfstring_table): accessor for tainted_frozen_strings * internal.h: declare rb_fstring_existing, rb_vm_tfstring_table * hash.c (fstring_existing_str): remove (moved to string.c) (hash_aset_str): use rb_fstring_existing * string.c (rb_fstring_existing): new, based on fstring_existing_str (tainted_fstr_update): new (rb_fstring_existing0): new, based on fstring_existing_str (rb_tainted_fstring_existing): new, special case for tainted strings (rb_str_free): delete from tainted_frozen_strings table * test/ruby/test_optimization.rb (test_hash_reuse_fstring): new test [ruby-core:82012] [Bug #13737] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20compile.c: fix catch-table labels optimizationnobu
* compile.c (remove_unreachable_chunk): do not eliminate chunks followed by labels in catch-table entries. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58810 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18compile.c: wrong optimizationnobu
* compile.c (compile_branch_condition): expression which has side effects should not be eliminated. [ruby-core:80740] [Bug #13444] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18test_optimization.rb: heredoc code stylenobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-01test/ruby/test_optimization.rb: quiet warningsnormal
This quiets an old "assigned but unused variable" warning left over after r56653 as well as two new "ambiguous first argment" warnings introduced in r58233. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e