OLD | NEW |
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.js_emitter.full_emitter; | 5 library dart2js.js_emitter.full_emitter; |
6 | 6 |
7 import 'dart:convert'; | 7 import 'dart:convert'; |
8 import 'dart:collection' show HashMap; | 8 import 'dart:collection' show HashMap; |
9 | 9 |
10 import 'package:js_runtime/shared/embedded_names.dart' as embeddedNames; | 10 import 'package:js_runtime/shared/embedded_names.dart' as embeddedNames; |
(...skipping 1420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1431 #helper.schemaChange = #schemaChange; | 1431 #helper.schemaChange = #schemaChange; |
1432 #helper.addMethod = #addMethod; | 1432 #helper.addMethod = #addMethod; |
1433 #helper.extractStubs = | 1433 #helper.extractStubs = |
1434 function(array, name, isStatic, originalDescriptor) { | 1434 function(array, name, isStatic, originalDescriptor) { |
1435 var descriptor = Object.create(null); | 1435 var descriptor = Object.create(null); |
1436 this.addStubs(descriptor, array, name, isStatic, []); | 1436 this.addStubs(descriptor, array, name, isStatic, []); |
1437 return descriptor; | 1437 return descriptor; |
1438 }; | 1438 }; |
1439 } | 1439 } |
1440 | 1440 |
| 1441 if (#hasInstrumentation) { |
| 1442 var __record_buffer = []; // TODO(sigmund): define as a proper global. |
| 1443 function __record_use(id, name) { |
| 1444 if (__record_buffer.length == 0) { |
| 1445 window.setTimeout(function () { |
| 1446 var xhr = new XMLHttpRequest(); |
| 1447 xhr.open("POST", "/coverage_uri_to_amend_by_server"); |
| 1448 xhr.send(JSON.stringify(__record_buffer)); |
| 1449 __record_buffer = []; |
| 1450 }, 1000); |
| 1451 } |
| 1452 __record_buffer.push([id, name]); |
| 1453 } |
| 1454 } |
| 1455 |
1441 if (#isProgramSplit) { | 1456 if (#isProgramSplit) { |
1442 /// We collect all the global state, so it can be passed to the | 1457 /// We collect all the global state, so it can be passed to the |
1443 /// initializer of deferred files. | 1458 /// initializer of deferred files. |
1444 var #globalsHolder = Object.create(null) | 1459 var #globalsHolder = Object.create(null) |
1445 } | 1460 } |
1446 | 1461 |
1447 // [map] returns an object that V8 shouldn't try to optimize with a | 1462 // [map] returns an object that V8 shouldn't try to optimize with a |
1448 // hidden class. This prevents a potential performance problem where V8 | 1463 // hidden class. This prevents a potential performance problem where V8 |
1449 // tries to build a hidden class for an object used as a hashMap. | 1464 // tries to build a hidden class for an object used as a hashMap. |
1450 // It requires fewer characters to declare a variable as a parameter than | 1465 // It requires fewer characters to declare a variable as a parameter than |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1523 #convertGlobalObjectsToFastObjects; | 1538 #convertGlobalObjectsToFastObjects; |
1524 #debugFastObjects; | 1539 #debugFastObjects; |
1525 | 1540 |
1526 #init; | 1541 #init; |
1527 | 1542 |
1528 #main; | 1543 #main; |
1529 })(); | 1544 })(); |
1530 """, { | 1545 """, { |
1531 "disableVariableRenaming": js.comment("/* ::norenaming:: */"), | 1546 "disableVariableRenaming": js.comment("/* ::norenaming:: */"), |
1532 "hasIncrementalSupport": compiler.hasIncrementalSupport, | 1547 "hasIncrementalSupport": compiler.hasIncrementalSupport, |
| 1548 // TODO(sigmund): add flag |
| 1549 "hasInstrumentation": const bool.fromEnvironment('instrumentForCoverage') |
| 1550 && compiler.dumpInfo, |
1533 "helper": js('this.#', [namer.incrementalHelperName]), | 1551 "helper": js('this.#', [namer.incrementalHelperName]), |
1534 "schemaChange": buildSchemaChangeFunction(), | 1552 "schemaChange": buildSchemaChangeFunction(), |
1535 "addMethod": buildIncrementalAddMethod(), | 1553 "addMethod": buildIncrementalAddMethod(), |
1536 "isProgramSplit": isProgramSplit, | 1554 "isProgramSplit": isProgramSplit, |
1537 "supportsDirectProtoAccess": buildSupportsDirectProtoAccess(), | 1555 "supportsDirectProtoAccess": buildSupportsDirectProtoAccess(), |
1538 "globalsHolder": globalsHolder, | 1556 "globalsHolder": globalsHolder, |
1539 "globalObjectSetup": buildGlobalObjectSetup(isProgramSplit), | 1557 "globalObjectSetup": buildGlobalObjectSetup(isProgramSplit), |
1540 "isolateName": namer.isolateName, | 1558 "isolateName": namer.isolateName, |
1541 "isolatePropertiesName": js(isolatePropertiesName), | 1559 "isolatePropertiesName": js(isolatePropertiesName), |
1542 "initName": initName, | 1560 "initName": initName, |
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2117 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { | 2135 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { |
2118 if (element.isInstanceMember) { | 2136 if (element.isInstanceMember) { |
2119 cachedClassBuilders.remove(element.enclosingClass); | 2137 cachedClassBuilders.remove(element.enclosingClass); |
2120 | 2138 |
2121 nativeEmitter.cachedBuilders.remove(element.enclosingClass); | 2139 nativeEmitter.cachedBuilders.remove(element.enclosingClass); |
2122 | 2140 |
2123 } | 2141 } |
2124 } | 2142 } |
2125 } | 2143 } |
2126 } | 2144 } |
OLD | NEW |