Commit Graph

55 Commits

Author SHA1 Message Date
KOBAYASHI Shuji 9bd692bc67 Fix class name validation in Struct.new
Before this patch:

  $ bin/mruby -e 'p Struct.new("A-")'
  #=> Struct::"A-"

After this patch:

  $ bin/mruby -e 'p Struct.new("A-")'
  #=> NameError: identifier A- needs to be constant
2019-06-13 21:24:48 +09:00
dearblue 6907e97fa1 Change modifier to MRB_INLINE from static inline 2019-04-19 22:24:22 +09:00
Yukihiro "Matz" Matsumoto 88ac7549c0 Remove MRB_API from mrb_instance_new. 2019-04-10 19:11:35 +09:00
dearblue e19353be25 Fix macro expressions with paren 2018-12-18 23:14:26 +09:00
dearblue 14133f4057 Fix macro arguments with paren 2018-12-18 23:05:36 +09:00
Yukihiro "Matz" Matsumoto 814b7b5ef8 Move back mrb_define_alias to mruby.h to avoid breakage. 2018-08-29 07:00:13 +09:00
Yukihiro "Matz" Matsumoto 4c974b9523 Small refactoring.
The macro `RCLASS_SUPER`, `RCLASS_IV_TBL` and `RCLASS_M_TBL` are
removed from `include/mruby/class.h`.
2018-08-25 09:16:01 +09:00
Yukihiro "Matz" Matsumoto fd086833ff Reorganize flags values for classes; fix #3975
Renamed flag macro names as well:
`MRB_FLAG_IS_FROZEN` -> `MRB_FL_OBJ_FROZEN`
`MRB_FLAG_IS_PREPENDED` -> `MRB_FL_CLASS_IS_PREPENDED`
`MRB_FLAG_IS_ORIGIN` -> `MRB_FL_CLASS_IS_ORIGIN`
`MRB_FLAG_IS_INHERITED` -> `MRB_FL_CLASS_IS_INHERITED`
2018-08-25 09:13:09 +09:00
Yukihiro "Matz" Matsumoto 891839b976 New bytecode implementation of mruby VM. 2018-07-30 22:57:54 +09:00
Yukihiro "Matz" Matsumoto 8f2c62407c Add MRB_METHOD_TABLE_INLINE option.
Now the method tables (in classes/modules and caches) keeps C function
pointers without wrapping in `struct RProc` objects. For the sake of
portability, `mrb_method_t` is represented by the struct and union, but
if the most significant bit of the pointer is not used by the platform,
`mrb_method_t` should be packed in `uintptr_t` to reduce memory usage.

`MRB_METHOD_TABLE_INLINE` is turned on by default for linux.
2017-11-20 18:33:41 +09:00
YAMAMOTO Masaya acdc2d1f24 Add MRB_WITHOUT_FLOAT 2017-10-11 17:58:11 +09:00
Yukihiro "Matz" Matsumoto 7edbe428ca Add new type of shared string: RSTR_FSHARED.
`RSTR_FSHARED` use frozen strings as shared body instead of
`struct mrb_shared_string`. This reduces allocation from
literal strings.
2017-10-01 16:24:43 +09:00
Yukihiro "Matz" Matsumoto 4c9a604877 Added method cache.
To enable method cache, define `MRB_METHOD_CACHE` or
`MRB_METHOD_CACHE_SIZE`. The cache size must be power of 2.
The default cache size is 128.

The measurement:
I measured simple benchmarks found in benchmark/ directory. With
method cache enabled, we gained 6-8% performance improvement, with
97-99% cache hit rate.
2017-08-22 22:17:01 +09:00
Yukihiro "Matz" Matsumoto da24af34b9 Better class name management.
The change removes several internal instance variables used by
class name management. The variables `__classid__` and `__classpath__`
are no longer available. `__outer__` is used only for unnamed outer
classes/modules (and will be removed after they are named).

[Important note]
Along with this change we removed several public functions.

 - mrb_class_outer_module()
 - mrb_class_sym()

We believe no one have used those functions, but if you do, please
ask us for the workaround.
2017-08-01 22:25:49 +09:00
Yukihiro "Matz" Matsumoto 27a5e10454 Avoid using C++ style comments (//). 2017-05-30 11:47:59 +09:00
Takashi Kokubun 10bb7ad693 Implement Object#freeze 2016-12-11 03:44:15 +09:00
Yukihiro "Matz" Matsumoto 065966dae4 common.h are supposed to be included from other header, so call it with quotes; ref #3032 2015-11-28 00:10:38 +09:00
Yukihiro "Matz" Matsumoto 5c405dea3d include changed from by quotes ("") to by brackets (<>); close #3032 2015-11-27 17:48:23 +09:00
Seba Gamboa a0fe0c40b1 Remove old doxygen tags 2015-10-08 12:29:10 -03:00
Seba Gamboa 40bf7bde78 Sorting documentation grouping 2015-09-21 01:48:42 -03:00
Seba Gamboa c127614638 Setting up doxygen groups 2015-09-20 21:14:07 -03:00
Yukihiro "Matz" Matsumoto 2550edd570 remove origin member to implement prepend from struct RClass; ref #2885
instead origin is saved in ICLASS with MRB_FLAG_IS_ORIGIN set.
2015-09-05 02:01:02 +09:00
Corey Powell 667f7788db Renamed MRB_FLAG_IS_INSTANCE to MRB_INSTANCE_TT_MASK 2015-07-15 07:27:31 -05:00
Corey Powell eb172c28d7 Applied gc patch to fix ORIGIN ICLASS method table leak
Based on the gc patch by ko1

https://github.com/ruby/ruby/commit/5922c954614e5947a548780bb3b894626affe6dd
2015-07-14 09:44:04 -05:00
Blaž Hrastnik f962890a92 Implement Module#prepend. 2015-07-13 14:04:42 +02:00
cremno 2106d4d446 remove mrb_define_method_vm() function
It isn't needed as it's very similar to mrb_define_method_raw() and also
there's only one place where mrb_proc_ptr() actually has to be called.

Inspired by @furunkel's method cache patch (#2764).
2015-05-15 13:04:55 +02:00
Yukihiro "Matz" Matsumoto 206f89e209 add MRB_API modifiers to mruby API functions 2014-08-04 00:47:08 +09:00
David Turnbull 249f05e7d7 Clean up value.h and mrb_value boxing 2014-07-09 06:32:11 +09:00
Yukihiro "Matz" Matsumoto b4dd3564ef REnv uses obj->c as env link; no super 2014-03-25 11:50:11 +09:00
Yukihiro "Matz" Matsumoto 3995e7ff8f rename voidp to cptr 2013-09-21 17:28:47 +09:00
Yukihiro "Matz" Matsumoto fdb58b4734 voidp should be an Object; close #1508 2013-09-21 17:18:56 +09:00
Dusan D. Majkic e2bdd8cd47 Remove function delarations not implemented in code 2013-08-27 14:57:36 +02:00
Yukihiro "Matz" Matsumoto 40e6cdcb5c rename mrb_value_p() to mrb_ptr() since _p means predicate in mruby source 2013-08-07 17:39:28 +09:00
Yuichi Nishiwaki 8dc2fa3bc8 add read barrier to value.p
API changes:
- value.p must be accessed via mrb_value_p macro
- value.p must be mutated via MRB_SET_VALUE_P macro
2013-08-03 14:03:44 -07:00
Yukihiro Matz Matsumoto b1bd62e047 remove all MRB_TT_MAIN from source 2013-03-26 21:25:00 +09:00
crimsonwoods 52eba9fee7 fix the type of argument named 'aspec'.
'aspec' should be large at least 24 bit.
2013-03-18 16:04:10 +09:00
Yukihiro Matz Matsumoto 243669308d obsolete mrb_object; opposite of bc870ce 2013-03-15 23:16:20 +09:00
Yukihiro Matz Matsumoto 59a6d1b514 remove TT_REGEX and TT_MATCH 2013-02-18 16:18:19 +09:00
mattn b1a5146ea8 Pluggable Regexp 2013-02-15 04:38:27 +09:00
Yukihiro Matz Matsumoto 52f7e83726 Module#dup should copy class methods as well 2012-11-03 08:28:48 +09:00
Yukihiro Matsumoto fd3af6aec8 introduce toplevel object main; close #327 2012-09-03 00:41:09 +09:00
Yukihiro Matsumoto 97b7eb6096 rename MRUBY_OBJECT_HEADER to MRB_OBJECT_HEADER 2012-08-18 19:05:18 +09:00
Yukihiro Matsumoto 7d02df3016 NaN boxing 2012-08-14 13:16:34 +09:00
Yukihiro Matsumoto c9fe903fe1 now segmented list can be used as instance variable tables by -DMRB_USE_IV_SEGLIST; we still need to measure the performance and memory consumption 2012-08-12 01:59:18 +09:00
Yukihiro Matsumoto 76f7aecff3 use ENABLE/DISABLE instead of INCLUDE for configuration macro names 2012-06-15 15:34:49 +09:00
Yukihiro "Matz" Matsumoto 0816c0eba5 Merge pull request #248 from monaka/pr-use-value-i-for-nil-false-check
Use value.i for nil/false check.
2012-06-06 22:55:10 -07:00
Masaki Muranaka e0909fef44 Use value.i for nil/false check. 2012-06-07 09:34:27 +09:00
Yukihiro Matsumoto 1a369de489 remove src/gc.h 2012-06-07 01:18:17 +09:00
Yukihiro Matsumoto 1f704552cc move respond_to and instance_of prototypes to mruby.h 2012-06-01 02:48:19 +09:00
Mitchell Blank Jr 9e336b00e5 More C++ compilability work: mrb_obj_alloc void* conversions
One of the biggest set of changes needed to make C++ compile, is that you
can't autoconvert "void*" to a different pointer type without a cast (you
can of course, convert pointers *to* "void*"!)

For the first part, convert the users of "mrb_obj_alloc".  Since it has
to return something, make it RBasic* (that's what mrb_obj_alloc() is
operating on anyway).  This way, even in C you'll get a warning if you
don't cast it.

For places where there are a lot of similar calls to mrb_obj_alloc(),
this can be easily hidden through a macro.  I did this in string.c:
    #define mrb_obj_alloc_string(mrb) ((struct RString *) mrb_obj_alloc((mrb), MRB_TT_STRING, (mrb)->string_class))

I also updated the mrb_object() macro to also return a RBasic* -- my
previous commit changed that from "void*" -> "RObject*", but I figure
it should be consistent with mrb_obj_alloc()
2012-05-20 09:43:14 -07:00