OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 ASSERT(top_ != NULL); | 173 ASSERT(top_ != NULL); |
174 return top_; | 174 return top_; |
175 } | 175 } |
176 | 176 |
177 private: | 177 private: |
178 static CodeGenerator* top_; | 178 static CodeGenerator* top_; |
179 CodeGenerator* previous_; | 179 CodeGenerator* previous_; |
180 }; | 180 }; |
181 | 181 |
182 | 182 |
| 183 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64 |
| 184 |
183 // State of used registers in a virtual frame. | 185 // State of used registers in a virtual frame. |
184 class FrameRegisterState { | 186 class FrameRegisterState { |
185 public: | 187 public: |
186 // Captures the current state of the given frame. | 188 // Captures the current state of the given frame. |
187 explicit FrameRegisterState(VirtualFrame* frame); | 189 explicit FrameRegisterState(VirtualFrame* frame); |
188 | 190 |
189 // Saves the state in the stack. | 191 // Saves the state in the stack. |
190 void Save(MacroAssembler* masm) const; | 192 void Save(MacroAssembler* masm) const; |
191 | 193 |
192 // Restores the state from the stack. | 194 // Restores the state from the stack. |
193 void Restore(MacroAssembler* masm) const; | 195 void Restore(MacroAssembler* masm) const; |
194 | 196 |
195 private: | 197 private: |
196 // Constants indicating special actions. They should not be multiples | 198 // Constants indicating special actions. They should not be multiples |
197 // of kPointerSize so they will not collide with valid offsets from | 199 // of kPointerSize so they will not collide with valid offsets from |
198 // the frame pointer. | 200 // the frame pointer. |
199 static const int kIgnore = -1; | 201 static const int kIgnore = -1; |
200 static const int kPush = 1; | 202 static const int kPush = 1; |
201 | 203 |
202 // This flag is ored with a valid offset from the frame pointer, so | 204 // This flag is ored with a valid offset from the frame pointer, so |
203 // it should fit in the low zero bits of a valid offset. | 205 // it should fit in the low zero bits of a valid offset. |
204 static const int kSyncedFlag = 2; | 206 static const int kSyncedFlag = 2; |
205 | 207 |
206 // C++ doesn't allow zero length arrays, so we make the array length 1 even | 208 int registers_[RegisterAllocator::kNumRegisters]; |
207 // if we don't need it. | |
208 static const int kRegistersArrayLength = | |
209 (RegisterAllocator::kNumRegisters == 0) ? | |
210 1 : RegisterAllocator::kNumRegisters; | |
211 int registers_[kRegistersArrayLength]; | |
212 }; | 209 }; |
213 | 210 |
| 211 #elif V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS |
| 212 |
| 213 |
| 214 class FrameRegisterState { |
| 215 public: |
| 216 inline FrameRegisterState(VirtualFrame frame) : frame_(frame) { } |
| 217 |
| 218 inline const VirtualFrame* frame() const { return &frame_; } |
| 219 |
| 220 private: |
| 221 VirtualFrame frame_; |
| 222 }; |
| 223 |
| 224 #else |
| 225 |
| 226 #error Unsupported target architecture. |
| 227 |
| 228 #endif |
| 229 |
214 | 230 |
215 // Helper interface to prepare to/restore after making runtime calls. | 231 // Helper interface to prepare to/restore after making runtime calls. |
216 class RuntimeCallHelper { | 232 class RuntimeCallHelper { |
217 public: | 233 public: |
218 virtual ~RuntimeCallHelper() {} | 234 virtual ~RuntimeCallHelper() {} |
219 | 235 |
220 virtual void BeforeCall(MacroAssembler* masm) const = 0; | 236 virtual void BeforeCall(MacroAssembler* masm) const = 0; |
221 | 237 |
222 virtual void AfterCall(MacroAssembler* masm) const = 0; | 238 virtual void AfterCall(MacroAssembler* masm) const = 0; |
223 | 239 |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
842 StringCharFromCodeGenerator char_from_code_generator_; | 858 StringCharFromCodeGenerator char_from_code_generator_; |
843 | 859 |
844 DISALLOW_COPY_AND_ASSIGN(StringCharAtGenerator); | 860 DISALLOW_COPY_AND_ASSIGN(StringCharAtGenerator); |
845 }; | 861 }; |
846 | 862 |
847 | 863 |
848 } // namespace internal | 864 } // namespace internal |
849 } // namespace v8 | 865 } // namespace v8 |
850 | 866 |
851 #endif // V8_CODEGEN_H_ | 867 #endif // V8_CODEGEN_H_ |
OLD | NEW |