aboutsummaryrefslogtreecommitdiffstats
path: root/compile.c
Commit message (Collapse)AuthorAgeFilesLines
...
* compile.c: no extra parenthesesnobu2015-12-041-35/+35
| | | | | | | * compile.c (COMPILE_ERROR): remove extra parentheses to enclose variadic arguments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52889 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: just append compile error messagenobu2015-12-041-10/+36
| | | | | | | * compile.c (append_compile_error, prepare_compile_error): simply append messages to the same SyntaxError exception. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm_core.h, iseq.h: remove rb_iseq_t::variable_body.ko12015-12-021-1/+1
| | | | | | | | | | | | | | | | Fields in rb_iseq_t::variable_body are contained by rb_iseq_t::body::mark_ary (hidden Array object). Index 0 to 2 of mark_ary are reserved by these objects. * iseq.c: catch up this fix. * compile.c (rb_iseq_original_iseq): trivial rewrite. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * iseq.h: introduce ISEQ_ORIGINAL_ISEQ() andko12015-12-021-7/+7
| | | | | | | | | | | | | | | ISEQ_ORIGINAL_ISEQ_ALLOC() macro. * compile.c: use them to access original iseq buffer. * iseq.c: ditto. * vm_core.h: rename iseq field to support this fix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * iseq.h: introduce ISEQ_FLIP_CNT_INCREMENT() macro.ko12015-12-021-1/+1
| | | | | | | | | | | * compile.c (iseq_compile_each): use it. * vm_core.h: rename flip_cnt field to support this fix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * iseq.h: introduce ISEQ_COVERAGE() and ISEQ_COVERAGE_SET() macro.ko12015-12-021-2/+2
| | | | | | | | | | | | | | | | | * compile.c: use them. * iseq.c: ditto. * iseq.c (rb_iseq_coverage): added. * thread.c (update_coverage): use rb_iseq_coverage(). * vm_core.h: rename coverage field name to support this fix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52860 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * iseq.h: introduce ISEQ_COMPILE_DATA() macro.ko12015-12-021-112/+112
| | | | | | | | | | | * compile.c, iseq.c: use ISEQ_COMPILE_DATA(). * vm_core.h: rename compile_data field to support this fix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52858 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: fix the elementnobu2015-12-021-9/+6
| | | | | | | * compile.c (iseq_set_sequence): fix the element for line number to rb_compile_bug. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52857 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: consistent messagesnobu2015-12-011-17/+32
| | | | | | | * compile.c (EXPECT_NODE, EXPECT_NODE_NONULL, UNKNOWN_NODE): make compile bug messages consistent. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52830 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: tailcall opt for indexersnobu2015-11-261-3/+4
| | | | | | | | | * compile.c (iseq_peephole_optimize): enable tail call optimization for specialized indexers. * compile.c (iseq_compile_each): blockiseq should be NULL, but not Qnil. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52759 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.h: rename membernobu2015-11-251-1/+1
| | | | | | | | | | | * iseq.h (rb_compile_option_struct): rename the member frozen_string_literal_debug as debug_frozen_string_literal. [Feature #11725] * ruby.c (proc_options): do not set $DEBUG and $VERBOSE only if no arguments is given. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52749 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: fix positionnobu2015-11-221-1/+1
| | | | | | | * compile.c (iseq_compile_each): vals is NULL here, show the position of the parent node. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52712 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: move logop DCEnobu2015-11-221-5/+39
| | | | | | | | | * compile.c (iseq_peephole_optimize): remove unreachable code chunk after jump/leave. * parse.y: move dead code elimination of logical operation to compile.c. not to warn logical operation of literal constants. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52711 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: optimize useless branchesnobu2015-11-221-1/+11
| | | | | | | | * compile.c (iseq_peephole_optimize): eliminate always/never branches after a literal object and when the value is used after the branch. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52710 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: free labels tablenobu2015-11-221-4/+12
| | | | | | | | | | * compile.c (validate_labels): free labels table before raising an exception. * compile.c (rb_iseq_build_from_ary): wrap labels table to ensure freeing. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52708 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: use rb_compile_bugnobu2015-11-221-23/+27
| | | | | | | * compile.c: use rb_compile_bug instead of rb_bug to show error position precisely. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52707 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: use COMPILE_ERRORnobu2015-11-221-32/+42
| | | | | | | * compile.c: use COMPILE_ERROR to save an exception to be raised at cleanup_iseq_build. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52706 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: flush disasmnobu2015-11-221-0/+1
| | | | | | * compile.c (dump_disasm_list): flush disassembled list. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52705 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: check each stepsnobu2015-11-221-9/+8
| | | | | | * compile.c (iseq_setup): check return values of each steps. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * compile.c (iseq_compile_each): add debug information to NODE_STRko12015-11-201-10/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | strings as default. [Feature #11725] * insns.def (freezestring): add new instruction to support adding debug information for dynamically constracted strings. * compile.c (iseq_compile_each): support adding debug information for NODE_DSTR with freezestring instruction. * error.c (rb_error_frozen): change the debug information ID name id_debug_created_info and this field should have a 2 element array containing path and line information. * defs/id.def: ditto. * test/ruby/test_rubyoptions.rb: catch up this fix. * test/ruby/test_iseq.rb: now frozen strings are not same. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * compile.c (iseq_compile_each): T_IMEMO/iseq objects should beko12015-11-191-2/+2
| | | | | | | | | wrap with ISeq wrappers. [Bug #11676] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52667 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: tailcall before specializenobu2015-11-191-7/+25
| | | | | | | | | * compile.c (iseq_tailcall_optimize): apply tail call optimization before conversion to specialized instructions. when looking back from `leave` instruction, `send` instructions have been translated already. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52663 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* comment for r52633 [ci skip]nobu2015-11-181-0/+17
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: optimize useless branchesnobu2015-11-181-0/+27
| | | | | | | | | * compile.c (iseq_peephole_optimize): eliminate always/never branches after a literal object. this sequence typically appears by defined? operator for a method call on a local variable. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52633 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: check type before checking insn_idnobu2015-11-181-1/+7
| | | | | | | * compile.c (iseq_peephole_optimize): check element type before checking insn_id which is valid only for INSN elements. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52632 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: tailcall on aref and asetnobu2015-11-161-1/+4
| | | | | | | * compile.c (iseq_peephole_optimize): optimize tail calls on aref and aset specialized instructions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: optimize leavenobu2015-11-161-1/+2
| | | | | | | * compile.c (iseq_peephole_optimize): optimize replaced leave instruction copied to jump instruction too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: fix variablenobu2015-11-141-1/+1
| | | | | | | * compile.c (iseq_peephole_optimize): use proper variable, without cast. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: remove unused labelsnobu2015-11-141-5/+36
| | | | | | | | | * compile.c (iseq_label_data): manage reference count. * compile.c (iseq_peephole_optimize): remove unreferred labels which may disturb optimization. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52567 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm.c (vm_define_method): refactoring.ko12015-11-131-2/+1
| | | | | | | | | | | | * get CREF in this function. * cbase is no longer needed (CREF_CLASS(cref) is enough). * compile.c: RubyVM::FrozenCore.define_method only accept 2 args. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: comments for r52517 [ci skip]nobu2015-11-111-0/+8
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52538 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: peepholenobu2015-11-101-0/+12
| | | | | | | * compile.c (iseq_peephole_optimize): remove putting object to be popped just soon. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52517 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * compile.c (iseq_compile_each): Dynamic string literals should beshugo2015-11-091-0/+5
| | | | | | | frozen. [ruby-core:57574] [Feature #8976] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* id.def: internal IDsnobu2015-10-271-2/+2
| | | | | | * defs/id.def: move internal IDs for frozen-string-literal-debug. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52300 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * ruby.c: introduce --enable-frozen-string-literal-debug option.ko12015-10-231-3/+11
| | | | | | | | | | | | | | | | | | | | | If this option is enabled, the modify error will be: can't modify frozen String (RuntimeError) => can't modify frozen String, created at test.rb:3 (RuntimeError) * iseq.h: add compile option frozen_string_literal_debug. * compile.c: catch up this fix. * error.c (rb_error_frozen): ditto. * iseq.c (set_compile_option_from_hash): ditto. * test/ruby/test_rubyoptions.rb: add a test for this fix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52257 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: optimize method chainnobu2015-10-231-24/+27
| | | | | | | * compile.c (iseq_peephole_optimize): optimize lengthy safe navigation method chain. [Feature #11537] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* safe navigation attrsetnobu2015-10-231-3/+13
| | | | | | | | | * compile.c (iseq_compile_each): support safe navigation of simple attribute assignment. [Feature #11537] * parse.y (mlhs_node, lhs, attrset_gen): ditto. keep mid non-attrset as the sign of safe navigation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: just insertnobu2015-10-231-6/+18
| | | | | | | * compile.c (compile_massign_lhs): just insert topn insn instead of popping and adding. [Feature #11537] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52233 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Safe navigation operatornobu2015-10-221-3/+50
| | | | | | | | | | | | | * compile.c (iseq_peephole_optimize): peephole optimization for branchnil jumps. * compile.c (iseq_compile_each): generate save navigation operator code. * insns.def (branchnil): new opcode to pop the tos and branch if it is nil. * parse.y (NEW_QCALL, call_op, parser_yylex): parse token '.?'. [Feature #11537] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* node.h: no attrset ID in NODEnobu2015-10-121-3/+4
| | | | | | | | * compile.c (iseq_compile_each), node.h (NEW_OP_ASGN22): attrset ID no longer needs to be stored in a NODE, create at byte code generation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52113 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * compile.c (iseq_compile_each): Dynamic string literals (e.g.,shugo2015-10-091-5/+0
| | | | | | | | | | "#{x}") should not be frozen because they don't literally represent strings. https://twitter.com/shugomaeda/status/651937650027401216 https://twitter.com/yukihiro_matz/status/651942882312482817 https://twitter.com/yukihiro_matz/status/651980835181096960 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52087 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: dstr head typenobu2015-10-051-2/+5
| | | | | | | * compile.c (compile_dstr_fragments): head of dstr must be a string. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52047 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: fix performance of strconcatnobu2015-09-291-0/+13
| | | | | | | | | | * compile.c (compile_dstr_fragments): fix performance by omitting the first empty string only for keeping literal encoding if other literals are too. [ruby-core:70930] [Bug #11556] * string.c (rb_str_append_literal): append but keep encoding non US-ASCII. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* fronzen-string-literal pragmanobu2015-09-271-0/+7
| | | | | | | | | | | | | * compile.c (iseq_compile_each): override compile option by option given by pragma. * iseq.c (rb_iseq_make_compile_option): extract a function to overwrite rb_compile_option_t. * parse.y (parser_set_compile_option_flag): introduce pragma to override compile options. * parse.y (magic_comments): new pragma "fronzen-string-literal". [Feature #8976] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51953 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm_core.h: split rb_call_info_t into several structs.ko12015-09-191-53/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * rb_call_info (ci) has compiled fixed information. * if ci->flag & VM_CALL_KWARG, then rb_call_info is also rb_call_info_with_kwarg. This technique reduce one word for major rb_call_info data. * rb_calling_info has temporary data (argc, blockptr, recv). for each method dispatch. This data is allocated only on machine stack. * rb_call_cache is for inline method cache. Before this patch, only rb_call_info_t data is passed. After this patch, above three structs are passed. This patch improves: * data locarity (rb_call_info is now read-only data). * reduce memory consumption (rb_call_info_with_kwarg, rb_calling_info). * compile.c: use above data. * insns.def: ditto. * iseq.c: ditto. * vm_args.c: ditto. * vm_eval.c: ditto. * vm_insnhelper.c: ditto. * vm_insnhelper.h: ditto. * iseq.h: add iseq_compile_data::ci_index and iseq_compile_data::ci_kw_indx. * tool/instruction.rb: introduce TS_CALLCACHE operand type. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51903 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm_insnhelper.c (vm_call_iseq_setup_normal): do not clear localko12015-09-121-1/+4
| | | | | | | | | | | | | | variables here. vm_push_frame() clears. * vm_insnhelper.c (vm_call_iseq_setup_tailcall): ditto. * vm_insnhelper.c (vm_push_frame): move check code to vm_check_frame(). Reorder initialization timing to reuse same values (sp). * compile.c (rb_iseq_compile_node): use iseq_set_exception_local_table() for ISEQ_TYPE_DEFINED_GUARD. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: register cdhashnobu2015-09-101-1/+1
| | | | | | | | * compile.c (iseq_build_from_ary_body): register cdhash to the iseq constant body instead of compile time mark array, not to get GCed. [ruby-core:70708] [Feature #8543] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51816 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm_core.h: remove rb_call_info_t::blockiseq.ko12015-09-081-26/+23
| | | | | | | | | | | | | * insns.def (send, invokesuper): pass blockiseq explicitly. * compile.c: catch up this fix. * iseq.c: ditto. * vm_args.c: ditto. * iseq.c (ISEQ_MINOR_VERSION): 2->3 because instruction spec was changed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51794 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * compile.c (iseq_set_sequence): rename variable namesko12015-08-271-40/+40
| | | | | | | | to make it readable. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51707 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm_opts.h, iseq.c, iseq.h: add compile option to force frozenko12015-08-211-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | string literals. [Feature #11473] This addition is not specification change, but to try frozen string literal world discussed on [Feature #11473]. You can try frozen string literal world using this magical line: RubyVM::InstructionSequence.compile_option = {frozen_string_literal: true} Note that this is a global compilation option, so that you need to compile another script like that: p 'foo'.frozen? #=> false RubyVM::InstructionSequence.compile_option = {frozen_string_literal: true} p 'foo'.frozen? #=> false, because this line is already compiled. p eval("'foo'.frozen?") #=> true Details: * String literals are deduped by rb_fstring(). * Dynamic string literals ("...#{xyz}...") is now only frozen, not deduped. Maybe you have other ideas. Now, please do not use this option on your productions :) Of course, current specification can be changed. * compile.c: ditto. * test/ruby/test_iseq.rb: add a test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e