| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 interface HVisitor<R> { | 5 interface HVisitor<R> { |
| 6 R visitAdd(HAdd node); | 6 R visitAdd(HAdd node); |
| 7 R visitBailoutTarget(HBailoutTarget node); | 7 R visitBailoutTarget(HBailoutTarget node); |
| 8 R visitBitAnd(HBitAnd node); | 8 R visitBitAnd(HBitAnd node); |
| 9 R visitBitNot(HBitNot node); | 9 R visitBitNot(HBitNot node); |
| 10 R visitBitOr(HBitOr node); | 10 R visitBitOr(HBitOr node); |
| (...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1312 | 1312 |
| 1313 int typeCode() => 4; | 1313 int typeCode() => 4; |
| 1314 bool typeEquals(other) => other is HInvokeInterceptor; | 1314 bool typeEquals(other) => other is HInvokeInterceptor; |
| 1315 bool dataEquals(HInvokeInterceptor other) { | 1315 bool dataEquals(HInvokeInterceptor other) { |
| 1316 return getter == other.getter && name == other.name; | 1316 return getter == other.getter && name == other.name; |
| 1317 } | 1317 } |
| 1318 } | 1318 } |
| 1319 | 1319 |
| 1320 abstract class HFieldAccess extends HInstruction { | 1320 abstract class HFieldAccess extends HInstruction { |
| 1321 final Element element; | 1321 final Element element; |
| 1322 final SourceString fieldName; |
| 1323 final LibraryElement library; |
| 1322 | 1324 |
| 1323 HFieldAccess(this.element, List<HInstruction> inputs) : super(inputs); | 1325 HFieldAccess(this.fieldName, this.library, List<HInstruction> inputs) |
| 1326 : element = null, super(inputs); |
| 1327 |
| 1328 HFieldAccess.withElement(Element element, List<HInstruction> inputs) |
| 1329 : this.element = element, |
| 1330 fieldName = element.name, |
| 1331 library = element.getLibrary(), |
| 1332 super(inputs); |
| 1324 } | 1333 } |
| 1325 | 1334 |
| 1326 class HFieldGet extends HFieldAccess { | 1335 class HFieldGet extends HFieldAccess { |
| 1327 final bool isFinalOrConst; | 1336 final bool isFinalOrConst; |
| 1328 | 1337 |
| 1329 HFieldGet(Element element, HInstruction receiver, | 1338 HFieldGet(SourceString name, LibraryElement library, HInstruction receiver, |
| 1330 [this.isFinalOrConst = false]) | 1339 [this.isFinalOrConst = false]) |
| 1331 : super(element, <HInstruction>[receiver]); | 1340 : super(name, library, <HInstruction>[receiver]); |
| 1341 |
| 1342 HFieldGet.withElement(Element element, HInstruction receiver, |
| 1343 [this.isFinalOrConst = false]) |
| 1344 : super.withElement(element, <HInstruction>[receiver]); |
| 1332 | 1345 |
| 1333 HInstruction get receiver() => inputs[0]; | 1346 HInstruction get receiver() => inputs[0]; |
| 1334 | 1347 |
| 1335 accept(HVisitor visitor) => visitor.visitFieldGet(this); | 1348 accept(HVisitor visitor) => visitor.visitFieldGet(this); |
| 1336 | 1349 |
| 1337 void prepareGvn() { | 1350 void prepareGvn() { |
| 1338 setUseGvn(); | 1351 setUseGvn(); |
| 1339 clearAllSideEffects(); | 1352 clearAllSideEffects(); |
| 1340 if (!isFinalOrConst) setDependsOnSomething(); | 1353 if (!isFinalOrConst) setDependsOnSomething(); |
| 1341 } | 1354 } |
| 1342 | 1355 |
| 1343 int typeCode() => 27; | 1356 int typeCode() => 27; |
| 1344 bool typeEquals(other) => other is HFieldGet; | 1357 bool typeEquals(other) => other is HFieldGet; |
| 1345 bool dataEquals(HFieldGet other) => element == other.element; | 1358 bool dataEquals(HFieldGet other) => element == other.element; |
| 1346 String toString() => "FieldGet $element"; | 1359 String toString() => "FieldGet ${element == null ? fieldName : element}"; |
| 1347 } | 1360 } |
| 1348 | 1361 |
| 1349 class HFieldSet extends HFieldAccess { | 1362 class HFieldSet extends HFieldAccess { |
| 1350 HFieldSet(Element element, HInstruction receiver, HInstruction value) | 1363 HFieldSet(SourceString name, |
| 1351 : super(element, <HInstruction>[receiver, value]); | 1364 LibraryElement library, |
| 1365 HInstruction receiver, |
| 1366 HInstruction value) |
| 1367 : super(name, library, <HInstruction>[receiver, value]); |
| 1368 |
| 1369 HFieldSet.withElement(Element element, |
| 1370 HInstruction receiver, |
| 1371 HInstruction value) |
| 1372 : super.withElement(element, <HInstruction>[receiver, value]); |
| 1352 | 1373 |
| 1353 HInstruction get receiver() => inputs[0]; | 1374 HInstruction get receiver() => inputs[0]; |
| 1354 HInstruction get value() => inputs[1]; | 1375 HInstruction get value() => inputs[1]; |
| 1355 accept(HVisitor visitor) => visitor.visitFieldSet(this); | 1376 accept(HVisitor visitor) => visitor.visitFieldSet(this); |
| 1356 | 1377 |
| 1357 void prepareGvn() { | 1378 void prepareGvn() { |
| 1358 // TODO(ngeoffray): implement more fine grained side effects. | 1379 // TODO(ngeoffray): implement more fine grained side effects. |
| 1359 setAllSideEffects(); | 1380 setAllSideEffects(); |
| 1360 } | 1381 } |
| 1361 | 1382 |
| 1362 final bool isStatement = true; | 1383 final bool isStatement = true; |
| 1363 String toString() => "FieldSet $element"; | 1384 String toString() => "FieldSet ${element == null ? fieldName : element}"; |
| 1364 } | 1385 } |
| 1365 | 1386 |
| 1366 class HLocalGet extends HFieldGet { | 1387 class HLocalGet extends HFieldGet { |
| 1367 HLocalGet(Element element, HLocalValue local) : super(element, local); | 1388 HLocalGet(Element element, HLocalValue local) |
| 1389 : super.withElement(element, local); |
| 1368 | 1390 |
| 1369 accept(HVisitor visitor) => visitor.visitLocalGet(this); | 1391 accept(HVisitor visitor) => visitor.visitLocalGet(this); |
| 1370 | 1392 |
| 1371 HLocalValue get local() => inputs[0]; | 1393 HLocalValue get local() => inputs[0]; |
| 1372 | 1394 |
| 1373 void prepareGvn() { | 1395 void prepareGvn() { |
| 1374 setUseGvn(); | 1396 setUseGvn(); |
| 1375 // TODO(floitsch): if the variable is not captured then it only depends | 1397 // TODO(floitsch): if the variable is not captured then it only depends |
| 1376 // on assignments to the same variable. Otherwise we need to see if the | 1398 // on assignments to the same variable. Otherwise we need to see if the |
| 1377 // variable is mutated inside closures. | 1399 // variable is mutated inside closures. |
| 1378 setDependsOnSomething(); | 1400 setDependsOnSomething(); |
| 1379 } | 1401 } |
| 1380 } | 1402 } |
| 1381 | 1403 |
| 1382 class HLocalSet extends HFieldSet { | 1404 class HLocalSet extends HFieldSet { |
| 1383 HLocalSet(Element element, HLocalValue local, HInstruction value) | 1405 HLocalSet(Element element, HLocalValue local, HInstruction value) |
| 1384 : super(element, local, value); | 1406 : super.withElement(element, local, value); |
| 1385 | 1407 |
| 1386 accept(HVisitor visitor) => visitor.visitLocalSet(this); | 1408 accept(HVisitor visitor) => visitor.visitLocalSet(this); |
| 1387 | 1409 |
| 1388 HLocalValue get local() => inputs[0]; | 1410 HLocalValue get local() => inputs[0]; |
| 1389 | 1411 |
| 1390 void prepareGvn() { | 1412 void prepareGvn() { |
| 1391 // TODO(floitsch): implement more fine grained side effects. | 1413 // TODO(floitsch): implement more fine grained side effects. |
| 1392 setAllSideEffects(); | 1414 setAllSideEffects(); |
| 1393 } | 1415 } |
| 1394 } | 1416 } |
| (...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2694 HBasicBlock get start() => expression.start; | 2716 HBasicBlock get start() => expression.start; |
| 2695 HBasicBlock get end() { | 2717 HBasicBlock get end() { |
| 2696 // We don't create a switch block if there are no cases. | 2718 // We don't create a switch block if there are no cases. |
| 2697 assert(!statements.isEmpty()); | 2719 assert(!statements.isEmpty()); |
| 2698 return statements.last().end; | 2720 return statements.last().end; |
| 2699 } | 2721 } |
| 2700 | 2722 |
| 2701 bool accept(HStatementInformationVisitor visitor) => | 2723 bool accept(HStatementInformationVisitor visitor) => |
| 2702 visitor.visitSwitchInfo(this); | 2724 visitor.visitSwitchInfo(this); |
| 2703 } | 2725 } |
| OLD | NEW |