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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart

Issue 744823004: Revert "Encode super calls via extra properties on prototypes." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: keep desirable changes Created 6 years, 1 month 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
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 part of dart2js.js_emitter; 5 part of dart2js.js_emitter;
6 6
7 7
8 class OldEmitter implements Emitter { 8 class OldEmitter implements Emitter {
9 final Compiler compiler; 9 final Compiler compiler;
10 final CodeEmitterTask task; 10 final CodeEmitterTask task;
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 # = Object.create(null); // embedded interceptorsByTag. 351 # = Object.create(null); // embedded interceptorsByTag.
352 # = Object.create(null); // embedded leafTags. 352 # = Object.create(null); // embedded leafTags.
353 # = Object.create(null); // embedded finishedClasses 353 # = Object.create(null); // embedded finishedClasses
354 })() 354 })()
355 ''', [allClassesAccess, 355 ''', [allClassesAccess,
356 interceptorsByTagAccess, 356 interceptorsByTagAccess,
357 leafTagsAccess, 357 leafTagsAccess,
358 finishedClassesAccess]); 358 finishedClassesAccess]);
359 } 359 }
360 360
361 List buildSplitOffAliases() {
362 if (backend.aliasedSuperMembers.isEmpty) return [];
363 return [js(r'''
364 var splitOffAliases = function(constructor) {
365 var hasOwnProperty = Object.prototype.hasOwnProperty;
366 var properties = constructor.prototype;
367 for (var member in properties) {
368 if (hasOwnProperty.call(properties, member)) {
369 var s = member.split(':');
370 if (s.length > 1) {
371 properties[s[0]] = properties[s[1]] = properties[member];
372 delete properties[member];
373 }
374 }
375 }
376 }
377 ''')];
378 }
379
380 jsAst.Fun get finishClassesFunction { 361 jsAst.Fun get finishClassesFunction {
381 // Class descriptions are collected in a JS object. 362 // Class descriptions are collected in a JS object.
382 // 'finishClasses' takes all collected descriptions and sets up 363 // 'finishClasses' takes all collected descriptions and sets up
383 // the prototype. 364 // the prototype.
384 // Once set up, the constructors prototype field satisfy: 365 // Once set up, the constructors prototype field satisfy:
385 // - it contains all (local) members. 366 // - it contains all (local) members.
386 // - its internal prototype (__proto__) points to the superclass' 367 // - its internal prototype (__proto__) points to the superclass'
387 // prototype field. 368 // prototype field.
388 // - the prototype's constructor field points to the JavaScript 369 // - the prototype's constructor field points to the JavaScript
389 // constructor. 370 // constructor.
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 return js.statement(''' 507 return js.statement('''
527 { 508 {
528 var finishedClasses = #; // finishedClassesAccess. 509 var finishedClasses = #; // finishedClassesAccess.
529 510
530 function finishClass(cls) { 511 function finishClass(cls) {
531 512
532 if (finishedClasses[cls]) return; 513 if (finishedClasses[cls]) return;
533 finishedClasses[cls] = true; 514 finishedClasses[cls] = true;
534 515
535 var superclass = pendingClasses[cls]; 516 var superclass = pendingClasses[cls];
536 var constructor = allClasses[cls];
537
538 // Process aliased members due to super calls. We have to do this early
539 // to ensure that we also hit the object class.
540 if (#) splitOffAliases(constructor);
541 517
542 // The superclass is only false (empty string) for the Dart Object 518 // The superclass is only false (empty string) for the Dart Object
543 // class. The minifier together with noSuchMethod can put methods on 519 // class. The minifier together with noSuchMethod can put methods on
544 // the Object.prototype object, and they show through here, so we check 520 // the Object.prototype object, and they show through here, so we check
545 // that we have a string. 521 // that we have a string.
546 if (!superclass || typeof superclass != "string") return; 522 if (!superclass || typeof superclass != "string") return;
547 finishClass(superclass); 523 finishClass(superclass);
524 var constructor = allClasses[cls];
548 var superConstructor = allClasses[superclass]; 525 var superConstructor = allClasses[superclass];
549 526
550 if (!superConstructor) 527 if (!superConstructor)
551 superConstructor = existingIsolateProperties[superclass]; 528 superConstructor = existingIsolateProperties[superclass];
552 529
553 var prototype = inheritFrom(constructor, superConstructor); 530 var prototype = inheritFrom(constructor, superConstructor);
554 531
555 if (#) { // !nativeClasses.isEmpty, 532 if (#) { // !nativeClasses.isEmpty,
556 // The property looks like this: 533 // The property looks like this:
557 // 534 //
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 for (i = 0; i < tags.length; i++) { 573 for (i = 0; i < tags.length; i++) {
597 #[tags[i]] = constructor; // embedded interceptorsByTag. 574 #[tags[i]] = constructor; // embedded interceptorsByTag.
598 #[tags[i]] = false; // embedded leafTags. 575 #[tags[i]] = false; // embedded leafTags.
599 } 576 }
600 } 577 }
601 } 578 }
602 } 579 }
603 } 580 }
604 } 581 }
605 }''', [finishedClassesAccess, 582 }''', [finishedClassesAccess,
606 backend.aliasedSuperMembers.isNotEmpty,
607 !nativeClasses.isEmpty, 583 !nativeClasses.isEmpty,
608 interceptorsByTagAccess, 584 interceptorsByTagAccess,
609 leafTagsAccess, 585 leafTagsAccess,
610 true, 586 true,
611 interceptorsByTagAccess, 587 interceptorsByTagAccess,
612 leafTagsAccess]); 588 leafTagsAccess]);
613 } 589 }
614 590
615 jsAst.Fun get finishIsolateConstructorFunction { 591 jsAst.Fun get finishIsolateConstructorFunction {
616 // We replace the old Isolate function with a new one that initializes 592 // We replace the old Isolate function with a new one that initializes
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 } 684 }
709 ''', [laziesAccess, laziesAccess, 685 ''', [laziesAccess, laziesAccess,
710 laziesAccess, 686 laziesAccess,
711 cyclicThrow]); 687 cyclicThrow]);
712 } 688 }
713 689
714 List buildDefineClassAndFinishClassFunctionsIfNecessary() { 690 List buildDefineClassAndFinishClassFunctionsIfNecessary() {
715 if (!needsDefineClass) return []; 691 if (!needsDefineClass) return [];
716 return defineClassFunction 692 return defineClassFunction
717 ..add(buildInheritFrom()) 693 ..add(buildInheritFrom())
718 ..addAll(buildSplitOffAliases())
719 ..add(js('$finishClassesName = #', finishClassesFunction)) 694 ..add(js('$finishClassesName = #', finishClassesFunction))
720 ..add(initFinishClasses); 695 ..add(initFinishClasses);
721 } 696 }
722 697
723 List buildLazyInitializerFunctionIfNecessary() { 698 List buildLazyInitializerFunctionIfNecessary() {
724 if (!needsLazyInitializer) return []; 699 if (!needsLazyInitializer) return [];
725 700
726 return [js('# = #', [js(lazyInitializerName), lazyInitializerFunction])]; 701 return [js('# = #', [js(lazyInitializerName), lazyInitializerFunction])];
727 } 702 }
728 703
(...skipping 1275 matching lines...) Expand 10 before | Expand all | Expand 10 after
2004 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { 1979 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) {
2005 if (element.isInstanceMember) { 1980 if (element.isInstanceMember) {
2006 cachedClassBuilders.remove(element.enclosingClass); 1981 cachedClassBuilders.remove(element.enclosingClass);
2007 1982
2008 nativeEmitter.cachedBuilders.remove(element.enclosingClass); 1983 nativeEmitter.cachedBuilders.remove(element.enclosingClass);
2009 1984
2010 } 1985 }
2011 } 1986 }
2012 } 1987 }
2013 } 1988 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698