Author: amitman...@google.com Date: Thu Mar 19 15:24:58 2009 New Revision: 5056
Modified: wiki/CompilationUnit.wiki Log: Edited wiki page through web user interface. Modified: wiki/CompilationUnit.wiki ============================================================================== --- wiki/CompilationUnit.wiki (original) +++ wiki/CompilationUnit.wiki Thu Mar 19 15:24:58 2009 @@ -5,7 +5,7 @@ == Overview == In GWT, both running hosted mode and compiling for web mode share infrastructure for building {{{TypeOracle}}} and managing Generators. Up to now we have not had a good name or well-defined boundaries for this viscera, but hopefully this design doc will shed some light on things related to the {{{CompilationUnit}}}. All doc is circa GWT 1.5 RC1, when a big refactoring effort over all this infrastructure occurred, code named "Flaming Sword of Death". -_*GRAVEYARD* is not yet implemented, all generated units are killed on refresh. Associated sections are italicized._ +Update: _*GRAVEYARD* is now implemented in Gwt trunk (r5048)._ == Goals == * Read Java source files off the classpath based on module source inclusions @@ -33,7 +33,10 @@ * *COMPILED*: In this intermediate state, the unit's source has been compiled by JDT. The unit will contain a set of {{{CompiledClasses}}}. * *ERROR*: In this final state, the unit was compiled, but contained one or more errors. Those errors are cached inside the unit, but all other internal state is cleared. * *CHECKED*: In this final state, the unit has been compiled and is error free. Additionally, all other units this unit depends on (transitively) are also error free. The unit contains a set of checked {{{CompiledClasses}}}. The unit and each contained {{{CompiledClass}}} releases all references to the JDT AST. Each class contains a reference to a valid JRealClassType, which has been added to the module's {{{TypeOracle}}}, as well as byte code, JSNI methods, and all other final state. - * _*GRAVEYARD*: A *CHECKED* generated unit enters this state at the start of a refresh. If a generator generates the same unit with identical source, the unit is immediately promoted to *CHECKED*, bypassing costly compilation, validation, and {{{TypeOracle}}} building._ + * *GRAVEYARD*: A *CHECKED* generated unit enters this state at the start of a refresh. If a generator generates the same unit with identical source, the unit bypasses costly compilation, validation, and {{{TypeOracle}}} building. Note that a *GRAVEYARD* unit is invalidated in any of the following cases: + * if its source changes + * if the state of any units that it depends on has become *FRESH* or *ERROR* + * if a source unit with the same main type is found ==={{{CompiledClass}}}=== Represents a single compiled Java class; a member of a {{{CompilationUnit}}}. Subparts include: @@ -82,21 +85,22 @@ # {{{ResourceOracle}}} for source path refreshes against file system # {{{JavaSourceOracle}}} refreshes against {{{ResourceOracle}}} if {{{ResourceOracle}}} state changed # {{{CompilationState}}} refreshes against {{{JavaSourceOracle}}} - # _All *GRAVEYARD* units are removed_ - # _All generated units become *GRAVEYARD*_ - # _Any contained JRealClassTypes are removed from {{{TypeOracle}}}_ + # All *GRAVEYARD* units are removed + # All generated units become *GRAVEYARD* + # Any contained JRealClassTypes are removed from {{{TypeOracle}}} # Any source files whose corresponding file was changed in {{{JavaSourceOracle}}} are invalidated and become *FRESH* + # The graveyard units are checked against new source units # All units whose corresponding file was removed from {{{JavaSourceOracle}}} are removed # Any new source files in {{{JavaSourceOracle}}} have new {{{CompilationUnits}}} created # All units depending on *FRESH* units are transitively invalidated and become *FRESH* # The sequence of events in use case #1 occurs ===#3: Newly generated units need to be assimilated=== - # A set *FRESH* {{{CompilationUnits}}} contained generated source are added to the {{{CompilationState}}} - # _For each new unit, if a *GRAVEYARD* unit with the same type name already exists, the source of the new unit is compared to the source of the existing unit._ - # _If the new unit's source is identical to the old unit's source, the old unit becomes *CHECKED* and the new unit is discarded_ - # _All JRealClassTypes in the contained {{{CompiledClasses}}} are re-added to {{{TypeOracle}}}_ - # _If the new unit's source differs from the old unit's source, the old unit is discarded and the new unit is added_ + # A set of *FRESH* {{{CompilationUnits}}} contained generated source are added to the {{{CompilationState}}} + # For each new unit, if a *GRAVEYARD* unit with the same type name already exists, the source of the new unit is compared to the source of the existing unit. + # If the new unit's source is identical to the old unit's source, the new unit is discarded + # All JRealClassTypes in the contained {{{CompiledClasses}}} are re-added to {{{TypeOracle}}} + # If the new unit's source differs from the old unit's source, the old unit is discarded and the new unit is added # If any *FRESH* units remain, the sequence of events in use case #1 occurs ===#4: A {{{CompilationUnit}}} becomes invalid=== @@ -105,4 +109,4 @@ # For each {{{CompiledClass}}} # The contained JRealClassType is removed from {{{TypeOracle}}} # All internal state is cleared - # The set of {{{CompiledClasses}}} is cleared + # The set of {{{CompiledClasses}}} is cleared \ No newline at end of file --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/Google-Web-Toolkit-Contributors -~----------~----~----~----~------~----~------~--~---