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 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
820 // Verify that all uses are in the graph. | 820 // Verify that all uses are in the graph. |
821 for (HUseIterator use = uses(); !use.Done(); use.Advance()) { | 821 for (HUseIterator use = uses(); !use.Done(); use.Advance()) { |
822 if (use.value()->IsInstruction()) { | 822 if (use.value()->IsInstruction()) { |
823 ASSERT(HInstruction::cast(use.value())->IsLinked()); | 823 ASSERT(HInstruction::cast(use.value())->IsLinked()); |
824 } | 824 } |
825 } | 825 } |
826 } | 826 } |
827 #endif | 827 #endif |
828 | 828 |
829 | 829 |
830 static bool HasPrimitiveRepresentation(HValue* instr) { | |
831 return instr->representation().IsInteger32() || | |
832 instr->representation().IsDouble(); | |
833 } | |
834 | |
835 | |
836 bool HInstruction::CanDeoptimize() { | |
837 // TODO(titzer): make this a virtual method? | |
Hannes Payer (out of office)
2014/02/05 14:44:46
I would prefer having a virtual method, but I leav
| |
838 switch (opcode()) { | |
839 case HValue::kAccessArgumentsAt: | |
840 case HValue::kApplyArguments: | |
841 case HValue::kArgumentsElements: | |
842 case HValue::kArgumentsLength: | |
843 case HValue::kArgumentsObject: | |
844 case HValue::kBoundsCheckBaseIndexInformation: | |
845 case HValue::kCapturedObject: | |
846 case HValue::kClampToUint8: | |
847 case HValue::kConstant: | |
848 case HValue::kContext: | |
849 case HValue::kDateField: | |
850 case HValue::kDebugBreak: | |
851 case HValue::kDeclareGlobals: | |
852 case HValue::kDiv: | |
Sven Panne
2014/03/25 09:16:15
Hmmm, div and mod *can* deoptimize in general, hav
| |
853 case HValue::kDummyUse: | |
854 case HValue::kEnterInlined: | |
855 case HValue::kEnvironmentMarker: | |
856 case HValue::kForInCacheArray: | |
857 case HValue::kForInPrepareMap: | |
858 case HValue::kFunctionLiteral: | |
859 case HValue::kGetCachedArrayIndex: | |
860 case HValue::kGoto: | |
861 case HValue::kInnerAllocatedObject: | |
862 case HValue::kInstanceOf: | |
863 case HValue::kInstanceOfKnownGlobal: | |
864 case HValue::kInvokeFunction: | |
865 case HValue::kLeaveInlined: | |
866 case HValue::kLoadContextSlot: | |
867 case HValue::kLoadFieldByIndex: | |
868 case HValue::kLoadFunctionPrototype: | |
869 case HValue::kLoadGlobalCell: | |
870 case HValue::kLoadGlobalGeneric: | |
871 case HValue::kLoadKeyed: | |
872 case HValue::kLoadKeyedGeneric: | |
873 case HValue::kLoadNamedField: | |
874 case HValue::kLoadNamedGeneric: | |
875 case HValue::kLoadRoot: | |
876 case HValue::kMapEnumLength: | |
877 case HValue::kMathFloorOfDiv: | |
878 case HValue::kMathMinMax: | |
879 case HValue::kMod: | |
880 case HValue::kMul: | |
881 case HValue::kOsrEntry: | |
882 case HValue::kParameter: | |
883 case HValue::kPower: | |
884 case HValue::kPushArgument: | |
885 case HValue::kRor: | |
886 case HValue::kSar: | |
887 case HValue::kSeqStringGetChar: | |
888 case HValue::kSeqStringSetChar: | |
889 case HValue::kShl: | |
890 case HValue::kShr: | |
891 case HValue::kSimulate: | |
892 case HValue::kStackCheck: | |
893 case HValue::kStoreCodeEntry: | |
894 case HValue::kStoreContextSlot: | |
895 case HValue::kStoreGlobalCell: | |
896 case HValue::kStoreKeyed: | |
897 case HValue::kStoreKeyedGeneric: | |
898 case HValue::kStoreNamedField: | |
899 case HValue::kStoreNamedGeneric: | |
900 case HValue::kStringAdd: | |
901 case HValue::kStringCharCodeAt: | |
902 case HValue::kStringCharFromCode: | |
903 case HValue::kSub: | |
904 case HValue::kThisFunction: | |
905 case HValue::kToFastProperties: | |
906 case HValue::kTransitionElementsKind: | |
907 case HValue::kTrapAllocationMemento: | |
908 case HValue::kTypeof: | |
909 case HValue::kUnaryMathOperation: | |
910 case HValue::kUseConst: | |
911 case HValue::kWrapReceiver: | |
912 return false; | |
913 case HValue::kForceRepresentation: | |
914 case HValue::kAdd: | |
915 case HValue::kBitwise: | |
916 case HValue::kChange: | |
917 case HValue::kCompareGeneric: | |
918 // These instructions might deoptimize if they are not primitive. | |
919 if (!HasPrimitiveRepresentation(this)) return true; | |
920 for (int i = 0; i < OperandCount(); i++) { | |
921 HValue* input = OperandAt(i); | |
922 if (!HasPrimitiveRepresentation(input)) return true; | |
923 } | |
924 return false; | |
925 default: | |
926 return true; | |
927 } | |
928 } | |
929 | |
930 | |
830 void HDummyUse::PrintDataTo(StringStream* stream) { | 931 void HDummyUse::PrintDataTo(StringStream* stream) { |
831 value()->PrintNameTo(stream); | 932 value()->PrintNameTo(stream); |
832 } | 933 } |
833 | 934 |
834 | 935 |
835 void HEnvironmentMarker::PrintDataTo(StringStream* stream) { | 936 void HEnvironmentMarker::PrintDataTo(StringStream* stream) { |
836 stream->Add("%s var[%d]", kind() == BIND ? "bind" : "lookup", index()); | 937 stream->Add("%s var[%d]", kind() == BIND ? "bind" : "lookup", index()); |
837 } | 938 } |
838 | 939 |
839 | 940 |
(...skipping 3611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4451 break; | 4552 break; |
4452 case kExternalMemory: | 4553 case kExternalMemory: |
4453 stream->Add("[external-memory]"); | 4554 stream->Add("[external-memory]"); |
4454 break; | 4555 break; |
4455 } | 4556 } |
4456 | 4557 |
4457 stream->Add("@%d", offset()); | 4558 stream->Add("@%d", offset()); |
4458 } | 4559 } |
4459 | 4560 |
4460 } } // namespace v8::internal | 4561 } } // namespace v8::internal |
OLD | NEW |