Граф коммитов

555 Коммитов

Автор SHA1 Сообщение Дата
svn 708142cabd * expand tabs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-29 18:00:14 +00:00
ko1 d3edfdc7d9 use RARRAY_AREF() instead of RARRAY_CONST_PTR().
* class.c (rb_keyword_error_new): use RARRAY_AREF() because
  RARRAY_CONST_PTR() can introduce additional overhead in a futre.
  Same fixes for other files.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-29 18:00:02 +00:00
nobu 37279d1546 non-symbol keys in kwargs
* class.c (separate_symbol): [EXPERIMENTAL] non-symbol key in keyword
  arguments hash causes an exception now.
  c.f. https://twitter.com/yukihiro_matz/status/1022287578995646464

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64358 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-14 11:58:17 +00:00
mame ffb09d8e87 eval.c: rename "rb_frozen_class_p" to "rb_class_modify_check"
Just refactoring.  Despite its name, the function does NOT return a
boolean but raises an exception when the class given is frozen.
I don't think the new name "rb_class_modify_check" is the best, but
it follows the precedeint "rb_ary_modify_check", and is definitely
better than "*_p".

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-27 13:57:14 +00:00
k0kubun ed935aa5be mjit_compile.c: merge initial JIT compiler
which has been developed by Takashi Kokubun <takashikkbn@gmail> as
YARV-MJIT. Many of its bugs are fixed by wanabe <s.wanabe@gmail.com>.

This JIT compiler is designed to be a safe migration path to introduce
JIT compiler to MRI. So this commit does not include any bytecode
changes or dynamic instruction modifications, which are done in original
MJIT.

This commit even strips off some aggressive optimizations from
YARV-MJIT, and thus it's slower than YARV-MJIT too. But it's still
fairly faster than Ruby 2.5 in some benchmarks (attached below).

Note that this JIT compiler passes `make test`, `make test-all`, `make
test-spec` without JIT, and even with JIT. Not only it's perfectly safe
with JIT disabled because it does not replace VM instructions unlike
MJIT, but also with JIT enabled it stably runs Ruby applications
including Rails applications.

I'm expecting this version as just "initial" JIT compiler. I have many
optimization ideas which are skipped for initial merging, and you may
easily replace this JIT compiler with a faster one by just replacing
mjit_compile.c. `mjit_compile` interface is designed for the purpose.

common.mk: update dependencies for mjit_compile.c.

internal.h: declare `rb_vm_insn_addr2insn` for MJIT.

vm.c: exclude some definitions if `-DMJIT_HEADER` is provided to
compiler. This avoids to include some functions which take a long time
to compile, e.g. vm_exec_core. Some of the purpose is achieved in
transform_mjit_header.rb (see `IGNORED_FUNCTIONS`) but others are
manually resolved for now. Load mjit_helper.h for MJIT header.
mjit_helper.h: New. This is a file used only by JIT-ed code. I'll
refactor `mjit_call_cfunc` later.
vm_eval.c: add some #ifdef switches to skip compiling some functions
like Init_vm_eval.

win32/mkexports.rb: export thread/ec functions, which are used by MJIT.

include/ruby/defines.h: add MJIT_FUNC_EXPORTED macro alis to clarify
that a function is exported only for MJIT.

array.c: export a function used by MJIT.
bignum.c: ditto.
class.c: ditto.
compile.c: ditto.
error.c: ditto.
gc.c: ditto.
hash.c: ditto.
iseq.c: ditto.
numeric.c: ditto.
object.c: ditto.
proc.c: ditto.
re.c: ditto.
st.c: ditto.
string.c: ditto.
thread.c: ditto.
variable.c: ditto.
vm_backtrace.c: ditto.
vm_insnhelper.c: ditto.
vm_method.c: ditto.

I would like to improve maintainability of function exports, but I
believe this way is acceptable as initial merging if we clarify the
new exports are for MJIT (so that we can use them as TODO list to fix)
and add unit tests to detect unresolved symbols.
I'll add unit tests of JIT compilations in succeeding commits.

Author: Takashi Kokubun <takashikkbn@gmail.com>
Contributor: wanabe <s.wanabe@gmail.com>

Part of [Feature #14235]

---

* Known issues
  * Code generated by gcc is faster than clang. The benchmark may be worse
    in macOS. Following benchmark result is provided by gcc w/ Linux.
  * Performance is decreased when Google Chrome is running
  * JIT can work on MinGW, but it doesn't improve performance at least
    in short running benchmark.
  * Currently it doesn't perform well with Rails. We'll try to fix this
    before release.

---

* Benchmark reslts

Benchmarked with:
Intel 4.0GHz i7-4790K with 16GB memory under x86-64 Ubuntu 8 Cores

- 2.0.0-p0: Ruby 2.0.0-p0
- r62186: Ruby trunk (early 2.6.0), before MJIT changes
- JIT off: On this commit, but without `--jit` option
- JIT on: On this commit, and with `--jit` option

** Optcarrot fps

Benchmark: https://github.com/mame/optcarrot

|         |2.0.0-p0 |r62186   |JIT off  |JIT on   |
|:--------|:--------|:--------|:--------|:--------|
|fps      |37.32    |51.46    |51.31    |58.88    |
|vs 2.0.0 |1.00x    |1.38x    |1.37x    |1.58x    |

** MJIT benchmarks

Benchmark: https://github.com/benchmark-driver/mjit-benchmarks
(Original: https://github.com/vnmakarov/ruby/tree/rtl_mjit_branch/MJIT-benchmarks)

|           |2.0.0-p0 |r62186   |JIT off  |JIT on   |
|:----------|:--------|:--------|:--------|:--------|
|aread      |1.00     |1.09     |1.07     |2.19     |
|aref       |1.00     |1.13     |1.11     |2.22     |
|aset       |1.00     |1.50     |1.45     |2.64     |
|awrite     |1.00     |1.17     |1.13     |2.20     |
|call       |1.00     |1.29     |1.26     |2.02     |
|const2     |1.00     |1.10     |1.10     |2.19     |
|const      |1.00     |1.11     |1.10     |2.19     |
|fannk      |1.00     |1.04     |1.02     |1.00     |
|fib        |1.00     |1.32     |1.31     |1.84     |
|ivread     |1.00     |1.13     |1.12     |2.43     |
|ivwrite    |1.00     |1.23     |1.21     |2.40     |
|mandelbrot |1.00     |1.13     |1.16     |1.28     |
|meteor     |1.00     |2.97     |2.92     |3.17     |
|nbody      |1.00     |1.17     |1.15     |1.49     |
|nest-ntimes|1.00     |1.22     |1.20     |1.39     |
|nest-while |1.00     |1.10     |1.10     |1.37     |
|norm       |1.00     |1.18     |1.16     |1.24     |
|nsvb       |1.00     |1.16     |1.16     |1.17     |
|red-black  |1.00     |1.02     |0.99     |1.12     |
|sieve      |1.00     |1.30     |1.28     |1.62     |
|trees      |1.00     |1.14     |1.13     |1.19     |
|while      |1.00     |1.12     |1.11     |2.41     |

** Discourse's script/bench.rb

Benchmark: https://github.com/discourse/discourse/blob/v1.8.7/script/bench.rb

NOTE: Rails performance was somehow a little degraded with JIT for now.
We should fix this.
(At least I know opt_aref is performing badly in JIT and I have an idea
 to fix it. Please wait for the fix.)

*** JIT off
Your Results: (note for timings- percentile is first, duration is second in millisecs)

categories_admin:
  50: 17
  75: 18
  90: 22
  99: 29
home_admin:
  50: 21
  75: 21
  90: 27
  99: 40
topic_admin:
  50: 17
  75: 18
  90: 22
  99: 32
categories:
  50: 35
  75: 41
  90: 43
  99: 77
home:
  50: 39
  75: 46
  90: 49
  99: 95
topic:
  50: 46
  75: 52
  90: 56
  99: 101

*** JIT on
Your Results: (note for timings- percentile is first, duration is second in millisecs)

categories_admin:
  50: 19
  75: 21
  90: 25
  99: 33
home_admin:
  50: 24
  75: 26
  90: 30
  99: 35
topic_admin:
  50: 19
  75: 20
  90: 25
  99: 30
categories:
  50: 40
  75: 44
  90: 48
  99: 76
home:
  50: 42
  75: 48
  90: 51
  99: 89
topic:
  50: 49
  75: 55
  90: 58
  99: 99

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-04 11:22:28 +00:00
nobu 17b3441ac4 non-keywords hash
* class.c (rb_scan_args), include/ruby/ruby.h (rb_scan_args_set):
  return non-keywords elements only in the last hash when keyword
  arguments are extracted from it, as well as methods defined in
  ruby level.  [ruby-core:82427] [Bug #13830]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59626 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-20 06:08:25 +00:00
nobu 1292d2d24c class.c: check kw hash
* class.c (rb_keyword_error_new): get rid of an intermediate
  string and check if keys are symbols.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59622 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-19 01:04:15 +00:00
nobu 52d35e75cf class.c: call rb_hash_keys directly
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-19 00:45:22 +00:00
normal f7f097a369 remove unused rb_obj_basic_to_s_p function
This hasn't been used since r36709 (2012-08-15)
("Kernel#inspect: improve consistency and do not call #to_s.")
and was never part of public API in include/ruby/

* class.c (rb_obj_basic_to_s_p): remove function
* internal.h (rb_obj_basic_to_s_p): remove declaration

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-29 22:34:19 +00:00
nobu 217f599a1e class.c: prohibit refinement module
* class.c (ensure_includable): cannot include refinement
  module, or the type and the class do not match.
  [ruby-core:79632] [Bug #13236]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-25 03:23:43 +00:00
nobu 19a1f70364 class.c: ensure_includable
* class.c (ensure_includable): extract checks to include and
  prepend.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58082 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-25 02:57:30 +00:00
nobu 13dffd8a2a class.c: non-keyword hash class
* class.c (rb_extract_keywords): keep the class of non-keyword
  elements hash as the original.  [ruby-core:77813] [Bug #12884]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-18 03:38:52 +00:00
nobu f5ef84cb5e class.c: missing unknown_keyword_error
* class.c (rb_get_kwargs): when values are stored, corresponding
  keys have been remove from the keyword hash, and the hash should
  be empty in that case.  [ruby-dev:49893] [Bug #13004]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56981 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-04 08:50:29 +00:00
nobu ee160e68f9 class.c: no fstring singleton class
* class.c (singleton_class_of): prohibit fstrings from creating
  singleton classes.
  temporary measure for [ruby-dev:49867] [Bug #12923]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-12 09:43:05 +00:00
nobu 4e41467894 class.c: trivial optimization
* class.c (singleton_class_of): just copy FROZEN flag without
  conditions.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56739 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-12 06:12:12 +00:00
nobu 4065c38a6a class.c: rb_undef_methods_from
* class.c (rb_undef_methods_from): undefine methods defined in
  super from klass.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56482 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-24 01:49:52 +00:00
nobu dd2ebf4d78 replace Fixnum with Integer in rdoc [ci skip]
* array.c, class.c: Fixed documentation where Fixnum was referred
  directly to use Integer, as Fixnum and Bignum are now unified
  into Integer and direct usage is deprecated.  [Fix GH-1459]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56382 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-09 14:05:57 +00:00
tenderlove c4c53310c2 Copy the serial number from the super class to the singleton class
This helps hit inline method caches more frequently.  Before this
commit:

```
[aaron@TC ruby (trunk)]$ time ./ruby -v benchmark/bm_vm2_poly_singleton.rb
ruby 2.4.0dev (2016-09-12 trunk 56141) [x86_64-darwin15]

real  0m3.679s
user  0m3.632s
sys 0m0.022s
```

After this commit:

```
[aaron@TC ruby (trunk)]$ time ./ruby -v benchmark/bm_vm2_poly_singleton.rb
ruby 2.4.0dev (2016-09-12 trunk 56141) [x86_64-darwin15]
last_commit=Copy the serial number from the super class to the singleton class

real  0m2.246s
user  0m2.203s
sys 0m0.020s
```

[Feature #12364]
[ruby-core:75425]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-12 15:40:09 +00:00
nobu d9a6f701bf class.c: instance method conditions
* class.c (ins_methods_i, ins_methods_prot_i, ins_methods_priv_i),
  (ins_methods_pub_i): check for each conditions to match.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56086 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-07 07:35:45 +00:00
nobu 9662ee0584 internal.h: inline Check_Type
* internal.h (Check_Type): inline check for the object type.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55734 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-23 13:43:44 +00:00
nobu 81442f903c prevent rb_cObject from GC
* class.c (Init_class_hierarchy): prevent rb_cObject which is the
  class tree root, from GC.  [ruby-dev:49666] [Bug #12492]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-06-16 07:35:37 +00:00
eregon e4cab0fe95 * class.c (rb_define_class): Fix documentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55166 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-25 20:01:24 +00:00
nobu 29123a3799 class.c: simplify
* class.c (rb_scan_args): merge code for n_trail.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55159 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-25 08:13:37 +00:00
naruse 75307ce858 * class.c (rb_scan_args): moved to bottom of the file to make the
effect of `#undef rb_scan_args` the minimum.

* include/ruby/ruby.h (rb_scan_args): overwrite only if GCC and
  optimized. Visual C++ 14 or later can compile it but make it
  conservative.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55110 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-22 02:44:54 +00:00
naruse 8becb1e465 Revert r50102
This reverts "* include/ruby/ruby.h (rb_scan_args): don't use ALWAYS_INLINE with"
This rb_scan_args macro is GCCism.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55104 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-21 14:01:23 +00:00
naruse cc41066002 * include/ruby/ruby.h (rb_scan_args): use __VA_ARGS__ instead of
va_arg to allow compilers optimize more aggressive.
  https://gustedt.wordpress.com/2011/07/10/avoid-writing-va_arg-functions/
  rb_scan_args is now expected to be statically resolved.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-21 13:24:33 +00:00
nobu 9bb8f28f3d class.c: err if superclass is 0
* class.c (rb_define_class, rb_define_class_id_under): raise
  ArgumentError if super is 0, deprecated behavior which has been
  warned long time.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54015 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-07 04:33:00 +00:00
normal 244916d43b resolve class name earlier and more consistently
This further avoids class name resolution issues which came
about due to relying on hash table ordering before r53376.

Pre-caching the class name when it is never used raises memory
use, but the overall gain from moving away from st still gives
us a small gain.  Reverting r53376 and this patch and testing with
"valgrind -v ./ruby -rrdoc -eexit" on x86 (32-bit) shows:

before:
    in use at exit: 1,662,239 bytes in 25,286 blocks
  total heap usage: 49,514 allocs, 24,228 frees, 6,005,561 bytes allocated

after, with this change:
    in use at exit: 1,646,529 bytes in 24,572 blocks
  total heap usage: 48,891 allocs, 24,319 frees, 6,003,921 bytes allocated

* class.c (Init_class_hierarchy): resolve name for rb_cObject ASAP
* object.c (rb_mod_const_set): move name resolution to rb_const_set
* variable.c (rb_const_set): do class resolution here
  [ruby-core:72807] [Bug #11977]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-12 19:26:07 +00:00
normal 1142de8e2a use id_table for constant tables
valgrind 3.9.0 on x86-64 reports a minor reduction in memory usage
when loading only RubyGems and RDoc by running: ruby -rrdoc -eexit

before: HEAP SUMMARY:
    in use at exit: 2,913,448 bytes in 27,394 blocks
  total heap usage: 48,362 allocs, 20,968 frees, 9,034,621 bytes alloc

after: HEAP SUMMARY:
    in use at exit: 2,880,056 bytes in 26,712 blocks
  total heap usage: 47,791 allocs, 21,079 frees, 9,046,507 bytes alloc

* class.c (struct clone_const_arg): adjust for id_table
  (clone_const): ditto
  (clone_const_i): ditto
  (rb_mod_init_copy): ditto
  (rb_singleton_class_clone_and_attach): ditto
  (rb_include_class_new): ditto
  (include_modules_at): ditto
* constant.h (rb_free_const_table): ditto
* gc.c (free_const_entry_i): ditto
  (rb_free_const_table): ditto
  (obj_memsize_of): ditto
  (mark_const_entry_i): ditto
  (mark_const_tbl): ditto
* internal.h (struct rb_classext_struct): ditto
* object.c (rb_mod_const_set): resolve class name on assignment
* variable.c (const_update): replace with const_tbl_update
  (const_tbl_update): new function
  (fc_i): adjust for id_table
  (find_class_path): ditto
  (autoload_const_set): st_update => const_tbl_update
  (rb_const_remove): adjust for id_table
  (sv_i): ditto
  (rb_local_constants_i): ditto
  (rb_local_constants): ditto
  (rb_mod_const_at): ditto
  (rb_mod_const_set): ditto
  (rb_const_lookup): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-29 20:19:14 +00:00
nobu 96ac47c251 gc.c: do not expose internal singleton class
* gc.c (internal_object_p): should not expose singleton classes
  without a metaclass.  based on patches by ko1 and shugo.
  [Bug #11740]
* class.c (rb_singleton_class_object_p): added.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-22 13:15:58 +00:00
ko1 800607aa7e revert r53228 because this patch breaks rubyspec
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53229 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-21 10:32:33 +00:00
ko1 1bcee938d5 * gc.c (internal_object_p): should not expose singleton classes
without a metaclass.
  [Bug #11740]

* class.c (rb_singleton_class_has_metaclass_p): added.

* test/ruby/test_class.rb: add a test.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53228 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-21 09:40:58 +00:00
hsbt b381e3caee * class.c: fix documentation for rb_define_class{_id}_under.
[fix GH-991][ci skip] Patch by @kachick

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52445 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-04 06:46:05 +00:00
nobu 6f77d0a3aa variable.c: rb_class_ivar_set
* variable.c (rb_class_ivar_set): rename as class specific ivar
  setter, and st_table is no longer involved.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52380 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-30 03:07:06 +00:00
normal a666e9b5f2 variable.c (rb_st_insert_id_and_value): reduce args
Minor simplification; this will hopefully make future patches
for switching to id_table easier-to-review.

* internal.h (rb_st_insert_id_and_value): update prototype
* variable.c (rb_st_insert_id_and_value): reduce args
  (find_class_path): adjust call for less args
  (rb_ivar_set): ditto
  (rb_cvar_set): ditto
* class.c (rb_singleton_class_attached): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-30 01:40:28 +00:00
nobu eb47de3005 class.c: refine error messages
* class.c (rb_define_class, rb_define_class_id_under): refine
  error messages.
* class.c (rb_define_module, rb_define_module_id_under): ditto,
  and make consistent with class.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-27 14:32:50 +00:00
ko1 15e48288fd * class.c (move_refined_method): should insert a write barrier
from an original class to a created (cloned) method entry.
* test/ruby/test_refinement.rb: add a test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51728 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-31 08:07:59 +00:00
ko1 2e2bd1c26b * class.c (move_refined_method): same as the last commit.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51545 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-12 09:00:56 +00:00
ko1 408fa5e687 * class.c, gc.c vm.c: use ID_TABLE_* instead of ST_*
(such as ST_CONTINUE) for enum rb_id_table_iterator_result.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-12 08:59:27 +00:00
ko1 c35ff11ae5 * id_table.h: introduce ID key table.
[Feature #11420]
  This table only manage ID->VALUE table to reduce overhead of st.
  Some functions prefixed rb_id_table_* are provided.
* id_table.c: implement rb_id_table_*.
  There are several algorithms to implement it.
  Now, there are roughly 4 types:
    * st
    * array
    * hash (implemented by  Yura Sokolov)
    * mix of array and hash
  The macro ID_TABLE_IMPL can choose implementation.
  You can see detailes about them at the head of id_table.c.
  At the default, I choose 34 (mix of list and hash).
  This is not final decision.
  Please report your suitable parameters or
  your data structure.
  * symbol.c: introduce rb_id_serial_t and rb_id_to_serial()
    to represent ID by serial number.
  * internal.h: use id_table for method tables.
  * class.c, gc.c, marshal.c, vm.c, vm_method.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51541 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-12 08:43:55 +00:00
ko1 e4198a73d4 * make rb_iseq_t T_IMEMO object (type is imemo_iseq).
All contents of previous rb_iseq_t is in rb_iseq_t::body.
  Remove rb_iseq_t::self because rb_iseq_t is an object.
  RubyVM::InstructionSequence is wrapper object points T_IMEMO/iseq.
  So RubyVM::ISeq.of(something) method returns different wrapper
  objects but they point the same T_IMEMO/iseq object.
  This patch is big, but most of difference is replacement of
  iseq->xxx to iseq->body->xxx.
  (previous) rb_iseq_t::compile_data is also located to
  rb_iseq_t::compile_data.
  It was moved from rb_iseq_body::compile_data.
  Now rb_iseq_t has empty two pointers.
  I will split rb_iseq_body data into static data and dynamic data.
* compile.c: rename some functions/macros.
  Now, we don't need to separate iseq and iseqval (only VALUE).
* eval.c (ruby_exec_internal): `n' is rb_iseq_t (T_IMEMO/iseq).
* ext/objspace/objspace.c (count_imemo_objects): count T_IMEMO/iseq.
* gc.c: check T_IMEMO/iseq.
* internal.h: add imemo_type::imemo_iseq.
* iseq.c: define RubyVM::InstructionSequnce as T_OBJECT.
  Methods are implemented by functions named iseqw_....
* load.c (rb_load_internal0): rb_iseq_new_top() returns
  rb_iseq_t (T_IMEMO/iesq).
* method.h (rb_add_method_iseq): accept rb_iseq_t (T_IMEMO/iseq).
* vm_core.h (GetISeqPtr): removed because it is not T_DATA now.
* vm_core.h (struct rb_iseq_body): remove padding for
  [Bug #10037][ruby-core:63721].



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-21 22:52:59 +00:00
ko1 16a68369d2 * iseq.c, internal.h (rb_iseq_clone): removed because we don't need to
clone iseq any more.
* class.c (clone_method): share iseq between cloned methods. All of
  method dependent information are able to refer from method entry.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-07 02:27:41 +00:00
ko1 5e8a147480 * method.h: introduce rb_callable_method_entry_t to remove
rb_control_frame_t::klass.
  [Bug #11278], [Bug #11279]
  rb_method_entry_t data belong to modules/classes.
  rb_method_entry_t::owner points defined module or class.
    module M
      def foo; end
    end
  In this case, owner is M.
  rb_callable_method_entry_t data belong to only classes.
  For modules, MRI creates corresponding T_ICLASS internally.
  rb_callable_method_entry_t can also belong to T_ICLASS.
  rb_callable_method_entry_t::defined_class points T_CLASS or
  T_ICLASS.
  rb_method_entry_t data for classes (not for modules) are also
  rb_callable_method_entry_t data because it is completely same data.
  In this case, rb_method_entry_t::owner == rb_method_entry_t::defined_class.
  For example, there are classes C and D, and incldues M,
    class C; include M; end
    class D; include M; end
  then, two T_ICLASS objects for C's super class and D's super class
  will be created.
  When C.new.foo is called, then M#foo is searcheed and
  rb_callable_method_t data is used by VM to invoke M#foo.
  rb_method_entry_t data is only one for M#foo.
  However, rb_callable_method_entry_t data are two (and can be more).
  It is proportional to the number of including (and prepending)
  classes (the number of T_ICLASS which point to the module).
  Now, created rb_callable_method_entry_t are collected when
  the original module M was modified. We can think it is a cache.
  We need to select what kind of method entry data is needed.
  To operate definition, then you need to use rb_method_entry_t.
  You can access them by the following functions.
  * rb_method_entry(VALUE klass, ID id);
  * rb_method_entry_with_refinements(VALUE klass, ID id);
  * rb_method_entry_without_refinements(VALUE klass, ID id);
  * rb_resolve_refined_method(VALUE refinements, const rb_method_entry_t *me);
  To invoke methods, then you need to use rb_callable_method_entry_t
  which you can get by the following APIs corresponding to the
  above listed functions.
  * rb_callable_method_entry(VALUE klass, ID id);
  * rb_callable_method_entry_with_refinements(VALUE klass, ID id);
  * rb_callable_method_entry_without_refinements(VALUE klass, ID id);
  * rb_resolve_refined_method_callable(VALUE refinements, const rb_callable_method_entry_t *me);
  VM pushes rb_callable_method_entry_t, so that rb_vm_frame_method_entry()
  returns rb_callable_method_entry_t.
  You can check a super class of current method by
  rb_callable_method_entry_t::defined_class.
* method.h: renamed from rb_method_entry_t::klass to
  rb_method_entry_t::owner.
* internal.h: add rb_classext_struct::callable_m_tbl to cache
  rb_callable_method_entry_t data.
  We need to consider abotu this field again because it is only
  active for T_ICLASS.
* class.c (method_entry_i): ditto.
* class.c (rb_define_attr): rb_method_entry() does not takes
  defiend_class_ptr.
* gc.c (mark_method_entry): mark RCLASS_CALLABLE_M_TBL() for T_ICLASS.
* cont.c (fiber_init): rb_control_frame_t::klass is removed.
* proc.c: fix `struct METHOD' data structure because
  rb_callable_method_t has all information.
* vm_core.h: remove several fields.
  * rb_control_frame_t::klass.
  * rb_block_t::klass.
  And catch up changes.
* eval.c: catch up changes.
* gc.c: ditto.
* insns.def: ditto.
* vm.c: ditto.
* vm_args.c: ditto.
* vm_backtrace.c: ditto.
* vm_dump.c: ditto.
* vm_eval.c: ditto.
* vm_insnhelper.c: ditto.
* vm_method.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-03 11:24:50 +00:00
normal b49075cdf1 move RB_GC_GUARD responsibility to rb_add_method_iseq
This simplifies all the callers and makes code easier to use
and review.  I was confused about the need for RB_GC_GUARD
in define_{aset,aref}_method of struct.c without reading
rb_add_method_iseq.

Likewise, do the same for rb_iseq_clone, where the GC guard
only seems neccesary iff RGenGC is disabled.

* vm_method.c (rb_add_method_iseq): add RB_GC_GUARD
* class.c (clone_method): remove RB_GC_GUARD
* struct.c (define_aref_method): ditto
  (define_aset_method): ditto
* vm.c (vm_define_method):
* iseq.c (rb_iseq_clone): add RB_GC_GUARD

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-30 21:07:18 +00:00
nobu da70f4d02a class.c: preserve encoding
* class.c (rb_check_inheritable): preserve encoding in an error
  message when the superclass is not a class.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51050 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-28 03:28:50 +00:00
nobu a13ab237c7 class.c: TypeError when superclass mismatch
* class.c (rb_define_class_id_under): raise TypeError exception
  same as ruby level class definition when superclass mismatch.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51048 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-28 03:07:37 +00:00
ko1 c8590d60f1 * method.h: constify rb_method_alias_struct::original_me and
rb_method_refined_struct::orig_me.
* class.c (move_refined_method): use RB_OBJ_WRITE() for
  me->def->body.refined.orig_me.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50948 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-18 08:01:13 +00:00
ko1 c19d373750 * method.h: back to share rb_method_definition_t by
rb_method_entry_t.
  r50728 changed sharing `def's to isolating `def's
  on alias and so on. However, this change conflicts
  future improvement plan. So I change back to sharing approach.
* method.h: move rb_method_definition_t::flags to
  rb_method_entry_t::attr::flags.
  rb_method_entry_t::attr is union with VALUE because this field
  should have same size of VALUE. rb_method_entry_t is T_IMEMO).
  And also add the following access macros to it's fileds.
  * METHOD_ENTRY_VISI(me)
  * METHOD_ENTRY_BASIC(me)
  * METHOD_ENTRY_SAFE(me)
* vm_method.c (rb_method_definition_addref): added instead of
  rb_method_definition_clone().
  Do not create new definition, but increment alias_count.
* class.c (clone_method): catch up this fix.
* class.c (method_entry_i): ditto.
* proc.c (mnew_internal): ditto.
* proc.c (mnew_missing): ditto.
* vm_eval.c: ditto.
* vm_insnhelper.c: ditto.
* vm_method.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-06 10:19:48 +00:00
ko1 c9044a2472 * class.c: ins_methods_push() needs rb_method_visibility_t type on
2nd arg.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50791 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-06 07:01:21 +00:00
ko1 1f9af2a953 * class.c (ins_methods_push): Change type and name of parameters
to make more clear.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50790 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-06 06:07:06 +00:00
nobu 32a586d738 class.c: suppress a warning
* class.c (ins_methods_push): suppress a signed and unsigned
  comparison warning.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-06 01:37:50 +00:00
ko1 eb774ceb22 * class.c (ins_methods_push): change 3rd parameter's type
from long to rb_method_visibility_t.
* class.c (ins_methods_i): catch up this fix.
* class.c (method_entry_i): cast to st_data_t instead of `long'.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-05 13:39:59 +00:00
ko1 3619a8b52d * method.h: constify rb_method_refined_t::orig_me.
Also constify the following functions.
  * rb_resolve_refined_method()
  * rb_method_entry_with_refinements()
  * rb_method_entry_without_refinements()
  * rb_method_entry_copy()'s parameter.
* class.c: catch up this fix.
* vm_insnhelper.c: ditto.
* vm_method.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50770 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-04 16:02:01 +00:00
ko1 9e73d45e0f * method.h: introduce rb_method_refined_t for refined method entry.
* class.c (move_refined_method): catch up this fix.
* gc.c (mark_method_entry): ditto.
* vm_eval.c (vm_call0_body): ditto.
* vm_insnhelper.c (vm_call_method): ditto.
* vm_method.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-03 22:27:51 +00:00
ko1 332210d441 * class.c (method_entry_i): mtbl should not have `me' as NULL.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-03 19:51:38 +00:00
ko1 93f88afbd6 * class.c (clone_method): do not use me->klass, but use explicitly
passed argument.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50754 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-03 19:36:52 +00:00
ko1 4e870d302b * vm_core.h (rb_vm_rewrite_cref_stack): rename to rb_vm_rewrite_cref().
* class.c (clone_method): use renamed name.
* vm_insnhelper.c (rb_vm_rewrite_cref): do not use `node' in variable
  names.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50752 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-03 19:12:26 +00:00
ko1 c3cc282f7f * class.c (clone_method): remove redundant check for me->def != NULL.
Now, all `me` have `me->def`.
* proc.c (rb_method_entry_location): ditto.
* vm.c (rb_vm_check_redefinition_opt_method): ditto.
* vm.c (add_opt_method): ditto.
* vm_eval.c (vm_call0_body): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50748 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-03 11:10:16 +00:00
ko1 18bbd05709 * method.h: split rb_method_definition_t::flag to several flags.
`flag' contains several categories of attributes and it makes us
  confusion (at least, I had confused).
  * rb_method_visibility_t (flags::visi)
    * NOEX_UNDEF     -> METHOD_VISI_UNDEF     = 0
    * NOEX_PUBLIC    -> METHOD_VISI_PUBLIC    = 1
    * NOEX_PRIVATE   -> METHOD_VISI_PRIVATE   = 2
    * NOEX_PROTECTED -> METHOD_VISI_PROTECTED = 3
  * NOEX_SAFE(flag)) -> safe (flags::safe, 2 bits)
  * NOEX_BASIC       -> basic (flags::basic, 1 bit)
  * NOEX_MODFUNC     -> rb_scope_visibility_t in CREF
  * NOEX_SUPER       -> MISSING_SUPER (enum missing_reason)
  * NOEX_VCALL       -> MISSING_VCALL (enum missing_reason)
  * NOEX_RESPONDS    -> BOUND_RESPONDS (macro)
  Now, NOEX_NOREDEF is not supported (I'm not sure it is needed).
  Background:
    I did not know what "NOEX" stands for.
    I asked Matz (who made this name) and his answer was "Nothing".
    "At first, it meant NO EXport (private), but the original
    meaning was gone."
    This is why I remove the mysterious word "NOEX" from MRI.
* vm_core.h: introduce `enum missing_reason' to represent
  method_missing (NoMethodError) reason.
* eval_intern.h: introduce rb_scope_visibility_t to represent
  scope visibility.
  It has 3 method visibilities (public/private/protected)
  and `module_function`.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-03 01:39:16 +00:00
ko1 ac88162198 * method.h: remove rb_method_iseq_t::iseqval.
While making a r50728, iseqval is needed (to mark correctly),
  but now just iseqptr is enough.
* class.c: catch up this fix.
* gc.c: ditto.
* proc.c: ditto.
* vm_method.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-02 14:32:33 +00:00
ko1 57b817f4c5 * method.h: make rb_method_entry_t a VALUE.
Motivation and new data structure are described in [Bug #11203].
  This patch also solve the following issues.
  * [Bug #11200] Memory leak of method entries
  * [Bug #11046] __callee__ returns incorrect method name in orphan
                 proc
* test/ruby/test_method.rb: add a test for [Bug #11046].
* vm_core.h: remvoe rb_control_frame_t::me. me is located at value
  stack.
* vm_core.h, gc.c, vm_method.c: remove unlinked_method... codes
  because method entries are simple VALUEs.
* method.h:  Now, all method entries has own independent method
  definititons. Strictly speaking, this change is not essential,
  but for future changes.
  * rb_method_entry_t::flag is move to rb_method_definition_t::flag.
  * rb_method_definition_t::alias_count is now
    rb_method_definition_t::alias_count_ptr, a pointer to the counter.
* vm_core.h, vm_insnhelper.c (rb_vm_frame_method_entry) added to
  search the current method entry from value stack.
* vm_insnhelper.c (VM_CHECK_MODE): introduced to enable/disable
  assertions.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50728 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-02 04:20:30 +00:00
ko1 cd909b553f * class.c: remove needless include pragmra for method.h.
* struct.c: ditto.
* vm_method.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50712 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-01 06:44:16 +00:00
ko1 258131446c * class.c (rb_class_has_methods): added to reduce depenedency
to internal class data structure.
* internal.h: ditto.
* hash.c (has_extra_methods): use added function.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-31 19:17:18 +00:00
nobu c2a04d87d0 vm_eval.c: allow symbols to instance_eval/exec
* vm_eval.c (rb_obj_instance_eval, rb_obj_instance_exec): allow
  symbols to just instance_eval/exec, execept for definition of
  singletons.  [ruby-core:68961] [Bug #11086]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50372 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-23 02:35:58 +00:00
ko1 5922c95461 * gc.c: fix memory leak by prepend method.
It is easy to reproduce with such script:
    module M; def bar; end; end
    loop{
      Class.new do
        def foo; end
        prepend M
      end
    }
* gc.c (obj_free): free T_ICLASS::m_tbl if it is created by prepend.
  To recognize it, check RICLASS_IS_ORIGIN flag.
* gc.c (gc_mark_children): T_ICLASS objects only need to mark
  T_ICLASS::m_tbl if RICLASS_IS_ORIGIN is set.
* gc.c (obj_memsize_of): count T_ICLASS if RICLASS_IS_ORIGIN is set.
* internal.h (RCLASS_SET_ORIGIN): add to set RCLASS_SET_ORIGIN.
  TODO: The word `origin' seems not good name. We need to invent
  another good name.
* class.c: use RCLASS_SET_ORIGIN().
* class.c (class_alloc): zero clear rb_classext_t.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49931 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-11 09:15:20 +00:00
ko1 8dced4d2c0 * internal.h: define rb_cref_t and change to use it.
rb_cref_t is data type of CREF. Now, the body is still NODE.
  It is easy to understand what is CREF and what is pure NODE.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-08 21:22:43 +00:00
ko1 9113098e65 * class.c (rb_prepend_module): need a WB for klass -> origin.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49875 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-06 13:51:27 +00:00
ko1 d84f9b1694 * fix namespace issue on singleton class expressions. [Bug #10943]
* vm_core.h, method.h: remove rb_iseq_t::cref_stack. CREF is stored
  to rb_method_definition_t::body.iseq_body.cref.
* vm_insnhelper.c: modify SVAR usage.
  When calling ISEQ type method, push CREF information onto method
  frame, SVAR located place. Before this fix, SVAR is simply nil.
  After this patch, CREF (or NULL == Qfalse for not iseq methods)
  is stored at the method invocation.
  When SVAR is requierd, then put NODE_IF onto SVAR location,
  and NDOE_IF::nd_reserved points CREF itself.
* vm.c (vm_cref_new, vm_cref_dump, vm_cref_new_toplevel): added.
* vm_insnhelper.c (vm_push_frame): accept CREF.
* method.h, vm_method.c (rb_add_method_iseq): added. This function
  accepts iseq and CREF.
* class.c (clone_method): use rb_add_method_iseq().
* gc.c (mark_method_entry): mark method_entry::body.iseq_body.cref.
* iseq.c: remove CREF related codes.
* insns.def (getinlinecache/setinlinecache): CREF should be cache key
  because a different CREF has a different namespace.
* node.c (rb_gc_mark_node): mark NODE_IF::nd_reserved for SVAR.
* proc.c: catch up changes.
* struct.c: ditto.
* insns.def: ditto.
* vm_args.c (raise_argument_error): ditto.
* vm_eval.c: ditto.
* test/ruby/test_class.rb: add a test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-06 12:24:58 +00:00
ko1 8f88ff4e37 * internal.h: remove struct method_table_wrapper.
struct method_table_wrapper was introduced to avoid duplicate marking
  for method tables.
  For example, `module M1; def foo; end; end` make one method table
  (mtbl) contains a method `foo`. M1 (T_MODULE) points mtbl.
  Classes C1 and C2 includes M1, then two T_ICLASS objects are created
  and they points mtbl too. In this case, three objects (one T_MODULE
  and two T_ICLASS objects) points same mtbl. On marking phase, these
  three objects mark same mtbl. To avoid such duplication, struct
  method_table_wrapper was introduced.
  However, created two T_ICLASS objects have same or shorter lifetime
  than M1 (T_MODULE) object. So that we only need to mark mtbl from M1,
  not from T_ICLASS objects. This patch tries marking only from M1.
  Note that one `Module#prepend` call creates two T_ICLASS objects.
  One for refering to a prepending Module object, same as
  `Module#include`. We don't nedd to care this T_ICLASS.
  One for moving original mtbl from a prepending class. We need to
  mark such mtbl from this T_ICLASS object. To mark the mtbl,
  we need to use `RCLASS_ORIGIN(klass)` on marking from a prepended
  class `klass`.
* class.c: ditto.
* eval.c (rb_using_refinement): ditto.
* gc.c: ditto.
* include/ruby/ruby.h: define m_tbl directly. The definition of
  struct RClass should be moved to (srcdir)/internal.h.
* method.h: remove decl of rb_free_m_tbl_wrapper().
* object.c: use RCLASS_M_TBL() directly.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-05 22:20:14 +00:00
ktsj e660f776c0 * vm_insnhelper.c (rb_vm_rewrite_cref_stack): copy nd_refinements
of orignal crefs. It fixes segmentation fault when calling
  refined method in duplicate module. [ruby-dev:48878] [Bug #10885]

* vm_core.h, class.c: change accordingly.

* test/ruby/test_refinement.rb: add a test for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-22 07:05:14 +00:00
nobu 16294913f7 use rb_funcallv
* use rb_funcallv() for no arguments call instead of variadic
  rb_funcall().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-16 04:08:52 +00:00
shugo 9e57ac56a3 * class.c (rb_obj_singleton_methods): should use RTEST() to convert
VALUE to int.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49503 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-05 01:34:01 +00:00
shugo dc3ea52e1c * class.c (method_entry_i, class_instance_method_list,
rb_obj_singleton_methods): should not include methods of
  superclasses if recur is false. [ruby-dev:48854] [Bug #10826]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-04 07:45:29 +00:00
nobu 0fb2cd458b class.c: add callback argument
* class.c (rb_class_foreach_subclass): add argument for callback
  function.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49335 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-19 14:09:20 +00:00
nobu 59270c607b class.c: prepend for each classes
* class.c (include_modules_at): allow prepend each modules upto
  once for each classes.  [EXPERIMENTAL]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49332 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-19 13:08:28 +00:00
ko1 1b6aa03eb9 * class.c (class_alloc): Strat from age == 2.
Class and Module objects can be living long life.
* iseq.c: Same for ISeq objects.
* gc.c (RVALUE_AGE_RESET): added.
* gc.c (newobj_of): allow to generate (age != 0) objects.
* gc.c (rb_copy_wb_protected_attribute): reset age for wb unprotected
  objects.
* include/ruby/ruby.h: add RUBY_TYPED_PROMOTED1 as an unrecommended
  flag.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48771 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-11 10:15:30 +00:00
ko1 6115f65d7d * vm_args.c: fix backtrace location for keyword related exceptions.
For example, the following program
    def foo(k1: 1); end # line 1
            foo(k2: 2)          # line 2
  causes "unknown keyword: k2 (ArgumentError)".
  Before this patch, the backtrace location is only line 2.
  However, error should be located at line 1 (over line 2 in
  stack trace). This patch fix this problem.
* class.c (rb_keyword_error_new): separate exception creation logic
  from rb_keyword_error(), to use in vm_args.c.
* vm_insnhelper.c (rb_arg_error_new): rename to rb_arity_error_new().
* vm_args.c (argument_arity_error): rename to argument_arity_error().
* vm_args.c (arugment_kw_error): added to fix backtrace.
* test/ruby/test_keyword.rb: add tests.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-27 10:15:47 +00:00
nobu 606e855622 rb_id2str over rb_id2name
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48575 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-25 18:44:22 +00:00
akr 2b9191e557 * internal.h: Gather declarations in non-header files.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-18 15:13:05 +00:00
akr 7cd76ab0c5 * internal.h: Include ruby.h and ruby/encoding.h to be
includable without prior inclusion.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-15 11:49:06 +00:00
ko1 fbebd502f9 * rewrite method/block parameter fitting logic to optimize
keyword arguments/parameters and a splat argument.
  [Feature #10440] (Details are described in this ticket)
  Most of complex part is moved to vm_args.c.
  Now, ISeq#to_a does not catch up new instruction format.
* vm_core.h: change iseq data structures.
  * introduce rb_call_info_kw_arg_t to represent keyword arguments.
  * add rb_call_info_t::kw_arg.
  * rename rb_iseq_t::arg_post_len to rb_iseq_t::arg_post_num.
  * rename rb_iseq_t::arg_keywords to arg_keyword_num.
  * rename rb_iseq_t::arg_keyword to rb_iseq_t::arg_keyword_bits.
    to represent keyword bitmap parameter index.
    This bitmap parameter shows that which keyword parameters are given
    or not given (0 for given).
    It is refered by `checkkeyword' instruction described bellow.
  * rename rb_iseq_t::arg_keyword_check to rb_iseq_t::arg_keyword_rest
    to represent keyword rest parameter index.
  * add rb_iseq_t::arg_keyword_default_values to represent default
    keyword values.
  * rename VM_CALL_ARGS_SKIP_SETUP to VM_CALL_ARGS_SIMPLE
    to represent
      (ci->flag & (SPLAT|BLOCKARG)) &&
      ci->blockiseq == NULL &&
      ci->kw_arg == NULL.
* vm_insnhelper.c, vm_args.c: rewrite with refactoring.
  * rewrite splat argument code.
  * rewrite keyword arguments/parameters code.
  * merge method and block parameter fitting code into one code base.
* vm.c, vm_eval.c: catch up these changes.
* compile.c (new_callinfo): callinfo requires kw_arg parameter.
* compile.c (compile_array_): check the last argument Hash object or
  not. If Hash object and all keys are Symbol literals, they are
  compiled to keyword arguments.
* insns.def (checkkeyword): add new instruction.
  This instruction check the availability of corresponding keyword.
  For example, a method "def foo k1: 'v1'; end" is cimpiled to the
  following instructions.
    0000 checkkeyword     2, 0  # check k1 is given.
    0003 branchif         9     # if given, jump to address #9
    0005 putstring        "v1"
    0007 setlocal_OP__WC__0 3   # k1 = 'v1'
    0009 trace            8
    0011 putnil
    0012 trace            16
    0014 leave
* insns.def (opt_send_simple): removed and add new instruction
  "opt_send_without_block".
* parse.y (new_args_tail_gen): reorder variables.
  Before this patch, a method "def foo(k1: 1, kr1:, k2: 2, **krest, &b)"
  has parameter variables "k1, kr1, k2, &b, internal_id, krest",
  but this patch reorders to "kr1, k1, k2, internal_id, krest, &b".
  (locate a block variable at last)
* parse.y (vtable_pop): added.
  This function remove latest `n' variables from vtable.
* iseq.c: catch up iseq data changes.
* proc.c: ditto.
* class.c (keyword_error): export as rb_keyword_error().
* common.mk: depend vm_args.c for vm.o.
* hash.c (rb_hash_has_key): export.
* internal.h: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-02 18:02:55 +00:00
nobu 67121b5060 class.c: delete expected keywords directly
* class.c (unknown_keyword_error): delete expected keywords
  directly from raw table, so that the given block is not called.
  [ruby-core:65837] [Bug #10413]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-22 18:41:54 +00:00
nobu 445086e56b class.c: do not freeze class of hidden object
* class.c (rb_freeze_singleton_class): get rid of freeze class of
  hidden object to fix segfaults.

* include/ruby/ruby.h (rb_obj_freeze_inline): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-19 02:40:58 +00:00
nobu d9a597408f class.c: do not freeze meta-meta-class
* class.c (rb_freeze_singleton_class): should not propagate to
  meta-meta-class, and so on, which is shared with the original
  class.  fix occational exceptions.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47633 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-19 01:45:45 +00:00
nobu ab22202a50 class.c: simplify
* class.c (singleton_class_of): use local variable and remove
  duplicated member access.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47575 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-13 13:07:04 +00:00
nobu 4df147d6e8 class.c: freeze meta class only
* class.c (singleton_class_of): should not propagete freezing to
  meta meta class.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47574 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-13 13:03:46 +00:00
normal 05b374b824 class.c: use ALLOC(rb_subclass_entry_t)
It is easier to search for allocations by type.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-13 06:17:58 +00:00
nagachika 1d0de2a513 * class.c (rb_prepend_module): fix typos in a comment.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47541 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-11 17:16:45 +00:00
ktsj 5a60ddc56d * class.c: [DOC] mention about prepended modules.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46702 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-05 05:13:28 +00:00
nobu 876bfc6b4e Init functions don't need ID caches
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46663 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-03 03:38:10 +00:00
nobu e99ee55abc constify parameters
* include/ruby/intern.h: constify `argv` parameters.

* include/ruby/ruby.h: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46459 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-18 06:16:39 +00:00
zzak 10e7f389e2 * class.c: [DOC] Fixed grammar and examples of instance_methods.
By @alex-frost via documenting-ruby/ruby#31 [ci skip]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-25 00:43:14 +00:00
nobu 7c072b35d1 class.c: always clear tables first
* class.c (rb_mod_init_copy): always clear instance variable,
  constant and method tables first, regardless the source tables.
  [ruby-dev:48182] [Bug #9813]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-08 05:34:31 +00:00
normal b39eabac5d class.c: check for malloc failures
* class.c (rb_class_subclass_add): use xmalloc
* class.c (rb_module_add_to_subclasses_list): ditto
* class.c (rb_class_remove_from_super_subclasses): use xfree
* class.c (rb_class_remove_from_module_subclasses): ditto
  [Bug #9616]

xmalloc does OOM checking and helps GC accounting when used
with xfree.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-09 05:22:01 +00:00
nobu 27bfb11d0d adjust indent and style
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-27 09:57:32 +00:00
nobu 1f29e8e2ba class.c: do nothing if copying self
* class.c (rb_mod_init_copy): do nothing if copying self.
  [ruby-dev:47989] [Bug #9535]
* hash.c (rb_hash_initialize_copy): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-21 11:42:03 +00:00
nobu bbba022739 class.c: allow nil keyword_hash
* class.c (rb_extract_keywords): treat nil keyword_hash same as 0,
  for the case rb_scan_args returns nil if no keyword hash.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44702 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-25 02:16:20 +00:00
nobu 0e4abc3295 class.c: simplify
* class.c (rb_obj_methods): simplify without jump.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-25 01:55:44 +00:00
ko1 c702005a7b * include/ruby/ruby.h: rename OBJ_WRITE and OBJ_WRITTEN into
RB_OBJ_WRITE and RB_OBJ_WRITTEN.
* array.c, class.c, compile.c, hash.c, internal.h, iseq.c,
  proc.c, process.c, re.c, string.c, variable.c, vm.c,
  vm_eval.c, vm_insnhelper.c, vm_insnhelper.h,
  vm_method.c: catch up this change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-20 08:07:47 +00:00
nobu c5601931c2 class.c: fix option hash
* class.c (rb_scan_args): if no keywords is given return nil as
  the option hash.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44244 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-16 10:25:21 +00:00
tmm1 c2dcb947aa object.c: use RCLASS_M_TBL_WRAPPER for equality checks
* class.c (include_modules_at): use RCLASS_M_TBL_WRAPPER for
  equality checks. this avoids an unnecessary deference inside a tight
  loop, fixing a performance regression from r43973.
* object.c (rb_obj_is_kind_of): ditto.
* object.c (rb_class_inherited_p): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-12 23:19:02 +00:00
charliesome c039c70815 * internal.h (RCLASS_SERIAL): Add RCLASS_SERIAL as a convenience
accessor for RCLASS_EXT(klass)->class_serial.

* class.c, vm_insnhelper.c, vm_method.c: Use RCLASS_SERIAL

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-09 11:00:23 +00:00
nobu 673aa23050 class.c: rest kwargs
* class.c (rb_get_kwargs): when values is non-null, remove
  extracted keywords from the rest keyword argument.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44077 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-08 11:47:39 +00:00
nobu dd8710d243 class.c, vm_insnhelper.c: check unknown keywords
* class.c (rb_get_kwargs): if optional is negative, unknown
  keywords are allowed.
* vm_insnhelper.c (vm_callee_setup_keyword_arg): check unknown
  keywords.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44069 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-08 07:19:30 +00:00
nobu 72f60a2ff1 class.c: optimization just one key
* class.c (keyword_error): use only element itself for
  optimization in the case the key has just one element.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-08 07:17:21 +00:00
tmm1 8f77cfb308 gc.c: promote long-lived NODE_CREF objects to oldgen
* include/ruby/ruby.h: add RGENGC_WB_PROTECTED_NODE_CREF setting
  In a large app, this reduces the size of
  remembered_shady_object_count by 80%. [Bug #9225] [ruby-core:58947]
* gc.c (rb_node_newnode): add FL_WB_PROTECTED flag to NODE_CREF
* class.c (rewrite_cref_stack): insert OBJ_WRITE for NODE_CREF
* iseq.c (set_relation): ditto
* iseq.c (rb_iseq_clone): ditto
* vm_eval.c (rb_yield_refine_block): ditto
* vm_insnhelper.c (vm_cref_push): ditto
* vm_insnhelper.h (COPY_CREF): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-08 02:28:04 +00:00
nobu 100fe2e659 class.c: fix uninitialized value
* class.c (rb_get_kwargs): fix returning uninitialized value when no
  optional keywords.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44056 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-08 01:32:07 +00:00
nobu 113008a7ae class.c: move kwarg functions
* class.c (rb_extract_keywords, rb_get_kwargs): move from
  vm_insnhelper.c.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-06 10:33:42 +00:00
tmm1 084b602d9a * include/ruby/ruby.h (struct RClass): Add wrapper struct around
RClass->m_tbl with serial. This prevents double marking method
  tables, since many classes/modules can share the same method table.
  This improves minor mark time in a large application by 30%.
* internal.h (struct method_table_wrapper): Define new
  wrapper struct with additional serial.
* internal.h (RCLASS_M_TBL_INIT): New macro for initializing method
  table wrapper and st_table.
* method.h (void rb_sweep_method_entry): Rename rb_free_m_table to
  rb_free_m_tbl for consistentcy
* .gdbinit (define rb_method_entry): Update rb_method_entry gdb helper
  for new method table structure.
* class.c: Use RCLASS_M_TBL_WRAPPER and
  RCLASS_M_TBL_INIT macros.
* class.c (rb_include_class_new): Share WRAPPER between module and
  iclass, so serial can prevent double marking.
* eval.c (rb_prepend_module): ditto.
* eval.c (rb_using_refinement): ditto.
* gc.c: Mark and free new wrapper struct.
* gc.c (obj_memsize_of): Count size of additional wrapper struct.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43973 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-03 08:11:07 +00:00
nobu c683096c90 vm_insnhelper.c: keyword hash functions
* vm_insnhelper.c (rb_extract_keywords, rb_check_keyword_opthash):
  extract from vm_callee_setup_keyword_arg.

* class.c (rb_scan_args): check if keys of keyword hash are symbols.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43934 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-30 12:22:17 +00:00
charliesome 8b0771b014 * class.c: unify names of vm state version counters to 'serial'.
This includes renaming 'vm_state_version_t' to 'rb_serial_t',
  'method_state' to 'method_serial', 'seq' to 'class_serial',
  'vmstat' to 'constant_serial', etc.

* insns.def: ditto
* internal.h: ditto
* vm.c: ditto
* vm_core.h: ditto
* vm_insnhelper.c: ditto
* vm_insnhelper.h: ditto
* vm_method.c: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-09 03:34:49 +00:00
charliesome 7fafa8f376 * insns.def, vm.c, vm_insnhelper.c, vm_insnhelper.h, vm_method.c: split
ruby_vm_global_state_version into two separate counters - one for the
  global method state and one for the global constant state. This means
  changes to constants do not affect method caches, and changes to
  methods do not affect constant caches. In particular, this means
  inclusions of modules containing constants no longer globally
  invalidate the method cache.

* class.c, eval.c, include/ruby/intern.h, insns.def, vm.c, vm_method.c:
  rename rb_clear_cache_by_class to rb_clear_method_cache_by_class

* class.c, include/ruby/intern.h, variable.c, vm_method.c: add
  rb_clear_constant_cache

* compile.c, vm_core.h, vm_insnhelper.c: rename vmstat field in
  rb_call_info_struct to method_state

* vm_method.c: rename vmstat field in struct cache_entry to method_state

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43455 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-29 00:52:38 +00:00
ko1 52c1331763 * class.c, variable.c, gc.c (rb_class_tbl): removed.
* vm.c, vm_core.h (rb_vm_add_root_module): added to register as a
  defined root module or class.
  This guard helps mark miss from defined classes/modules they are
  only refered from C's global variables in C-exts.
  Basically, it is extension's bug.
  Register to hash object VM has.
  Marking a hash objects allows generational GC supports.
* gc.c (RGENGC_PRINT_TICK): disable (revert).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43263 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-11 18:27:18 +00:00
ko1 9d70a17541 revert r43259 because it is possible to mark miss classes defined in C-exts. Thanks charliesome.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-11 18:03:43 +00:00
ko1 7aecb95637 * class.c, variable.c, gc.c (rb_class_tbl): removed.
rb_class_tbl is no longer used.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-11 17:33:44 +00:00
charliesome f088828106 * class.c (class_alloc): remove mc_tbl
* gc.c (obj_free): ditto

* internal.h (struct rb_classext_struct): ditto

* method.h (rb_method_entry): remove ent param

* vm_method.c: restore the global method cache. Per class cache tables
  turned out to be far too slow.

  [ruby-core:57289] [Bug #8930]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-24 05:02:13 +00:00
nobu 67129c8383 class.c: exclude refined methods
* class.c (method_entry_i): should exclude refined methods from
  instance method list.  [ruby-core:57080] [Bug #8881]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42903 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-10 03:39:31 +00:00
nobu bbbc8b57eb class.c: remove recursion
* class.c (rewrite_cref_stack): remove recursion.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-05 15:05:20 +00:00
nobu eeb39e0152 vm.c: prototype
* vm.c (rb_next_class_sequence): use ANSI style definition and
  prorotype declaration, instead of old-K&R style.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-04 07:18:24 +00:00
charliesome 2f522b9cc6 * class.c, compile.c, eval.c, gc.h, insns.def, internal.h, method.h,
variable.c, vm.c, vm_core.c, vm_insnhelper.c, vm_insnhelper.h,
  vm_method.c: Implement class hierarchy method cache invalidation.

  [ruby-core:55053] [Feature #8426] [GH-387]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-04 05:25:06 +00:00
ko1 9af743fe0e * class.c (rb_prepend_module): make T_ICLASS object shady because
this T_ICLASS object seems to share method table with other class
  objects. It was causes WB miss.
  TODO: need to know the data structure.
* test/ruby/test_module.rb: add a test for WB miss.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-12 06:19:15 +00:00
ko1 982fee4fcc * include/ruby/ruby.h, gc.c: rename macros and functions:
OBJ_WB_GIVEUP() -> OBJ_WB_UNPROTECT(),
  rb_obj_wb_giveup() -> rb_obj_wb_unprotect(),
  rb_gc_giveup_promoted_writebarrier() ->
  rb_gc_writebarrier_unprotect_promoted(),
* class.c, eval.c, hash.c: use OBJ_WB_UNPROTECT().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41582 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-22 21:54:10 +00:00
ko1 7da562e740 * class.c (rb_include_class_new), eval.c (rb_using_refinement):
make classes/modules (who share method table) shady.
  If module `a' and `b' shares method table m_tbl and new method
  with iseq is added, then write barrier is applied only `a' or `b'.
  To avoid this issue, shade such classes/modules.
* vm_method.c (rb_method_entry_make): add write barriers.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41580 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-22 20:48:35 +00:00
ko1 4223f00713 * include/ruby/ruby.h (OBJ_WRITE): cast to (VALUE *) for second
parameter `slot'. You don't need to write a cast (VALUE *) any more.
* class.c, compile.c, hash.c, iseq.c, proc.c, re.c, variable.c,
  vm.c, vm_method.c: remove cast expressions for OBJ_WRITE().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 19:52:40 +00:00
ko1 9b47ec04a8 * include/ruby/ruby.h (struct rb_data_type_struct), gc.c: add
rb_data_type_struct::flags. Now, this flags is passed
  at T_DATA object creation. You can specify FL_WB_PROTECTED
  on this flag.
* iseq.c: making non-shady iseq objects.
* class.c, compile.c, proc.c, vm.c: add WB for iseq objects.
* vm_core.h, iseq.h: constify fields to detect WB insertion.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41412 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-19 06:26:01 +00:00
ko1 87a120fbdc * class.c, include/ruby/ruby.h: add write barriers for T_CLASS,
T_MODULE, T_ICLASS.
* constant.h: constify rb_const_entry_t::value and file to detect
  assignment.
* variable.c, internal.h (rb_st_insert_id_and_value, rb_st_copy):
  added. update table with write barrier.
* method.h: constify some variables to detect assignment.
* object.c (init_copy): add WBs.
* variable.c: ditto.
* vm_method.c (rb_add_method): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-14 09:23:54 +00:00
shugo 1f828497d1 * safe.c (rb_set_safe_level, safe_setter): raise an ArgumentError
when $SAFE is set to 4.  $SAFE=4 is now obsolete.
  [ruby-core:55222] [Feature #8468]

* object.c (rb_obj_untrusted, rb_obj_untrust, rb_obj_trust):
  Kernel#untrusted?, untrust, and trust are now deprecated.
  Their behavior is same as tainted?, taint, and untaint,
  respectively.

* include/ruby/ruby.h (OBJ_UNTRUSTED, OBJ_UNTRUST): OBJ_UNTRUSTED()
  and OBJ_UNTRUST() are aliases of OBJ_TAINTED() and OBJ_TAINT(),
  respectively.

* array.c, class.c, debug.c, dir.c, encoding.c, error.c, eval.c,
  ext/curses/curses.c, ext/dbm/dbm.c, ext/dl/cfunc.c,
  ext/dl/cptr.c, ext/dl/dl.c, ext/etc/etc.c, ext/fiddle/fiddle.c,
  ext/fiddle/pointer.c, ext/gdbm/gdbm.c, ext/readline/readline.c,
  ext/sdbm/init.c, ext/socket/ancdata.c, ext/socket/basicsocket.c,
  ext/socket/socket.c, ext/socket/udpsocket.c,
  ext/stringio/stringio.c, ext/syslog/syslog.c, ext/tk/tcltklib.c,
  ext/win32ole/win32ole.c, file.c, gc.c, hash.c, io.c, iseq.c,
  load.c, marshal.c, object.c, proc.c, process.c, random.c, re.c,
  safe.c, string.c, thread.c, transcode.c, variable.c,
  vm_insnhelper.c, vm_method.c, vm_trace.c: remove code for
  $SAFE=4.

* test/dl/test_dl2.rb, test/erb/test_erb.rb,
  test/readline/test_readline.rb,
  test/readline/test_readline_history.rb, test/ruby/test_alias.rb,
  test/ruby/test_array.rb, test/ruby/test_dir.rb,
  test/ruby/test_encoding.rb, test/ruby/test_env.rb,
  test/ruby/test_eval.rb, test/ruby/test_exception.rb,
  test/ruby/test_file_exhaustive.rb, test/ruby/test_hash.rb,
  test/ruby/test_io.rb, test/ruby/test_method.rb,
  test/ruby/test_module.rb, test/ruby/test_object.rb,
  test/ruby/test_pack.rb, test/ruby/test_rand.rb,
  test/ruby/test_regexp.rb, test/ruby/test_settracefunc.rb,
  test/ruby/test_struct.rb, test/ruby/test_thread.rb,
  test/ruby/test_time.rb: remove tests for $SAFE=4.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-12 14:20:51 +00:00
charliesome b512e61ca0 * class.c (include_modules_at): invalidate method cache if included
module contains constants

* test/ruby/test_module.rb: add test

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-08 10:48:33 +00:00
ko1 83aba04862 * include/ruby/ruby.h: constify RBasic::klass and add
RBASIC_CLASS(obj) macro which returns a class of `obj'.
  This change is a part of RGENGC branch [ruby-trunk - Feature #8339].
* object.c: add new function rb_obj_reveal().
  This function reveal interal (hidden) object by rb_obj_hide().
  Note that do not change class before and after hiding.
  Only permitted example is:
  klass = RBASIC_CLASS(obj);
  rb_obj_hide(obj);
  ....
  rb_obj_reveal(obj, klass);
  TODO: API design. rb_obj_reveal() should be replaced with others.
  TODO: modify constified variables using cast may be harmful for
  compiler's analysis and optimizaton.
  Any idea to prohibt inserting RBasic::klass directly?
  If rename RBasic::klass and force to use RBASIC_CLASS(obj),
  then all codes such as `RBASIC(obj)->klass' will be
  compilation error. Is it acceptable? (We have similar
  experience at Ruby 1.9,
  for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)".
* internal.h: add some macros.
* RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal
  object.
* RBASIC_SET_CLASS(obj, cls) set RBasic::klass.
* RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS
  without write barrier (planned).
* RCLASS_SET_SUPER(a, b) set super class of a.
* array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c,
  file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c,
  parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c,
  string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c:
  Use above macros and functions to access RBasic::klass.
* ext/coverage/coverage.c, ext/readline/readline.c,
  ext/socket/ancdata.c, ext/socket/init.c,
* ext/zlib/zlib.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 10:49:11 +00:00
nobu 609c7420d7 class.c: rb_singleton_class_get
* class.c (rb_singleton_class_get): get the singleton class if exists,
  or nil.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 05:50:38 +00:00
nobu 111c791c37 class.c: adjust indent
* class.c (singleton_class_of): adjust indent.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40681 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 05:49:47 +00:00
nobu e8bdef657a class.c: include modules only
* class.c (rb_mod_included_modules): should not include non-modules.
  [ruby-core:53158] [Bug #8025]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-08 16:05:50 +00:00
nobu 3fd0000c0c class.c: exclude original module
* class.c (rb_mod_included_modules): should not include the original
  module itself.  [ruby-core:53158] [Bug #8025]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-08 13:47:11 +00:00
nobu 97982e823f id.def: predefined IDs
* defs/id.def: add more predefined IDs used in core.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40556 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-02 07:54:17 +00:00
nobu 6500760bd3 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40433 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-24 04:51:05 +00:00
zzak 0b4214ad9b * class.c: Example of Object#methods by @windwiny [Fixes GH-293]
* ruby.c: Document return values of Kernel #sub, #gsub, and #chop


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40432 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-24 04:47:31 +00:00
nobu c5fe7eb6f6 class.c: suppress wrong warning
* class.c (HAVE_METACLASS_P): should check FL_SINGLTON flag before get
  instance variable to get rid of wrong warning about __attached__.
  [ruby-core:53839] [Bug #8188]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-30 21:27:27 +00:00
nobu 99126a4c88 class.c: from the origin class
* class.c (rb_obj_singleton_methods): collect methods from the origin
  class.  [ruby-core:53207] [Bug #8044]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39744 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-13 06:13:08 +00:00
marcandre dfde34cb3c * class.c (rb_mod_ancestors): Include singleton_class in ancestors list
[Feature #8035]

* test/ruby/test_module.rb (class): test for above

* test/ruby/marshaltestlib.rb (module): adapt test

* NEWS: list change

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39628 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-07 17:54:49 +00:00
nobu f113ab552c class.c: check redefinition
* class.c (rb_prepend_module): check redefinition of built-in opimized
  methods.  [ruby-dev:47124] [Bug #7983]
* vm.c (rb_vm_check_redefinition_by_prepend): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39601 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-05 12:36:45 +00:00
nobu 632ab19c4d class.c: cyclic prepend
* class.c (include_modules_at): detect cyclic prepend with original
  method table.  [ruby-core:52205] [Bug #7841]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-14 02:08:31 +00:00
nobu ad6f06aed8 object.c: singleton class clone
* object.c (rb_obj_clone): attach clone to its singleton class during
  cloning singleton class so that singleton_method_added will be called
  on it.  based on the patch by shiba (satoshi shiba)[Bug #5283] in
  [ruby-dev:44477].  [Bug #5283]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38648 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-29 02:37:47 +00:00
charliesome a70bb8889b * class.c (rewrite_cref_stack, clone_method): rewrite a method's cref
stack when cloning into a new class to allow lexical const lookup to
  work as expected [ruby-core:47834] [Bug #7107]
* test/ruby/test_class.rb (class TestClass): related test

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38423 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-17 09:49:00 +00:00
nobu 3738ebe15a * object.c (Init_Object): no needs to override with same method.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38366 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-13 14:32:40 +00:00
charliesome c01f06089f * object.c (Init_Object): use rb_mod_init_copy for Class#initialize_copy
* class.c (rb_class_init_copy): rename to class_init_copy_check, performs type
	  checks on arguments to prevent reinitialization of initialized class
	  [ruby-core:50869] [Bug #7557]
	* class.c (rb_mod_init_copy): use class_init_copy_check if receiver is T_CLASS
	* test/ruby/test_class.rb (class TestClass): related test


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38364 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-13 14:11:01 +00:00
shugo 75bed271f0 * class.c (rb_prepend_module): move refined methods from the origin
of a class to the class, because refinements should have priority
  over prepended modules.

* test/ruby/test_refinement.rb: related test.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38344 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-12 09:35:50 +00:00
shugo 7ef16d224a * fix the behavior when a module is included into a refinement.
This change is a little tricky, so it might be better to prohibit
  module inclusion to refinements.

* include/ruby/ruby.h (RMODULE_INCLUDED_INTO_REFINEMENT): new flag
  to represent that a module (iclass) is included into a refinement.

* class.c (include_modules_at): set RMODULE_INCLUDED_INTO_REFINEMENT
  if klass is a refinement.

* eval.c (rb_mod_refine): set the superclass of a refinement to the
  refined class for super.

* eval.c (rb_using_refinement): skip the above superclass (the
  refined class) when creating iclasses for refinements.  Otherwise,
  `using Refinement1; using Refinement2' creates iclasses:
  <Refinement2> -> <RefinedClass> -> <Refinement1> -> RefinedClass,
  where <Module> is an iclass for Module, so RefinedClass is
  searched before Refinement1.  The correct iclasses should be
  <Refinement2> -> <Refinement1> -> RefinedClass.

* vm_insnhelper.c (vm_search_normal_superclass): if klass is an
  iclass for a refinement, use the refinement's superclass instead
  of the iclass's superclass.  Otherwise, multiple refinements are
  searched by super.  For example, if a refinement Refinement2
  includes a module M (i.e., Refinement2 -> <M> -> RefinedClass,
  and if refinements iclasses are <Refinement2> -> <M>' ->
  <Refinement1> -> RefinedClass, then super in <Refinement2> should
  use Refinement2's superclass <M> instead of <Refinement2>'s
  superclass <M>'.

* vm_insnhelper.c (vm_search_super_method): do not raise a
  NotImplementError if current_defind_class is a module included
  into a refinement.  Because of the change of
  vm_search_normal_superclass(), the receiver might not be an
  instance of the module('s iclass).

* test/ruby/test_refinement.rb: related test.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38298 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-10 16:05:45 +00:00
shugo 60d6038dda * revised r37993 to avoid SEGV/ILL in tests. In r37993, a method
entry with VM_METHOD_TYPE_REFINED holds only the original method
  definition, so ci->me is set to a method entry allocated in the
  stack, and it causes SEGV/ILL.  In this commit, a method entry
  with VM_METHOD_TYPE_REFINED holds the whole original method entry.
  Furthermore, rb_thread_mark() is changed to mark cfp->klass to
  avoid GC for iclasses created by copy_refinement_iclass().

* vm_method.c (rb_method_entry_make): add a method entry with
  VM_METHOD_TYPE_REFINED to the class refined by the refinement if
  the target module is a refinement.  When a method entry with
  VM_METHOD_TYPE_UNDEF is invoked by vm_call_method(), a method with
  the same name is searched in refinements.  If such a method is
  found, the method is invoked.  Otherwise, the original method in
  the refined class (rb_method_definition_t::body.orig_me) is
  invoked.  This change is made to simplify the normal method lookup
  and to improve the performance of normal method calls.

* vm_method.c (EXPR1, search_method, rb_method_entry),
  vm_eval.c (rb_call0, rb_search_method_entry): do not use
  refinements for method lookup.

* vm_insnhelper.c (vm_call_method): search methods in refinements if
  ci->me is VM_METHOD_TYPE_REFINED.  If the method is called by
  super (i.e., ci->call == vm_call_super_method), skip the same
  method entry as the current method to avoid infinite call of the
  same method.

* class.c (include_modules_at): add a refined method entry for each
  method defined in a module included in a refinement.

* class.c (rb_prepend_module): set an empty table to
  RCLASS_M_TBL(klass) to add refined method entries, because
  refinements should have priority over prepended modules.

* proc.c (mnew): use rb_method_entry_with_refinements() to get
  a refined method.

* vm.c (rb_thread_mark): mark cfp->klass for iclasses created by
  copy_refinement_iclass().

* vm.c (Init_VM), cont.c (fiber_init): initialize th->cfp->klass.

* test/ruby/test_refinement.rb (test_inline_method_cache): do not skip
  the test because it should pass successfully.

* test/ruby/test_refinement.rb (test_redefine_refined_method): new
  test for the case a refined method is redefined.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-06 13:08:41 +00:00
shugo 9e44974874 * revert r37993 to avoid SEGV in tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38022 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-30 02:11:59 +00:00
shugo 421314cf4e * vm_method.c (rb_method_entry_make): add a method entry with
VM_METHOD_TYPE_REFINED to the class refined by the refinement if
  the target module is a refinement.  When a method entry with
  VM_METHOD_TYPE_UNDEF is invoked by vm_call_method(), a method with
  the same name is searched in refinements.  If such a method is
  found, the method is invoked.  Otherwise, the original method in
  the refined class (rb_method_definition_t::body.orig_def) is
  invoked.  This change is made to simplify the normal method lookup
  and to improve the performance of normal method calls.

* vm_method.c (EXPR1, search_method, rb_method_entry),
  vm_eval.c (rb_call0, rb_search_method_entry): do not use
  refinements for method lookup.

* vm_insnhelper.c (vm_call_method): search methods in refinements if
  ci->me is VM_METHOD_TYPE_REFINED.  If the method is called by
  super (i.e., ci->call == vm_call_super_method), skip the same
  method entry as the current method to avoid infinite call of the
  same method.

* class.c (include_modules_at): add a refined method entry for each
  method defined in a module included in a refinement.

* class.c (rb_prepend_module): set an empty table to
  RCLASS_M_TBL(klass) to add refined method entries, because
  refinements should have priority over prepended modules.

* proc.c (mnew): use rb_method_entry_with_refinements() to get
  a refined method.

* test/ruby/test_refinement.rb (test_inline_method_cache): do not skip
  the test because it should pass successfully.

* test/ruby/test_refinement.rb (test_redefine_refined_method): new
  test for the case a refined method is redefined.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37993 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29 12:50:10 +00:00
ko1 f3e5f2cd75 * bignum.c (bignew_1): Bignum instances are frozen.
Feature #3222
* include/ruby/ruby.h: Fixnum instances are also frozen.
* class.c (singleton_class_of): check Bignum before
  singleton cheking.
* test/ruby/test_bignum.rb: add a test.
* test/ruby/test_fixnum.rb: ditto.
* test/ruby/marshaltestlib.rb, test/ruby/test_eval.rb,
  test/ruby/test_object.rb: catch up above changes.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37348 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-28 00:03:20 +00:00
ko1 180c744b3b * numeric.c (rb_float_new_in_heap), include/ruby/ruby.h:
make all Float objects frozen.
  [ruby-dev:46081] [ruby-trunk - Feature #6936]
  Most part of patch by NARUSE, Yui  <naruse@ruby-lang.org>.
* class.c (singleton_class_of): raise TypeError when
  trying to define a singleton method on Float objects.
* vm.c (vm_define_method): ditto.
* test/ruby/marshaltestlib.rb: catch up above changes.
* test/ruby/test_class.rb: ditto.
* test/test_pp.rb: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37341 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-27 02:10:53 +00:00
ko1 9dc3a7d7a5 * include/ruby/ruby.h, class.c: remove (revert)
`rb_add_method_cfunc_frameless()' API.
  This API is not mature to become an offical API.
  For example, we can not use this API with
  `rb_define_private_method()'.
* method.h, vm_method.c (rb_add_method_cfunc_frameless): removed.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37320 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-25 06:03:53 +00:00
nari c3a46d6aca * include/ruby/ruby.h: add C APIs.
VALUE rb_newobj_of(VALUE klass, VALUE flags)
  #define NEWOBJ_OF(obj,type,klass,flags)
  These allow to change a allocation strategy depending on klass
  or flags.

* gc.c: ditto

* array.c: use new C API.
* bignum.c: ditto
* class.c: ditto
* complex.c: ditto
* ext/socket/ancdata.c: ditto
* ext/socket/option.c: ditto
* hash.c: ditto
* io.c: ditto
* marshal.c: ditto
* numeric.c: ditto
* object.c: ditto
* random.c: ditto
* range.c: ditto
* rational.c: ditto
* re.c: ditto
* string.c: ditto
* struct.c: ditto
  [Feature #7177][Feature #7047]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37275 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-20 06:57:51 +00:00
ko1 588b73bca2 * class.c (rb_define_frameless_method): rename from
rb_define_method_fast(). Defined method with this C API
  does not make a method frame. It is bit lightweight than
  ordinal C functions. Now only 0 or 1 argc are permitted.
* method.h (VM_METHOD_TYPE_CFUNC_FRAMELESS): rename macro name
  from VM_METHOD_TYPE_CFUNC_FAST.
* vm_insnhelper.c, vm_method.c: rename related functions.
* proc.c (rb_method_entry_arity): catch up above changes.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37252 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-18 05:22:13 +00:00
ko1 90a6dce041 * method.h: introduce new method type VM_METHOD_TYPE_CFUNC_FAST.
This method is similar to VM_METHOD_TYPE_CFUNC methods, but
  called cfunc without building new frame (does not push new control
  frame). If error is occured in cfunc, the backtrace only shows
  caller frame and upper.
  This kind of methods can be added by rb_define_method_fast().
  This feature is similar to specialized instructions (opt_plus, etc),
  but more flexible (but a bit slower).
* class.c (rb_define_method_fast): added.
  Maybe it will be renamed soon.
* vm_insnhelper.c (vm_call_method): support method type
  VM_METHOD_TYPE_CFUNC_FAST.
* proc.c (rb_method_entry_arity): catch up new method type.
* vm_method.c (rb_add_method_cfunc_fast): added.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-15 21:24:08 +00:00
nobu 5fbfc21b67 internal.h: allocator function in rb_classext_t
* internal.h (struct rb_classext_struct): move allocator function into
  rb_classext_t from ordinary method table.  [ruby-dev:46121]
  [Feature #6993]
* object.c (rb_obj_alloc): call allocator function directly.
* vm_method.c (rb_define_alloc_func, rb_undef_alloc_func)
  (rb_get_alloc_func): use allocator function in rb_classext_t.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36925 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-08 09:52:26 +00:00
usa 6a80947a4b * class.c (singleton_class_of): flonum can't have singleton class.
* vm.c (vm_define_method): flonum can't have singleton method.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36803 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-23 11:36:42 +00:00
nobu 28827e61d1 method in instance_eval
* class.c (rb_special_singleton_class_of): utility function.
* vm_eval.c (eval_under): special deal for class variable scope with
  instance_eval.
* vm_eval.c (rb_obj_instance_eval, rb_obj_instance_exec): allow method
  definition in instance_eval of special constants.  [ruby-core:28324]
  [Bug #2788]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36647 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-06 15:31:13 +00:00
shugo 9537e8ffe5 * internal.h, class.c, eval.c, insns.def: find the appropriate
receiver for super called in instance_eval.  If such a receiver is
  not found, raise NoMethodError. [ruby-dev:39772] [Bug #2402]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-06 07:00:19 +00:00
shugo 19ddfc2483 * eval.c (rb_mod_using): new method Module#using. [experimental]
* eval.c (rb_mod_refine): new method Module#refine. [experimental]

* eval.c (f_using): new method Kernel#using. [experimental]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36596 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-02 11:34:19 +00:00
shugo 319088e9c7 * class.c, insns.def, method.h, proc.c, vm.c, vm_core.h, vm_eval.c,
vm_insnhelper.c, vm_insnhelper.h, vm_method.c: add klass to
  rb_control_frame_t to implement super correctly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-02 11:08:44 +00:00
nobu b283d01987 class.c: fix duplication of prepended module
* class.c (include_class_new): fix duplication of prepended module.
  since m_tbl of prepended module is always zero, copy from its
  copy iclass of original.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36585 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-31 15:33:23 +00:00
nobu edb1fc4eb2 prepend: fix mixing with include
* class.c (rb_include_module): include modules after the origin.
* class.c (include_modules_at): skip prepended modules.
* class.c (rb_prepend_module): now basic.klass in ICLASS refers the
  old original class/module.  [ruby-dev:45868][Bug #6662]
* class.c (rb_mod_ancestors): ditto.
* vm_method.c (search_method): search method entry from the origin
  iclass.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36266 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-02 08:06:37 +00:00
nagachika 912df4b615 * class.c (class_instance_method_list): consider prepended Class/Module
when recur != 0. [ruby-dev:45863] [Bug #6660]

* test/ruby/test_module.rb (test_prepend_instance_methods_false): add
  a test for it.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-28 00:39:52 +00:00
nobu 3f3225905b prepend: fix ancestors order
* class.c (rb_mod_ancestors): fix ancestors order.
  [ruby-core:45919][Bug #6658] [ruby-dev:45861][Bug #6659]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36241 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-27 21:12:46 +00:00
nobu d4269d7b7c fix null m_tbl
* class.c (rb_obj_singleton_methods): m_tbl in prepended class/module
  is NULL.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-27 13:40:34 +00:00
nobu cf3a8f09b8 ancestor modules
* class.c (rb_prepend_module): ancestors of prepending module also
  should be included.  [ruby-core:45914][Bug #6654]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-27 12:31:17 +00:00
nobu 48c04ad0d8 fix null m_tbl
* class.c (class_instance_method_list): m_tbl in prepended
  class/module is NULL.  [ruby-core:45915][Bug #6655]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-27 12:01:39 +00:00
nobu 8ddbbb3324 Module#prepend
* class.c (rb_prepend_module): prepend module into another module.
* eval.c (rb_mod_prepend): new method Module#prepend.  [Feature #1102]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-27 07:48:50 +00:00
nobu ffa20cf154 use rb_check_hash_type
* class.c (rb_scan_args): use rb_check_hash_type.
* process.c (rb_exec_getargs): ditto.
* sprintf.c (get_hash): ditto.
* string.c (rb_str_sub_bang, str_gsub): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-26 07:46:24 +00:00
nobu 82a408fb9d Revert r31873 Module#mix
* class.c (rb_mix_module): revert Module#mix.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36216 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-25 08:49:32 +00:00
drbrain 1d4e7d9232 * class.c (rb_mod_init_copy): Clear the cached inspect string of a
dup'd anonymous module or class.  [ruby-trunk - Bug #6454]
* test/ruby/test_module.rb (class TestModule):  ditto


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35759 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-22 20:15:28 +00:00
nobu 57fb219905 * reduce UNREACHABLE.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-15 00:06:13 +00:00
drbrain da39d32f60 * encoding.c (rb_enc_codepoint_len): Use UNREACHABLE to avoid "control
reaches end of non-void function" warnings.  [ruby-trunk - Bug #6066]
* re.c (name_to_backref_number):  ditto.
* object.c (rb_Float):  ditto.
* io.c (io_readpartial):  ditto.
* io.c (io_read_nonblock):  ditto.
* pack.c (rb_uv_to_utf8):  ditto.
* proc.c (rb_method_entry_arity):  ditto.
* vm_method.c (rb_f_notimplement):  ditto.
* struct.c (rb_struct_aset_id):  ditto.
* class.c (rb_scan_args):  ditto.
* process.c (rlimit_resource_type):  ditto.
* process.c (rlimit_resource_value):  ditto.
* process.c (p_uid_switch):  ditto.
* process.c (p_gid_switch):  ditto.
* ext/digest/digest.c (rb_digest_instance_update):  ditto.
* ext/digest/digest.c (rb_digest_instance_finish):  ditto.
* ext/digest/digest.c (rb_digest_instance_reset):  ditto.
* ext/digest/digest.c (rb_digest_instance_block_length):  ditto.
* ext/bigdecimal/bigdecimal.c (BigDecimalCmp):  ditto.
* ext/dl/handle.c (rb_dlhandle_close):  ditto.
* ext/tk/tcltklib.c (pending_exception_check0):  ditto.
* ext/tk/tcltklib.c (pending_exception_check1):  ditto.
* ext/tk/tcltklib.c (ip_cancel_eval_core):  ditto.
* ext/tk/tcltklib.c (lib_get_reltype_name):  ditto.
* ext/tk/tcltklib.c (create_dummy_encoding_for_tk_core):  ditto.
* ext/tk/tkutil/tkutil.c (tk_hash_kv):  ditto.
* ext/openssl/ossl_ssl.c (ossl_ssl_session_reused):  ditto.
* ext/openssl/ossl_pkey_ec.c (ossl_ec_key_dsa_verify_asn1):  ditto.
* ext/openssl/ossl_pkey_ec.c (ossl_ec_point_is_at_infinit):  ditto.
* ext/openssl/ossl_pkey_ec.c (ossl_ec_point_is_on_curve):  ditto.
* ext/fiddle/conversions.c (generic_to_value):  ditto.
* ext/socket/raddrinfo.c (rsock_io_socket_addrinfo):  ditto.
* ext/socket/socket.c (sock_s_getnameinfo):  ditto.
* ext/ripper/eventids2.c (ripper_token2eventid):  ditto.
* cont.c (return_fiber):  ditto.
* dmydln.c (dln_load):  ditto.
* vm_insnhelper.c (vm_search_normal_superclass):  ditto.
* bignum.c (big_fdiv):  ditto.
* marshal.c (r_symlink):  ditto.
* marshal.c (r_symbol):  ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35321 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-13 23:45:37 +00:00
marcandre 7316302483 * include/ruby/intern.h: Add rb_check_arity, rb_error_arity [#6085]
* array.c: Use rb_check_arity / rb_error_arity

* class.c: ditto

* enumerator.c: ditto

* eval.c: ditto

* file.c: ditto

* hash.c: ditto

* numeric.c: ditto

* proc.c: ditto

* process.c: ditto

* random.c: ditto

* re.c: ditto

* signal.c: ditto

* string.c: ditto

* struct.c: ditto

* transcode.c: ditto

* vm_eval.c: ditto

* vm_insnhelper.c: ditto & implementation of rb_error_arity

* test/ruby/test_arity.rb: tests for above

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-14 21:10:34 +00:00
nari 50675fdba1 * gc.c: use Bitmap Marking algorithm to avoid copy-on-write of
memory pages. See [ruby-dev:45085] [Feature #5839]
  [ruby-core:41916].

* include/ruby/ruby.h : FL_MARK rename to FL_RESERVED1.

* node.h : ditto.

* debug.c : ditto.

* object.c (rb_obj_clone): FL_MARK move to a bitmap.

* class.c (rb_singleton_class_clone): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-07 14:02:23 +00:00
nobu 8baffe6ef6 * class.c (rb_obj_methods), compile.c (iseq_compile_each),
iseq.c(iseq_load, rb_iseq_parameters), pack.c (pack_pack),
  regcomp.c (is_not_included, update_string_node_case_fold),
  transcode.c (rb_econv_open0, make_replacement),
  vm_eval.c (raise_method_missing): remove unused variable.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33950 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-05 09:50:12 +00:00
naruse 6e56d645f0 * lib/delegate.rb (Delegator#methods): Kernel#methods receives
zero or one argument. [ruby-core:37118] [Bug #4882]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33939 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-04 03:05:03 +00:00
nobu 92a05ea2cf * class.c (class_alloc): allocate extra memory after containing
object setup to get rid of rare-but-potential memory leak.
* gc.c (gc_mark_children): skip marking extended members if ptr is
  NULL.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33400 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-04 12:10:09 +00:00
naruse 0688c81a89 Revert r33397 because it cause segv.
"* class.c (class_alloc): allocate extra memory after containing"

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-04 09:44:08 +00:00
nobu bf8168cf33 * class.c (class_alloc): allocate extra memory after containing
object setup to get rid of rare-but-potential memory leak.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33397 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-04 06:04:46 +00:00
nobu 8e6e8e6288 * use RB_TYPE_P which is optimized for constant types, instead of
comparison with TYPE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-29 11:07:45 +00:00
matz 8fca66d7eb * class.c (Init_class_hierarchy): should name BasicObject
explicitly.

* variable.c (rb_const_defined_0): should not check for
  superclasses as const_get.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32342 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-30 18:34:09 +00:00
akr e7996eb3cc * internal.h: declare internal functions here.
* 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-06-17 22:43:38 +00:00
nobu 83ef8ee73e clone_const_i
* class.c (clone_const_i, class_instance_method_list): get rid of
  type-punning function.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31919 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-04 03:49:50 +00:00
nobu 40930b7144 * class.c (check_mix_method_i, do_mix_method_i): not mix methods
renamed as nil.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31917 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-04 02:30:59 +00:00
nobu 604fe33b44 * class.c (rb_mix_module): implement Module#mix.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-31 16:16:06 +00:00
nobu 52f5f410e4 * internal.h: add for internal use only.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-18 13:41:54 +00:00
matz 1df42597d1 cancel subversion backfire. sorry
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31046 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-07 08:44:45 +00:00
matz eb807d42ec * gc.c (rb_gc_set_params): allow GC parameter configuration by
environment variables.  based on a patch from funny-falcon at
  https://gist.github.com/856296, but honors safe level.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-07 08:39:39 +00:00
naruse 18f4f08885 * class.c: fix camelCase to snake_case in documentation code examples.
patched by Andrew Grimm. fixes Bug #4469

* marshal.c: ditto.

* proc.c: ditto.

* sample/biorhythm.rb: ditto.

* vm_eval.c: ditto.

* vm_method.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31031 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-05 20:25:08 +00:00
nagachika c8e5ba0e84 * class.c (clone_method): add GC guard to prevent intermediate
variable from GC. [Bug #4321] [ruby-dev:43107]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-01-26 13:59:20 +00:00
nobu 1a3f4dbafa * class.c (make_metaclass): fix probable typo. builtin type flag
cannot be used with FL_TEST.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30086 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-05 08:56:42 +00:00
akr 5c6b43d91e * class.c: parenthesize macro arguments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30077 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-04 02:18:42 +00:00
usa 6223582f2a * class.c (clone_const): need to return value. fix r29602.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29606 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-27 03:06:27 +00:00
mame a115768161 * class.c, constant.h, gc.c, method.h, object.c, variable.c,
vm_insnhelper.c: use struct rb_constant_entry_t as entry of
  RCLASS_CONST_TBL.  RCLASS_CONST_TBL has contained VALUE of constant
  directly.  Now instead rb_const_entry_t is contained in
  RCLASS_CONST_TBL,  rb_const_entry_t is managed by malloc, and
  have not only the value itself but also visibility flag.
  This is another preparation for private constant (see
  [ruby-dev:39685][ruby-core:32698]).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29602 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-26 17:27:32 +00:00
mame 2285a8d813 * class.c, gc.c, object.c, variable.c, vm_insnhelper.c,
include/ruby/ruby.h: separate RCLASS_CONST_TBL from RCLASS_IV_TBL.
  RCLASS_IV_TBL has contained not only instance variable table but
  also constant table.  Now the two table are separated to
  RCLASS_CONST_TBL and RCLASS_IV_TBL.  This is a preparation for
  private constant (see [ruby-dev:39685][ruby-core:32698]).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29600 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-26 17:27:21 +00:00
nobu 137d82569f * class.c (rb_define_{class,module}_id_under): register to be
marked, which probably are defined and used internally.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-17 01:40:22 +00:00
nobu 7735e63593 * array.c (rb_ary_and, rb_ary_or), class.c (rb_mod_init_copy),
gc.c (undefine_final), time.c (time_mload): get rid of
  type-punning casts.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-13 22:22:18 +00:00
nobu cea3919ae6 * configure.in (RUBY_CHECK_PRINTF_PREFIX): check for printf format
specifier if possible.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-12 15:03:51 +00:00
knu 82abe79b9f * class.c (rb_scan_args): Add support for optional keyword
argument hash.

* README.EXT, README.EXT.ja: Update documentation accordingly.

* dir.c (dir_initialize): Make use of the new rb_scan_args()
  feature.

* io.c (rb_io_s_popen, rb_scan_open_args, rb_io_initialize)
  (rb_io_s_pipe, open_key_args, io_s_foreach, io_s_readlines)
  (rb_io_s_read, rb_io_set_encoding): Ditto.

* transcode.c (str_transcode, econv_args)
  (econv_primitive_convert): Ditto.

* ext/zlib/zlib.c (rb_gzreader_initialize): Ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-09-10 07:51:58 +00:00
akr a35c3cf341 * class.c (rb_include_module): don't clear the method cache if the
included module has no method.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28813 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-01 00:46:18 +00:00
naruse 7175a9073e * class.c, compile.c, dir.c, file.c, iseq.c, parse.y, random.c:
clean unused-value warnings.

* cont.c, process.c, vm_exec.h: clean cast warnings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28762 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-07-27 07:13:43 +00:00
mame 9b94dabe77 * class.c (rb_mod_init_copy): when class is dup'ed, a metaclass of the
class should be attached to the dup'ed class, not the original
  class.  [ruby-core:30843] [Bug #3461]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28453 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-06-27 17:47:21 +00:00
marcandre 52ebd4b7f4 * class.c: rdoc fix [ruby-core:30449]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28379 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-06-22 04:52:03 +00:00
mame d35f8ea885 * object.c: Object#public_methods, private_methods, etc. returns
method ids that belong to the class or the singleton class(es) of
  the object.  [ruby-dev:41613]

* class.c: on the other hand, Module#public_instance_methods, etc.
  returns method ids that belong to the module itself (even if the
  module is singleton, it does not return method ids of super
  class(es); see [ruby-core:28837]).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-06-17 16:58:25 +00:00
nobu 45f6fbf339 * removed trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28085 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-29 18:51:39 +00:00
nari ca64478089 * gc.c : use simple lazy sweep algorithm for response performance
gain. See [ruby-dev:41067].

* object.c: FL_MARK of some objects by lazy sweep is copied when
  RVALUE is cloned. These objects are not marked in the mark phase.
  So delete FL_MARK.

* class.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-28 11:13:42 +00:00
marcandre 7729de4d91 * array.c: Documentation: change => in call-seq to ->.
Harmonize "#=>" in examples. [ruby-core:30206]

* bignum.c: ditto

* class.c: ditto

* compar.c: ditto

* cont.c: ditto

* dir.c: ditto

* encoding.c: ditto

* enum.c: ditto

* enumerator.c: ditto

* error.c: ditto

* eval.c: ditto

* file.c: ditto

* gc.c: ditto

* io.c: ditto

* load.c: ditto

* marshal.c: ditto

* math.c: ditto

* numeric.c: ditto

* object.c: ditto

* pack.c: ditto

* proc.c: ditto

* process.c: ditto

* random.c: ditto

* range.c: ditto

* re.c: ditto

* ruby.c: ditto

* signal.c: ditto

* sprintf.c: ditto

* string.c: ditto

* struct.c: ditto

* thread.c: ditto

* time.c: ditto

* transcode.c: ditto

* variable.c: ditto

* vm_eval.c: ditto

* vm_method.c: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-17 21:07:33 +00:00
ko1 b4d7d616d9 * method.h, vm_method.c: rename some internal functions related to
rb_method_entry_t.
  rb_add_method_me()        -> rb_method_entry_set().
  rb_get_method_entry()     -> rb_method_entry_without_cache().
  rb_gc_mark_method_entry() -> rb_mark_method_entry().
* class.c, proc.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-04 20:25:09 +00:00
shyouhei d894e1d930 instance_methods should not special-case singleton classes, fixes #2993
Signed-off-by: URABE, Shyouhei <shyouhei@ruby-lang.org>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27085 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-03-29 05:59:46 +00:00
shugo b09eabd430 * class.c (rb_class_init_copy): raise a TypeError if the argument is
BasicObject.  [ruby-core:27060]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-02-06 15:26:34 +00:00
marcandre fb2941a4ec * object.c (rb_class_initialize): Make sure BasicObject doesn't get initialized twice [ruby-core:27577]
* class.c (rb_class_init_copy): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26314 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-01-13 02:57:48 +00:00
nobu b4da253400 * class.c (rb_define_class): raise TypeError same as class
statement.  [ruby-core:27504]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-01-09 19:54:38 +00:00
mame 4a761c3209 * class.c (rb_mod_init_copy): fix memory leak of Class#dup.
[ruby-dev:39687]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-14 12:56:16 +00:00
akr b9e0294eda fix typos.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-03 17:46:28 +00:00
matz 5d6440c748 * class.c (rb_class_new): move class check to rb_check_inheritable().
* class.c (rb_check_inheritable): should not allow subclass of
  class Class.  [ruby-core:26225]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25449 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-23 23:37:14 +00:00
usa 359d932332 * class.c (rb_obj_basic_to_s_p): typo. Please become familiar with
the ANSI style. 



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25436 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-22 12:12:24 +00:00
matz 7eac66b9c6 * object.c (rb_obj_inspect): print instance variables only when
Object#to_s is not overridden.  [ruby-core:24425]

* class.c (rb_obj_basic_to_s_p): new function.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-21 20:17:27 +00:00
yugui 9b062c9685 * class.c (make_singleton_class): variable name changed.
removed an unnecessary conditional.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24721 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-31 07:21:54 +00:00
yugui e056ac59a7 * class.c: refactored singleton class related matters.
Handles eigenclasses and plain classes transparently.

  (make_metaclass): renamed from make_metametaclass.
  (METACLASS_OF): new utility macro
  (META_CLASS_OF_CLASS_CLASS): ditto.
  (ENSURE_EIGENCLASS): ditto.
  (make_singleton_class): extracted from rb_singleton_class.
  (boot_defclass): moved from object.c
  (Init_class_hierarchy): extracted from Init_Object.
  (rb_make_metaclass): refactored.
  (singleton_class_of): extracted from rb_singleton_class.
  (rb_singleton_class): refactored.
  (rb_define_singleton_method): it needs a metaclass only
  but not its metametaclass.

* object.c: booting class hierarchy was moved to class.c
  for keeping dependency between compilation units least.
  (Init_Object): extracting the booting into
  Init_class_hierarchy.
  (boot_defclass): moved to class.c.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24720 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-31 05:55:57 +00:00
yugui ebabbc6cb9 Doxygen comment.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-29 13:39:44 +00:00
nobu fcf88c1b8d * method.h (rb_method_definition_t): split from rb_method_entry_t
to deal aliases.  [ruby-dev:39165]

* proc.c (struct METHOD): contains rb_method_entry_t copy.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-28 02:45:41 +00:00
naruse 054770068a * class.c (rb_define_module_id_under): fix the name.
* class.c (rb_define_module_under): fix for prevvious changes.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-12 06:54:45 +00:00
nobu 31f4a82942 * class.c (rb_define_class_id_under, rb_define_module_id_under):
new functions to define a nested class/module with non-ascii
  name.

* struct.c (make_struct): use name with encoding.

* struct.c (inspect_struct): ditto.  [ruby-core:24849]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24513 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-12 06:32:21 +00:00
nobu e07cb859cc * suppressed shorten-64-to-32 warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-18 08:05:32 +00:00
ko1 c330876d7c * method.h, vm_core.h: add rb_method_entry_t. Remove nodes around
method management.  This change affect some VM control stack structure.
* vm.c, vm_insnhelper.c, vm_method.c, vm_eval.c: ditto.  and make some
  refactoring.
* insns.def, class.c, eval.c, proc.c, vm_dump.c : ditto.
* vm_core.h, compile.c (iseq_specialized_instruction): remove
  VM_CALL_SEND_BIT.  use another optimization tech for Kernel#send.
* node.h: remove unused node types.
* ext/objspace/objspace.c (count_nodes): ditto.
* gc.c: add mark/free functions for method entry.
* include/ruby/intern.h: remove decl of
  rb_define_notimplement_method_id().  nobody can use it
  because noex is not opend.
* iseq.c (iseq_mark): fix to check ic_method is available.
* iseq.c (rb_iseq_disasm): fix to use rb_method_get_iseq().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-15 14:59:41 +00:00
yugui 2d42e704f4 Doxy-comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23902 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-29 16:39:28 +00:00
matz 4d4bd7ab95 * class.c (clone_method): add cast to remove warning from
rb_gc_write_barrier().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23489 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-19 05:00:19 +00:00
matz 7d1f48b5c3 * struct.c (struct_ivar_get): new function to avoid repeated
rb_intern() calls.

* struct.c (rb_struct_iv_get): use struct_ivar_get()

* struct.c (num_members): ditto.

* struct.c (rb_struct_s_members): ditto.

* class.c (rb_singleton_class): cache symbol to reduce calls to
  rb_intern().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23488 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-19 04:58:36 +00:00
nari 57b83a5191 * gc.c: add longlife garbage collection. [ruby-dev:38423]
(NORMAL_HEAPS_USED): new macro.
  (LONGLIFE_ALLOCATE_HEAPS_MIN): ditto.
  (add_longlife_heaps_slot): new function.
  (rb_newobj_from_longlife_heap): ditto.
  (rb_newobj_longlife): ditto.
  (rb_node_newnode_longlife): ditto.
  (rb_gc_write_barrier): ditto.
  (remembered_set_recycle): ditto.
  (rb_gc_mark_remembered_set): ditto.
  (clear_mark_longlife_heaps): ditto.
  (gc_sweep_for_longlife): ditto.
  (assign_heap_slot): new argumnent to longlife heaps slot.
  (add_freelist): ditto.
  (gc_sweep): avoid lonlife heap slot. set longlife_collection
   flag at add heap.
  (rb_gc_force_recycle): avoid mark object and remembered_set
   object.
  (garbage_collect): add longlife collection.
  (rb_gc_start): invoke longlife collection.
  (gc_profile_record_get): for longlife collction profile.
  (gc_profile_result): ditto.

* include/ruby/intern.h (rb_gc_write_barrier): declared.

* include/ruby/ruby.h (FL_REMEMBERED_SET): renamed from FL_RESERVED.

* debug.c (FL_REMEMBERED_SET): ditto.

* insns.def (setinlinecache): insert write barrier.

* vm_insnhelper.c (vm_method_search): ditto.

* set_relation (set_relation): use longlife object.

* vm.c (vm_define_method): ditto.

* vm_core.h (NEW_INLINE_CACHE_ENTRY): ditto.

* vm_method.c (rb_add_method): ditto.

* class.c (rb_add_method): ditto.

* node.h (NEW_NODE_LONGLIFE): new macro.
  (rb_node_newnode_longlife): declared.
					    


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23421 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-13 14:08:26 +00:00
akr 8b27d153d2 * class.c (rb_define_method_id): use rb_define_notimplement_method_id
if rb_f_notimplement is given.
  (rb_define_protected_method): ditto.
  (rb_define_private_method): ditto.
  (rb_define_method): use rb_define_method_id.

* include/ruby/intern.h (rb_f_notimplement): declared.
  (rb_define_notimplement_method_id): declared.

* proc.c (method_inspect): show not-implemented.

* vm_method.c (notimplement_body): new variable.
  (rb_notimplement_body_p): new function.
  (rb_method_boundp): return false if not implemented.
  (rb_f_notimplement): new function.
  (rb_define_notimplement_method_id): new function.

* process.c (rb_f_fork): use rb_f_notimplement if not implemented.

* file.c (rb_file_s_lchmod): use rb_f_notimplement if not implemented.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-04-16 14:17:14 +00:00
nobu ffbaa25b62 * class.c: fixed indent.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22923 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-03-13 05:55:13 +00:00
knu 400ded9338 * class.c (rb_scan_args): Allow specifying the number of trailing
mandatory arguments right after the number of optional arguments
  only if the number of leading mandatory arguments is not omitted.

* ext/socket/tcpserver.c (tcp_svr_init): Make use of it.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-24 15:41:39 +00:00
knu ca292099a6 * class.c (rb_scan_args): Revamp rb_scan_args() to compute the
number of required and optional arguments precisely to prepare
  for a more informative error message.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22601 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-24 15:15:25 +00:00
nobu 12d2c8ba41 stripped trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22552 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-22 14:23:33 +00:00
knu f5ca95ee10 * class.c (rb_scan_args), README.EXT, README.EXT.ja: Add support
for specifying the number of the trailing mandatory arguments.
  Update the documents accordingly. [ruby-dev:37995]




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22339 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-16 08:04:56 +00:00
yugui 3a5c0bbcb5 * test/ruby/test_metaclass.rb: new test case for metaclass hierarchy.
* class.c (make_metametaclass): new function. extracted from
  rb_make_metaclass.

* class.c (rb_make_metaclass): uses make_metametaclass when called for a
  metaclass.

* class.c (rb_singleton_class): creates a meta^(n+2)-class in
  addition to a meta^(n+1)-class when called for a meta^(n)-class.
  This is because the returned meta^(n+1) class must acts as an instance of 
  Class, metaclass of Class, ..., meta^(n+1)-class of Class,
  Module, metaclass of Module, ..., meta^(n+1)-class of Module,
  Object, metaclass of Object, ..., meta^(n+2)-class of Object,
  BasicObject, metaclass of BasicObject, ..., meta^(n+2)-class of
  and BasicObject even when Class, Module, Object or BasicObject has
  not have its meta^(i)-class yet.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-15 06:23:43 +00:00
matz 06151d4a99 * class.c (rb_class_instance_methods): rdoc fixed. [ruby-core:19458]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19900 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-23 08:30:52 +00:00
yugui 7a86a81dcc * class.c (rb_make_metaclass): [BUG] Fixed a bus error
on the case for metaclass of a class which includes a
  module.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19550 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-25 11:31:02 +00:00
yugui 788001a9c8 * class.c (rb_make_metaclass): Made class of class of class
from Class into its own eigenclass. Now meta^(n)-class
  hierarchy regresses infinitely, again.
  (This feature was decided on developer-meeting-20080922.)

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19546 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-25 09:46:59 +00:00
ko1 2e311f6bd5 * include/ruby/node.h, node.h: move node.h from include path.
This change stop to install node.h beacuase of saving ABI
  (node.h will be changed. Extensions should not depends on
  this file).
* blockinlining.c, class.c, compile.c, debug.h, enum.c,
  gc.c, iseq.c, parse.y, ruby.c, signal.c, variable.c,
  vm.c, vm_core.h, vm_dump.c: ditto.
* ext/ripper/depend: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 19:52:31 +00:00
ko1 68a533c611 * class.c, vm_core.h: move decl of rb_iseq_clone() to class.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19476 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 08:10:20 +00:00
ko1 7f7834abf7 * include/ruby/node.h, vm_core.h: move definition of
RUBY_VM_METHOD_NODE to node.h.
* class.c, common.mk: remove useless inclusion.
* compile.h, iseq.h, vm_core.h: rename compile.h to iseq.h.
  move some definitions from vm_core.h to iseq.h.
* compile.c, iseq.c, vm.c: ditto.
* eval.c, compile.c: move some functions for parser
  from eval.c to compile.c.
* eval_intern.h, vm_core.h: move va_init_list() macro to
  vm_core.h.
* iseq.c (rb_iseq_new_top, rb_iseq_first_lineno): added.
* load.c, ruby.c: use rb_iseq_new_top() instead of
  rb_iseq_new() with ISEQ_TYPE_TOP constant directly.
* proc.c: use rb_iseq_first_lineno() instead of accessing
  iseq structure.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 07:49:45 +00:00
ko1 204929af9d * include/ruby/signal.h: removed.
* common.mk, class.c, eval.c, eval_intern.h, file.c, gc.c, hash.c,
  io.c, process.c, signal.c: vm_core.h: ditto.
  Some unused external global variables are also removed.
  (rb_prohibit_interrupt, rb_trap_immediate, rb_trap_pending,
  rb_thread_critical)
* ext/openssl/ossl_ssl.c, ext/openssl/ossl_x509store.c,
  ext/readline/readline.c, ext/socket/depend,
  ext/socket/socket.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19080 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-03 08:00:05 +00:00
shugo f433d710d0 * object.c (rb_obj_untrusted): new method Object#untrusted?.
(rb_obj_untrust): new method Object#untrust.
  (rb_obj_trust): new method Object#trust.
* array.c, debug.c, time.c, include/ruby/ruby.h, re.c, variable.c,
  string.c, io.c, dir.c, vm_method.c, struct.c, class.c, hash.c,
  ruby.c, marshal.c: fixes for Object#untrusted?.
* test/ruby/test_module.rb, test/ruby/test_array.rb,
  test/ruby/test_object.rb, test/ruby/test_string.rb,
  test/ruby/test_marshal.rb, test/ruby/test_hash.rb: added tests for
  Object#untrusted?.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-13 07:25:05 +00:00
matz e956f28724 * class.c (clone_method): should copy cbase in cref as well.
[ruby-dev:35116]

* iseq.c (iseq_mark): mark original iseq object.

* iseq.c (iseq_free): do not free internal data if they have
  original iseq to belong.

* iseq.c (rb_iseq_clone): a new function to clone iseq value.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18490 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-11 08:13:42 +00:00
nobu 5a647a3f5f * include/ruby/ruby.h (CONST_ID): constant ID cache for non-gcc.
* *.c: no cache in init functions.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-09 09:25:32 +00:00
akr 861219ce4a fix doc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15734 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-09 01:04:46 +00:00