Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 11 matching lines...) Expand all Loading... | |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_ARM_MACRO_ASSEMBLER_ARM_H_ | 28 #ifndef V8_ARM_MACRO_ASSEMBLER_ARM_H_ |
| 29 #define V8_ARM_MACRO_ASSEMBLER_ARM_H_ | 29 #define V8_ARM_MACRO_ASSEMBLER_ARM_H_ |
| 30 | 30 |
| 31 #include "assembler.h" | 31 #include "assembler.h" |
| 32 #include "frames.h" | |
| 32 #include "v8globals.h" | 33 #include "v8globals.h" |
| 33 | 34 |
| 34 namespace v8 { | 35 namespace v8 { |
| 35 namespace internal { | 36 namespace internal { |
| 36 | 37 |
| 37 // ---------------------------------------------------------------------------- | 38 // ---------------------------------------------------------------------------- |
| 38 // Static helper functions | 39 // Static helper functions |
| 39 | 40 |
| 40 // Generate a MemOperand for loading a field from an object. | 41 // Generate a MemOperand for loading a field from an object. |
| 41 static inline MemOperand FieldMemOperand(Register object, int offset) { | 42 static inline MemOperand FieldMemOperand(Register object, int offset) { |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 304 // Compare double values and then load the fpscr flags to a register. | 305 // Compare double values and then load the fpscr flags to a register. |
| 305 void VFPCompareAndLoadFlags(const DwVfpRegister src1, | 306 void VFPCompareAndLoadFlags(const DwVfpRegister src1, |
| 306 const DwVfpRegister src2, | 307 const DwVfpRegister src2, |
| 307 const Register fpscr_flags, | 308 const Register fpscr_flags, |
| 308 const Condition cond = al); | 309 const Condition cond = al); |
| 309 void VFPCompareAndLoadFlags(const DwVfpRegister src1, | 310 void VFPCompareAndLoadFlags(const DwVfpRegister src1, |
| 310 const double src2, | 311 const double src2, |
| 311 const Register fpscr_flags, | 312 const Register fpscr_flags, |
| 312 const Condition cond = al); | 313 const Condition cond = al); |
| 313 | 314 |
| 314 | |
| 315 // --------------------------------------------------------------------------- | |
| 316 // Activation frames | |
| 317 | |
| 318 void EnterInternalFrame() { EnterFrame(StackFrame::INTERNAL); } | |
| 319 void LeaveInternalFrame() { LeaveFrame(StackFrame::INTERNAL); } | |
| 320 | |
| 321 void EnterConstructFrame() { EnterFrame(StackFrame::CONSTRUCT); } | |
| 322 void LeaveConstructFrame() { LeaveFrame(StackFrame::CONSTRUCT); } | |
| 323 | |
| 324 // Enter exit frame. | 315 // Enter exit frame. |
| 325 // stack_space - extra stack space, used for alignment before call to C. | 316 // stack_space - extra stack space, used for alignment before call to C. |
| 326 void EnterExitFrame(bool save_doubles, int stack_space = 0); | 317 void EnterExitFrame(bool save_doubles, int stack_space = 0); |
| 327 | 318 |
| 328 // Leave the current exit frame. Expects the return value in r0. | 319 // Leave the current exit frame. Expects the return value in r0. |
| 329 // Expect the number of values, pushed prior to the exit frame, to | 320 // Expect the number of values, pushed prior to the exit frame, to |
| 330 // remove in a register (or no_reg, if there is nothing to remove). | 321 // remove in a register (or no_reg, if there is nothing to remove). |
| 331 void LeaveExitFrame(bool save_doubles, Register argument_count); | 322 void LeaveExitFrame(bool save_doubles, Register argument_count); |
| 332 | 323 |
| 333 // Get the actual activation frame alignment for target environment. | 324 // Get the actual activation frame alignment for target environment. |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 864 void Check(Condition cond, const char* msg); | 855 void Check(Condition cond, const char* msg); |
| 865 | 856 |
| 866 // Print a message to stdout and abort execution. | 857 // Print a message to stdout and abort execution. |
| 867 void Abort(const char* msg); | 858 void Abort(const char* msg); |
| 868 | 859 |
| 869 // Verify restrictions about code generated in stubs. | 860 // Verify restrictions about code generated in stubs. |
| 870 void set_generating_stub(bool value) { generating_stub_ = value; } | 861 void set_generating_stub(bool value) { generating_stub_ = value; } |
| 871 bool generating_stub() { return generating_stub_; } | 862 bool generating_stub() { return generating_stub_; } |
| 872 void set_allow_stub_calls(bool value) { allow_stub_calls_ = value; } | 863 void set_allow_stub_calls(bool value) { allow_stub_calls_ = value; } |
| 873 bool allow_stub_calls() { return allow_stub_calls_; } | 864 bool allow_stub_calls() { return allow_stub_calls_; } |
| 865 void set_has_frame(bool value) { has_frame_ = value; } | |
| 866 bool has_frame() { return has_frame_; } | |
| 867 inline bool AllowThisStubCall(CodeStub* stub); | |
| 874 | 868 |
| 875 // EABI variant for double arguments in use. | 869 // EABI variant for double arguments in use. |
| 876 bool use_eabi_hardfloat() { | 870 bool use_eabi_hardfloat() { |
| 877 #if USE_EABI_HARDFLOAT | 871 #if USE_EABI_HARDFLOAT |
| 878 return true; | 872 return true; |
| 879 #else | 873 #else |
| 880 return false; | 874 return false; |
| 881 #endif | 875 #endif |
| 882 } | 876 } |
| 883 | 877 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1010 | 1004 |
| 1011 void ClampUint8(Register output_reg, Register input_reg); | 1005 void ClampUint8(Register output_reg, Register input_reg); |
| 1012 | 1006 |
| 1013 void ClampDoubleToUint8(Register result_reg, | 1007 void ClampDoubleToUint8(Register result_reg, |
| 1014 DoubleRegister input_reg, | 1008 DoubleRegister input_reg, |
| 1015 DoubleRegister temp_double_reg); | 1009 DoubleRegister temp_double_reg); |
| 1016 | 1010 |
| 1017 | 1011 |
| 1018 void LoadInstanceDescriptors(Register map, Register descriptors); | 1012 void LoadInstanceDescriptors(Register map, Register descriptors); |
| 1019 | 1013 |
| 1014 // Activation support. | |
| 1015 void EnterFrame(StackFrame::Type type); | |
| 1016 void LeaveFrame(StackFrame::Type type); | |
| 1017 | |
| 1020 private: | 1018 private: |
| 1021 void CallCFunctionHelper(Register function, | 1019 void CallCFunctionHelper(Register function, |
| 1022 ExternalReference function_reference, | 1020 ExternalReference function_reference, |
| 1023 Register scratch, | 1021 Register scratch, |
| 1024 int num_reg_arguments, | 1022 int num_reg_arguments, |
| 1025 int num_double_arguments); | 1023 int num_double_arguments); |
| 1026 | 1024 |
| 1027 void Jump(intptr_t target, RelocInfo::Mode rmode, Condition cond = al); | 1025 void Jump(intptr_t target, RelocInfo::Mode rmode, Condition cond = al); |
| 1028 int CallSize(intptr_t target, RelocInfo::Mode rmode, Condition cond = al); | 1026 int CallSize(intptr_t target, RelocInfo::Mode rmode, Condition cond = al); |
| 1029 void Call(intptr_t target, | 1027 void Call(intptr_t target, |
| 1030 RelocInfo::Mode rmode, | 1028 RelocInfo::Mode rmode, |
| 1031 Condition cond = al); | 1029 Condition cond = al); |
| 1032 | 1030 |
| 1033 // Helper functions for generating invokes. | 1031 // Helper functions for generating invokes. |
| 1034 void InvokePrologue(const ParameterCount& expected, | 1032 void InvokePrologue(const ParameterCount& expected, |
| 1035 const ParameterCount& actual, | 1033 const ParameterCount& actual, |
| 1036 Handle<Code> code_constant, | 1034 Handle<Code> code_constant, |
| 1037 Register code_reg, | 1035 Register code_reg, |
| 1038 Label* done, | 1036 Label* done, |
| 1039 InvokeFlag flag, | 1037 InvokeFlag flag, |
| 1040 const CallWrapper& call_wrapper, | 1038 const CallWrapper& call_wrapper, |
| 1041 CallKind call_kind); | 1039 CallKind call_kind); |
| 1042 | 1040 |
| 1043 // Activation support. | |
| 1044 void EnterFrame(StackFrame::Type type); | |
| 1045 void LeaveFrame(StackFrame::Type type); | |
| 1046 | |
| 1047 void InitializeNewString(Register string, | 1041 void InitializeNewString(Register string, |
| 1048 Register length, | 1042 Register length, |
| 1049 Heap::RootListIndex map_index, | 1043 Heap::RootListIndex map_index, |
| 1050 Register scratch1, | 1044 Register scratch1, |
| 1051 Register scratch2); | 1045 Register scratch2); |
| 1052 | 1046 |
| 1053 // Compute memory operands for safepoint stack slots. | 1047 // Compute memory operands for safepoint stack slots. |
| 1054 static int SafepointRegisterStackIndex(int reg_code); | 1048 static int SafepointRegisterStackIndex(int reg_code); |
| 1055 MemOperand SafepointRegisterSlot(Register reg); | 1049 MemOperand SafepointRegisterSlot(Register reg); |
| 1056 MemOperand SafepointRegistersAndDoublesSlot(Register reg); | 1050 MemOperand SafepointRegistersAndDoublesSlot(Register reg); |
| 1057 | 1051 |
| 1058 bool generating_stub_; | 1052 bool generating_stub_; |
| 1059 bool allow_stub_calls_; | 1053 bool allow_stub_calls_; |
| 1054 bool has_frame_; | |
| 1060 // This handle will be patched with the code object on installation. | 1055 // This handle will be patched with the code object on installation. |
| 1061 Handle<Object> code_object_; | 1056 Handle<Object> code_object_; |
| 1062 | 1057 |
| 1063 // Needs access to SafepointRegisterStackIndex for optimized frame | 1058 // Needs access to SafepointRegisterStackIndex for optimized frame |
| 1064 // traversal. | 1059 // traversal. |
| 1065 friend class OptimizedFrame; | 1060 friend class OptimizedFrame; |
| 1066 }; | 1061 }; |
| 1067 | 1062 |
| 1068 | 1063 |
|
Søren Thygesen Gjesse
2011/05/31 07:51:45
Can these two classes be in platform independent m
Erik Corry
2011/05/31 11:52:52
Done.
| |
| 1064 class FrameScope { | |
| 1065 public: | |
| 1066 explicit FrameScope(MacroAssembler* masm, StackFrame::Type type) | |
| 1067 : masm_(masm), type_(type) { | |
| 1068 ASSERT(!masm->has_frame()); | |
| 1069 masm->set_has_frame(true); | |
| 1070 if (type != StackFrame::NONE) { | |
| 1071 masm->EnterFrame(type); | |
| 1072 } | |
| 1073 } | |
| 1074 | |
| 1075 ~FrameScope() { | |
| 1076 if (type_ != StackFrame::NONE) { | |
| 1077 masm_->LeaveFrame(type_); | |
| 1078 } | |
| 1079 masm_->set_has_frame(false); | |
| 1080 } | |
| 1081 | |
| 1082 // Normally we generate the leave-frame code when this object goes | |
| 1083 // out of scope. Sometimes we may need to generate the code somewhere else | |
| 1084 // in addition. Calling this will achieve that, but the object stays in | |
| 1085 // scope, the MacroAssembler is still marked as being in a frame scope, and | |
| 1086 // the code will be generated again when it goes out of scope. | |
| 1087 void GenerateLeaveFrame() { | |
| 1088 masm_->LeaveFrame(type_); | |
| 1089 } | |
| 1090 | |
| 1091 private: | |
| 1092 MacroAssembler* masm_; | |
| 1093 StackFrame::Type type_; | |
| 1094 }; | |
| 1095 | |
| 1096 | |
| 1097 class NoCurrentFrameScope { | |
| 1098 public: | |
| 1099 explicit NoCurrentFrameScope(MacroAssembler* masm) | |
| 1100 : masm_(masm), saved_(masm->has_frame()) { | |
| 1101 masm->set_has_frame(false); | |
| 1102 } | |
| 1103 | |
| 1104 ~NoCurrentFrameScope() { | |
| 1105 masm_->set_has_frame(saved_); | |
| 1106 } | |
| 1107 | |
| 1108 private: | |
| 1109 MacroAssembler* masm_; | |
| 1110 bool saved_; | |
| 1111 }; | |
| 1112 | |
| 1113 | |
| 1069 #ifdef ENABLE_DEBUGGER_SUPPORT | 1114 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 1070 // The code patcher is used to patch (typically) small parts of code e.g. for | 1115 // The code patcher is used to patch (typically) small parts of code e.g. for |
| 1071 // debugging and other types of instrumentation. When using the code patcher | 1116 // debugging and other types of instrumentation. When using the code patcher |
| 1072 // the exact number of bytes specified must be emitted. It is not legal to emit | 1117 // the exact number of bytes specified must be emitted. It is not legal to emit |
| 1073 // relocation information. If any of these constraints are violated it causes | 1118 // relocation information. If any of these constraints are violated it causes |
| 1074 // an assertion to fail. | 1119 // an assertion to fail. |
| 1075 class CodePatcher { | 1120 class CodePatcher { |
| 1076 public: | 1121 public: |
| 1077 CodePatcher(byte* address, int instructions); | 1122 CodePatcher(byte* address, int instructions); |
| 1078 virtual ~CodePatcher(); | 1123 virtual ~CodePatcher(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1118 #define __FILE_LINE__ __FILE__ ":" CODE_COVERAGE_TOSTRING(__LINE__) | 1163 #define __FILE_LINE__ __FILE__ ":" CODE_COVERAGE_TOSTRING(__LINE__) |
| 1119 #define ACCESS_MASM(masm) masm->stop(__FILE_LINE__); masm-> | 1164 #define ACCESS_MASM(masm) masm->stop(__FILE_LINE__); masm-> |
| 1120 #else | 1165 #else |
| 1121 #define ACCESS_MASM(masm) masm-> | 1166 #define ACCESS_MASM(masm) masm-> |
| 1122 #endif | 1167 #endif |
| 1123 | 1168 |
| 1124 | 1169 |
| 1125 } } // namespace v8::internal | 1170 } } // namespace v8::internal |
| 1126 | 1171 |
| 1127 #endif // V8_ARM_MACRO_ASSEMBLER_ARM_H_ | 1172 #endif // V8_ARM_MACRO_ASSEMBLER_ARM_H_ |
| OLD | NEW |