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

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

Issue 1491413008: Canonical output ordering for constants. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: baseline for fix Created 5 years 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
OLDNEW
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 library dart2js.js_emitter.startup_emitter.model_emitter; 5 library dart2js.js_emitter.startup_emitter.model_emitter;
6 6
7 import 'dart:convert' show JsonEncoder; 7 import 'dart:convert' show JsonEncoder;
8 8
9 import 'package:js_runtime/shared/embedded_names.dart' show 9 import 'package:js_runtime/shared/embedded_names.dart' show
10 CLASS_FIELDS_EXTRACTOR, 10 CLASS_FIELDS_EXTRACTOR,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 import '../../io/source_map_builder.dart' show 49 import '../../io/source_map_builder.dart' show
50 SourceMapBuilder; 50 SourceMapBuilder;
51 import '../../js/js.dart' as js; 51 import '../../js/js.dart' as js;
52 import '../../js_backend/js_backend.dart' show 52 import '../../js_backend/js_backend.dart' show
53 JavaScriptBackend, 53 JavaScriptBackend,
54 Namer, 54 Namer,
55 ConstantEmitter; 55 ConstantEmitter;
56 import '../../util/uri_extras.dart' show 56 import '../../util/uri_extras.dart' show
57 relativize; 57 relativize;
58 58
59 import '../constant_ordering.dart' show deepCompareConstants;
59 import '../headers.dart'; 60 import '../headers.dart';
60 import '../js_emitter.dart' show 61 import '../js_emitter.dart' show
61 NativeEmitter; 62 NativeEmitter;
62 63
63 import '../js_emitter.dart' show 64 import '../js_emitter.dart' show
64 buildTearOffCode, 65 buildTearOffCode,
65 NativeGenerator; 66 NativeGenerator;
66 import '../model.dart'; 67 import '../model.dart';
67 68
68 part 'deferred_fragment_hash.dart'; 69 part 'deferred_fragment_hash.dart';
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 // Emit constant interceptors first. Constant interceptors for primitives 134 // Emit constant interceptors first. Constant interceptors for primitives
134 // might be used by code that builds other constants. See Issue 18173. 135 // might be used by code that builds other constants. See Issue 18173.
135 if (a.isInterceptor != b.isInterceptor) { 136 if (a.isInterceptor != b.isInterceptor) {
136 return a.isInterceptor ? -1 : 1; 137 return a.isInterceptor ? -1 : 1;
137 } 138 }
138 139
139 // Sorting by the long name clusters constants with the same constructor 140 // Sorting by the long name clusters constants with the same constructor
140 // which compresses a tiny bit better. 141 // which compresses a tiny bit better.
141 int r = namer.constantLongName(a).compareTo(namer.constantLongName(b)); 142 int r = namer.constantLongName(a).compareTo(namer.constantLongName(b));
142 if (r != 0) return r; 143 if (r != 0) return r;
143 // Resolve collisions in the long name by using the constant name (i.e. JS 144
144 // name) which is unique. 145 // Resolve collisions in the long name by using a structural order.
145 return namer.constantName(a).compareTo(namer.constantName(b)); 146 return deepCompareConstants(a, b);
146 } 147 }
147 148
148 js.Expression generateStaticClosureAccess(FunctionElement element) { 149 js.Expression generateStaticClosureAccess(FunctionElement element) {
149 return js.js('#.#()', 150 return js.js('#.#()',
150 [namer.globalObjectFor(element), namer.staticClosureName(element)]); 151 [namer.globalObjectFor(element), namer.staticClosureName(element)]);
151 } 152 }
152 153
153 js.Expression generateConstantReference(ConstantValue value) { 154 js.Expression generateConstantReference(ConstantValue value) {
154 if (value.isFunction) { 155 if (value.isFunction) {
155 FunctionConstantValue functionConstant = value; 156 FunctionConstantValue functionConstant = value;
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 // Json does not support comments, so we embed the explanation in the 415 // Json does not support comments, so we embed the explanation in the
415 // data. 416 // data.
416 mapping["_comment"] = "This mapping shows which compiled `.js` files are " 417 mapping["_comment"] = "This mapping shows which compiled `.js` files are "
417 "needed for a given deferred library import."; 418 "needed for a given deferred library import.";
418 mapping.addAll(compiler.deferredLoadTask.computeDeferredMap()); 419 mapping.addAll(compiler.deferredLoadTask.computeDeferredMap());
419 compiler.outputProvider(compiler.deferredMapUri.path, 'deferred_map') 420 compiler.outputProvider(compiler.deferredMapUri.path, 'deferred_map')
420 ..add(const JsonEncoder.withIndent(" ").convert(mapping)) 421 ..add(const JsonEncoder.withIndent(" ").convert(mapping))
421 ..close(); 422 ..close();
422 } 423 }
423 } 424 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/lazy_emitter/model_emitter.dart ('k') | tests/compiler/dart2js_extra/many_constants_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698