Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame^] | 1 | // Copyright 2011 the V8 project authors. All rights reserved. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +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 | |
| 28 | #ifndef V8_X64_CODEGEN_X64_H_ |
| 29 | #define V8_X64_CODEGEN_X64_H_ |
| 30 | |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 31 | #include "ast.h" |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 32 | #include "ic-inl.h" |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 33 | #include "jump-target-heavy.h" |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 34 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 35 | namespace v8 { |
| 36 | namespace internal { |
| 37 | |
| 38 | // Forward declarations |
Leon Clarke | 4515c47 | 2010-02-03 11:58:03 +0000 | [diff] [blame] | 39 | class CompilationInfo; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 40 | class DeferredCode; |
| 41 | class RegisterAllocator; |
| 42 | class RegisterFile; |
| 43 | |
| 44 | enum InitState { CONST_INIT, NOT_CONST_INIT }; |
| 45 | enum TypeofState { INSIDE_TYPEOF, NOT_INSIDE_TYPEOF }; |
| 46 | |
| 47 | |
| 48 | // ------------------------------------------------------------------------- |
| 49 | // Reference support |
| 50 | |
Leon Clarke | d91b9f7 | 2010-01-27 17:25:45 +0000 | [diff] [blame] | 51 | // A reference is a C++ stack-allocated object that puts a |
| 52 | // reference on the virtual frame. The reference may be consumed |
| 53 | // by GetValue, TakeValue, SetValue, and Codegen::UnloadReference. |
| 54 | // When the lifetime (scope) of a valid reference ends, it must have |
| 55 | // been consumed, and be in state UNLOADED. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 56 | class Reference BASE_EMBEDDED { |
| 57 | public: |
| 58 | // The values of the types is important, see size(). |
Leon Clarke | d91b9f7 | 2010-01-27 17:25:45 +0000 | [diff] [blame] | 59 | enum Type { UNLOADED = -2, ILLEGAL = -1, SLOT = 0, NAMED = 1, KEYED = 2 }; |
| 60 | |
| 61 | Reference(CodeGenerator* cgen, |
| 62 | Expression* expression, |
| 63 | bool persist_after_get = false); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 64 | ~Reference(); |
| 65 | |
| 66 | Expression* expression() const { return expression_; } |
| 67 | Type type() const { return type_; } |
| 68 | void set_type(Type value) { |
Leon Clarke | d91b9f7 | 2010-01-27 17:25:45 +0000 | [diff] [blame] | 69 | ASSERT_EQ(ILLEGAL, type_); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 70 | type_ = value; |
| 71 | } |
| 72 | |
Leon Clarke | d91b9f7 | 2010-01-27 17:25:45 +0000 | [diff] [blame] | 73 | void set_unloaded() { |
| 74 | ASSERT_NE(ILLEGAL, type_); |
| 75 | ASSERT_NE(UNLOADED, type_); |
| 76 | type_ = UNLOADED; |
| 77 | } |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 78 | // The size the reference takes up on the stack. |
Leon Clarke | d91b9f7 | 2010-01-27 17:25:45 +0000 | [diff] [blame] | 79 | int size() const { |
| 80 | return (type_ < SLOT) ? 0 : type_; |
| 81 | } |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 82 | |
| 83 | bool is_illegal() const { return type_ == ILLEGAL; } |
| 84 | bool is_slot() const { return type_ == SLOT; } |
| 85 | bool is_property() const { return type_ == NAMED || type_ == KEYED; } |
Leon Clarke | d91b9f7 | 2010-01-27 17:25:45 +0000 | [diff] [blame] | 86 | bool is_unloaded() const { return type_ == UNLOADED; } |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 87 | |
| 88 | // Return the name. Only valid for named property references. |
| 89 | Handle<String> GetName(); |
| 90 | |
| 91 | // Generate code to push the value of the reference on top of the |
| 92 | // expression stack. The reference is expected to be already on top of |
Leon Clarke | d91b9f7 | 2010-01-27 17:25:45 +0000 | [diff] [blame] | 93 | // the expression stack, and it is consumed by the call unless the |
| 94 | // reference is for a compound assignment. |
| 95 | // If the reference is not consumed, it is left in place under its value. |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 96 | void GetValue(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 97 | |
| 98 | // Like GetValue except that the slot is expected to be written to before |
Leon Clarke | d91b9f7 | 2010-01-27 17:25:45 +0000 | [diff] [blame] | 99 | // being read from again. The value of the reference may be invalidated, |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 100 | // causing subsequent attempts to read it to fail. |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 101 | void TakeValue(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 102 | |
| 103 | // Generate code to store the value on top of the expression stack in the |
| 104 | // reference. The reference is expected to be immediately below the value |
Leon Clarke | d91b9f7 | 2010-01-27 17:25:45 +0000 | [diff] [blame] | 105 | // on the expression stack. The value is stored in the location specified |
| 106 | // by the reference, and is left on top of the stack, after the reference |
| 107 | // is popped from beneath it (unloaded). |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 108 | void SetValue(InitState init_state); |
| 109 | |
| 110 | private: |
| 111 | CodeGenerator* cgen_; |
| 112 | Expression* expression_; |
| 113 | Type type_; |
Leon Clarke | d91b9f7 | 2010-01-27 17:25:45 +0000 | [diff] [blame] | 114 | bool persist_after_get_; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 115 | }; |
| 116 | |
| 117 | |
| 118 | // ------------------------------------------------------------------------- |
| 119 | // Control destinations. |
| 120 | |
| 121 | // A control destination encapsulates a pair of jump targets and a |
| 122 | // flag indicating which one is the preferred fall-through. The |
| 123 | // preferred fall-through must be unbound, the other may be already |
| 124 | // bound (ie, a backward target). |
| 125 | // |
| 126 | // The true and false targets may be jumped to unconditionally or |
| 127 | // control may split conditionally. Unconditional jumping and |
| 128 | // splitting should be emitted in tail position (as the last thing |
| 129 | // when compiling an expression) because they can cause either label |
| 130 | // to be bound or the non-fall through to be jumped to leaving an |
| 131 | // invalid virtual frame. |
| 132 | // |
| 133 | // The labels in the control destination can be extracted and |
| 134 | // manipulated normally without affecting the state of the |
| 135 | // destination. |
| 136 | |
| 137 | class ControlDestination BASE_EMBEDDED { |
| 138 | public: |
| 139 | ControlDestination(JumpTarget* true_target, |
| 140 | JumpTarget* false_target, |
| 141 | bool true_is_fall_through) |
| 142 | : true_target_(true_target), |
| 143 | false_target_(false_target), |
| 144 | true_is_fall_through_(true_is_fall_through), |
| 145 | is_used_(false) { |
| 146 | ASSERT(true_is_fall_through ? !true_target->is_bound() |
| 147 | : !false_target->is_bound()); |
| 148 | } |
| 149 | |
| 150 | // Accessors for the jump targets. Directly jumping or branching to |
| 151 | // or binding the targets will not update the destination's state. |
| 152 | JumpTarget* true_target() const { return true_target_; } |
| 153 | JumpTarget* false_target() const { return false_target_; } |
| 154 | |
| 155 | // True if the the destination has been jumped to unconditionally or |
| 156 | // control has been split to both targets. This predicate does not |
| 157 | // test whether the targets have been extracted and manipulated as |
| 158 | // raw jump targets. |
| 159 | bool is_used() const { return is_used_; } |
| 160 | |
| 161 | // True if the destination is used and the true target (respectively |
| 162 | // false target) was the fall through. If the target is backward, |
| 163 | // "fall through" included jumping unconditionally to it. |
| 164 | bool true_was_fall_through() const { |
| 165 | return is_used_ && true_is_fall_through_; |
| 166 | } |
| 167 | |
| 168 | bool false_was_fall_through() const { |
| 169 | return is_used_ && !true_is_fall_through_; |
| 170 | } |
| 171 | |
| 172 | // Emit a branch to one of the true or false targets, and bind the |
| 173 | // other target. Because this binds the fall-through target, it |
| 174 | // should be emitted in tail position (as the last thing when |
| 175 | // compiling an expression). |
| 176 | void Split(Condition cc) { |
| 177 | ASSERT(!is_used_); |
| 178 | if (true_is_fall_through_) { |
| 179 | false_target_->Branch(NegateCondition(cc)); |
| 180 | true_target_->Bind(); |
| 181 | } else { |
| 182 | true_target_->Branch(cc); |
| 183 | false_target_->Bind(); |
| 184 | } |
| 185 | is_used_ = true; |
| 186 | } |
| 187 | |
| 188 | // Emit an unconditional jump in tail position, to the true target |
| 189 | // (if the argument is true) or the false target. The "jump" will |
| 190 | // actually bind the jump target if it is forward, jump to it if it |
| 191 | // is backward. |
| 192 | void Goto(bool where) { |
| 193 | ASSERT(!is_used_); |
| 194 | JumpTarget* target = where ? true_target_ : false_target_; |
| 195 | if (target->is_bound()) { |
| 196 | target->Jump(); |
| 197 | } else { |
| 198 | target->Bind(); |
| 199 | } |
| 200 | is_used_ = true; |
| 201 | true_is_fall_through_ = where; |
| 202 | } |
| 203 | |
| 204 | // Mark this jump target as used as if Goto had been called, but |
| 205 | // without generating a jump or binding a label (the control effect |
| 206 | // should have already happened). This is used when the left |
| 207 | // subexpression of the short-circuit boolean operators are |
| 208 | // compiled. |
| 209 | void Use(bool where) { |
| 210 | ASSERT(!is_used_); |
| 211 | ASSERT((where ? true_target_ : false_target_)->is_bound()); |
| 212 | is_used_ = true; |
| 213 | true_is_fall_through_ = where; |
| 214 | } |
| 215 | |
| 216 | // Swap the true and false targets but keep the same actual label as |
| 217 | // the fall through. This is used when compiling negated |
| 218 | // expressions, where we want to swap the targets but preserve the |
| 219 | // state. |
| 220 | void Invert() { |
| 221 | JumpTarget* temp_target = true_target_; |
| 222 | true_target_ = false_target_; |
| 223 | false_target_ = temp_target; |
| 224 | |
| 225 | true_is_fall_through_ = !true_is_fall_through_; |
| 226 | } |
| 227 | |
| 228 | private: |
| 229 | // True and false jump targets. |
| 230 | JumpTarget* true_target_; |
| 231 | JumpTarget* false_target_; |
| 232 | |
| 233 | // Before using the destination: true if the true target is the |
| 234 | // preferred fall through, false if the false target is. After |
| 235 | // using the destination: true if the true target was actually used |
| 236 | // as the fall through, false if the false target was. |
| 237 | bool true_is_fall_through_; |
| 238 | |
| 239 | // True if the Split or Goto functions have been called. |
| 240 | bool is_used_; |
| 241 | }; |
| 242 | |
| 243 | |
| 244 | // ------------------------------------------------------------------------- |
| 245 | // Code generation state |
| 246 | |
| 247 | // The state is passed down the AST by the code generator (and back up, in |
| 248 | // the form of the state of the jump target pair). It is threaded through |
| 249 | // the call stack. Constructing a state implicitly pushes it on the owning |
| 250 | // code generator's stack of states, and destroying one implicitly pops it. |
| 251 | // |
| 252 | // The code generator state is only used for expressions, so statements have |
| 253 | // the initial state. |
| 254 | |
| 255 | class CodeGenState BASE_EMBEDDED { |
| 256 | public: |
| 257 | // Create an initial code generator state. Destroying the initial state |
| 258 | // leaves the code generator with a NULL state. |
| 259 | explicit CodeGenState(CodeGenerator* owner); |
| 260 | |
| 261 | // Create a code generator state based on a code generator's current |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 262 | // state. The new state has its own control destination. |
| 263 | CodeGenState(CodeGenerator* owner, ControlDestination* destination); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 264 | |
| 265 | // Destroy a code generator state and restore the owning code generator's |
| 266 | // previous state. |
| 267 | ~CodeGenState(); |
| 268 | |
| 269 | // Accessors for the state. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 270 | ControlDestination* destination() const { return destination_; } |
| 271 | |
| 272 | private: |
| 273 | // The owning code generator. |
| 274 | CodeGenerator* owner_; |
| 275 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 276 | // A control destination in case the expression has a control-flow |
| 277 | // effect. |
| 278 | ControlDestination* destination_; |
| 279 | |
| 280 | // The previous state of the owning code generator, restored when |
| 281 | // this state is destroyed. |
| 282 | CodeGenState* previous_; |
| 283 | }; |
| 284 | |
| 285 | |
| 286 | // ------------------------------------------------------------------------- |
| 287 | // Arguments allocation mode |
| 288 | |
| 289 | enum ArgumentsAllocationMode { |
| 290 | NO_ARGUMENTS_ALLOCATION, |
| 291 | EAGER_ARGUMENTS_ALLOCATION, |
| 292 | LAZY_ARGUMENTS_ALLOCATION |
| 293 | }; |
| 294 | |
| 295 | |
| 296 | // ------------------------------------------------------------------------- |
| 297 | // CodeGenerator |
| 298 | |
| 299 | class CodeGenerator: public AstVisitor { |
| 300 | public: |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 301 | static bool MakeCode(CompilationInfo* info); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 302 | |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 303 | // Printing of AST, etc. as requested by flags. |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 304 | static void MakeCodePrologue(CompilationInfo* info); |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 305 | |
| 306 | // Allocate and install the code. |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 307 | static Handle<Code> MakeCodeEpilogue(MacroAssembler* masm, |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 308 | Code::Flags flags, |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 309 | CompilationInfo* info); |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 310 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 311 | // Print the code after compiling it. |
| 312 | static void PrintCode(Handle<Code> code, CompilationInfo* info); |
| 313 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 314 | #ifdef ENABLE_LOGGING_AND_PROFILING |
| 315 | static bool ShouldGenerateLog(Expression* type); |
| 316 | #endif |
| 317 | |
Ben Murdoch | 7f4d5bd | 2010-06-15 11:15:29 +0100 | [diff] [blame] | 318 | static bool RecordPositions(MacroAssembler* masm, |
| 319 | int pos, |
| 320 | bool right_here = false); |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 321 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 322 | // Accessors |
| 323 | MacroAssembler* masm() { return masm_; } |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 324 | VirtualFrame* frame() const { return frame_; } |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 325 | inline Handle<Script> script(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 326 | |
| 327 | bool has_valid_frame() const { return frame_ != NULL; } |
| 328 | |
| 329 | // Set the virtual frame to be new_frame, with non-frame register |
| 330 | // reference counts given by non_frame_registers. The non-frame |
| 331 | // register reference counts of the old frame are returned in |
| 332 | // non_frame_registers. |
| 333 | void SetFrame(VirtualFrame* new_frame, RegisterFile* non_frame_registers); |
| 334 | |
| 335 | void DeleteFrame(); |
| 336 | |
| 337 | RegisterAllocator* allocator() const { return allocator_; } |
| 338 | |
| 339 | CodeGenState* state() { return state_; } |
| 340 | void set_state(CodeGenState* state) { state_ = state; } |
| 341 | |
| 342 | void AddDeferred(DeferredCode* code) { deferred_.Add(code); } |
| 343 | |
| 344 | bool in_spilled_code() const { return in_spilled_code_; } |
| 345 | void set_in_spilled_code(bool flag) { in_spilled_code_ = flag; } |
| 346 | |
| 347 | private: |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 348 | // Type of a member function that generates inline code for a native function. |
| 349 | typedef void (CodeGenerator::*InlineFunctionGenerator) |
| 350 | (ZoneList<Expression*>*); |
| 351 | |
| 352 | static const InlineFunctionGenerator kInlineFunctionGenerators[]; |
| 353 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 354 | // Construction/Destruction |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 355 | explicit CodeGenerator(MacroAssembler* masm); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 356 | |
| 357 | // Accessors |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 358 | inline bool is_eval(); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 359 | inline Scope* scope(); |
Steve Block | 1e0659c | 2011-05-24 12:43:12 +0100 | [diff] [blame] | 360 | inline StrictModeFlag strict_mode_flag(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 361 | |
| 362 | // Generating deferred code. |
| 363 | void ProcessDeferred(); |
| 364 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 365 | // State |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 366 | ControlDestination* destination() const { return state_->destination(); } |
| 367 | |
| 368 | // Track loop nesting level. |
| 369 | int loop_nesting() const { return loop_nesting_; } |
| 370 | void IncrementLoopNesting() { loop_nesting_++; } |
| 371 | void DecrementLoopNesting() { loop_nesting_--; } |
| 372 | |
| 373 | |
| 374 | // Node visitors. |
| 375 | void VisitStatements(ZoneList<Statement*>* statements); |
| 376 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 377 | virtual void VisitSlot(Slot* node); |
| 378 | #define DEF_VISIT(type) \ |
| 379 | virtual void Visit##type(type* node); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 380 | AST_NODE_LIST(DEF_VISIT) |
| 381 | #undef DEF_VISIT |
| 382 | |
| 383 | // Visit a statement and then spill the virtual frame if control flow can |
| 384 | // reach the end of the statement (ie, it does not exit via break, |
| 385 | // continue, return, or throw). This function is used temporarily while |
| 386 | // the code generator is being transformed. |
| 387 | void VisitAndSpill(Statement* statement); |
| 388 | |
| 389 | // Visit a list of statements and then spill the virtual frame if control |
| 390 | // flow can reach the end of the list. |
| 391 | void VisitStatementsAndSpill(ZoneList<Statement*>* statements); |
| 392 | |
| 393 | // Main code generation function |
Andrei Popescu | 402d937 | 2010-02-26 13:31:12 +0000 | [diff] [blame] | 394 | void Generate(CompilationInfo* info); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 395 | |
| 396 | // Generate the return sequence code. Should be called no more than |
| 397 | // once per compiled function, immediately after binding the return |
| 398 | // target (which can not be done more than once). |
| 399 | void GenerateReturnSequence(Result* return_value); |
| 400 | |
Steve Block | 8defd9f | 2010-07-08 12:39:36 +0100 | [diff] [blame] | 401 | // Generate code for a fast smi loop. |
| 402 | void GenerateFastSmiLoop(ForStatement* node); |
| 403 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 404 | // Returns the arguments allocation mode. |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 405 | ArgumentsAllocationMode ArgumentsMode(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 406 | |
| 407 | // Store the arguments object and allocate it if necessary. |
| 408 | Result StoreArgumentsObject(bool initial); |
| 409 | |
| 410 | // The following are used by class Reference. |
| 411 | void LoadReference(Reference* ref); |
| 412 | void UnloadReference(Reference* ref); |
| 413 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 414 | Operand SlotOperand(Slot* slot, Register tmp); |
| 415 | |
| 416 | Operand ContextSlotOperandCheckExtensions(Slot* slot, |
| 417 | Result tmp, |
| 418 | JumpTarget* slow); |
| 419 | |
| 420 | // Expressions |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 421 | void LoadCondition(Expression* x, |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 422 | ControlDestination* destination, |
| 423 | bool force_control); |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 424 | void Load(Expression* expr); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 425 | void LoadGlobal(); |
| 426 | void LoadGlobalReceiver(); |
| 427 | |
| 428 | // Generate code to push the value of an expression on top of the frame |
| 429 | // and then spill the frame fully to memory. This function is used |
| 430 | // temporarily while the code generator is being transformed. |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 431 | void LoadAndSpill(Expression* expression); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 432 | |
| 433 | // Read a value from a slot and leave it on top of the expression stack. |
| 434 | void LoadFromSlot(Slot* slot, TypeofState typeof_state); |
| 435 | void LoadFromSlotCheckForArguments(Slot* slot, TypeofState state); |
| 436 | Result LoadFromGlobalSlotCheckExtensions(Slot* slot, |
| 437 | TypeofState typeof_state, |
| 438 | JumpTarget* slow); |
| 439 | |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 440 | // Support for loading from local/global variables and arguments |
| 441 | // whose location is known unless they are shadowed by |
| 442 | // eval-introduced bindings. Generates no code for unsupported slot |
| 443 | // types and therefore expects to fall through to the slow jump target. |
| 444 | void EmitDynamicLoadFromSlotFastCase(Slot* slot, |
| 445 | TypeofState typeof_state, |
| 446 | Result* result, |
| 447 | JumpTarget* slow, |
| 448 | JumpTarget* done); |
| 449 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 450 | // Store the value on top of the expression stack into a slot, leaving the |
| 451 | // value in place. |
| 452 | void StoreToSlot(Slot* slot, InitState init_state); |
| 453 | |
Kristian Monsen | 50ef84f | 2010-07-29 15:18:00 +0100 | [diff] [blame] | 454 | // Support for compiling assignment expressions. |
| 455 | void EmitSlotAssignment(Assignment* node); |
| 456 | void EmitNamedPropertyAssignment(Assignment* node); |
| 457 | void EmitKeyedPropertyAssignment(Assignment* node); |
| 458 | |
Leon Clarke | f7060e2 | 2010-06-03 12:02:55 +0100 | [diff] [blame] | 459 | // Receiver is passed on the frame and not consumed. |
| 460 | Result EmitNamedLoad(Handle<String> name, bool is_contextual); |
| 461 | |
Kristian Monsen | 50ef84f | 2010-07-29 15:18:00 +0100 | [diff] [blame] | 462 | // If the store is contextual, value is passed on the frame and consumed. |
| 463 | // Otherwise, receiver and value are passed on the frame and consumed. |
| 464 | Result EmitNamedStore(Handle<String> name, bool is_contextual); |
| 465 | |
Leon Clarke | d91b9f7 | 2010-01-27 17:25:45 +0000 | [diff] [blame] | 466 | // Load a property of an object, returning it in a Result. |
| 467 | // The object and the property name are passed on the stack, and |
| 468 | // not changed. |
Leon Clarke | f7060e2 | 2010-06-03 12:02:55 +0100 | [diff] [blame] | 469 | Result EmitKeyedLoad(); |
Leon Clarke | d91b9f7 | 2010-01-27 17:25:45 +0000 | [diff] [blame] | 470 | |
Kristian Monsen | 50ef84f | 2010-07-29 15:18:00 +0100 | [diff] [blame] | 471 | // Receiver, key, and value are passed on the frame and consumed. |
| 472 | Result EmitKeyedStore(StaticType* key_type); |
| 473 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 474 | // Special code for typeof expressions: Unfortunately, we must |
| 475 | // be careful when loading the expression in 'typeof' |
| 476 | // expressions. We are not allowed to throw reference errors for |
| 477 | // non-existing properties of the global object, so we must make it |
| 478 | // look like an explicit property access, instead of an access |
| 479 | // through the context chain. |
| 480 | void LoadTypeofExpression(Expression* x); |
| 481 | |
| 482 | // Translate the value on top of the frame into control flow to the |
| 483 | // control destination. |
| 484 | void ToBoolean(ControlDestination* destination); |
| 485 | |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 486 | // Generate code that computes a shortcutting logical operation. |
| 487 | void GenerateLogicalBooleanOperation(BinaryOperation* node); |
| 488 | |
| 489 | void GenericBinaryOperation(BinaryOperation* expr, |
| 490 | OverwriteMode overwrite_mode); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 491 | |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 492 | // Generate a stub call from the virtual frame. |
| 493 | Result GenerateGenericBinaryOpStubCall(GenericBinaryOpStub* stub, |
| 494 | Result* left, |
| 495 | Result* right); |
| 496 | |
Kristian Monsen | 50ef84f | 2010-07-29 15:18:00 +0100 | [diff] [blame] | 497 | // Emits code sequence that jumps to a JumpTarget if the inputs |
| 498 | // are both smis. Cannot be in MacroAssembler because it takes |
| 499 | // advantage of TypeInfo to skip unneeded checks. |
| 500 | void JumpIfBothSmiUsingTypeInfo(Result* left, |
| 501 | Result* right, |
| 502 | JumpTarget* both_smi); |
| 503 | |
Ben Murdoch | 7f4d5bd | 2010-06-15 11:15:29 +0100 | [diff] [blame] | 504 | // Emits code sequence that jumps to deferred code if the input |
| 505 | // is not a smi. Cannot be in MacroAssembler because it takes |
| 506 | // advantage of TypeInfo to skip unneeded checks. |
| 507 | void JumpIfNotSmiUsingTypeInfo(Register reg, |
| 508 | TypeInfo type, |
| 509 | DeferredCode* deferred); |
| 510 | |
| 511 | // Emits code sequence that jumps to deferred code if the inputs |
| 512 | // are not both smis. Cannot be in MacroAssembler because it takes |
| 513 | // advantage of TypeInfo to skip unneeded checks. |
| 514 | void JumpIfNotBothSmiUsingTypeInfo(Register left, |
| 515 | Register right, |
| 516 | TypeInfo left_info, |
| 517 | TypeInfo right_info, |
| 518 | DeferredCode* deferred); |
| 519 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 520 | // If possible, combine two constant smi values using op to produce |
| 521 | // a smi result, and push it on the virtual frame, all at compile time. |
| 522 | // Returns true if it succeeds. Otherwise it has no effect. |
| 523 | bool FoldConstantSmis(Token::Value op, int left, int right); |
| 524 | |
| 525 | // Emit code to perform a binary operation on a constant |
| 526 | // smi and a likely smi. Consumes the Result *operand. |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 527 | Result ConstantSmiBinaryOperation(BinaryOperation* expr, |
Leon Clarke | d91b9f7 | 2010-01-27 17:25:45 +0000 | [diff] [blame] | 528 | Result* operand, |
| 529 | Handle<Object> constant_operand, |
Leon Clarke | d91b9f7 | 2010-01-27 17:25:45 +0000 | [diff] [blame] | 530 | bool reversed, |
| 531 | OverwriteMode overwrite_mode); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 532 | |
| 533 | // Emit code to perform a binary operation on two likely smis. |
| 534 | // The code to handle smi arguments is produced inline. |
| 535 | // Consumes the Results *left and *right. |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 536 | Result LikelySmiBinaryOperation(BinaryOperation* expr, |
Leon Clarke | d91b9f7 | 2010-01-27 17:25:45 +0000 | [diff] [blame] | 537 | Result* left, |
| 538 | Result* right, |
| 539 | OverwriteMode overwrite_mode); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 540 | |
Andrei Popescu | 402d937 | 2010-02-26 13:31:12 +0000 | [diff] [blame] | 541 | void Comparison(AstNode* node, |
| 542 | Condition cc, |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 543 | bool strict, |
| 544 | ControlDestination* destination); |
Ben Murdoch | 3bec4d2 | 2010-07-22 14:51:16 +0100 | [diff] [blame] | 545 | |
| 546 | // If at least one of the sides is a constant smi, generate optimized code. |
| 547 | void ConstantSmiComparison(Condition cc, |
| 548 | bool strict, |
| 549 | ControlDestination* destination, |
| 550 | Result* left_side, |
| 551 | Result* right_side, |
| 552 | bool left_side_constant_smi, |
| 553 | bool right_side_constant_smi, |
| 554 | bool is_loop_condition); |
| 555 | |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 556 | void GenerateInlineNumberComparison(Result* left_side, |
| 557 | Result* right_side, |
| 558 | Condition cc, |
| 559 | ControlDestination* dest); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 560 | |
| 561 | // To prevent long attacker-controlled byte sequences, integer constants |
| 562 | // from the JavaScript source are loaded in two parts if they are larger |
| 563 | // than 16 bits. |
| 564 | static const int kMaxSmiInlinedBits = 16; |
| 565 | bool IsUnsafeSmi(Handle<Object> value); |
| 566 | // Load an integer constant x into a register target using |
| 567 | // at most 16 bits of user-controlled data per assembly operation. |
| 568 | void LoadUnsafeSmi(Register target, Handle<Object> value); |
| 569 | |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 570 | void CallWithArguments(ZoneList<Expression*>* arguments, |
| 571 | CallFunctionFlags flags, |
| 572 | int position); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 573 | |
Leon Clarke | d91b9f7 | 2010-01-27 17:25:45 +0000 | [diff] [blame] | 574 | // An optimized implementation of expressions of the form |
| 575 | // x.apply(y, arguments). We call x the applicand and y the receiver. |
| 576 | // The optimization avoids allocating an arguments object if possible. |
| 577 | void CallApplyLazy(Expression* applicand, |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 578 | Expression* receiver, |
| 579 | VariableProxy* arguments, |
| 580 | int position); |
| 581 | |
| 582 | void CheckStack(); |
| 583 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 584 | bool CheckForInlineRuntimeCall(CallRuntime* node); |
Iain Merrick | 9ac36c9 | 2010-09-13 15:29:50 +0100 | [diff] [blame] | 585 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 586 | void ProcessDeclarations(ZoneList<Declaration*>* declarations); |
| 587 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 588 | // Declare global variables and functions in the given array of |
| 589 | // name/value pairs. |
| 590 | void DeclareGlobals(Handle<FixedArray> pairs); |
| 591 | |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 592 | // Instantiate the function based on the shared function info. |
Shimeng (Simon) Wang | 8a31eba | 2010-12-06 19:01:33 -0800 | [diff] [blame] | 593 | void InstantiateFunction(Handle<SharedFunctionInfo> function_info, |
| 594 | bool pretenure); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 595 | |
| 596 | // Support for type checks. |
| 597 | void GenerateIsSmi(ZoneList<Expression*>* args); |
| 598 | void GenerateIsNonNegativeSmi(ZoneList<Expression*>* args); |
| 599 | void GenerateIsArray(ZoneList<Expression*>* args); |
Andrei Popescu | 402d937 | 2010-02-26 13:31:12 +0000 | [diff] [blame] | 600 | void GenerateIsRegExp(ZoneList<Expression*>* args); |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 601 | void GenerateIsObject(ZoneList<Expression*>* args); |
Ben Murdoch | 3bec4d2 | 2010-07-22 14:51:16 +0100 | [diff] [blame] | 602 | void GenerateIsSpecObject(ZoneList<Expression*>* args); |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 603 | void GenerateIsFunction(ZoneList<Expression*>* args); |
Leon Clarke | d91b9f7 | 2010-01-27 17:25:45 +0000 | [diff] [blame] | 604 | void GenerateIsUndetectableObject(ZoneList<Expression*>* args); |
Iain Merrick | 7568138 | 2010-08-19 15:07:18 +0100 | [diff] [blame] | 605 | void GenerateIsStringWrapperSafeForDefaultValueOf( |
| 606 | ZoneList<Expression*>* args); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 607 | |
| 608 | // Support for construct call checks. |
| 609 | void GenerateIsConstructCall(ZoneList<Expression*>* args); |
| 610 | |
| 611 | // Support for arguments.length and arguments[?]. |
| 612 | void GenerateArgumentsLength(ZoneList<Expression*>* args); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 613 | void GenerateArguments(ZoneList<Expression*>* args); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 614 | |
| 615 | // Support for accessing the class and value fields of an object. |
| 616 | void GenerateClassOf(ZoneList<Expression*>* args); |
| 617 | void GenerateValueOf(ZoneList<Expression*>* args); |
| 618 | void GenerateSetValueOf(ZoneList<Expression*>* args); |
| 619 | |
| 620 | // Fast support for charCodeAt(n). |
Ben Murdoch | 7f4d5bd | 2010-06-15 11:15:29 +0100 | [diff] [blame] | 621 | void GenerateStringCharCodeAt(ZoneList<Expression*>* args); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 622 | |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 623 | // Fast support for string.charAt(n) and string[n]. |
Ben Murdoch | 7f4d5bd | 2010-06-15 11:15:29 +0100 | [diff] [blame] | 624 | void GenerateStringCharFromCode(ZoneList<Expression*>* args); |
| 625 | |
| 626 | // Fast support for string.charAt(n) and string[n]. |
| 627 | void GenerateStringCharAt(ZoneList<Expression*>* args); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 628 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 629 | // Fast support for object equality testing. |
| 630 | void GenerateObjectEquals(ZoneList<Expression*>* args); |
| 631 | |
| 632 | void GenerateLog(ZoneList<Expression*>* args); |
| 633 | |
| 634 | void GenerateGetFramePointer(ZoneList<Expression*>* args); |
| 635 | |
| 636 | // Fast support for Math.random(). |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 637 | void GenerateRandomHeapNumber(ZoneList<Expression*>* args); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 638 | |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 639 | // Fast support for StringAdd. |
| 640 | void GenerateStringAdd(ZoneList<Expression*>* args); |
| 641 | |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 642 | // Fast support for SubString. |
| 643 | void GenerateSubString(ZoneList<Expression*>* args); |
| 644 | |
| 645 | // Fast support for StringCompare. |
| 646 | void GenerateStringCompare(ZoneList<Expression*>* args); |
| 647 | |
| 648 | // Support for direct calls from JavaScript to native RegExp code. |
| 649 | void GenerateRegExpExec(ZoneList<Expression*>* args); |
| 650 | |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 651 | void GenerateRegExpConstructResult(ZoneList<Expression*>* args); |
| 652 | |
| 653 | // Support for fast native caches. |
| 654 | void GenerateGetFromCache(ZoneList<Expression*>* args); |
| 655 | |
Andrei Popescu | 402d937 | 2010-02-26 13:31:12 +0000 | [diff] [blame] | 656 | // Fast support for number to string. |
| 657 | void GenerateNumberToString(ZoneList<Expression*>* args); |
| 658 | |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 659 | // Fast swapping of elements. Takes three expressions, the object and two |
| 660 | // indices. This should only be used if the indices are known to be |
| 661 | // non-negative and within bounds of the elements array at the call site. |
| 662 | void GenerateSwapElements(ZoneList<Expression*>* args); |
| 663 | |
| 664 | // Fast call for custom callbacks. |
| 665 | void GenerateCallFunction(ZoneList<Expression*>* args); |
| 666 | |
Andrei Popescu | 402d937 | 2010-02-26 13:31:12 +0000 | [diff] [blame] | 667 | // Fast call to math functions. |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 668 | void GenerateMathPow(ZoneList<Expression*>* args); |
Andrei Popescu | 402d937 | 2010-02-26 13:31:12 +0000 | [diff] [blame] | 669 | void GenerateMathSin(ZoneList<Expression*>* args); |
| 670 | void GenerateMathCos(ZoneList<Expression*>* args); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 671 | void GenerateMathSqrt(ZoneList<Expression*>* args); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 672 | void GenerateMathLog(ZoneList<Expression*>* args); |
Andrei Popescu | 402d937 | 2010-02-26 13:31:12 +0000 | [diff] [blame] | 673 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 674 | // Check whether two RegExps are equivalent. |
Ben Murdoch | bb769b2 | 2010-08-11 14:56:33 +0100 | [diff] [blame] | 675 | void GenerateIsRegExpEquivalent(ZoneList<Expression*>* args); |
| 676 | |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 677 | void GenerateHasCachedArrayIndex(ZoneList<Expression*>* args); |
| 678 | void GenerateGetCachedArrayIndex(ZoneList<Expression*>* args); |
Shimeng (Simon) Wang | 8a31eba | 2010-12-06 19:01:33 -0800 | [diff] [blame] | 679 | void GenerateFastAsciiArrayJoin(ZoneList<Expression*>* args); |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 680 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 681 | // Simple condition analysis. |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 682 | enum ConditionAnalysis { |
| 683 | ALWAYS_TRUE, |
| 684 | ALWAYS_FALSE, |
| 685 | DONT_KNOW |
| 686 | }; |
| 687 | ConditionAnalysis AnalyzeCondition(Expression* cond); |
| 688 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 689 | // Methods used to indicate which source code is generated for. Source |
| 690 | // positions are collected by the assembler and emitted with the relocation |
| 691 | // information. |
| 692 | void CodeForFunctionPosition(FunctionLiteral* fun); |
| 693 | void CodeForReturnPosition(FunctionLiteral* fun); |
| 694 | void CodeForStatementPosition(Statement* node); |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 695 | void CodeForDoWhileConditionPosition(DoWhileStatement* stmt); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 696 | void CodeForSourcePosition(int pos); |
| 697 | |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 698 | void SetTypeForStackSlot(Slot* slot, TypeInfo info); |
| 699 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 700 | #ifdef DEBUG |
| 701 | // True if the registers are valid for entry to a block. There should |
| 702 | // be no frame-external references to (non-reserved) registers. |
| 703 | bool HasValidEntryRegisters(); |
| 704 | #endif |
| 705 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 706 | ZoneList<DeferredCode*> deferred_; |
| 707 | |
| 708 | // Assembler |
| 709 | MacroAssembler* masm_; // to generate code |
| 710 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 711 | CompilationInfo* info_; |
| 712 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 713 | // Code generation state |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 714 | VirtualFrame* frame_; |
| 715 | RegisterAllocator* allocator_; |
| 716 | CodeGenState* state_; |
| 717 | int loop_nesting_; |
| 718 | |
| 719 | // Jump targets. |
| 720 | // The target of the return from the function. |
| 721 | BreakTarget function_return_; |
| 722 | |
| 723 | // True if the function return is shadowed (ie, jumping to the target |
| 724 | // function_return_ does not jump to the true function return, but rather |
| 725 | // to some unlinking code). |
| 726 | bool function_return_is_shadowed_; |
| 727 | |
| 728 | // True when we are in code that expects the virtual frame to be fully |
| 729 | // spilled. Some virtual frame function are disabled in DEBUG builds when |
| 730 | // called from spilled code, because they do not leave the virtual frame |
| 731 | // in a spilled state. |
| 732 | bool in_spilled_code_; |
| 733 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 734 | friend class VirtualFrame; |
| 735 | friend class JumpTarget; |
| 736 | friend class Reference; |
| 737 | friend class Result; |
Leon Clarke | 4515c47 | 2010-02-03 11:58:03 +0000 | [diff] [blame] | 738 | friend class FastCodeGenerator; |
Leon Clarke | d91b9f7 | 2010-01-27 17:25:45 +0000 | [diff] [blame] | 739 | friend class FullCodeGenerator; |
| 740 | friend class FullCodeGenSyntaxChecker; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 741 | |
| 742 | friend class CodeGeneratorPatcher; // Used in test-log-stack-tracer.cc |
| 743 | |
| 744 | DISALLOW_COPY_AND_ASSIGN(CodeGenerator); |
| 745 | }; |
| 746 | |
| 747 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 748 | } } // namespace v8::internal |
| 749 | |
| 750 | #endif // V8_X64_CODEGEN_X64_H_ |