Unverified Commit 71242c0f authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by GitHub

Merge pull request #4662 from...

Merge pull request #4662 from shuujii/fix-RBreak-exceeding-6-words-on-32-bit-mode-w-o-boxing-and-MRB_USE_FLOAT

Fix `RBreak` exceeding 6 words on 32-bit mode w/o boxing and `MRB_USE_FLOAT`
parents 14d5a86b be78b5d8
......@@ -10,15 +10,17 @@
#define MRB_FIXNUM_SHIFT 0
#define MRB_TT_HAS_BASIC MRB_TT_OBJECT
typedef struct mrb_value {
union {
union mrb_value_value {
#ifndef MRB_WITHOUT_FLOAT
mrb_float f;
#endif
void *p;
mrb_int i;
mrb_sym sym;
} value;
};
typedef struct mrb_value {
union mrb_value_value value;
enum mrb_vtype tt;
} mrb_value;
......
......@@ -32,11 +32,39 @@ MRB_API mrb_noreturn void mrb_no_method_error(mrb_state *mrb, mrb_sym id, mrb_va
/* declaration for `fail` method */
MRB_API mrb_value mrb_f_raise(mrb_state*, mrb_value);
#if defined(MRB_64BIT) || defined(MRB_USE_FLOAT) || defined(MRB_NAN_BOXING) || defined(MRB_WORD_BOXING)
struct RBreak {
MRB_OBJECT_HEADER;
struct RProc *proc;
mrb_value val;
};
#define mrb_break_value_get(brk) ((brk)->val)
#define mrb_break_value_set(brk, v) ((brk)->val = v)
#else
struct RBreak {
MRB_OBJECT_HEADER;
struct RProc *proc;
union mrb_value_value val_val;
};
#define RBREAK_VALUE_TT_MASK ((1 << 8) - 1)
static inline mrb_value
mrb_break_value_get(struct RBreak *brk)
{
mrb_value val;
val.value = brk->val_val;
val.tt = brk->flags & RBREAK_VALUE_TT_MASK;
return val;
}
static inline void
mrb_break_value_set(struct RBreak *brk, mrb_value val)
{
brk->val_val = val.value;
brk->flags &= ~RBREAK_VALUE_TT_MASK;
brk->flags |= val.tt;
}
#endif /* MRB_64BIT || MRB_USE_FLOAT || MRB_NAN_BOXING || MRB_WORD_BOXING */
#define mrb_break_proc_get(brk) ((brk)->proc)
#define mrb_break_proc_set(brk, p) ((brk)->proc = p)
/**
* Protect
......
......@@ -836,8 +836,8 @@ break_new(mrb_state *mrb, struct RProc *p, mrb_value val)
struct RBreak *brk;
brk = (struct RBreak*)mrb_obj_alloc(mrb, MRB_TT_BREAK, NULL);
brk->proc = p;
brk->val = val;
mrb_break_proc_set(brk, p);
mrb_break_value_set(brk, val);
return brk;
}
......@@ -2100,8 +2100,8 @@ RETRY_TRY_BLOCK:
}
if (FALSE) {
L_BREAK:
v = ((struct RBreak*)mrb->exc)->val;
proc = ((struct RBreak*)mrb->exc)->proc;
v = mrb_break_value_get((struct RBreak*)mrb->exc);
proc = mrb_break_proc_get((struct RBreak*)mrb->exc);
mrb->exc = NULL;
ci = mrb->c->ci;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment