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

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
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 898 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 } 909 }
910 910
911 911
912 void HJSArrayLength::PrintDataTo(StringStream* stream) { 912 void HJSArrayLength::PrintDataTo(StringStream* stream) {
913 value()->PrintNameTo(stream); 913 value()->PrintNameTo(stream);
914 stream->Add(" "); 914 stream->Add(" ");
915 typecheck()->PrintNameTo(stream); 915 typecheck()->PrintNameTo(stream);
916 } 916 }
917 917
918 918
919 HValue* HUnaryMathOperation::Canonicalize() {
920 if (op() == kMathFloor) {
921 // If the input is integer32 then we replace the floor instruction
922 // with its input. This happens before the representation changes are
923 // introduced.
924 if (value()->representation().IsInteger32()) return value();
925
926 #ifdef V8_TARGET_ARCH_ARM
927 if (value()->IsDiv() && (value()->UseCount() == 1)) {
928 // TODO(2038): Implement this optimization for non ARM architectures.
929 HDiv* hdiv = HDiv::cast(value());
930 HValue* left = hdiv->left();
931 HValue* right = hdiv->right();
932 // Try to simplify left and right values of the division.
933 HValue* new_left =
934 LChunkBuilder::SimplifiedDividendForMathFloorOfDiv(left);
935 HValue* new_right =
936 LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(right);
937
938 // Return if left or right are not optimizable.
939 if ((new_left == NULL) || (new_right == NULL)) return this;
940
941 // Insert the new values in the graph.
942 if (new_left->IsInstruction() &&
943 !HInstruction::cast(new_left)->IsLinked()) {
944 HInstruction::cast(new_left)->InsertBefore(this);
945 }
946 if (new_right->IsInstruction() &&
947 !HInstruction::cast(new_right)->IsLinked()) {
948 HInstruction::cast(new_right)->InsertBefore(this);
949 }
950 HMathFloorOfDiv* instr = new HMathFloorOfDiv(context(),
951 new_left,
952 new_right);
953 // Replace this HMathFloor instruction by the new HMathFloorOfDiv.
954 instr->InsertBefore(this);
955 ReplaceAllUsesWith(instr);
956 Kill();
957 // We know the division had no other uses than this HMathFloor. Delete it.
958 // Also delete the arguments of the division if they are not used any
959 // more.
960 hdiv->DeleteAndReplaceWith(NULL);
961 ASSERT(left->IsChange() || left->IsConstant());
962 ASSERT(right->IsChange() || right->IsConstant());
963 if (left->HasNoUses()) left->DeleteAndReplaceWith(NULL);
964 if (right->HasNoUses()) right->DeleteAndReplaceWith(NULL);
965
966 // Return NULL to remove this instruction from the graph.
967 return NULL;
968 }
969 #endif // V8_TARGET_ARCH_ARM
970 }
971 return this;
972 }
973
974
919 HValue* HCheckInstanceType::Canonicalize() { 975 HValue* HCheckInstanceType::Canonicalize() {
920 if (check_ == IS_STRING && 976 if (check_ == IS_STRING &&
921 !value()->type().IsUninitialized() && 977 !value()->type().IsUninitialized() &&
922 value()->type().IsString()) { 978 value()->type().IsString()) {
923 return NULL; 979 return NULL;
924 } 980 }
925 if (check_ == IS_SYMBOL && 981 if (check_ == IS_SYMBOL &&
926 value()->IsConstant() && 982 value()->IsConstant() &&
927 HConstant::cast(value())->handle()->IsSymbol()) { 983 HConstant::cast(value())->handle()->IsSymbol()) {
928 return NULL; 984 return NULL;
(...skipping 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after
2334 2390
2335 2391
2336 void HCheckPrototypeMaps::Verify() { 2392 void HCheckPrototypeMaps::Verify() {
2337 HInstruction::Verify(); 2393 HInstruction::Verify();
2338 ASSERT(HasNoUses()); 2394 ASSERT(HasNoUses());
2339 } 2395 }
2340 2396
2341 #endif 2397 #endif
2342 2398
2343 } } // namespace v8::internal 2399 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698