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
597149ae
Commit
597149ae
authored
Nov 22, 2017
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change newline style of test/t/lang.rb (from DOS)
parent
b4f9b031
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
74 deletions
+74
-74
test/t/lang.rb
test/t/lang.rb
+74
-74
No files found.
test/t/lang.rb
View file @
597149ae
# The aim of these tests is to detect pitfall for optimized VM.
# Test for or/and
#
# You may think instruction fusion(OP_EQ and OP_JMPIF) for avoiding
# generate intermediate boolean value.
# But and/or is pitfall for this fusioning.
#
# For example, the following mruby code:
#
# if i > 0 and i < 10
#
# compiles to the following byte code:
#
# 1 000 OP_LOADI R1 0 ; R1:i
# 2 001 OP_MOVE R2 R1 ; R1:i
# 2 002 OP_LOADI R3 0
# 2 003 OP_GT R2 :> 1
# 2 004 OP_JMPNOT R2 008
# 2 005 OP_MOVE R2 R1 ; R1:i
# 2 006 OP_LOADI R3 10
# 2 007 OP_LT R2 :< 1
# 2 008 OP_JMPNOT R2 (The address of end of then part)
#
# When the instruction fusion the OP_GT and OP_JMPNOT you fell into the pitfalls.
# The deleted intermediate boolean value is used in OP_JMPNOT (address 008).
assert
(
'and'
,
'11.2.3'
)
do
a
=
1
if
a
>
0
and
a
<
10
b
=
1
else
b
=
0
end
assert_equal
1
,
b
if
a
<
0
and
a
<
10
b
=
1
else
b
=
0
end
assert_equal
0
,
b
if
a
<
0
and
a
>
10
b
=
1
else
b
=
0
end
assert_equal
0
,
b
end
assert
(
'or'
,
'11.2.4'
)
do
a
=
1
if
a
>
0
or
a
<
10
b
=
1
else
b
=
0
end
assert_equal
1
,
b
if
a
<
0
or
a
<
10
b
=
1
else
b
=
0
end
assert_equal
1
,
b
if
a
<
0
or
a
>
10
b
=
1
else
b
=
0
end
assert_equal
0
,
b
end
# The aim of these tests is to detect pitfall for optimized VM.
# Test for or/and
#
# You may think instruction fusion(OP_EQ and OP_JMPIF) for avoiding
# generate intermediate boolean value.
# But and/or is pitfall for this fusioning.
#
# For example, the following mruby code:
#
# if i > 0 and i < 10
#
# compiles to the following byte code:
#
# 1 000 OP_LOADI R1 0 ; R1:i
# 2 001 OP_MOVE R2 R1 ; R1:i
# 2 002 OP_LOADI R3 0
# 2 003 OP_GT R2 :> 1
# 2 004 OP_JMPNOT R2 008
# 2 005 OP_MOVE R2 R1 ; R1:i
# 2 006 OP_LOADI R3 10
# 2 007 OP_LT R2 :< 1
# 2 008 OP_JMPNOT R2 (The address of end of then part)
#
# When the instruction fusion the OP_GT and OP_JMPNOT you fell into the pitfalls.
# The deleted intermediate boolean value is used in OP_JMPNOT (address 008).
assert
(
'and'
,
'11.2.3'
)
do
a
=
1
if
a
>
0
and
a
<
10
b
=
1
else
b
=
0
end
assert_equal
1
,
b
if
a
<
0
and
a
<
10
b
=
1
else
b
=
0
end
assert_equal
0
,
b
if
a
<
0
and
a
>
10
b
=
1
else
b
=
0
end
assert_equal
0
,
b
end
assert
(
'or'
,
'11.2.4'
)
do
a
=
1
if
a
>
0
or
a
<
10
b
=
1
else
b
=
0
end
assert_equal
1
,
b
if
a
<
0
or
a
<
10
b
=
1
else
b
=
0
end
assert_equal
1
,
b
if
a
<
0
or
a
>
10
b
=
1
else
b
=
0
end
assert_equal
0
,
b
end
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