Show
Ignore:
Timestamp:
11/02/09 14:49:00 (3 weeks ago)
Author:
jmaessen
Message:

[codegen, testing] Tweaked ManglingClassWriter to try to recover reasonably
from classload failures in getCommonSuperClass. Relaxed the set of
method modifiers for which we are willing to generate code (anything
where the code generator doesn't care).

Added two test cases for method inheritance: One runs
Compiled12.inherit which the last checkin permitted to typecheck.
The second is TreapAndTest which runs a simple monomorphic Treap
implementation through its paces.

TreapAndTest is, at about 350LOC, the largest thing we've compiled
to date. It's also the first program to do serious data-structure
manipulation (rather than pushing numbers, strings, and small objects
around).

Location:
trunk/ProjectFortress/src/com/sun/fortress
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/NamingCzar.java

    r4300 r4305  
    9797                                             "$" + WellKnownNames.anyTypeName; 
    9898 
    99     // java.lang.Object correctly formatted for asm generation 
    100     public static final String javaObject = "java/lang/Object"; 
    101  
    10299    // Base class for all executable Fortress Components 
    103100    public static final String fortressExecutable = "com/sun/fortress/runtimeSystem/FortressExecutable"; 
     
    109106 
    110107    // Base class for non-executable Fortress Components 
    111     public static final String fortressComponent = javaObject; 
     108    public static final String fortressComponent = Naming.javaObject; 
    112109 
    113110    public static final String primordialTask    = "com/sun/fortress/runtimeSystem/PrimordialTask"; 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/codegen/CodeGen.java

    r4300 r4305  
    971971 
    972972        body.accept(this); 
    973         exitMethodScope(selfIndex, selfVar, paramsGen); 
    974     } 
     973        try { 
     974            exitMethodScope(selfIndex, selfVar, paramsGen); 
     975        } catch (Throwable t) { 
     976            throw new Error("\n"+NodeUtil.getSpan(body)+": Error trying to close method scope.",t); 
     977        } 
     978    } 
     979 
     980    private static final Modifiers fnDeclCompilableModifiers = 
     981        Modifiers.GetterSetter.combine(Modifiers.IO).combine( 
     982            Modifiers.Private).combine(Modifiers.Abstract); 
    975983 
    976984    public void forFnDecl(FnDecl x) { 
     
    10431051        header.getThrowsClause().isNone() && // no throws clause 
    10441052        header.getContract().isNone() && // no contract 
    1045         header.getMods().isEmpty() && // no modifiers 
     1053            header.getMods().remove(fnDeclCompilableModifiers).isEmpty() && // no unhandled modifiers 
    10461054        !inABlock; // no local functions 
    10471055 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/codegen/ManglingClassWriter.java

    r4273 r4305  
    4141 
    4242    public MethodVisitor visitCGMethod(int access, String name, String desc, String signature, String[] exceptions) { 
    43         
     43 
    4444        return new ManglingMethodVisitor(super.visitMethod(access, name, desc, signature, exceptions)); 
    4545    } 
     
    4949    protected String getCommonSuperClass(String type1, String type2) { 
    5050        // We may need to do something interesting here. 
    51         // [added try/catch wrapper to get useful information out on failure - JWM] 
     51        // Consider doing it pre-emptively rather than copping out on failure. 
    5252        try { 
    5353            return super.getCommonSuperClass(type1, type2); 
    5454        } catch (Throwable e) { 
    55             throw new Error("Couldn't getCommonSuperClass("+type1+", "+type2+")",e); 
     55            // [added try/catch wrapper to get useful information out on failure - JWM] 
     56            // throw new Error("Couldn't getCommonSuperClass("+type1+", "+type2+")",e); 
     57 
     58            // Note: the following apparent cop-out was gleaned by perusing: 
     59            //   http://www.java2s.com/Open-Source/Java-Document/Byte-Code/asm/org/objectweb/asm/ClassWriterComputeFramesTest.java.htm 
     60            // This returns java.lang.Object as the CommonSuperClass of anything involving an interface 
     61            // type.  Since all Fortress traits correspond to interface types, we ought to be able to 
     62            // do the same. 
     63            // 
     64            // That said, it still feels wrong. 
     65            return Naming.javaObject; 
    5666        } 
    5767    } 
     
    6373        name = Naming.mangleFortressIdentifier(name); 
    6474        superName = Naming.mangleFortressIdentifier(superName); 
    65          
     75 
    6676        String[] _interfaces = 
    6777            interfaces == null ? null : new String[interfaces.length]; 
     
    110120 
    111121} 
    112              
    113              
     122 
  • trunk/ProjectFortress/src/com/sun/fortress/runtimeSystem/Naming.java

    r4291 r4305  
    3535    public final static String INDEX = "\u261e";  // "__"; // "\u261e"; // white right point index (for dotted of functional methods) 
    3636    public final static String BOX = "\u2610"; // ballot box, used to indicate prefix or postfix. 
    37   
     37 
    3838    public static final String BALLOT_BOX_WITH_CHECK = "\u2611"; // boolean static param 
    3939    public static final String SCALES = "\u2696"; // dimension static param 
     
    4343    public static final String YINYANG = "\u262f"; // type static param 
    4444    public static final String ATOM = "\u269b"; // unit static param 
    45      
    46     public static final String GENERIC_TAGS =  
     45 
     46    public static final String GENERIC_TAGS = 
    4747        BALLOT_BOX_WITH_CHECK + SCALES + MUSIC_SHARP + 
    4848        HAMMER_AND_PICK + YINYANG + ATOM; 
     
    7676 
    7777    public static final String runtimeValues = "com/sun/fortress/compiler/runtimeValues/"; 
     78 
     79    // java.lang.Object correctly formatted for asm generation 
     80    public static final String javaObject = "java/lang/Object"; 
    7881 
    7982    /** 
     
    355358            case 'Z': 
    356359            case 'V': // should only appear in return if well-formed 
    357                  
     360 
    358361            case '[': // eat array indicator 
    359362            case '(': // eat intro and outro, assume well-formed 
     
    371374        } 
    372375        return sb.toString(); 
    373     }    
    374      
     376    } 
     377 
    375378    public static String demangleMethodSignature(String s) { 
    376379        StringBuffer sb = new StringBuffer(); 
     
    389392            case 'Z': 
    390393            case 'V': // should only appear in return if well-formed 
    391                  
     394 
    392395            case '[': // eat array indicator 
    393396            case '(': // eat intro and outro, assume well-formed 
     
    406409        return sb.toString(); 
    407410    } 
    408      
     411 
    409412    /** 
    410413     * Mangles the chunks of a fortress identifier, where the chunks are 
    411414     * delimited by $, /, and ; appearing outside of Oxford brackets. 
    412      *  
     415     * 
    413416     * Returns either when the string is exhausted, 
    414417     * or after a semicolon is processed. 
    415      *   
     418     * 
    416419     * @param s  the string to mangle 
    417420     * @param i  the index to begin at 
     
    422425        return mangleOrNotFortressIdentifier(s,start, sb,true); 
    423426    } 
    424      
     427 
    425428    public static String mangleFortressIdentifier(String s) { 
    426429        if (s == null) 
     
    437440         return t; 
    438441    } 
    439      
     442 
    440443    /** 
    441444     * Expects a type, surrounded by L;, or one of the descriptor type characters. 
     
    460463     * Names beginning and end with less-than and greater-than are left along 
    461464     * (init, clinit) 
    462      *  
     465     * 
    463466     * @param s 
    464467     * @return 
     
    477480     * DE-mangles the chunks of a fortress identifier, where the chunks are 
    478481     * delimited by $, /, and ; appearing outside of Oxford brackets. 
    479      *  
     482     * 
    480483     * Returns either when the string is exhausted, 
    481484     * or after a semicolon is processed. 
    482      *  
     485     * 
    483486     * @param s  the string to mangle 
    484487     * @param i  the index to begin at 
     
    489492        return mangleOrNotFortressIdentifier(s,start, sb,false); 
    490493    } 
    491      
     494 
    492495    public static String demangleFortressIdentifier(String s) { 
    493496        if (s == null) 
    494497            return null; 
    495498        int l = s.length(); 
    496          
     499 
    497500        // Special case of <init> and <clinit> 
    498501        if (pointyDelimitedInitMethod(s)) 
     
    514517    } 
    515518 
    516      
     519 
    517520    private static int mangleOrNotFortressIdentifier(String s, int start, StringBuffer sb, boolean mangleOrNot) { 
    518521        int l = s.length(); 
    519522        int nesting = 0; 
    520          
     523 
    521524        for (int i = start; i < l; i++) { 
    522525            char ch = s.charAt(i); 
     
    551554        } 
    552555    } 
    553      
     556 
    554557 
    555558    /** 
     
    637640            if (mangledString.startsWith("\\-")) 
    638641                mangledString = mangledString; 
    639              
     642 
    640643            return mangledString; 
    641644        }