Changeset 3040
- Timestamp:
- 11/07/08 14:29:25 (13 months ago)
- Location:
- trunk/ProjectFortress
- Files:
-
- 1 added
- 13 modified
-
src/com/sun/fortress/Shell.java (modified) (3 diffs)
-
src/com/sun/fortress/interpreter/env/ComponentWrapper.java (modified) (2 diffs)
-
src/com/sun/fortress/interpreter/evaluator/BaseEnv.java (modified) (2 diffs)
-
src/com/sun/fortress/interpreter/evaluator/Evaluator.java (modified) (1 diff)
-
src/com/sun/fortress/interpreter/evaluator/Init.java (modified) (3 diffs)
-
src/com/sun/fortress/interpreter/rewrite/DesugarerVisitor.java (modified) (2 diffs)
-
src/com/sun/fortress/nodes_util/NodeFactory.java (modified) (14 diffs)
-
src/com/sun/fortress/nodes_util/Unprinter.java (modified) (3 diffs)
-
src/com/sun/fortress/repository/DerivedFiles.java (modified) (1 diff)
-
src/com/sun/fortress/repository/ProjectProperties.java (modified) (1 diff)
-
src/com/sun/fortress/tests/unit_tests/FileTests.java (modified) (3 diffs)
-
src/com/sun/fortress/tests/unit_tests/SystemJUTest.java (modified) (1 diff)
-
src/com/sun/fortress/useful/Useful.java (modified) (1 diff)
-
test_leaks (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ProjectFortress/src/com/sun/fortress/Shell.java
r3017 r3040 50 50 import com.sun.fortress.nodes_util.ASTIO; 51 51 import com.sun.fortress.interpreter.Driver; 52 import com.sun.fortress.interpreter.evaluator.Init; 52 53 import com.sun.fortress.interpreter.evaluator.values.FValue; 53 54 import com.sun.fortress.syntax_abstractions.parser.PreParser; … … 231 232 } 232 233 234 int return_code = 0; 235 233 236 // Now match the assembled string. 234 237 try { … … 277 280 278 281 } else { printUsageMessage(); } 279 } 280 catch (UserError error) { 282 } catch (UserError error) { 281 283 System.err.println(error.getMessage()); 282 System.exit(-1);284 return_code = -1; 283 285 } 284 286 catch (IOException error) { 285 287 System.err.println(error.getMessage()); 286 System.exit(-2); 287 } 288 return_code = -2; 289 } 290 291 Init.allowForLeakChecks(); 292 293 294 if (return_code != 0) 295 System.exit(return_code); 288 296 } 289 297 -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/env/ComponentWrapper.java
r2942 r3040 95 95 } 96 96 97 /** 98 * Reads a "command line" component; do not leave in the cache. 99 * @param comp 100 * @param api_list 101 * @param linker 102 * @param implicitLibs 103 */ 97 104 public ComponentWrapper(ComponentIndex comp, List<APIWrapper> api_list, 98 105 HashMap<String, ComponentWrapper> linker, String[] implicitLibs) { … … 100 107 cacheDisabled = noCache; 101 108 transformed = getCached(comp); 102 // TODO Auto-generated constructor stub109 componentCache.forget(comp.ast().getName()); 103 110 } 104 111 -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/BaseEnv.java
r2973 r3040 746 746 int negative_object_depth) { 747 747 if (-negative_object_depth > 0) { 748 // This assumes $self can be found in the current environment. 749 // Next statement maps -1 to zero, -2 to one, -3 to two, etc. 748 750 negative_object_depth = -1 - negative_object_depth; 749 751 FObject obj = (FObject) e.getLeafValue(WellKnownNames.secretSelfName); … … 754 756 e = obj.getSelfEnv(); 755 757 } 756 } else if (negative_object_depth == 0) 757 e = e.getTopLevel(); 758 } else if (negative_object_depth == 0) { 759 e = e.getTopLevel(); 760 } else if (negative_object_depth < 0) { 761 // True only for MIN_VALUE 762 return e; 763 } 758 764 return e; 759 765 } -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/Evaluator.java
r3028 r3040 1661 1661 1662 1662 public FValue forVarRef(VarRef x) { 1663 1663 // Id id = x.getVar(); 1664 // String s= id.getText(); 1665 // if (s.contains("$self")) { 1666 // id = x.getVar(); 1667 // } 1664 1668 FValue res = BaseEnv.toContainingObjectEnv(e, x.getLexicalDepth()).getValueNull(x); 1665 1669 if (res == null) { -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/Init.java
r2842 r3040 30 30 import com.sun.fortress.interpreter.evaluator.values.GenericFunctionOrMethod; 31 31 import com.sun.fortress.interpreter.glue.NativeApp; 32 import com.sun.fortress.repository.ProjectProperties; 33 import com.sun.fortress.useful.Useful; 32 34 33 35 … … 40 42 41 43 // For leak detection. 42 static int countdown= 4;43 44 static int countdown=16; 45 44 46 public static void initializeEverything() { 45 47 FTypeArrow.reset(); … … 60 62 NativeApp.reset(); 61 63 62 // For leak detection; runs 4 tests, then cleans the heap, and hangs. 63 if (false && countdown-- == 0) { 64 for (int i = 0; i < 10; i++) 65 System.gc(); 66 try { 67 Thread.sleep(1000000000); 68 } catch (InterruptedException ex) { 69 70 } 71 } 64 72 65 73 66 } 74 67 68 public static void allowForLeakChecks() { 69 if (ProjectProperties.leakCheck) { 70 // Clean the heap up nicely before a heap snapshot 71 // (is the GC really necessary?) 72 // note that if we snapshotting the heap,the Nth call to 73 // initializeEverything will do its own GC and sleep, to catch 74 // leaks in a seres of running tests. 75 initializeEverything(); 76 for (int i = 0; i < 10; i++) 77 System.gc(); 78 /* Hang for jmap probe */ 79 try { 80 String pid = Useful.getPid(); 81 if (pid == null) 82 pid = "<this process id>"; 83 System.err.println("Now is a good time to attach to this process with \"jmap -heap:format=b " + pid + "\"\n" + 84 "Now sleeping for a very long time..."); 85 Thread.sleep(1000000000); 86 } catch (InterruptedException ex) { 87 88 } 89 } 90 } 91 75 92 } -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/rewrite/DesugarerVisitor.java
r3026 r3040 722 722 @Override 723 723 public Node forVarType(VarType vre) { 724 String s = NodeUtil.nameString(vre.getName()); 725 StaticParam tp = visibleGenericParameters.get(s); 726 if (tp != null) { 727 usedGenericParameters.put(s, tp); 728 } 729 Node node = newType(vre, s); 724 Id id = vre.getName(); 725 Node node = vre; 726 if (id.getApi().isNone()) { 727 String s = NodeUtil.nameString(id); 728 StaticParam tp = visibleGenericParameters.get(s); 729 if (tp != null) { 730 usedGenericParameters.put(s, tp); 731 } 732 node = newType(vre, s); 733 } else { 734 // Rewrite lexical nesting depth to zero if api-qualified. 735 node = NodeFactory.makeVarType(vre, 0); 736 } 737 730 738 return visitNode(node); 731 739 … … 1122 1130 return s; 1123 1131 } 1124 1132 1125 1133 /** 1126 1134 * Given List<Id>, generate tuple of corresponding VarRef -
trunk/ProjectFortress/src/com/sun/fortress/nodes_util/NodeFactory.java
r3026 r3040 78 78 79 79 public static APIName makeAPINameSkipLast(Id first, Id rest) { 80 List<Id> ids = new ArrayList<Id>();80 ArrayList<Id> ids = new ArrayList<Id>(); 81 81 Id last = first; 82 82 ids.add(first); … … 86 86 if (!IterUtil.isEmpty(apiNames)) last = IterUtil.last(apiNames); 87 87 } 88 ids.trimToSize(); 88 89 return new APIName(FortressUtil.spanTwo(first, last), ids); 89 90 } 90 91 91 92 public static APIName makeAPIName(Id first, Id rest) { 92 List<Id> ids = new ArrayList<Id>();93 ArrayList<Id> ids = new ArrayList<Id>(); 93 94 ids.add(first); 94 95 if (rest.getApi().isSome()) { … … 96 97 } 97 98 ids.add(new Id(rest.getSpan(), rest.getText())); 99 ids.trimToSize(); 98 100 return new APIName(FortressUtil.spanTwo(first, rest), ids); 99 101 } … … 431 433 432 434 private static List<Id> stringToIds(String path) { 433 List<Id> ids = new ArrayList<Id>();435 ArrayList<Id> ids = new ArrayList<Id>(); 434 436 435 437 StringTokenizer st = new StringTokenizer(path, "."); … … 438 440 ids.add(makeId(e)); 439 441 } 442 ids.trimToSize(); 440 443 return ids; 441 444 } … … 473 476 474 477 public static APIName makeAPINameFromPath(Span span, String path, String delimiter) { 475 List<Id> ids = new ArrayList<Id>();478 ArrayList<Id> ids = new ArrayList<Id>(); 476 479 String file = new File(path).getName(); 477 480 if (file.length() <= 4) { … … 481 484 ids.add(new Id(span, n)); 482 485 } 486 ids.trimToSize(); 483 487 return new APIName(span, ids); 484 488 } … … 516 520 517 521 public static Id makeId(Span span, String api, String name) { 518 List<Id> apis = new ArrayList<Id>();522 ArrayList<Id> apis = new ArrayList<Id>(); 519 523 apis.add(makeId(span, api)); 524 apis.trimToSize(); 520 525 return new Id(span, Option.some(new APIName(span, apis)), name); 521 526 } … … 636 641 name, 637 642 Option.some((Type)makeVarType(type.getSpan(),type)), 638 new ArrayList<Modifier>(),643 Collections.<Modifier>emptyList(), 639 644 false); 640 645 } … … 644 649 name, 645 650 Option.some(type), 646 new ArrayList<Modifier>(),651 Collections.<Modifier>emptyList(), 647 652 false); 648 653 } … … 652 657 name, 653 658 type, 654 new ArrayList<Modifier>(),659 Collections.<Modifier>emptyList(), 655 660 false); 656 661 } … … 658 663 public static LValueBind makeLValue(String name, Type type) { 659 664 return new LValueBind(type.getSpan(), makeId(name), Option.some(type), 660 new ArrayList<Modifier>(), false);665 Collections.<Modifier>emptyList(), false); 661 666 } 662 667 … … 722 727 public static MatrixType makeMatrixType(Span span, Type element, 723 728 ExtentRange dimension) { 724 List<ExtentRange> dims = new ArrayList<ExtentRange>();729 ArrayList<ExtentRange> dims = new ArrayList<ExtentRange>(); 725 730 dims.add(dimension); 731 dims.trimToSize(); 726 732 return new MatrixType(span, element, dims); 727 733 } … … 730 736 ExtentRange dimension, 731 737 List<ExtentRange> dimensions) { 732 List<ExtentRange> dims = new ArrayList<ExtentRange>();738 ArrayList<ExtentRange> dims = new ArrayList<ExtentRange>(); 733 739 dims.add(dimension); 734 740 dims.addAll(dimensions); 741 dims.trimToSize(); 735 742 return new MatrixType(span, element, dims); 736 743 } -
trunk/ProjectFortress/src/com/sun/fortress/nodes_util/Unprinter.java
r2941 r3040 25 25 import java.math.BigInteger; 26 26 import java.util.ArrayList; 27 import java.util.Collections; 27 28 import java.util.List; 28 29 import java.util.Map; … … 323 324 if (fcl == List.class) { 324 325 // empty list 325 f.set(node, new ArrayList());326 f.set(node, Collections.EMPTY_LIST); 326 327 } else if (fcl == String.class) { 327 328 // empty string … … 630 631 x = deQuote(s).intern(); // Intermediate form is quoted. 631 632 } else if (s.startsWith("]")) { 633 a.trimToSize(); 632 634 return a; 633 635 } else { -
trunk/ProjectFortress/src/com/sun/fortress/repository/DerivedFiles.java
r3002 r3040 67 67 } 68 68 } 69 70 public void forget(APIName name) { 71 cached.remove(name); 72 } 69 73 70 74 } -
trunk/ProjectFortress/src/com/sun/fortress/repository/ProjectProperties.java
r2941 r3040 288 288 public final static String API_TREE_SUFFIX = "tfi"; 289 289 290 public final static boolean leakCheck = getBoolean("fortress.test.leaks", false); 291 290 292 291 293 /** Creates a new instance of ProjectProperties */ -
trunk/ProjectFortress/src/com/sun/fortress/tests/unit_tests/FileTests.java
r2927 r3040 26 26 import junit.framework.Test; 27 27 import junit.framework.TestCase; 28 import junit.framework.TestResult; 28 29 import junit.framework.TestSuite; 29 30 … … 31 32 import com.sun.fortress.Shell; 32 33 import com.sun.fortress.interpreter.Driver; 34 import com.sun.fortress.interpreter.evaluator.Init; 33 35 import com.sun.fortress.nodes.APIName; 34 36 import com.sun.fortress.nodes.CompilationUnit; … … 203 205 } 204 206 205 public static Test suite(String dirname, boolean failsOnly, boolean expect_failure) throws IOException { 206 TestSuite suite = new TestSuite("Test for default package"); 207 // $JUnit-BEGIN$ 208 dirname = ProjectProperties.backslashToSlash(dirname); 207 public static TestSuite suite(String dir_name, boolean failsOnly, boolean expect_failure) throws IOException { 208 TestSuite suite = new TestSuite("Runs all tests in " + dir_name) { 209 public void run(TestResult result) { 210 super.run(result); 211 Init.allowForLeakChecks(); 212 } 213 }; 214 String dirname = ProjectProperties.backslashToSlash(dir_name); 209 215 File dir = new File(dirname); 210 216 String[] files = dir.list(); -
trunk/ProjectFortress/src/com/sun/fortress/tests/unit_tests/SystemJUTest.java
r2449 r3040 38 38 testDir = s; 39 39 } 40 TestSuite suite = new TestSuite("Test all .fss files in 'tests'.");40 // TestSuite suite = new TestSuite("Test all .fss files in 'tests'."); 41 41 //$JUnit-BEGIN$ 42 suite.addTest(FileTests.suite(testDir, failsOnly, false));42 // suite.addTest(FileTests.suite(testDir, failsOnly, false)); 43 43 //$JUnit-END$ 44 return suite;44 return FileTests.suite(testDir, failsOnly, false); 45 45 } 46 46 -
trunk/ProjectFortress/src/com/sun/fortress/useful/Useful.java
r2715 r3040 1056 1056 } 1057 1057 1058 /** 1059 * Gets a string representing the pid of this program - Java VM 1060 */ 1061 public static String getPid() { 1062 ArrayList<String> commands = new ArrayList<String>(); 1063 commands.add("/bin/bash"); 1064 commands.add("-c"); 1065 commands.add("echo $PPID"); 1066 ProcessBuilder pb = new ProcessBuilder(commands); 1067 1068 try { 1069 1070 Process pr = pb.start(); 1071 pr.waitFor(); 1072 if (pr.exitValue() == 0) { 1073 BufferedReader outReader = new BufferedReader( 1074 new InputStreamReader(pr.getInputStream())); 1075 return outReader.readLine().trim(); 1076 } else { 1077 return null; 1078 } 1079 } catch (IOException x) { 1080 return null; 1081 } catch (InterruptedException x) { 1082 return null; 1083 } 1084 } 1058 1085 1059 1086 }

