Skip to content

Instantly share code, notes, and snippets.

@miura1729
Created January 29, 2025 10:02
Show Gist options
  • Save miura1729/9988d1d54d1218e619a459fe0da26691 to your computer and use it in GitHub Desktop.
Save miura1729/9988d1d54d1218e619a459fe0da26691 to your computer and use it in GitHub Desktop.
therad2.rb乃コンパイル結果
#include <mruby.h>
#include <mruby/value.h>
#include <mruby/array.h>
#include <mruby/hash.h>
#include <mruby/throw.h>
#include <mruby/proc.h>
#include <mruby/string.h>
#include <mruby/range.h>
#include <mruby/error.h>
#include <mruby/variable.h>
#include <mruby/throw.h>
#include <mruby/data.h>
#include <mruby/class.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <pthread.h>
#undef mrb_int
typedef mrb_float mrb_float2;
#define mrb_float_value2(n) ({\
mrb_value rc; \
rc.f = n; \
rc; \
})
#define mmc_boxing_array(src, size, boxing_func) ({ \
mrb_value ary; \
ary = mrb_ary_new_capa(mrb, (size)); \
for (int i = 0; i < (size); i++) { \
mrb_ary_push(mrb, ary, (boxing_func)(mrb, (src)[i])); \
} \
ary; \
})
typedef void *gproc;
struct gctab {
int size;
int csize;
int osize;
struct gctab *prev;
mrb_value **complex;
mrb_value **object;
void *caller_alloc;
int ret_status;
mrb_value *single[0];
};
typedef mrb_value mrb_value_mutex;
struct mutex_wrapper {
pthread_mutex_t mp;
};
void mrb_mutex_free(mrb_state *mrb, void *data)
{
struct mutex_wrapper *mutex_data = (struct mutex_wrapper *)data;
pthread_mutex_destroy(&mutex_data->mp);
mrb_free(mrb, data);
}
mrb_data_type mutex_data_header = {"Mutex Data", mrb_mutex_free};
void mrb_mark_local(mrb_state *mrb)
{
struct gctab *curtab = (struct gctab *)mrb->allocf_ud;
while (curtab) {
for (int i = curtab->size; i--;) {
if (!mrb_immediate_p(*curtab->single[i])) {
mrb_gc_mark(mrb, mrb_basic_ptr(*curtab->single[i]));
}
}
for (int i = curtab->osize; i--;) {
if (!mrb_immediate_p(*curtab->object[i])) {
mrb_gc_mark(mrb, mrb_basic_ptr(*curtab->object[i]));
}
}
for (int i = curtab->csize; i--;) {
mrb_value *cptr = curtab->complex[i];
for (int j = 0; cptr[j].value.ttt != MRB_TT_FREE; j++) {
if (!mrb_immediate_p(cptr[i])) {
mrb_gc_mark(mrb, mrb_basic_ptr(cptr[j]));
}
}
}
curtab = curtab->prev;
}
}
struct thread_list {
struct pthead_t *thread;
struct thread_list *next;
struct thread_list *prev;
};
struct mmc_system {
struct RClass *pthread_class;
struct thread_list *thread_list;
pthread_mutex_t *io_mutex;
pthread_mutex_t *gc_mutex;
};
struct env2 {
struct env0 *prev;
};
struct env5 {
struct env2 *prev;
};
struct env6 {
struct env2 *prev;
};
struct env15 {
struct env2 *prev;
};
struct cls0_8 {
};
struct cls3_8 {
};
struct cls2_8 {
};
struct cls5_8 {
pthread_t thread;
void *argv;
void (*thread_func)(void *);
};
struct env9 {
struct env6 *prev;
};
struct env12 {
struct env6 *prev;
};
struct env14 {
struct env6 *prev;
};
static mrb_value_mutex main_Object_0(mrb_state *, mrb_value v9,struct gctab *);
struct cls3_8 * const0;
struct cls2_8 * const1;
struct proc6 {
int id;
void *code[1];
struct env2 *env;
mrb_value self;
};
struct proc15 {
int id;
void *code[1];
struct env2 *env;
mrb_value self;
};
static mrb_value_mutex foo__Object__1(mrb_state *, mrb_value v470,struct gctab *);
static mrb_int initialize__Count__4(mrb_state *, mrb_value_mutex v1274,struct gctab *);
static mrb_value p6_Object_0_3(mrb_state *, gproc cgproc, mrb_value_mutex v514, mrb_value_mutex v515, gproc v516, struct gctab *);
static mrb_value p15_Object_1_7(mrb_state *, gproc cgproc, mrb_value_mutex v608, mrb_value_mutex v609, gproc v610, struct gctab *);
static mrb_int c__Count__4(mrb_state *, mrb_value_mutex v1866,struct gctab *);
static mrb_int skip_ucnt__Count__5(mrb_state *, mrb_value_mutex v2447, mrb_value_mutex v2448,struct gctab *);
static mrb_int kakutani__Object__6(mrb_state *, mrb_value v2971, mrb_int v2972, mrb_value_mutex v2973,struct gctab *);
int main(int argc, char **argv)
{
mrb_state *mrb = mrb_open();
struct mrb_jmpbuf c_jmp;
struct gctab *gctab = (struct gctab *)alloca(sizeof(struct gctab));
struct RClass *pthread_class;
struct thread_list *thread_list;
pthread_mutex_t *io_mutex;
pthread_mutex_t *gc_mutex;
struct mmc_system *mmc_system;
gctab->prev = NULL;
gctab->size = 0;
gctab->csize = 0;
gctab->osize = 0;
gctab->ret_status = 0;
mmc_system = malloc(sizeof(struct mmc_system));
pthread_class = mrb_define_class(mrb, "Pthread", mrb->object_class);
mmc_system->pthread_class = pthread_class;
thread_list = malloc(sizeof(struct thread_list));
thread_list->thread = pthread_self();
thread_list->next = NULL;
thread_list->prev = NULL;
mmc_system->thread_list = thread_list;
io_mutex = malloc(sizeof(pthread_mutex_t));
pthread_mutex_init(io_mutex, NULL);
mmc_system->io_mutex = io_mutex;
gc_mutex = malloc(sizeof(pthread_mutex_t));
pthread_mutex_init(gc_mutex, NULL);
mmc_system->gc_mutex = gc_mutex;
mrb->ud = (void *)mmc_system;
MRB_SET_INSTANCE_TT(((struct mmc_system *)mrb->ud)->pthread_class, MRB_TT_DATA);
MRB_TRY(&c_jmp) {
mrb->jmp = &c_jmp;
main_Object_0(mrb, mrb_top_self(mrb), gctab);
}
MRB_CATCH(&c_jmp) {
mrb_p(mrb, mrb_obj_value(mrb->exc));
return 1;
}
MRB_END_EXC(&c_jmp);
return 0;
}
static mrb_value_mutex main_Object_0(mrb_state *mrb, mrb_value v9, struct gctab *prevgctab) {
mrb_value self;
mrb_value mutexself;
mrb_value_mutex v17;
struct gctab *gctab = (struct gctab *)alloca(sizeof(struct gctab) + 1 * sizeof(mrb_value *));
gctab->prev = prevgctab;
gctab->complex = NULL;
gctab->object = NULL;
gctab->size = 0;
gctab->csize = 0;
gctab->osize = 0;
gctab->ret_status = 0;
L0:;
mutexself = v9;
self = v9;
/* START END */
gctab->caller_alloc = alloca((sizeof(mrb_value_mutex)) + (sizeof(mrb_value_mutex)));
gctab->single[0] = &mutexself;/* normal */
gctab->size = 1;
v17 = foo__Object__1(mrb, self, gctab);
return v17;
}
static mrb_value_mutex foo__Object__1(mrb_state *mrb, mrb_value v470, struct gctab *prevgctab) {
struct env2 env;
struct REnv *venv = NULL;
mrb_value self;
mrb_value mutexself;
mrb_value_mutex v500;
mrb_value_mutex v501;/*snd*/
mrb_value v504;
mrb_value_mutex v507;/*snd*/
mrb_value_mutex v508;/*snd*/
struct proc6 v509;
struct cls5_8 * v597;
;
struct cls5_8 * v598;/*snd*/
mrb_value_mutex v601;/*snd*/
mrb_value_mutex v602;/*snd*/
struct proc15 v603;
struct cls5_8 * v691;
;
struct cls5_8 * v692;/*snd*/
struct cls5_8 * v693;/*snd*/
;
struct cls5_8 * v695;
struct cls5_8 * v696;/*snd*/
;
struct cls5_8 * v698;
mrb_value_mutex v700;/*snd*/
mrb_value_mutex v702;
int ai = mrb_gc_arena_save(mrb);
struct gctab *gctab = (struct gctab *)alloca(sizeof(struct gctab) + 2 * sizeof(mrb_value *));
gctab->prev = prevgctab;
gctab->complex = NULL;
gctab->object = NULL;
gctab->size = 0;
gctab->csize = 0;
gctab->osize = 0;
gctab->ret_status = 0;
L20:;
mutexself = v470;
self = v470;
/* START END */
mrb->allocf_ud = (void *)gctab;
{
mrb_value obj = mrb_ary_new_capa(mrb, 0);for (int i = 0;i < 0; i++) ARY_PTR(mrb_ary_ptr(obj))[i] = mrb_nil_value();
ARY_SET_LEN(mrb_ary_ptr(obj), 0);
gctab->size = 0;
mrb->allocf_ud = (void *)gctab;
v500 = mrb_nil_value();
gctab->single[0] = &v500; /* conversion */
gctab->size++;
v500 = ({ struct mutex_wrapper *mutex = malloc(sizeof(struct mutex_wrapper));
mrb_value mutexobj = mrb_obj_value(mrb_data_object_alloc(mrb, ((struct mmc_system *)mrb->ud)->pthread_class, mutex, &mutex_data_header));
pthread_mutex_init(&mutex->mp, NULL);
mrb_iv_set(mrb, mutexobj, mrb_intern_cstr(mrb, "@object"), obj);
mutexobj;
})
;
}
gctab->size = 0;
initialize__Count__4(mrb, v500, gctab);
v501 = v500;
{
mrb_value tmpele[] = {
(mrb_fixnum_value(0)), (mrb_fixnum_value(0))
};
gctab->size = 0;
mrb->allocf_ud = (void *)gctab;
v504 = mrb_nil_value();
gctab->single[0] = &v504; /* conversion */
gctab->size++;
mrb_value array = mrb_ary_new_from_values(mrb, 2, tmpele);
mrb->allocf_ud = (void *)gctab;
v504 = mrb_nil_value();
gctab->single[1] = &v504; /* conversion */
gctab->size++;
v504 = ({ struct mutex_wrapper *mutex = malloc(sizeof(struct mutex_wrapper));
mrb_value mutexobj = mrb_obj_value(mrb_data_object_alloc(mrb, ((struct mmc_system *)mrb->ud)->pthread_class, mutex, &mutex_data_header));
pthread_mutex_init(&mutex->mp, NULL);
mrb_iv_set(mrb, mutexobj, mrb_intern_cstr(mrb, "@object"), array);
mutexobj;
})
;
ARY_SET_LEN(mrb_ary_ptr(array), 2);
}
v507 = v501;
v508 = v504;
v509.id = 6;
v509.self = self;
v509.env = &env;
{
struct thprocarg597 {
mrb_state *mrb;
gproc cgproc;
mrb_value_mutex v507;
mrb_value_mutex v508;
gproc v509;
struct gctab *prevgctab;
};
struct thprocarg597 *tpargv = malloc(sizeof(struct thprocarg597));
tpargv->mrb = mrb;
tpargv->cgproc = ((gproc)&v509);
tpargv->v507 = v507;
tpargv->v508 = v508;
tpargv->v509 = ((gproc)&v509);
tpargv->prevgctab = gctab;
void *apply_thproc(void *arg) {
struct thprocarg597 *tpargv = (struct thprocarg597 *)arg;
p6_Object_0_3(tpargv->mrb, tpargv->cgproc, tpargv->v507, tpargv->v508, tpargv->v509, tpargv->prevgctab);
return NULL;
}
v597 = malloc(sizeof(*v597));
v597->argv = tpargv;
pthread_create(&v597->thread, NULL, apply_thproc, tpargv);
}
v598 = v597;
v601 = v501;
v602 = v504;
v603.id = 15;
v603.self = self;
v603.env = &env;
{
struct thprocarg691 {
mrb_state *mrb;
gproc cgproc;
mrb_value_mutex v601;
mrb_value_mutex v602;
gproc v603;
struct gctab *prevgctab;
};
struct thprocarg691 *tpargv = malloc(sizeof(struct thprocarg691));
tpargv->mrb = mrb;
tpargv->cgproc = ((gproc)&v603);
tpargv->v601 = v601;
tpargv->v602 = v602;
tpargv->v603 = ((gproc)&v603);
tpargv->prevgctab = gctab;
void *apply_thproc(void *arg) {
struct thprocarg691 *tpargv = (struct thprocarg691 *)arg;
p15_Object_1_7(tpargv->mrb, tpargv->cgproc, tpargv->v601, tpargv->v602, tpargv->v603, tpargv->prevgctab);
return NULL;
}
v691 = malloc(sizeof(*v691));
v691->argv = tpargv;
pthread_create(&v691->thread, NULL, apply_thproc, tpargv);
}
v692 = v691;
v693 = v598;
{
void *ret;
pthread_join(v693->thread, &ret);
}
v696 = v692;
{
void *ret;
pthread_join(v696->thread, &ret);
}
v700 = v504;
gctab->single[0] = &v501;/* normal */
pthread_mutex_lock(((struct mmc_system *)mrb->ud)->io_mutex);
mrb->allocf_ud = (void *)gctab;
mrb_p(mrb, ({
struct mutex_wrapper *mutex = (struct mutex_wrapper *)DATA_PTR(v700);
pthread_mutex_lock(&mutex->mp);
mrb_iv_get(mrb, v700, mrb_intern_cstr(mrb, "@object"));
})
);
pthread_mutex_unlock(((struct mmc_system *)mrb->ud)->io_mutex);
v702 = v700;
pthread_mutex_unlock(&((struct mutex_wrapper *)(DATA_PTR(v700)))->mp);
mrb_gc_arena_restore(mrb, ai);
return v702;
mrb_gc_arena_restore(mrb, ai);
}
static mrb_int initialize__Count__4(mrb_state *mrb, mrb_value_mutex v1274, struct gctab *prevgctab) {
struct env5 env;
struct REnv *venv = NULL;
mrb_value self;
mrb_value mutexself;
struct gctab *gctab = prevgctab;
L55:;
mutexself = v1274;
self = ({
struct mutex_wrapper *mutex = (struct mutex_wrapper *)DATA_PTR(v1274);
pthread_mutex_lock(&mutex->mp);
mrb_iv_get(mrb, v1274, mrb_intern_cstr(mrb, "@object"));
})
;
/* START END */
pthread_mutex_unlock(&((struct mutex_wrapper *)(DATA_PTR(mutexself)))->mp);
{mrb_value val;
val = (mrb_fixnum_value(2));
ARY_PTR(mrb_ary_ptr(self))[0] = (mrb_fixnum_value(2));
}
return 2;
}
static mrb_value p6_Object_0_3(mrb_state *mrb, gproc cgproc, mrb_value_mutex v514, mrb_value_mutex v515, gproc v516, struct gctab *prevgctab) {
struct proc6 *proc = (struct proc6 *)cgproc;
mrb_value v513 = proc->self;
struct env6 env;
struct REnv *venv = NULL;
mrb_value self;
mrb_value mutexself;
mrb_value_mutex v524;
mrb_value_mutex v525;
gproc v526;
mrb_value_mutex v538;/*snd*/
mrb_int v540;
mrb_value_mutex v571;
mrb_value_mutex v572;
mrb_int v574;
mrb_bool v583;/*snd1*/
mrb_value_mutex v553;/*snd*/
mrb_value_mutex v554;/*snd*/
mrb_int v556;
char *v559 = "thread 1 out ";
mrb_value v561;
mrb_value v563;
mrb_value_mutex v566;/*snd*/
mrb_int v568;
struct gctab *gctab = (struct gctab *)alloca(sizeof(struct gctab) + 4 * sizeof(mrb_value *));
gctab->prev = prevgctab;
gctab->complex = NULL;
gctab->object = NULL;
gctab->size = 0;
gctab->csize = 0;
gctab->osize = 0;
gctab->ret_status = 0;
env.prev = proc->env;
L21:;
mutexself = v513;
self = v513;
v524 = v514;
v525 = v515;
v526 = v516;
/* START END */
v538 = v524;
gctab->single[0] = &v524;/* normal */
gctab->single[1] = &v525;/* normal */
gctab->size = 2;
v540 = c__Count__4(mrb, v538, gctab);
v571 = v524; /* 1*/
v572 = v525; /* 1*/
v574 = v540; /* 1*/
L23:;
v583 = (v574 < 1000);
if (v583) goto L22; else goto L24;
L22:;
v553 = v571;
v554 = v572;
gctab->single[0] = &v571;/* normal */
gctab->single[1] = &v572;/* normal */
gctab->single[2] = &v553;/* normal */
gctab->size = 3;
v556 = skip_ucnt__Count__5(mrb, v553, v554, gctab);
mrb->allocf_ud = (void *)gctab;
v561 = mrb_nil_value();
gctab->single[3] = &v561; /* conversion */
gctab->size++;
v561 = (mrb_str_new_cstr(mrb, "thread 1 out "));
mrb->allocf_ud = (void *)gctab;
v561 = mrb_str_cat_cstr(mrb, v561, ({char *_buf = alloca(255);sprintf(_buf, "%d", v556);_buf;}));
gctab->size = 2;
pthread_mutex_lock(((struct mmc_system *)mrb->ud)->io_mutex);
mrb->allocf_ud = (void *)gctab;
mrb_p(mrb, v561);
pthread_mutex_unlock(((struct mmc_system *)mrb->ud)->io_mutex);
v563 = v561;
v566 = v572;
v568 = kakutani__Object__6(mrb, self, v556, v566, gctab);
v571 = v571; /* 2*/
v572 = v572; /* 2*/
v574 = v556; /* 2*/
goto L23;
L24:;
return mrb_nil_value();
}
static mrb_value p15_Object_1_7(mrb_state *mrb, gproc cgproc, mrb_value_mutex v608, mrb_value_mutex v609, gproc v610, struct gctab *prevgctab) {
struct proc15 *proc = (struct proc15 *)cgproc;
mrb_value v607 = proc->self;
struct env15 env;
struct REnv *venv = NULL;
mrb_value self;
mrb_value mutexself;
mrb_value_mutex v618;
mrb_value_mutex v619;
gproc v620;
mrb_value_mutex v632;/*snd*/
mrb_int v634;
mrb_value_mutex v665;
mrb_value_mutex v666;
mrb_int v668;
mrb_bool v677;/*snd1*/
mrb_value_mutex v647;/*snd*/
mrb_value_mutex v648;/*snd*/
mrb_int v650;
char *v653 = "thread 2 out ";
mrb_value v655;
mrb_value v657;
mrb_value_mutex v660;/*snd*/
mrb_int v662;
struct gctab *gctab = (struct gctab *)alloca(sizeof(struct gctab) + 4 * sizeof(mrb_value *));
gctab->prev = prevgctab;
gctab->complex = NULL;
gctab->object = NULL;
gctab->size = 0;
gctab->csize = 0;
gctab->osize = 0;
gctab->ret_status = 0;
env.prev = proc->env;
L25:;
mutexself = v607;
self = v607;
v618 = v608;
v619 = v609;
v620 = v610;
/* START END */
v632 = v618;
gctab->single[0] = &v618;/* normal */
gctab->single[1] = &v619;/* normal */
gctab->size = 2;
v634 = c__Count__4(mrb, v632, gctab);
v665 = v618; /* 1*/
v666 = v619; /* 1*/
v668 = v634; /* 1*/
L27:;
v677 = (v668 < 1000);
if (v677) goto L26; else goto L28;
L26:;
v647 = v665;
v648 = v666;
gctab->single[0] = &v665;/* normal */
gctab->single[1] = &v666;/* normal */
gctab->single[2] = &v647;/* normal */
gctab->size = 3;
v650 = skip_ucnt__Count__5(mrb, v647, v648, gctab);
mrb->allocf_ud = (void *)gctab;
v655 = mrb_nil_value();
gctab->single[3] = &v655; /* conversion */
gctab->size++;
v655 = (mrb_str_new_cstr(mrb, "thread 2 out "));
mrb->allocf_ud = (void *)gctab;
v655 = mrb_str_cat_cstr(mrb, v655, ({char *_buf = alloca(255);sprintf(_buf, "%d", v650);_buf;}));
gctab->size = 2;
pthread_mutex_lock(((struct mmc_system *)mrb->ud)->io_mutex);
mrb->allocf_ud = (void *)gctab;
mrb_p(mrb, v655);
pthread_mutex_unlock(((struct mmc_system *)mrb->ud)->io_mutex);
v657 = v655;
v660 = v666;
v662 = kakutani__Object__6(mrb, self, v650, v660, gctab);
v665 = v665; /* 2*/
v666 = v666; /* 2*/
v668 = v650; /* 2*/
goto L27;
L28:;
return mrb_nil_value();
}
static mrb_int c__Count__4(mrb_state *mrb, mrb_value_mutex v1866, struct gctab *prevgctab) {
struct env9 env;
struct REnv *venv = NULL;
mrb_value_mutex self;
mrb_value_mutex mutexself;
mrb_int v1876;
struct gctab *gctab = prevgctab;
L82:;
mutexself = v1866;
self = v1866;
/* START END */
v1876 = (mrb_fixnum(ARY_PTR(mrb_ary_ptr(mrb_iv_get(mrb, self, mrb_intern_cstr(mrb, "@object"))))[0]));
return v1876;
}
static mrb_int skip_ucnt__Count__5(mrb_state *mrb, mrb_value_mutex v2447, mrb_value_mutex v2448, struct gctab *prevgctab) {
struct env12 env;
struct REnv *venv = NULL;
mrb_value self;
mrb_value mutexself;
mrb_value_mutex v2456;
char *v2468 = "skip";
char *v2470;
mrb_value_mutex v2484;
mrb_value_mutex v2491;/*snd*/
mrb_int v2492;
mrb_value v2494;
mrb_value_mutex v2517;
mrb_int v2480;
mrb_int v2481;/*snd1*/
mrb_int v2505;
mrb_int v2507;
mrb_int v2508;
mrb_int v2512;
mrb_int v2513;
mrb_int v2514;/*snd1*/
struct gctab *gctab = (struct gctab *)alloca(sizeof(struct gctab) + 3 * sizeof(mrb_value *));
gctab->prev = prevgctab;
gctab->complex = NULL;
gctab->object = NULL;
gctab->size = 0;
gctab->csize = 0;
gctab->osize = 0;
gctab->ret_status = 0;
L109:;
mutexself = v2447;
self = ({
struct mutex_wrapper *mutex = (struct mutex_wrapper *)DATA_PTR(v2447);
pthread_mutex_lock(&mutex->mp);
mrb_iv_get(mrb, v2447, mrb_intern_cstr(mrb, "@object"));
})
;
v2456 = v2448;
/* START END */
gctab->size = 0;
mrb->allocf_ud = (void *)gctab;
gctab->single[0] = &mutexself;/* normal */
gctab->single[1] = &v2456;/* normal */
gctab->single[2] = &self;/* normal */
gctab->size = 3;
pthread_mutex_lock(((struct mmc_system *)mrb->ud)->io_mutex);
mrb->allocf_ud = (void *)gctab;
mrb_p(mrb, (mrb_str_new_cstr(mrb, "skip")));
pthread_mutex_unlock(((struct mmc_system *)mrb->ud)->io_mutex);
v2470 = "skip";
v2484 = v2456; /* 1*/
L111:;
v2491 = v2484;
v2492 = (mrb_fixnum(ARY_PTR(mrb_ary_ptr(self))[0]));
{
mrb_value val = ({
struct mutex_wrapper *mutex = (struct mutex_wrapper *)DATA_PTR(v2491);
pthread_mutex_lock(&mutex->mp);
mrb_iv_get(mrb, v2491, mrb_intern_cstr(mrb, "@object"));
})
;
v2494 = ((v2492) < ARY_LEN(mrb_ary_ptr(val))) ? ARY_PTR(mrb_ary_ptr(val))[v2492] : mrb_nil_value();
}
pthread_mutex_unlock(&((struct mutex_wrapper *)(DATA_PTR(v2491)))->mp);
if ((mrb_test(v2494))) goto L110; else goto L112;
L110:;
v2480 = (mrb_fixnum(ARY_PTR(mrb_ary_ptr(self))[0]));
v2481 = (v2480 + 1);
{mrb_value val;
val = (mrb_fixnum_value(v2481));
ARY_PTR(mrb_ary_ptr(self))[0] = (mrb_fixnum_value(v2481));
}
v2484 = v2484; /* 2*/
goto L111;
L112:;
v2505 = (mrb_fixnum(ARY_PTR(mrb_ary_ptr(self))[0]));
gctab->single[1] = &self;/* normal */
gctab->size = 2;
pthread_mutex_lock(((struct mmc_system *)mrb->ud)->io_mutex);
mrb->allocf_ud = (void *)gctab;
mrb_p(mrb, (mrb_fixnum_value(v2505)));
pthread_mutex_unlock(((struct mmc_system *)mrb->ud)->io_mutex);
v2507 = v2505;
v2508 = (mrb_fixnum(ARY_PTR(mrb_ary_ptr(self))[0]));
pthread_mutex_lock(((struct mmc_system *)mrb->ud)->io_mutex);
mrb->allocf_ud = (void *)gctab;
mrb_p(mrb, (mrb_fixnum_value(v2508)));
pthread_mutex_unlock(((struct mmc_system *)mrb->ud)->io_mutex);
v2512 = v2508;
v2513 = (mrb_fixnum(ARY_PTR(mrb_ary_ptr(self))[0]));
v2514 = (v2513 + 1);
{mrb_value val;
val = (mrb_fixnum_value(v2514));
ARY_PTR(mrb_ary_ptr(self))[0] = (mrb_fixnum_value(v2514));
}
pthread_mutex_unlock(&((struct mutex_wrapper *)(DATA_PTR(mutexself)))->mp);
return v2508;
}
static mrb_int kakutani__Object__6(mrb_state *mrb, mrb_value v2971, mrb_int v2972, mrb_value_mutex v2973, struct gctab *prevgctab) {
struct env14 env;
struct REnv *venv = NULL;
mrb_value self;
mrb_value mutexself;
mrb_int v2985;
mrb_value_mutex v2986;
mrb_value_mutex v3004;/*snd*/
mrb_int v3005;/*snd*/
mrb_value v3007;
mrb_value_mutex v3141;
mrb_bool v3010;
;
mrb_bool v3032;/*snd1*/
mrb_int v3074;
mrb_value_mutex v3075;
mrb_int v3078;
mrb_value_mutex v3088;/*snd*/
mrb_int v3090;
mrb_int v3091;/*snd1*/
mrb_int v3092;/*snd*/
mrb_value_mutex v3093;/*snd*/
mrb_int v3095;/*snd*/
mrb_int v3097;
mrb_int v3070;/*snd1*/
struct gctab *gctab = (struct gctab *)alloca(sizeof(struct gctab) + 2 * sizeof(mrb_value *));
gctab->prev = prevgctab;
gctab->complex = NULL;
gctab->object = NULL;
gctab->size = 0;
gctab->csize = 0;
gctab->osize = 0;
gctab->ret_status = 0;
L132:;
mutexself = v2971;
self = v2971;
v2985 = v2972;
v2986 = v2973;
/* START END */
v3004 = v2986;
v3005 = v2985;
{
mrb_value val = ({
struct mutex_wrapper *mutex = (struct mutex_wrapper *)DATA_PTR(v3004);
pthread_mutex_lock(&mutex->mp);
mrb_iv_get(mrb, v3004, mrb_intern_cstr(mrb, "@object"));
})
;
v3007 = ((v3005) < ARY_LEN(mrb_ary_ptr(val))) ? ARY_PTR(mrb_ary_ptr(val))[v3005] : mrb_nil_value();
}
pthread_mutex_unlock(&((struct mutex_wrapper *)(DATA_PTR(v3004)))->mp);
gctab->single[0] = &v2986;/* normal */
gctab->size = 1;
if (1) {
v3010 = mrb_nil_p(v3007);
}
else {
v3010 = mrb_nil_p(v3007);
}
if (v3010) goto L133; else goto L138;
L133:;
v3032 = ((v2985 & 1) == 0);
if (v3032) goto L134; else goto L135;
L134:;
v3074 = v2985; /* 1*/
v3075 = v2986; /* 1*/
v3078 = (v2985 >> 1); /* 1*/
L136:;
v3088 = v3075;
gctab->single[0] = &v3075;/* normal */
v3090 = kakutani__Object__6(mrb, self, v3078, v3088, gctab);
v3091 = (v3090 + 1);
v3092 = v3091;
v3093 = v3075;
v3095 = v3091;
gctab->single[1] = &v3093;/* normal */
gctab->size = 2;
mrb->allocf_ud = (void *)gctab;
mrb_ary_set(mrb, ({
struct mutex_wrapper *mutex = (struct mutex_wrapper *)DATA_PTR(v3093);
pthread_mutex_lock(&mutex->mp);
mrb_iv_get(mrb, v3093, mrb_intern_cstr(mrb, "@object"));
})
, v3074, (mrb_fixnum_value(v3095)));
v3097 = v3095;
pthread_mutex_unlock(&((struct mutex_wrapper *)(DATA_PTR(v3093)))->mp);
return v3092;
L135:;
v3070 = ((v2985 * 3) + 1);
v3074 = v2985; /* 2*/
v3075 = v2986; /* 2*/
v3078 = v3070; /* 2*/
goto L136;
L138:;
return (mrb_fixnum(v3007));
}
/*
Class Object
Instance variables
methodes
foo (Object e=false, NilClass e=false l=0 var=0) -> Mutex<Array<[:undef] => Fixnum e=false|[:undef] => NilClass e=false l=0 var=0|[:undef] => Fixnum e=false pos =true|0 => Fixnum e=false|0 => Fixnum e=false pos =true|1 => Fixnum e=false|1 => Fixnum e=false pos =true> e=true l=3>
-- effects ---
kakutani (Object e=false, Fixnum e=false pos =true, Mutex<Array<[:undef] => Fixnum e=false|[:undef] => NilClass e=false l=0 var=0|[:undef] => Fixnum e=false pos =true|0 => Fixnum e=false|0 => Fixnum e=false pos =true|1 => Fixnum e=false|1 => Fixnum e=false pos =true> e=true l=3>, NilClass e=false l=0 var=0) -> Fixnum e=false pos =true
-- effects ---
modify []= [[Mutex<Array<[:undef] => Fixnum val=0 e=false|[:undef] => NilClass e=false l=0 var=0|[:undef] => Fixnum e=false pos =true|0 => Fixnum val=0 e=false|0 => Fixnum e=false pos =true|1 => Fixnum val=0 e=false|1 => Fixnum e=false pos =true> e=true l=3>]]
Class Count
Instance variables
@c: Fixnum e=false pos =true
methodes
initialize (Mutex<Count e=false l=3 var=0>, NilClass e=false l=0 var=0) -> Fixnum e=false
initialize (Mutex<Count e=true l=3 var=0>, NilClass e=false l=0 var=0) -> Fixnum e=false
-- effects ---
iv_write @c SETIV 2 3
iv_write @c SETIV 2 3
iv_write @c SETIV 2 3
iv_write @c SETIV 2 3
c (Mutex<Count e=true l=3 var=0>, NilClass e=false l=0 var=0) -> Fixnum e=false
-- effects ---
iv_read @c GETIV 2 3
iv_read @c GETIV 2 3
skip_cnt (Mutex<Count e=true l=3 var=0>, Mutex<Array<[:undef] => Fixnum e=false|[:undef] => NilClass e=false l=0 var=0|[:undef] => Fixnum e=false pos =true|0 => Fixnum e=false|0 => Fixnum e=false pos =true|1 => Fixnum e=false|1 => Fixnum e=false pos =true> e=true l=3>, NilClass e=false l=0 var=0) -> Fixnum e=false pos =true
-- effects ---
iv_read @c GETIV 2 3
iv_read @c GETIV 2 3
iv_read @c GETIV 2 3
iv_read @c GETIV 2 3
iv_read @c GETIV 2 3
iv_read @c GETIV 2 3
iv_read @c GETIV 2 3
iv_read @c GETIV 2 3
iv_read @c GETIV 2 3
iv_read @c GETIV 2 3
iv_read @c GETIV 2 3
iv_read @c GETIV 2 3
iv_write @c SETIV 2 3
iv_write @c SETIV 2 3
iv_write @c SETIV 2 3
iv_write @c SETIV 2 3
Class #<Class:MMC_EXT>
Instance variables
methodes
Class #<Class:Count>
Instance variables
methodes
Class MMC_EXT::Mutex
Instance variables
methodes
Class MMC_EXT::Thread
Instance variables
methodes
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment