OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1435 val, representation(), false, false); | 1435 val, representation(), false, false); |
1436 result->InsertBefore(this); | 1436 result->InsertBefore(this); |
1437 return result; | 1437 return result; |
1438 } | 1438 } |
1439 return val; | 1439 return val; |
1440 } | 1440 } |
1441 } | 1441 } |
1442 | 1442 |
1443 if (op() == kMathFloor) { | 1443 if (op() == kMathFloor) { |
1444 HValue* val = value(); | 1444 HValue* val = value(); |
1445 if (val->IsChange()) val = HChange::cast(val)->value(); | |
1446 if (val->IsDiv() && (val->UseCount() == 1)) { | 1445 if (val->IsDiv() && (val->UseCount() == 1)) { |
1447 HDiv* hdiv = HDiv::cast(val); | 1446 HDiv* hdiv = HDiv::cast(val); |
1448 HValue* left = hdiv->left(); | 1447 HValue* left = hdiv->left(); |
1449 HValue* right = hdiv->right(); | 1448 HValue* right = hdiv->right(); |
1450 // Try to simplify left and right values of the division. | 1449 // Try to simplify left and right values of the division. |
1451 HValue* new_left = SimplifiedDividendForMathFloorOfDiv(left); | 1450 HValue* new_left = SimplifiedDividendForMathFloorOfDiv(left); |
1452 if (new_left == NULL && | 1451 if (new_left == NULL && |
1453 hdiv->observed_input_representation(1).IsSmiOrInteger32()) { | 1452 hdiv->observed_input_representation(1).IsSmiOrInteger32()) { |
1454 new_left = new(block()->zone()) HChange( | 1453 new_left = new(block()->zone()) HChange( |
1455 left, Representation::Integer32(), false, false); | 1454 left, Representation::Integer32(), false, false); |
(...skipping 18 matching lines...) Expand all Loading... |
1474 if (new_left->IsInstruction() && | 1473 if (new_left->IsInstruction() && |
1475 !HInstruction::cast(new_left)->IsLinked()) { | 1474 !HInstruction::cast(new_left)->IsLinked()) { |
1476 HInstruction::cast(new_left)->InsertBefore(this); | 1475 HInstruction::cast(new_left)->InsertBefore(this); |
1477 } | 1476 } |
1478 if (new_right->IsInstruction() && | 1477 if (new_right->IsInstruction() && |
1479 !HInstruction::cast(new_right)->IsLinked()) { | 1478 !HInstruction::cast(new_right)->IsLinked()) { |
1480 HInstruction::cast(new_right)->InsertBefore(this); | 1479 HInstruction::cast(new_right)->InsertBefore(this); |
1481 } | 1480 } |
1482 HMathFloorOfDiv* instr = | 1481 HMathFloorOfDiv* instr = |
1483 HMathFloorOfDiv::New(block()->zone(), context(), new_left, new_right); | 1482 HMathFloorOfDiv::New(block()->zone(), context(), new_left, new_right); |
1484 // Replace this HMathFloor instruction by the new HMathFloorOfDiv. | |
1485 instr->InsertBefore(this); | 1483 instr->InsertBefore(this); |
1486 ReplaceAllUsesWith(instr); | 1484 return instr; |
1487 Kill(); | |
1488 // We know the division had no other uses than this HMathFloor. Delete it. | |
1489 // Dead code elimination will deal with |left| and |right| if | |
1490 // appropriate. | |
1491 hdiv->DeleteAndReplaceWith(NULL); | |
1492 | |
1493 // Return NULL to remove this instruction from the graph. | |
1494 return NULL; | |
1495 } | 1485 } |
1496 } | 1486 } |
1497 return this; | 1487 return this; |
1498 } | 1488 } |
1499 | 1489 |
1500 | 1490 |
1501 HValue* HCheckInstanceType::Canonicalize() { | 1491 HValue* HCheckInstanceType::Canonicalize() { |
1502 if (check_ == IS_STRING && value()->type().IsString()) { | 1492 if (check_ == IS_STRING && value()->type().IsString()) { |
1503 return value(); | 1493 return value(); |
1504 } | 1494 } |
(...skipping 2942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4447 break; | 4437 break; |
4448 case kExternalMemory: | 4438 case kExternalMemory: |
4449 stream->Add("[external-memory]"); | 4439 stream->Add("[external-memory]"); |
4450 break; | 4440 break; |
4451 } | 4441 } |
4452 | 4442 |
4453 stream->Add("@%d", offset()); | 4443 stream->Add("@%d", offset()); |
4454 } | 4444 } |
4455 | 4445 |
4456 } } // namespace v8::internal | 4446 } } // namespace v8::internal |
OLD | NEW |