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

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

Issue 851473002: Use prototype inheritance to reduce number of is check properties. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Comments. Created 5 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_emitter/old_emitter/emitter.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) 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 '../../dart2jslib.dart' show Compiler; 7 import '../../dart2jslib.dart' show Compiler;
8 import '../../js/js.dart' as js; 8 import '../../js/js.dart' as js;
9 import '../../js_backend/js_backend.dart' show 9 import '../../js_backend/js_backend.dart' show
10 JavaScriptBackend, 10 JavaScriptBackend,
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 102
103 return js.js.statement( 103 return js.js.statement(
104 boilerplate, 104 boilerplate,
105 {'deferredInitializer': emitDeferredInitializerGlobal(program.loadMap), 105 {'deferredInitializer': emitDeferredInitializerGlobal(program.loadMap),
106 'holders': emitHolders(fragment.holders), 106 'holders': emitHolders(fragment.holders),
107 'cyclicThrow': 107 'cyclicThrow':
108 backend.emitter.staticFunctionAccess(backend.getCyclicThrowHelper()), 108 backend.emitter.staticFunctionAccess(backend.getCyclicThrowHelper()),
109 'outputContainsConstantList': program.outputContainsConstantList, 109 'outputContainsConstantList': program.outputContainsConstantList,
110 'embeddedGlobals': emitEmbeddedGlobals(program.loadMap), 110 'embeddedGlobals': emitEmbeddedGlobals(program.loadMap),
111 'constants': emitConstants(fragment.constants), 111 'constants': emitConstants(fragment.constants),
112 'staticNonFinals': emitStaticNonFinalFields(fragment.staticNonFinalFiel ds), 112 'staticNonFinals':
113 emitStaticNonFinalFields(fragment.staticNonFinalFields),
113 'nativeBoilerplate': nativeBoilerplate, 114 'nativeBoilerplate': nativeBoilerplate,
115 'operatorIsPrefix': js.string(namer.operatorIsPrefix),
114 'eagerClasses': emitEagerClassInitializations(fragment.libraries), 116 'eagerClasses': emitEagerClassInitializations(fragment.libraries),
115 'main': fragment.main, 117 'main': fragment.main,
116 'code': code}); 118 'code': code});
117 } 119 }
118 120
119 js.Block emitHolders(List<Holder> holders) { 121 js.Block emitHolders(List<Holder> holders) {
120 // The top-level variables for holders must *not* be renamed by the 122 // The top-level variables for holders must *not* be renamed by the
121 // JavaScript pretty printer because a lot of code already uses the 123 // JavaScript pretty printer because a lot of code already uses the
122 // non-renamed names. The generated code looks like this: 124 // non-renamed names. The generated code looks like this:
123 // 125 //
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 prototype[descriptor[i]] = descriptor[i + 1]; 486 prototype[descriptor[i]] = descriptor[i + 1];
485 } 487 }
486 } else { 488 } else {
487 constructor = descriptor[2]; 489 constructor = descriptor[2];
488 for (var i = 3; i < descriptor.length; i += 2) { 490 for (var i = 3; i < descriptor.length; i += 2) {
489 prototype[descriptor[i]] = descriptor[i + 1]; 491 prototype[descriptor[i]] = descriptor[i + 1];
490 } 492 }
491 } 493 }
492 constructor.builtin\$cls = name; // Needed for RTI. 494 constructor.builtin\$cls = name; // Needed for RTI.
493 constructor.prototype = prototype; 495 constructor.prototype = prototype;
496 prototype[#operatorIsPrefix + name] = constructor;
494 prototype.constructor = constructor; 497 prototype.constructor = constructor;
495 return constructor; 498 return constructor;
496 } 499 }
497 500
498 function compileMixinConstructor(name, prototype, descriptor) { 501 function compileMixinConstructor(name, prototype, descriptor) {
499 // $mixinFormatDescription. 502 // $mixinFormatDescription.
500 var mixinName = descriptor[2]; 503 var mixinName = descriptor[2];
501 var mixinHolderIndex = descriptor[3]; 504 var mixinHolderIndex = descriptor[3];
502 var mixin = holders[mixinHolderIndex][mixinName].ensureResolved(); 505 var mixin = holders[mixinHolderIndex][mixinName].ensureResolved();
503 var mixinPrototype = mixin.prototype; 506 var mixinPrototype = mixin.prototype;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 568
566 var end = Date.now(); 569 var end = Date.now();
567 print('Setup: ' + (end - start) + ' ms.'); 570 print('Setup: ' + (end - start) + ' ms.');
568 571
569 #main(); // Start main. 572 #main(); // Start main.
570 573
571 }(Date.now(), #code) 574 }(Date.now(), #code)
572 }"""; 575 }""";
573 576
574 } 577 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698