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 @@ ...@@ -10,15 +10,17 @@
#define MRB_FIXNUM_SHIFT 0 #define MRB_FIXNUM_SHIFT 0
#define MRB_TT_HAS_BASIC MRB_TT_OBJECT #define MRB_TT_HAS_BASIC MRB_TT_OBJECT
typedef struct mrb_value { union mrb_value_value {
union {
#ifndef MRB_WITHOUT_FLOAT #ifndef MRB_WITHOUT_FLOAT
mrb_float f; mrb_float f;
#endif #endif
void *p; void *p;
mrb_int i; mrb_int i;
mrb_sym sym; mrb_sym sym;
} value; };
typedef struct mrb_value {
union mrb_value_value value;
enum mrb_vtype tt; enum mrb_vtype tt;
} mrb_value; } mrb_value;
......
...@@ -32,11 +32,39 @@ MRB_API mrb_noreturn void mrb_no_method_error(mrb_state *mrb, mrb_sym id, mrb_va ...@@ -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 */ /* declaration for `fail` method */
MRB_API mrb_value mrb_f_raise(mrb_state*, mrb_value); 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 { struct RBreak {
MRB_OBJECT_HEADER; MRB_OBJECT_HEADER;
struct RProc *proc; struct RProc *proc;
mrb_value val; 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 * Protect
......
...@@ -836,8 +836,8 @@ break_new(mrb_state *mrb, struct RProc *p, mrb_value val) ...@@ -836,8 +836,8 @@ break_new(mrb_state *mrb, struct RProc *p, mrb_value val)
struct RBreak *brk; struct RBreak *brk;
brk = (struct RBreak*)mrb_obj_alloc(mrb, MRB_TT_BREAK, NULL); brk = (struct RBreak*)mrb_obj_alloc(mrb, MRB_TT_BREAK, NULL);
brk->proc = p; mrb_break_proc_set(brk, p);
brk->val = val; mrb_break_value_set(brk, val);
return brk; return brk;
} }
...@@ -2100,8 +2100,8 @@ RETRY_TRY_BLOCK: ...@@ -2100,8 +2100,8 @@ RETRY_TRY_BLOCK:
} }
if (FALSE) { if (FALSE) {
L_BREAK: L_BREAK:
v = ((struct RBreak*)mrb->exc)->val; v = mrb_break_value_get((struct RBreak*)mrb->exc);
proc = ((struct RBreak*)mrb->exc)->proc; proc = mrb_break_proc_get((struct RBreak*)mrb->exc);
mrb->exc = NULL; mrb->exc = NULL;
ci = mrb->c->ci; 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