summaryrefslogtreecommitdiff
path: root/src/fjbg
Commit message (Collapse)AuthorAgeFilesLines
* A few bits of java code which use "" + x and ca...Paul Phillips2011-01-182-2/+2
| | | | | | A few bits of java code which use "" + x and can't be helped out by scala compiler optimizations. No review.
* Misc uninteresting tidbits to take some weight ...Paul Phillips2011-01-022-0/+21
| | | | | | Misc uninteresting tidbits to take some weight off overly large patches in progress. No review.
* fixed (and extended) bytecode readermichelou2010-12-3034-445/+2121
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | IMPORTANT NOTE Modifying code of the FJBG library is a very sensitive task since its write operations are eg. used by the Scala compiler. This SVN commit affects (should affect) only the read operations (which did never work) of the FJBG library. Changes include: - fixed several killer bugs in the bytecode reader (see below). - added missing input stream constructors in several Attribute classes (eg. JBootstrapInvokeDynamic, JEnclosingMethodAttribute, JInnerClassesAttribute) together with the corresponding class registrations in class JAttributeFactory. - added classes JExceptionsTable, JLocalVariableTableAttribute and JStackMapTableAttribute (including corresponding factory methods in class FJBGContext). - overriden method toString in most classes to support output format similar to javap (see below). - did some code cleanup (tabs, etc..). Bug fixes include: - fixed incorrect stream.readInt() in JSourceFileAttribute constructor. - fixed missing code.lineNumbers initialization in JLineNumberTableAttribute constructor. - fixed incorrect code in class util.ByteArray constructor (stream). - added method setCode in class JMethod to link them together. Output of decoded bytecode: The added toString() methods return javap-like formatted strings for the decoded data, eg. for the LocalVariableTable attribute you get the following output: ... LocalVariableTable: Start Length Slot Name Signature 0 6 0 this LTest$; 0 6 1 args [Ljava/lang/String; Executing the following Java code will produce decoded bytecode in a format similar to the command line "javap -p -v -classpath <cpath> <classes>": static void printClass(String filePath) throws Exception { FJBGContext fjbgContext = new FJBGContext(49, 0); DataInputStream in = new DataInputStream(new FileInputStream(filePath)); JClass jclass = fjbgContext.JClass(in); System.out.println(jclass); in.close(); } Mainly for providing a demonstrator of the FJBG reader we added to the FJBG library the main class ch.epfl.lamp.fjbg.Main which behaves similarly to javap, the class file disassembler of the J2SE SDK. For instance the following commands produce (more or less) the same output: ~$ scala ch.epfl.lamp.fjbg.Main -classpath classes 'Test javap -p -v$' ~$ -classpath classes 'Test $' In several cases fjbg.Main will provide more information for access flags (eg. brigde methods) and class file attributes (eg. enclosing methods). TODO - integration of FJBGContext.JLocalVariableTableAttribute into the JVM backend of the Scala compiler (cleaner handling of local variables). - The source code of the FJBG library is currently generated using the compiler option "-source 1.4"; moving to source release 1.5 would allow further code improvements like: List --> List<T> (cast removals) StringBuffer --> StringBuilder (faster implementation) /*@Override*/ --> @Override A A A A A A A A A A A A A A A A A A A A A A A A A A A A A
* Fix InnerClasses attribute: anonymous classes d...Iulian Dragos2010-11-131-1/+8
| | | | | | | | Fix InnerClasses attribute: anonymous classes don't have an outer name. EnclosingMethod is correctly generated. Fixed isAnonymousClass definition. Updated test that depends on anonymous inner class names. Closes (again) #3249, references #2749. review by odersky,extempore.
* Generate EnclosingMethod classfile attributes. Iulian Dragos2010-11-122-0/+47
| | | | | | | | This should fix java signatures when they refer to method type parameters. I unrolled Adriaans previous fix for #3249, as this one is more general. Closes #3249, review by moors.
* Reverted previous commit as I think it is wedgi...Paul Phillips2010-10-1710-51/+21
| | | | | | Reverted previous commit as I think it is wedging under -optimise. No review.
* Made some changes to fjbg so when people run in...Paul Phillips2010-10-1610-21/+51
| | | | | | | | Made some changes to fjbg so when people run into #1133 at least it will tell them what method was the cause. The fact that ten files are touched in this commit instead of one or two is a testament to the wonder of checked exceptions. No review.
* Found the following inefficiencies in fjbg:Paul Phillips2010-09-221-3/+37
| | | | | | | | | | | | | | | | | | | | | | ldc being used instead of bipush or sipush. The cheaper instructions were only being used when the argument was typed as byte or short, but an Int in the byte or short range can as easily use them. This also saves an entry in the constant pool. iconst_n not being used except on Ints. Same issue in reverse: pushing short 3 on the stack is cheaper with iconst_3 than with sipush. Example: class A { def f1: Int = 100 // was ldc #X, now bipush 100 def f2: Int = 5000 // was ldc #X, now sipush 5000 def f3: Byte = 2 // was bipush 2, now iconst_2 def f4: Short = 2 // was sipush 2, now iconst_2 } Review by dragos.
* Guard against overflow in fjbg.Paul Phillips2010-09-191-3/+4
|
* Restoring negative literal parsing behavior to ...Paul Phillips2010-09-171-11/+16
| | | | | | | | | | | | | | | | | | | | | Restoring negative literal parsing behavior to what should be the least surprising option. Thanks much to Johannes Rudolph for identifying the bug in the bytecode generator which needed addressing for us to arrive at proper -0.0 behavior, and for writing the majority of this patch. A '-' followed immediately by either a number or a period should now always be treated as a single numeric literal, which means the minus binds more tightly than anything else. A specific example of how this differs from 2.8 final is: -5.+(10) == 5.0 // and not -15.0 The full range of potentially ambiguous parses involving prefix operators, numbers, and dots is quite large and still needs to be completely and clearly specified. Closes #2378 and #3657, review by odersky, jrudolph.
* Removed more than 3400 svn '$Id' keywords and r...Antonio Cunei2010-05-1226-26/+0
| | | | | Removed more than 3400 svn '$Id' keywords and related junk.
* Closes #3310 (very large Scala class is compile...Gilles Dubochet2010-04-291-0/+3
| | | | | | Closes #3310 (very large Scala class is compiled to invalid classfile because Scala signature can't fit into constant pool). Review by dragos.
* Scala signature is generated as an annotation (...Gilles Dubochet2010-03-231-4/+32
| | | | | | | | | | | | | Scala signature is generated as an annotation (that is accessible through Java reflection). - compiler generates all pickled Scala signatures as annotations to class files. - compiler can read class files with signature as annotations or old-style signatures as attributes. - Scalap has also been updated to new signatures (contributed by Ilya Sergey: thanks a lot). - FJBG updated to allow entering constant pool strings as byte arrays. - ByteCodecs decode method returns the length of the decoded array. Review by ilyas. Already mostly reviewed by odersky.
* Fixes and test cases for #2087 and #2400.Paul Phillips2009-11-141-1/+1
| | | | | | | fixing a long-standing bug in fjbg and recompiling fjbg.jar, which had the side effect of revealing that the current fjbg jar had never been recompiled with target 1.5, so now it's smaller and (I imagine) faster.
* SABBUS now builds FJBG, which sources are now p...Gilles Dubochet2009-09-2128-0/+6173
SABBUS now builds FJBG, which sources are now part of the Scala module.