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