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

Side by Side Diff: pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart

Issue 2569733002: Even less reliance on Compiler.closedWorld (Closed)
Patch Set: Updated cf. comments. Created 4 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 import 'package:js_runtime/shared/embedded_names.dart'; 5 import 'package:js_runtime/shared/embedded_names.dart';
6 import 'package:kernel/ast.dart' as ir; 6 import 'package:kernel/ast.dart' as ir;
7 7
8 import '../constants/expressions.dart'; 8 import '../constants/expressions.dart';
9 import '../common.dart'; 9 import '../common.dart';
10 import '../common/names.dart'; 10 import '../common/names.dart';
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 } 62 }
63 _typeConverter = new DartTypeConverter(this); 63 _typeConverter = new DartTypeConverter(this);
64 } 64 }
65 65
66 Compiler get _compiler => _backend.compiler; 66 Compiler get _compiler => _backend.compiler;
67 TreeElements get elements => _resolvedAst.elements; 67 TreeElements get elements => _resolvedAst.elements;
68 DiagnosticReporter get reporter => _compiler.reporter; 68 DiagnosticReporter get reporter => _compiler.reporter;
69 Element get _target => _resolvedAst.element; 69 Element get _target => _resolvedAst.element;
70 ClosedWorld get _closedWorld => _compiler.closedWorld; 70 ClosedWorld get _closedWorld => _compiler.closedWorld;
71 71
72 GlobalTypeInferenceResults get _globalInferenceResults =>
73 _compiler.globalInference.results;
74
72 GlobalTypeInferenceElementResult _resultOf(Element e) => 75 GlobalTypeInferenceElementResult _resultOf(Element e) =>
73 _compiler.globalInference.results.resultOf(e); 76 _globalInferenceResults.resultOf(e);
74 77
75 ConstantValue getConstantForSymbol(ir.SymbolLiteral node) { 78 ConstantValue getConstantForSymbol(ir.SymbolLiteral node) {
76 if (kernel.syntheticNodes.contains(node)) { 79 if (kernel.syntheticNodes.contains(node)) {
77 return _backend.constantSystem.createSymbol(_compiler, node.value); 80 return _backend.constantSystem.createSymbol(_compiler, node.value);
78 } 81 }
79 ast.Node astNode = getNode(node); 82 ast.Node astNode = getNode(node);
80 ConstantValue constantValue = _backend.constants 83 ConstantValue constantValue = _backend.constants
81 .getConstantValueForNode(astNode, _resolvedAst.elements); 84 .getConstantValueForNode(astNode, _resolvedAst.elements);
82 assert(invariant(astNode, constantValue != null, 85 assert(invariant(astNode, constantValue != null,
83 message: 'No constant computed for $node')); 86 message: 'No constant computed for $node'));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 return getElement(variable) as LocalElement; 129 return getElement(variable) as LocalElement;
127 } 130 }
128 131
129 bool getCanThrow(ir.Node procedure) { 132 bool getCanThrow(ir.Node procedure) {
130 FunctionElement function = getElement(procedure); 133 FunctionElement function = getElement(procedure);
131 return !_closedWorld.getCannotThrow(function); 134 return !_closedWorld.getCannotThrow(function);
132 } 135 }
133 136
134 TypeMask returnTypeOf(ir.Member node) { 137 TypeMask returnTypeOf(ir.Member node) {
135 return TypeMaskFactory.inferredReturnTypeForElement( 138 return TypeMaskFactory.inferredReturnTypeForElement(
136 getElement(node), _compiler); 139 getElement(node), _globalInferenceResults);
137 } 140 }
138 141
139 SideEffects getSideEffects(ir.Node node) { 142 SideEffects getSideEffects(ir.Node node) {
140 return _closedWorld.getSideEffectsOfElement(getElement(node)); 143 return _closedWorld.getSideEffectsOfElement(getElement(node));
141 } 144 }
142 145
143 CallStructure getCallStructure(ir.Arguments arguments) { 146 CallStructure getCallStructure(ir.Arguments arguments) {
144 int argumentCount = arguments.positional.length + arguments.named.length; 147 int argumentCount = arguments.positional.length + arguments.named.length;
145 List<String> namedArguments = arguments.named.map((e) => e.name).toList(); 148 List<String> namedArguments = arguments.named.map((e) => e.name).toList();
146 return new CallStructure(argumentCount, namedArguments); 149 return new CallStructure(argumentCount, namedArguments);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 if (mask.isContainer && (mask as ContainerTypeMask).length != null) { 261 if (mask.isContainer && (mask as ContainerTypeMask).length != null) {
259 // A container on which we have inferred the length. 262 // A container on which we have inferred the length.
260 return true; 263 return true;
261 } 264 }
262 // TODO(sra): Recognize any combination of fixed length indexables. 265 // TODO(sra): Recognize any combination of fixed length indexables.
263 if (mask.containsOnly( 266 if (mask.containsOnly(
264 _closedWorld.backendClasses.fixedListImplementation) || 267 _closedWorld.backendClasses.fixedListImplementation) ||
265 mask.containsOnly( 268 mask.containsOnly(
266 _closedWorld.backendClasses.constListImplementation) || 269 _closedWorld.backendClasses.constListImplementation) ||
267 mask.containsOnlyString(_closedWorld) || 270 mask.containsOnlyString(_closedWorld) ||
268 backend.isTypedArray(mask)) { 271 _closedWorld.commonMasks.isTypedArray(mask)) {
269 return true; 272 return true;
270 } 273 }
271 return false; 274 return false;
272 } 275 }
273 276
274 TypeMask inferredIndexType(ir.ForInStatement forInStatement) { 277 TypeMask inferredIndexType(ir.ForInStatement forInStatement) {
275 return TypeMaskFactory.inferredTypeForSelector( 278 return TypeMaskFactory.inferredTypeForSelector(new Selector.index(),
276 new Selector.index(), typeOfIterator(forInStatement), _compiler); 279 typeOfIterator(forInStatement), _globalInferenceResults);
277 } 280 }
278 281
279 TypeMask inferredTypeOf(ir.Member node) { 282 TypeMask inferredTypeOf(ir.Member node) {
280 return TypeMaskFactory.inferredTypeForElement(getElement(node), _compiler); 283 return TypeMaskFactory.inferredTypeForElement(
284 getElement(node), _globalInferenceResults);
281 } 285 }
282 286
283 TypeMask selectorTypeOf(Selector selector, TypeMask mask) { 287 TypeMask selectorTypeOf(Selector selector, TypeMask mask) {
284 return TypeMaskFactory.inferredTypeForSelector(selector, mask, _compiler); 288 return TypeMaskFactory.inferredTypeForSelector(
289 selector, mask, _globalInferenceResults);
285 } 290 }
286 291
287 TypeMask typeFromNativeBehavior(native.NativeBehavior nativeBehavior) { 292 TypeMask typeFromNativeBehavior(native.NativeBehavior nativeBehavior) {
288 return TypeMaskFactory.fromNativeBehavior(nativeBehavior, _compiler); 293 return TypeMaskFactory.fromNativeBehavior(nativeBehavior, _closedWorld);
289 } 294 }
290 295
291 ConstantValue getConstantFor(ir.Node node) { 296 ConstantValue getConstantFor(ir.Node node) {
292 ConstantValue constantValue = 297 ConstantValue constantValue =
293 _backend.constants.getConstantValueForNode(getNode(node), elements); 298 _backend.constants.getConstantValueForNode(getNode(node), elements);
294 assert(invariant(getNode(node), constantValue != null, 299 assert(invariant(getNode(node), constantValue != null,
295 message: 'No constant computed for $node')); 300 message: 'No constant computed for $node'));
296 return constantValue; 301 return constantValue;
297 } 302 }
298 303
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 ir.Procedure get mapLiteralUntypedMaker => 357 ir.Procedure get mapLiteralUntypedMaker =>
353 kernel.functions[_backend.helpers.mapLiteralUntypedMaker]; 358 kernel.functions[_backend.helpers.mapLiteralUntypedMaker];
354 359
355 MemberElement get jsIndexableLength => _backend.helpers.jsIndexableLength; 360 MemberElement get jsIndexableLength => _backend.helpers.jsIndexableLength;
356 361
357 ir.Procedure get checkConcurrentModificationError => 362 ir.Procedure get checkConcurrentModificationError =>
358 kernel.functions[_backend.helpers.checkConcurrentModificationError]; 363 kernel.functions[_backend.helpers.checkConcurrentModificationError];
359 364
360 TypeMask get checkConcurrentModificationErrorReturnType => 365 TypeMask get checkConcurrentModificationErrorReturnType =>
361 TypeMaskFactory.inferredReturnTypeForElement( 366 TypeMaskFactory.inferredReturnTypeForElement(
362 _backend.helpers.checkConcurrentModificationError, _compiler); 367 _backend.helpers.checkConcurrentModificationError,
368 _globalInferenceResults);
363 369
364 ir.Procedure get checkSubtype => 370 ir.Procedure get checkSubtype =>
365 kernel.functions[_backend.helpers.checkSubtype]; 371 kernel.functions[_backend.helpers.checkSubtype];
366 372
367 ir.Procedure get checkSubtypeOfRuntimeType => 373 ir.Procedure get checkSubtypeOfRuntimeType =>
368 kernel.functions[_backend.helpers.checkSubtypeOfRuntimeType]; 374 kernel.functions[_backend.helpers.checkSubtypeOfRuntimeType];
369 375
370 ir.Procedure get assertHelper => 376 ir.Procedure get assertHelper =>
371 kernel.functions[_backend.helpers.assertHelper]; 377 kernel.functions[_backend.helpers.assertHelper];
372 378
373 TypeMask get throwTypeErrorType => TypeMaskFactory 379 TypeMask get throwTypeErrorType =>
374 .inferredReturnTypeForElement(_backend.helpers.throwTypeError, _compiler); 380 TypeMaskFactory.inferredReturnTypeForElement(
381 _backend.helpers.throwTypeError, _globalInferenceResults);
375 382
376 TypeMask get assertHelperReturnType => TypeMaskFactory 383 TypeMask get assertHelperReturnType =>
377 .inferredReturnTypeForElement(_backend.helpers.assertHelper, _compiler); 384 TypeMaskFactory.inferredReturnTypeForElement(
385 _backend.helpers.assertHelper, _globalInferenceResults);
378 386
379 ir.Procedure get assertTest => kernel.functions[_backend.helpers.assertTest]; 387 ir.Procedure get assertTest => kernel.functions[_backend.helpers.assertTest];
380 388
381 TypeMask get assertTestReturnType => TypeMaskFactory 389 TypeMask get assertTestReturnType =>
382 .inferredReturnTypeForElement(_backend.helpers.assertTest, _compiler); 390 TypeMaskFactory.inferredReturnTypeForElement(
391 _backend.helpers.assertTest, _globalInferenceResults);
383 392
384 ir.Procedure get assertThrow => 393 ir.Procedure get assertThrow =>
385 kernel.functions[_backend.helpers.assertThrow]; 394 kernel.functions[_backend.helpers.assertThrow];
386 395
387 ir.Procedure get setRuntimeTypeInfo => 396 ir.Procedure get setRuntimeTypeInfo =>
388 kernel.functions[_backend.helpers.setRuntimeTypeInfo]; 397 kernel.functions[_backend.helpers.setRuntimeTypeInfo];
389 398
390 TypeMask get assertThrowReturnType => TypeMaskFactory 399 TypeMask get assertThrowReturnType =>
391 .inferredReturnTypeForElement(_backend.helpers.assertThrow, _compiler); 400 TypeMaskFactory.inferredReturnTypeForElement(
401 _backend.helpers.assertThrow, _globalInferenceResults);
392 402
393 ir.Procedure get runtimeTypeToString => 403 ir.Procedure get runtimeTypeToString =>
394 kernel.functions[_backend.helpers.runtimeTypeToString]; 404 kernel.functions[_backend.helpers.runtimeTypeToString];
395 405
396 ir.Procedure get createRuntimeType => 406 ir.Procedure get createRuntimeType =>
397 kernel.functions[_backend.helpers.createRuntimeType]; 407 kernel.functions[_backend.helpers.createRuntimeType];
398 408
399 TypeMask get createRuntimeTypeReturnType => 409 TypeMask get createRuntimeTypeReturnType =>
400 TypeMaskFactory.inferredReturnTypeForElement( 410 TypeMaskFactory.inferredReturnTypeForElement(
401 _backend.helpers.createRuntimeType, _compiler); 411 _backend.helpers.createRuntimeType, _globalInferenceResults);
402 412
403 ir.Class get objectClass => kernel.classes[_compiler.coreClasses.objectClass]; 413 ir.Class get objectClass => kernel.classes[_compiler.coreClasses.objectClass];
404 414
405 ir.Procedure get currentIsolate => 415 ir.Procedure get currentIsolate =>
406 kernel.functions[_backend.helpers.currentIsolate]; 416 kernel.functions[_backend.helpers.currentIsolate];
407 417
408 ir.Procedure get callInIsolate => 418 ir.Procedure get callInIsolate =>
409 kernel.functions[_backend.helpers.callInIsolate]; 419 kernel.functions[_backend.helpers.callInIsolate];
410 420
411 bool isInForeignLibrary(ir.Member member) => 421 bool isInForeignLibrary(ir.Member member) =>
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 astAdapter.reporter.internalError( 854 astAdapter.reporter.internalError(
845 CURRENT_ELEMENT_SPANNABLE, "Unexpected constant target: $element."); 855 CURRENT_ELEMENT_SPANNABLE, "Unexpected constant target: $element.");
846 return null; 856 return null;
847 } 857 }
848 858
849 @override 859 @override
850 ConstantExpression visitStringLiteral(ir.StringLiteral node) { 860 ConstantExpression visitStringLiteral(ir.StringLiteral node) {
851 return new StringConstantExpression(node.value); 861 return new StringConstantExpression(node.value);
852 } 862 }
853 } 863 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/invoke_dynamic_specializers.dart ('k') | pkg/compiler/lib/src/ssa/locals_handler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698