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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/full_emitter/nsm_emitter.dart

Issue 2871583002: Pass InterceptorData through ResolutionWorldBuilder and access it through ClosedWorld (Closed)
Patch Set: Created 3 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) 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.js_emitter.full_emitter.nsm_emitter; 5 library dart2js.js_emitter.full_emitter.nsm_emitter;
6 6
7 import '../../elements/entities.dart'; 7 import '../../elements/entities.dart';
8 import '../../js/js.dart' as jsAst; 8 import '../../js/js.dart' as jsAst;
9 import '../../js/js.dart' show js; 9 import '../../js/js.dart' show js;
10 import '../../js_backend/js_backend.dart' show GetterName, SetterName; 10 import '../../js_backend/js_backend.dart' show GetterName, SetterName;
(...skipping 16 matching lines...) Expand all
27 bool get generateTrivialNsmHandlers => true; 27 bool get generateTrivialNsmHandlers => true;
28 28
29 // If we need fewer than this many noSuchMethod handlers we can save space by 29 // If we need fewer than this many noSuchMethod handlers we can save space by
30 // just emitting them in JS, rather than emitting the JS needed to generate 30 // just emitting them in JS, rather than emitting the JS needed to generate
31 // them at run time. 31 // them at run time.
32 static const VERY_FEW_NO_SUCH_METHOD_HANDLERS = 10; 32 static const VERY_FEW_NO_SUCH_METHOD_HANDLERS = 10;
33 33
34 static const MAX_MINIFIED_LENGTH_FOR_DIFF_ENCODING = 4; 34 static const MAX_MINIFIED_LENGTH_FOR_DIFF_ENCODING = 4;
35 35
36 void emitNoSuchMethodHandlers(AddPropertyFunction addProperty) { 36 void emitNoSuchMethodHandlers(AddPropertyFunction addProperty) {
37 ClassStubGenerator generator = new ClassStubGenerator( 37 ClassStubGenerator generator = new ClassStubGenerator(task.emitter,
38 task.emitter, 38 compiler.commonElements, namer, codegenWorldBuilder, closedWorld,
39 compiler.commonElements,
40 namer,
41 codegenWorldBuilder,
42 backend.interceptorData,
43 closedWorld,
44 enableMinification: compiler.options.enableMinification); 39 enableMinification: compiler.options.enableMinification);
45 40
46 // Keep track of the JavaScript names we've already added so we 41 // Keep track of the JavaScript names we've already added so we
47 // do not introduce duplicates (bad for code size). 42 // do not introduce duplicates (bad for code size).
48 Map<jsAst.Name, Selector> addedJsNames = 43 Map<jsAst.Name, Selector> addedJsNames =
49 generator.computeSelectorsForNsmHandlers(); 44 generator.computeSelectorsForNsmHandlers();
50 45
51 // Set flag used by generateMethod helper below. If we have very few 46 // Set flag used by generateMethod helper below. If we have very few
52 // handlers we use addProperty for them all, rather than try to generate 47 // handlers we use addProperty for them all, rather than try to generate
53 // them at runtime. 48 // them at runtime.
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 List<jsAst.Statement> buildTrivialNsmHandlers() { 136 List<jsAst.Statement> buildTrivialNsmHandlers() {
142 List<jsAst.Statement> statements = <jsAst.Statement>[]; 137 List<jsAst.Statement> statements = <jsAst.Statement>[];
143 if (trivialNsmHandlers.length == 0) return statements; 138 if (trivialNsmHandlers.length == 0) return statements;
144 139
145 bool minify = compiler.options.enableMinification; 140 bool minify = compiler.options.enableMinification;
146 bool useDiffEncoding = minify && trivialNsmHandlers.length > 30; 141 bool useDiffEncoding = minify && trivialNsmHandlers.length > 30;
147 142
148 // Find out how many selectors there are with the special calling 143 // Find out how many selectors there are with the special calling
149 // convention. 144 // convention.
150 Iterable<Selector> interceptedSelectors = trivialNsmHandlers.where( 145 Iterable<Selector> interceptedSelectors = trivialNsmHandlers.where(
151 (Selector s) => backend.interceptorData.isInterceptedName(s.name)); 146 (Selector s) => closedWorld.interceptorData.isInterceptedName(s.name));
152 Iterable<Selector> ordinarySelectors = trivialNsmHandlers.where( 147 Iterable<Selector> ordinarySelectors = trivialNsmHandlers.where(
153 (Selector s) => !backend.interceptorData.isInterceptedName(s.name)); 148 (Selector s) => !closedWorld.interceptorData.isInterceptedName(s.name));
154 149
155 // Get the short names (JS names, perhaps minified). 150 // Get the short names (JS names, perhaps minified).
156 Iterable<jsAst.Name> interceptedShorts = 151 Iterable<jsAst.Name> interceptedShorts =
157 interceptedSelectors.map(namer.invocationMirrorInternalName); 152 interceptedSelectors.map(namer.invocationMirrorInternalName);
158 Iterable<jsAst.Name> ordinaryShorts = 153 Iterable<jsAst.Name> ordinaryShorts =
159 ordinarySelectors.map(namer.invocationMirrorInternalName); 154 ordinarySelectors.map(namer.invocationMirrorInternalName);
160 155
161 jsAst.Expression sortedShorts; 156 jsAst.Expression sortedShorts;
162 Iterable<String> sortedLongs; 157 Iterable<String> sortedLongs;
163 if (useDiffEncoding) { 158 if (useDiffEncoding) {
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 } 403 }
409 404
410 String get value { 405 String get value {
411 if (_cachedValue == null) { 406 if (_cachedValue == null) {
412 _cachedValue = _computeDiffEncoding(); 407 _cachedValue = _computeDiffEncoding();
413 } 408 }
414 409
415 return _cachedValue; 410 return _cachedValue;
416 } 411 }
417 } 412 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698