Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add test case for JIT-compilation of multi-return

  • Loading branch information...
commit 11c2430de37447a706fdea44b164c5b03cbbd34c 1 parent 36c4355
@nominolo authored
Showing with 29 additions and 1 deletion.
  1. +1 −1  Makefile.in
  2. +24 −0 tests/Bc/MultiReturnJit.hs
  3. +4 −0 vm/unittest.cc
View
2  Makefile.in
@@ -175,7 +175,7 @@ TEST_FILES := tests/Bc/Bc0016.lcbc tests/Bc/Bc0014.lcbc \
tests/Bc/Side0003.lcbc \
tests/Bc/RealWorld.lcbc tests/Bc/SharedFail.lcbc \
tests/Bc/MultiReturn.lcbc tests/Bc/MultiReturn2.lcbc \
- tests/Bc/MultiReturn3.lcbc
+ tests/Bc/MultiReturn3.lcbc tests/Bc/MultiReturnJit.lcbc
lcvm: $(VM_SRCS:.cc=.o) vm/main.o
@echo "LINK $(filter %.o %.a, $^) => $@"
View
24 tests/Bc/MultiReturnJit.hs
@@ -0,0 +1,24 @@
+{-# LANGUAGE MagicHash, NoImplicitPrelude, UnboxedTuples, BangPatterns #-}
+{-# OPTIONS_GHC -fobject-code #-}
+module Bc.MultiReturnJit where
+
+import GHC.Prim
+import GHC.Types
+import GHC.Num
+import GHC.Base
+
+{-# NOINLINE sumlen #-}
+sumlen :: [Int] -> (# Int, Int #)
+sumlen [] = (# 0, 0 #)
+sumlen (I# x : xs) =
+ case sumlen xs of
+ (# I# s, I# l #) -> (# I# (s +# x), I# (l +# 1#) #)
+
+{-# NOINLINE enumFromTo #-}
+enumFromTo :: Int -> Int -> [Int]
+enumFromTo from@(I# m) to@(I# n) =
+ if m ># n then [] else
+ from : enumFromTo (I# (m +# 1#)) to
+
+test = case sumlen (enumFromTo 1 100) of
+ (# sum_, len_ #) -> sum_ == 5050 && len_ == 100
View
4 vm/unittest.cc
@@ -1089,6 +1089,10 @@ TEST_F(RunFileTest, MultiReturn3) {
run("Bc.MultiReturn3");
}
+TEST_F(RunFileTest, MultiReturnJit) {
+ run("Bc.MultiReturnJit");
+}
+
TEST(HotCounters, Simple) {
HotCounters counters(5);
BcIns pc[] = { BcIns::ad(BcIns::kFUNC, 3, 0) };
Please sign in to comment.
Something went wrong with that request. Please try again.