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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/ssa/from_ir_inliner.dart

Issue 57873002: Build new IR for functions returning a constant (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: no nested functions in ir Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 part of ssa;
6
7 class SsaFromIrInliner extends IrNodesVisitor {
8
9 final SsaBuilder builder;
10
11 SsaFromIrInliner(this.builder);
12
13 final Map<IrNode, HInstruction> emitted = new Map<IrNode, HInstruction>();
14
15 Compiler get compiler => builder.compiler;
16
17 void visitIrReturn(IrReturn node) {
18 HInstruction hValue = emitted[node.value];
19 builder.localsHandler.updateLocal(builder.returnElement, hValue);
20 }
21
22 void visitIrConstant(IrConstant node) {
23 emitted[node] = builder.graph.addConstant(node.value, compiler);
24 }
25
26 void visitNode(IrNode node) {
27 compiler.internalError('Unexpected IrNode $node');
28 }
29 }
30
31 class IrInlineWeeder extends IrNodesVisitor {
32 static bool canBeInlined(IrFunction irFunction, int maxInliningNodes) {
33 IrInlineWeeder weeder = new IrInlineWeeder(maxInliningNodes);
34 weeder.visitAll(irFunction.statements);
35 return !weeder.tooDifficult;
36 }
37
38 final int maxInliningNodes;
39
40 IrInlineWeeder(this.maxInliningNodes);
41
42 bool seenReturn = false;
43 bool tooDifficult = false;
44 int nodeCount = 0;
45
46 bool registerNode() {
47 if (nodeCount++ > maxInliningNodes) {
48 tooDifficult = true;
49 return false;
50 } else {
51 return true;
52 }
53 }
54
55 void visitNode(IrNode node) {
56 if (!registerNode()) return;
57 if (seenReturn) {
58 tooDifficult = true;
59 }
60 }
61
62 void visitIrReturn(IrReturn node) {
63 visitNode(node);
64 seenReturn = true;
65 }
66
67 void visitIrFunction(IrFunction node) {
68 tooDifficult = true;
69 }
70
71 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698