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

Side by Side Diff: pkg/compiler/lib/src/js_backend/codegen/task.dart

Issue 1512303002: dart2js cps: Add instruction for bounds checks. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 /// Generate code using the cps-based IR pipeline. 5 /// Generate code using the cps-based IR pipeline.
6 library code_generator_task; 6 library code_generator_task;
7 7
8 import 'glue.dart'; 8 import 'glue.dart';
9 import 'codegen.dart'; 9 import 'codegen.dart';
10 import 'unsugar.dart'; 10 import 'unsugar.dart';
11 11
12 import '../js_backend.dart'; 12 import '../js_backend.dart';
13 13
14 import '../../common.dart'; 14 import '../../common.dart';
15 import '../../common/codegen.dart' show 15 import '../../common/codegen.dart' show
16 CodegenWorkItem; 16 CodegenWorkItem;
17 import '../../common/tasks.dart' show 17 import '../../common/tasks.dart' show
18 CompilerTask, 18 CompilerTask,
19 GenericTask; 19 GenericTask;
20 import '../../compiler.dart' show 20 import '../../compiler.dart' show
21 Compiler; 21 Compiler;
22 import '../../constants/constant_system.dart'; 22 import '../../constants/constant_system.dart';
23 import '../../cps_ir/cps_ir_builder_task.dart'; 23 import '../../cps_ir/cps_ir_builder_task.dart';
24 import '../../cps_ir/cps_ir_nodes.dart' as cps; 24 import '../../cps_ir/cps_ir_nodes.dart' as cps;
25 import '../../cps_ir/cps_ir_nodes_sexpr.dart'; 25 import '../../cps_ir/cps_ir_nodes_sexpr.dart';
26 import '../../cps_ir/cps_ir_integrity.dart'; 26 import '../../cps_ir/cps_ir_integrity.dart';
27 import '../../cps_ir/optimizers.dart'; 27 import '../../cps_ir/optimizers.dart';
28 import '../../cps_ir/optimizers.dart' as cps_opt; 28 import '../../cps_ir/optimizers.dart' as cps_opt;
29 import '../../cps_ir/type_mask_system.dart'; 29 import '../../cps_ir/type_mask_system.dart';
30 import '../../cps_ir/finalize.dart' show Finalize;
30 import '../../diagnostics/invariant.dart' show 31 import '../../diagnostics/invariant.dart' show
31 DEBUG_MODE; 32 DEBUG_MODE;
32 import '../../elements/elements.dart'; 33 import '../../elements/elements.dart';
33 import '../../js/js.dart' as js; 34 import '../../js/js.dart' as js;
34 import '../../js_backend/codegen/codegen.dart'; 35 import '../../js_backend/codegen/codegen.dart';
35 import '../../io/source_information.dart' show 36 import '../../io/source_information.dart' show
36 SourceInformationStrategy; 37 SourceInformationStrategy;
37 import '../../tree_ir/tree_ir_builder.dart' as tree_builder; 38 import '../../tree_ir/tree_ir_builder.dart' as tree_builder;
38 import '../../tracer.dart'; 39 import '../../tracer.dart';
39 import '../../ssa/ssa.dart' as ssa; 40 import '../../ssa/ssa.dart' as ssa;
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 cps.FunctionDefinition optimizeCpsIr(cps.FunctionDefinition cpsFunction) { 203 cps.FunctionDefinition optimizeCpsIr(cps.FunctionDefinition cpsFunction) {
203 cpsOptimizationTask.measure(() { 204 cpsOptimizationTask.measure(() {
204 applyCpsPass(new RedundantJoinEliminator(), cpsFunction); 205 applyCpsPass(new RedundantJoinEliminator(), cpsFunction);
205 applyCpsPass(new RedundantPhiEliminator(), cpsFunction); 206 applyCpsPass(new RedundantPhiEliminator(), cpsFunction);
206 applyCpsPass(new InsertRefinements(typeSystem), cpsFunction); 207 applyCpsPass(new InsertRefinements(typeSystem), cpsFunction);
207 applyCpsPass(new TypePropagator(compiler, typeSystem, this), cpsFunction); 208 applyCpsPass(new TypePropagator(compiler, typeSystem, this), cpsFunction);
208 applyCpsPass(new RedundantJoinEliminator(), cpsFunction); 209 applyCpsPass(new RedundantJoinEliminator(), cpsFunction);
209 applyCpsPass(new ShrinkingReducer(), cpsFunction); 210 applyCpsPass(new ShrinkingReducer(), cpsFunction);
210 applyCpsPass(new RedundantRefinementEliminator(typeSystem), cpsFunction); 211 applyCpsPass(new RedundantRefinementEliminator(typeSystem), cpsFunction);
211 applyCpsPass(new GVN(compiler), cpsFunction); 212 applyCpsPass(new GVN(compiler), cpsFunction);
213 applyCpsPass(new BoundsChecker(typeSystem, compiler.world), cpsFunction);
asgerf 2015/12/10 18:32:14 It works better with refinement information. We mi
212 applyCpsPass(new RemoveRefinements(), cpsFunction); 214 applyCpsPass(new RemoveRefinements(), cpsFunction);
213 applyCpsPass(new ShrinkingReducer(), cpsFunction); 215 applyCpsPass(new ShrinkingReducer(), cpsFunction);
214 applyCpsPass(new ScalarReplacer(compiler), cpsFunction); 216 applyCpsPass(new ScalarReplacer(compiler), cpsFunction);
215 applyCpsPass(new MutableVariableEliminator(), cpsFunction); 217 applyCpsPass(new MutableVariableEliminator(), cpsFunction);
216 applyCpsPass(new RedundantJoinEliminator(), cpsFunction); 218 applyCpsPass(new RedundantJoinEliminator(), cpsFunction);
217 applyCpsPass(new RedundantPhiEliminator(), cpsFunction); 219 applyCpsPass(new RedundantPhiEliminator(), cpsFunction);
218 applyCpsPass(new BoundsChecker(typeSystem, compiler.world), cpsFunction);
219 applyCpsPass(new ShrinkingReducer(), cpsFunction); 220 applyCpsPass(new ShrinkingReducer(), cpsFunction);
220 applyCpsPass(new OptimizeInterceptors(backend), cpsFunction); 221 applyCpsPass(new OptimizeInterceptors(backend), cpsFunction);
221 applyCpsPass(new ShrinkingReducer(), cpsFunction); 222 applyCpsPass(new ShrinkingReducer(), cpsFunction);
222 }); 223 });
223 return cpsFunction; 224 return cpsFunction;
224 } 225 }
225 226
226 tree_ir.FunctionDefinition compileToTreeIr(cps.FunctionDefinition cpsNode) { 227 tree_ir.FunctionDefinition compileToTreeIr(cps.FunctionDefinition cpsNode) {
228 applyCpsPass(new Finalize(backend), cpsNode);
227 tree_builder.Builder builder = new tree_builder.Builder( 229 tree_builder.Builder builder = new tree_builder.Builder(
228 reporter.internalError); 230 reporter.internalError);
229 tree_ir.FunctionDefinition treeNode = 231 tree_ir.FunctionDefinition treeNode =
230 treeBuilderTask.measure(() => builder.buildFunction(cpsNode)); 232 treeBuilderTask.measure(() => builder.buildFunction(cpsNode));
231 assert(treeNode != null); 233 assert(treeNode != null);
232 traceGraph('Tree builder', treeNode); 234 traceGraph('Tree builder', treeNode);
233 assert(checkTreeIntegrity(treeNode)); 235 assert(checkTreeIntegrity(treeNode));
234 return treeNode; 236 return treeNode;
235 } 237 }
236 238
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 treeOptimizationTask] 283 treeOptimizationTask]
282 ..addAll(fallbackCompiler.tasks); 284 ..addAll(fallbackCompiler.tasks);
283 } 285 }
284 286
285 js.Node attachPosition(js.Node node, AstElement element) { 287 js.Node attachPosition(js.Node node, AstElement element) {
286 return node.withSourceInformation( 288 return node.withSourceInformation(
287 sourceInformationFactory.createBuilderForContext(element) 289 sourceInformationFactory.createBuilderForContext(element)
288 .buildDeclaration(element)); 290 .buildDeclaration(element));
289 } 291 }
290 } 292 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698