summaryrefslogtreecommitdiff
path: root/compile.c
AgeCommit message (Collapse)Author
2015-12-04compile.c: no extra parenthesesnobu
* 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
2015-12-04compile.c: just append compile error messagenobu
* 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
2015-12-02* vm_core.h, iseq.h: remove rb_iseq_t::variable_body.ko1
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
2015-12-02* iseq.h: introduce ISEQ_ORIGINAL_ISEQ() andko1
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
2015-12-02* iseq.h: introduce ISEQ_FLIP_CNT_INCREMENT() macro.ko1
* 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
2015-12-02* iseq.h: introduce ISEQ_COVERAGE() and ISEQ_COVERAGE_SET() macro.ko1
* 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
2015-12-02* iseq.h: introduce ISEQ_COMPILE_DATA() macro.ko1
* 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
2015-12-02compile.c: fix the elementnobu
* 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
2015-12-01compile.c: consistent messagesnobu
* 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
2015-11-26compile.c: tailcall opt for indexersnobu
* 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
2015-11-25iseq.h: rename membernobu
* 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
2015-11-22compile.c: fix positionnobu
* 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
2015-11-22compile.c: move logop DCEnobu
* 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
2015-11-22compile.c: optimize useless branchesnobu
* 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
2015-11-22compile.c: free labels tablenobu
* 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
2015-11-22compile.c: use rb_compile_bugnobu
* 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
2015-11-22compile.c: use COMPILE_ERRORnobu
* 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
2015-11-22compile.c: flush disasmnobu
* 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
2015-11-22compile.c: check each stepsnobu
* 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
2015-11-20* compile.c (iseq_compile_each): add debug information to NODE_STRko1
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
2015-11-19* compile.c (iseq_compile_each): T_IMEMO/iseq objects should beko1
wrap with ISeq wrappers. [Bug #11676] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52667 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-19compile.c: tailcall before specializenobu
* 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
2015-11-18comment for r52633 [ci skip]nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-18compile.c: optimize useless branchesnobu
* 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
2015-11-18compile.c: check type before checking insn_idnobu
* 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
2015-11-16compile.c: tailcall on aref and asetnobu
* 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
2015-11-16compile.c: optimize leavenobu
* 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
2015-11-14compile.c: fix variablenobu
* 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
2015-11-14compile.c: remove unused labelsnobu
* 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
2015-11-13* vm.c (vm_define_method): refactoring.ko1
* 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
2015-11-11compile.c: comments for r52517 [ci skip]nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52538 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-10compile.c: peepholenobu
* 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
2015-11-09* compile.c (iseq_compile_each): Dynamic string literals should beshugo
frozen. [ruby-core:57574] [Feature #8976] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-27id.def: internal IDsnobu
* 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
2015-10-23* ruby.c: introduce --enable-frozen-string-literal-debug option.ko1
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
2015-10-23compile.c: optimize method chainnobu
* 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
2015-10-23safe navigation attrsetnobu
* 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
2015-10-23compile.c: just insertnobu
* 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
2015-10-22Safe navigation operatornobu
* 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
2015-10-12node.h: no attrset ID in NODEnobu
* 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
2015-10-09* compile.c (iseq_compile_each): Dynamic string literals (e.g.,shugo
"#{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
2015-10-05compile.c: dstr head typenobu
* 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
2015-09-29compile.c: fix performance of strconcatnobu
* 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
2015-09-27fronzen-string-literal pragmanobu
* 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
2015-09-19* vm_core.h: split rb_call_info_t into several structs.ko1
* 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
2015-09-12* vm_insnhelper.c (vm_call_iseq_setup_normal): do not clear localko1
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
2015-09-10compile.c: register cdhashnobu
* 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
2015-09-08* vm_core.h: remove rb_call_info_t::blockiseq.ko1
* 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
2015-08-27* compile.c (iseq_set_sequence): rename variable namesko1
to make it readable. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51707 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-21* vm_opts.h, iseq.c, iseq.h: add compile option to force frozenko1
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