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

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

Issue 1955403002: Skip spurious constants in deferred computation. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 4 years, 7 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) 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 part of js_backend; 5 part of js_backend;
6 6
7 /// [ConstantCompilerTask] for compilation of constants for the JavaScript 7 /// [ConstantCompilerTask] for compilation of constants for the JavaScript
8 /// backend. 8 /// backend.
9 /// 9 ///
10 /// Since this task needs to distinguish between frontend and backend constants 10 /// Since this task needs to distinguish between frontend and backend constants
11 /// the actual compilation of the constants is forwarded to a 11 /// the actual compilation of the constants is forwarded to a
12 /// [DartConstantCompiler] for the frontend interpretation of the constants and 12 /// [DartConstantCompiler] for the frontend interpretation of the constants and
13 /// to a [JavaScriptConstantCompiler] for the backend interpretation. 13 /// to a [JavaScriptConstantCompiler] for the backend interpretation.
14 class JavaScriptConstantTask extends ConstantCompilerTask { 14 class JavaScriptConstantTask extends ConstantCompilerTask {
15 DartConstantCompiler dartConstantCompiler; 15 DartConstantCompiler dartConstantCompiler;
16 JavaScriptConstantCompiler jsConstantCompiler; 16 JavaScriptConstantCompiler jsConstantCompiler;
17 17
18 JavaScriptConstantTask(Compiler compiler) 18 JavaScriptConstantTask(Compiler compiler)
19 : this.dartConstantCompiler = new DartConstantCompiler(compiler), 19 : this.dartConstantCompiler = new DartConstantCompiler(compiler),
20 this.jsConstantCompiler = new JavaScriptConstantCompiler(compiler), 20 this.jsConstantCompiler = new JavaScriptConstantCompiler(compiler),
21 super(compiler); 21 super(compiler);
22 22
23 String get name => 'ConstantHandler'; 23 String get name => 'ConstantHandler';
24 24
25 @override 25 @override
26 ConstantSystem get constantSystem => dartConstantCompiler.constantSystem; 26 ConstantSystem get constantSystem => dartConstantCompiler.constantSystem;
27 27
28 @override 28 @override
29 bool hasConstantValue(ConstantExpression expression) {
30 return dartConstantCompiler.hasConstantValue(expression);
31 }
32
33 @override
29 ConstantValue getConstantValue(ConstantExpression expression) { 34 ConstantValue getConstantValue(ConstantExpression expression) {
30 return dartConstantCompiler.getConstantValue(expression); 35 return dartConstantCompiler.getConstantValue(expression);
31 } 36 }
32 37
33 @override 38 @override
34 ConstantValue getConstantValueForVariable(VariableElement element) { 39 ConstantValue getConstantValueForVariable(VariableElement element) {
35 return dartConstantCompiler.getConstantValueForVariable(element); 40 return dartConstantCompiler.getConstantValueForVariable(element);
36 } 41 }
37 42
38 @override 43 @override
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 element.node.accept(new ForgetConstantNodeVisitor(this)); 249 element.node.accept(new ForgetConstantNodeVisitor(this));
245 } 250 }
246 } 251 }
247 252
248 @override 253 @override
249 ConstantValue getConstantValue(ConstantExpression expression) { 254 ConstantValue getConstantValue(ConstantExpression expression) {
250 assert(invariant(CURRENT_ELEMENT_SPANNABLE, expression != null, 255 assert(invariant(CURRENT_ELEMENT_SPANNABLE, expression != null,
251 message: "ConstantExpression is null in getConstantValue.")); 256 message: "ConstantExpression is null in getConstantValue."));
252 // TODO(johhniwinther): ensure expressions have been evaluated at this 257 // TODO(johhniwinther): ensure expressions have been evaluated at this
253 // point. This can't be enabled today due to dartbug.com/26406. 258 // point. This can't be enabled today due to dartbug.com/26406.
254 259 if (compiler.serialization.supportsDeserialization) {
260 evaluate(expression);
261 }
255 ConstantValue value = super.getConstantValue(expression); 262 ConstantValue value = super.getConstantValue(expression);
256 if (value == null && 263 if (value == null &&
257 expression != null && 264 expression != null &&
258 expression.kind == ConstantExpressionKind.ERRONEOUS) { 265 expression.kind == ConstantExpressionKind.ERRONEOUS) {
259 // TODO(johnniwinther): When the Dart constant system sees a constant 266 // TODO(johnniwinther): When the Dart constant system sees a constant
260 // expression as erroneous but the JavaScript constant system finds it ok 267 // expression as erroneous but the JavaScript constant system finds it ok
261 // we have store a constant value for the erroneous constant expression. 268 // we have store a constant value for the erroneous constant expression.
262 // Ensure the computed constant expressions are always the same; that only 269 // Ensure the computed constant expressions are always the same; that only
263 // the constant values may be different. 270 // the constant values may be different.
264 value = new NullConstantValue(); 271 value = new NullConstantValue();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 // TODO(ahe): This doesn't belong here. Rename this class and generalize. 308 // TODO(ahe): This doesn't belong here. Rename this class and generalize.
302 var closureClassMap = constants 309 var closureClassMap = constants
303 .compiler.closureToClassMapper.closureMappingCache 310 .compiler.closureToClassMapper.closureMappingCache
304 .remove(node); 311 .remove(node);
305 if (closureClassMap != null) { 312 if (closureClassMap != null) {
306 closureClassMap 313 closureClassMap
307 .removeMyselfFrom(constants.compiler.enqueuer.codegen.universe); 314 .removeMyselfFrom(constants.compiler.enqueuer.codegen.universe);
308 } 315 }
309 } 316 }
310 } 317 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/backend.dart ('k') | pkg/compiler/lib/src/serialization/task.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698