| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 // allocator | 45 // allocator |
| 46 // AddDeferred | 46 // AddDeferred |
| 47 // in_spilled_code | 47 // in_spilled_code |
| 48 // set_in_spilled_code | 48 // set_in_spilled_code |
| 49 // | 49 // |
| 50 // These methods are either used privately by the shared code or implemented as | 50 // These methods are either used privately by the shared code or implemented as |
| 51 // shared code: | 51 // shared code: |
| 52 // CodeGenerator | 52 // CodeGenerator |
| 53 // ~CodeGenerator | 53 // ~CodeGenerator |
| 54 // ProcessDeferred | 54 // ProcessDeferred |
| 55 // ClearDeferred | |
| 56 // GenCode | 55 // GenCode |
| 57 // BuildBoilerplate | 56 // BuildBoilerplate |
| 58 // ComputeCallInitialize | 57 // ComputeCallInitialize |
| 59 // ComputeCallInitializeInLoop | 58 // ComputeCallInitializeInLoop |
| 60 // ProcessDeclarations | 59 // ProcessDeclarations |
| 61 // DeclareGlobals | 60 // DeclareGlobals |
| 62 // FindInlineRuntimeLUT | 61 // FindInlineRuntimeLUT |
| 63 // CheckForInlineRuntimeCall | 62 // CheckForInlineRuntimeCall |
| 64 // PatchInlineRuntimeEntry | 63 // PatchInlineRuntimeEntry |
| 65 // GenerateFastCaseSwitchStatement | 64 // GenerateFastCaseSwitchStatement |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 ASSERT(top_ != NULL); | 108 ASSERT(top_ != NULL); |
| 110 return top_; | 109 return top_; |
| 111 } | 110 } |
| 112 | 111 |
| 113 private: | 112 private: |
| 114 static CodeGenerator* top_; | 113 static CodeGenerator* top_; |
| 115 CodeGenerator* previous_; | 114 CodeGenerator* previous_; |
| 116 }; | 115 }; |
| 117 | 116 |
| 118 | 117 |
| 119 // Use lazy compilation; defaults to true. | |
| 120 // NOTE: Do not remove non-lazy compilation until we can properly | |
| 121 // install extensions with lazy compilation enabled. At the | |
| 122 // moment, this doesn't work for the extensions in Google3, | |
| 123 // and we can only run the tests with --nolazy. | |
| 124 | |
| 125 | |
| 126 // Deferred code objects are small pieces of code that are compiled | 118 // Deferred code objects are small pieces of code that are compiled |
| 127 // 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 |
| 128 // paths thereby avoiding expensive jumps around uncommon code parts. | 120 // paths thereby avoiding expensive jumps around uncommon code parts. |
| 129 class DeferredCode: public ZoneObject { | 121 class DeferredCode: public ZoneObject { |
| 130 public: | 122 public: |
| 131 explicit DeferredCode(CodeGenerator* generator); | 123 DeferredCode(); |
| 132 virtual ~DeferredCode() { } | 124 virtual ~DeferredCode() { } |
| 133 | 125 |
| 134 virtual void Generate() = 0; | 126 virtual void Generate() = 0; |
| 135 | 127 |
| 136 // Unuse the entry and exit targets, deallocating all virtual frames | 128 CodeGenerator* cgen() const { return CodeGeneratorScope::Current(); } |
| 137 // held by them. It will be impossible to emit a (correct) jump | |
| 138 // into or out of the deferred code after clearing. | |
| 139 void Clear() { | |
| 140 enter_.Unuse(); | |
| 141 exit_.Unuse(); | |
| 142 } | |
| 143 | |
| 144 MacroAssembler* masm() const { return masm_; } | |
| 145 CodeGenerator* generator() const { return generator_; } | |
| 146 | 129 |
| 147 // Set the virtual frame for entry to the deferred code as a | 130 // Set the virtual frame for entry to the deferred code as a |
| 148 // snapshot of the code generator's current frame (plus additional | 131 // snapshot of the code generator's current frame (plus additional |
| 149 // results). This is optional, but should be done before branching | 132 // results). This is optional, but should be done before branching |
| 150 // or jumping to the deferred code. | 133 // or jumping to the deferred code. |
| 151 inline void SetEntryFrame(Result* arg); | 134 inline void SetEntryFrame(Result* arg); |
| 152 inline void SetEntryFrame(Result* arg0, Result* arg1); | 135 inline void SetEntryFrame(Result* arg0, Result* arg1); |
| 153 | 136 |
| 154 JumpTarget* enter() { return &enter_; } | 137 JumpTarget* enter() { return &enter_; } |
| 155 | 138 |
| 156 void BindExit() { exit_.Bind(0); } | 139 void BindExit() { exit_.Bind(0); } |
| 157 void BindExit(Result* result) { exit_.Bind(result, 1); } | 140 void BindExit(Result* result) { exit_.Bind(result, 1); } |
| 158 void BindExit(Result* result0, Result* result1) { | 141 void BindExit(Result* result0, Result* result1) { |
| 159 exit_.Bind(result0, result1, 2); | 142 exit_.Bind(result0, result1, 2); |
| 160 } | 143 } |
| 161 void BindExit(Result* result0, Result* result1, Result* result2) { | 144 void BindExit(Result* result0, Result* result1, Result* result2) { |
| 162 exit_.Bind(result0, result1, result2, 3); | 145 exit_.Bind(result0, result1, result2, 3); |
| 163 } | 146 } |
| 164 | 147 |
| 165 int statement_position() const { return statement_position_; } | 148 int statement_position() const { return statement_position_; } |
| 166 int position() const { return position_; } | 149 int position() const { return position_; } |
| 167 | 150 |
| 168 #ifdef DEBUG | 151 #ifdef DEBUG |
| 169 void set_comment(const char* comment) { comment_ = comment; } | 152 void set_comment(const char* comment) { comment_ = comment; } |
| 170 const char* comment() const { return comment_; } | 153 const char* comment() const { return comment_; } |
| 171 #else | 154 #else |
| 172 inline void set_comment(const char* comment) { } | 155 void set_comment(const char* comment) { } |
| 173 const char* comment() const { return ""; } | 156 const char* comment() const { return ""; } |
| 174 #endif | 157 #endif |
| 175 | 158 |
| 176 protected: | 159 protected: |
| 177 CodeGenerator* const generator_; | |
| 178 MacroAssembler* const masm_; | |
| 179 JumpTarget enter_; | 160 JumpTarget enter_; |
| 180 JumpTarget exit_; | 161 JumpTarget exit_; |
| 181 | 162 |
| 182 private: | 163 private: |
| 183 int statement_position_; | 164 int statement_position_; |
| 184 int position_; | 165 int position_; |
| 185 #ifdef DEBUG | 166 #ifdef DEBUG |
| 186 const char* comment_; | 167 const char* comment_; |
| 187 #endif | 168 #endif |
| 188 DISALLOW_COPY_AND_ASSIGN(DeferredCode); | 169 DISALLOW_COPY_AND_ASSIGN(DeferredCode); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 PrintF("ArgumentsAccessStub (type %d)\n", type_); | 330 PrintF("ArgumentsAccessStub (type %d)\n", type_); |
| 350 } | 331 } |
| 351 #endif | 332 #endif |
| 352 }; | 333 }; |
| 353 | 334 |
| 354 | 335 |
| 355 } // namespace internal | 336 } // namespace internal |
| 356 } // namespace v8 | 337 } // namespace v8 |
| 357 | 338 |
| 358 #endif // V8_CODEGEN_H_ | 339 #endif // V8_CODEGEN_H_ |
| OLD | NEW |