aboutsummaryrefslogtreecommitdiffstats
path: root/compile.c
Commit message (Collapse)AuthorAgeFilesLines
* compile.c: use ALLOCV_Nnobu2018-01-181-3/+5
| | | | | | | * compile.c (ibf_dump_object_list): allocate known-size array by ALLOCV_N instead of rb_ary_tmp_new. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61936 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ibf_dump_object_unsupported marked as NORETURNshyouhei2018-01-181-0/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* node.c: Stop double meaning of NODE_FOR by introducing NODE_FOR_MASGNmame2018-01-161-32/+28
| | | | | | | | | NODE_FOR was used both for "for"-statement itself and for multi-assignment of for-statement (for x, y, in...end). This change separates the two purposes, NODE_FOR for the former, and newly introduced NODE_FOR_MASGN for the latter. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61871 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* __declspec(align(#)) does not take sizeof()shyouhei2018-01-151-1/+1
| | | | | | | same as r61833 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ruby_aligned_char no longer needed.shyouhei2018-01-151-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* __declspec(align(#)) does not take sizeof()shyouhei2018-01-151-1/+1
| | | | | | | Use compile-time constant expression instead. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61833 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* __attibute__((__aligned__)) for RSTRING_PTR()shyouhei2018-01-151-1/+1
| | | | | | | | | | | | | | | | For instance array.c:rb_ary_product() uses RSTRING_PTR() as an array of int. So to avoid misaligned memory access RSTRING_PTR() must at least be sizeof(int)-aligned. However the type of RSTRING_PTR() is char*, which of course can expect alignment as much as 1. This is a problem. The reality is, there is no misaligned memory access because the memory region behind RSTRING_PTR() is allocated using malloc(). Memory regions returned from malloc() are always aligned appropriately. So let's tell the compiler about this information. It seems GCC, clang, and MSVC have such feature. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61827 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
* compile.c (struct ibf_object_*): Use FLEX_ARY_LENmame2018-01-131-4/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61810 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c (struct ibf_id_entry): Just removed.mame2018-01-131-13/+0
| | | | | | It looked unused. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.h (struct iseq_catch_table_entry, iseq_compile_data_storage): Use ↵mame2018-01-131-1/+1
| | | | | | FLEX_ARY_LEN git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* delete tool/instruction.rb (2nd try)shyouhei2018-01-121-4/+3
| | | | | | | | | | | | | | | | | | | | | | | Previous commit changed insns.def format. Now is the time for its generators. In doing so I chose to modernize the system, not just patch. My attempt includes - extensive use of Onigumo regular expressions - split from one big file (instruction.rb) into separated MVC - partial view Also, let me take this opportunity to kill old unused features such as - stack caching - minsns / yasmdata which are never seriously used - yarvarch document generation (moved to doc/) - vast majority of unused arguments to insns2vm.rb This commit generates VM source codes that cleanly compile, and the generated binary passes tests. At least for me. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* merge revisions 61753:61750 61747:61740 61737:61728shyouhei2018-01-101-3/+4
| | | | | | | Revert all the VM generator rewrites; requested by naruse git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.c: Add a succinct bitvector implementation for insn_info_tablemame2018-01-091-0/+9
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61739 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* delete tool/instruction.rbshyouhei2018-01-091-4/+3
| | | | | | | | | | | | | | | | | | | | | | | Previous commit changed insns.def format. Now is the time for its generators. In doing so I chose to modernize the system, not just patch. My attempt includes - extensive use of Onigumo regular expressions - split from one big file (instruction.rb) into separated MVC - partial view Also, let me take this opportunity to kill old unused features such as - stack caching - minsns / yasmdata which are never seriously used - yarvarch document generation (moved to doc/) - vast majority of unused arguments to insns2vm.rb This commit generates VM source codes that cleanly compile, and the generated binary passes tests. At least for me. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61733 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Rename code_range to code_locationmame2018-01-091-2/+2
| | | | | | | | | | | Because the name "code_range" is ambiguous with encoding's. Abbreviations ("crange", and "cr") are also renamed to "loc". The traditional "code_location" (a pair of lineno and column) is renamed to "code_position". Abbreviations are also renamed (first_loc to beg_pos, and last_loc to end_pos). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61721 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h: remove dependecy on ruby/encoding.hnobu2018-01-091-1/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c (iseq_compile_each0): remove irrelevant tracecoveragemame2018-01-091-0/+12
| | | | | | | | | | | | | | | This change removes tracecoverage instructions on a line that has any NODE but is non-significant, such as, just one literal. This fixes the following failure that occurs only when coverage is enabled: 1) Failure: TestISeq#test_to_a_lines [.../ruby/test/ruby/test_iseq.rb:56]: <[3, 4, 7, 9]> expected but was <[3, 4, 5, 6, 7, 8, 9]>. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61711 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: Remove special handling of tOROP and tANDOPmame2018-01-091-14/+11
| | | | | | The complexity is no longer considered necessary. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61701 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* use `getblockparamproxy` to pass blocks.ko12018-01-081-2/+1
| | | | | | | | | | | | | * compile.c (setup_args): use `getblockparamproxy` (`rb_block_param_proxy`) to represent a block parameter passing. * vm_args.c (vm_caller_setup_arg_block): check `rb_block_param_proxy` instead of using `VM_CALL_ARGS_BLOCKARG_BLOCKPARAM` call flag. * vm_core.h (VM_CALL_ARGS_BLOCKARG_BLOCKPARAM): removed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61694 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: compile_case2 branchnobu2018-01-081-2/+5
| | | | | | * compile.c (compile_case2): compile as a branch condition. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61675 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Speedup `block.call` [Feature #14330]ko12018-01-071-1/+26
| | | | | | | | | | | | | | | | | | | | | | * insns.def (getblockparamproxy): introduce new instruction to return the `rb_block_param_proxy` object if possible. This object responds to `call` method and invoke given block (completely similar to `yield`). * method.h (OPTIMIZED_METHOD_TYPE_BLOCK_CALL): add new optimized call type which is for `rb_block_param_proxy.cal`. * vm_insnhelper.c (vm_call_method_each_type): ditto. * vm_insnhelper.c (vm_call_opt_block_call): ditto. * vm_core.h (BOP_CALL, PROC_REDEFINED_OP_FLAG): add check for `Proc#call` redefinition. * compile.c (iseq_compile_each0): compile to use new insn `getblockparamproxy` for method call. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: fix stack consistency errornobu2018-01-051-0/+5
| | | | | | | | | * compile.c (iseq_peephole_optimize): fix stack consistency error from return in loop, by adding extra `pop` when replacing `jump` with `leave`, which is never reached but needed to adjust sp calculation. [ruby-core:84589] [Bug #14273] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61618 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: remove more unreachable chunknobu2018-01-051-8/+30
| | | | | | | * compile.c (remove_unreachable_chunk): remove beyond labels to be removed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61617 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* node.h: remove NODE_PRELUDEmame2018-01-051-21/+1
| | | | | | | | | | | NODE_PRELUDE contains a `BEGIN` node, a main node, and compile_option. This node is assumed that it must be located immediately under the root NODE_SCOPE, but this strange assumption is not so good, IMO. This change removes the assumtion; it integrates the former two nodes by block_append, and moves compile_option into rb_ast_body_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* make rb_iseq_new* accept rb_ast_body_t instead of NODE*mame2018-01-051-1/+5
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61609 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* check array for zsuper. [Bug #14279]ko12018-01-051-0/+2
| | | | | | | | | | * compile.c (iseq_compile_each0): for zsuper (NODE_ZSUPER), we need to check given argument is Array or not. * test/ruby/test_super.rb: add a test for this bug. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Refactor ISEQ_TYPE_DEFINED_GUARD outmame2018-01-051-8/+3
| | | | | | | | | This commit removes ISEQ_TYPE_DEFINED_GUARD because it is no longer needed. And this introduces ISEQ_TYPE_PLAIN which means that the iseq does nothing special but just wrap an expression. Currently, this is used for once execution: `/foo#{ bar }baz/o`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61601 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: refactoring of defined? exception handlermame2018-01-051-7/+12
| | | | | | | This commit removes tmp_node trick to create a special exception handler for `defined?`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61599 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* node.h: add NODE_ONCE instead of reuse of NODE_SCOPEmame2018-01-041-3/+5
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61597 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.c: Refactor out rb_iseq_new_ifunc from rb_iseq_new_with_optmame2018-01-041-10/+36
| | | | | | It is too error-prone to pass IMEMO_IFUNC object as NODE*. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61592 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: next labelnobu2018-01-041-3/+7
| | | | | | | * compile.c (compile_next): label for jump to the end of block is removable. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61587 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: fix disasm dumpnobu2018-01-031-2/+5
| | | | | | | | | | * compile.c (DECL_ANCHOR): initialize as anchor type, which is not a valid iseq element. * compile.c (BADINSN_DUMP): dump from the first element, excluding the anchor itself. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61584 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: label spnobu2018-01-031-1/+2
| | | | | | | * compile.c (dump_disasm_list_with_cursor): show stack depth for each label. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61578 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* bit-fields other than int is a C99ismshyouhei2018-01-021-1/+5
| | | | | | | To be precise C90 says "A bit-field may have type int, unsigned int, or signed int". It is clear that char or enum are NG. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61554 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* rb_insn_func_t is incompatible with void*shyouhei2018-01-021-1/+1
| | | | | | Why not just use void* ? git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.h: Extract position array from iseq_insn_info_entrymame2018-01-011-31/+51
| | | | | | | | | | This makes TracePoint a bit fast by reducing cache misses of `get_insn_info_binary_search`. Also, I plan to use succinct bitvector algorithm for `get_insn_info` instead of binary search. This change will make it easy. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_core.h: refactoring of insns_infomame2018-01-011-8/+8
| | | | | | | This factors rb_iseq_constant_body#insns_info and #insns_info_size to struct iseq_insn_info. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Set first line numbers for empty iseqs.ko12017-12-251-1/+3
| | | | | | | | | | | | | * compile.c (iseq_compile_each): for empty method, block and so on, `last_line` is not set so that line number of `putnil` instruction will be zero. This patch set `first_lineno` for such `putnil`. Problem is reported by deivid-rodriguez via Yuichiro Kaneko. * test/ruby/test_iseq.rb: add a test for this spec. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61457 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: toplevel return argumentsnobu2017-12-241-1/+0
| | | | | | | * compile.c (compile_return): evaluate arguments to top-level return but ignore the results. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61437 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* fix last commitko12017-12-231-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* RubyVM::InstructionSequence#trace_points.ko12017-12-231-1/+1
| | | | | | | | | | * iseq.c (iseqw_trace_points): add `RubyVM::InstructionSequence#trace_points` method for tools which want to manipulate ISeq (and traces). * test/ruby/test_iseq.rb: add a test for this method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61427 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* revert line number spec of *return events.ko12017-12-231-0/+3
| | | | | | | | | | | | | | | | | | * compile.c (rb_iseq_compile_node): line number spec of :return, :b_return and :end events of 'TracePoint` is changed for [Feature #14104]. Quoted from [Feature #14104]: > Line numbers on :return/:b_return events show the last executed lines, > instead of end lines (without return statement). Note that :end event also affected. However, "buybug", a well-known ruby debugger depends on previous behavior so that I reverted this specification. * test/ruby/test_settracefunc.rb: catch up this fix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* revert r61371 for [Bug #14214]ko12017-12-211-21/+3
| | | | | | | Reverted patch doesn't check overwritten value. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61387 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: branch on block paramnobu2017-12-201-3/+21
| | | | | | | | * compile.c (compile_branch_condition): replace block param value in branch conditions with `defined(yield)`, to get rid of creating proc value. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61371 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: add a RUBY_EVENT_COVERAGE_LINE event for line coveragemame2017-12-201-1/+12
| | | | | | | | | | | | | | | | | | | 2.5's line coverage measurement was about two times slower than 2.4 because of two reasons; (1) vm_trace uses rb_iseq_event_flags (which takes O(n) currently where n is the length of iseq) to get an event type, and (2) RUBY_EVENT_LINE uses setjmp to call an event hook. This change adds a special event for line coverage, RUBY_EVENT_COVERAGE_LINE, and adds `tracecoverage` instructions where the event occurs in iseq. `tracecoverage` instruction calls an event hook without vm_trace. And, RUBY_EVENT_COVERAGE_LINE is an internal event which does not use setjmp. This change also cancells lineno change due to the deletion of trace instructions [Feature #14104]. So fixes [Bug #14191]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61350 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: pop splat resultnobu2017-12-191-7/+11
| | | | | | | | | | * compile.c (compile_array): pop splat result without creating a new hash if the whole hash is popped. [ruby-core:84340] [Bug #14201] From: Nobuyoshi Nakada <nobu@ruby-lang.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61331 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: side effect in splatnobu2017-12-191-2/+5
| | | | | | | | | | * 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
* iseq.c (finish_iseq_build): fix coverage leakage [Bug #14191]mame2017-12-181-11/+7
| | | | | | | | | | Before this change, coverage.so had failed to measure some multiple-line code fragments. This is because removing trace instructions (#14104) changed TracePoint's lineno (new lineno), and coverage counter array was based on old lineno. This change initializes coverage counter array based on new lineno. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61313 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* node.[ch], parse.y, compile.c: rename nd_column to nd_first_columnmame2017-12-141-29/+29
| | | | | | | | nd_set_column -> nd_first_set_column nd_lineno -> nd_first_lineno nd_set_lineno -> nd_first_set_lineno git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61224 b2dd03c8-39d4-4d8f-98ff-823fe69b080e