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 913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
924 } | 924 } |
925 | 925 |
926 | 926 |
927 void HJSArrayLength::PrintDataTo(StringStream* stream) { | 927 void HJSArrayLength::PrintDataTo(StringStream* stream) { |
928 value()->PrintNameTo(stream); | 928 value()->PrintNameTo(stream); |
929 stream->Add(" "); | 929 stream->Add(" "); |
930 typecheck()->PrintNameTo(stream); | 930 typecheck()->PrintNameTo(stream); |
931 } | 931 } |
932 | 932 |
933 | 933 |
934 HValue* HUnaryMathOperation::Canonicalize() { | |
935 if (op() == kMathFloor) { | |
936 // If the input is integer32 then we replace the floor instruction | |
937 // with its input. This happens before the representation changes are | |
938 // introduced. | |
939 if (value()->representation().IsInteger32()) return value(); | |
940 | |
941 #ifdef V8_TARGET_ARCH_ARM | |
942 if (value()->IsDiv() && (value()->UseCount() == 1)) { | |
943 // TODO(2038): Implement this optimization for non ARM architectures. | |
944 HDiv* hdiv = HDiv::cast(value()); | |
945 HValue* left = hdiv->left(); | |
946 HValue* right = hdiv->right(); | |
947 // Try to simplify left and right values of the division. | |
948 HValue* new_left = | |
949 LChunkBuilder::SimplifiedDividendForMathFloorOfDiv(left); | |
950 HValue* new_right = | |
951 LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(right); | |
952 | |
953 // Return if left or right are not optimizable. | |
954 if ((new_left == NULL) || (new_right == NULL)) return this; | |
955 | |
956 // Insert the new values in the graph. | |
957 if (new_left->IsInstruction() && | |
958 !HInstruction::cast(new_left)->IsLinked()) { | |
959 HInstruction::cast(new_left)->InsertBefore(this); | |
960 } | |
961 if (new_right->IsInstruction() && | |
962 !HInstruction::cast(new_right)->IsLinked()) { | |
963 HInstruction::cast(new_right)->InsertBefore(this); | |
964 } | |
965 HMathFloorOfDiv* instr = new HMathFloorOfDiv(context(), | |
966 new_left, | |
967 new_right); | |
968 // Replace this HMathFloor instruction by the new HMathFloorOfDiv. | |
969 instr->InsertBefore(this); | |
970 ReplaceAllUsesWith(instr); | |
971 Kill(); | |
972 // We know the division had no other uses than this HMathFloor. Delete it. | |
973 // Also delete the arguments of the division if they are not used any | |
974 // more. | |
975 hdiv->DeleteAndReplaceWith(NULL); | |
976 ASSERT(left->IsChange() || left->IsConstant()); | |
977 ASSERT(right->IsChange() || right->IsConstant()); | |
978 if (left->HasNoUses()) left->DeleteAndReplaceWith(NULL); | |
979 if (right->HasNoUses()) right->DeleteAndReplaceWith(NULL); | |
980 | |
981 // Return NULL to remove this instruction from the graph. | |
982 return NULL; | |
983 } | |
984 #endif // V8_TARGET_ARCH_ARM | |
985 } | |
986 return this; | |
987 } | |
988 | |
989 | |
990 HValue* HCheckInstanceType::Canonicalize() { | 934 HValue* HCheckInstanceType::Canonicalize() { |
991 if (check_ == IS_STRING && | 935 if (check_ == IS_STRING && |
992 !value()->type().IsUninitialized() && | 936 !value()->type().IsUninitialized() && |
993 value()->type().IsString()) { | 937 value()->type().IsString()) { |
994 return NULL; | 938 return NULL; |
995 } | 939 } |
996 if (check_ == IS_SYMBOL && | 940 if (check_ == IS_SYMBOL && |
997 value()->IsConstant() && | 941 value()->IsConstant() && |
998 HConstant::cast(value())->handle()->IsSymbol()) { | 942 HConstant::cast(value())->handle()->IsSymbol()) { |
999 return NULL; | 943 return NULL; |
(...skipping 1426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2426 | 2370 |
2427 | 2371 |
2428 void HCheckPrototypeMaps::Verify() { | 2372 void HCheckPrototypeMaps::Verify() { |
2429 HInstruction::Verify(); | 2373 HInstruction::Verify(); |
2430 ASSERT(HasNoUses()); | 2374 ASSERT(HasNoUses()); |
2431 } | 2375 } |
2432 | 2376 |
2433 #endif | 2377 #endif |
2434 | 2378 |
2435 } } // namespace v8::internal | 2379 } } // namespace v8::internal |
OLD | NEW |