summaryrefslogtreecommitdiff
path: root/load.c
AgeCommit message (Collapse)Author
2013-05-23load.c: fix invalid readnobu
* load.c (loaded_feature_path): fix invalid read by index underflow. the beginning of name is also a boundary as well as just after '/'. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40900 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13* *.c, parse.y, insns.def: use RARRAY_AREF/ASET macroko1
instead of using RARRAY_PTR(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-05* load.c (features_index_add): use rb_str_subseq() to specify C stringshirosaki
position properly to fix require non ascii path. [ruby-core:53733] [Bug #8165] * test/ruby/test_require.rb (TestRequire#test_require_nonascii_path): a test for the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40135 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-24load.c: no longer used variable and objectnobu
* load.c (rb_feature_p): remvoe variable and string object which are no longer used since r39874. [Bug #8048] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39898 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-22load.c: loaded_features_index st_tablenobu
* load.c (rb_feature_p), vm_core.h (rb_vm_struct): turn loaded_features_index into st_table. patches by tmm1 (Aman Gupta) in [ruby-core:53251] and [ruby-core:53274] [Bug #8048] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-09fix commit missnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39647 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-09load.c: hide internal objectsnobu
* load.c (rb_construct_expanded_load_path, Init_load): hide internal objects, expanded_load_path, {load_path,loaded_features}_snapshot, and loaded_features_index in the VM, and ruby_dln_librefs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39646 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-08load.c: move loop invariant conditionnobu
* load.c (rb_feature_p): move this_feature_index condition which is loop invariant. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39645 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-08load.c: reduce indexes arraysnobu
* load.c (features_index_add_single, rb_feature_p): store single index as Fixnum to reduce the number of arrays for the indexes. based on the patch by tmm1 (Aman Gupta) in [ruby-core:53216] [Bug #8048]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39644 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-08load.c: reorder conditionsnobu
* load.c (loaded_feature_path): reorder conditions so simple comparision comes first. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-10* probes.d: updating probes to be more symmetrical, addingtenderlove
documentation. * load.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-09* load.c (load_lock): if thread shield is destroyed and there is noglass
waiting thread, insert new thread shield into load_table. [Bug #7530] [ruby-core:50645] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38750 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-09* load.c (load_lock): revert r38744. it should acquire new threadglass
shield. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38749 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-09* load.c (load_lock): fix not to delete thread shield twice.glass
it may break the shield locked by another thread. [Bug #7530] [ruby-core:50645] * test/ruby/test_require.rb: a test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38744 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-25error.c: rb_write_error_strnobu
* error.c (compile_err_append, compile_warn_print, warn_print): use rb_write_error_str() instead of writing to rb_stderr directly. * io.c (rb_write_error_str): a stopgap measure not to unblock GVL. warning from require seems to still have race condition errors. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38590 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-18* vm.c (rb_vm_jump_tag_but_local_jump): remove unnessesary 2ndnagachika
argument. * load.c (rb_load_internal): ditto. * eval_intern.h (rb_vm_jump_tag_but_local_jump): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38452 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-01adjust style.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-12* probes.d: add DTrace probe declarations. [ruby-core:27448]tenderlove
* array.c (empty_ary_alloc, ary_new): added array create DTrace probe. * compile.c (rb_insns_name): allowing DTrace probes to access instruction sequence name. * Makefile.in: translate probes.d file to appropriate header file. * common.mk: declare dependencies on the DTrace header. * configure.in: add a test for existence of DTrace. * eval.c (setup_exception): add a probe for when an exception is raised. * gc.c: Add DTrace probes for mark begin and end, and sweep begin and end. * hash.c (empty_hash_alloc): Add a probe for hash allocation. * insns.def: Add probes for function entry and return. * internal.h: function declaration for compile.c change. * load.c (rb_f_load): add probes for `load` entry and exit, require entry and exit, and wrapping search_required for load path search. * object.c (rb_obj_alloc): added a probe for general object creation. * parse.y (yycompile0): added a probe around parse and compile phase. * string.c (empty_str_alloc, str_new): DTrace probes for string allocation. * test/dtrace/*: tests for DTrace probes. * vm.c (vm_invoke_proc): add probes for function return on exception raise, hash create, and instruction sequence execution. * vm_core.h: add probe declarations for function entry and exit. * vm_dump.c: add probes header file. * vm_eval.c (vm_call0_cfunc, vm_call0_cfunc_with_frame): add probe on function entry and return. * vm_exec.c: expose instruction number to instruction name function. * vm_insnshelper.c: add function entry and exit probes for cfunc methods. * vm_insnhelper.h: vm usage information is always collected, so uncomment the functions. 12 19:14:50 2012 Akinori MUSHA <knu@iDaemons.org> * configure.in (isinf, isnan): isinf() and isnan() are macros on DragonFly which cannot be found by AC_REPLACE_FUNCS(). This workaround enforces the fact that they exist on DragonFly. 12 15:59:38 2012 Shugo Maeda <shugo@ruby-lang.org> * vm_core.h (rb_call_info_t::refinements), compile.c (new_callinfo), vm_insnhelper.c (vm_search_method): revert r37616 because it's too slow. [ruby-dev:46477] * test/ruby/test_refinement.rb (test_inline_method_cache): skip the test until the bug is fixed efficiently. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06Fix typos in commentsshirosaki
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37529 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-05Fix compatibility of cached expanded load pathshirosaki
* file.c (rb_get_path_check_to_string): extract from rb_get_path_check(). We change the spec not to call to_path of String object. * file.c (rb_get_path_check_convert): extract from rb_get_path_check(). * file.c (rb_get_path_check): follow the above change. * file.c (rb_file_expand_path_fast): remove check_expand_path_args(). Instead we call it in load.c. * file.c (rb_find_file_ext_safe): use rb_get_expanded_load_path() to reduce expand cost. * file.c (rb_find_file_safe): ditto. * internal.h (rb_get_expanded_load_path): add a declaration. * internal.h (rb_get_path_check_to_string, rb_get_path_check_convert): add declarations. * load.c (rb_construct_expanded_load_path): fix for compatibility. Same checks in rb_get_path_check() are added. We don't replace $LOAD_PATH and ensure that String object of $LOAD_PATH are frozen. We don't freeze non String object and expand it every times. We add arguments for expanding load path partially and checking if load path have relative paths or non String objects. * load.c (load_path_getcwd): get current working directory for checking if it's changed when getting load path. * load.c (rb_get_expanded_load_path): fix for rebuilding cache properly. We check if current working directory is changed and rebuild expanded load path cache. We expand paths which start with ~ (User HOME) and non String objects every times for compatibility. We make this accessible from other source files. * load.c (rb_feature_provided): call rb_get_path() since we changed rb_file_expand_path_fast() not to call it. * load.c (Init_load): initialize vm->load_path_check_cache. * vm.c (rb_vm_mark): mark vm->load_path_check_cache for GC. * vm_core.h (rb_vm_struct): add vm->load_path_check_cache to store data to check load path cache validity. * test/ruby/test_require.rb (TestRequire): add tests for require compatibility related to cached expanded load path. [ruby-core:47970] [Bug #7158] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37482 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-05Cache the expanded load pathshirosaki
* load.c (rb_get_expanded_load_path): cache the expanded load path. This saves 4KB of allocation and some stats for every element of the load path (so nearly a MB in my Rails app) on every require. * load.c (rb_construct_expanded_load_path): ensure that $LOAD_PATH entries are frozen strings. The user must mutate $LOAD_PATH itself rather than its individual entries. * vm_core.h (rb_vm_struct): add fields. * vm.c (rb_vm_mark): mark new fields. * ruby.c (process_options): modify $LOAD_PATH directly rather than its elements. Patch by Greg Price. [ruby-core:47970] [Bug #7158] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37481 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-05Index $LOADED_FEATURES so that require isn't so slowshirosaki
* load.c (rb_feature_p, rb_provide_feature): index $LOADED_FEATURES so that require isn't so slow. * load.c (rb_provide_feature, get_loaded_features_index): ensure that $LOADED_FEATURES entries are frozen strings. The user must mutate $LOADED_FEATURES itself rather than its individual entries. * load.c (reset_loaded_features_snapshot): add a new function to reset vm->loaded_features_snapshot. * load.c (get_loaded_features_index_raw): add a new function to get the loaded-features index. * load.c (features_index_add_single): add a new function to add to the loaded-features index a single feature. * load.c (features_index_add): add a new function to add to the loaded-features index all the required entries for `feature`. * vm_core.h (rb_vm_struct): add fields. * vm.c (rb_vm_mark): mark new fields. * include/ruby/intern.h (rb_hash_clear): declare function. * hash.c (rb_hash_clear): make function non-static. Patch by Greg Price. [ruby-core:47970] [Bug #7158] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-05Expose whether two arrays are sharedshirosaki
* array.c (rb_ary_shared_with_p): new function. Expose whether two arrays are shared (read-only, C only). * include/ruby/intern.h (rb_ary_shared_with_p): declare. Patch by Greg Price. [ruby-core:47970] [Bug #7158] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37478 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-05Clarify and explain loaded_feature_path and rb_feature_pshirosaki
* load.c (loaded_feature_path): clarify and briefly comment function. These clarifications have no effect on the behavior of the function. * load.c (rb_feature_p): explain the search loop. Especially useful because the logic is complicated as described in the second paragraph. Patch by Greg Price. [ruby-core:47970] [Bug #7158] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37477 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-29load.c: adjust stylenobu
* load.c (loaded_feature_path): adjust style. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-24Improve require/File.expand_path performance on Windowsluislavena
* configure.in (mingw): add shlwapi to the list of dependency libs for Windows. * win32/Makefile.sub (EXTSOLIBS): ditto. * internal.h: declare internal functions rb_w32_init_file, rb_file_expand_path_internal and rb_file_expand_path_fast. * file.c (Init_File): invoke Windows initialization rb_w32_init_file * win32/file.c (rb_file_load_path_internal): new function. Windows-specific implementation that replaces file_expand_path. [Bug #6836][ruby-core:46996] * win32/file.c (rb_w32_init_file): new function. Initialize codepage cache for faster conversion encodings lookup. * file.c (file_expand_path): rename to rb_file_expand_path_internal. Conditionally exclude from Windows. * file.c (rb_file_expand_path_fast): new function. delegates to rb_file_expand_path_internal without performing a hit to the filesystem. * file.c (file_expand_path_1): use rb_file_expand_path_internal without path expansion (used by require). * file.c (rb_find_file_ext_safe): ditto. * file.c (rb_find_file_safe): ditto. * load.c (rb_get_expanded_load_path): use rb_file_expand_path_fast. * load.c (rb_feature_provided): ditto. * file.c (rb_file_expand_path): use rb_file_expand_path_internal with path expansion. * file.c (rb_file_absolute_path): ditto. * test/ruby/test_file_exhaustive.rb: new tests to exercise rb_file_expand_path_internal implementation and compliance with existing behaviors. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-23load.c: keep encoding of feature namenobu
* file.c (rb_find_file_ext_safe, rb_find_file_safe): default to US-ASCII for encdb and transdb. * load.c (search_required): keep encoding of feature name. set loading path to filesystem encoding. [Bug #6377][ruby-core:44750] * ruby.c (add_modules, require_libraries): assume default external encoding as well as ARGV. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36800 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-05ThreadShieldnobu
* thread.c (ThreadShield): rename from Barrier. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36320 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-11* thread.c (rb_threadptr_execute_interrupts_common):naruse
test_signal_requiring of test/ruby/test_signal.rb fail if the sub process is killed on waiting IO in lex_io_gets in rb_load_file in rb_load_internal in require. This is because (1) the process receive the killing signal in rb_thread_io_blocking_region in rb_read_internal in lex_io_gets. (2) set th->errinfo as INT2FIX(TAG_FATAL) at rb_threadptr_execute_interrupts_common. (3) escape rb_load_file in rb_load_internal and jump to EXEC_TAG() without set loaded as TRUE. (4) call first rb_exc_raise(GET_THREAD()->errinfo); because loaded is FALSE as above. this errinfo should be an exception object but this is INT2FIX(TAG_FATAL). Don't call first rb_exc_raise if GET_THREAD()->errinfo is Fixnum. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35625 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-29* st.c (st_update): pass pointer to key to the callback function.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35172 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-29* st.c (st_update): add existing parameter to the callback function.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35170 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-16* load.c (ruby_init_ext): don't free the given pointer itself.yugui
It is not guaranteed even that the pointer is on heap. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-07* error.c (rb_load_fail): should honor encoding.nobu
* load.c (load_failed): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34944 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-07* load.c (load_failed): no need to guard fname, it's stored in the exception ↵nobu
to be raised. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-06* error.c (rb_loaderror_with_path): Adding the missing file as antenderlove
instance variable to the LoadError exception. * load.c: call rb_loaderror_with_path so that the missing path is added to the exception. * ruby.c: call rb_loaderror rather than raising our own LoadError exception. * include/ruby/intern.h: add declaration for rb_loaderror_with_path. * test/ruby/test_require.rb: add supporting test for LoadError#path method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-23* load.c (rb_f_require): Add note to require for scope of items in thedrbrain
loaded file. [ruby-trunk - #5910] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34758 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-13* load.c (load_unlock): update loading table at once.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34292 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-14* load.c (load_unlock): release loading barrier and then remove itnobu
from loading_table if it is not in-use. [Bug #5754] * thread.c (rb_barrier_release, rb_barrier_destroy): return whether any other threads are waiting on it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34039 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-14* load.c (load_lock): delete the loading barrier if it has beennobu
destroyed. * thread.c (rb_barrier_wait): return nil for recursive lock instead of false, to distinguish it from destroyed barrier. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34036 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-13* load.c (load_unlock): all threads requiring one file shouldnobu
share same loading barrier, so it must be kept alive while those are waiting on it. [ruby-core:41618] [Bug #5754] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-12* load.c (rb_feature_p): lazy assigned load_path searched innobu
loading_table were not expanded, but all features, pushed to loading table, are expanded. a patch by Yura Sokolov <funny.falcon AT gmail.com> in [ruby-core:41545]. [Bug #5727] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-23* load.c (rb_f_require): Improve documentation of Kernel#require.drbrain
[Ruby 1.9 - Bug #5210] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-26* eval_error.c (rb_print_undef_str): new function to raisenobu
NameError for undefined method. * load.c (rb_mod_autoload_p), object.c (rb_mod_const_get), variable.c (rb_f_untrace_var, set_const_visibility), vm_method.c (rb_mod_{remove,undef,alias}_method, set_method_visibility): remove inadvertent symbol creation. based on the first patch by Jeremy Evans at [ruby-core:38447]. [Feature #5089] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-10* load.c (rb_f_autoload): prevent to autoload for singletonmrkn
classes. fixes [Bug #4886] [ruby-dev:43816] * bootstraptest/test_autoload.rb: add tests for the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32489 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-18* eval.c, hash.c, load.c, proc.c, range.c, thread.c, time.c: don'takr
declare internal functions. * internal.h, vm_core.h: declare internal functions. * array.c: include internal.h. * common.mk: update dependency for array.o. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17* internal.h: declare internal functions here.akr
* 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
2011-05-31 * load.c (loaded_feature_path): cut nonsence loop execution to fixtarui
performance bug. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31875 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-22* include/ruby/defines.h (CASEFOLD_FILESYSTEM): Revert r30508. See #4255.nahi
Now __APPLE__ is not CASEFOLD_FILESYSTEM again. * load.c (loaded_feature_path, rb_feature_p, load_lock): Revert r30508. See #4255. Make $LOADED_FEATURES scanning case-sensitive again. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31692 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-02-05* load.c (rb_get_expanded_load_path): always expand load paths.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-01-10* include/ruby/defines.h (CASEFOLD_FILESYSTEM): HFS+ is casenobu
insensitive. * load.c (loaded_feature_path, rb_feature_p, load_lock): on a case-insensitive filesystem, loaded features search should ignore case. [ruby-core:34297] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30508 b2dd03c8-39d4-4d8f-98ff-823fe69b080e