aboutsummaryrefslogtreecommitdiffstats
path: root/variable.c
Commit message (Collapse)AuthorAgeFilesLines
...
* export func for MJITKoichi Sasada2019-11-291-1/+1
|
* Revert "export for MJIT"Koichi Sasada2019-11-291-1/+1
| | | | This reverts commit 2e6f1cf8b264f4c8499c4e5f18bf662fdade04ff.
* export for MJITKoichi Sasada2019-11-291-1/+1
|
* fastpath for ivar read of FL_EXIVAR objects.Koichi Sasada2019-11-291-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | vm_getivar() provides fastpath for T_OBJECT by caching an index of ivar. This patch also provides fastpath for FL_EXIVAR objects. FL_EXIVAR objects have an each ivar array and index can be cached as T_OBJECT. To access this ivar array, generic_iv_tbl is exposed by rb_ivar_generic_ivtbl() (declared in variable.h which is newly introduced). Benchmark script: Benchmark.driver(repeat_count: 3){|x| x.executable name: 'clean', command: %w'../clean/miniruby' x.executable name: 'trunk', command: %w'./miniruby' objs = [Object.new, 'str', {a: 1, b: 2}, [1, 2]] objs.each.with_index{|obj, i| rep = obj.inspect rep = 'Object.new' if /\#/ =~ rep x.prelude str = %Q{ v#{i} = #{rep} def v#{i}.foo @iv # ivar access method (attr_reader) end v#{i}.instance_variable_set(:@iv, :iv) } puts str x.report %Q{ v#{i}.foo } } } Result: v0.foo # T_OBJECT clean: 85387141.8 i/s trunk: 85249373.6 i/s - 1.00x slower v1.foo # T_STRING trunk: 57894407.5 i/s clean: 39957178.6 i/s - 1.45x slower v2.foo # T_HASH trunk: 56629413.2 i/s clean: 39227088.9 i/s - 1.44x slower v3.foo # T_ARRAY trunk: 55797530.2 i/s clean: 38263572.9 i/s - 1.46x slower
* Improve consistency of bool/true/falseKazuhiro NISHIYAMA2019-11-251-2/+2
|
* Deprecate rb_eval_cmd, add rb_eval_cmd_kwJeremy Evans2019-11-181-1/+1
| | | | | | | | rb_eval_cmd takes a safe level, and now that $SAFE is deprecated, it should be deprecated as well. Replace with rb_eval_cmd_kw, which takes a keyword flag. Switch the two callers to this function.
* Deprecate taint/trust and related methods, and make the methods no-opsJeremy Evans2019-11-181-7/+0
| | | | | | This removes the related tests, and puts the related specs behind version guards. This affects all code in lib, including some libraries that may want to support older versions of Ruby.
* Warn on access/modify of $SAFE, and remove effects of modifying $SAFEJeremy Evans2019-11-181-23/+2
| | | | | | | | | | | | | | | | | This removes the security features added by $SAFE = 1, and warns for access or modification of $SAFE from Ruby-level, as well as warning when calling all public C functions related to $SAFE. This modifies some internal functions that took a safe level argument to no longer take the argument. rb_require_safe now warns, rb_require_string has been added as a version that takes a VALUE and does not warn. One public C function that still takes a safe level argument and that this doesn't warn for is rb_eval_cmd. We may want to consider adding an alternative method that does not take a safe level argument, and warn for rb_eval_cmd.
* delete unused functions卜部昌平2019-11-141-24/+0
| | | | | | | | | | | | Looking at the list of symbols inside of libruby-static.a, I found hundreds of functions that are defined, but used from nowhere. There can be reasons for each of them (e.g. some functions are specific to some platform, some are useful when debugging, etc). However it seems the functions deleted here exist for no reason. This changeset reduces the size of ruby binary from 26,671,456 bytes to 26,592,864 bytes on my machine.
* Prefer st_is_member over st_lookup with 0Ben Woosley2019-10-091-1/+1
| | | | The st_is_member DEFINE has simpler semantics, for more readable code.
* [EXPERIMENTAL] Make Module#name return a frozen StringJean Boussier2019-09-261-4/+1
| | | | | | * Always the same frozen String for a given Module or Class. * Avoids extra allocations whenever calling Module#name. * See [Feature #16150]
* variable.c: Rename rb_st_copy to rb_iv_tbl_copyYusuke Endoh2019-09-221-4/+5
| | | | | | | | | This function was created as a variant of st_copy with firing write barrier. It should have more explicit name, such as st_copy_with_write_barrier. But because it is used only for copying iv_tbl, so I rename it to rb_iv_tbl_copy now. If we face other use case than iv_tbl, we may want to rename it to more general name.
* Fix Module#class_variables for singleton classes of classes/modulesJeremy Evans2019-09-211-0/+6
| | | | | | | | | | | | | | | | | | | Module#class_variables should reflect class variable lookup. For singleton classes of classes/modules, this means the lookup should be: * Singleton Class * Class * All Ancestors of Class Note that this doesn't include modules included in the singleton class, because class variable lookup doesn't include those. Singleton classes of other objects do not have this behavior and always just search all ancestors of the singleton class, so do not change the behavior for them. Fixes [Bug #8297]
* Export rb_const_source_location_at for MJITKazuki Tsujimoto2019-09-011-1/+1
|
* move docs around [ci skip]卜部昌平2019-08-291-42/+0
| | | | To properly generate documents.
* rb_ivar_foreach now free from ANYARGS卜部昌平2019-08-271-5/+7
| | | | | | | After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is dangerous and should be extinct. This commit adds a function prototype for rb_ivar_foreach. Luckily this change revealed no problematic usage of the function.
* rb_define_hooked_variable now free from ANYARGS卜部昌平2019-08-271-16/+17
| | | | | | | | | After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is dangerous and should be extinct. This commit uses rb_gvar_getter_t / rb_gvar_setter_t for rb_define_hooked_variable / rb_define_virtual_variable which revealed lots of function prototype inconsistencies. Some of them were literally decades old, going back to dda5dc00cff334cac373096d444a0fd59e716124.
* rb_ensure now free from ANYARGS卜部昌平2019-08-271-2/+4
| | | | | | After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is dangerous and should be extinct. This commit deletes ANYARGS from rb_ensure, which also revealed many arity / type mismatches.
* Don't accidentally name anonymous module/classAlan Wu2019-08-141-23/+3
| | | | | | | | | | | | | | | | | | b00f280d4b9569e7153365d7e1c522b3d6b3c6cf introduced an accidental behavior change in that defining a module/class under `m` gives `m` a name when `m` is anonymous. `ruby -ve 'Module.new { class self::A; end; p name }'` outputs a name similar to `Module#inspect` when it should output `nil` like in Ruby 2.6.x. * variable.c: Use `make_temporary_path` instead of `save_temporary_path` when getting the name of the parent module. * variable.c (rb_set_class_path): Delegate to `rb_set_class_path_string` instead of duplicating the logic. [Bug #16097]
* Rename rb_gc_mark_no_pin -> rb_gc_mark_movableAaron Patterson2019-08-121-4/+4
| | | | | | Renaming this function. "No pin" leaks some implementation details. We just want users to know that if they mark this object, the reference may move and they'll need to update the reference accordingly.
* remove RHash::iter_lev.Koichi Sasada2019-07-311-5/+20
| | | | | | | | | | | | | | | iter_lev is used to detect the hash is iterating or not. Usually, iter_lev should be very small number (1 or 2) so `int` is overkill. This patch introduce iter_lev in flags (7 bits, FL13 to FL19) and if iter_lev exceeds this range, save it in hidden attribute. We can get 1 word in RHash. We can't modify frozen objects. Therefore I added new internal API `rb_ivar_set_internal()` which allows us to set an attribute even if the target object is frozen if the name is hidden ivar (the name without `@` prefix).
* Use rb_ident_hash_new instead of rb_hash_new_compare_by_idNobuyoshi Nakada2019-07-031-1/+1
| | | | The latter is same as the former, removed the duplicate function.
* * expand tabs.git2019-07-011-3/+3
|
* Fixed inadvertent ID creation in rb_iv_getNobuyoshi Nakada2019-07-011-1/+6
|
* Make autoloading_const_entry staticNobuyoshi Nakada2019-06-231-1/+1
|
* * expand tabs.git2019-06-231-14/+14
|
* Module#constant_source_location [Feature #10771]Nobuyoshi Nakada2019-06-231-0/+56
|
* Split global search for moduleNobuyoshi Nakada2019-06-231-11/+17
|
* Hoisted out autoloading_const_entryNobuyoshi Nakada2019-06-231-8/+21
|
* * expand tabs.git2019-06-211-1/+1
|
* Turned `recur` into `int` [Feature #15777]Nobuyoshi Nakada2019-06-211-3/+3
|
* Add an optional `inherit` argument to Module#autoload?Jean Boussier2019-06-211-0/+7
| | | | | | [Feature #15777] Closes: https://github.com/ruby/ruby/pull/2173
* Add compaction support for more types.Aaron Patterson2019-06-111-4/+14
| | | | | | | | This commit adds compaction support for: * Fibers * Continuations * Autoload Constants
* Fix FrozenError when assigning frozen class to constantNobuyoshi Nakada2019-06-011-2/+4
| | | | | * variable.c (set_namespace_path): modules/classes can get named by assignment to constant, even if frozen. [Bug #15891]
* Set namespace treeNobuyoshi Nakada2019-05-221-14/+8
| | | | | * variable.c (set_namespace_path): set path to the whole namespace tree. [Feature #15765]
* Extract build_const_pathnameAlan Wu2019-05-221-15/+20
| | | | | * variable.c (build_const_pathname): build constant path from name as a string. [Feature #15765]
* Eagerly name modules and classesAlan Wu2019-05-221-218/+104
| | | | | | | | | | | | | | | | | | | | | | | * variable.c: make the hidden ivars `classpath` and `tmp_classpath` the source of truth for module and constant names. Assign to them when modules are bind to constants. * variable.c: remove references to module name cache, as what used to be the cache is now the source of truth. Remove rb_class_path_no_cache(). * variable.c: remove the hidden ivar `classid`. This existed for the purposes of module name search, which is now replaced. Also, remove the associated rb_name_class(). * class.c: use rb_set_class_path_string to set the name of Object during boot. Must use a fstring as this runs before rb_cString is initialized and creating a normal string leads to a VALUE without a class. * spec/ruby/core/module/name_spec.rb: add a few specs to specify what happens to Module#name across multiple operations. These specs pass without other code changes in this commit. [Feature #15765]
* Rename rb_gc_new_location to rb_gc_locationAaron Patterson2019-05-181-1/+1
| | | | | The function will return new or existing locations depending on whether or not the object actually moved, so give it a more appropriate name.
* newptr should not be NULLUrabe, Shyouhei2019-04-261-7/+3
| | | | obj_ivar_heap_alloc already handles that situation.
* avoid reading uninitialized variableUrabe, Shyouhei2019-04-261-0/+1
| | | | | | | | | | | | | | | | | autoload_reset() can read this state.result. Because autoload_reset is a function passed to rb_ensure, there is a chance when an execption raises before actually filling this memory region. test/ruby/test_defined.rb:test_autoload_noload is one of such case. Found using memory sanitizer. ==54014==WARNING: MemorySanitizer: use-of-uninitialized-value #0 0x557a683f3e5a in autoload_reset variable.c:2372:9 #1 0x557a6707a93b in rb_ensure eval.c:1084:5 #2 0x557a683efbf5 in rb_autoload_load variable.c:2475:14 #3 0x557a685fc460 in vm_get_ev_const vm_insnhelper.c:938:4 #4 0x557a68448e0a in vm_exec_core insns.def:267:11
* Add `GC.compact` again.tenderlove2019-04-201-4/+28
| | | | | | 🙏 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Reverting compaction for nowtenderlove2019-04-171-28/+4
| | | | | | For some reason symbols (or classes) are being overridden in trunk git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Adding `GC.compact` and compacting GC support.tenderlove2019-04-171-4/+28
| | | | | | | | | | | This commit adds the new method `GC.compact` and compacting GC support. Please see this issue for caveats: https://bugs.ruby-lang.org/issues/15626 [Feature #15626] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Reverting all commits from r67479 to r67496 because of CI failureskazu2019-04-101-28/+4
| | | | | | | | Because hard to specify commits related to r67479 only. So please commit again. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Adding `GC.compact` and compacting GC support.tenderlove2019-04-091-4/+28
| | | | | | | | | | | This commit adds the new method `GC.compact` and compacting GC support. Please see this issue for caveats: https://bugs.ruby-lang.org/issues/15626 [Feature #15626] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67479 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [DOC] Fix method references to Method instance methodsnobu2019-03-281-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [DOC] fix markups [ci skip]nobu2019-03-281-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * expand tabs.svn2019-03-091-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* variable.c: hoisted out rb_namespace_pnobu2019-03-091-4/+14
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * expand tabs.svn2018-12-281-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66609 b2dd03c8-39d4-4d8f-98ff-823fe69b080e