Author: [email protected]
Date: Wed Jan 14 11:19:48 2009
New Revision: 4454
Modified:
wiki/OverlayTypes.wiki
Log:
Edited wiki page through web user interface.
Modified: wiki/OverlayTypes.wiki
==============================================================================
--- wiki/OverlayTypes.wiki (original)
+++ wiki/OverlayTypes.wiki Wed Jan 14 11:19:48 2009
@@ -219,7 +219,7 @@
=== Restrictions ===
The restrictions on overlay types given above still apply, with the
following modifications:
- * An overlay type may implement any number of interfaces with methods
that are annotated with `...@singlejsoimpl`. _This makes it obvious to the
system which interfaces should have these alternate rules applied._
+ * An overlay type may implement any number of non-trivial interfaces
that are annotated with `...@singlejsoimpl`. _This makes it obvious to the
system which interfaces should have these alternate rules applied._
* Any given `...@singlejsoimpl` interface may be implemented by exactly one
overlay type, although that overlay type may be further extended. Any
number of non-overlay types may implement the interface. _This allows any
method defined in the interface to be statically-dispatched in the fallback
case._
* If a `...@singlejsoimpl` interfaces extends a non-trivial interface, that
super-interface must also be be annotated with `...@singlejsoimpl`.
* The `...@singlejsoimpl` annotation may only be applied to interfaces.
@@ -230,10 +230,10 @@
The hosted-mode implementation relies on `JavaScriptObject$` implementing
all `...@singlejsoimpl` interfaces and supporting polymorphic dispatch. The
following bytecode transformations are applied: (note that code samples are
only intended to be representative of transformations applied)
* `JavaScriptObject$` implements all `...@singlejsoimpl` interfaces via the
disemboweled overlay types.
- * All methods in a `...@singlejsoimpl` interface are renamed to include the
type name of the type.
+ * All methods in a `...@singlejsoimpl` interface are renamed to include the
type name of the declaring interface type.
* Implemented in `RewriteSingleJsoImplDispatches.java`.
- * All call sites with a `...@singlejsoimpl` type as the owner are
rewritten with a mangled name. Call sites to more specific types are left
unchanged.
* `Person.getName()` would be transformed into
`Person.com_google_Person_getName()`
+ * All call sites with a `...@singlejsoimpl` type as the owner are
rewritten with a mangled name. Call sites to more specific types are left
unchanged.
* _This allows `JavaScriptObject$` to unambiguously dispatch methods
with identical descriptors from unrelated interfaces_.
* `JavaScriptObject$` implements all of the mangled methods as
trampoline functions to the single JSO-derived implementation.
* Implemented in `WriteJsoImpl.java`.
@@ -250,6 +250,35 @@
return this.someMethod(a, b);
}
}}}
- *
-=== Web Mode Implementation ===
\ No newline at end of file
+ This implementation is relatively simple because it does not require
significant transformation of call-sites, and continues to rely on regular
`INVOKEINTERFACE` JVM behaviors. The net effect is that the
`JavaScriptObject$` type is assignable to all `...@singlejsoimpl` types and
contains many trivial trampoline methods.
+
+=== Web Mode Implementation ===
+
+The changes to web mode are similar to those in hosted mode, where the
dispatch, casts, and instanceof checks are the primary changes made.
+
+'!JavaScriptObject' implements all interfaces that are known to have both
overlay and non-overlay implementations.
+
+Casts and instanceof checks are accomplished by adding a flag to
`JCastOperation` and `JInstanceOf` to allow a non-null, non-Java-derived
(i.e. `o.typeMarker$ != nullMethod`) object to pass the type checks.
Additional methods are added to the `Cast` utility class and
`CastNormalizer` updated.
+
+Any untightened, polymorphic method dispatch sites are rewritten to use
the single implementation of a `...@singlejsoimpl` method as a fallback in the
case that the target object is a non-Java-derived object. The use of
`typeMarker$` covers objects from external GWT modules.
+ {{{
+ Person p;
+ p.doSomething();
+}}}
+becomes
+ {{{
+ p.typeMarker$ != nullMethod ? p.doSomething() :
JsoPerson_doSomething$(p);
+}}}
+
+
+
+=== Other Updates ===
+
+ * JsoRestrictionsChecker has been updated with the new rules. One
design change is that the checker must accumulate state before a final
check pass in order to completely validate the type hierarchy of overlay
types. The order in which the JDT visitors will visit types is undefined,
so it may be the case that an overlay type is visited before its
`...@singlejsoimpl` interface.
+ * `TypeOracle` provides a getter to return all types annotated with
`...@singlejsoimpl`.
+ * `JTypeOracle` gains similar functionality and some extra utility
methods.
+
+=== Notes ===
+
+ * The implementation of overlay types in GWT 1.5 does not support
Generators defining new JSO subtypes (due to the need to redefine or
otherwise extend `JavaScriptObject$` during subsequent compilation). This
restriction is still in place.
\ No newline at end of file
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---