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