From 28a1c4f33e3349a98c04b8e068d9c674eb936064 Mon Sep 17 00:00:00 2001 From: tarui Date: Fri, 15 Nov 2013 17:15:31 +0000 Subject: * cont.c : Introdule ensure rollback mechanism. Please see below. * internal.h (ruby_register_rollback_func_for_ensure): catch up above change. Add rollback mechanism API. * vm_core.h (typedef struct rb_vm_struct): catch up above change. Introdule ensure-rollback relation table. * vm_core.h (typedef struct rb_thread_struct): catch up above change. Introdule ensure stack. * eval.c (rb_ensure): catch up above change. Introdule ensure stack. * hash.c : New function for rollback ensure, and register it to ensure-rollback relation table. [ruby-dev:47803] [Bug #9105] Ensure Rollback Mechanism: A rollback's function is a function to rollback a state before ensure's function execution. When the jump of callcc is across the scope of rb_ensure, ensure's functions and rollback's functions are executed appropriately for keeping consistency. Current API is unstable, and only internal use. ruby_register_rollback_func_for_ensure(ensure_func,rollback_func) This API create relation ensure's function to rollback's function. By registered rollback's function, it is executed When jumpping into corresponding rb_ensure scope. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- vm_core.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'vm_core.h') diff --git a/vm_core.h b/vm_core.h index 44f871dd6f..94527bbfa6 100644 --- a/vm_core.h +++ b/vm_core.h @@ -387,6 +387,9 @@ typedef struct rb_vm_struct { /* hook */ rb_hook_list_t event_hooks; + /* relation table of ensure - rollback for callcc */ + struct st_table *ensure_rollback_table; + /* postponed_job */ struct rb_postponed_job_struct *postponed_job_buffer; int postponed_job_index; @@ -507,6 +510,17 @@ typedef struct rb_thread_list_struct{ } rb_thread_list_t; +typedef struct rb_ensure_entry { + VALUE marker; + VALUE (*e_proc)(ANYARGS); + VALUE data2; +} rb_ensure_entry_t; + +typedef struct rb_ensure_list { + struct rb_ensure_list *next; + struct rb_ensure_entry entry; +} rb_ensure_list_t; + typedef struct rb_thread_struct { VALUE self; rb_vm_t *vm; @@ -626,6 +640,9 @@ typedef struct rb_thread_struct { VALUE root_fiber; rb_jmpbuf_t root_jmpbuf; + /* ensure & callcc */ + rb_ensure_list_t *ensure_list; + /* misc */ int method_missing_reason; int abort_on_exception; -- cgit v1.2.3