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

Unified Diff: pkg/compiler/lib/src/js_backend/constant_handler_javascript.dart

Issue 2076503002: Cache metadata constants for make benefit of glorious try/poi/forget_element_test (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js_backend/constant_handler_javascript.dart
diff --git a/pkg/compiler/lib/src/js_backend/constant_handler_javascript.dart b/pkg/compiler/lib/src/js_backend/constant_handler_javascript.dart
index dcab36a23909a0250981dd8ee8384431b36fd66b..ddf76746e0398bf3ef7c4128d939d7da3922fd1d 100644
--- a/pkg/compiler/lib/src/js_backend/constant_handler_javascript.dart
+++ b/pkg/compiler/lib/src/js_backend/constant_handler_javascript.dart
@@ -115,6 +115,12 @@ class JavaScriptConstantCompiler extends ConstantCompilerBase
final Map<Node, ConstantExpression> nodeConstantMap =
new Map<Node, ConstantExpression>();
+ // Constants computed for metadata.
+ // TODO(johnniwinther): Remove this when no longer used by
+ // poi/forget_element_test.
+ final Map<MetadataAnnotation, ConstantExpression> metadataConstantMap =
+ new Map<MetadataAnnotation, ConstantExpression>();
+
JavaScriptConstantCompiler(Compiler compiler)
: super(compiler, JAVA_SCRIPT_CONSTANT_SYSTEM);
@@ -211,6 +217,15 @@ class JavaScriptConstantCompiler extends ConstantCompilerBase
return getConstantValue(metadata.constant);
}
+ @override
+ ConstantExpression compileMetadata(
+ MetadataAnnotation metadata, Node node, TreeElements elements) {
+ ConstantExpression constant =
+ super.compileMetadata(metadata, node, elements);
+ metadataConstantMap[metadata] = constant;
+ return constant;
+ }
+
void forgetElement(Element element) {
super.forgetElement(element);
const ForgetConstantElementVisitor().visit(element, this);
@@ -226,6 +241,7 @@ class ForgetConstantElementVisitor
void visitElement(Element e, JavaScriptConstantCompiler constants) {
for (MetadataAnnotation data in e.implementation.metadata) {
+ constants.metadataConstantMap.remove(data);
if (data.hasNode) {
data.node.accept(new ForgetConstantNodeVisitor(constants));
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698