Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Unified Diff: pkg/compiler/lib/src/cps_ir/cps_fragment.dart

Issue 1458703007: dart2js cps: Refactor CallExpressions into Primitives. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Another minor fix Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/cps_ir/cps_fragment.dart
diff --git a/pkg/compiler/lib/src/cps_ir/cps_fragment.dart b/pkg/compiler/lib/src/cps_ir/cps_fragment.dart
index 7fc2ae38373fb2bd8cac048dd568cec129d9ae34..77825136a6e5a0c799c96c715c3f9f34b690769b 100644
--- a/pkg/compiler/lib/src/cps_ir/cps_fragment.dart
+++ b/pkg/compiler/lib/src/cps_ir/cps_fragment.dart
@@ -123,35 +123,19 @@ class CpsFragment {
return letPrim(apply);
}
- /// Inserts an invocation. binds its continuation, and returns the
- /// continuation parameter (i.e. the return value of the invocation).
- ///
- /// The continuation body becomes the new hole.
- Parameter invokeMethod(Primitive receiver,
+ /// Inserts an invocation and returns a primitive holding the returned value.
+ Primitive invokeMethod(Primitive receiver,
Selector selector,
TypeMask mask,
List<Primitive> arguments) {
- Continuation cont = new Continuation(<Parameter>[new Parameter(null)]);
- InvokeMethod invoke =
- new InvokeMethod(receiver, selector, mask, arguments, cont,
- sourceInformation);
- put(new LetCont(cont, invoke));
- context = cont;
- return cont.parameters.single;
+ return letPrim(new InvokeMethod(receiver, selector, mask, arguments,
+ sourceInformation));
Kevin Millikin (Google) 2015/11/23 10:22:44 I'm not sure what the indentation is intended to b
asgerf 2015/11/23 10:48:57 Done.
}
- /// Inserts an invocation. binds its continuation, and returns the
- /// continuation parameter (i.e. the return value of the invocation).
- ///
- /// The continuation body becomes the new hole.
- Parameter invokeStatic(FunctionElement target, List<Primitive> arguments) {
- Continuation cont = new Continuation(<Parameter>[new Parameter(null)]);
- InvokeStatic invoke =
- new InvokeStatic(target, new Selector.fromElement(target), arguments,
- cont, sourceInformation);
- put(new LetCont(cont, invoke));
- context = cont;
- return cont.parameters.single;
+ /// Inserts an invocation and returns a primitive holding the returned value.
+ Primitive invokeStatic(FunctionElement target, List<Primitive> arguments) {
+ return letPrim(new InvokeStatic(target, new Selector.fromElement(target),
+ arguments, sourceInformation));
}
/// Inserts an invocation to a static function that throws an error.
@@ -253,10 +237,45 @@ class CpsFragment {
Continuation letCont([List<Parameter> parameters]) {
if (parameters == null) parameters = <Parameter>[];
Continuation cont = new Continuation(parameters);
+ bindContinuation(cont);
+ return cont;
+ }
+
+ /// Binds an existing continuation at this position.
+ ///
+ /// The LetCont body becomes the new hole.
+ void bindContinuation(Continuation cont) {
LetCont let = new LetCont(cont, null);
put(let);
context = let;
- return cont;
+ }
+
+ /// Inlines [target] at the current position, substituting the provided
+ /// arguments.
+ ///
+ /// Returns a primitive containing the function's return value.
+ ///
+ /// The new hole is the the point after [target] has returned. The fragment
+ /// remains open, even if [target] never returns.
+ ///
+ /// The [target] function is destroyed and should not be reused.
+ Primitive inlineFunction(FunctionDefinition target,
+ List<Primitive> arguments,
+ Primitive thisArgument,
Kevin Millikin (Google) 2015/11/23 10:22:43 It seems to me that thisArgument should come befor
asgerf 2015/11/23 10:48:56 Done.
+ {Entity hint}) {
+ if (thisArgument != null) {
+ target.thisParameter.replaceUsesWith(thisArgument);
+ }
+ for (int i = 0; i < arguments.length; ++i) {
+ target.parameters[i].replaceUsesWith(arguments[i]);
+ }
+ Continuation returnCont = target.returnContinuation;
Kevin Millikin (Google) 2015/11/23 10:22:44 Strange that this is still a continuation but call
asgerf 2015/11/23 10:48:57 Acknowledged.
+ bindContinuation(returnCont);
+ put(target.body);
+ Parameter returnValue = returnCont.parameters.single;
+ returnValue.hint = hint;
+ context = returnCont;
+ return returnValue;
}
/// Returns a fragment whose context is the body of the given continuation.

Powered by Google App Engine
This is Rietveld 408576698