We define compositional compilation to be the ability to typecheck source code fragments in isolation, generate corresponding binaries, and link together fragments whose mutual assumptions are satisfied, without reinspecting the code. Even though compositional compilation is a highly desirable feature, in Java-like languages it can hardly be achieved. This is due to the fact that the bytecode generated for a fragment (say, a class) is not uniquely determined by its source code, but depends on the compilation context. In this paper, we propose a way to obtain compositional compilation for Java, by introducing a polymorphic form of bytecode containing type variables (ranging over class names) and equipped with a set of constraints involving type variables. Thus, polymorphic bytecode provides a representation for all the (standard Java) bytecode that can be obtained by replacing type variables with class names satisfying the associated constraints. We illustrate our proposal by developing a type inference and a linking algorithm for a small subset of Java. The type inference algorithm compiles a class in isolation generating the corresponding polymorphic bytecode fragment with the needed constraints on the classes it depends on. The linking algorithm takes a collection of polymorphic bytecode fragments, checks their mutual consistency, and possibly simplifies and specializes them. In particular, when a self-contained collection of fragments is taken, linking either fails, or produces standard Java bytecode (which is the same as the one which would have been produced by standard Java compilation of all fragments together).

Polymorphic Bytecode: Compositional Compilation for Java-like Languages

DAMIANI, Ferruccio;
2005-01-01

Abstract

We define compositional compilation to be the ability to typecheck source code fragments in isolation, generate corresponding binaries, and link together fragments whose mutual assumptions are satisfied, without reinspecting the code. Even though compositional compilation is a highly desirable feature, in Java-like languages it can hardly be achieved. This is due to the fact that the bytecode generated for a fragment (say, a class) is not uniquely determined by its source code, but depends on the compilation context. In this paper, we propose a way to obtain compositional compilation for Java, by introducing a polymorphic form of bytecode containing type variables (ranging over class names) and equipped with a set of constraints involving type variables. Thus, polymorphic bytecode provides a representation for all the (standard Java) bytecode that can be obtained by replacing type variables with class names satisfying the associated constraints. We illustrate our proposal by developing a type inference and a linking algorithm for a small subset of Java. The type inference algorithm compiles a class in isolation generating the corresponding polymorphic bytecode fragment with the needed constraints on the classes it depends on. The linking algorithm takes a collection of polymorphic bytecode fragments, checks their mutual consistency, and possibly simplifies and specializes them. In particular, when a self-contained collection of fragments is taken, linking either fails, or produces standard Java bytecode (which is the same as the one which would have been produced by standard Java compilation of all fragments together).
2005
POPL 2005: The 32nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages
Long Beach, CA (USA)
January 12-14, 2005
Proceedings of the 32nd ACM SIGPLAN-SIGACT symposium on Principles of programming languages
ACM
40
26
37
158113830X
http://dl.acm.org/citation.cfm?id=1040308
http://www.cs.princeton.edu/~dpw/popl/05/
http://www.scopus.com/record/display.url?eid=2-s2.0-29144469108&origin=resultslist&sort=plf-f&src=s&nlo=&nlr=&nls=&sid=6duJwc5vpYAxfwFlqj2kCkS%3a570&sot=aut&sdt=a&sl=38&s=AU-ID%28%22Damiani%2c+Ferruccio%22+8072103800%29&relpos=27&relpos=27&searchTerm=AU-ID%28\%22Damiani,%20Ferruccio\%22%208072103800%29
type systems; compositional analysis; Bytecode; Compositional compilation; Java programming language
DAVIDE ANCONA; FERRUCCIO DAMIANI; SOPHIA DROSSOPOULOU; ELENA ZUCCA
File in questo prodotto:
File Dimensione Formato  
ACM-popl-2005.pdf

Accesso riservato

Descrizione: Articolo principale (versione per conferenza)
Tipo di file: PDF EDITORIALE
Dimensione 580.53 kB
Formato Adobe PDF
580.53 kB Adobe PDF   Visualizza/Apri   Richiedi una copia

I documenti in IRIS sono protetti da copyright e tutti i diritti sono riservati, salvo diversa indicazione.

Utilizza questo identificativo per citare o creare un link a questo documento: https://hdl.handle.net/2318/122642
Citazioni
  • ???jsp.display-item.citation.pmc??? ND
  • Scopus 38
  • ???jsp.display-item.citation.isi??? 7
social impact