Граф коммитов

586 Коммитов

Автор SHA1 Сообщение Дата
rhe 8dce62218a compile.c: fix possible use of uninitialized value
LABEL::unremovable added by r58810 is not initialized by
new_label_body(), making the optimization unstable.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58894 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-26 01:50:20 +00:00
nobu cffb09aa80 LABEL_FORMAT
* compile.c (LABEL_FORMAT): extract format string for labels.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58854 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-23 12:11:57 +00:00
nobu 52de826096 compile.c: optimize branches
* compile.c (compile_branch_condition, iseq_compile_each0):
  eliminate unreachable branches in NODE_IF.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58815 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20 11:40:57 +00:00
nobu 4b39eaf4cc compile.c: binary logop check
* compile.c (compile_branch_condition): turn recursion at binary
  logical operator into loop by goto, and check the result of RHS
  of NODE_OR.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58814 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20 10:27:27 +00:00
nobu 35c54a11b3 compile.c: fix catch-table labels optimization
* 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-05-20 02:11:24 +00:00
nobu 0183613bf9 compile.c: dump_disasm_list_with_cursor
* compile.c (dump_disasm_list_with_cursor): improve disassemble
  list.  show whole elemetns and mark the current element.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58797 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19 14:58:38 +00:00
normal 9d09240d9e rb_execution_context_t: move stack, stack_size and cfp from rb_thread_t
The goal is to reduce rb_context_t and rb_fiber_t size
by removing the need to store the entire rb_thread_t in
there.

[ruby-core:81045] Work-in-progress: soon, we will move more fields here.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-09 05:06:41 +00:00
nobu 5cc56f0d9b compile.c: wrong optimization
* 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-18 13:14:06 +00:00
ko1 7519688ed8 introduce imemo_type_p(v, imemo_type)
* internal.h: introduce imemo_type_p() which checks the given value is
  T_IMEMO and imemo_type() == given imemo_type.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-07 06:41:32 +00:00
nobu 42c13d386c compile.c: remove side effects by debug macros
* compile.c (debugp_param): do not evaluate arguments of debug
  macros, unless the debug mode is enabled.  these macros should
  not have side effects.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58253 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-05 08:34:18 +00:00
normal 6f73c38791 compile.c: avoid duplicate mark entry for string literal Range
iseq_add_mark_object is called in iseq_set_sequence later on,
so we only need to call iseq_add_mark_object_compile_time
in iseq_peephole_optimize.  Without this change, there would've
been a duplicate entry in the long-lived iseq mark_ary.

* compile.c (iseq_peephole_optimize): avoid duplicate mark object entry
  [ruby-core:80536] [Feature #13355]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-02 20:16:02 +00:00
normal 120976b9f9 compile.c: optimize literal String range in case/when dispatch
This is similar in spirit to opt_case_dispatch as the literal
Range here is guaranteed to be immutable when used for
checkmatch.

Normal range literals with non-frozen strings are actually
mutable, as Range#begin and Range#end exposes the strings to
modification.  So those Range objects cannot be frozen without
breaking compatibility, but Ranges in case/when dispatch can be
frozen at compile time.

* compile.c (iseq_peephole_optimize): persistent Range creation
  when String literals are used as beginning and end of range
  when used for case/when dispatch.
  [ruby-core:80290] [Feature #13355]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58233 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-01 21:38:25 +00:00
normal 669a55dfed fix redefinition optimization for -"literal string" (UMinus)
Unfortunately this enlarges insns.def by yet another
instruction.  However, it is much prettier than opt_str_freeze
in use, and maybe we can avoid having so many instructions in
the future.

[ruby-core:80368]

* insns.def (DEFINE_INSN): new instruction: opt_str_uminus (maybe temporary)
* compile.c (iseq_compile_each0): split instructions
* test/ruby/test_optimization.rb (test_string_uminus): new test
* vm.c (vm_init_redefined_flag): set redefinintion flag for uminus
* vm_core.h (enum ruby_basic_operators): add BOP_UMINUS

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-27 06:12:37 +00:00
normal cad4591086 remove branches in dmark and dfree GC callbacks
dmark and dfree callbacks are never called in gc.c for NULL
DATA_PTR values, not even for zombie objects.

* compile.c (ibf_loader_mark): remove branch for pointer validity
* compile.c (ibf_loader_free): ditto
* cont.c (cont_free): ditto
* cont.c (fiber_free): ditto
* dir.c (dir_free): ditto
* ext/stringio/stringio.c (strio_mark): ditto
* proc.c (binding_free): ditto
* thread_sync.c (mutex_free): ditto
* vm.c (thread_free): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-17 19:59:56 +00:00
mame 3c96f9c76a Fix a consistency bug of ISEQ_COVERAGE [Bug #13305]
There is an invariant that ISEQ_COVERAGE(iseq) must be Qnil if and only
if option->coverage_enabled is false.  This invariant was broken by
NODE_PRELUDE which updates option->coverage_enabled but not
ISEQ_COVERAGE(iseq).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-14 11:39:58 +00:00
nobu c279ac3615 compile.c: compile flip-flop
* compile.c (iseq_compile_each0): compile flip-flop directly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57947 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-13 00:11:25 +00:00
nobu dae32a40d9 compile.c: omit newrange
* compile.c (iseq_compile_each): omit creating literal-only range
  to be popped immediately.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57946 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-13 00:11:24 +00:00
nobu c9a1f7a42b compile.c: compile_const_prefix
* compile.c (compile_const_prefix): rename, and check the result
  of parts of the prefix.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57908 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-12 13:51:12 +00:00
nobu c0764a3cd8 compile.c: omit newhash
* compile.c (iseq_compile_each): omit creating literal-only hash
  to be popped immediately.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-12 05:52:42 +00:00
nobu ae46708c10 compile.c: NODE_VALUES must not be popped
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57891 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-12 05:48:58 +00:00
nobu cd7b59e4f2 compile.c: iseq_compile_each0
* compile.c (iseq_compile_each0): split from null node case to
  constify line and type.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57890 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-11 22:44:26 +00:00
nobu f19b041837 compile.c: compile_when
* compile.c (compile_when): extract from iseq_compile_each.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57889 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-11 22:37:50 +00:00
nobu 16e5c20f9a compile.c: compile_case
* compile.c (compile_case): extract from iseq_compile_each.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-11 22:25:32 +00:00
nobu 0d45ea8d8a compile.c: constify flags
* compile.c (compile_cpath): return `noscoped` bit flag, instead
  of boolean flag.

* compile.c (iseq_compile_each): constify flags.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57836 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-11 12:26:00 +00:00
normal 568f8adfc8 compile.c: apply opt_str_freeze to String#-@ (uminus)
The same optimization used for "literal string".freeze
can easily apply to uminus without introducing any
compatibility problems.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57828 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-10 20:09:06 +00:00
shyouhei c56edb9a59 revert RB_FIXABLE related changesets [Bug #13288][Bug #13293][Bug #13294]
This commit is auto-generated using following command:

svn diff -r57807:57788 include internal.h bignum.c numeric.c compile.c insns.def object.c sprintf.c | patch -p0


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57818 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-09 02:31:23 +00:00
shyouhei 74cdd893eb optimize FIXABLE macro
Looking at the source code, FIXABLE tends to be just before LOING2FIX
to check applicability of that operation.  Why not try computing first
then check for overflow, which should be optimial.

I also tried the same thing for unsigned types but resulted in slower
execution.  It seems RB_POSFIXABLE() is fast enough on modern CPUs.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-06 11:14:05 +00:00
nobu c8921b5ef0 compile.c: variable type
* compile.c (iseq_compile_each): fix variable type, use VALUE for
  Symbol.
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?revision=57772&view=revision

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-05 23:36:44 +00:00
nobu f01836cb3f compile.c: operand size check
* compile.c (ibf_load_code): raise an exception on invalid operand
  size.  should not use assert() to validate incoming data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57774 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-04 14:44:05 +00:00
nobu 37102f6bdb compile.c: memory leak
* compile.c (iseq_set_sequence): fix potential memory leaks on an
  invalid instruction sequence.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-04 14:37:22 +00:00
nobu 8f2b1b67ea compile.c: fix invalid label message
* compile.c (validate_label): fix invalid label message.
  registered labels are Symbols, not IDs.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-04 14:21:57 +00:00
normal d1a506eca7 deduplicate strings sooner at load and compile
We can use rb_fstring_cstr in some places to prevent an
intermediate object from being created before deduplication
via rb_fstring.

* compile.c (iseq_compile_each): use rb_fstring_cstr
  (rb_insns_name_array): ditto
* load.c (rb_load_internal0): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57745 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-01 01:16:26 +00:00
nobu 9b1f2b073f kwrest arg name
* compile.c (iseq_set_arguments_keywords): make keyword rest
  argument name nd_vid consistently, regardless of whether other
  keyword arguments are present.  [Fix GH-1529]

* parse.y (new_args_tail_gen): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57733 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-27 13:52:07 +00:00
yui-knk 2235695cbb compile.c: Fix a typo
* compile.c (compile_branch_condition): NODE_LIT is
  always true.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57666 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-20 14:40:56 +00:00
nobu 5c0aa3ad92 compile.c: suppress a warning
* compile.c (iseq_build_kw): suppress an alloc-size-larger-than
  warning by gcc 7.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57617 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-13 05:23:36 +00:00
nobu c4770f1a10 compile.c: restore catch entry sp
* compile.c (iseq_build_from_ary_exception): restore stack depth
  of catch entries.  accurate stack depths cannot be calculated
  from dumped array.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57498 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-02 05:56:06 +00:00
nobu 4de496034d compile.c: restore misc params
* compile.c (rb_iseq_build_from_ary): restore misc params.
  accurate stack depths cannot be calculated from dumped array.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57497 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-02 05:45:22 +00:00
nobu 6bff3ce394 compile.c: keyword table for required kwarg
* compile.c (iseq_build_kw): keyword table is necessary also when
  required keyword argumetns only.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57496 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-02 05:45:21 +00:00
nobu f81c1c24b8 compile.c: optimization of defined? in condition
* compile.c (compile_branch_condition): trivial optimization of
  defined? expression in a branch condition, where a string is not
  needed, but just a boolean.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57381 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-20 04:27:55 +00:00
nobu d6fc7d43d7 compile.c: check err_info
* compile.c (iseq_setup): bail out if any errors found.
  [ruby-core:76531] [Bug #12613]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57368 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-19 03:42:07 +00:00
nobu 14a730e91e immediate message mode of compile error
* compile.c (append_compile_error): set Qtrue for erred state with
  showing the message immediately.

* iseq.c (prepare_iseq_build): make immediate message mode if main
  or top level context, not to show the failed path twice in the
  first line.

* iseq.c (cleanup_iseq_build): raise default message exception if
  immediate message mode.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57313 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-12 07:41:35 +00:00
nobu 257fd90166 compile.c: invalid yield in main
* compile.c (iseq_compile_each): yield cannot be in the main
  context as well as a top context.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57312 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-12 05:43:00 +00:00
nobu 52b02ad22a compile.c: check compile
* compile.c (iseq_compile_each): check if sub nodes succeeded.
  [ruby-core:76531] [Bug #12613]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57300 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-10 15:28:11 +00:00
nobu 6f31dcd72f compile.c: fallback nil
* compile.c (iseq_compile_each): push fallback nil only when
  defined guard is added.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-03 10:49:12 +00:00
nobu 7e001f288b compile.c: omit unnecessary defined guard
* compile.c (defined_expr): omit unnecessary defined guard when
  method call has no receiver and no arguments.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57258 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-03 09:48:43 +00:00
nobu e53e986082 compile.c: constify
* compile.c (method_for_self): constify an argument of build
  function for VC6.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57173 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-24 13:19:50 +00:00
nobu 342f10b9b3 compile.c: toplevel return
* compile.c (iseq_compile_each): stop execution of the current source
  by toplevel return.  [ruby-core:36785] [Feature #4840]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57132 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-21 01:58:32 +00:00
rhe 451e0a6ee1 compile.c: do not emit numeric literal range in void context
A fix-up for r56316. Fix stack consistency error on '1..3; nil'.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-17 08:25:34 +00:00
nobu e9a8e8ab4a remove core#hash_merge_ary
* compile.c (compile_array_): remove m_core_hash_merge_ary which
  seems unreachable, and wrong number of arguments.

* vm.c (m_core_hash_merge_ary): removed because it is never used.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-09 02:57:57 +00:00
nobu 761653db90 compile.c: static_literal_value
* compile.c (static_literal_value): separate getter from predicate
  function.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-08 13:51:34 +00:00