Last change
on this file since 331 was 331, checked in by coas-nagasima, 6 years ago |
prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl
|
-
Property svn:eol-style
set to
native
-
Property svn:mime-type
set to
text/x-ruby
|
File size:
1.5 KB
|
Rev | Line | |
---|
[331] | 1 | # The aim of these tests is to detect pitfall for optimized VM.
|
---|
| 2 |
|
---|
| 3 | # Test for or/and
|
---|
| 4 | #
|
---|
| 5 | # You may think instruction fusion(OP_EQ and OP_JMPIF) for avoiding
|
---|
| 6 | # generate intermediate boolean value.
|
---|
| 7 | # But and/or is pitfall for this fusioning.
|
---|
| 8 | #
|
---|
| 9 | # For example, the following mruby code:
|
---|
| 10 | #
|
---|
| 11 | # if i > 0 and i < 10 then
|
---|
| 12 | #
|
---|
| 13 | # compiles to the following byte code:
|
---|
| 14 | #
|
---|
| 15 | # 1 000 OP_LOADI R1 0 ; R1:i
|
---|
| 16 | # 2 001 OP_MOVE R2 R1 ; R1:i
|
---|
| 17 | # 2 002 OP_LOADI R3 0
|
---|
| 18 | # 2 003 OP_GT R2 :> 1
|
---|
| 19 | # 2 004 OP_JMPNOT R2 008
|
---|
| 20 | # 2 005 OP_MOVE R2 R1 ; R1:i
|
---|
| 21 | # 2 006 OP_LOADI R3 10
|
---|
| 22 | # 2 007 OP_LT R2 :< 1
|
---|
| 23 | # 2 008 OP_JMPNOT R2 (The address of end of then part)
|
---|
| 24 | #
|
---|
| 25 | # When the instruction fusion the OP_GT and OP_JMPNOT you fell into the pitfalls.
|
---|
| 26 | # The deleted intermediate boolean value is used in OP_JMPNOT (address 008).
|
---|
| 27 |
|
---|
| 28 | assert('and', '11.2.3') do
|
---|
| 29 | a = 1
|
---|
| 30 | if a > 0 and a < 10 then
|
---|
| 31 | b = 1
|
---|
| 32 | else
|
---|
| 33 | b = 0
|
---|
| 34 | end
|
---|
| 35 | assert_equal 1, b
|
---|
| 36 |
|
---|
| 37 | if a < 0 and a < 10 then
|
---|
| 38 | b = 1
|
---|
| 39 | else
|
---|
| 40 | b = 0
|
---|
| 41 | end
|
---|
| 42 | assert_equal 0, b
|
---|
| 43 |
|
---|
| 44 | if a < 0 and a > 10 then
|
---|
| 45 | b = 1
|
---|
| 46 | else
|
---|
| 47 | b = 0
|
---|
| 48 | end
|
---|
| 49 | assert_equal 0, b
|
---|
| 50 | end
|
---|
| 51 |
|
---|
| 52 | assert('or','11.2.4') do
|
---|
| 53 | a = 1
|
---|
| 54 | if a > 0 or a < 10 then
|
---|
| 55 | b = 1
|
---|
| 56 | else
|
---|
| 57 | b = 0
|
---|
| 58 | end
|
---|
| 59 | assert_equal 1, b
|
---|
| 60 |
|
---|
| 61 | if a < 0 or a < 10 then
|
---|
| 62 | b = 1
|
---|
| 63 | else
|
---|
| 64 | b = 0
|
---|
| 65 | end
|
---|
| 66 | assert_equal 1, b
|
---|
| 67 |
|
---|
| 68 | if a < 0 or a > 10 then
|
---|
| 69 | b = 1
|
---|
| 70 | else
|
---|
| 71 | b = 0
|
---|
| 72 | end
|
---|
| 73 | assert_equal 0, b
|
---|
| 74 | end
|
---|
Note:
See
TracBrowser
for help on using the repository browser.