summaryrefslogtreecommitdiff
path: root/ruby.c
AgeCommit message (Collapse)Author
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-24ruby.c: fix r60393nobu
* ruby.c (load_file_internal): set loop options after parsing shebang line. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60396 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-24parse.y: rb_parser_set_optionsnobu
* parse.y (yycompile0): append top-level addenda before appending prelude nodes. * parse.y (rb_parser_set_options): set top-level addendum options before parsing. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60393 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21The encoding of __FILE__ and __dir__ should be sameusa
* ruby.c (process_options): convert the real path of the script to locale encoding if its encoding is not locale (maybe UTF-8) on Windows/OS X. this change makes the encoding of __dir__ to the same encoding of __FILE__ when the script name is passed from commandline. * test/ruby/test_options.rb (test___dir__encoding): test for this change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60300 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-19ruby.c: reject NUL in $0nobu
* ruby.c (ruby_setproctitle): raise if the argument contains NUL char. process title is a NUL-terminated string. [ruby-core:82425] [Bug #13829] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60215 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-20ruby.c: show help messages of --dumpsonots
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59973 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-20ruby.c: paragraph mode by -00nobu
* ruby.c (proc_options): set to paragraph mode, if -00 is given, as well as perl and -R0 option in 0.49. [ruby-core:81987] [Bug #13736] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-10ruby.c: ignore non-option in shebang linenobu
* ruby.c (moreswitches): process all words as options only in an environment variable, but not in a shebang line. [ruby-core:82267] [Bug #13786] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-09ruby.c: origargnobu
* ruby.c (dladdr_path, ruby_set_argv): add guards for origarg. [ruby-core:82272] [Bug #13788] * ruby.c (proc_options, process_options, ruby_process_options): set origarg if not set yet. * ruby.c (process_options): prefer argv in the argument to origarg as program name. * ruby.c (ruby_sysinit): set origarg only if argc and argv seem valid. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-21RUBY_DEVEL flagnobu
* configure.in: define RUBY_DEVEL only in the trunk. * gc.c: enable runtime rgengc debug if RUBY_DEVEL * ruby.c (debug_option): enable RUBY_DEBUG in --debug option only if RUBY_DEVEL. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59131 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-21ruby.c: debug options in command linenobu
* ruby.c (debug_option): parse options in --debug command line option same as RUBY_DEBUG env. available only in the trunk. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59129 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-08ruby.c: script name in UTF-8nobu
* ruby.c (process_options): keep script name in UTF-8 if UTF8_PATH to get rid of loss by conversion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-03ruby.c: dladdr_path is not used on cygwinnobu
* ruby.c (dladdr_path): dladdr is provided on recent cygwin, but GetModuleFileNameW is used instead of it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-01improve English for a warning messageduerst
On DOSish systems, there is a warning message for \r\n line endings on shebang line. Improve this message from "shebang line ends with \r may cause a problem" to "shebang line ending with \r may cause problems". git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58981 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-28ruby.c: file in load_file argumentnobu
* ruby.c (load_file): move opened file to an argument, to reduce open/close calls in the near future. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-28ruby.c: shrink ruby_cmdline_options_tnobu
* ruby.c (ruby_cmdline_options_t): reordered members and turned simple flags into bit fields to reduce the size (136->104 on LP64). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58937 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-17ruby.c: encode script namenobu
* ruby.c (process_options): encode script name to locale encoding instead of associate, if UTF-8 path. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58767 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-31ruby.c: defining DATAnobu
* ruby.c (load_file_internal): define DATA here instead of ensure func. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-31ruby.c: forbid optionsnobu
* ruby.c (forbid_setid): constified. * ruby.c (process_options): forbid if setid earlier. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57484 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-13declare `rb_w32_sysinit` in header.usa
* include/ruby/win32.h (rb_w32_sysinit): declare. [ruby-core:78444] [Bug #12994] * ruby.c (ruby_sysinit): follow above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57072 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-07ruby.c: dump optionnobu
* ruby.c (process_options): dump specified informations all, not only first one. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57017 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-21ruby.c: retry loading with GCnobu
* ruby.c (open_load_file): retry after GC when the limit for open file descriptors reached. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56463 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-12* ruby.c (open_load_file): revert r56385. it introduced incompatibilityusa
about `DATA.binmode?`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56401 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-12ruby.c: fix macrosnobu
* ruby.c (open_load_file): FILE_ALT_SEPARATOR and EXEEXT are config.status variables, not available in config.h. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56400 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-10ruby.c: bind fd before waitingnobu
* ruby.c (open_load_file): bind the open fd to an IO instance before waiting FIFO, not to leak the fd if interrupted. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56388 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-10ruby.c: compare with EXEEXTnobu
* ruby.c (open_load_file): compare with EXEEXT instead of hard coded name, and do not match with mere EXEEXT. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56386 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-10ruby.c: open in binary mode to loadnobu
* ruby.c (open_load_file): open in binary mode if available, as parser deals with EOLs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56385 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-19ruby_cmdline_options_tnobu
* ruby.c (ruby_cmdline_options_t): typedef. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55970 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-06-03ruby.c: refix r55260nobu
* ruby.c (process_options): rb_str_conv_enc() never set encoding of the source string, but returns the string itself if the conversion failed. then the instance variable does not need to be set again. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-06-03* ruby.c (process_options): need to duplicate path before passing it tousa
rb_str_conv_enc() because the function might call rb_enc_associate() internally. this fixes test failures on Windows introduced at r55260. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55267 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-06-02ruby.c: no MAXPATHLEN for loadpathnobu
* ruby.c (ruby_init_loadpath_safe): remove MAXPATHLEN restriction for Windows 10. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55260 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-26Fix -e script encodingnobu
* ruby.c (process_options): convert -e script to the encoding given by a command line option on Windows. assume it is the expected encoding. [ruby-dev:49461] [Bug #11900] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54785 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-24Revert r54742nobu
Commit miss. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54744 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-24Fix compile error other than gccnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54742 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-23ruby.c: fix command line encoding on cygwinnobu
* ruby.c: cygwin does not use w32_cmdvector, command line can be other than UTF-8. [ruby-dev:49519] [Bug #12184] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54720 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-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-14ruby.c: reduce fstatnobu
* file.c (ruby_is_fd_loadable): now return -1 if loadable but may block. * ruby.c (open_load_file): wait to read by the result of ruby_is_fd_loadable, without fstat. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-11Revert r54082 "ruby.c: load in binary mode"nobu
DATA is expected to be text mode, but there is no ways to make a FD to text mode from binary mode. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54084 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-11ruby.c: load in binary modenobu
* ruby.c (open_load_file): always open in binary mode if provided, parser deals with CRs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54082 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-08ruby.c: extra commanobu
* ruby.c (feature_option, debug_option, dump_option): remove an extra comma from option lists. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54033 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-07test_rubyoptions.rb: fix testnobu
* test/ruby/test_rubyoptions.rb (test_shebang): adjust only expected stderr as a warning, assertion has meaning on all platforms. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-07* ruby.c (warn_cr_in_shebang): meaningless check on DOSISH platforms.usa
fixed a test failure introduced at r53998. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54023 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-04ruby.c: warn_cr_in_shebangnobu
* ruby.c (load_file_internal): warn if shebang line ends with a carriage return. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53998 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-04ruby.c: simplifynobu
* ruby.c (load_file_internal): simplify by local variables instead of repeating RSTRING macros. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53995 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-04ruby.c: remove a magic numbernobu
* ruby.c (load_file_internal): remove a magic number, which means the length of ruby_engine but the value is unknown in this file since the variable is in a different file now. instead, strstr should deal with it well, as far as ruby_engine does not contain a space and a hyphen. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53993 b2dd03c8-39d4-4d8f-98ff-823fe69b080e