| 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 // Deferred code objects are small pieces of code that are compiled | 118 // Deferred code objects are small pieces of code that are compiled |
| 119 // out of line. They are used to defer the compilation of uncommon | 119 // out of line. They are used to defer the compilation of uncommon |
| 120 // paths thereby avoiding expensive jumps around uncommon code parts. | 120 // paths thereby avoiding expensive jumps around uncommon code parts. |
| 121 class DeferredCode: public ZoneObject { | 121 class DeferredCode: public ZoneObject { |
| 122 public: | 122 public: |
| 123 DeferredCode(); | 123 DeferredCode(); |
| 124 virtual ~DeferredCode() { } | 124 virtual ~DeferredCode() { } |
| 125 | 125 |
| 126 virtual void Generate() = 0; | 126 virtual void Generate() = 0; |
| 127 | 127 |
| 128 CodeGenerator* cgen() const { return CodeGeneratorScope::Current(); } | 128 MacroAssembler* masm() { return masm_; } |
| 129 | |
| 130 // Set the virtual frame for entry to the deferred code as a | |
| 131 // snapshot of the code generator's current frame (plus additional | |
| 132 // results). This is optional, but should be done before branching | |
| 133 // or jumping to the deferred code. | |
| 134 inline void SetEntryFrame(Result* arg); | |
| 135 inline void SetEntryFrame(Result* arg0, Result* arg1); | |
| 136 | |
| 137 JumpTarget* enter() { return &enter_; } | |
| 138 | |
| 139 void BindExit() { exit_.Bind(0); } | |
| 140 void BindExit(Result* result) { exit_.Bind(result, 1); } | |
| 141 void BindExit(Result* result0, Result* result1) { | |
| 142 exit_.Bind(result0, result1, 2); | |
| 143 } | |
| 144 void BindExit(Result* result0, Result* result1, Result* result2) { | |
| 145 exit_.Bind(result0, result1, result2, 3); | |
| 146 } | |
| 147 | 129 |
| 148 int statement_position() const { return statement_position_; } | 130 int statement_position() const { return statement_position_; } |
| 149 int position() const { return position_; } | 131 int position() const { return position_; } |
| 150 | 132 |
| 133 Label* entry_label() { return &entry_label_; } |
| 134 Label* exit_label() { return &exit_label_; } |
| 135 |
| 151 #ifdef DEBUG | 136 #ifdef DEBUG |
| 152 void set_comment(const char* comment) { comment_ = comment; } | 137 void set_comment(const char* comment) { comment_ = comment; } |
| 153 const char* comment() const { return comment_; } | 138 const char* comment() const { return comment_; } |
| 154 #else | 139 #else |
| 155 void set_comment(const char* comment) { } | 140 void set_comment(const char* comment) { } |
| 156 const char* comment() const { return ""; } | 141 const char* comment() const { return ""; } |
| 157 #endif | 142 #endif |
| 158 | 143 |
| 144 inline void Jump(); |
| 145 inline void Branch(Condition cc); |
| 146 void BindExit() { masm_->bind(&exit_label_); } |
| 147 |
| 148 void SaveRegisters(); |
| 149 void RestoreRegisters(); |
| 150 |
| 159 protected: | 151 protected: |
| 160 JumpTarget enter_; | 152 MacroAssembler* masm_; |
| 161 JumpTarget exit_; | |
| 162 | 153 |
| 163 private: | 154 private: |
| 155 // Constants indicating special actions. They should not be multiples |
| 156 // of kPointerSize so they will not collide with valid offsets from |
| 157 // the frame pointer. |
| 158 static const int kIgnore = -1; |
| 159 static const int kPush = 1; |
| 160 |
| 161 // This flag is ored with a valid offset from the frame pointer, so |
| 162 // it should fit in the low zero bits of a valid offset. |
| 163 static const int kSyncedFlag = 2; |
| 164 |
| 164 int statement_position_; | 165 int statement_position_; |
| 165 int position_; | 166 int position_; |
| 167 |
| 168 Label entry_label_; |
| 169 Label exit_label_; |
| 170 |
| 171 int registers_[RegisterAllocator::kNumRegisters]; |
| 172 |
| 166 #ifdef DEBUG | 173 #ifdef DEBUG |
| 167 const char* comment_; | 174 const char* comment_; |
| 168 #endif | 175 #endif |
| 169 DISALLOW_COPY_AND_ASSIGN(DeferredCode); | 176 DISALLOW_COPY_AND_ASSIGN(DeferredCode); |
| 170 }; | 177 }; |
| 171 | 178 |
| 172 | 179 |
| 173 // RuntimeStub models code stubs calling entry points in the Runtime class. | 180 // RuntimeStub models code stubs calling entry points in the Runtime class. |
| 174 class RuntimeStub : public CodeStub { | 181 class RuntimeStub : public CodeStub { |
| 175 public: | 182 public: |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 PrintF("ArgumentsAccessStub (type %d)\n", type_); | 337 PrintF("ArgumentsAccessStub (type %d)\n", type_); |
| 331 } | 338 } |
| 332 #endif | 339 #endif |
| 333 }; | 340 }; |
| 334 | 341 |
| 335 | 342 |
| 336 } // namespace internal | 343 } // namespace internal |
| 337 } // namespace v8 | 344 } // namespace v8 |
| 338 | 345 |
| 339 #endif // V8_CODEGEN_H_ | 346 #endif // V8_CODEGEN_H_ |
| OLD | NEW |