Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
9f041078
Unverified
Commit
9f041078
authored
Oct 29, 2021
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
boxing_nan.h: allow `MRB_INT64` with `MRB_NAN_BOXING`.
Integers out of 32 bit range will be allocated in the heap.
parent
85fcd2dc
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
64 additions
and
41 deletions
+64
-41
build_config/boxing.rb
build_config/boxing.rb
+0
-2
include/mruby/boxing_nan.h
include/mruby/boxing_nan.h
+42
-13
include/mruby/boxing_word.h
include/mruby/boxing_word.h
+2
-2
src/etc.c
src/etc.c
+19
-23
src/kernel.c
src/kernel.c
+1
-1
No files found.
build_config/boxing.rb
View file @
9f041078
...
@@ -3,8 +3,6 @@ bits = [64, 32]
...
@@ -3,8 +3,6 @@ bits = [64, 32]
ints
=
[
64
,
32
]
ints
=
[
64
,
32
]
boxings
.
product
(
bits
,
ints
)
do
|
boxing
,
bit
,
int
|
boxings
.
product
(
bits
,
ints
)
do
|
boxing
,
bit
,
int
|
next
if
boxing
==
"nan"
&&
int
==
64
MRuby
::
Build
.
new
(
"boxing-
#{
boxing
}
-m
#{
bit
}
-i
#{
int
}
"
)
do
|
conf
|
MRuby
::
Build
.
new
(
"boxing-
#{
boxing
}
-m
#{
bit
}
-i
#{
int
}
"
)
do
|
conf
|
conf
.
toolchain
:gcc
conf
.
toolchain
:gcc
conf
.
gembox
'default'
conf
.
gembox
'default'
...
...
include/mruby/boxing_nan.h
View file @
9f041078
...
@@ -15,12 +15,6 @@
...
@@ -15,12 +15,6 @@
# error ---->> MRB_NAN_BOXING and MRB_NO_FLOAT conflict <<----
# error ---->> MRB_NAN_BOXING and MRB_NO_FLOAT conflict <<----
#endif
#endif
#ifdef MRB_INT64
# error ---->> MRB_NAN_BOXING and MRB_INT64 conflict <<----
#endif
#define MRB_FIXNUM_SHIFT 0
#define MRB_SYMBOL_SHIFT 0
#define MRB_FIXNUM_MIN INT32_MIN
#define MRB_FIXNUM_MIN INT32_MIN
#define MRB_FIXNUM_MAX INT32_MAX
#define MRB_FIXNUM_MAX INT32_MAX
...
@@ -74,18 +68,19 @@ mrb_nan_boxing_value_float(mrb_value v)
...
@@ -74,18 +68,19 @@ mrb_nan_boxing_value_float(mrb_value v)
r.u = float_uint_union.u + 0x8004000000000000; \
r.u = float_uint_union.u + 0x8004000000000000; \
} while(0)
} while(0)
#define NANBOX_SET_VALUE(o, tt, v) do { \
(o).u = ((uint64_t)tt<<48) | (uint64_t)(v); \
} while (0)
#define mrb_float_p(o) (((uint64_t)(o.u)&0xfffc000000000000) != 0)
#define mrb_float_p(o) (((uint64_t)(o.u)&0xfffc000000000000) != 0)
struct
RInteger
{
MRB_OBJECT_HEADER
;
mrb_int
i
;
};
MRB_INLINE
enum
mrb_vtype
MRB_INLINE
enum
mrb_vtype
mrb_type
(
mrb_value
o
)
mrb_type
(
mrb_value
o
)
{
{
if
(
mrb_float_p
(
o
))
return
MRB_TT_FLOAT
;
if
(
mrb_float_p
(
o
))
return
MRB_TT_FLOAT
;
u
int64_t
u
=
o
.
u
;
int64_t
u
=
o
.
u
;
switch
((
enum
mrb_nanbox_tt_inline
)((
u
>>
48
)
&
3
))
{
switch
((
enum
mrb_nanbox_tt_inline
)((
u
>>
48
)
&
3
))
{
case
MRB_NANBOX_TT_POINTER
:
{
case
MRB_NANBOX_TT_POINTER
:
{
if
(
u
==
0
)
return
MRB_TT_FALSE
;
if
(
u
==
0
)
return
MRB_TT_FALSE
;
...
@@ -107,17 +102,50 @@ mrb_type(mrb_value o)
...
@@ -107,17 +102,50 @@ mrb_type(mrb_value o)
#define NANBOX_SET_MISC_VALUE(r,t,i) NANBOX_SET_VALUE(r, MRB_NANBOX_TT_MISC, ((t)<<8) | i)
#define NANBOX_SET_MISC_VALUE(r,t,i) NANBOX_SET_VALUE(r, MRB_NANBOX_TT_MISC, ((t)<<8) | i)
#define mrb_float(o) mrb_nan_boxing_value_float(o)
#define mrb_float(o) mrb_nan_boxing_value_float(o)
#ifdef MRB_INT64
/*
#ifdef MRB_32BIT
#define mrb_fixnum(o) ((mrb_int)((intptr_t)0xffffffffffff&((o).u))|(((o).u & 0x800000000000)?0xffff000000000000:0))
#else
#define mrb_fixnum(o) ((mrb_int)(int32_t)((o).u))
#endif
*/
#define mrb_fixnum(o) ((mrb_int)(int32_t)((o).u))
static
inline
mrb_int
mrb_nan_boxing_value_int
(
mrb_value
v
)
{
uint64_t
u
=
v
.
u
;
if
(((
u
>>
48
)
&
3
)
==
MRB_NANBOX_TT_POINTER
)
{
struct
RInteger
*
p
=
(
struct
RInteger
*
)(
uintptr_t
)
u
;
return
p
->
i
;
}
return
mrb_fixnum
(
v
);
}
#define mrb_integer(o) mrb_nan_boxing_value_int(o)
#else
#define mrb_fixnum(o) ((mrb_int)(((uintptr_t)0xffffffff)&((o).u)))
#define mrb_fixnum(o) ((mrb_int)(((uintptr_t)0xffffffff)&((o).u)))
#define mrb_integer(o) mrb_fixnum(o)
#define mrb_integer(o) mrb_fixnum(o)
#endif
#define mrb_symbol(o) ((mrb_sym)((uintptr_t)0xffffffff)&((o).u))
#define mrb_symbol(o) ((mrb_sym)((uintptr_t)0xffffffff)&((o).u))
#define mrb_ptr(o) ((void*)(uintptr_t)(o).u)
#define mrb_ptr(o) ((void*)(uintptr_t)(o).u)
#define mrb_cptr(o) ((void*)(uintptr_t)(0xfffffffffffe&(o).u))
#define mrb_cptr(o) ((void*)(uintptr_t)(0xfffffffffffe&(o).u))
#define NANBOX_SET_VALUE(o, tt, v) do { \
(o).u = ((uint64_t)tt<<48) | ((uint64_t)(v)); \
} while (0)
#define SET_NIL_VALUE(r) NANBOX_SET_MISC_VALUE(r, MRB_TT_FALSE, 0)
#define SET_NIL_VALUE(r) NANBOX_SET_MISC_VALUE(r, MRB_TT_FALSE, 0)
#define SET_FALSE_VALUE(r) NANBOX_SET_MISC_VALUE(r, MRB_TT_FALSE, 1)
#define SET_FALSE_VALUE(r) NANBOX_SET_MISC_VALUE(r, MRB_TT_FALSE, 1)
#define SET_TRUE_VALUE(r) NANBOX_SET_MISC_VALUE(r, MRB_TT_TRUE, 1)
#define SET_TRUE_VALUE(r) NANBOX_SET_MISC_VALUE(r, MRB_TT_TRUE, 1)
#define SET_BOOL_VALUE(r,b) NANBOX_SET_MISC_VALUE(r, (b) ? MRB_TT_TRUE : MRB_TT_FALSE, 1)
#define SET_BOOL_VALUE(r,b) NANBOX_SET_MISC_VALUE(r, (b) ? MRB_TT_TRUE : MRB_TT_FALSE, 1)
#define SET_INT_VALUE(mrb,r,n) SET_FIXNUM_VALUE(r,n)
#ifdef MRB_INT64
MRB_API
mrb_value
mrb_boxing_int_value
(
struct
mrb_state
*
,
mrb_int
);
#define SET_INT_VALUE(mrb, r, n) ((r) = mrb_boxing_int_value(mrb, n))
#else
#define SET_INT_VALUE(mrb, r, n) SET_FIXNUM_VALUE(r, n)
#endif
#define SET_FIXNUM_VALUE(r,n) NANBOX_SET_VALUE(r, MRB_NANBOX_TT_INTEGER, (uint32_t)(n))
#define SET_FIXNUM_VALUE(r,n) NANBOX_SET_VALUE(r, MRB_NANBOX_TT_INTEGER, (uint32_t)(n))
#define SET_SYM_VALUE(r,v) NANBOX_SET_VALUE(r, MRB_NANBOX_TT_SYMBOL, (uint32_t)(v))
#define SET_SYM_VALUE(r,v) NANBOX_SET_VALUE(r, MRB_NANBOX_TT_SYMBOL, (uint32_t)(v))
#define SET_OBJ_VALUE(r,v) do {(r).u = (uint64_t)(uintptr_t)v;} while (0)
#define SET_OBJ_VALUE(r,v) do {(r).u = (uint64_t)(uintptr_t)v;} while (0)
...
@@ -126,5 +154,6 @@ mrb_type(mrb_value o)
...
@@ -126,5 +154,6 @@ mrb_type(mrb_value o)
#define mrb_nil_p(o) (mrb_type(o) == MRB_TT_FALSE && ((o).u & 3) == 0)
#define mrb_nil_p(o) (mrb_type(o) == MRB_TT_FALSE && ((o).u & 3) == 0)
#define mrb_false_p(o) (mrb_type(o) == MRB_TT_FALSE && ((o).u & 2) == 0)
#define mrb_false_p(o) (mrb_type(o) == MRB_TT_FALSE && ((o).u & 2) == 0)
#define mrb_fixnum_p(o) (!mrb_float_p(o) && ((o.u>>48)&3)==MRB_NANBOX_TT_INTEGER)
#endif
/* MRUBY_BOXING_NAN_H */
#endif
/* MRUBY_BOXING_NAN_H */
include/mruby/boxing_word.h
View file @
9f041078
...
@@ -144,7 +144,7 @@ MRB_API mrb_value mrb_word_boxing_cptr_value(struct mrb_state*, void*);
...
@@ -144,7 +144,7 @@ MRB_API mrb_value mrb_word_boxing_cptr_value(struct mrb_state*, void*);
#ifndef MRB_NO_FLOAT
#ifndef MRB_NO_FLOAT
MRB_API
mrb_value
mrb_word_boxing_float_value
(
struct
mrb_state
*
,
mrb_float
);
MRB_API
mrb_value
mrb_word_boxing_float_value
(
struct
mrb_state
*
,
mrb_float
);
#endif
#endif
MRB_API
mrb_value
mrb_
word_
boxing_int_value
(
struct
mrb_state
*
,
mrb_int
);
MRB_API
mrb_value
mrb_boxing_int_value
(
struct
mrb_state
*
,
mrb_int
);
#define mrb_immediate_p(o) ((o).w & WORDBOX_IMMEDIATE_MASK || (o).w == MRB_Qnil)
#define mrb_immediate_p(o) ((o).w & WORDBOX_IMMEDIATE_MASK || (o).w == MRB_Qnil)
...
@@ -210,7 +210,7 @@ mrb_integer_func(mrb_value o) {
...
@@ -210,7 +210,7 @@ mrb_integer_func(mrb_value o) {
#define SET_FALSE_VALUE(r) ((r).w = MRB_Qfalse)
#define SET_FALSE_VALUE(r) ((r).w = MRB_Qfalse)
#define SET_TRUE_VALUE(r) ((r).w = MRB_Qtrue)
#define SET_TRUE_VALUE(r) ((r).w = MRB_Qtrue)
#define SET_BOOL_VALUE(r,b) ((b) ? SET_TRUE_VALUE(r) : SET_FALSE_VALUE(r))
#define SET_BOOL_VALUE(r,b) ((b) ? SET_TRUE_VALUE(r) : SET_FALSE_VALUE(r))
#define SET_INT_VALUE(mrb,r,n) ((r) = mrb_
word_
boxing_int_value(mrb, n))
#define SET_INT_VALUE(mrb,r,n) ((r) = mrb_boxing_int_value(mrb, n))
#define SET_FIXNUM_VALUE(r,n) WORDBOX_SET_SHIFT_VALUE(r, FIXNUM, n)
#define SET_FIXNUM_VALUE(r,n) WORDBOX_SET_SHIFT_VALUE(r, FIXNUM, n)
#define SET_SYM_VALUE(r,n) WORDBOX_SET_SHIFT_VALUE(r, SYMBOL, n)
#define SET_SYM_VALUE(r,n) WORDBOX_SET_SHIFT_VALUE(r, SYMBOL, n)
#define SET_OBJ_VALUE(r,v) ((r).w = (uintptr_t)(v))
#define SET_OBJ_VALUE(r,v) ((r).w = (uintptr_t)(v))
...
...
src/etc.c
View file @
9f041078
...
@@ -145,13 +145,7 @@ mrb_obj_id(mrb_value obj)
...
@@ -145,13 +145,7 @@ mrb_obj_id(mrb_value obj)
}
}
}
}
#if defined(MRB_NAN_BOXING) && defined(MRB_64BIT)
#define mrb_xxx_boxing_cptr_value mrb_nan_boxing_cptr_value
#endif
#ifdef MRB_WORD_BOXING
#ifdef MRB_WORD_BOXING
#define mrb_xxx_boxing_cptr_value mrb_word_boxing_cptr_value
#ifndef MRB_NO_FLOAT
#ifndef MRB_NO_FLOAT
MRB_API
mrb_value
MRB_API
mrb_value
mrb_word_boxing_float_value
(
mrb_state
*
mrb
,
mrb_float
f
)
mrb_word_boxing_float_value
(
mrb_state
*
mrb
,
mrb_float
f
)
...
@@ -190,30 +184,32 @@ mrb_word_boxing_value_float(mrb_value v)
...
@@ -190,30 +184,32 @@ mrb_word_boxing_value_float(mrb_value v)
#endif
/* MRB_NO_FLOAT */
#endif
/* MRB_NO_FLOAT */
MRB_API
mrb_value
MRB_API
mrb_value
mrb_word_boxing_
int_value
(
mrb_state
*
mrb
,
mrb_int
n
)
mrb_word_boxing_
cptr_value
(
mrb_state
*
mrb
,
void
*
p
)
{
{
if
(
FIXABLE
(
n
))
return
mrb_fixnum_value
(
n
);
mrb_value
v
;
else
{
struct
RCptr
*
cptr
=
MRB_OBJ_ALLOC
(
mrb
,
MRB_TT_CPTR
,
mrb
->
object_class
);
union
mrb_value_
v
;
v
.
p
=
mrb_obj_alloc
(
mrb
,
MRB_TT_INTEGER
,
mrb
->
integer_class
);
SET_OBJ_VALUE
(
v
,
cptr
);
v
.
ip
->
i
=
n
;
cptr
->
p
=
p
;
MRB_SET_FROZEN_FLAG
(
v
.
ip
);
return
v
;
return
v
.
value
;
}
}
}
#endif
/* MRB_WORD_BOXING */
#endif
/* MRB_WORD_BOXING */
#if defined(MRB_WORD_BOXING) || (defined(MRB_NAN_BOXING) && defined(MRB_
64BIT
))
#if defined(MRB_WORD_BOXING) || (defined(MRB_NAN_BOXING) && defined(MRB_
INT64
))
MRB_API
mrb_value
MRB_API
mrb_value
mrb_
xxx_boxing_cptr_value
(
mrb_state
*
mrb
,
void
*
p
)
mrb_
boxing_int_value
(
mrb_state
*
mrb
,
mrb_int
n
)
{
{
if
(
FIXABLE
(
n
))
return
mrb_fixnum_value
(
n
);
else
{
mrb_value
v
;
mrb_value
v
;
struct
RCptr
*
cptr
=
MRB_OBJ_ALLOC
(
mrb
,
MRB_TT_CPTR
,
mrb
->
object_class
)
;
struct
RInteger
*
p
;
SET_OBJ_VALUE
(
v
,
cptr
);
p
=
(
struct
RInteger
*
)
mrb_obj_alloc
(
mrb
,
MRB_TT_INTEGER
,
mrb
->
integer_class
);
cptr
->
p
=
p
;
p
->
i
=
n
;
MRB_SET_FROZEN_FLAG
((
struct
RBasic
*
)
p
);
SET_OBJ_VALUE
(
v
,
p
);
return
v
;
return
v
;
}
}
}
#endif
#endif
...
...
src/kernel.c
View file @
9f041078
...
@@ -97,7 +97,7 @@ mrb_equal_m(mrb_state *mrb, mrb_value self)
...
@@ -97,7 +97,7 @@ mrb_equal_m(mrb_state *mrb, mrb_value self)
mrb_value
mrb_value
mrb_obj_id_m
(
mrb_state
*
mrb
,
mrb_value
self
)
mrb_obj_id_m
(
mrb_state
*
mrb
,
mrb_value
self
)
{
{
return
mrb_
int_value
(
mrb
,
mrb_obj_id
(
self
));
return
mrb_
fixnum_value
(
mrb_obj_id
(
self
));
}
}
static
int
static
int
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment