Chromium Code Reviews| 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 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 790 static const int GREATER_TYPECODE = 21; | 790 static const int GREATER_TYPECODE = 21; |
| 791 static const int GREATER_EQUAL_TYPECODE = 22; | 791 static const int GREATER_EQUAL_TYPECODE = 22; |
| 792 static const int LESS_TYPECODE = 23; | 792 static const int LESS_TYPECODE = 23; |
| 793 static const int LESS_EQUAL_TYPECODE = 24; | 793 static const int LESS_EQUAL_TYPECODE = 24; |
| 794 static const int STATIC_TYPECODE = 25; | 794 static const int STATIC_TYPECODE = 25; |
| 795 static const int STATIC_STORE_TYPECODE = 26; | 795 static const int STATIC_STORE_TYPECODE = 26; |
| 796 static const int FIELD_GET_TYPECODE = 27; | 796 static const int FIELD_GET_TYPECODE = 27; |
| 797 static const int TYPE_CONVERSION_TYPECODE = 28; | 797 static const int TYPE_CONVERSION_TYPECODE = 28; |
| 798 static const int BAILOUT_TARGET_TYPECODE = 29; | 798 static const int BAILOUT_TARGET_TYPECODE = 29; |
| 799 static const int INVOKE_STATIC_TYPECODE = 30; | 799 static const int INVOKE_STATIC_TYPECODE = 30; |
| 800 static const int INVOKE_DYNAMIC_GETTER_TYPECODE = 31; | |
| 800 | 801 |
| 801 HInstruction(this.inputs) | 802 HInstruction(this.inputs) |
| 802 : id = idCounter++, | 803 : id = idCounter++, |
| 803 usedBy = <HInstruction>[]; | 804 usedBy = <HInstruction>[]; |
| 804 | 805 |
| 805 int hashCode() => id; | 806 int hashCode() => id; |
| 806 | 807 |
| 807 bool getFlag(int position) => (flags & (1 << position)) != 0; | 808 bool getFlag(int position) => (flags & (1 << position)) != 0; |
| 808 void setFlag(int position) { flags |= (1 << position); } | 809 void setFlag(int position) { flags |= (1 << position); } |
| 809 void clearFlag(int position) { flags &= ~(1 << position); } | 810 void clearFlag(int position) { flags &= ~(1 << position); } |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1297 HInvokeDynamicField(Selector selector, Element element, | 1298 HInvokeDynamicField(Selector selector, Element element, |
| 1298 List<HInstruction> inputs) | 1299 List<HInstruction> inputs) |
| 1299 : super(selector, element, inputs); | 1300 : super(selector, element, inputs); |
| 1300 toString() => 'invoke dynamic field: $selector'; | 1301 toString() => 'invoke dynamic field: $selector'; |
| 1301 | 1302 |
| 1302 // TODO(floitsch): make class abstract instead of adding an abstract method. | 1303 // TODO(floitsch): make class abstract instead of adding an abstract method. |
| 1303 abstract accept(HVisitor visitor); | 1304 abstract accept(HVisitor visitor); |
| 1304 } | 1305 } |
| 1305 | 1306 |
| 1306 class HInvokeDynamicGetter extends HInvokeDynamicField { | 1307 class HInvokeDynamicGetter extends HInvokeDynamicField { |
| 1307 HInvokeDynamicGetter(selector, element, receiver) | 1308 final bool possibleTargetsAreFields; |
|
kasperl
2012/09/11 07:39:11
Maybe this should be allPossibleTargetsAreFields -
ngeoffray
2012/09/11 08:51:08
Done.
| |
| 1309 HInvokeDynamicGetter( | |
| 1310 selector, element, receiver, this.possibleTargetsAreFields) | |
| 1308 : super(selector, element,[receiver]); | 1311 : super(selector, element,[receiver]); |
| 1309 toString() => 'invoke dynamic getter: $selector'; | 1312 toString() => 'invoke dynamic getter: $selector'; |
| 1310 accept(HVisitor visitor) => visitor.visitInvokeDynamicGetter(this); | 1313 accept(HVisitor visitor) => visitor.visitInvokeDynamicGetter(this); |
| 1314 | |
| 1315 void prepareGvn(HTypeMap types) { | |
| 1316 if (possibleTargetsAreFields) { | |
| 1317 setUseGvn(); | |
| 1318 clearAllSideEffects(); | |
| 1319 setDependsOnSomething(); | |
| 1320 } else { | |
| 1321 setAllSideEffects(); | |
| 1322 } | |
| 1323 } | |
| 1324 | |
| 1325 int typeCode() => HInstruction.INVOKE_DYNAMIC_GETTER_TYPECODE; | |
| 1326 bool typeEquals(other) => other is HInvokeDynamicGetter; | |
| 1327 bool dataEquals(HInvokeInterceptor other) => selector == other.selector; | |
| 1311 } | 1328 } |
| 1312 | 1329 |
| 1313 class HInvokeDynamicSetter extends HInvokeDynamicField { | 1330 class HInvokeDynamicSetter extends HInvokeDynamicField { |
| 1314 HInvokeDynamicSetter(selector, element, receiver, value) | 1331 HInvokeDynamicSetter(selector, element, receiver, value) |
| 1315 : super(selector, element, [receiver, value]); | 1332 : super(selector, element, [receiver, value]); |
| 1316 toString() => 'invoke dynamic setter: $selector'; | 1333 toString() => 'invoke dynamic setter: $selector'; |
| 1317 accept(HVisitor visitor) => visitor.visitInvokeDynamicSetter(this); | 1334 accept(HVisitor visitor) => visitor.visitInvokeDynamicSetter(this); |
| 1318 } | 1335 } |
| 1319 | 1336 |
| 1320 class HInvokeStatic extends HInvoke { | 1337 class HInvokeStatic extends HInvoke { |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 1349 | 1366 |
| 1350 HInstruction get value { | 1367 HInstruction get value { |
| 1351 assert(isSetter); | 1368 assert(isSetter); |
| 1352 // Index 0: the element, index 1: 'this'. | 1369 // Index 0: the element, index 1: 'this'. |
| 1353 return inputs[2]; | 1370 return inputs[2]; |
| 1354 } | 1371 } |
| 1355 } | 1372 } |
| 1356 | 1373 |
| 1357 class HInvokeInterceptor extends HInvokeStatic { | 1374 class HInvokeInterceptor extends HInvokeStatic { |
| 1358 final Selector selector; | 1375 final Selector selector; |
| 1376 final bool _hasSideEffects; | |
|
kasperl
2012/09/11 07:39:11
Is this private just because of naming conflicts?
ngeoffray
2012/09/11 08:51:08
Done.
| |
| 1359 | 1377 |
| 1360 HInvokeInterceptor(this.selector, | 1378 HInvokeInterceptor(this.selector, |
| 1361 List<HInstruction> inputs, | 1379 List<HInstruction> inputs, |
| 1362 [HType knownType = HType.UNKNOWN]) | 1380 [bool this._hasSideEffects = true]) |
| 1363 : super(inputs, knownType); | 1381 : super(inputs); |
| 1364 | 1382 |
| 1365 toString() => 'invoke interceptor: ${element.name}'; | 1383 toString() => 'invoke interceptor: ${element.name}'; |
| 1366 accept(HVisitor visitor) => visitor.visitInvokeInterceptor(this); | 1384 accept(HVisitor visitor) => visitor.visitInvokeInterceptor(this); |
| 1367 | 1385 |
| 1368 bool isLengthGetter() { | 1386 bool isLengthGetter() { |
| 1369 return selector.isGetter() && | 1387 return selector.isGetter() && |
| 1370 selector.name == const SourceString('length'); | 1388 selector.name == const SourceString('length'); |
| 1371 } | 1389 } |
| 1372 | 1390 |
| 1373 bool isPopCall(HTypeMap types) { | 1391 bool isPopCall(HTypeMap types) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1409 | 1427 |
| 1410 void prepareGvn(HTypeMap types) { | 1428 void prepareGvn(HTypeMap types) { |
| 1411 if (isLengthGetterOnStringOrArray(types)) { | 1429 if (isLengthGetterOnStringOrArray(types)) { |
| 1412 setUseGvn(); | 1430 setUseGvn(); |
| 1413 clearAllSideEffects(); | 1431 clearAllSideEffects(); |
| 1414 // If the input is a string, we know the length cannot change. | 1432 // If the input is a string, we know the length cannot change. |
| 1415 // We cannot do the same thing for non-extendable array because | 1433 // We cannot do the same thing for non-extendable array because |
| 1416 // we don't express that type yet: a mutable array might be | 1434 // we don't express that type yet: a mutable array might be |
| 1417 // extendable. | 1435 // extendable. |
| 1418 if (!inputs[1].isString(types)) setDependsOnSomething(); | 1436 if (!inputs[1].isString(types)) setDependsOnSomething(); |
| 1437 } else if (!_hasSideEffects) { | |
| 1438 setUseGvn(); | |
| 1439 clearAllSideEffects(); | |
| 1440 setDependsOnSomething(); | |
| 1419 } else { | 1441 } else { |
| 1420 setAllSideEffects(); | 1442 setAllSideEffects(); |
| 1421 } | 1443 } |
| 1422 } | 1444 } |
| 1423 | 1445 |
| 1424 int typeCode() => HInstruction.INVOKE_INTERCEPTOR_TYPECODE; | 1446 int typeCode() => HInstruction.INVOKE_INTERCEPTOR_TYPECODE; |
| 1425 bool typeEquals(other) => other is HInvokeInterceptor; | 1447 bool typeEquals(other) => other is HInvokeInterceptor; |
| 1426 bool dataEquals(HInvokeInterceptor other) => selector == other.selector; | 1448 bool dataEquals(HInvokeInterceptor other) => selector == other.selector; |
| 1427 } | 1449 } |
| 1428 | 1450 |
| (...skipping 1446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2875 HBasicBlock get start => expression.start; | 2897 HBasicBlock get start => expression.start; |
| 2876 HBasicBlock get end { | 2898 HBasicBlock get end { |
| 2877 // We don't create a switch block if there are no cases. | 2899 // We don't create a switch block if there are no cases. |
| 2878 assert(!statements.isEmpty()); | 2900 assert(!statements.isEmpty()); |
| 2879 return statements.last().end; | 2901 return statements.last().end; |
| 2880 } | 2902 } |
| 2881 | 2903 |
| 2882 bool accept(HStatementInformationVisitor visitor) => | 2904 bool accept(HStatementInformationVisitor visitor) => |
| 2883 visitor.visitSwitchInfo(this); | 2905 visitor.visitSwitchInfo(this); |
| 2884 } | 2906 } |
| OLD | NEW |