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

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

Issue 2302363003: No longer store the compilation-context in WorkItem. (Closed)
Patch Set: ... lint Created 4 years, 3 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
« no previous file with comments | « pkg/compiler/lib/src/enqueue.dart ('k') | pkg/compiler/lib/src/js_backend/enqueuer.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 library js_backend.backend; 5 library js_backend.backend;
6 6
7 import 'dart:async' show Future; 7 import 'dart:async' show Future;
8 8
9 import 'package:js_runtime/shared/embedded_names.dart' as embeddedNames; 9 import 'package:js_runtime/shared/embedded_names.dart' as embeddedNames;
10 10
11 import '../closure.dart'; 11 import '../closure.dart';
12 import '../common.dart'; 12 import '../common.dart';
13 import '../common/backend_api.dart' 13 import '../common/backend_api.dart'
14 show Backend, ImpactTransformer, ForeignResolver, NativeRegistry; 14 show Backend, ImpactTransformer, ForeignResolver, NativeRegistry;
15 import '../common/codegen.dart' show CodegenImpact, CodegenWorkItem; 15 import '../common/codegen.dart' show CodegenImpact, CodegenWorkItem;
16 import '../common/names.dart' show Identifiers, Selectors, Uris; 16 import '../common/names.dart' show Identifiers, Selectors, Uris;
17 import '../common/registry.dart' show EagerRegistry, Registry; 17 import '../common/registry.dart' show EagerRegistry, Registry;
18 import '../common/resolution.dart' show Frontend, Resolution, ResolutionImpact; 18 import '../common/resolution.dart' show Frontend, Resolution, ResolutionImpact;
19 import '../common/tasks.dart' show CompilerTask; 19 import '../common/tasks.dart' show CompilerTask;
20 import '../common/work.dart' show ItemCompilationContext;
21 import '../compiler.dart' show Compiler; 20 import '../compiler.dart' show Compiler;
22 import '../constants/constant_system.dart'; 21 import '../constants/constant_system.dart';
23 import '../constants/expressions.dart'; 22 import '../constants/expressions.dart';
24 import '../constants/values.dart'; 23 import '../constants/values.dart';
25 import '../core_types.dart' show CoreClasses, CoreTypes; 24 import '../core_types.dart' show CoreClasses, CoreTypes;
26 import '../dart_types.dart'; 25 import '../dart_types.dart';
27 import '../deferred_load.dart' show DeferredLoadTask; 26 import '../deferred_load.dart' show DeferredLoadTask;
28 import '../dump_info.dart' show DumpInfoTask; 27 import '../dump_info.dart' show DumpInfoTask;
29 import '../elements/elements.dart'; 28 import '../elements/elements.dart';
30 import '../enqueue.dart' 29 import '../enqueue.dart'
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 import 'namer.dart'; 70 import 'namer.dart';
72 import 'native_data.dart' show NativeData; 71 import 'native_data.dart' show NativeData;
73 import 'no_such_method_registry.dart'; 72 import 'no_such_method_registry.dart';
74 import 'patch_resolver.dart'; 73 import 'patch_resolver.dart';
75 import 'type_variable_handler.dart'; 74 import 'type_variable_handler.dart';
76 75
77 part 'runtime_types.dart'; 76 part 'runtime_types.dart';
78 77
79 const VERBOSE_OPTIMIZER_HINTS = false; 78 const VERBOSE_OPTIMIZER_HINTS = false;
80 79
81 class JavaScriptItemCompilationContext extends ItemCompilationContext {
82 final Set<HInstruction> boundsChecked = new Set<HInstruction>();
83 final Set<HInstruction> allocatedFixedLists = new Set<HInstruction>();
84 }
85
86 abstract class FunctionCompiler { 80 abstract class FunctionCompiler {
87 /// Generates JavaScript code for `work.element`. 81 /// Generates JavaScript code for `work.element`.
88 jsAst.Fun compile(CodegenWorkItem work); 82 jsAst.Fun compile(CodegenWorkItem work);
89 83
90 Iterable get tasks; 84 Iterable get tasks;
91 } 85 }
92 86
93 /* 87 /*
94 * Invariants: 88 * Invariants:
95 * canInline(function) implies canInline(function, insideLoop:true) 89 * canInline(function) implies canInline(function, insideLoop:true)
(...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 if (!enqueuer.nativeEnqueuer.hasInstantiatedNativeClasses()) return; 1290 if (!enqueuer.nativeEnqueuer.hasInstantiatedNativeClasses()) return;
1297 Registry registry = compiler.globalDependencies; 1291 Registry registry = compiler.globalDependencies;
1298 enqueue(enqueuer, helpers.getNativeInterceptorMethod, registry); 1292 enqueue(enqueuer, helpers.getNativeInterceptorMethod, registry);
1299 enqueueClass(enqueuer, helpers.jsJavaScriptObjectClass, registry); 1293 enqueueClass(enqueuer, helpers.jsJavaScriptObjectClass, registry);
1300 enqueueClass(enqueuer, helpers.jsPlainJavaScriptObjectClass, registry); 1294 enqueueClass(enqueuer, helpers.jsPlainJavaScriptObjectClass, registry);
1301 enqueueClass(enqueuer, helpers.jsJavaScriptFunctionClass, registry); 1295 enqueueClass(enqueuer, helpers.jsJavaScriptFunctionClass, registry);
1302 needToInitializeIsolateAffinityTag = true; 1296 needToInitializeIsolateAffinityTag = true;
1303 needToInitializeDispatchProperty = true; 1297 needToInitializeDispatchProperty = true;
1304 } 1298 }
1305 1299
1306 JavaScriptItemCompilationContext createItemCompilationContext() {
1307 return new JavaScriptItemCompilationContext();
1308 }
1309
1310 void enqueueHelpers(ResolutionEnqueuer world, Registry registry) { 1300 void enqueueHelpers(ResolutionEnqueuer world, Registry registry) {
1311 assert(helpers.interceptorsLibrary != null); 1301 assert(helpers.interceptorsLibrary != null);
1312 // TODO(ngeoffray): Not enqueuing those two classes currently make 1302 // TODO(ngeoffray): Not enqueuing those two classes currently make
1313 // the compiler potentially crash. However, any reasonable program 1303 // the compiler potentially crash. However, any reasonable program
1314 // will instantiate those two classes. 1304 // will instantiate those two classes.
1315 addInterceptors(helpers.jsBoolClass, world, registry); 1305 addInterceptors(helpers.jsBoolClass, world, registry);
1316 addInterceptors(helpers.jsNullClass, world, registry); 1306 addInterceptors(helpers.jsNullClass, world, registry);
1317 if (compiler.options.enableTypeAssertions) { 1307 if (compiler.options.enableTypeAssertions) {
1318 // Unconditionally register the helper that checks if the 1308 // Unconditionally register the helper that checks if the
1319 // expression in an if/while/for is a boolean. 1309 // expression in an if/while/for is a boolean.
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
1560 enqueueClass(enqueuer, cls, registry); 1550 enqueueClass(enqueuer, cls, registry);
1561 } 1551 }
1562 for (BackendImpact otherImpact in impact.otherImpacts) { 1552 for (BackendImpact otherImpact in impact.otherImpacts) {
1563 enqueueImpact(enqueuer, otherImpact, registry); 1553 enqueueImpact(enqueuer, otherImpact, registry);
1564 } 1554 }
1565 } 1555 }
1566 1556
1567 CodegenEnqueuer get codegenEnqueuer => compiler.enqueuer.codegen; 1557 CodegenEnqueuer get codegenEnqueuer => compiler.enqueuer.codegen;
1568 1558
1569 CodegenEnqueuer createCodegenEnqueuer(Compiler compiler) { 1559 CodegenEnqueuer createCodegenEnqueuer(Compiler compiler) {
1570 return new CodegenEnqueuer(compiler, createItemCompilationContext, 1560 return new CodegenEnqueuer(compiler, const TreeShakingEnqueuerStrategy());
1571 const TreeShakingEnqueuerStrategy());
1572 } 1561 }
1573 1562
1574 WorldImpact codegen(CodegenWorkItem work) { 1563 WorldImpact codegen(CodegenWorkItem work) {
1575 Element element = work.element; 1564 Element element = work.element;
1576 if (compiler.elementHasCompileTimeError(element)) { 1565 if (compiler.elementHasCompileTimeError(element)) {
1577 DiagnosticMessage message = 1566 DiagnosticMessage message =
1578 // If there's more than one error, the first is probably most 1567 // If there's more than one error, the first is probably most
1579 // informative, as the following errors may be side-effects of the 1568 // informative, as the following errors may be side-effects of the
1580 // first error. 1569 // first error.
1581 compiler.elementsWithCompileTimeErrors[element].first; 1570 compiler.elementsWithCompileTimeErrors[element].first;
(...skipping 1624 matching lines...) Expand 10 before | Expand all | Expand 10 after
3206 3195
3207 @override 3196 @override
3208 void onImpactUsed(ImpactUseCase impactUse) { 3197 void onImpactUsed(ImpactUseCase impactUse) {
3209 if (impactUse == DeferredLoadTask.IMPACT_USE && !supportSerialization) { 3198 if (impactUse == DeferredLoadTask.IMPACT_USE && !supportSerialization) {
3210 // TODO(johnniwinther): Allow emptying when serialization has been 3199 // TODO(johnniwinther): Allow emptying when serialization has been
3211 // performed. 3200 // performed.
3212 resolution.emptyCache(); 3201 resolution.emptyCache();
3213 } 3202 }
3214 } 3203 }
3215 } 3204 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/enqueue.dart ('k') | pkg/compiler/lib/src/js_backend/enqueuer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698