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
4d8ff2fb
Unverified
Commit
4d8ff2fb
authored
Apr 14, 2019
by
Yukihiro "Matz" Matsumoto
Committed by
GitHub
Apr 14, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4373 from shuujii/fix-broken-NaN-with-MRB_NAN_BOXING
Fix broken NaN with `MRB_NAN_BOXING`
parents
79fd986b
f639da0f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
80 deletions
+16
-80
src/vm.c
src/vm.c
+16
-80
No files found.
src/vm.c
View file @
4d8ff2fb
...
...
@@ -2214,9 +2214,13 @@ RETRY_TRY_BLOCK:
}
#define TYPES2(a,b) ((((uint16_t)(a))<<8)|(((uint16_t)(b))&0xff))
#define OP_MATH_BODY(op,v1,v2) do {\
v1(regs[a]) = v1(regs[a]) op v2(regs[a+1]);\
} while(0)
#define OP_MATH_FLOAT_BODY(op,t1,t2) do { \
RETURN_TYPE_OF_##t1 x = t1(regs[a]); \
RETURN_TYPE_OF_##t2 y = t2(regs[a+1]); \
SET_FLOAT_VALUE(mrb, regs[a], x op y); \
} while (0)
#define RETURN_TYPE_OF_mrb_fixnum mrb_int
#define RETURN_TYPE_OF_mrb_float mrb_float
CASE
(
OP_ADD
,
B
)
{
/* need to check if op is overridden */
...
...
@@ -2239,33 +2243,13 @@ RETRY_TRY_BLOCK:
break
;
#ifndef MRB_WITHOUT_FLOAT
case
TYPES2
(
MRB_TT_FIXNUM
,
MRB_TT_FLOAT
):
{
mrb_int
x
=
mrb_fixnum
(
regs
[
a
]);
mrb_float
y
=
mrb_float
(
regs
[
a
+
1
]);
SET_FLOAT_VALUE
(
mrb
,
regs
[
a
],
(
mrb_float
)
x
+
y
);
}
OP_MATH_FLOAT_BODY
(
+
,
mrb_fixnum
,
mrb_float
);
break
;
case
TYPES2
(
MRB_TT_FLOAT
,
MRB_TT_FIXNUM
):
#ifdef MRB_WORD_BOXING
{
mrb_float
x
=
mrb_float
(
regs
[
a
]);
mrb_int
y
=
mrb_fixnum
(
regs
[
a
+
1
]);
SET_FLOAT_VALUE
(
mrb
,
regs
[
a
],
x
+
y
);
}
#else
OP_MATH_BODY
(
+
,
mrb_float
,
mrb_fixnum
);
#endif
OP_MATH_FLOAT_BODY
(
+
,
mrb_float
,
mrb_fixnum
);
break
;
case
TYPES2
(
MRB_TT_FLOAT
,
MRB_TT_FLOAT
):
#ifdef MRB_WORD_BOXING
{
mrb_float
x
=
mrb_float
(
regs
[
a
]);
mrb_float
y
=
mrb_float
(
regs
[
a
+
1
]);
SET_FLOAT_VALUE
(
mrb
,
regs
[
a
],
x
+
y
);
}
#else
OP_MATH_BODY
(
+
,
mrb_float
,
mrb_float
);
#endif
OP_MATH_FLOAT_BODY
(
+
,
mrb_float
,
mrb_float
);
break
;
#endif
case
TYPES2
(
MRB_TT_STRING
,
MRB_TT_STRING
):
...
...
@@ -2300,33 +2284,13 @@ RETRY_TRY_BLOCK:
break
;
#ifndef MRB_WITHOUT_FLOAT
case
TYPES2
(
MRB_TT_FIXNUM
,
MRB_TT_FLOAT
):
{
mrb_int
x
=
mrb_fixnum
(
regs
[
a
]);
mrb_float
y
=
mrb_float
(
regs
[
a
+
1
]);
SET_FLOAT_VALUE
(
mrb
,
regs
[
a
],
(
mrb_float
)
x
-
y
);
}
OP_MATH_FLOAT_BODY
(
-
,
mrb_fixnum
,
mrb_float
);
break
;
case
TYPES2
(
MRB_TT_FLOAT
,
MRB_TT_FIXNUM
):
#ifdef MRB_WORD_BOXING
{
mrb_float
x
=
mrb_float
(
regs
[
a
]);
mrb_int
y
=
mrb_fixnum
(
regs
[
a
+
1
]);
SET_FLOAT_VALUE
(
mrb
,
regs
[
a
],
x
-
y
);
}
#else
OP_MATH_BODY
(
-
,
mrb_float
,
mrb_fixnum
);
#endif
OP_MATH_FLOAT_BODY
(
-
,
mrb_float
,
mrb_fixnum
);
break
;
case
TYPES2
(
MRB_TT_FLOAT
,
MRB_TT_FLOAT
):
#ifdef MRB_WORD_BOXING
{
mrb_float
x
=
mrb_float
(
regs
[
a
]);
mrb_float
y
=
mrb_float
(
regs
[
a
+
1
]);
SET_FLOAT_VALUE
(
mrb
,
regs
[
a
],
x
-
y
);
}
#else
OP_MATH_BODY
(
-
,
mrb_float
,
mrb_float
);
#endif
OP_MATH_FLOAT_BODY
(
-
,
mrb_float
,
mrb_float
);
break
;
#endif
default:
...
...
@@ -2357,33 +2321,13 @@ RETRY_TRY_BLOCK:
break
;
#ifndef MRB_WITHOUT_FLOAT
case
TYPES2
(
MRB_TT_FIXNUM
,
MRB_TT_FLOAT
):
{
mrb_int
x
=
mrb_fixnum
(
regs
[
a
]);
mrb_float
y
=
mrb_float
(
regs
[
a
+
1
]);
SET_FLOAT_VALUE
(
mrb
,
regs
[
a
],
(
mrb_float
)
x
*
y
);
}
OP_MATH_FLOAT_BODY
(
*
,
mrb_fixnum
,
mrb_float
);
break
;
case
TYPES2
(
MRB_TT_FLOAT
,
MRB_TT_FIXNUM
):
#ifdef MRB_WORD_BOXING
{
mrb_float
x
=
mrb_float
(
regs
[
a
]);
mrb_int
y
=
mrb_fixnum
(
regs
[
a
+
1
]);
SET_FLOAT_VALUE
(
mrb
,
regs
[
a
],
x
*
y
);
}
#else
OP_MATH_BODY
(
*
,
mrb_float
,
mrb_fixnum
);
#endif
OP_MATH_FLOAT_BODY
(
*
,
mrb_float
,
mrb_fixnum
);
break
;
case
TYPES2
(
MRB_TT_FLOAT
,
MRB_TT_FLOAT
):
#ifdef MRB_WORD_BOXING
{
mrb_float
x
=
mrb_float
(
regs
[
a
]);
mrb_float
y
=
mrb_float
(
regs
[
a
+
1
]);
SET_FLOAT_VALUE
(
mrb
,
regs
[
a
],
x
*
y
);
}
#else
OP_MATH_BODY
(
*
,
mrb_float
,
mrb_float
);
#endif
OP_MATH_FLOAT_BODY
(
*
,
mrb_float
,
mrb_float
);
break
;
#endif
default:
...
...
@@ -2466,14 +2410,10 @@ RETRY_TRY_BLOCK:
break
;
#ifndef MRB_WITHOUT_FLOAT
case
MRB_TT_FLOAT
:
#ifdef MRB_WORD_BOXING
{
mrb_float
x
=
mrb_float
(
regs
[
a
]);
SET_FLOAT_VALUE
(
mrb
,
regs
[
a
],
x
+
b
);
}
#else
mrb_float
(
regs
[
a
])
+=
b
;
#endif
break
;
#endif
default:
...
...
@@ -2507,14 +2447,10 @@ RETRY_TRY_BLOCK:
break
;
#ifndef MRB_WITHOUT_FLOAT
case
MRB_TT_FLOAT
:
#ifdef MRB_WORD_BOXING
{
mrb_float
x
=
mrb_float
(
regs
[
a
]);
SET_FLOAT_VALUE
(
mrb
,
regs
[
a
],
(
mrb_float
)
x
-
(
mrb_float
)
b
);
}
#else
mrb_float
(
regs_a
[
0
])
-=
b
;
#endif
break
;
#endif
default:
...
...
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