summaryrefslogtreecommitdiff
path: root/internal.h
AgeCommit message (Collapse)Author
2018-01-27internal.h: add BITFIELD macro to aid C99 usersnormal
I plan to use this macro to pack other enums in the VM. * internal.h: add BITFIELD macro * method.h: use BITFIELD for rb_method_visibility_t [ruby-core:85074] [Misc #14395] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62077 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-27array.c: rb_check_to_arraynobu
* array.c (rb_check_to_array): conversion to array by to_a method. returns nil if not possible. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62072 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-24process.c: add :exception option to Kernel.#systemk0kubun
to raise error when it fails. [Feature 14386] [GH-1795] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-18merge extern declarations into internal.hshyouhei
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-15Add tests for Node code locationsyui-knk
* test/-ext-/ast/test_ast.rb: Add tests for Node code locations. This file tests 1. There are no Node whose code location is default value (#test_not_cared) 2. There are no Node whose children's code locations exceed parent's code location (#test_ranges) * ext/-test-/ast/ast.c, ext/-test-/ast/extconf.rb: Define AST module to help tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61859 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-13internal.h (FLEX_ARY_LEN): Add a macro to define a flexible arraymame
Also, use it in iseq.c. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61804 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09internal.h: remove dependecy on ruby/encoding.hnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09internal.h: remove dependecy on ruby/io.hnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61712 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-05marshal.c: allow marshalling keyword_init structk0kubun
struct.c: define rb_struct_s_keyword_init to shared with marshal.c internal.h: add the declaration to be used by marshal.c test/ruby/test_marshal.rb: add test for Bug#14314 [Feature #14314] [ruby-core:84629] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61616 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-02statement experssion is a GCCismshyouhei
should mark as such. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-02_Static_assert is a C11ismshyouhei
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61555 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-02long long is a C99ismshyouhei
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61550 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-02__VA_ARGS__ is a C99ismshyouhei
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-02long long is a C99simshyouhei
Don't assume 8-bytes integers == "long long". git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61547 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-30bit fields treating negative values should be declared as signed intngoto
* internal.h (struct vm_ifunc_argc): Bit fields are unsigned by default. For storing nagative values to bit fields, they must be declated as signed int. Fix multiple test failure observed by 32-bit binaries compiled with Oracle Developer Studio (Solaris Studio) 12.x on Solaris 10 on sparc architecture. [Bug #14260] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-30hash literal deduplicates like Hash#[]=normal
From: Eric Wong <e@80x24.org> * hash.c (rb_hash_key_str): new function (hash_aset_str): use rb_hash_key_str * internal.h: add rb_hash_key_str * st.c (st_stringify): use rb_hash_key_str * test/ruby/test_hash.rb (test_NEWHASH_fstring_key): dynamic key [ruby-core:84554] [Feature #14258] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61514 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-18suppress warning: 'const' attribute on function returning 'void'naruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61323 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-13iseq.c: dump type of branchiftype on disasmk0kubun
This makes easier to debug scripts related to r59950. * before $ ./ruby --dump=insns -e '"#{a}"' == disasm: #<ISeq:<main>@-e>============================================ 0000 putobject "" ( 1)[Li] 0002 putself 0003 opt_send_without_block <callinfo!mid:a, argc:0, FCALL|VCALL|ARGS_SIMPLE>, <callcache> 0006 dup 0007 branchiftype 5, 15 0010 dup 0011 opt_send_without_block <callinfo!mid:to_s, argc:0, FCALL|ARGS_SIMPLE>, <callcache> 0014 tostring 0015 concatstrings 2 0017 leave * after $ ./ruby --dump=insns -e '"#{a}"' == disasm: #<ISeq:<main>@-e>============================================ 0000 putobject "" ( 1)[Li] 0002 putself 0003 opt_send_without_block <callinfo!mid:a, argc:0, FCALL|VCALL|ARGS_SIMPLE>, <callcache> 0006 dup 0007 branchiftype T_STRING, 15 0010 dup 0011 opt_send_without_block <callinfo!mid:to_s, argc:0, FCALL|ARGS_SIMPLE>, <callcache> 0014 tostring 0015 concatstrings 2 0017 leave git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61217 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-05Revamp method coverage to support define_methodmame
Traditionally, method coverage measurement was implemented by inserting `trace2` instruction to the head of method iseq. So, it just measured methods defined by `def` keyword. This commit drastically changes the measuring mechanism of method coverage; at `RUBY_EVENT_CALL`, it keeps a hash from rb_method_entry_t* to runs (i.e., it counts the runs per method entry), and at `Coverage.result`, it creates the result hash by enumerating all `rb_method_entry_t*` objects (by `ObjectSpace.each_object`). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61023 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-04bignum.c, numeric.c: add Integer#pow(b, m)mrkn
This commit is based on the pull-request #1320 created by Makoto Kishimoto. [Feature #12508] [Feature #11003] [close GH-1320] * bignum.c (rb_int_powm): Added for Integer#pow(b, m). * internal.h (rb_int_powm): Declared to refer in numeric.c. * bignum.c (bary_powm_gmp): Added for Integer#pow(b, m) using GMP. * bignum.c (int_pow_tmp1): Added for implementing Integer#pow(b, m). * bignum.c (int_pow_tmp2, int_pow_tmp3): ditto. * internal.h (rb_num_positive_int_p): Moved from numeric.c for sharing the definition with bignum.c. * internal.h (rb_num_negative_int_p, rb_num_compare_with_zero): ditto. * numeric.c(negative_int_p): Moved to internal.h for sharing the definition with bignum.c. * numeric.c (positive_int_p, compare_with_zero): ditto. * numeric.c (rb_int_odd_p): Exported (renamed from int_odd_p). * internal.h (rb_int_odd_p): ditto. * internal.h (HALF_LONG_MSB): Added. * numeric.c (SQRT_LONG_MAX): Redefined by using HALF_LONG_MSB. * test/ruby/test_numeric.rb (test_pow): Added for Integer#pow(b, m). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-16`rb_source_loc` -> `rb_source_location_cstr`ko1
* vm.c (rb_source_loc): rename to rb_source_location_cstr() to make behavior clear compare with rb_source_location(). * error.c (warning_string): use rb_source_location_cstr() directly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-16remove an unused function.ko1
* vm.c (rb_sourcefilename): removed because nobody use it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60788 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-04Rename imemo_strterm to imemo_parser_strtermmame
Per ko1's request. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60642 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-04Revert "Revert "Replace NODE_STRTERM and NODE_HEREDOC with imemo_strterm""mame
Retry r60634 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-04Revert "Replace NODE_STRTERM and NODE_HEREDOC with imemo_strterm"mame
Due to build failure on mswin and mingw. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-04Replace NODE_STRTERM and NODE_HEREDOC with imemo_strtermmame
Just refactoring. NODE_STRTERM and NODE_HEREDOC are not an internal node of AST, but a temporary storage for managing termination of string literals and heredocs. Instead of NODE abuse, I want to use imemo for the storage in order to avoid (my) confusion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27Revert "Revert "Manage AST NODEs out of GC""mame
This re-introduces r60485. This reverts commit 5a176b75b1187cbd3861c387bde65ff66396a07c. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60488 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27Revert "Manage AST NODEs out of GC"mame
This reverts commit 620ba74778bfdbdc34ffbb142d49ce84a0ef58e9. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60486 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27Manage AST NODEs out of GCmame
NODEs in AST are no longer objects managed by GC. This change will remove the restriction imposed by the GC. For example, a NODE can use more than five words (this is my primary purpose; we want to store the position data for each NODE, for coverage library), or even a NODE can have variable length (some kinds of NODEs have unused fields). To do this, however, we need more work, since Ripper still uses T_NODE objects managed by the GC. The life time of NODEs is more obvious than other kinds of objects; they are created at parsing, and they become disused immediately after compilation. This change releases all NODEs by a few `xfree`s after compilation, so performance will be improved a bit. In extreme example, `eval("x=1;" * 10000000)` runs much faster (40 sec. -> 7.8 sec. on my machine). The most important part of this change is `ast_t` struct, which has three contents: (1) NODE buffer (malloc'ed memory), (2) a reference to the root NODE, and (3) an array that contains objects that must be marked during parsing (such as literal objects). Some functions that had received `NODE*` arguments, must now receive `ast_t*`. * node.c, node.h: defines `ast_t` struct and related operations. * gc.c, internal.h: defines `imemo_ast`. * parse.y: makes `parser_params` struct have a reference to `ast_t`. Instead of `rb_node_newnode`, use `rb_ast_newnode` to create a NODE. * iseq.c, load.c, ruby.c, template/prelude.c.tmpl: modifies some functions to handle `ast_t*` instead of `NODE*`. * test/ruby/test_gc.rb: ad-hoc fix for a failed test. The test assumes GC eden is increased at startup by NODE object creation. However, this change now create no NODE object, so GC eden is not necessarily increased. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-26Use rb_execution_context_t instead of rb_thread_tko1
to represent execution context [Feature #14038] * vm_core.h (rb_thread_t): rb_thread_t::ec is now a pointer. There are many code using `th` to represent execution context (such as cfp, VM stack and so on). To access `ec`, they need to use `th->ec->...` (adding one indirection) so that we need to replace them by passing `ec` instead of `th`. * vm_core.h (GET_EC()): introduced to access current ec. Also remove `ruby_current_thread` global variable. * cont.c (rb_context_t): introduce rb_context_t::thread_ptr instead of rb_context_t::thread_value. * cont.c (ec_set_vm_stack): added to update vm_stack explicitly. * cont.c (ec_switch): added to switch ec explicitly. * cont.c (rb_fiber_close): added to terminate fibers explicitly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60440 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-26common conversion functionsnobu
* array.c (rb_to_array_type): make public to share common code internally. * hash.c (rb_to_hash_type): make public to share common code internally. * symbol.c (rb_to_symbol_type): make public to share common code internally. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-25Refactoring by adding `rb_imemo_alloc_new` to create imemo_alloc buffermame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22vm_insnhelper.c: array aref optimizationnobu
* vm_insnhelper.c (vm_opt_aref): optimize on other than fixnum argument too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21Add doxygen commentssonots
* include/ruby/ruby.h (enum ruby_value_type): add doxygen comments * internal.h (enum imemo_type, struct vm_svar): add doxygen comments * method.h (rb_method_type_t, rb_method_iseq_t): add doxygen comments git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60285 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21fix comment abount IMEMO_FL_USHIFTtarui
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60252 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21imemo_mask (enum) -> IMEMO_MASK (immediate value).ko1
* internal.h: imemo_mask is not a valid imemo type but switch statements show warnings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60250 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21fix up imemo_allocnobu
* internal.h (rb_imemo_alloc_struct), gc.c (gc_mark_imemo): turned next into the pointer to chain. * parse.y (NEWHEAP): needs a cast. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60244 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21Replace NODE_ALLOCA with T_IMEMO (imemo_alloc)mame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21[Feature #13712] String#start_with? supports regexpnaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-02Revert "vm_eval.c: add rb_yield_assoc_or_values()"glass
This reverts commit r60095 to prevent performance degradation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-02vm_eval.c: add rb_yield_assoc_or_values()glass
The new function rb_yield_assoc_or_values() will reduce branching. * vm_eval.c: add rb_yield_assoc_or_values() * internal.h: ditto * hash.c: use rb_yield_assoc_or_values() * struct.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60095 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-30hash.c: remove special treatments on deletionglass
st.c was improved in r56650 that it permits deletion during iteration. In this commit, special treatments for previous implementation are removed. * hash.c: don't use *_check and *_safe functions in st.c * internal.h: remove HASH_DELETED flag git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-25Fix overflow detection for LLP64 arch [Bug #13748]naruse
FIXNUMs are expected to fit into a long type, but the test is about a VALUE type. Since long is < than VALUE on LLP64, the overflow is not detected. As a result "2**31" evaluates to "-2147483648" on Windows with gcc-7.1.0. patched by Lars Kanis <lars@greiz-reinsdorf.de> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-21file.c: rb_check_realpathnobu
* file.c (rb_check_realpath): returns real path which has no symbolic links. similar to rb_realpath except for returning Qnil if any parts did not exist. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59983 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-18error.c: KeyError#receiver and KeyError#keynobu
* error.c: new method KeyError#receiver and KeyError#key. [Feature #12063] * hash.c: make KeyError object with receiver and key. * sprintf.c: ditto. Author: ksss <co000ri@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59955 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-10store ec instead of thread in rb_context_t.ko1
* cont.c (rb_context_t): introduce saved_ec instaad of saved_thread. We only need to transfer ec data (not all of thread data). Introduce `thread_value` field to point creation thread. To acccess this field, `cont_thread_value()` is introduced. * vm.c (rb_execution_context_mark): remove `static` and use it from cont.c (use this function instead of `rb_thread_mark`). * vm_insnhelper.c (rb_vm_push_frame): accept ec instead of th. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-07ruby.h: unnormalized Fixnum valuenobu
* include/ruby/ruby.h (ST2FIX): fix unnormalized Fixnum value bug on mingw/mswin. [ruby-core:82687] [Bug #13877] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59765 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-05add rb_hash_new_with_size()shyouhei
Sometimes, size of a hash can be calcluated a priori. By providing such info to the constructor we can avoid unnecessary internal re- allocations. This can boost for instance creation of hash literals. [Bug #13861] Signed-off-by: Urabe, Shyouhei <shyouhei@ruby-lang.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59744 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-03Refactor the internal data format for coverage measurementmame
To prepare new measuring targets: branch and method coverages. So far, iseq->coverage was an array of counts executed for line coverage. Now, it is a three-element array for each measuring target, whose first element is an array for line coverage. The second element is planned for branch coverage, and the third will be for method coverage. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-10Fiber#to_s (#inspect) return richer information.ko1
* cont.c (fiber_to_s): return with block and status information. * proc.c (proc_to_s_): removed and introduce rb_block_to_s() function to return block information string. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59558 b2dd03c8-39d4-4d8f-98ff-823fe69b080e