OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_FULL_CODEGEN_H_ | 5 #ifndef V8_FULL_CODEGEN_H_ |
6 #define V8_FULL_CODEGEN_H_ | 6 #define V8_FULL_CODEGEN_H_ |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 872 matching lines...) Loading... |
883 Address pc(uint32_t index) { | 883 Address pc(uint32_t index) { |
884 return instruction_start_ + pc_offset(index); | 884 return instruction_start_ + pc_offset(index); |
885 } | 885 } |
886 | 886 |
887 enum BackEdgeState { | 887 enum BackEdgeState { |
888 INTERRUPT, | 888 INTERRUPT, |
889 ON_STACK_REPLACEMENT, | 889 ON_STACK_REPLACEMENT, |
890 OSR_AFTER_STACK_CHECK | 890 OSR_AFTER_STACK_CHECK |
891 }; | 891 }; |
892 | 892 |
893 // Patch all interrupts with allowed loop depth in the unoptimized code to | 893 // Increase allowed loop nesting level by one and patch those matching loops. |
894 // unconditionally call replacement_code. | 894 static void Patch(Isolate* isolate, Code* unoptimized_code); |
895 static void Patch(Isolate* isolate, | |
896 Code* unoptimized_code); | |
897 | 895 |
898 // Patch the back edge to the target state, provided the correct callee. | 896 // Patch the back edge to the target state, provided the correct callee. |
899 static void PatchAt(Code* unoptimized_code, | 897 static void PatchAt(Code* unoptimized_code, |
900 Address pc, | 898 Address pc, |
901 BackEdgeState target_state, | 899 BackEdgeState target_state, |
902 Code* replacement_code); | 900 Code* replacement_code); |
903 | 901 |
904 // Change all patched back edges back to normal interrupts. | 902 // Change all patched back edges back to normal interrupts. |
905 static void Revert(Isolate* isolate, | 903 static void Revert(Isolate* isolate, |
906 Code* unoptimized_code); | 904 Code* unoptimized_code); |
907 | 905 |
908 // Change a back edge patched for on-stack replacement to perform a | 906 // Change a back edge patched for on-stack replacement to perform a |
909 // stack check first. | 907 // stack check first. |
910 static void AddStackCheck(Handle<Code> code, uint32_t pc_offset); | 908 static void AddStackCheck(Handle<Code> code, uint32_t pc_offset); |
911 | 909 |
912 // Revert the patch by AddStackCheck. | 910 // Revert the patch by AddStackCheck. |
913 static void RemoveStackCheck(Handle<Code> code, uint32_t pc_offset); | 911 static void RemoveStackCheck(Handle<Code> code, uint32_t pc_offset); |
914 | 912 |
915 // Return the current patch state of the back edge. | 913 // Return the current patch state of the back edge. |
916 static BackEdgeState GetBackEdgeState(Isolate* isolate, | 914 static BackEdgeState GetBackEdgeState(Isolate* isolate, |
917 Code* unoptimized_code, | 915 Code* unoptimized_code, |
918 Address pc_after); | 916 Address pc_after); |
919 | 917 |
920 #ifdef DEBUG | 918 #ifdef DEBUG |
921 // Verify that all back edges of a certain loop depth are patched. | 919 // Verify that all back edges of a certain loop depth are patched. |
922 static bool Verify(Isolate* isolate, | 920 static bool Verify(Isolate* isolate, Code* unoptimized_code); |
923 Code* unoptimized_code, | |
924 int loop_nesting_level); | |
925 #endif // DEBUG | 921 #endif // DEBUG |
926 | 922 |
927 private: | 923 private: |
928 Address entry_at(uint32_t index) { | 924 Address entry_at(uint32_t index) { |
929 ASSERT(index < length_); | 925 ASSERT(index < length_); |
930 return start_ + index * kEntrySize; | 926 return start_ + index * kEntrySize; |
931 } | 927 } |
932 | 928 |
933 static const int kTableLengthSize = kIntSize; | 929 static const int kTableLengthSize = kIntSize; |
934 static const int kAstIdOffset = 0 * kIntSize; | 930 static const int kAstIdOffset = 0 * kIntSize; |
935 static const int kPcOffsetOffset = 1 * kIntSize; | 931 static const int kPcOffsetOffset = 1 * kIntSize; |
936 static const int kLoopDepthOffset = 2 * kIntSize; | 932 static const int kLoopDepthOffset = 2 * kIntSize; |
937 static const int kEntrySize = 3 * kIntSize; | 933 static const int kEntrySize = 3 * kIntSize; |
938 | 934 |
939 Address start_; | 935 Address start_; |
940 Address instruction_start_; | 936 Address instruction_start_; |
941 uint32_t length_; | 937 uint32_t length_; |
942 }; | 938 }; |
943 | 939 |
944 | 940 |
945 } } // namespace v8::internal | 941 } } // namespace v8::internal |
946 | 942 |
947 #endif // V8_FULL_CODEGEN_H_ | 943 #endif // V8_FULL_CODEGEN_H_ |
OLD | NEW |