Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: src/hydrogen-instructions.cc

Issue 9638018: [v8-dev] Optimise Math.floor(x/y) to use integer division for specific divisor.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/hydrogen-instructions.h ('k') | src/ia32/lithium-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
934 HValue* HCheckInstanceType::Canonicalize() { 990 HValue* HCheckInstanceType::Canonicalize() {
935 if (check_ == IS_STRING && 991 if (check_ == IS_STRING &&
936 !value()->type().IsUninitialized() && 992 !value()->type().IsUninitialized() &&
937 value()->type().IsString()) { 993 value()->type().IsString()) {
938 return NULL; 994 return NULL;
939 } 995 }
940 if (check_ == IS_SYMBOL && 996 if (check_ == IS_SYMBOL &&
941 value()->IsConstant() && 997 value()->IsConstant() &&
942 HConstant::cast(value())->handle()->IsSymbol()) { 998 HConstant::cast(value())->handle()->IsSymbol()) {
943 return NULL; 999 return NULL;
(...skipping 1426 matching lines...) Expand 10 before | Expand all | Expand 10 after
2370 2426
2371 2427
2372 void HCheckPrototypeMaps::Verify() { 2428 void HCheckPrototypeMaps::Verify() {
2373 HInstruction::Verify(); 2429 HInstruction::Verify();
2374 ASSERT(HasNoUses()); 2430 ASSERT(HasNoUses());
2375 } 2431 }
2376 2432
2377 #endif 2433 #endif
2378 2434
2379 } } // namespace v8::internal 2435 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen-instructions.h ('k') | src/ia32/lithium-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698