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

Side by Side Diff: pkg/compiler/lib/src/js_backend/backend_impact.dart

Issue 1469353004: Restrict backend misuse (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix unittests 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_helpers.impact; 5 library dart2js.js_helpers.impact;
6 6
7 import '../common/names.dart' show 7 import '../common/names.dart' show
8 Identifiers; 8 Identifiers;
9 import '../compiler.dart' show 9 import '../compiler.dart' show
10 Compiler; 10 Compiler;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 BackendImpact _computeSignature; 61 BackendImpact _computeSignature;
62 62
63 BackendImpact get computeSignature { 63 BackendImpact get computeSignature {
64 if (_computeSignature == null) { 64 if (_computeSignature == null) {
65 _computeSignature = new BackendImpact( 65 _computeSignature = new BackendImpact(
66 staticUses: [ 66 staticUses: [
67 helpers.setRuntimeTypeInfo, 67 helpers.setRuntimeTypeInfo,
68 helpers.getRuntimeTypeInfo, 68 helpers.getRuntimeTypeInfo,
69 helpers.computeSignature, 69 helpers.computeSignature,
70 helpers.getRuntimeTypeArguments], 70 helpers.getRuntimeTypeArguments],
71 instantiatedClasses: [ 71 otherImpacts: [
72 coreClasses.listClass]); 72 listValues]);
73 } 73 }
74 return _computeSignature; 74 return _computeSignature;
75 } 75 }
76 76
77 BackendImpact _asyncBody; 77 BackendImpact _asyncBody;
78 78
79 BackendImpact get asyncBody { 79 BackendImpact get asyncBody {
80 if (_asyncBody == null) { 80 if (_asyncBody == null) {
81 _asyncBody = new BackendImpact( 81 _asyncBody = new BackendImpact(
82 staticUses: [ 82 staticUses: [
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 otherImpacts: [ 180 otherImpacts: [
181 // Also register the types of the arguments passed to this method. 181 // Also register the types of the arguments passed to this method.
182 _needsList( 182 _needsList(
183 'Needed to encode the arguments for throw NoSuchMethodError.'), 183 'Needed to encode the arguments for throw NoSuchMethodError.'),
184 _needsString( 184 _needsString(
185 'Needed to encode the name for throw NoSuchMethodError.')]); 185 'Needed to encode the name for throw NoSuchMethodError.')]);
186 } 186 }
187 return _throwNoSuchMethod; 187 return _throwNoSuchMethod;
188 } 188 }
189 189
190 BackendImpact _stringValues;
191
192 BackendImpact get stringValues {
193 if (_stringValues == null) {
194 _stringValues = new BackendImpact(
195 instantiatedClasses: [
196 helpers.jsStringClass]);
197 }
198 return _stringValues;
199 }
200
201 BackendImpact _numValues;
202
203 BackendImpact get numValues {
204 if (_numValues == null) {
205 _numValues = new BackendImpact(
206 instantiatedClasses: [
207 helpers.jsIntClass,
208 helpers.jsPositiveIntClass,
209 helpers.jsUInt32Class,
210 helpers.jsUInt31Class,
211 helpers.jsNumberClass,
212 helpers.jsDoubleClass]);
213 }
214 return _numValues;
215 }
216
217 BackendImpact get intValues => numValues;
218
219 BackendImpact get doubleValues => numValues;
220
221 BackendImpact _boolValues;
222
223 BackendImpact get boolValues {
224 if (_boolValues == null) {
225 _boolValues = new BackendImpact(
226 instantiatedClasses: [
227 helpers.jsBoolClass]);
228 }
229 return _boolValues;
230 }
231
232 BackendImpact _nullValue;
233
234 BackendImpact get nullValue {
235 if (_nullValue == null) {
236 _nullValue = new BackendImpact(
237 instantiatedClasses: [
238 helpers.jsNullClass]);
239 }
240 return _nullValue;
241 }
242
243 BackendImpact _listValues;
244
245 BackendImpact get listValues {
246 if (_listValues == null) {
247 _listValues = new BackendImpact(
248 instantiatedClasses: [
249 helpers.jsArrayClass,
250 helpers.jsMutableArrayClass,
251 helpers.jsFixedArrayClass,
252 helpers.jsExtendableArrayClass,
253 helpers.jsUnmodifiableArrayClass]);
254 }
255 return _listValues;
256 }
257
190 BackendImpact _throwRuntimeError; 258 BackendImpact _throwRuntimeError;
191 259
192 BackendImpact get throwRuntimeError { 260 BackendImpact get throwRuntimeError {
193 if (_throwRuntimeError == null) { 261 if (_throwRuntimeError == null) {
194 _throwRuntimeError = new BackendImpact( 262 _throwRuntimeError = new BackendImpact(
195 staticUses: [ 263 staticUses: [
196 helpers.throwRuntimeError], 264 helpers.throwRuntimeError],
197 // Also register the types of the arguments passed to this method. 265 otherImpacts: [
198 instantiatedClasses: [ 266 // Also register the types of the arguments passed to this method.
199 coreClasses.stringClass]); 267 stringValues]);
200 } 268 }
201 return _throwRuntimeError; 269 return _throwRuntimeError;
202 } 270 }
203 271
204 BackendImpact _superNoSuchMethod; 272 BackendImpact _superNoSuchMethod;
205 273
206 BackendImpact get superNoSuchMethod { 274 BackendImpact get superNoSuchMethod {
207 if (_superNoSuchMethod == null) { 275 if (_superNoSuchMethod == null) {
208 _superNoSuchMethod = new BackendImpact( 276 _superNoSuchMethod = new BackendImpact(
209 staticUses: [ 277 staticUses: [
210 helpers.createInvocationMirror, 278 helpers.createInvocationMirror,
211 coreClasses.objectClass.lookupLocalMember( 279 helpers.objectNoSuchMethod],
212 Identifiers.noSuchMethod_)],
213 otherImpacts: [ 280 otherImpacts: [
214 _needsInt( 281 _needsInt(
215 'Needed to encode the invocation kind of super.noSuchMethod.'), 282 'Needed to encode the invocation kind of super.noSuchMethod.'),
216 _needsList( 283 _needsList(
217 'Needed to encode the arguments of super.noSuchMethod.'), 284 'Needed to encode the arguments of super.noSuchMethod.'),
218 _needsString( 285 _needsString(
219 'Needed to encode the name of super.noSuchMethod.')]); 286 'Needed to encode the name of super.noSuchMethod.')]);
220 } 287 }
221 return _superNoSuchMethod; 288 return _superNoSuchMethod;
222 } 289 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 if (_incDecOperation == null) { 337 if (_incDecOperation == null) {
271 _incDecOperation = 338 _incDecOperation =
272 _needsInt('Needed for the `+ 1` or `- 1` operation of ++/--.'); 339 _needsInt('Needed for the `+ 1` or `- 1` operation of ++/--.');
273 } 340 }
274 return _incDecOperation; 341 return _incDecOperation;
275 } 342 }
276 343
277 /// Helper for registering that `int` is needed. 344 /// Helper for registering that `int` is needed.
278 BackendImpact _needsInt(String reason) { 345 BackendImpact _needsInt(String reason) {
279 // TODO(johnniwinther): Register [reason] for use in dump-info. 346 // TODO(johnniwinther): Register [reason] for use in dump-info.
280 return new BackendImpact( 347 return intValues;
281 instantiatedClasses: [coreClasses.intClass]);
282 } 348 }
283 349
284 /// Helper for registering that `List` is needed. 350 /// Helper for registering that `List` is needed.
285 BackendImpact _needsList(String reason) { 351 BackendImpact _needsList(String reason) {
286 // TODO(johnniwinther): Register [reason] for use in dump-info. 352 // TODO(johnniwinther): Register [reason] for use in dump-info.
287 return new BackendImpact( 353 return listValues;
288 instantiatedClasses: [coreClasses.listClass]);
289 } 354 }
290 355
291 /// Helper for registering that `String` is needed. 356 /// Helper for registering that `String` is needed.
292 BackendImpact _needsString(String reason) { 357 BackendImpact _needsString(String reason) {
293 // TODO(johnniwinther): Register [reason] for use in dump-info. 358 // TODO(johnniwinther): Register [reason] for use in dump-info.
294 return new BackendImpact( 359 return stringValues;
295 instantiatedClasses: [
296 coreClasses.stringClass]);
297 } 360 }
298 361
299 BackendImpact _assertWithoutMessage; 362 BackendImpact _assertWithoutMessage;
300 363
301 BackendImpact get assertWithoutMessage { 364 BackendImpact get assertWithoutMessage {
302 if (_assertWithoutMessage == null) { 365 if (_assertWithoutMessage == null) {
303 _assertWithoutMessage = new BackendImpact( 366 _assertWithoutMessage = new BackendImpact(
304 staticUses: [ 367 staticUses: [
305 helpers.assertHelper]); 368 helpers.assertHelper]);
306 } 369 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 408
346 BackendImpact _stringJuxtaposition; 409 BackendImpact _stringJuxtaposition;
347 410
348 BackendImpact get stringJuxtaposition { 411 BackendImpact get stringJuxtaposition {
349 if (_stringJuxtaposition == null) { 412 if (_stringJuxtaposition == null) {
350 _stringJuxtaposition = _needsString('String.concat is used.'); 413 _stringJuxtaposition = _needsString('String.concat is used.');
351 } 414 }
352 return _stringJuxtaposition; 415 return _stringJuxtaposition;
353 } 416 }
354 417
355 // TODO(johnniwinther): Point to to the JavaScript classes instead of the Dart 418 BackendImpact get nullLiteral => nullValue;
356 // classes in these impacts.
357 BackendImpact _nullLiteral;
358 419
359 BackendImpact get nullLiteral { 420 BackendImpact get boolLiteral => boolValues;
360 if (_nullLiteral == null) {
361 _nullLiteral = new BackendImpact(
362 instantiatedClasses: [
363 coreClasses.nullClass]);
364 }
365 return _nullLiteral;
366 }
367 421
368 BackendImpact _boolLiteral; 422 BackendImpact get intLiteral => intValues;
369 423
370 BackendImpact get boolLiteral { 424 BackendImpact get doubleLiteral => doubleValues;
371 if (_boolLiteral == null) {
372 _boolLiteral = new BackendImpact(
373 instantiatedClasses: [
374 coreClasses.boolClass]);
375 }
376 return _boolLiteral;
377 }
378 425
379 BackendImpact _intLiteral; 426 BackendImpact get stringLiteral => stringValues;
380
381 BackendImpact get intLiteral {
382 if (_intLiteral == null) {
383 _intLiteral = new BackendImpact(
384 instantiatedClasses: [
385 coreClasses.intClass]);
386 }
387 return _intLiteral;
388 }
389
390 BackendImpact _doubleLiteral;
391
392 BackendImpact get doubleLiteral {
393 if (_doubleLiteral == null) {
394 _doubleLiteral = new BackendImpact(
395 instantiatedClasses: [
396 coreClasses.doubleClass]);
397 }
398 return _doubleLiteral;
399 }
400
401 BackendImpact _stringLiteral;
402
403 BackendImpact get stringLiteral {
404 if (_stringLiteral == null) {
405 _stringLiteral = new BackendImpact(
406 instantiatedClasses: [
407 coreClasses.stringClass]);
408 }
409 return _stringLiteral;
410 }
411 427
412 BackendImpact _catchStatement; 428 BackendImpact _catchStatement;
413 429
414 BackendImpact get catchStatement { 430 BackendImpact get catchStatement {
415 if (_catchStatement == null) { 431 if (_catchStatement == null) {
416 _catchStatement = new BackendImpact( 432 _catchStatement = new BackendImpact(
417 staticUses: [ 433 staticUses: [
418 helpers.exceptionUnwrapper], 434 helpers.exceptionUnwrapper],
419 instantiatedClasses: [ 435 instantiatedClasses: [
420 helpers.jsPlainJavaScriptObjectClass, 436 helpers.jsPlainJavaScriptObjectClass,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 } 477 }
462 return _typeLiteral; 478 return _typeLiteral;
463 } 479 }
464 480
465 BackendImpact _stackTraceInCatch; 481 BackendImpact _stackTraceInCatch;
466 482
467 BackendImpact get stackTraceInCatch { 483 BackendImpact get stackTraceInCatch {
468 if (_stackTraceInCatch == null) { 484 if (_stackTraceInCatch == null) {
469 _stackTraceInCatch = new BackendImpact( 485 _stackTraceInCatch = new BackendImpact(
470 instantiatedClasses: [ 486 instantiatedClasses: [
471 coreClasses.stackTraceClass], 487 helpers.stackTraceClass],
472 staticUses: [ 488 staticUses: [
473 helpers.traceFromException]); 489 helpers.traceFromException]);
474 } 490 }
475 return _stackTraceInCatch; 491 return _stackTraceInCatch;
476 } 492 }
477 493
478 BackendImpact _syncForIn; 494 BackendImpact _syncForIn;
479 495
480 BackendImpact get syncForIn { 496 BackendImpact get syncForIn {
481 if (_syncForIn == null) { 497 if (_syncForIn == null) {
482 _syncForIn = new BackendImpact( 498 _syncForIn = new BackendImpact(
483 // The SSA builder recognizes certain for-in loops and can generate 499 // The SSA builder recognizes certain for-in loops and can generate
484 // calls to throwConcurrentModificationError. 500 // calls to throwConcurrentModificationError.
485 staticUses: [ 501 staticUses: [
486 helpers.checkConcurrentModificationError]); 502 helpers.checkConcurrentModificationError]);
487 } 503 }
488 return _syncForIn; 504 return _syncForIn;
489 } 505 }
490 506
491 BackendImpact _typeVariableExpression; 507 BackendImpact _typeVariableExpression;
492 508
493 BackendImpact get typeVariableExpression { 509 BackendImpact get typeVariableExpression {
494 if (_typeVariableExpression == null) { 510 if (_typeVariableExpression == null) {
495 _typeVariableExpression = new BackendImpact( 511 _typeVariableExpression = new BackendImpact(
496 staticUses: [ 512 staticUses: [
497 helpers.setRuntimeTypeInfo, 513 helpers.setRuntimeTypeInfo,
498 helpers.getRuntimeTypeInfo, 514 helpers.getRuntimeTypeInfo,
499 helpers.runtimeTypeToString, 515 helpers.runtimeTypeToString,
500 helpers.createRuntimeType], 516 helpers.createRuntimeType],
501 instantiatedClasses: [
502 coreClasses.listClass],
503 otherImpacts: [ 517 otherImpacts: [
518 listValues,
504 getRuntimeTypeArgument, 519 getRuntimeTypeArgument,
505 _needsInt('Needed for accessing a type variable literal on this.') 520 _needsInt('Needed for accessing a type variable literal on this.')
506 ]); 521 ]);
507 } 522 }
508 return _typeVariableExpression; 523 return _typeVariableExpression;
509 } 524 }
510 525
511 BackendImpact _typeCheck; 526 BackendImpact _typeCheck;
512 527
513 BackendImpact get typeCheck { 528 BackendImpact get typeCheck {
514 if (_typeCheck == null) { 529 if (_typeCheck == null) {
515 _typeCheck = new BackendImpact( 530 _typeCheck = new BackendImpact(
516 instantiatedClasses: [ 531 otherImpacts: [
517 coreClasses.boolClass]); 532 boolValues]);
518 } 533 }
519 return _typeCheck; 534 return _typeCheck;
520 } 535 }
521 536
522 BackendImpact _checkedModeTypeCheck; 537 BackendImpact _checkedModeTypeCheck;
523 538
524 BackendImpact get checkedModeTypeCheck { 539 BackendImpact get checkedModeTypeCheck {
525 if (_checkedModeTypeCheck == null) { 540 if (_checkedModeTypeCheck == null) {
526 _checkedModeTypeCheck = new BackendImpact( 541 _checkedModeTypeCheck = new BackendImpact(
527 staticUses: [ 542 staticUses: [
(...skipping 16 matching lines...) Expand all
544 BackendImpact _genericTypeCheck; 559 BackendImpact _genericTypeCheck;
545 560
546 BackendImpact get genericTypeCheck { 561 BackendImpact get genericTypeCheck {
547 if (_genericTypeCheck == null) { 562 if (_genericTypeCheck == null) {
548 _genericTypeCheck = new BackendImpact( 563 _genericTypeCheck = new BackendImpact(
549 staticUses: [ 564 staticUses: [
550 helpers.checkSubtype, 565 helpers.checkSubtype,
551 // TODO(johnniwinther): Investigate why this is needed. 566 // TODO(johnniwinther): Investigate why this is needed.
552 helpers.setRuntimeTypeInfo, 567 helpers.setRuntimeTypeInfo,
553 helpers.getRuntimeTypeInfo], 568 helpers.getRuntimeTypeInfo],
554 instantiatedClasses: [
555 coreClasses.listClass],
556 otherImpacts: [ 569 otherImpacts: [
570 listValues,
557 getRuntimeTypeArgument]); 571 getRuntimeTypeArgument]);
558 } 572 }
559 return _genericTypeCheck; 573 return _genericTypeCheck;
560 } 574 }
561 575
562 BackendImpact _genericIsCheck; 576 BackendImpact _genericIsCheck;
563 577
564 BackendImpact get genericIsCheck { 578 BackendImpact get genericIsCheck {
565 if (_genericIsCheck == null) { 579 if (_genericIsCheck == null) {
566 _genericIsCheck = new BackendImpact( 580 _genericIsCheck = new BackendImpact(
567 instantiatedClasses: [ 581 otherImpacts: [
568 coreClasses.listClass]); 582 intValues]);
569 } 583 }
570 return _genericIsCheck; 584 return _genericIsCheck;
571 } 585 }
572 586
573 BackendImpact _genericCheckedModeTypeCheck; 587 BackendImpact _genericCheckedModeTypeCheck;
574 588
575 BackendImpact get genericCheckedModeTypeCheck { 589 BackendImpact get genericCheckedModeTypeCheck {
576 if (_genericCheckedModeTypeCheck == null) { 590 if (_genericCheckedModeTypeCheck == null) {
577 _genericCheckedModeTypeCheck = new BackendImpact( 591 _genericCheckedModeTypeCheck = new BackendImpact(
578 staticUses: [ 592 staticUses: [
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 646
633 BackendImpact get closure { 647 BackendImpact get closure {
634 if (_closure == null) { 648 if (_closure == null) {
635 _closure = new BackendImpact( 649 _closure = new BackendImpact(
636 instantiatedClasses: [ 650 instantiatedClasses: [
637 coreClasses.functionClass]); 651 coreClasses.functionClass]);
638 } 652 }
639 return _closure; 653 return _closure;
640 } 654 }
641 } 655 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698