| 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; |
| 11 import 'package:js_runtime/shared/embedded_names.dart' show | 11 import 'package:js_runtime/shared/embedded_names.dart' show |
| 12 JsBuiltin, | 12 JsBuiltin, |
| 13 JsGetName; | 13 JsGetName; |
| 14 | 14 |
| 15 import '../headers.dart'; | 15 import '../headers.dart'; |
| 16 import '../js_emitter.dart' hide Emitter; | 16 import '../js_emitter.dart' hide Emitter; |
| 17 import '../js_emitter.dart' as js_emitter show Emitter; | 17 import '../js_emitter.dart' as js_emitter show Emitter; |
| 18 import '../model.dart'; | 18 import '../model.dart'; |
| 19 import '../program_builder/program_builder.dart'; | 19 import '../program_builder/program_builder.dart'; |
| 20 import '../constant_ordering.dart' show deepCompareConstants; |
| 20 | 21 |
| 21 import '../../common.dart'; | 22 import '../../common.dart'; |
| 22 import '../../common/names.dart' show | 23 import '../../common/names.dart' show |
| 23 Names; | 24 Names; |
| 24 import '../../compiler.dart' show | 25 import '../../compiler.dart' show |
| 25 Compiler; | 26 Compiler; |
| 26 import '../../constants/values.dart'; | 27 import '../../constants/values.dart'; |
| 27 import '../../core_types.dart' show | 28 import '../../core_types.dart' show |
| 28 CoreClasses; | 29 CoreClasses; |
| 29 import '../../dart_types.dart' show | 30 import '../../dart_types.dart' show |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 // Emit constant interceptors first. Constant interceptors for primitives | 246 // Emit constant interceptors first. Constant interceptors for primitives |
| 246 // might be used by code that builds other constants. See Issue 18173. | 247 // might be used by code that builds other constants. See Issue 18173. |
| 247 if (a.isInterceptor != b.isInterceptor) { | 248 if (a.isInterceptor != b.isInterceptor) { |
| 248 return a.isInterceptor ? -1 : 1; | 249 return a.isInterceptor ? -1 : 1; |
| 249 } | 250 } |
| 250 | 251 |
| 251 // Sorting by the long name clusters constants with the same constructor | 252 // Sorting by the long name clusters constants with the same constructor |
| 252 // which compresses a tiny bit better. | 253 // which compresses a tiny bit better. |
| 253 int r = namer.constantLongName(a).compareTo(namer.constantLongName(b)); | 254 int r = namer.constantLongName(a).compareTo(namer.constantLongName(b)); |
| 254 if (r != 0) return r; | 255 if (r != 0) return r; |
| 255 // Resolve collisions in the long name by using the constant name (i.e. JS | 256 |
| 256 // name) which is unique. | 257 // Resolve collisions in the long name by using a structural order. |
| 257 // TODO(herhut): Find a better way to resolve collisions. | 258 return deepCompareConstants(a, b); |
| 258 return namer.constantName(a).hashCode.compareTo( | |
| 259 namer.constantName(b).hashCode); | |
| 260 } | 259 } |
| 261 | 260 |
| 262 @override | 261 @override |
| 263 jsAst.Expression constantReference(ConstantValue value) { | 262 jsAst.Expression constantReference(ConstantValue value) { |
| 264 if (value.isFunction) { | 263 if (value.isFunction) { |
| 265 FunctionConstantValue functionConstant = value; | 264 FunctionConstantValue functionConstant = value; |
| 266 return isolateStaticClosureAccess(functionConstant.element); | 265 return isolateStaticClosureAccess(functionConstant.element); |
| 267 } | 266 } |
| 268 | 267 |
| 269 // We are only interested in the "isInlined" part, but it does not hurt to | 268 // We are only interested in the "isInlined" part, but it does not hurt to |
| (...skipping 1861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2131 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { | 2130 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { |
| 2132 if (element.isInstanceMember) { | 2131 if (element.isInstanceMember) { |
| 2133 cachedClassBuilders.remove(element.enclosingClass); | 2132 cachedClassBuilders.remove(element.enclosingClass); |
| 2134 | 2133 |
| 2135 nativeEmitter.cachedBuilders.remove(element.enclosingClass); | 2134 nativeEmitter.cachedBuilders.remove(element.enclosingClass); |
| 2136 | 2135 |
| 2137 } | 2136 } |
| 2138 } | 2137 } |
| 2139 } | 2138 } |
| 2140 } | 2139 } |
| OLD | NEW |