aboutsummaryrefslogtreecommitdiffstats
path: root/inits.c
Commit message (Collapse)AuthorAgeFilesLines
* Improve performance some Float methods [Feature #17498] (#4018)S.H2021-01-011-1/+1
|
* Moved time.rb to timev.rbNobuyoshi Nakada2020-12-311-1/+1
|
* Add time.rb as builtinNobuyoshi Nakada2020-12-311-0/+1
|
* Buffer protocol proposal (#3261)Kenta Murata2020-09-251-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add buffer protocol * Modify for some review comments * Per-object buffer availability * Rename to MemoryView from Buffer and make compilable * Support integral repeat count in memory view format * Support 'x' for padding bytes * Add rb_memory_view_parse_item_format * Check type in rb_memory_view_register * Update dependencies in common.mk * Add test of MemoryView * Add test of rb_memory_view_init_as_byte_array * Add native size format test * Add MemoryView test utilities * Add test of rb_memory_view_fill_contiguous_strides * Skip spaces in format string * Support endianness specifiers * Update documentation * Support alignment * Use RUBY_ALIGNOF * Fix format parser to follow the pack format * Support the _ modifier * Parse count specifiers in get_format_size function. * Use STRUCT_ALIGNOF * Fix test * Fix test * Fix total size for the case with tail padding * Fix rb_memory_view_get_item_pointer * Fix rb_memory_view_parse_item_format again
* Standardised scheduler interface.Samuel Williams2020-09-141-0/+1
|
* If the GC runs before the Mutex's are initialised then we get a crash in ↵Matt Valentine-House2020-09-101-0/+1
| | | | | | pthread_mutex_lock. It is possible for GC to run during initialisation due to objects being allocated
* Introduce Ractor mechanism for parallel executionKoichi Sasada2020-09-031-0/+2
| | | | | | | | | | | | | | | | This commit introduces Ractor mechanism to run Ruby program in parallel. See doc/ractor.md for more details about Ractor. See ticket [Feature #17100] to see the implementation details and discussions. [Feature #17100] This commit does not complete the implementation. You can find many bugs on using Ractor. Also the specification will be changed so that this feature is experimental. You will see a warning when you make the first Ractor with `Ractor.new`. I hope this feature can help programmers from thread-safety issues.
* Make Integer#zero? a separated method and builtin (#3226)Takashi Kokubun2020-06-201-0/+1
| | | | | | | A prerequisite to fix https://bugs.ruby-lang.org/issues/15589 with JIT. This commit alone doesn't make a significant difference yet, but I thought this commit should be committed independently. This method override was discussed in [Misc #16961].
* Defer initializationNobuyoshi Nakada2020-05-161-0/+4
| | | | | Defer initialization of extension libraries, loading prelude files and requiring files, and skip if dump options are given.
* Moved `Dir.open` and `Dir#initialize` to dir.rbNobuyoshi Nakada2020-04-061-0/+1
|
* support builtin for Kernel#cloneS.H2020-03-171-0/+1
|
* Moved Array#shuffle and Array#shuffle! to rbincNobuyoshi Nakada2020-01-261-0/+1
|
* Remove special handling of $SAFE and related C-APIsJeremy Evans2020-01-221-1/+0
| | | | These were all deprecated in Ruby 2.7.
* Separate builtin initialization callsNobuyoshi Nakada2019-12-291-7/+13
|
* decouple internal.h headers卜部昌平2019-12-261-1/+2
| | | | | | | | | | | | | | | | | | Saves comitters' daily life by avoid #include-ing everything from internal.h to make each file do so instead. This would significantly speed up incremental builds. We take the following inclusion order in this changeset: 1. "ruby/config.h", where _GNU_SOURCE is defined (must be the very first thing among everything). 2. RUBY_EXTCONF_H if any. 3. Standard C headers, sorted alphabetically. 4. Other system headers, maybe guarded by #ifdef 5. Everything else, sorted alphabetically. Exceptions are those win32-related headers, which tend not be self- containing (headers have inclusion order dependencies).
* Moved Kernel#warn to warning.rbNobuyoshi Nakada2019-12-131-0/+1
|
* load prelude.rb by builtin features.Koichi Sasada2019-11-151-0/+4
| | | | | | | | | The script in prelude.rb was embed in MRI to load it (eval this script at everyboot). This commit change the loading process of prelude.rb. MRI doesn't eval a script, but load from compiled binary with builtin feature. So that Init_prelude() does not load `prelude.rb` now.
* Rubified the APIs of pack.cYusuke Endoh2019-11-081-1/+1
|
* use builtins for GC.Koichi Sasada2019-11-081-1/+1
| | | | Define a part of GC in gc.rb.
* Define IO#read/write_nonblock with builtins.Koichi Sasada2019-11-081-0/+1
| | | | | | | IO#read/write_nonblock methods are defined in prelude.rb with special private method __read/write_nonblock to reduce keyword parameters overhead. We can move them into io.rb with builtin functions.
* use builtin for RubyVM::AbstractSyntaxTree.Koichi Sasada2019-11-081-1/+1
| | | | | Define RubyVM::AbstractSyntaxTree in ast.rb with __builtin functions.
* use builtin for TracePoint.Koichi Sasada2019-11-081-1/+2
| | | | Define TracePoint in trace_point.rb and use __builtin_ syntax.
* support builtin features with Ruby and C.Koichi Sasada2019-11-081-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Support loading builtin features written in Ruby, which implement with C builtin functions. [Feature #16254] Several features: (1) Load .rb file at boottime with native binary. Now, prelude.rb is loaded at boottime. However, this file is contained into the interpreter as a text format and we need to compile it. This patch contains a feature to load from binary format. (2) __builtin_func() in Ruby call func() written in C. In Ruby file, we can write `__builtin_func()` like method call. However this is not a method call, but special syntax to call a function `func()` written in C. C functions should be defined in a file (same compile unit) which load this .rb file. Functions (`func` in above example) should be defined with (a) 1st parameter: rb_execution_context_t *ec (b) rest parameters (0 to 15). (c) VALUE return type. This is very similar requirements for functions used by rb_define_method(), however `rb_execution_context_t *ec` is new requirement. (3) automatic C code generation from .rb files. tool/mk_builtin_loader.rb creates a C code to load .rb files needed by miniruby and ruby command. This script is run by BASERUBY, so *.rb should be written in BASERUBY compatbile syntax. This script load a .rb file and find all of __builtin_ prefix method calls, and generate a part of C code to export functions. tool/mk_builtin_binary.rb creates a C code which contains binary compiled Ruby files needed by ruby command.
* Explicitly initialise encodings on init to remove branches on encoding lookupLourens Naudé2019-07-231-0/+1
| | | | | | [Misc #15806] Closes: https://github.com/ruby/ruby/pull/2128
* Defer setting gc_stress until inits doneNobuyoshi Nakada2019-04-241-0/+1
| | | | [Bug #15784]
* initialize VM postponed_job first. [Bug #15288]ko12018-11-081-0/+1
| | | | | | | | * inits.c: call `Init_vm_postponed_job` first because postponed_job is used by transient heap. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65628 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* introduce USE_TRANSIENT_HEAP to enable/disable theap.ko12018-11-011-0/+2
| | | | | | | | * include/ruby/ruby.h: intrdocue `USE_TRANSIENT_HEAP` macro to enable/disable transient heap. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* introduce TransientHeap. [Bug #14858]ko12018-10-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * transient_heap.c, transient_heap.h: implement TransientHeap (theap). theap is designed for Ruby's object system. theap is like Eden heap on generational GC terminology. theap allocation is very fast because it only needs to bump up pointer and deallocation is also fast because we don't do anything. However we need to evacuate (Copy GC terminology) if theap memory is long-lived. Evacuation logic is needed for each type. See [Bug #14858] for details. * array.c: Now, theap for T_ARRAY is supported. ary_heap_alloc() tries to allocate memory area from theap. If this trial sccesses, this array has theap ptr and RARRAY_TRANSIENT_FLAG is turned on. We don't need to free theap ptr. * ruby.h: RARRAY_CONST_PTR() returns malloc'ed memory area. It menas that if ary is allocated at theap, force evacuation to malloc'ed memory. It makes programs slow, but very compatible with current code because theap memory can be evacuated (theap memory will be recycled). If you want to get transient heap ptr, use RARRAY_CONST_PTR_TRANSIENT() instead of RARRAY_CONST_PTR(). If you can't understand when evacuation will occur, use RARRAY_CONST_PTR(). (re-commit of r65444) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65449 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* revert r65444 and r65446 because of commit missko12018-10-301-1/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* introduce TransientHeap. [Bug #14858]ko12018-10-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * transient_heap.c, transient_heap.h: implement TransientHeap (theap). theap is designed for Ruby's object system. theap is like Eden heap on generational GC terminology. theap allocation is very fast because it only needs to bump up pointer and deallocation is also fast because we don't do anything. However we need to evacuate (Copy GC terminology) if theap memory is long-lived. Evacuation logic is needed for each type. See [Bug #14858] for details. * array.c: Now, theap for T_ARRAY is supported. ary_heap_alloc() tries to allocate memory area from theap. If this trial sccesses, this array has theap ptr and RARRAY_TRANSIENT_FLAG is turned on. We don't need to free theap ptr. * ruby.h: RARRAY_CONST_PTR() returns malloc'ed memory area. It menas that if ary is allocated at theap, force evacuation to malloc'ed memory. It makes programs slow, but very compatible with current code because theap memory can be evacuated (theap memory will be recycled). If you want to get transient heap ptr, use RARRAY_CONST_PTR_TRANSIENT() instead of RARRAY_CONST_PTR(). If you can't understand when evacuation will occur, use RARRAY_CONST_PTR(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65444 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* add new instruction attribute called leafshyouhei2018-09-111-0/+1
| | | | | | | | | | | An instruction is leaf if it has no rb_funcall inside. In order to check this property, we introduce stack canary which is a random number collected at runtime. Stack top is always filled with this number and checked for stack smashing operations, when VM_CHECK_MODE. [GH-1947] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Define AST module under RubyVM [experimental]yui-knk2018-05-311-0/+1
| | | | | | | | | | | * ext/-test-/ast/ast.c: Rename to ast.c and define AST module under RubyVM. * common.mk: compile ast.c. * ext/-test-/ast/extconf.rb: Don't need this file anymore. * inits.c (rb_call_inits): Call Init_ast to setup AST module. * test/-ext-/ast/test_ast.rb: Follow up the namespace change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Revert "Improve performance of creating Hash object"watson19782017-12-191-1/+0
| | | | | | | | | This reverts commit r61309 Because it was unstable on mswin CI. [ruby-dev:50370][Bug #14203] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61341 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Improve performance of creating Hash objectwatson19782017-12-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When generate Hash object, the heap area of st_table will be always allocated in internally and seems it take a time. To improve performance of creating Hash object, this patch will reduce count of allocating heap areas for st_table by reuse them. Performance of creating Hash literal -> 1.53 times faster. [Fix GH-1766] [ruby-core:84008] [Feature #14146] ### Environment * OS : macOS 10.13.1 * CPU : 1.4 GHz Intel Core i7 * Compiler : Apple LLVM version 9.0.0 (clang-900.0.39) ### Before $ ./miniruby -v -I. -I../benchmark-ips/lib ~/tmp/bench/literal.rb ruby 2.5.0dev (2017-11-28 hash 60926) [x86_64-darwin17] Warming up -------------------------------------- Hash literal 51.544k i/100ms Calculating ------------------------------------- Hash literal 869.132k (± 1.1%) i/s - 4.381M in 5.041574s ### After $ ./miniruby -v -I. -I../benchmark-ips/lib ~/tmp/bench/literal.rb ruby 2.5.0dev (2017-11-28 hash 60926) [x86_64-darwin17] Warming up -------------------------------------- Hash literal 63.068k i/100ms Calculating ------------------------------------- Hash literal 1.328M (± 2.3%) i/s - 6.685M in 5.037861s ### Test code require 'benchmark/ips' Benchmark.ips do |x| x.report "Hash literal" do |loop| count = 0 while count < loop hash = {foo: 12, bar: 34, baz: 56} count += 1 end end end git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (InitVM_Random): move Random::DEFAULT initializationkosaki2015-11-301-1/+1
| | | | | | | | bits to Init_Random_default. * random.c (Init_Random_default): renamed from Init_Rndom2. * random.c (Init_RandomSeedCore): renamed from Init_Random. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52816 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h: Include ruby.h and ruby/encoding.h to beakr2014-11-151-1/+0
| | | | | | | | includable without prior inclusion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_method.c: configurable global method cache sizenobu2014-09-181-0/+1
| | | | | | | | * vm_method.c (Init_Method): make global method cache size configurable by environment variable "RUBY_GLOBAL_METHOD_CACHE_SIZE" [Fix GH-719] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Process.detach: avoid singleton class creationnormal2014-09-121-1/+1
| | | | | | | | | | | | | | | * process.c (Init_process): subclass Thread as Process::Waiter (rb_detach_process): use Process::Waiter instead of singleton class * test/ruby/test_process.rb (test_process_detach): new test * inits.c (rb_call_inits): call Init_Thread before Init_process to ensure Process::Waiter may be a subclass of Thread Thanks to headius for reporting [Bug #10231] Thanks to nobu for review of my initial patch. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47561 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/rbconfig/sizeof: move to an extension librarynobu2013-11-181-1/+0
| | | | | | | | | | | | * common.mk, ext/rbconfig/sizeof: move RbConfig::SIZEOF to an extension library to get rid of annoying nmake VPATH rule. * inits.c (rb_call_inits), miniinit.c (Init_sizes): RbConfig::SIZEOF is no loger built-in. * template/sizes.c.tmpl (Init_sizeof): rename initialization function. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43708 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* sizes.c: RbConfig::SIZEOFnobu2013-07-291-0/+1
| | | | | | * sizes.c (Init_sizes): define RbConfig::SIZEOF. [Feature #8568] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42244 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm_trace.c: separate trace_func related functions fromko12012-08-151-0/+1
| | | | | | | | | | | thread.c. * thread.c: ditto. * common.mk: add vm_trace.o. * inits.c: call Init_vm_trace(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h: declare internal functions here.akr2011-06-171-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | * node.h: declare NODE dependent internal functions here. * iseq.h: declare rb_iseq_t dependent internal functions here. * vm_core.h: declare rb_thread_t dependent internal functions here. * bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c, enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c, iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y, proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c, thread.c, time.c, transcode.c, variable.c, vm.c, tool/compile_prelude.rb: don't declare internal functions declared in above headers. include above headers if required. Note that rb_thread_mark() was declared as void rb_thread_mark(rb_thread_t *th) in cont.c but defined as void rb_thread_mark(void *ptr) in vm.c. Now it is declared as the later in internal.h. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * inits.c (rb_call_inits): do not repeat.nobu2008-11-071-87/+46
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20135 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * eval_safe.c, safe.c: rename eval_safe.c to safe.c.ko12008-09-231-0/+2
| | | | | | | | | * common.mk, eval.c, safe.c, inits.c: separate safe.c from eval.c and make Init_safe(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19467 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * prec.c: removed. Precision will be redesigned and be back again.yugui2008-09-191-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | c.f. [ruby-dev:36352]. * common.mk (COMMON_OBJS): removed prec.o. * inits.c (rb_call_inits): removed Init_Precision. * numeric.c (Init_Numeric): removed inclusion of Precision. removed #induced_from from each class. * rational.c: ditto. * ext/bigdecimal/bigdecimal.c: ditto. * lib/rdoc/knwon_classes.rb: removed the entry for Precision. * test/ruby/test_prec.rb: removed. * test/ruby/test_integer.rb: removed tests for Precision. * test/ruby/test_fixnum.rb: ditto. * test/ruby/test_float.rb: ditto. * test/ruby/test_rational.rb: ditto. * test/ruby/test_complex.rb: ditto. * test/bigdecimal/test_bigdecimal.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/encoding.h (rb_enc_ispunct): added.nobu2008-08-141-2/+0
| | | | | | | | | | | | | | | * common.mk (COMMONOBJS), inits.c (rb_call_inits): id.c is now included from parse.c. * id.c (Init_id), id.h (ruby_method_ids): added IDs used by VM. * parse.y (global_symbols): added rooms for VM IDs. * parse.y (rb_intern3, rb_id2str): single puctuation symbol is now same as char code. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_memhash): randomize hash to avoid algorithmicakr2008-06-201-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | complexity attacks. (rb_str_hash): use rb_memhash. * include/ruby/intern.h (rb_reset_random_seed): declared. * thread.c (rb_thread_atfork): call rb_reset_random_seed. * inits.c (rb_call_inits): call Init_RandomSeed at first. * random.c (seed_initialized): defined. (fill_random_seed): extracted from random_seed. (make_seed_value): extracted from random_seed. (rb_f_rand): initialize random seed at first. (initial_seed): defined. (Init_RandomSeed): defined. (Init_RandomSeed2): defined. (rb_reset_random_seed): defined. (Init_Random): call Init_RandomSeed2. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17465 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* both complex and rational are now builtin classes.tadf2008-03-161-0/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * $Date$ keyword removed to avoid inclusion of locale dependentakr2008-01-061-1/+0
| | | | | | | string. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * transcode.c: new file to provide encoding conversion features.matz2007-12-101-0/+2
| | | | | | code contributed by Martin Duerst. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14172 b2dd03c8-39d4-4d8f-98ff-823fe69b080e