| 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 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 uint32_t pc_offset(uint32_t index) { | 905 uint32_t pc_offset(uint32_t index) { |
| 906 return Memory::uint32_at(entry_at(index) + kPcOffsetOffset); | 906 return Memory::uint32_at(entry_at(index) + kPcOffsetOffset); |
| 907 } | 907 } |
| 908 | 908 |
| 909 Address pc(uint32_t index) { | 909 Address pc(uint32_t index) { |
| 910 return instruction_start_ + pc_offset(index); | 910 return instruction_start_ + pc_offset(index); |
| 911 } | 911 } |
| 912 | 912 |
| 913 enum BackEdgeState { | 913 enum BackEdgeState { |
| 914 INTERRUPT, | 914 INTERRUPT, |
| 915 ON_STACK_REPLACEMENT | 915 ON_STACK_REPLACEMENT, |
| 916 OSR_AFTER_STACK_CHECK |
| 916 }; | 917 }; |
| 917 | 918 |
| 918 // Patch all interrupts with allowed loop depth in the unoptimized code to | 919 // Patch all interrupts with allowed loop depth in the unoptimized code to |
| 919 // unconditionally call replacement_code. | 920 // unconditionally call replacement_code. |
| 920 static void Patch(Isolate* isolate, | 921 static void Patch(Isolate* isolate, |
| 921 Code* unoptimized_code); | 922 Code* unoptimized_code); |
| 922 | 923 |
| 923 // Patch the interrupt at the instruction before pc_after in | 924 // Patch the back edge to the target state, provided the correct callee. |
| 924 // the unoptimized code to unconditionally call replacement_code. | |
| 925 static void PatchAt(Code* unoptimized_code, | 925 static void PatchAt(Code* unoptimized_code, |
| 926 Address pc_after, | 926 Address pc, |
| 927 BackEdgeState target_state, |
| 927 Code* replacement_code); | 928 Code* replacement_code); |
| 928 | 929 |
| 929 // Change all patched interrupts patched in the unoptimized code | 930 // Change all patched back edges back to normal interrupts. |
| 930 // back to normal interrupts. | |
| 931 static void Revert(Isolate* isolate, | 931 static void Revert(Isolate* isolate, |
| 932 Code* unoptimized_code); | 932 Code* unoptimized_code); |
| 933 | 933 |
| 934 // Change patched interrupt in the unoptimized code | 934 // Change a back edge patched for on-stack replacement to perform a |
| 935 // back to a normal interrupt. | 935 // stack check first. |
| 936 static void RevertAt(Code* unoptimized_code, | 936 static void AddStackCheck(CompilationInfo* info); |
| 937 Address pc_after, | |
| 938 Code* interrupt_code); | |
| 939 | 937 |
| 940 #ifdef DEBUG | 938 // Remove the stack check, if available, and replace by on-stack replacement. |
| 939 static void RemoveStackCheck(CompilationInfo* info); |
| 940 |
| 941 // Return the current patch state of the back edge. |
| 941 static BackEdgeState GetBackEdgeState(Isolate* isolate, | 942 static BackEdgeState GetBackEdgeState(Isolate* isolate, |
| 942 Code* unoptimized_code, | 943 Code* unoptimized_code, |
| 943 Address pc_after); | 944 Address pc_after); |
| 944 | 945 |
| 946 #ifdef DEBUG |
| 945 // Verify that all back edges of a certain loop depth are patched. | 947 // Verify that all back edges of a certain loop depth are patched. |
| 946 static bool Verify(Isolate* isolate, | 948 static bool Verify(Isolate* isolate, |
| 947 Code* unoptimized_code, | 949 Code* unoptimized_code, |
| 948 int loop_nesting_level); | 950 int loop_nesting_level); |
| 949 #endif // DEBUG | 951 #endif // DEBUG |
| 950 | 952 |
| 951 private: | 953 private: |
| 952 Address entry_at(uint32_t index) { | 954 Address entry_at(uint32_t index) { |
| 953 ASSERT(index < length_); | 955 ASSERT(index < length_); |
| 954 return start_ + index * kEntrySize; | 956 return start_ + index * kEntrySize; |
| 955 } | 957 } |
| 956 | 958 |
| 957 static const int kTableLengthSize = kIntSize; | 959 static const int kTableLengthSize = kIntSize; |
| 958 static const int kAstIdOffset = 0 * kIntSize; | 960 static const int kAstIdOffset = 0 * kIntSize; |
| 959 static const int kPcOffsetOffset = 1 * kIntSize; | 961 static const int kPcOffsetOffset = 1 * kIntSize; |
| 960 static const int kLoopDepthOffset = 2 * kIntSize; | 962 static const int kLoopDepthOffset = 2 * kIntSize; |
| 961 static const int kEntrySize = 3 * kIntSize; | 963 static const int kEntrySize = 3 * kIntSize; |
| 962 | 964 |
| 963 Address start_; | 965 Address start_; |
| 964 Address instruction_start_; | 966 Address instruction_start_; |
| 965 uint32_t length_; | 967 uint32_t length_; |
| 966 }; | 968 }; |
| 967 | 969 |
| 968 | 970 |
| 969 } } // namespace v8::internal | 971 } } // namespace v8::internal |
| 970 | 972 |
| 971 #endif // V8_FULL_CODEGEN_H_ | 973 #endif // V8_FULL_CODEGEN_H_ |
| OLD | NEW |