summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorbuzbee <buzbee@google.com>2012-06-15 16:40:31 -0700
committerbuzbee <buzbee@google.com>2012-06-16 14:56:03 -0700
commit6969d50c820bd63043940b0e0f0ddc6e6ac763b0 (patch)
treee6e02ddea49c4ad6706931a62172bce9a921d8d0 /test
parente5f01223ae03b89767dc7881d75dca061121ee36 (diff)
downloadart-6969d50c820bd63043940b0e0f0ddc6e6ac763b0.zip
art-6969d50c820bd63043940b0e0f0ddc6e6ac763b0.tar.gz
art-6969d50c820bd63043940b0e0f0ddc6e6ac763b0.tar.bz2
Invoke support for Quick Compiler
Fleshed out invoke and const-string support. Fixed a bug in Phi node insertion. With this CL, the "Recursive Fibonacci" and "HelloWorld" milestones are met. Added are a set of "HL" (for High-Level) invoke intrinsics. Until we complete the merging of the Quick & Iceland runtime models the invoke code sequences are slightly different. Thus, the Greenland IR needs to represent invokes at a somewhat higher level than Iceland. The test for fast/slow path needs to happen during the lowering of the HLInvokeXXX intrinsics in both the Quick and Portable paths. This will generally be the case in the short term - push fast/slow path determination below the Greenland IR level. As unification proceeds, we'll pull as much as makes sense into the common front end. Change-Id: I0a18edf1be18583c0afdc3f7e10a3e4691968e77
Diffstat (limited to 'test')
-rw-r--r--test/Fibonacci/Fibonacci.java14
1 files changed, 13 insertions, 1 deletions
diff --git a/test/Fibonacci/Fibonacci.java b/test/Fibonacci/Fibonacci.java
index 9c94367..a5c4e4b 100644
--- a/test/Fibonacci/Fibonacci.java
+++ b/test/Fibonacci/Fibonacci.java
@@ -16,6 +16,8 @@
class Fibonacci {
+/*
+ // Iterative version
static int fibonacci(int n) {
if (n == 0) {
return 0;
@@ -29,12 +31,22 @@ class Fibonacci {
}
return y;
}
+*/
+
+ // Recursive version
+ static int fibonacci(int n) {
+ if ((n == 0) || (n == 1)) {
+ return n;
+ } else {
+ return fibonacci(n - 1) + (fibonacci(n - 2));
+ }
+ }
public static void main(String[] args) {
String arg = (args.length > 0) ? args[0] : "10";
try {
int x = Integer.parseInt(arg);
- int y = fibonacci(x); /* to warm up cache */
+ int y = fibonacci(x);
System.out.printf("fibonacci(%d)=%d\n", x, y);
y = fibonacci(x + 1);
System.out.printf("fibonacci(%d)=%d\n", x + 1, y);