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

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

Issue 85813002: Revert "Revert "Build new IR for functions returning a constant."" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: feedback by kasper Created 7 years 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
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of ssa; 5 part of ssa;
6 6
7 class SsaCodeGeneratorTask extends CompilerTask { 7 class SsaCodeGeneratorTask extends CompilerTask {
8 8
9 final JavaScriptBackend backend; 9 final JavaScriptBackend backend;
10 10
11 SsaCodeGeneratorTask(JavaScriptBackend backend) 11 SsaCodeGeneratorTask(JavaScriptBackend backend)
12 : this.backend = backend, 12 : this.backend = backend,
13 super(backend.compiler); 13 super(backend.compiler);
14 String get name => 'SSA code generator'; 14 String get name => 'SSA code generator';
15 NativeEmitter get nativeEmitter => backend.emitter.nativeEmitter; 15 NativeEmitter get nativeEmitter => backend.emitter.nativeEmitter;
16 16
17 17
18 js.Node attachPosition(js.Node node, Element element) { 18 js.Node attachPosition(js.Node node, Element element) {
19 // TODO(sra): Attaching positions might be cleaner if the source position 19 // TODO(sra): Attaching positions might be cleaner if the source position
20 // was on a wrapping node. 20 // was on a wrapping node.
21 SourceFile sourceFile = sourceFileOfElement(element); 21 SourceFile sourceFile = sourceFileOfElement(element);
22 Node expression = element.implementation.parseNode(backend.compiler); 22 if (compiler.irBuilder.hasIr(element)) {
23 Token beginToken; 23 IrFunction function = compiler.irBuilder.getIr(element);
24 Token endToken; 24 node.sourcePosition = new OffsetSourceFileLocation(
25 if (expression == null) { 25 sourceFile, function.offset, function.sourceName);
26 // Synthesized node. Use the enclosing element for the location. 26 node.endSourcePosition = new OffsetSourceFileLocation(
27 beginToken = endToken = element.position(); 27 sourceFile, function.endOffset);
28 } else { 28 } else {
29 beginToken = expression.getBeginToken(); 29 Node expression = element.implementation.parseNode(backend.compiler);
30 endToken = expression.getEndToken(); 30 Token beginToken;
31 } 31 Token endToken;
32 // TODO(podivilov): find the right sourceFile here and remove offset checks 32 if (expression == null) {
33 // below. 33 // Synthesized node. Use the enclosing element for the location.
34 if (beginToken.charOffset < sourceFile.length) { 34 beginToken = endToken = element.position();
35 node.sourcePosition = new SourceFileLocation(sourceFile, beginToken); 35 } else {
36 } 36 beginToken = expression.getBeginToken();
37 if (endToken.charOffset < sourceFile.length) { 37 endToken = expression.getEndToken();
38 node.endSourcePosition = new SourceFileLocation(sourceFile, endToken); 38 }
39 // TODO(podivilov): find the right sourceFile here and remove offset
40 // checks below.
41 if (beginToken.charOffset < sourceFile.length) {
42 node.sourcePosition =
43 new TokenSourceFileLocation(sourceFile, beginToken);
44 }
45 if (endToken.charOffset < sourceFile.length) {
46 node.endSourcePosition =
47 new TokenSourceFileLocation(sourceFile, endToken);
48 }
39 } 49 }
40 return node; 50 return node;
41 } 51 }
42 52
43 SourceFile sourceFileOfElement(Element element) { 53 SourceFile sourceFileOfElement(Element element) {
44 // TODO(johnniwinther): remove the 'element.patch' hack. 54 // TODO(johnniwinther): remove the 'element.patch' hack.
45 FunctionElement functionElement = element.asFunctionElement(); 55 FunctionElement functionElement = element.asFunctionElement();
46 if (functionElement != null && functionElement.patch != null) { 56 if (functionElement != null && functionElement.patch != null) {
47 element = functionElement.patch; 57 element = functionElement.patch;
48 } 58 }
(...skipping 2509 matching lines...) Expand 10 before | Expand all | Expand 10 after
2558 if (left.isConstantNull() || right.isConstantNull() || 2568 if (left.isConstantNull() || right.isConstantNull() ||
2559 (left.isPrimitive(compiler) && 2569 (left.isPrimitive(compiler) &&
2560 left.instructionType == right.instructionType)) { 2570 left.instructionType == right.instructionType)) {
2561 return '=='; 2571 return '==';
2562 } 2572 }
2563 return null; 2573 return null;
2564 } else { 2574 } else {
2565 return '==='; 2575 return '===';
2566 } 2576 }
2567 } 2577 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698