Chromium Code Reviews| 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 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 900 } | 900 } |
| 901 | 901 |
| 902 | 902 |
| 903 void HJSArrayLength::PrintDataTo(StringStream* stream) { | 903 void HJSArrayLength::PrintDataTo(StringStream* stream) { |
| 904 value()->PrintNameTo(stream); | 904 value()->PrintNameTo(stream); |
| 905 stream->Add(" "); | 905 stream->Add(" "); |
| 906 typecheck()->PrintNameTo(stream); | 906 typecheck()->PrintNameTo(stream); |
| 907 } | 907 } |
| 908 | 908 |
| 909 | 909 |
| 910 HValue* HUnaryMathOperation::Canonicalize() { | |
| 911 if (op() == kMathFloor) { | |
| 912 // If the input is integer32 then we replace the floor instruction | |
| 913 // with its input. This happens before the representation changes are | |
| 914 // introduced. | |
| 915 if (value()->representation().IsInteger32()) return value(); | |
| 916 | |
| 917 if (value()->IsDiv() && LChunkBuilder::SupportsMathFloorOfDiv()) { | |
|
fschneider
2012/03/28 09:59:18
The function SupportsMathFloorDiv is essentially l
Alexandre
2012/03/28 16:27:38
Done.
| |
| 918 HDiv* hdiv = HDiv::cast(value()); | |
| 919 HValue* left = hdiv->left(); | |
| 920 HValue* right = hdiv->right(); | |
| 921 // Try to simplify left and right values of the division. | |
| 922 HValue* new_left = | |
| 923 LChunkBuilder::SimplifiedDividendForMathFloorOfDiv(left); | |
| 924 HValue* new_right = | |
| 925 LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(right); | |
| 926 | |
| 927 // Return if left or right are not optimizable. | |
| 928 if ((new_left == NULL) || (new_right == NULL)) return this; | |
| 929 | |
| 930 // Insert the new values in the graph. | |
| 931 if (new_left->IsInstruction() && | |
| 932 !HInstruction::cast(new_left)->IsLinked()) { | |
| 933 HInstruction::cast(new_left)->InsertBefore(this); | |
| 934 } | |
| 935 if (new_right->IsInstruction() && | |
| 936 !HInstruction::cast(new_right)->IsLinked()) { | |
| 937 HInstruction::cast(new_right)->InsertBefore(this); | |
| 938 } | |
| 939 HMathFloorOfDiv* instr = new HMathFloorOfDiv(context(), | |
| 940 new_left, | |
| 941 new_right); | |
| 942 // Replace this HMathFloor instruction by the new HMathFloorOfDiv. | |
| 943 instr->InsertBefore(this); | |
| 944 ReplaceAllUsesWith(instr); | |
| 945 Kill(); | |
| 946 // If the division had no other uses than this HMathFloor, delete it. | |
|
fschneider
2012/03/28 09:59:18
Not sure how often the division acutally has other
Alexandre
2012/03/28 16:27:38
Done.
| |
| 947 // Also delete the arguments of the division if they are not used any | |
| 948 // more. | |
| 949 if (hdiv->HasNoUses()) { | |
| 950 hdiv->DeleteAndReplaceWith(NULL); | |
| 951 ASSERT(left->IsChange() || left->IsConstant()); | |
| 952 ASSERT(right->IsChange() || right->IsConstant()); | |
| 953 if (left->HasNoUses()) left->DeleteAndReplaceWith(NULL); | |
| 954 if (right->HasNoUses()) right->DeleteAndReplaceWith(NULL); | |
| 955 } | |
| 956 // Return NULL to remove this instruction from the graph. | |
| 957 return NULL; | |
| 958 } | |
| 959 } | |
| 960 return this; | |
| 961 } | |
| 962 | |
| 963 | |
| 910 HValue* HCheckInstanceType::Canonicalize() { | 964 HValue* HCheckInstanceType::Canonicalize() { |
| 911 if (check_ == IS_STRING && | 965 if (check_ == IS_STRING && |
| 912 !value()->type().IsUninitialized() && | 966 !value()->type().IsUninitialized() && |
| 913 value()->type().IsString()) { | 967 value()->type().IsString()) { |
| 914 return NULL; | 968 return NULL; |
| 915 } | 969 } |
| 916 if (check_ == IS_SYMBOL && | 970 if (check_ == IS_SYMBOL && |
| 917 value()->IsConstant() && | 971 value()->IsConstant() && |
| 918 HConstant::cast(value())->handle()->IsSymbol()) { | 972 HConstant::cast(value())->handle()->IsSymbol()) { |
| 919 return NULL; | 973 return NULL; |
| (...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2287 | 2341 |
| 2288 | 2342 |
| 2289 void HCheckPrototypeMaps::Verify() { | 2343 void HCheckPrototypeMaps::Verify() { |
| 2290 HInstruction::Verify(); | 2344 HInstruction::Verify(); |
| 2291 ASSERT(HasNoUses()); | 2345 ASSERT(HasNoUses()); |
| 2292 } | 2346 } |
| 2293 | 2347 |
| 2294 #endif | 2348 #endif |
| 2295 | 2349 |
| 2296 } } // namespace v8::internal | 2350 } } // namespace v8::internal |
| OLD | NEW |