OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 100 |
101 // Construct an initial virtual frame on entry to a JS function. | 101 // Construct an initial virtual frame on entry to a JS function. |
102 inline VirtualFrame(); | 102 inline VirtualFrame(); |
103 | 103 |
104 // Construct an invalid virtual frame, used by JumpTargets. | 104 // Construct an invalid virtual frame, used by JumpTargets. |
105 inline VirtualFrame(InvalidVirtualFrameInitializer* dummy); | 105 inline VirtualFrame(InvalidVirtualFrameInitializer* dummy); |
106 | 106 |
107 // Construct a virtual frame as a clone of an existing one. | 107 // Construct a virtual frame as a clone of an existing one. |
108 explicit inline VirtualFrame(VirtualFrame* original); | 108 explicit inline VirtualFrame(VirtualFrame* original); |
109 | 109 |
110 inline CodeGenerator* cgen(); | 110 inline CodeGenerator* cgen() const; |
111 inline MacroAssembler* masm(); | 111 inline MacroAssembler* masm(); |
112 | 112 |
113 // The number of elements on the virtual frame. | 113 // The number of elements on the virtual frame. |
114 int element_count() { return element_count_; } | 114 int element_count() const { return element_count_; } |
115 | 115 |
116 // The height of the virtual expression stack. | 116 // The height of the virtual expression stack. |
117 inline int height(); | 117 inline int height() const; |
118 | 118 |
119 bool is_used(int num) { | 119 bool is_used(int num) { |
120 switch (num) { | 120 switch (num) { |
121 case 0: { // r0. | 121 case 0: { // r0. |
122 return kR0InUse[top_of_stack_state_]; | 122 return kR0InUse[top_of_stack_state_]; |
123 } | 123 } |
124 case 1: { // r1. | 124 case 1: { // r1. |
125 return kR1InUse[top_of_stack_state_]; | 125 return kR1InUse[top_of_stack_state_]; |
126 } | 126 } |
127 case 2: | 127 case 2: |
(...skipping 27 matching lines...) Expand all Loading... |
155 // the frame after a runtime call). No code is emitted except to bring the | 155 // the frame after a runtime call). No code is emitted except to bring the |
156 // frame to a spilled state. | 156 // frame to a spilled state. |
157 void Forget(int count) { | 157 void Forget(int count) { |
158 SpillAll(); | 158 SpillAll(); |
159 element_count_ -= count; | 159 element_count_ -= count; |
160 } | 160 } |
161 | 161 |
162 // Spill all values from the frame to memory. | 162 // Spill all values from the frame to memory. |
163 void SpillAll(); | 163 void SpillAll(); |
164 | 164 |
165 void AssertIsSpilled() { | 165 void AssertIsSpilled() const { |
166 ASSERT(top_of_stack_state_ == NO_TOS_REGISTERS); | 166 ASSERT(top_of_stack_state_ == NO_TOS_REGISTERS); |
167 ASSERT(register_allocation_map_ == 0); | 167 ASSERT(register_allocation_map_ == 0); |
168 } | 168 } |
169 | 169 |
170 void AssertIsNotSpilled() { | 170 void AssertIsNotSpilled() { |
171 ASSERT(!SpilledScope::is_spilled()); | 171 ASSERT(!SpilledScope::is_spilled()); |
172 } | 172 } |
173 | 173 |
174 // Spill all occurrences of a specific register from the frame. | 174 // Spill all occurrences of a specific register from the frame. |
175 void Spill(Register reg) { | 175 void Spill(Register reg) { |
176 UNIMPLEMENTED(); | 176 UNIMPLEMENTED(); |
177 } | 177 } |
178 | 178 |
179 // Spill all occurrences of an arbitrary register if possible. Return the | 179 // Spill all occurrences of an arbitrary register if possible. Return the |
180 // register spilled or no_reg if it was not possible to free any register | 180 // register spilled or no_reg if it was not possible to free any register |
181 // (ie, they all have frame-external references). Unimplemented. | 181 // (ie, they all have frame-external references). Unimplemented. |
182 Register SpillAnyRegister(); | 182 Register SpillAnyRegister(); |
183 | 183 |
184 // Make this virtual frame have a state identical to an expected virtual | 184 // Make this virtual frame have a state identical to an expected virtual |
185 // frame. As a side effect, code may be emitted to make this frame match | 185 // frame. As a side effect, code may be emitted to make this frame match |
186 // the expected one. | 186 // the expected one. |
187 void MergeTo(VirtualFrame* expected); | 187 void MergeTo(const VirtualFrame* expected, Condition cond = al); |
188 | 188 |
189 // Detach a frame from its code generator, perhaps temporarily. This | 189 // Detach a frame from its code generator, perhaps temporarily. This |
190 // tells the register allocator that it is free to use frame-internal | 190 // tells the register allocator that it is free to use frame-internal |
191 // registers. Used when the code generator's frame is switched from this | 191 // registers. Used when the code generator's frame is switched from this |
192 // one to NULL by an unconditional jump. | 192 // one to NULL by an unconditional jump. |
193 void DetachFromCodeGenerator() { | 193 void DetachFromCodeGenerator() { |
194 AssertIsSpilled(); | 194 AssertIsSpilled(); |
195 } | 195 } |
196 | 196 |
197 // (Re)attach a frame to its code generator. This informs the register | 197 // (Re)attach a frame to its code generator. This informs the register |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 int element_count_; | 419 int element_count_; |
420 TopOfStack top_of_stack_state_:3; | 420 TopOfStack top_of_stack_state_:3; |
421 int register_allocation_map_:kNumberOfAllocatedRegisters; | 421 int register_allocation_map_:kNumberOfAllocatedRegisters; |
422 | 422 |
423 // The index of the element that is at the processor's stack pointer | 423 // The index of the element that is at the processor's stack pointer |
424 // (the sp register). For now since everything is in memory it is given | 424 // (the sp register). For now since everything is in memory it is given |
425 // by the number of elements on the not-very-virtual stack frame. | 425 // by the number of elements on the not-very-virtual stack frame. |
426 int stack_pointer() { return element_count_ - 1; } | 426 int stack_pointer() { return element_count_ - 1; } |
427 | 427 |
428 // The number of frame-allocated locals and parameters respectively. | 428 // The number of frame-allocated locals and parameters respectively. |
429 inline int parameter_count(); | 429 inline int parameter_count() const; |
430 inline int local_count(); | 430 inline int local_count() const; |
431 | 431 |
432 // The index of the element that is at the processor's frame pointer | 432 // The index of the element that is at the processor's frame pointer |
433 // (the fp register). The parameters, receiver, function, and context | 433 // (the fp register). The parameters, receiver, function, and context |
434 // are below the frame pointer. | 434 // are below the frame pointer. |
435 inline int frame_pointer(); | 435 inline int frame_pointer() const; |
436 | 436 |
437 // The index of the first parameter. The receiver lies below the first | 437 // The index of the first parameter. The receiver lies below the first |
438 // parameter. | 438 // parameter. |
439 int param0_index() { return 1; } | 439 int param0_index() { return 1; } |
440 | 440 |
441 // The index of the context slot in the frame. It is immediately | 441 // The index of the context slot in the frame. It is immediately |
442 // below the frame pointer. | 442 // below the frame pointer. |
443 inline int context_index(); | 443 inline int context_index(); |
444 | 444 |
445 // The index of the function slot in the frame. It is below the frame | 445 // The index of the function slot in the frame. It is below the frame |
446 // pointer and context slot. | 446 // pointer and context slot. |
447 inline int function_index(); | 447 inline int function_index(); |
448 | 448 |
449 // The index of the first local. Between the frame pointer and the | 449 // The index of the first local. Between the frame pointer and the |
450 // locals lies the return address. | 450 // locals lies the return address. |
451 inline int local0_index(); | 451 inline int local0_index() const; |
452 | 452 |
453 // The index of the base of the expression stack. | 453 // The index of the base of the expression stack. |
454 inline int expression_base_index(); | 454 inline int expression_base_index() const; |
455 | 455 |
456 // Convert a frame index into a frame pointer relative offset into the | 456 // Convert a frame index into a frame pointer relative offset into the |
457 // actual stack. | 457 // actual stack. |
458 inline int fp_relative(int index); | 458 inline int fp_relative(int index); |
459 | 459 |
460 // Spill all elements in registers. Spill the top spilled_args elements | 460 // Spill all elements in registers. Spill the top spilled_args elements |
461 // on the frame. Sync all other frame elements. | 461 // on the frame. Sync all other frame elements. |
462 // Then drop dropped_args elements from the virtual frame, to match | 462 // Then drop dropped_args elements from the virtual frame, to match |
463 // the effect of an upcoming call that will drop them from the stack. | 463 // the effect of an upcoming call that will drop them from the stack. |
464 void PrepareForCall(int spilled_args, int dropped_args); | 464 void PrepareForCall(int spilled_args, int dropped_args); |
465 | 465 |
466 // If all top-of-stack registers are in use then the lowest one is pushed | 466 // If all top-of-stack registers are in use then the lowest one is pushed |
467 // onto the physical stack and made free. | 467 // onto the physical stack and made free. |
468 void EnsureOneFreeTOSRegister(); | 468 void EnsureOneFreeTOSRegister(); |
469 | 469 |
470 // Emit instructions to get the top of stack state from where we are to where | 470 // Emit instructions to get the top of stack state from where we are to where |
471 // we want to be. | 471 // we want to be. |
472 void MergeTOSTo(TopOfStack expected_state); | 472 void MergeTOSTo(TopOfStack expected_state, Condition cond); |
473 | 473 |
474 inline bool Equals(VirtualFrame* other); | 474 inline bool Equals(const VirtualFrame* other); |
475 | 475 |
476 friend class JumpTarget; | 476 friend class JumpTarget; |
477 }; | 477 }; |
478 | 478 |
479 | 479 |
480 } } // namespace v8::internal | 480 } } // namespace v8::internal |
481 | 481 |
482 #endif // V8_ARM_VIRTUAL_FRAME_ARM_H_ | 482 #endif // V8_ARM_VIRTUAL_FRAME_ARM_H_ |
OLD | NEW |