aboutsummaryrefslogtreecommitdiffstats
path: root/compile.c
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* hoist out rb_call_info_kw_arg_bytes to inline functionnormal2015-08-121-1/+1
| | | | | | | | | * vm_core.h (rb_call_info_kw_arg_bytes): extract from compile.c * compile.c (iseq_build_callinfo_from_hash): use above function This will be use for implementing iseq_memsize git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51546 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm_core.h: size should be unsigned.ko12015-07-241-7/+7
| | | | | | | | | | | | | | | | | | | | | | * rb_call_info_t::index * rb_iseq_constant_body::stack_max * rb_iseq_constant_body::local_size * rb_iseq_constant_body::param::size * rb_iseq_constant_body::local_table_size * rb_iseq_constant_body::is_size * rb_iseq_constant_body::callinfo_size * iseq.h: same for iseq_catch_table::size. * compile.c: catch up these fix. * iseq.c: ditto. * proc.c: ditto. * vm.c: ditto. * vm_args.c: ditto. * vm_eval.c: ditto. * vm_insnhelper.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51369 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm_core.h: constify rb_iseq_constant_body::param::opt_table andko12015-07-241-94/+107
| | | | | | | | | rb_iseq_constant_body::param::keyword. * compile.c: catch up this fix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51367 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm_core.h: constify rb_iseq_constant_body::catch_table.ko12015-07-241-33/+36
| | | | | | | | | | * compile.c (iseq_set_exception_table): catch up this fix. * iseq.c: ditto. * vm.c (vm_exec): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51365 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm_core.h: constify rb_iseq_constant_body::local_table andko12015-07-231-15/+27
| | | | | | | | | | | rb_iseq_param_keyword::table and rb_iseq_param_keyword::default_values. * compile.c: catch up this fix. * iseq.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm_core.h: constify rb_iseq_constant_body::iseq_encoded andko12015-07-231-1/+2
| | | | | | | | | | | rb_control_frame_t::pc. * compile.c (rb_iseq_translate_threaded_code): catch up this fix. * iseq.c: ditto. * vm_exec.c (vm_exec_core): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51356 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm_core.h: separate rb_iseq_body into rb_iseq_constant_body andko12015-07-221-9/+9
| | | | | | | | | | | | rb_iseq_variable_body (rb_iseq_t::variable_body). rb_iseq_variable_body can be modified after compilation. * compile.c: use rb_iseq_t::variable_body. * iseq.c: ditto. * thread.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51339 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * make rb_iseq_t T_IMEMO object (type is imemo_iseq).ko12015-07-211-377/+365
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All contents of previous rb_iseq_t is in rb_iseq_t::body. Remove rb_iseq_t::self because rb_iseq_t is an object. RubyVM::InstructionSequence is wrapper object points T_IMEMO/iseq. So RubyVM::ISeq.of(something) method returns different wrapper objects but they point the same T_IMEMO/iseq object. This patch is big, but most of difference is replacement of iseq->xxx to iseq->body->xxx. (previous) rb_iseq_t::compile_data is also located to rb_iseq_t::compile_data. It was moved from rb_iseq_body::compile_data. Now rb_iseq_t has empty two pointers. I will split rb_iseq_body data into static data and dynamic data. * compile.c: rename some functions/macros. Now, we don't need to separate iseq and iseqval (only VALUE). * eval.c (ruby_exec_internal): `n' is rb_iseq_t (T_IMEMO/iseq). * ext/objspace/objspace.c (count_imemo_objects): count T_IMEMO/iseq. * gc.c: check T_IMEMO/iseq. * internal.h: add imemo_type::imemo_iseq. * iseq.c: define RubyVM::InstructionSequnce as T_OBJECT. Methods are implemented by functions named iseqw_.... * load.c (rb_load_internal0): rb_iseq_new_top() returns rb_iseq_t (T_IMEMO/iesq). * method.h (rb_add_method_iseq): accept rb_iseq_t (T_IMEMO/iseq). * vm_core.h (GetISeqPtr): removed because it is not T_DATA now. * vm_core.h (struct rb_iseq_body): remove padding for [Bug #10037][ruby-core:63721]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * compile.c: constify the first parameter (iseq).ko12015-07-211-2/+2
| | | | | | | | | | * iseq_add_mark_object() * iseq_add_mark_object_compile_time() * iseq.c, iseq.h (rb_iseq_add_mark_object): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51311 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ruby_vm_throw_flagsnobu2015-07-201-4/+4
| | | | | | * vm_core.h (ruby_vm_throw_flags): constants for throw. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51300 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: use ruby_tag_typenobu2015-07-171-5/+5
| | | | | | | | * compile.c (iseq_compile_each): use enum ruby_tag_type names. * vm_core.h (ruby_tag_type): move from eval_intern.h for compiling break/next/redo/return. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51283 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: remove unused bignobu2015-07-171-7/+2
| | | | | | | * compile.c (iseq_compile_each): remove unused big flag, `while` loop always leaves a result on the stack. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51282 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm_core.h: constify rb_iseq_t::parent_iseq.ko12015-07-161-15/+16
| | | | | | | | | | | | rb_iseq_t::local_iseq is not constant data because local_iseq::flip_cnt can be modified (commentted). * compile.c: catch up this fix. * iseq.c: ditto. * vm_insnhelper.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51269 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c (COMPILE_ERROR): reduce GET_THREAD() callsnormal2015-07-071-4/+5
| | | | | | | | | | | Shorten a long line and reduce global variable access, giving a minor code size reduction (at least on 32-bit x86): text data bss dec hex filename 96807 772 48 97627 17d5b compile.orig 96775 772 48 97595 17d3b compile.o git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51184 b2dd03c8-39d4-4d8f-98ff-823fe69b080e