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

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

Issue 939753002: dart2js: only allocate one closure in 'setupClass' of the new emitter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update comment. Created 5 years, 10 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 | no next file » | 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 '../../dart_types.dart' show DartType; 8 import '../../dart_types.dart' show DartType;
9 import '../../elements/elements.dart' show ClassElement; 9 import '../../elements/elements.dart' show ClassElement;
10 import '../../js/js.dart' as js; 10 import '../../js/js.dart' as js;
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 // initialization failed. 834 // initialization failed.
835 holder[name] = null; 835 holder[name] = null;
836 } 836 }
837 holder[getterName] = function() { return this[name]; }; 837 holder[getterName] = function() { return this[name]; };
838 } 838 }
839 return result; 839 return result;
840 }; 840 };
841 } 841 }
842 842
843 function setupClass(name, holder, descriptor) { 843 function setupClass(name, holder, descriptor) {
844 var ensureResolved = function() { 844 var patch = function() {
845 var constructor = compileConstructor(name, descriptor); 845 var constructor = compileConstructor(name, descriptor);
846 holder[name] = constructor; 846 holder[name] = constructor;
847 constructor.ensureResolved = function() { return this; }; 847 constructor.ensureResolved = function() { return this; };
848 return constructor; 848 if (this === patch) return constructor; // Was used as "ensureResolved".
849 };
850
851 var patch = function() {
852 var constructor = ensureResolved();
853 var object = new constructor(); 849 var object = new constructor();
854 constructor.apply(object, arguments); 850 constructor.apply(object, arguments);
855 return object; 851 return object;
856 }; 852 };
857 853
858 // We store the ensureResolved function on the patch function to make it 854 // We store the patch function on itself to make it
859 // possible to resolve superclass references without constructing instances. 855 // possible to resolve superclass references without constructing instances.
860 patch.ensureResolved = ensureResolved; 856 patch.ensureResolved = patch;
861 holder[name] = patch; 857 holder[name] = patch;
862 } 858 }
863 859
864 #tearOff; 860 #tearOff;
865 861
866 #parseFunctionDescriptor; 862 #parseFunctionDescriptor;
867 863
868 function compileConstructor(name, descriptor) { 864 function compileConstructor(name, descriptor) {
869 descriptor = compile(name, descriptor); 865 descriptor = compile(name, descriptor);
870 var prototype = determinePrototype(descriptor); 866 var prototype = determinePrototype(descriptor);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 974
979 var end = Date.now(); 975 var end = Date.now();
980 // print('Setup: ' + (end - start) + ' ms.'); 976 // print('Setup: ' + (end - start) + ' ms.');
981 977
982 #invokeMain; // Start main. 978 #invokeMain; // Start main.
983 979
984 }(Date.now(), #code) 980 }(Date.now(), #code)
985 }"""; 981 }""";
986 982
987 } 983 }
OLDNEW
« 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