| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.startup_emitter.model_emitter; | 5 part of dart2js.js_emitter.startup_emitter.model_emitter; |
| 6 | 6 |
| 7 /// The name of the property that stores the tear-off getter on a static | 7 /// The name of the property that stores the tear-off getter on a static |
| 8 /// function. | 8 /// function. |
| 9 /// | 9 /// |
| 10 /// This property is only used when isolates are used. | 10 /// This property is only used when isolates are used. |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 | 355 |
| 356 /// An expression that returns `true` if `__proto__` can be assigned to stitch | 356 /// An expression that returns `true` if `__proto__` can be assigned to stitch |
| 357 /// together a prototype chain, and the performance is good. | 357 /// together a prototype chain, and the performance is good. |
| 358 const String directAccessTestExpression = r''' | 358 const String directAccessTestExpression = r''' |
| 359 (function () { | 359 (function () { |
| 360 var cls = function () {}; | 360 var cls = function () {}; |
| 361 cls.prototype = {'p': {}}; | 361 cls.prototype = {'p': {}}; |
| 362 var object = new cls(); | 362 var object = new cls(); |
| 363 if (!(object.__proto__ && object.__proto__.p === cls.prototype.p)) | 363 if (!(object.__proto__ && object.__proto__.p === cls.prototype.p)) |
| 364 return false; | 364 return false; |
| 365 | 365 |
| 366 try { | 366 try { |
| 367 // Are we running on a platform where the performance is good? | 367 // Are we running on a platform where the performance is good? |
| 368 // (i.e. Chrome or d8). | 368 // (i.e. Chrome or d8). |
| 369 | 369 |
| 370 // Chrome userAgent? | 370 // Chrome userAgent? |
| 371 if (typeof navigator != "undefined" && | 371 if (typeof navigator != "undefined" && |
| 372 typeof navigator.userAgent == "string" && | 372 typeof navigator.userAgent == "string" && |
| 373 navigator.userAgent.indexOf("Chrome/") >= 0) return true; | 373 navigator.userAgent.indexOf("Chrome/") >= 0) return true; |
| 374 // d8 version() looks like "N.N.N.N", jsshell version() like "N". | 374 // d8 version() looks like "N.N.N.N", jsshell version() like "N". |
| 375 if (typeof version == "function" && | 375 if (typeof version == "function" && |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 Map<DeferredFragment, _DeferredFragmentHash> deferredLoadHashes) { | 461 Map<DeferredFragment, _DeferredFragmentHash> deferredLoadHashes) { |
| 462 MainFragment fragment = program.fragments.first; | 462 MainFragment fragment = program.fragments.first; |
| 463 | 463 |
| 464 Iterable<Holder> nonStaticStateHolders = | 464 Iterable<Holder> nonStaticStateHolders = |
| 465 program.holders.where((Holder holder) => !holder.isStaticStateHolder); | 465 program.holders.where((Holder holder) => !holder.isStaticStateHolder); |
| 466 | 466 |
| 467 return js.js.statement(mainBoilerplate, { | 467 return js.js.statement(mainBoilerplate, { |
| 468 'directAccessTestExpression': js.js(directAccessTestExpression), | 468 'directAccessTestExpression': js.js(directAccessTestExpression), |
| 469 'typeNameProperty': js.string(ModelEmitter.typeNameProperty), | 469 'typeNameProperty': js.string(ModelEmitter.typeNameProperty), |
| 470 'cyclicThrow': backend.emitter | 470 'cyclicThrow': backend.emitter |
| 471 .staticFunctionAccess(backend.helpers.cyclicThrowHelper), | 471 .staticFunctionAccess(compiler.commonElements.cyclicThrowHelper), |
| 472 'operatorIsPrefix': js.string(namer.operatorIsPrefix), | 472 'operatorIsPrefix': js.string(namer.operatorIsPrefix), |
| 473 'tearOffCode': new js.Block(buildTearOffCode(backend)), | 473 'tearOffCode': new js.Block(buildTearOffCode(backend)), |
| 474 'embeddedTypes': generateEmbeddedGlobalAccess(TYPES), | 474 'embeddedTypes': generateEmbeddedGlobalAccess(TYPES), |
| 475 'embeddedInterceptorTags': | 475 'embeddedInterceptorTags': |
| 476 generateEmbeddedGlobalAccess(INTERCEPTORS_BY_TAG), | 476 generateEmbeddedGlobalAccess(INTERCEPTORS_BY_TAG), |
| 477 'embeddedLeafTags': generateEmbeddedGlobalAccess(LEAF_TAGS), | 477 'embeddedLeafTags': generateEmbeddedGlobalAccess(LEAF_TAGS), |
| 478 'embeddedGlobalsObject': js.js("init"), | 478 'embeddedGlobalsObject': js.js("init"), |
| 479 'holdersList': new js.ArrayInitializer(nonStaticStateHolders | 479 'holdersList': new js.ArrayInitializer(nonStaticStateHolders |
| 480 .map((holder) => js.js("#", holder.name)) | 480 .map((holder) => js.js("#", holder.name)) |
| 481 .toList(growable: false)), | 481 .toList(growable: false)), |
| (...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1392 } | 1392 } |
| 1393 statements.add(js.js.statement("setOrUpdateInterceptorsByTag(#);", | 1393 statements.add(js.js.statement("setOrUpdateInterceptorsByTag(#);", |
| 1394 js.objectLiteral(interceptorsByTag))); | 1394 js.objectLiteral(interceptorsByTag))); |
| 1395 statements.add( | 1395 statements.add( |
| 1396 js.js.statement("setOrUpdateLeafTags(#);", js.objectLiteral(leafTags))); | 1396 js.js.statement("setOrUpdateLeafTags(#);", js.objectLiteral(leafTags))); |
| 1397 statements.addAll(subclassAssignments); | 1397 statements.addAll(subclassAssignments); |
| 1398 | 1398 |
| 1399 return wrapPhase('nativeSupport', new js.Block(statements)); | 1399 return wrapPhase('nativeSupport', new js.Block(statements)); |
| 1400 } | 1400 } |
| 1401 } | 1401 } |
| OLD | NEW |