sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1 | // Copyright 2010 the V8 project authors. All rights reserved. |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 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. |
| 27 | |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 28 | #ifndef V8_ARM_CODEGEN_ARM_H_ |
| 29 | #define V8_ARM_CODEGEN_ARM_H_ |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 30 | |
vegorov@chromium.org | dff694e | 2010-05-17 09:10:26 +0000 | [diff] [blame] | 31 | #include "ast.h" |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 32 | #include "code-stubs-arm.h" |
| 33 | #include "ic-inl.h" |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 34 | |
kasperl@chromium.org | 71affb5 | 2009-05-26 05:44:31 +0000 | [diff] [blame] | 35 | namespace v8 { |
| 36 | namespace internal { |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 37 | |
| 38 | // Forward declarations |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 39 | class CompilationInfo; |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 40 | class DeferredCode; |
vegorov@chromium.org | dff694e | 2010-05-17 09:10:26 +0000 | [diff] [blame] | 41 | class JumpTarget; |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 42 | class RegisterAllocator; |
| 43 | class RegisterFile; |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 44 | |
ager@chromium.org | 3bf7b91 | 2008-11-17 09:09:45 +0000 | [diff] [blame] | 45 | enum InitState { CONST_INIT, NOT_CONST_INIT }; |
| 46 | enum TypeofState { INSIDE_TYPEOF, NOT_INSIDE_TYPEOF }; |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 47 | enum GenerateInlineSmi { DONT_GENERATE_INLINE_SMI, GENERATE_INLINE_SMI }; |
kmillikin@chromium.org | 69ea396 | 2010-07-05 11:01:40 +0000 | [diff] [blame] | 48 | enum WriteBarrierCharacter { UNLIKELY_SMI, LIKELY_SMI, NEVER_NEWSPACE }; |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 49 | |
ager@chromium.org | 3bf7b91 | 2008-11-17 09:09:45 +0000 | [diff] [blame] | 50 | |
| 51 | // ------------------------------------------------------------------------- |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 52 | // Reference support |
| 53 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 54 | // A reference is a C++ stack-allocated object that puts a |
| 55 | // reference on the virtual frame. The reference may be consumed |
| 56 | // by GetValue, TakeValue, SetValue, and Codegen::UnloadReference. |
| 57 | // When the lifetime (scope) of a valid reference ends, it must have |
| 58 | // been consumed, and be in state UNLOADED. |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 59 | class Reference BASE_EMBEDDED { |
| 60 | public: |
| 61 | // The values of the types is important, see size(). |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 62 | enum Type { UNLOADED = -2, ILLEGAL = -1, SLOT = 0, NAMED = 1, KEYED = 2 }; |
| 63 | Reference(CodeGenerator* cgen, |
| 64 | Expression* expression, |
| 65 | bool persist_after_get = false); |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 66 | ~Reference(); |
| 67 | |
| 68 | Expression* expression() const { return expression_; } |
| 69 | Type type() const { return type_; } |
| 70 | void set_type(Type value) { |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 71 | ASSERT_EQ(ILLEGAL, type_); |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 72 | type_ = value; |
| 73 | } |
| 74 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 75 | void set_unloaded() { |
| 76 | ASSERT_NE(ILLEGAL, type_); |
| 77 | ASSERT_NE(UNLOADED, type_); |
| 78 | type_ = UNLOADED; |
| 79 | } |
ager@chromium.org | 3bf7b91 | 2008-11-17 09:09:45 +0000 | [diff] [blame] | 80 | // The size the reference takes up on the stack. |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 81 | int size() const { |
| 82 | return (type_ < SLOT) ? 0 : type_; |
| 83 | } |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 84 | |
| 85 | bool is_illegal() const { return type_ == ILLEGAL; } |
| 86 | bool is_slot() const { return type_ == SLOT; } |
| 87 | bool is_property() const { return type_ == NAMED || type_ == KEYED; } |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 88 | bool is_unloaded() const { return type_ == UNLOADED; } |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 89 | |
| 90 | // Return the name. Only valid for named property references. |
| 91 | Handle<String> GetName(); |
| 92 | |
| 93 | // Generate code to push the value of the reference on top of the |
| 94 | // expression stack. The reference is expected to be already on top of |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 95 | // the expression stack, and it is consumed by the call unless the |
| 96 | // reference is for a compound assignment. |
| 97 | // If the reference is not consumed, it is left in place under its value. |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 98 | void GetValue(); |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 99 | |
| 100 | // Generate code to store the value on top of the expression stack in the |
| 101 | // reference. The reference is expected to be immediately below the value |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 102 | // on the expression stack. The value is stored in the location specified |
| 103 | // by the reference, and is left on top of the stack, after the reference |
| 104 | // is popped from beneath it (unloaded). |
kmillikin@chromium.org | 69ea396 | 2010-07-05 11:01:40 +0000 | [diff] [blame] | 105 | void SetValue(InitState init_state, WriteBarrierCharacter wb); |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 106 | |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 107 | // This is in preparation for something that uses the reference on the stack. |
| 108 | // If we need this reference afterwards get then dup it now. Otherwise mark |
| 109 | // it as used. |
| 110 | inline void DupIfPersist(); |
| 111 | |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 112 | private: |
| 113 | CodeGenerator* cgen_; |
| 114 | Expression* expression_; |
| 115 | Type type_; |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 116 | // Keep the reference on the stack after get, so it can be used by set later. |
| 117 | bool persist_after_get_; |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 118 | }; |
| 119 | |
| 120 | |
| 121 | // ------------------------------------------------------------------------- |
| 122 | // Code generation state |
| 123 | |
| 124 | // The state is passed down the AST by the code generator (and back up, in |
| 125 | // the form of the state of the label pair). It is threaded through the |
| 126 | // call stack. Constructing a state implicitly pushes it on the owning code |
| 127 | // generator's stack of states, and destroying one implicitly pops it. |
| 128 | |
| 129 | class CodeGenState BASE_EMBEDDED { |
| 130 | public: |
| 131 | // Create an initial code generator state. Destroying the initial state |
| 132 | // leaves the code generator with a NULL state. |
| 133 | explicit CodeGenState(CodeGenerator* owner); |
| 134 | |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 135 | // Destroy a code generator state and restore the owning code generator's |
| 136 | // previous state. |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 137 | virtual ~CodeGenState(); |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 138 | |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 139 | virtual JumpTarget* true_target() const { return NULL; } |
| 140 | virtual JumpTarget* false_target() const { return NULL; } |
| 141 | |
| 142 | protected: |
| 143 | inline CodeGenerator* owner() { return owner_; } |
| 144 | inline CodeGenState* previous() const { return previous_; } |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 145 | |
| 146 | private: |
| 147 | CodeGenerator* owner_; |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 148 | CodeGenState* previous_; |
| 149 | }; |
| 150 | |
| 151 | |
| 152 | class ConditionCodeGenState : public CodeGenState { |
| 153 | public: |
| 154 | // Create a code generator state based on a code generator's current |
| 155 | // state. The new state has its own pair of branch labels. |
| 156 | ConditionCodeGenState(CodeGenerator* owner, |
| 157 | JumpTarget* true_target, |
| 158 | JumpTarget* false_target); |
| 159 | |
| 160 | virtual JumpTarget* true_target() const { return true_target_; } |
| 161 | virtual JumpTarget* false_target() const { return false_target_; } |
| 162 | |
| 163 | private: |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 164 | JumpTarget* true_target_; |
| 165 | JumpTarget* false_target_; |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 166 | }; |
| 167 | |
| 168 | |
| 169 | class TypeInfoCodeGenState : public CodeGenState { |
| 170 | public: |
| 171 | TypeInfoCodeGenState(CodeGenerator* owner, |
| 172 | Slot* slot_number, |
| 173 | TypeInfo info); |
| 174 | ~TypeInfoCodeGenState(); |
| 175 | |
| 176 | virtual JumpTarget* true_target() const { return previous()->true_target(); } |
| 177 | virtual JumpTarget* false_target() const { |
| 178 | return previous()->false_target(); |
| 179 | } |
| 180 | |
| 181 | private: |
| 182 | Slot* slot_; |
| 183 | TypeInfo old_type_info_; |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 184 | }; |
| 185 | |
| 186 | |
ager@chromium.org | 3bf7b91 | 2008-11-17 09:09:45 +0000 | [diff] [blame] | 187 | // ------------------------------------------------------------------------- |
fschneider@chromium.org | 013f3e1 | 2010-04-26 13:27:52 +0000 | [diff] [blame] | 188 | // Arguments allocation mode |
| 189 | |
| 190 | enum ArgumentsAllocationMode { |
| 191 | NO_ARGUMENTS_ALLOCATION, |
| 192 | EAGER_ARGUMENTS_ALLOCATION, |
| 193 | LAZY_ARGUMENTS_ALLOCATION |
| 194 | }; |
| 195 | |
| 196 | |
fschneider@chromium.org | 013f3e1 | 2010-04-26 13:27:52 +0000 | [diff] [blame] | 197 | // ------------------------------------------------------------------------- |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 198 | // CodeGenerator |
| 199 | |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 200 | class CodeGenerator: public AstVisitor { |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 201 | public: |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 202 | static bool MakeCode(CompilationInfo* info); |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 203 | |
christian.plesner.hansen@gmail.com | 9d58c2b | 2009-10-16 11:48:38 +0000 | [diff] [blame] | 204 | // Printing of AST, etc. as requested by flags. |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 205 | static void MakeCodePrologue(CompilationInfo* info); |
christian.plesner.hansen@gmail.com | 9d58c2b | 2009-10-16 11:48:38 +0000 | [diff] [blame] | 206 | |
| 207 | // Allocate and install the code. |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 208 | static Handle<Code> MakeCodeEpilogue(MacroAssembler* masm, |
christian.plesner.hansen@gmail.com | 9d58c2b | 2009-10-16 11:48:38 +0000 | [diff] [blame] | 209 | Code::Flags flags, |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 210 | CompilationInfo* info); |
christian.plesner.hansen@gmail.com | 9d58c2b | 2009-10-16 11:48:38 +0000 | [diff] [blame] | 211 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame^] | 212 | // Print the code after compiling it. |
| 213 | static void PrintCode(Handle<Code> code, CompilationInfo* info); |
| 214 | |
christian.plesner.hansen@gmail.com | aca4968 | 2009-01-07 14:29:04 +0000 | [diff] [blame] | 215 | #ifdef ENABLE_LOGGING_AND_PROFILING |
christian.plesner.hansen@gmail.com | 37abdec | 2009-01-06 14:43:28 +0000 | [diff] [blame] | 216 | static bool ShouldGenerateLog(Expression* type); |
christian.plesner.hansen@gmail.com | aca4968 | 2009-01-07 14:29:04 +0000 | [diff] [blame] | 217 | #endif |
christian.plesner.hansen@gmail.com | 37abdec | 2009-01-06 14:43:28 +0000 | [diff] [blame] | 218 | |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 219 | static void SetFunctionInfo(Handle<JSFunction> fun, |
sgjesse@chromium.org | 911335c | 2009-08-19 12:59:44 +0000 | [diff] [blame] | 220 | FunctionLiteral* lit, |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 221 | bool is_toplevel, |
sgjesse@chromium.org | 911335c | 2009-08-19 12:59:44 +0000 | [diff] [blame] | 222 | Handle<Script> script); |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 223 | |
vegorov@chromium.org | 2356e6f | 2010-06-09 09:38:56 +0000 | [diff] [blame] | 224 | static bool RecordPositions(MacroAssembler* masm, |
| 225 | int pos, |
| 226 | bool right_here = false); |
christian.plesner.hansen@gmail.com | 9d58c2b | 2009-10-16 11:48:38 +0000 | [diff] [blame] | 227 | |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 228 | // Accessors |
| 229 | MacroAssembler* masm() { return masm_; } |
ager@chromium.org | 3bf7b91 | 2008-11-17 09:09:45 +0000 | [diff] [blame] | 230 | VirtualFrame* frame() const { return frame_; } |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 231 | inline Handle<Script> script(); |
ager@chromium.org | 3bf7b91 | 2008-11-17 09:09:45 +0000 | [diff] [blame] | 232 | |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 233 | bool has_valid_frame() const { return frame_ != NULL; } |
| 234 | |
| 235 | // Set the virtual frame to be new_frame, with non-frame register |
| 236 | // reference counts given by non_frame_registers. The non-frame |
| 237 | // register reference counts of the old frame are returned in |
| 238 | // non_frame_registers. |
| 239 | void SetFrame(VirtualFrame* new_frame, RegisterFile* non_frame_registers); |
| 240 | |
| 241 | void DeleteFrame(); |
| 242 | |
| 243 | RegisterAllocator* allocator() const { return allocator_; } |
| 244 | |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 245 | CodeGenState* state() { return state_; } |
| 246 | void set_state(CodeGenState* state) { state_ = state; } |
| 247 | |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 248 | TypeInfo type_info(Slot* slot) { |
| 249 | int index = NumberOfSlot(slot); |
| 250 | if (index == kInvalidSlotNumber) return TypeInfo::Unknown(); |
| 251 | return (*type_info_)[index]; |
| 252 | } |
| 253 | |
| 254 | TypeInfo set_type_info(Slot* slot, TypeInfo info) { |
| 255 | int index = NumberOfSlot(slot); |
| 256 | ASSERT(index >= kInvalidSlotNumber); |
| 257 | if (index != kInvalidSlotNumber) { |
| 258 | TypeInfo previous_value = (*type_info_)[index]; |
| 259 | (*type_info_)[index] = info; |
| 260 | return previous_value; |
| 261 | } |
| 262 | return TypeInfo::Unknown(); |
| 263 | } |
| 264 | |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 265 | void AddDeferred(DeferredCode* code) { deferred_.Add(code); } |
| 266 | |
vegorov@chromium.org | dff694e | 2010-05-17 09:10:26 +0000 | [diff] [blame] | 267 | // Constants related to patching of inlined load/store. |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 268 | static int GetInlinedKeyedLoadInstructionsAfterPatch() { |
ricow@chromium.org | 0b9f850 | 2010-08-18 07:45:01 +0000 | [diff] [blame] | 269 | return FLAG_debug_code ? 32 : 13; |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 270 | } |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 271 | static const int kInlinedKeyedStoreInstructionsAfterPatch = 5; |
whesse@chromium.org | ba5a61b | 2010-07-26 11:44:40 +0000 | [diff] [blame] | 272 | static int GetInlinedNamedStoreInstructionsAfterPatch() { |
| 273 | ASSERT(inlined_write_barrier_size_ != -1); |
| 274 | return inlined_write_barrier_size_ + 4; |
| 275 | } |
vegorov@chromium.org | dff694e | 2010-05-17 09:10:26 +0000 | [diff] [blame] | 276 | |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 277 | private: |
erik.corry@gmail.com | d88afa2 | 2010-09-15 12:33:05 +0000 | [diff] [blame] | 278 | // Type of a member function that generates inline code for a native function. |
| 279 | typedef void (CodeGenerator::*InlineFunctionGenerator) |
| 280 | (ZoneList<Expression*>*); |
| 281 | |
| 282 | static const InlineFunctionGenerator kInlineFunctionGenerators[]; |
| 283 | |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 284 | // Construction/Destruction |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 285 | explicit CodeGenerator(MacroAssembler* masm); |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 286 | |
| 287 | // Accessors |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 288 | inline bool is_eval(); |
sgjesse@chromium.org | 833cdd7 | 2010-02-26 10:06:16 +0000 | [diff] [blame] | 289 | inline Scope* scope(); |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 290 | |
sgjesse@chromium.org | 755c5b1 | 2009-05-29 11:04:38 +0000 | [diff] [blame] | 291 | // Generating deferred code. |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 292 | void ProcessDeferred(); |
| 293 | |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 294 | static const int kInvalidSlotNumber = -1; |
| 295 | |
| 296 | int NumberOfSlot(Slot* slot); |
| 297 | |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 298 | // State |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 299 | bool has_cc() const { return cc_reg_ != al; } |
| 300 | JumpTarget* true_target() const { return state_->true_target(); } |
| 301 | JumpTarget* false_target() const { return state_->false_target(); } |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 302 | |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 303 | // Track loop nesting level. |
| 304 | int loop_nesting() const { return loop_nesting_; } |
| 305 | void IncrementLoopNesting() { loop_nesting_++; } |
| 306 | void DecrementLoopNesting() { loop_nesting_--; } |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 307 | |
| 308 | // Node visitors. |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 309 | void VisitStatements(ZoneList<Statement*>* statements); |
| 310 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame^] | 311 | virtual void VisitSlot(Slot* node); |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 312 | #define DEF_VISIT(type) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame^] | 313 | virtual void Visit##type(type* node); |
sgjesse@chromium.org | 0b6db59 | 2009-07-30 14:48:31 +0000 | [diff] [blame] | 314 | AST_NODE_LIST(DEF_VISIT) |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 315 | #undef DEF_VISIT |
| 316 | |
| 317 | // Main code generation function |
fschneider@chromium.org | b95b98b | 2010-02-23 10:34:29 +0000 | [diff] [blame] | 318 | void Generate(CompilationInfo* info); |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 319 | |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 320 | // Generate the return sequence code. Should be called no more than |
| 321 | // once per compiled function, immediately after binding the return |
| 322 | // target (which can not be done more than once). The return value should |
| 323 | // be in r0. |
| 324 | void GenerateReturnSequence(); |
| 325 | |
fschneider@chromium.org | 013f3e1 | 2010-04-26 13:27:52 +0000 | [diff] [blame] | 326 | // Returns the arguments allocation mode. |
| 327 | ArgumentsAllocationMode ArgumentsMode(); |
| 328 | |
| 329 | // Store the arguments object and allocate it if necessary. |
| 330 | void StoreArgumentsObject(bool initial); |
| 331 | |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 332 | // The following are used by class Reference. |
| 333 | void LoadReference(Reference* ref); |
| 334 | void UnloadReference(Reference* ref); |
| 335 | |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 336 | MemOperand SlotOperand(Slot* slot, Register tmp); |
| 337 | |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 338 | MemOperand ContextSlotOperandCheckExtensions(Slot* slot, |
| 339 | Register tmp, |
| 340 | Register tmp2, |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 341 | JumpTarget* slow); |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 342 | |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 343 | // Expressions |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 344 | void LoadCondition(Expression* x, |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 345 | JumpTarget* true_target, |
| 346 | JumpTarget* false_target, |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 347 | bool force_cc); |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 348 | void Load(Expression* expr); |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 349 | void LoadGlobal(); |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 350 | void LoadGlobalReceiver(Register scratch); |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 351 | |
| 352 | // Read a value from a slot and leave it on top of the expression stack. |
| 353 | void LoadFromSlot(Slot* slot, TypeofState typeof_state); |
fschneider@chromium.org | 013f3e1 | 2010-04-26 13:27:52 +0000 | [diff] [blame] | 354 | void LoadFromSlotCheckForArguments(Slot* slot, TypeofState state); |
vegorov@chromium.org | dff694e | 2010-05-17 09:10:26 +0000 | [diff] [blame] | 355 | |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 356 | // Store the value on top of the stack to a slot. |
| 357 | void StoreToSlot(Slot* slot, InitState init_state); |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 358 | |
ager@chromium.org | ac091b7 | 2010-05-05 07:34:42 +0000 | [diff] [blame] | 359 | // Support for compiling assignment expressions. |
| 360 | void EmitSlotAssignment(Assignment* node); |
| 361 | void EmitNamedPropertyAssignment(Assignment* node); |
| 362 | void EmitKeyedPropertyAssignment(Assignment* node); |
| 363 | |
| 364 | // Load a named property, returning it in r0. The receiver is passed on the |
fschneider@chromium.org | 013f3e1 | 2010-04-26 13:27:52 +0000 | [diff] [blame] | 365 | // stack, and remains there. |
| 366 | void EmitNamedLoad(Handle<String> name, bool is_contextual); |
| 367 | |
ager@chromium.org | ac091b7 | 2010-05-05 07:34:42 +0000 | [diff] [blame] | 368 | // Store to a named property. If the store is contextual, value is passed on |
| 369 | // the frame and consumed. Otherwise, receiver and value are passed on the |
| 370 | // frame and consumed. The result is returned in r0. |
| 371 | void EmitNamedStore(Handle<String> name, bool is_contextual); |
| 372 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 373 | // Load a keyed property, leaving it in r0. The receiver and key are |
| 374 | // passed on the stack, and remain there. |
lrn@chromium.org | c34f580 | 2010-04-28 12:53:43 +0000 | [diff] [blame] | 375 | void EmitKeyedLoad(); |
| 376 | |
| 377 | // Store a keyed property. Key and receiver are on the stack and the value is |
| 378 | // in r0. Result is returned in r0. |
kmillikin@chromium.org | 69ea396 | 2010-07-05 11:01:40 +0000 | [diff] [blame] | 379 | void EmitKeyedStore(StaticType* key_type, WriteBarrierCharacter wb_info); |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 380 | |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 381 | void LoadFromGlobalSlotCheckExtensions(Slot* slot, |
| 382 | TypeofState typeof_state, |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 383 | JumpTarget* slow); |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 384 | |
vegorov@chromium.org | dff694e | 2010-05-17 09:10:26 +0000 | [diff] [blame] | 385 | // Support for loading from local/global variables and arguments |
| 386 | // whose location is known unless they are shadowed by |
| 387 | // eval-introduced bindings. Generates no code for unsupported slot |
| 388 | // types and therefore expects to fall through to the slow jump target. |
| 389 | void EmitDynamicLoadFromSlotFastCase(Slot* slot, |
| 390 | TypeofState typeof_state, |
| 391 | JumpTarget* slow, |
| 392 | JumpTarget* done); |
| 393 | |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 394 | // Special code for typeof expressions: Unfortunately, we must |
| 395 | // be careful when loading the expression in 'typeof' |
| 396 | // expressions. We are not allowed to throw reference errors for |
| 397 | // non-existing properties of the global object, so we must make it |
| 398 | // look like an explicit property access, instead of an access |
| 399 | // through the context chain. |
| 400 | void LoadTypeofExpression(Expression* x); |
| 401 | |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 402 | void ToBoolean(JumpTarget* true_target, JumpTarget* false_target); |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 403 | |
ager@chromium.org | b26c50a | 2010-03-26 09:27:16 +0000 | [diff] [blame] | 404 | // Generate code that computes a shortcutting logical operation. |
| 405 | void GenerateLogicalBooleanOperation(BinaryOperation* node); |
| 406 | |
kasperl@chromium.org | 86f77b7 | 2009-07-06 08:21:57 +0000 | [diff] [blame] | 407 | void GenericBinaryOperation(Token::Value op, |
| 408 | OverwriteMode overwrite_mode, |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 409 | GenerateInlineSmi inline_smi, |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 410 | int known_rhs = |
| 411 | GenericBinaryOpStub::kUnknownIntValue); |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 412 | void Comparison(Condition cc, |
| 413 | Expression* left, |
| 414 | Expression* right, |
| 415 | bool strict = false); |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 416 | |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 417 | void SmiOperation(Token::Value op, |
| 418 | Handle<Object> value, |
| 419 | bool reversed, |
| 420 | OverwriteMode mode); |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 421 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 422 | void CallWithArguments(ZoneList<Expression*>* arguments, |
| 423 | CallFunctionFlags flags, |
| 424 | int position); |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 425 | |
fschneider@chromium.org | 013f3e1 | 2010-04-26 13:27:52 +0000 | [diff] [blame] | 426 | // An optimized implementation of expressions of the form |
| 427 | // x.apply(y, arguments). We call x the applicand and y the receiver. |
| 428 | // The optimization avoids allocating an arguments object if possible. |
| 429 | void CallApplyLazy(Expression* applicand, |
| 430 | Expression* receiver, |
| 431 | VariableProxy* arguments, |
| 432 | int position); |
| 433 | |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 434 | // Control flow |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 435 | void Branch(bool if_true, JumpTarget* target); |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 436 | void CheckStack(); |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 437 | |
| 438 | bool CheckForInlineRuntimeCall(CallRuntime* node); |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 439 | |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 440 | static Handle<Code> ComputeLazyCompile(int argc); |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 441 | void ProcessDeclarations(ZoneList<Declaration*>* declarations); |
| 442 | |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 443 | // Declare global variables and functions in the given array of |
| 444 | // name/value pairs. |
| 445 | void DeclareGlobals(Handle<FixedArray> pairs); |
| 446 | |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 447 | // Instantiate the function based on the shared function info. |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 448 | void InstantiateFunction(Handle<SharedFunctionInfo> function_info, |
| 449 | bool pretenure); |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 450 | |
| 451 | // Support for type checks. |
| 452 | void GenerateIsSmi(ZoneList<Expression*>* args); |
| 453 | void GenerateIsNonNegativeSmi(ZoneList<Expression*>* args); |
| 454 | void GenerateIsArray(ZoneList<Expression*>* args); |
fschneider@chromium.org | b95b98b | 2010-02-23 10:34:29 +0000 | [diff] [blame] | 455 | void GenerateIsRegExp(ZoneList<Expression*>* args); |
ager@chromium.org | 6141cbe | 2009-11-20 12:14:52 +0000 | [diff] [blame] | 456 | void GenerateIsObject(ZoneList<Expression*>* args); |
ricow@chromium.org | 4980dff | 2010-07-19 08:33:45 +0000 | [diff] [blame] | 457 | void GenerateIsSpecObject(ZoneList<Expression*>* args); |
ager@chromium.org | 6141cbe | 2009-11-20 12:14:52 +0000 | [diff] [blame] | 458 | void GenerateIsFunction(ZoneList<Expression*>* args); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 459 | void GenerateIsUndetectableObject(ZoneList<Expression*>* args); |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 460 | void GenerateIsStringWrapperSafeForDefaultValueOf( |
| 461 | ZoneList<Expression*>* args); |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 462 | |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 463 | // Support for construct call checks. |
| 464 | void GenerateIsConstructCall(ZoneList<Expression*>* args); |
| 465 | |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 466 | // Support for arguments.length and arguments[?]. |
| 467 | void GenerateArgumentsLength(ZoneList<Expression*>* args); |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 468 | void GenerateArguments(ZoneList<Expression*>* args); |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 469 | |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 470 | // Support for accessing the class and value fields of an object. |
| 471 | void GenerateClassOf(ZoneList<Expression*>* args); |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 472 | void GenerateValueOf(ZoneList<Expression*>* args); |
| 473 | void GenerateSetValueOf(ZoneList<Expression*>* args); |
| 474 | |
| 475 | // Fast support for charCodeAt(n). |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 476 | void GenerateStringCharCodeAt(ZoneList<Expression*>* args); |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 477 | |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 478 | // Fast support for string.charAt(n) and string[n]. |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 479 | void GenerateStringCharFromCode(ZoneList<Expression*>* args); |
| 480 | |
| 481 | // Fast support for string.charAt(n) and string[n]. |
| 482 | void GenerateStringCharAt(ZoneList<Expression*>* args); |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 483 | |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 484 | // Fast support for object equality testing. |
| 485 | void GenerateObjectEquals(ZoneList<Expression*>* args); |
| 486 | |
christian.plesner.hansen@gmail.com | 37abdec | 2009-01-06 14:43:28 +0000 | [diff] [blame] | 487 | void GenerateLog(ZoneList<Expression*>* args); |
| 488 | |
ager@chromium.org | eadaf22 | 2009-06-16 09:43:10 +0000 | [diff] [blame] | 489 | // Fast support for Math.random(). |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 490 | void GenerateRandomHeapNumber(ZoneList<Expression*>* args); |
ager@chromium.org | eadaf22 | 2009-06-16 09:43:10 +0000 | [diff] [blame] | 491 | |
sgjesse@chromium.org | ac6aa17 | 2009-12-04 12:29:05 +0000 | [diff] [blame] | 492 | // Fast support for StringAdd. |
| 493 | void GenerateStringAdd(ZoneList<Expression*>* args); |
| 494 | |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 495 | // Fast support for SubString. |
| 496 | void GenerateSubString(ZoneList<Expression*>* args); |
| 497 | |
| 498 | // Fast support for StringCompare. |
| 499 | void GenerateStringCompare(ZoneList<Expression*>* args); |
| 500 | |
| 501 | // Support for direct calls from JavaScript to native RegExp code. |
| 502 | void GenerateRegExpExec(ZoneList<Expression*>* args); |
| 503 | |
whesse@chromium.org | b6e43bb | 2010-04-14 09:36:28 +0000 | [diff] [blame] | 504 | void GenerateRegExpConstructResult(ZoneList<Expression*>* args); |
| 505 | |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 506 | // Support for fast native caches. |
| 507 | void GenerateGetFromCache(ZoneList<Expression*>* args); |
| 508 | |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 509 | // Fast support for number to string. |
| 510 | void GenerateNumberToString(ZoneList<Expression*>* args); |
| 511 | |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 512 | // Fast swapping of elements. |
| 513 | void GenerateSwapElements(ZoneList<Expression*>* args); |
| 514 | |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 515 | // Fast call for custom callbacks. |
| 516 | void GenerateCallFunction(ZoneList<Expression*>* args); |
| 517 | |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 518 | // Fast call to math functions. |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 519 | void GenerateMathPow(ZoneList<Expression*>* args); |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 520 | void GenerateMathSin(ZoneList<Expression*>* args); |
| 521 | void GenerateMathCos(ZoneList<Expression*>* args); |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 522 | void GenerateMathSqrt(ZoneList<Expression*>* args); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame^] | 523 | void GenerateMathLog(ZoneList<Expression*>* args); |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 524 | |
lrn@chromium.org | c4e51ac | 2010-08-09 09:47:21 +0000 | [diff] [blame] | 525 | void GenerateIsRegExpEquivalent(ZoneList<Expression*>* args); |
| 526 | |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 527 | void GenerateHasCachedArrayIndex(ZoneList<Expression*>* args); |
| 528 | void GenerateGetCachedArrayIndex(ZoneList<Expression*>* args); |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 529 | void GenerateFastAsciiArrayJoin(ZoneList<Expression*>* args); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 530 | |
christian.plesner.hansen@gmail.com | 9d58c2b | 2009-10-16 11:48:38 +0000 | [diff] [blame] | 531 | // Simple condition analysis. |
| 532 | enum ConditionAnalysis { |
| 533 | ALWAYS_TRUE, |
| 534 | ALWAYS_FALSE, |
| 535 | DONT_KNOW |
| 536 | }; |
| 537 | ConditionAnalysis AnalyzeCondition(Expression* cond); |
| 538 | |
christian.plesner.hansen@gmail.com | 37abdec | 2009-01-06 14:43:28 +0000 | [diff] [blame] | 539 | // Methods used to indicate which source code is generated for. Source |
| 540 | // positions are collected by the assembler and emitted with the relocation |
| 541 | // information. |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 542 | void CodeForFunctionPosition(FunctionLiteral* fun); |
kasperl@chromium.org | 8ccb0be | 2009-04-07 07:21:39 +0000 | [diff] [blame] | 543 | void CodeForReturnPosition(FunctionLiteral* fun); |
sgjesse@chromium.org | c514574 | 2009-10-07 09:00:33 +0000 | [diff] [blame] | 544 | void CodeForStatementPosition(Statement* node); |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 545 | void CodeForDoWhileConditionPosition(DoWhileStatement* stmt); |
christian.plesner.hansen@gmail.com | 37abdec | 2009-01-06 14:43:28 +0000 | [diff] [blame] | 546 | void CodeForSourcePosition(int pos); |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 547 | |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 548 | #ifdef DEBUG |
| 549 | // True if the registers are valid for entry to a block. |
| 550 | bool HasValidEntryRegisters(); |
| 551 | #endif |
| 552 | |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 553 | List<DeferredCode*> deferred_; |
| 554 | |
| 555 | // Assembler |
| 556 | MacroAssembler* masm_; // to generate code |
| 557 | |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 558 | CompilationInfo* info_; |
| 559 | |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 560 | // Code generation state |
ager@chromium.org | 3bf7b91 | 2008-11-17 09:09:45 +0000 | [diff] [blame] | 561 | VirtualFrame* frame_; |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 562 | RegisterAllocator* allocator_; |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 563 | Condition cc_reg_; |
| 564 | CodeGenState* state_; |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 565 | int loop_nesting_; |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 566 | |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 567 | Vector<TypeInfo>* type_info_; |
| 568 | |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 569 | // Jump targets |
| 570 | BreakTarget function_return_; |
| 571 | |
| 572 | // True if the function return is shadowed (ie, jumping to the target |
| 573 | // function_return_ does not jump to the true function return, but rather |
| 574 | // to some unlinking code). |
| 575 | bool function_return_is_shadowed_; |
| 576 | |
whesse@chromium.org | ba5a61b | 2010-07-26 11:44:40 +0000 | [diff] [blame] | 577 | // Size of inlined write barriers generated by EmitNamedStore. |
| 578 | static int inlined_write_barrier_size_; |
| 579 | |
ager@chromium.org | 3bf7b91 | 2008-11-17 09:09:45 +0000 | [diff] [blame] | 580 | friend class VirtualFrame; |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 581 | friend class JumpTarget; |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 582 | friend class Reference; |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 583 | friend class FastCodeGenerator; |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 584 | friend class FullCodeGenerator; |
| 585 | friend class FullCodeGenSyntaxChecker; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame^] | 586 | friend class LCodeGen; |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 587 | |
| 588 | DISALLOW_COPY_AND_ASSIGN(CodeGenerator); |
| 589 | }; |
| 590 | |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 591 | |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 592 | } } // namespace v8::internal |
| 593 | |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 594 | #endif // V8_ARM_CODEGEN_ARM_H_ |