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

Side by Side Diff: pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart

Issue 1576063003: dart2js cps: Translate identity placeholders to refinement nodes. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Replace array-refinements in finalize pass Created 4 years, 11 months 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 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 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 library dart2js.ir_builder; 5 library dart2js.ir_builder;
6 6
7 import '../closure.dart' as closure; 7 import '../closure.dart' as closure;
8 import '../common.dart'; 8 import '../common.dart';
9 import '../common/names.dart' show 9 import '../common/names.dart' show
10 Names, 10 Names,
11 Selectors; 11 Selectors;
12 import '../compile_time_constants.dart' show 12 import '../compile_time_constants.dart' show
13 BackendConstantEnvironment; 13 BackendConstantEnvironment;
14 import '../constants/constant_system.dart'; 14 import '../constants/constant_system.dart';
15 import '../constants/values.dart' show 15 import '../constants/values.dart' show
16 ConstantValue, 16 ConstantValue,
17 PrimitiveConstantValue; 17 PrimitiveConstantValue;
18 import '../dart_types.dart'; 18 import '../dart_types.dart';
19 import '../elements/elements.dart'; 19 import '../elements/elements.dart';
20 import '../io/source_information.dart'; 20 import '../io/source_information.dart';
21 import '../js/js.dart' as js show 21 import '../js/js.dart' as js show
22 js, 22 js,
23 LiteralStatement, 23 LiteralStatement,
24 Template; 24 Template,
25 isIdentityTemplate;
25 import '../native/native.dart' show 26 import '../native/native.dart' show
26 NativeBehavior; 27 NativeBehavior;
27 import '../tree/tree.dart' as ast; 28 import '../tree/tree.dart' as ast;
28 import '../types/types.dart' show 29 import '../types/types.dart' show
29 TypeMask; 30 TypeMask;
30 import '../universe/call_structure.dart' show 31 import '../universe/call_structure.dart' show
31 CallStructure; 32 CallStructure;
32 import '../universe/selector.dart' show 33 import '../universe/selector.dart' show
33 Selector, 34 Selector,
34 SelectorKind; 35 SelectorKind;
(...skipping 2660 matching lines...) Expand 10 before | Expand all | Expand 10 after
2695 List<ir.Primitive> arguments) { 2696 List<ir.Primitive> arguments) {
2696 return addPrimitive(new ir.CreateInvocationMirror(selector, arguments)); 2697 return addPrimitive(new ir.CreateInvocationMirror(selector, arguments));
2697 } 2698 }
2698 2699
2699 ir.Primitive buildForeignCode(js.Template codeTemplate, 2700 ir.Primitive buildForeignCode(js.Template codeTemplate,
2700 List<ir.Primitive> arguments, 2701 List<ir.Primitive> arguments,
2701 NativeBehavior behavior, 2702 NativeBehavior behavior,
2702 {Element dependency}) { 2703 {Element dependency}) {
2703 assert(behavior != null); 2704 assert(behavior != null);
2704 TypeMask type = program.getTypeMaskForForeign(behavior); 2705 TypeMask type = program.getTypeMaskForForeign(behavior);
2706 if (js.isIdentityTemplate(codeTemplate) && !program.isArrayType(type)) {
2707 // JS expression is just a refinement.
2708 // Do not do this for arrays - those are special because array types can
2709 // change at runtime. The input and output must therefore be modeled
2710 // as distinct values.
2711 return addPrimitive(new ir.Refinement(arguments.single, type));
2712 }
2705 ir.Primitive result = addPrimitive(new ir.ForeignCode( 2713 ir.Primitive result = addPrimitive(new ir.ForeignCode(
2706 codeTemplate, 2714 codeTemplate,
2707 type, 2715 type,
2708 arguments, 2716 arguments,
2709 behavior, 2717 behavior,
2710 dependency: dependency)); 2718 dependency: dependency));
2711 if (!codeTemplate.isExpression) { 2719 if (!codeTemplate.isExpression) {
2712 // Close the term if this is a "throw" expression or native body. 2720 // Close the term if this is a "throw" expression or native body.
2713 add(new ir.Unreachable()); 2721 add(new ir.Unreachable());
2714 _current = null; 2722 _current = null;
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
2899 } 2907 }
2900 2908
2901 class SwitchCaseInfo { 2909 class SwitchCaseInfo {
2902 final List<ir.Primitive> constants = <ir.Primitive>[]; 2910 final List<ir.Primitive> constants = <ir.Primitive>[];
2903 final SubbuildFunction buildBody; 2911 final SubbuildFunction buildBody;
2904 2912
2905 SwitchCaseInfo(this.buildBody); 2913 SwitchCaseInfo(this.buildBody);
2906 2914
2907 void addConstant(ir.Primitive constant) => constants.add(constant); 2915 void addConstant(ir.Primitive constant) => constants.add(constant);
2908 } 2916 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart » ('j') | pkg/compiler/lib/src/js/js.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698