Merge changes I4ba34cab,Ifb7baa1d,If3d41c14,I165c6710,I78ab48d8, ...

* changes:
  Inline is{Integer,Double,Symbol,List,...} with instanceof
  Expand statistics feature to cover all vm stats
  Apply reduction limit during evaluation
  Remove incorrect copyright header from Google
  Move user stream IO setup to common PrologControl
  Apply Gerrit-style formatting settings for Eclipse
diff --git a/src/builtin/PRED_regex_match_3.java b/src/builtin/PRED_regex_match_3.java
index ba895eb..cf5fcd2 100644
--- a/src/builtin/PRED_regex_match_3.java
+++ b/src/builtin/PRED_regex_match_3.java
@@ -1,7 +1,6 @@
 package com.googlecode.prolog_cafe.builtin;
 import com.googlecode.prolog_cafe.exceptions.IllegalTypeException;
 import com.googlecode.prolog_cafe.exceptions.PInstantiationException;
-import com.googlecode.prolog_cafe.lang.ChoicePointFrame;
 import com.googlecode.prolog_cafe.lang.JavaObjectTerm;
 import com.googlecode.prolog_cafe.lang.ListTerm;
 import com.googlecode.prolog_cafe.lang.Operation;
@@ -11,7 +10,6 @@
 import com.googlecode.prolog_cafe.lang.Term;
 import com.googlecode.prolog_cafe.lang.VariableTerm;
 
-import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -60,7 +58,7 @@
 
       engine.r1 = new JavaObjectTerm(matcher);
       engine.r2 = arg3;
-      return engine.jtry(regex_check, regex_next, new ChoicePointFrame.S2(engine));
+      return engine.jtry2(regex_check, regex_next);
   }
 
   private static final class PRED_regex_check extends Operation {
@@ -95,7 +93,7 @@
         return engine.fail();
       }
 
-      return engine.jtry(regex_check, regex_next, new ChoicePointFrame.S2(engine));
+      return engine.jtry2(regex_check, regex_next);
     }
   }
 
@@ -107,4 +105,4 @@
     }
     return list;
   }
-}
\ No newline at end of file
+}
diff --git a/src/compiler/am2j.pl b/src/compiler/am2j.pl
index a8cba29..d7a753e 100644
--- a/src/compiler/am2j.pl
+++ b/src/compiler/am2j.pl
@@ -130,6 +130,12 @@
 	write(Out, 'import '), 
 	write_package(P, Out), 
 	write(Out, '.*;'), nl(Out).
+write_java0(import_static(P,F), _, Out) :- !,
+	write(Out, 'import static '),
+	write_package(P, Out),
+	write(Out, '.'),
+	write(Out, F),
+	write(Out, ';'), nl(Out).
 write_java0(import_package(P,FA), _, Out) :- !,
 	write(Out, 'import '), 
 	write_package(P, Out), 
@@ -143,12 +149,7 @@
 write_java0((Label: Instruction), In, Out) :- !,
 	write_label(Label, Out),
 	write_java0(Instruction, In, Out).
-write_java0(label(fail/0), _, Out) :- !,
-	tab(Out, 4),
-	write(Out, 'static final Operation '),
-	write_index(fail/0, Out),
-	write(Out, ' = com.googlecode.prolog_cafe.lang.Failure.FAIL_0'),
-	write(Out, ';'), nl(Out).
+write_java0(label(fail/0), _, _) :- !.
 write_java0(label(L), _, Out) :- !,
 	tab(Out, 4),
 	write(Out, 'static final Operation '),
@@ -468,16 +469,10 @@
 write_java0(try(Li,Lj), _, Out) :- !, 
 	clause(current_arity(A), _),
 	tab(Out, 8),
-	write(Out, 'return engine.jtry('),
+	write(Out, 'return engine.jtry'), write(Out, A), write(Out, '('),
 	write_index(Li, Out), 
 	write(Out, ', '),
 	write_index(Lj, Out),
-	write(Out, ', '),
-	( A == 0 ->
-		write(Out, 'new S0()')
-		;
-		write(Out, 'new S'), write(Out, A), write(Out, '(engine)')
-	),
 	write(Out, ');'), nl(Out).
 write_java0(retry(Li,Lj), _, Out) :- !, 
 	tab(Out, 8),
@@ -1182,6 +1177,7 @@
 +  end_predicate(p, f/n)
 
 +  import_package(p)
++  import_static(p, f/n)
 +  import_package(p, f/n)
 
 +  main(f/n, public): [Instructions]
diff --git a/src/compiler/pl2am.pl b/src/compiler/pl2am.pl
index dca9608..2cbe84c 100644
--- a/src/compiler/pl2am.pl
+++ b/src/compiler/pl2am.pl
@@ -102,6 +102,7 @@
   end_predicate(p, f/n)
 
   import_package(p)
+  import_static(p, f/n)
   import_package(p, f/n)
 
   main(f/n, public): [Instructions]
@@ -162,6 +163,7 @@
 :- dynamic package_name/1.
 :- dynamic public_predicates/2.
 :- dynamic import_package/2.
+:- dynamic import_static/2.
 :- dynamic internal_declarations/1.
 :- dynamic file_name/1.
 :- dynamic dummy_clause_counter/1.
@@ -205,6 +207,7 @@
 	retractall(package_name(_)),
 	retractall(public_predicates(_,_)),
 	retractall(import_package(_,_)),
+	retractall(import_static(_,_)),
 	retractall(internal_declarations(_)),
 	retractall(file_name(_)),
 	retractall(dummy_clause_counter(_)),
@@ -250,7 +253,7 @@
 	assert_import('com.googlecode.prolog_cafe.builtin'),
 	assert_import('com.googlecode.prolog_cafe.exceptions'),
 	assert_import('com.googlecode.prolog_cafe.lang'),
-	assert_import('com.googlecode.prolog_cafe.lang.ChoicePointFrame'),
+	assert(import_static('com.googlecode.prolog_cafe.lang.Failure', fail_0)),
 	assert_dummy_package,
 	assert_dummy_public.
 
@@ -815,16 +818,23 @@
 
 %%% Import Declarations
 generate_import --> 
+	{findall((P,C), import_static(P, C), S)},
+	gen_importstatic(S),
 	{findall((P,C), import_package(P, C), X)},
-	gen_import(X).
+	gen_importpkg(X).
 
-gen_import([]) --> !.
-gen_import([(P,'*')|Xs]) --> !, 
+gen_importstatic([]) --> !.
+gen_importstatic([(P,C)|Xs]) -->
+	[import_static(P, C)],
+	gen_importstatic(Xs).
+
+gen_importpkg([]) --> !.
+gen_importpkg([(P,'*')|Xs]) --> !,
 	[import_package(P)],
-	gen_import(Xs).
-gen_import([(P,C)|Xs]) --> 
+	gen_importpkg(Xs).
+gen_importpkg([(P,C)|Xs]) -->
 	[import_package(P, C)],
-	gen_import(Xs).
+	gen_importpkg(Xs).
 
 %%% Information
 generate_info(Functor, Arity) --> 
diff --git a/src/lang/ChoicePointFrame.java b/src/lang/ChoicePointFrame.java
index ba33382..8d66621 100644
--- a/src/lang/ChoicePointFrame.java
+++ b/src/lang/ChoicePointFrame.java
@@ -7,7 +7,7 @@
  * @author Naoyuki Tamura (tamura@kobe-u.ac.jp)
  * @version 1.0
  */
-public abstract class ChoicePointFrame {
+class ChoicePointFrame {
     ChoicePointFrame prior;
 
     long timeStamp;
@@ -29,13 +29,10 @@
       return t;
     }
 
-    public static final class S0 extends ChoicePointFrame {
-    }
-
-    public static final class S1 extends ChoicePointFrame {
+    static final class S1 extends ChoicePointFrame {
       private final Term r1;
 
-      public S1(Prolog engine) {
+      S1(Prolog engine) {
         this.r1 = engine.r1;
       }
 
@@ -45,10 +42,10 @@
       }
     }
 
-    public static final class S2 extends ChoicePointFrame {
+    static final class S2 extends ChoicePointFrame {
       private final Term r1, r2;
 
-      public S2(Prolog engine) {
+      S2(Prolog engine) {
         this.r1 = engine.r1;
         this.r2 = engine.r2;
       }
@@ -59,10 +56,10 @@
       }
     }
 
-    public static final class S3 extends ChoicePointFrame {
+    static final class S3 extends ChoicePointFrame {
       private final Term r1, r2, r3;
 
-      public S3(Prolog engine) {
+      S3(Prolog engine) {
         this.r1 = engine.r1;
         this.r2 = engine.r2;
         this.r3 = engine.r3;
@@ -76,10 +73,10 @@
       }
     }
 
-    public static final class S4 extends ChoicePointFrame {
+    static final class S4 extends ChoicePointFrame {
       private final Term r1, r2, r3, r4;
 
-      public S4(Prolog engine) {
+      S4(Prolog engine) {
         this.r1 = engine.r1;
         this.r2 = engine.r2;
         this.r3 = engine.r3;
@@ -95,10 +92,10 @@
       }
     }
 
-    public static final class S5 extends ChoicePointFrame {
+    static final class S5 extends ChoicePointFrame {
       private final Term r1, r2, r3, r4, r5;
 
-      public S5(Prolog engine) {
+      S5(Prolog engine) {
         this.r1 = engine.r1;
         this.r2 = engine.r2;
         this.r3 = engine.r3;
@@ -116,10 +113,10 @@
       }
     }
 
-    public static final class S6 extends ChoicePointFrame {
+    static final class S6 extends ChoicePointFrame {
       private final Term r1, r2, r3, r4, r5, r6;
 
-      public S6(Prolog engine) {
+      S6(Prolog engine) {
         this.r1 = engine.r1;
         this.r2 = engine.r2;
         this.r3 = engine.r3;
@@ -139,10 +136,10 @@
       }
     }
 
-    public static final class S7 extends ChoicePointFrame {
+    static final class S7 extends ChoicePointFrame {
       private final Term r1, r2, r3, r4, r5, r6, r7;
 
-      public S7(Prolog engine) {
+      S7(Prolog engine) {
         this.r1 = engine.r1;
         this.r2 = engine.r2;
         this.r3 = engine.r3;
@@ -164,10 +161,10 @@
       }
     }
 
-    public static class S8 extends ChoicePointFrame {
+    static class S8 extends ChoicePointFrame {
       private final Term r1, r2, r3, r4, r5, r6, r7, r8;
 
-      public S8(Prolog engine) {
+      S8(Prolog engine) {
         this.r1 = engine.r1;
         this.r2 = engine.r2;
         this.r3 = engine.r3;
@@ -191,7 +188,7 @@
       }
     }
 
-    public static class S9 extends ChoicePointFrame {
+    static class S9 extends ChoicePointFrame {
       private final Term r1, r2, r3, r4, r5, r6, r7, r8, r9;
 
       S9(Prolog engine) {
@@ -220,10 +217,10 @@
       }
     }
 
-    public static class S10 extends ChoicePointFrame {
+    static class S10 extends ChoicePointFrame {
       private final Term r1, r2, r3, r4, r5, r6, r7, r8, r9, r10;
 
-      public S10(Prolog engine) {
+      S10(Prolog engine) {
         this.r1 = engine.r1;
         this.r2 = engine.r2;
         this.r3 = engine.r3;
diff --git a/src/lang/Failure.java b/src/lang/Failure.java
index 15c3c04..7b109a0 100644
--- a/src/lang/Failure.java
+++ b/src/lang/Failure.java
@@ -22,7 +22,7 @@
     /** Returns a string representation of this <code>Failure</code>. */
     public String toString(){ return "Failure"; }
 
-    public static final Operation FAIL_0 = new PRED_fail_0();
+    public static final Operation fail_0 = new PRED_fail_0();
     private static final class PRED_fail_0 extends Operation {
       @Override
       public Operation exec(Prolog engine) throws PrologException {
diff --git a/src/lang/Prolog.java b/src/lang/Prolog.java
index d1f2d65..e3c059b 100644
--- a/src/lang/Prolog.java
+++ b/src/lang/Prolog.java
@@ -139,7 +139,7 @@
 	CPFTimeStamp = Long.MIN_VALUE;
 
 	// Creates an initial choice point frame.
-	ChoicePointFrame initialFrame = new ChoicePointFrame.S0();
+	ChoicePointFrame initialFrame = new ChoicePointFrame();
 	initialFrame.b0 = B0;
 	initialFrame.bp = Failure.FAILURE;
 	initialFrame.tr = trail.top();
@@ -261,8 +261,20 @@
       stack.top.restore(this);
     }
 
+    public Operation jtry0(Operation p, Operation next) { return jtry(p, next, new ChoicePointFrame()); }
+    public Operation jtry1(Operation p, Operation next) { return jtry(p, next, new ChoicePointFrame.S1(this)); }
+    public Operation jtry2(Operation p, Operation next) { return jtry(p, next, new ChoicePointFrame.S2(this)); }
+    public Operation jtry3(Operation p, Operation next) { return jtry(p, next, new ChoicePointFrame.S3(this)); }
+    public Operation jtry4(Operation p, Operation next) { return jtry(p, next, new ChoicePointFrame.S4(this)); }
+    public Operation jtry5(Operation p, Operation next) { return jtry(p, next, new ChoicePointFrame.S5(this)); }
+    public Operation jtry6(Operation p, Operation next) { return jtry(p, next, new ChoicePointFrame.S6(this)); }
+    public Operation jtry7(Operation p, Operation next) { return jtry(p, next, new ChoicePointFrame.S7(this)); }
+    public Operation jtry8(Operation p, Operation next) { return jtry(p, next, new ChoicePointFrame.S8(this)); }
+    public Operation jtry9(Operation p, Operation next) { return jtry(p, next, new ChoicePointFrame.S8(this)); }
+    public Operation jtry10(Operation p, Operation next) { return jtry(p, next, new ChoicePointFrame.S8(this)); }
+
     /** Creates a new choice point frame. */
-    public Operation jtry(Operation p, Operation next, ChoicePointFrame entry) {
+    private Operation jtry(Operation p, Operation next, ChoicePointFrame entry) {
       entry.cont = cont;
       entry.b0 = B0;
       entry.bp = next;