summaryrefslogtreecommitdiffhomepage
path: root/src/proc.c
AgeCommit message (Collapse)Author
2018-07-30New bytecode implementation of mruby VM.Yukihiro "Matz" Matsumoto
2017-12-20Do not need to take `target_class` from the upper proc.Yukihiro "Matz" Matsumoto
Since it is already set in `mrb_proc_new()`.
2017-11-20Add `MRB_METHOD_TABLE_INLINE` option.Yukihiro "Matz" Matsumoto
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-10-28Heavily refactored how lexical scope links are implemented; fix #3821Yukihiro "Matz" Matsumoto
Instead of `irep` links, we added a `upper` link to `struct RProc`. To make a space for the `upper` link, we moved `target_class` reference. If a `Proc` does not have `env`, `target_class` is saved in an `union` shared with `env` (if a `Proc` has env, you can tell it by `MRB_PROC_ENV_P()). Otherwise `target_class` is referenced from `env->c`. We removed links in `env` as well. This change removes 2 members from `mrb_irep` struct, thus saving 2 words per method/proc/block. This also fixes potential memory leaks due to the circular references caused by a link from `mrb_irep`.
2017-09-27fix: src\proc.c(96): warning C4244: 'function': conversion from 'mrb_int' to ↵Tomasz Dąbrowski
'int', possible loss of data
2017-09-01Avoid copying over initialized procs using `initialize_copy`; fix #3803Yukihiro "Matz" Matsumoto
It may be better to raise exceptions, but CRuby doesn't.
2017-08-30Set the ORPHAN flag in `Proc.new`; fix #3798Yukihiro "Matz" Matsumoto
2017-08-01Cosmetic changes (removing spaces before `*` in return types).Yukihiro "Matz" Matsumoto
2017-04-22Keep reference to mrb_context from env; fix #3619Yukihiro "Matz" Matsumoto
2017-04-13Proc#call needs to reserve at least 2 registers; fix #3606Yukihiro "Matz" Matsumoto
One for the receiver, the other for the block.
2017-04-03Insert ` mrb_field_write_barrier()` for GC; fix #3534Yukihiro "Matz" Matsumoto
2016-12-22Should call initialize method if definedksss
2016-12-21Proc shouldn't have `initialize` methodksss
Fix #3356
2016-12-02Fix segfault in mrb_proc_copy.Clayton Smith
2016-11-24Fix calling .arity on Proc with undefined `initialize`Francois Chagnon
Reported by @bouk
2016-09-25Remove needless MRB_APIKouhei Sutou
ref #3215 If a function (such as mrb_read_irep_file()) is declared without MRB_API in header file (such as include/mruby/dump.h), implementation of the function in source file (such as src/load.c) should also defined without MRB_API. If MRB_API is mismatch, Visual C++ reports link error with C2375 error code: https://msdn.microsoft.com/en-us/library/5k6kw95a.aspx
2015-11-27include changed from by quotes ("") to by brackets (<>); close #3032Yukihiro "Matz" Matsumoto
2015-06-29Fix a crash bug when GC is ran while creating a proc with envKouhei Sutou
mrb_proc_new_cfunc_with_env() allocates RProc with RProc::env as NULL then allocates REnv and sets it to RProc::env of the allocated RProc. If incremental GC is ran before "allocates REnv and sets it to RProc::env of the allocated RProc", the allocated RProc's GC status is "marked" (Black) and the allocated REnv's GC status is "unmarked" (White). The next incremental GC sweeps the allocated REnv without re-marking the allocated RProc. Because the RProc is Black and the REnv is White. We need to implement write barrier for the case. We can force to cause the above situation by the following patch: diff --git a/src/proc.c b/src/proc.c index f98998f..4f4e25c 100644 --- a/src/proc.c +++ b/src/proc.c @@ -92,6 +92,7 @@ mrb_proc_new_cfunc_with_env(mrb_state *mrb, mrb_func_t func, mrb_int argc, const struct REnv *e; int i; + mrb_incremental_gc(mrb); p->env = e = env_new(mrb, argc); MRB_ENV_UNSHARE_STACK(e); e->stack = (mrb_value*)mrb_malloc(mrb, sizeof(mrb_value) * argc); With this patch, "rake test" causes segmentation fault.
2015-06-23fix Proc#curry test failure; ref #2848Yukihiro "Matz" Matsumoto
2015-06-22fix arity of lambdas with optional argumentscremno
From the CRuby 2.2.2 Proc#arity documentation: If the block has optional arguments, returns -n-1, where n is the number of mandatory arguments, with the exception for blocks that are not lambdas and have only a finite number of optional arguments; in this latter case, returns n.
2015-05-22Verify that proc_lambda is passed a procCarson McDonald
2014-10-02cast MRB_ENV_STACK_LEN to (mrb_int); ref #2600Yukihiro "Matz" Matsumoto
2014-10-02Pacify MSVC warnings for numeric.c, proc.c, and symbol.cHiroshi Mimaki
2014-09-02move mrb_proc_new_cfunc_with_env() to the coreYukihiro "Matz" Matsumoto
2014-08-29Fix mismatches for MRB_API declarations.Tatsuhiko Kubo
2014-08-29revert 6c1dfc9; ref #2525 #2565Yukihiro "Matz" Matsumoto
2014-08-13need to add space for receiver to proc env; fix #2525Yukihiro "Matz" Matsumoto
2014-08-04add MRB_API modifiers to mruby API functionsYukihiro "Matz" Matsumoto
2014-07-13use C style comments instead of C++ style commentsTatsuhiko Kubo
2014-06-25Proc#arity return 0 when opcode was not OP_ENTERksss
2014-06-15arity for cfunc is not implemented yetksss
2014-06-15Proc class define before a first methodksss
mrb_define_method setting mrb->proc_class for method proc
2014-05-17Delete unnecessary semicolonJun Hiroe
2014-05-14mv opcode.h -> include/mruby/opcode.h and remove duplication from mruby-eval gemYukihiro "Matz" Matsumoto
2014-04-30adjust indentNobuyoshi Nakada
2014-04-29make cioff in struct REnv from int to ptrdiff_t; close #2149Yukihiro "Matz" Matsumoto
2014-04-15resolve conflictYukihiro "Matz" Matsumoto
2014-04-01Use MRB_ENV_STACK_LEN instead of accessing `flags` directly to get REnv's ↵take_cheeze
stack length.
2014-03-26Merge pull request #1948 from monaka/pr-remove-unused-null-checkYukihiro "Matz" Matsumoto
Remove redundant NULL checks.
2014-03-26Remove redundant NULL checks.Masaki Muranaka
mrb_malloc causes an exception when memory was empty.
2014-03-25REnv uses obj->c as env link; no superYukihiro "Matz" Matsumoto
2014-01-06adjust proc->target_class according to surrounding proc->target_class; based ↵Yukihiro "Matz" Matsumoto
on a patch from @Fleurer; close #1627
2013-12-01add mrb_intern_lit for creating symbol from string literaltake_cheeze
2013-11-29rename mrb_intern2() to mrb_intern(); huge API incompatibility; close #1513Yukihiro "Matz" Matsumoto
2013-11-08allow irep to be GCedYukihiro "Matz" Matsumoto
2013-11-07call_iseq will never be NULLYukihiro "Matz" Matsumoto
2013-11-07modified to use irep->reps to reference child ireps. preparation forYukihiro "Matz" Matsumoto
removing irep array from mrb_state. note that instructions OP_LAMBDA, OP_EXEC and OP_EPUSH are incompatible, and dumped mrb format has changed.
2013-07-12Replace mrb_intern() func with mrb_intern2() func or mrb_intern_cstr() func.Jun Hiroe
2013-06-15Merge upstreamDaniel Bovensiepen
2013-06-17Add ISO Number to ProcDaniel Bovensiepen