summaryrefslogtreecommitdiff
path: root/iseq.c
AgeCommit message (Collapse)Author
2017-01-12immediate message mode of compile errornobu
* 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
2016-09-27iseq.c: syntax error in compile_filenobu
* iseq.c (iseqw_s_compile_file): deal with syntax error as well as compile, and should not abort when rescued. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-27iseq.c: kwarg to compilenobu
* iseq.c (iseqw_s_compile, iseqw_s_compile_file): allow keyword arguments as the options. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56266 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-27iseq.c: file name encodingnobu
* iseq.c (iseqw_s_compile): keep the encoding of file name. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56265 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-13Use PRIuSIZE format specifier for size_t valuesrhe
Use PRIuSIZE instead of PRIdSIZE. This fixes the exception message shown on too large xmalloc2. This commit also fixes other incorrect use of PRIdSIZE in other functions; though most of them are debug print. * gc.c (heap_extend_pages, get_envparam_size, ruby_malloc_size_overflow, gc_profile_dump_on): Use PRIuSIZE instead of PRIdSIZE as the passed value is size_t, not ssize_t. * iseq.c (get_line_info, rb_iseq_disasm_insn): Ditto. * sprintf.c (rb_str_format): Ditto. * thread_win32.c (native_thread_create): Ditto. * vm.c (get_param): Ditto. * ext/objspace/objspace_dump.c (dump_append_string_content, dump_object): Ditto. * ext/socket/raddrinfo.c (host_str, port_str): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-22iseq.c: undef allocatornobu
* iseq.c (Init_ISeq): undefine allocator of InstructionSequence, to get rid of segfaults at method call on uninitialized object. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55981 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-03* vm_core.h: introduce VM_FRAME_RUBYFRAME_P()ko1
and VM_FRAME_CFRAME_P(). Most of case, RUBY_VM_NORMAL_ISEQ_P() is no longer needed. * vm_core.h: introduce rb_obj_is_iseq(). * cont.c, vm.c: VM_FRAME_MAGIC_DUMMY with VM_FRAME_FLAG_CFRAME. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55804 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-29rb_funcallvnobu
* *.c: rename rb_funcall2 to rb_funcallv, except for extensions which are/will be/may be gems. [Fix GH-1406] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-28* vm_core.h: revisit the structure of frame, block and env.ko1
[Bug #12628] This patch introduce many changes. * Introduce concept of "Block Handler (BH)" to represent passed blocks. * move rb_control_frame_t::flag to ep[0] (as a special local variable). This flags represents not only frame type, but also env flags such as escaped. * rename `rb_block_t` to `struct rb_block`. * Make Proc, Binding and RubyVM::Env objects wb-protected. Check [Bug #12628] for more details. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-13* iseq.c (Init_ISeq): undef ISeq.translate and ISeq.load_iseqko1
to prevent calling super classes' methods. Without this patch, you can write workaround like: class << RubyVM::InstructionSequence def translate; end undef translate end * test/ruby/test_iseq.rb: add a test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55656 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-14* iseq.h (struct iseq_compile_data): use struct rb_id_tablenaruse
instead of st_table. * iseq.c (prepare_iseq_build): don't allocate ivar_cache_table until it has at least one element. * iseq.c (compile_data_free): free ivar_cache_table only if it is allocated. * compile.c (get_ivar_ic_value): allocate if the table is not allocated yet. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55002 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-11 * compile.c (iseq_compile_each): share InlineCache during sametarui
instance variable accesses. Reducing memory consumption, rasing cache hit rate and rasing branch prediction hit rate are expected. A part of [Bug #12274]. * iseq.h (struct iseq_compile_data): introduce instance variable IC table for sharing. * iseq.c (prepare_iseq_build, compile_data_free): construct/destruct above table. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54976 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-28remove rb_thread_t::base_blocknobu
* error.c (rb_compile_err_append): rb_thread_t::base_block is no longer used. * iseq.c (rb_iseq_compile_with_option): ditto, no protection is needed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-28remove rb_thread_t::parse_in_evalnobu
* parse.y (struct parser_params): move parse_in_eval flag from rb_thread_t. * parse.y (rb_parser_set_context): set parsing context, not only mild error flag. * iseq.c (rb_iseq_compile_with_option): the parser now refers no thread local states to be restored. * vm_eval.c (eval_string_with_cref): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54343 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-21suppress warningnobu
* iseq.c (rb_iseq_compile_with_option): suppress maybe-uninitialized warning by gcc 4.8. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54217 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-19SyntaxError message at iseq compilenobu
* iseq.c (rb_iseq_compile_with_option): make the parser in mild error. * load.c (rb_load_internal0): ditto. * parse.y (yycompile0): return the error message within the error to be raised. [Feature #11951] * parse.y (parser_compile_error): accumulate error messages in the error_buffer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-10iseq.h: coverage_enabled flagnobu
* iseq.c (prepare_iseq_build): enable coverage by coverage_enabled option, not by parse_in_eval flag in the thread context. * iseq.h (rb_compile_option_struct): add coverage_enabled flag. * parse.y (yycompile0): set coverage_enabled flag if coverage array is made. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-10iseq.c: set coverage at oncenobu
* iseq.c (prepare_iseq_build): set coverage at once, not repeatedly resetting. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-26fstring early for internal iseqnormal
All of the strings created here eventually get converted to fstrings when they are frozen into the iseq. Prepare the fstring early so we may reduce a one or two objects. This is a very minor change, mainly for the '<main>' dedupe. * compile.c (caller_location): use rb_fstring_cstr for "<compiled>" (it is converted to fstring anyways inside rb_iseq_new_with_opt) * iseq.c (iseqw_s_compile): ditto * iseq.c (rb_iseq_new_main): use rb_fstring_cstr for "<main>" * vm.c (Init_VM): ditto, share with with above * iseq.c (iseqw_s_compile_file): rb_fstring before rb_io_t->pathv share "<main>" with above * vm.c (rb_binding_add_dynavars): fstring "<temp>" immediately git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-13iseq.c: mark parent iseqnobu
* iseq.c (rb_iseq_mark): mark parent iseq to prevent dynamically generated iseq by eval from GC. [ruby-core:72620] [Bug #11928] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53524 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-12iseq.c: mark parents of wrapped iseqnobu
* iseq.c (iseqw_mark): as wrapped iseq is isolated from the call stack, it needs to take care of its parent and ancestors, so that they do not become orphans. [ruby-core:72620] [Bug #11928] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53514 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-08iseq.c: volatile only on gcc4.8nobu
* iseq.c (rb_iseq_compile_with_option): no volatile on gcc other than 4.8. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53465 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-08iseq.c: make local variables volatilenobu
* iseq.c (rb_iseq_compile_with_option): prepare arguments outside EXEC_TAG, and make local variables volatile not to be clobbered by longjmp. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53460 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-08* iseq.c (rb_iseq_compile_with_option): move variable initializationshugo
code to avoid maybe-uninitialized warnings by gcc 4.8. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53458 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-28iseq.c: suppress warningsnobu
* iseq.c (rb_iseq_compile_with_option): suppress "clobbered" warnings by old gcc. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-24iseq.c: narrow down protected regionnobu
* iseq.c (rb_iseq_compile_with_option): narrow down protected region, and check/convert/prepare arguments before setting base_block which needs to roll back. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53282 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-14* enum.c: fix a typo in documentation.hsbt
[ci skip][fix GH-1140] Patch by @jutaz * io.c: ditto. * iseq.c: ditto. * numeric.c: ditto. * process.c: ditto. * string.c: ditto. * vm_trace.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-12iseq.c: use rb_check_funcallnobu
* iseq.c (rb_iseq_load_iseq): use rb_check_funcall instead of repeating method search. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53048 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-09* iseq.c: rename methodsko1
RubyVM::InstructionSequence#to_binary_format -> #to_binary RubyVM::InstructionSequence.from_binary_format -> .load_from_binary RubyVM::InstructionSequence.from_binary_format_extra_data -> .load_from_binary_extra_data * iseq.c: fix document of iseq.to_binary. [Fix GH-1134] * sample/iseq_loader.rb: catch up this change. * test/lib/iseq_loader_checker.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-09add documentation for RubyVM::InstructionSequence#to_binary_format and ↵ko1
RubyVM::InstructionSequence.from_binary_format git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08make local symbols staticnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52964 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08* iseq.c (iseq_s_load): fix mysterious bug.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52953 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08* remove trailing spaces.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52950 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08* introduce new ISeq binary format serializer/de-serializerko1
and a pre-compilation/runtime loader sample. [Feature #11788] * iseq.c: add new methods: * RubyVM::InstructionSequence#to_binary_format(extra_data = nil) * RubyVM::InstructionSequence.from_binary_format(binary) * RubyVM::InstructionSequence.from_binary_format_extra_data(binary) * compile.c: implement body of this new feature. * load.c (rb_load_internal0), iseq.c (rb_iseq_load_iseq): call RubyVM::InstructionSequence.load_iseq(fname) with loading script name if this method is defined. We can return any ISeq object as a result value. Otherwise loading will be continue as usual. This interface is not matured and is not extensible. So that we don't guarantee the future compatibility of this method. Basically, you should'nt use this method. * iseq.h: move ISEQ_MAJOR/MINOR_VERSION (and some definitions) from iseq.c. * encoding.c (rb_data_is_encoding), internal.h: added. * vm_core.h: add several supports for lazy load. * add USE_LAZY_LOAD macro to specify enable or disable of this feature. * add several fields to rb_iseq_t. * introduce new macro rb_iseq_check(). * insns.def: some check for lazy loading feature. * vm_insnhelper.c: ditto. * proc.c: ditto. * vm.c: ditto. * test/lib/iseq_loader_checker.rb: enabled iff suitable environment variables are provided. * test/runner.rb: enable lib/iseq_loader_checker.rb. * sample/iseq_loader.rb: add sample compiler and loader. $ ruby sample/iseq_loader.rb [dir] will compile all ruby scripts in [dir]. With default setting, this compile creates *.rb.yarb files in same directory of target .rb scripts. $ ruby -r sample/iseq_loader.rb [app] will run with enable to load compiled binary data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52949 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08error.c: name_err_local_variablesnobu
* error.c (name_err_local_variables): new method NameError#local_variables for internal use only. [Feature #11777] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52942 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-07* iseq.c (iseq_load): disable peephole optimization optionko1
because apply it multiple times change the sequence. (iseq != peephole_optimize(load(iseq.to_a))) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52924 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-07* iseq.c (iseq_translate): at the end of constructing an iseq,ko1
call RubyVM::InstructionSequence.translate(iseq) if this method is defined. If the return value is also an object of RubyVM::InstructionSequence, then use it instead of created one. For example, this method is useful to test iseq dumper/loader such as RubyVM::InstructionSequence#to_a and rb_iseq_load(). Because this method is for such internal experimental usage, the interface is not matured. For example, this interface has no extensibility. Two or more translaters can not run simultaneously. So that we don't guarantee future compatibility of this method. Basically, do not use this method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52921 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_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-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-01iseq.c (iseq_memsize): account for rb_call_cache entriesnormal
Add some comments to clarify the allocated field used for the allocations while we're at it. TODO: figure out a better way of testing/maintaining this... git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52419 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-23* iseq.c (make_compile_option_value): include frozen_string_literal*ko1
in a made option value. * vm_opts.h: forgot to add OPT_FROZEN_STRING_LITERAL_DEBUG at last commit. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52258 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-14iseq.c: list of keywords [Fix GH-1056]nobu
* iseq.c (rb_insn_operand_intern): change kw in callinfo disasm from the number of keyword arguments to an ordered list of the keywords used. [Feature #11589] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52123 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-05* iseq.c (rb_iseq_free): free iseq::variable_body to avoid memoryko1
leak. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52051 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* iseq.c (rb_iseq_free): free rb_iseq_t::body::cc_entries.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51904 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