Related articles |
---|
[2 earlier articles] |
Re: CUP/LEX has limitations jones@cs.ua.edu (Joel Jones) (2005-06-26) |
Re: CUP/LEX has limitations snicol@apk.net (Scott Nicol) (2005-06-26) |
Re: CUP/LEX has limitations alpanad@gmail.com (2005-06-30) |
Re: CUP/LEX has limitations gah@ugcs.caltech.edu (glen herrmannsfeldt) (2005-06-30) |
Re: CUP/LEX has limitations snicol@apk.net (Scott Nicol) (2005-07-02) |
Re: CUP/LEX has limitations Martin.Ward@durham.ac.uk (Martin Ward) (2005-07-03) |
Re: CUP/LEX has limitations pohjalai@cc.helsinki.fi (A Pietu Pohjalainen) (2005-07-22) |
From: | A Pietu Pohjalainen <pohjalai@cc.helsinki.fi> |
Newsgroups: | comp.compilers |
Date: | 22 Jul 2005 20:23:53 -0400 |
Organization: | University of Helsinki |
References: | 05-06-115 05-06-118 |
Keywords: | Java |
Posted-Date: | 22 Jul 2005 20:23:53 EDT |
Scott Nicol <snicol@apk.net> wrote:
> I haven't used CUP/LEX, but I'm quite familiar with the "code too
> large" error in Java. Java has a limit of 64k code per method (you,
> like I, might be wondering what was being smoked when that decision
> was made).
This 64k code per method limit seems really accidental. In Java class
files, the actualy bytecode is stored in an attribute named 'Code'. This
attribute has a specified structure, as defined in JVM spec § 4.7.3,
which is as follows:
Code_attribute {
u2 attribute_name_index;
u4 attribute_length;
u2 max_stack;
u2 max_locals;
u4 code_length;
u1 code[code_length];
u2 exception_table_length;
{ u2 start_pc;
u2 end_pc;
u2 handler_pc;
u2 catch_type;
} exception_table[exception_table_length];
u2 attributes_count;
attribute_info attributes[attributes_count];
}
So, in the attribute structure, there is four bytes allocated for the
length of the actual content (code_length). However, there is another
constraint at JVM spec § 4.8.1, which states that "The value of the
code_length item must be less than 65536."
If the specification was internally coherent, the type of code_length
would be u2, wouldn't it? With this structure, there's a huge
unnecessary overhead of two bytes per method in the class file. ;)
br,
Pietu Pohjalainen
Return to the
comp.compilers page.
Search the
comp.compilers archives again.