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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/new_emitter/model_emitter.dart

Issue 1215463006: Move nativeInfo encoding into NativeGenerator. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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 library dart2js.new_js_emitter.model_emitter; 5 library dart2js.new_js_emitter.model_emitter;
6 6
7 import '../../constants/values.dart' show ConstantValue, FunctionConstantValue; 7 import '../../constants/values.dart' show ConstantValue, FunctionConstantValue;
8 import '../../dart2jslib.dart' show Compiler; 8 import '../../dart2jslib.dart' show Compiler;
9 import '../../elements/elements.dart' show ClassElement, FunctionElement; 9 import '../../elements/elements.dart' show ClassElement, FunctionElement;
10 import '../../js/js.dart' as js; 10 import '../../js/js.dart' as js;
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 246
247 js.Expression nativeInfoAccess = js.js('nativeInfo', []); 247 js.Expression nativeInfoAccess = js.js('nativeInfo', []);
248 js.Expression constructorAccess = js.js('constructor', []); 248 js.Expression constructorAccess = js.js('constructor', []);
249 Function subclassReadGenerator = (js.Expression subclass) { 249 Function subclassReadGenerator = (js.Expression subclass) {
250 return js.js('holdersMap[#][#].ensureResolved()', [subclass, subclass]); 250 return js.js('holdersMap[#][#].ensureResolved()', [subclass, subclass]);
251 }; 251 };
252 js.Expression interceptorsByTagAccess = 252 js.Expression interceptorsByTagAccess =
253 generateEmbeddedGlobalAccess(INTERCEPTORS_BY_TAG); 253 generateEmbeddedGlobalAccess(INTERCEPTORS_BY_TAG);
254 js.Expression leafTagsAccess = 254 js.Expression leafTagsAccess =
255 generateEmbeddedGlobalAccess(LEAF_TAGS); 255 generateEmbeddedGlobalAccess(LEAF_TAGS);
256 js.Statement nativeInfoHandler = nativeEmitter.buildNativeInfoHandler( 256 NativeGenerator generator = new NativeGenerator();
257 js.Statement nativeInfoHandler = generator.buildNativeInfoHandler(
257 nativeInfoAccess, 258 nativeInfoAccess,
258 constructorAccess, 259 constructorAccess,
259 subclassReadGenerator, 260 subclassReadGenerator,
260 interceptorsByTagAccess, 261 interceptorsByTagAccess,
261 leafTagsAccess); 262 leafTagsAccess);
262 263
263 nativeHoles['needsNativeSupport'] = program.needsNativeSupport; 264 nativeHoles['needsNativeSupport'] = program.needsNativeSupport;
264 nativeHoles['needsNoNativeSupport'] = !program.needsNativeSupport; 265 nativeHoles['needsNoNativeSupport'] = !program.needsNativeSupport;
265 nativeHoles['nativeInfoHandler'] = nativeInfoHandler; 266 nativeHoles['nativeInfoHandler'] = nativeInfoHandler;
266 267
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 " [name, class-code, holder-index], or " 585 " [name, class-code, holder-index], or "
585 " [name, class-code, native-info, holder-index]."; 586 " [name, class-code, native-info, holder-index].";
586 587
587 js.Expression emitLibrary(Library library) { 588 js.Expression emitLibrary(Library library) {
588 Iterable staticDescriptors = library.statics.expand(emitStaticMethod); 589 Iterable staticDescriptors = library.statics.expand(emitStaticMethod);
589 590
590 Iterable classDescriptors = library.classes.expand((Class cls) { 591 Iterable classDescriptors = library.classes.expand((Class cls) {
591 js.Literal name = js.quoteName(cls.name); 592 js.Literal name = js.quoteName(cls.name);
592 js.LiteralNumber holderIndex = js.number(cls.holder.index); 593 js.LiteralNumber holderIndex = js.number(cls.holder.index);
593 js.Expression emittedClass = emitClass(cls); 594 js.Expression emittedClass = emitClass(cls);
594 if (cls.nativeInfo == null) { 595 js.Expression nativeInfo = new NativeGenerator.encodeNativeInfo(cls);
596 if (nativeInfo == null) {
595 return [name, emittedClass, holderIndex]; 597 return [name, emittedClass, holderIndex];
596 } else { 598 } else {
597 return [name, emittedClass, cls.nativeInfo, holderIndex]; 599 return [name, emittedClass, nativeInfo, holderIndex];
598 } 600 }
599 }); 601 });
600 602
601 js.Expression staticArray = 603 js.Expression staticArray =
602 new js.ArrayInitializer(staticDescriptors.toList(growable: false)); 604 new js.ArrayInitializer(staticDescriptors.toList(growable: false));
603 js.Expression classArray = 605 js.Expression classArray =
604 new js.ArrayInitializer(classDescriptors.toList(growable: false)); 606 new js.ArrayInitializer(classDescriptors.toList(growable: false));
605 607
606 return new js.ArrayInitializer([staticArray, classArray]); 608 return new js.ArrayInitializer([staticArray, classArray]);
607 } 609 }
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 1239
1238 var end = Date.now(); 1240 var end = Date.now();
1239 // print('Setup: ' + (end - start) + ' ms.'); 1241 // print('Setup: ' + (end - start) + ' ms.');
1240 1242
1241 #invokeMain; // Start main. 1243 #invokeMain; // Start main.
1242 1244
1243 })(Date.now(), #code) 1245 })(Date.now(), #code)
1244 }"""; 1246 }""";
1245 1247
1246 } 1248 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698