aboutsummaryrefslogtreecommitdiffstats
path: root/ruby.c
Commit message (Collapse)AuthorAgeFilesLines
* * node.h (ast_t): renamed to `rb_ast_t`.ko12017-10-291-5/+5
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Revert "Revert "Manage AST NODEs out of GC""mame2017-10-271-14/+21
| | | | | | | 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
* Revert "Manage AST NODEs out of GC"mame2017-10-271-21/+14
| | | | | | This reverts commit 620ba74778bfdbdc34ffbb142d49ce84a0ef58e9. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60486 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Manage AST NODEs out of GCmame2017-10-271-14/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* ruby.c: fix r60393nobu2017-10-241-1/+4
| | | | | | | * 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
* parse.y: rb_parser_set_optionsnobu2017-10-241-9/+4
| | | | | | | | | | * 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
* The encoding of __FILE__ and __dir__ should be sameusa2017-10-211-0/+5
| | | | | | | | | | | | * 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
* ruby.c: reject NUL in $0nobu2017-10-191-4/+10
| | | | | | | | * 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
* ruby.c: show help messages of --dumpsonots2017-09-201-6/+17
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59973 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ruby.c: paragraph mode by -00nobu2017-09-201-1/+1
| | | | | | | | * 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
* ruby.c: ignore non-option in shebang linenobu2017-08-101-3/+3
| | | | | | | | * 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
* ruby.c: origargnobu2017-08-091-15/+26
| | | | | | | | | | | | | | | | * 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
* RUBY_DEVEL flagnobu2017-06-211-0/+2
| | | | | | | | | | | * 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
* ruby.c: debug options in command linenobu2017-06-211-0/+4
| | | | | | | * 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
* ruby.c: script name in UTF-8nobu2017-06-081-6/+9
| | | | | | | * 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
* ruby.c: dladdr_path is not used on cygwinnobu2017-06-031-1/+1
| | | | | | | * 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
* improve English for a warning messageduerst2017-06-011-1/+1
| | | | | | | | 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
* ruby.c: file in load_file argumentnobu2017-05-281-14/+14
| | | | | | | * 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
* ruby.c: shrink ruby_cmdline_options_tnobu2017-05-281-9/+11
| | | | | | | | * 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
* ruby.c: encode script namenobu2017-05-171-8/+10
| | | | | | | * 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
* ruby.c: defining DATAnobu2017-01-311-20/+18
| | | | | | | * 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
* ruby.c: forbid optionsnobu2017-01-311-8/+6
| | | | | | | | * 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
* declare `rb_w32_sysinit` in header.usa2016-12-131-1/+0
| | | | | | | | | | * 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
* ruby.c: dump optionnobu2016-12-071-9/+19
| | | | | | | * 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
* ruby.c: retry loading with GCnobu2016-10-211-1/+7
| | | | | | | * 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
* * ruby.c (open_load_file): revert r56385. it introduced incompatibilityusa2016-10-121-9/+6
| | | | | | | about `DATA.binmode?`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56401 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ruby.c: fix macrosnobu2016-10-121-2/+2
| | | | | | | * 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
* ruby.c: bind fd before waitingnobu2016-10-101-13/+11
| | | | | | | * 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
* ruby.c: compare with EXEEXTnobu2016-10-101-3/+7
| | | | | | | * 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
* ruby.c: open in binary mode to loadnobu2016-10-101-6/+9
| | | | | | | * 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
* ruby_cmdline_options_tnobu2016-08-191-18/+20
| | | | | | * ruby.c (ruby_cmdline_options_t): typedef. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* rb_funcallvnobu2016-07-291-1/+1
| | | | | | | * *.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
* * vm_core.h: revisit the structure of frame, block and env.ko12016-07-281-7/+4
| | | | | | | | | | | | | | | | | | | | | | [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
* ruby.c: refix r55260nobu2016-06-031-1/+3
| | | | | | | | | * 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
* * ruby.c (process_options): need to duplicate path before passing it tousa2016-06-031-1/+1
| | | | | | | | 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
* ruby.c: no MAXPATHLEN for loadpathnobu2016-06-021-6/+35
| | | | | | | * 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
* Fix -e script encodingnobu2016-04-261-2/+19
| | | | | | | | * 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
* Revert r54742nobu2016-04-241-13/+3
| | | | | | Commit miss. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54744 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fix compile error other than gccnobu2016-04-241-3/+13
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54742 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ruby.c: fix command line encoding on cygwinnobu2016-04-231-0/+2
| | | | | | | * 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
* remove rb_thread_t::parse_in_evalnobu2016-03-281-31/+19
| | | | | | | | | | | | * 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
* SyntaxError message at iseq compilenobu2016-03-191-0/+8
| | | | | | | | | | | | * 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
* ruby.c: reduce fstatnobu2016-03-141-11/+4
| | | | | | | | | * 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
* Revert r54082 "ruby.c: load in binary mode"nobu2016-03-111-5/+2
| | | | | | | 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
* ruby.c: load in binary modenobu2016-03-111-2/+5
| | | | | | | * 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
* ruby.c: extra commanobu2016-03-081-20/+32
| | | | | | | * 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
* test_rubyoptions.rb: fix testnobu2016-03-071-4/+2
| | | | | | | | * 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
* * ruby.c (warn_cr_in_shebang): meaningless check on DOSISH platforms.usa2016-03-071-0/+6
| | | | | | | fixed a test failure introduced at r53998. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54023 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ruby.c: warn_cr_in_shebangnobu2016-03-041-0/+10
| | | | | | | * 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
* ruby.c: simplifynobu2016-03-041-9/+10
| | | | | | | * 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