Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: src/ia32/virtual-frame-ia32.h

Issue 1961004: First step towards making JumpTarget work on ARM. Instead... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 12 matching lines...) Expand all
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 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. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_IA32_VIRTUAL_FRAME_IA32_H_ 28 #ifndef V8_IA32_VIRTUAL_FRAME_IA32_H_
29 #define V8_IA32_VIRTUAL_FRAME_IA32_H_ 29 #define V8_IA32_VIRTUAL_FRAME_IA32_H_
30 30
31 #include "type-info.h" 31 #include "type-info.h"
32 #include "register-allocator.h" 32 #include "register-allocator.h"
33 #include "scopes.h" 33 #include "scopes.h"
Søren Thygesen Gjesse 2010/05/06 07:48:11 Sort includes.
34 #include "codegen.h"
34 35
35 namespace v8 { 36 namespace v8 {
36 namespace internal { 37 namespace internal {
37 38
38 // ------------------------------------------------------------------------- 39 // -------------------------------------------------------------------------
39 // Virtual frames 40 // Virtual frames
40 // 41 //
41 // The virtual frame is an abstraction of the physical stack frame. It 42 // The virtual frame is an abstraction of the physical stack frame. It
42 // encapsulates the parameters, frame-allocated locals, and the expression 43 // encapsulates the parameters, frame-allocated locals, and the expression
43 // stack. It supports push/pop operations on the expression stack, as well 44 // stack. It supports push/pop operations on the expression stack, as well
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 int element_count() { return elements_.length(); } 91 int element_count() { return elements_.length(); }
91 92
92 // The height of the virtual expression stack. 93 // The height of the virtual expression stack.
93 int height() { return element_count() - expression_base_index(); } 94 int height() { return element_count() - expression_base_index(); }
94 95
95 int register_location(int num) { 96 int register_location(int num) {
96 ASSERT(num >= 0 && num < RegisterAllocator::kNumRegisters); 97 ASSERT(num >= 0 && num < RegisterAllocator::kNumRegisters);
97 return register_locations_[num]; 98 return register_locations_[num];
98 } 99 }
99 100
100 int register_location(Register reg) { 101 inline int register_location(Register reg);
101 return register_locations_[RegisterAllocator::ToNumber(reg)];
102 }
103 102
104 void set_register_location(Register reg, int index) { 103 inline void set_register_location(Register reg, int index);
105 register_locations_[RegisterAllocator::ToNumber(reg)] = index;
106 }
107 104
108 bool is_used(int num) { 105 bool is_used(int num) {
109 ASSERT(num >= 0 && num < RegisterAllocator::kNumRegisters); 106 ASSERT(num >= 0 && num < RegisterAllocator::kNumRegisters);
110 return register_locations_[num] != kIllegalIndex; 107 return register_locations_[num] != kIllegalIndex;
111 } 108 }
112 109
113 bool is_used(Register reg) { 110 inline bool is_used(Register reg);
114 return register_locations_[RegisterAllocator::ToNumber(reg)]
115 != kIllegalIndex;
116 }
117 111
118 // Add extra in-memory elements to the top of the frame to match an actual 112 // Add extra in-memory elements to the top of the frame to match an actual
119 // frame (eg, the frame after an exception handler is pushed). No code is 113 // frame (eg, the frame after an exception handler is pushed). No code is
120 // emitted. 114 // emitted.
121 void Adjust(int count); 115 void Adjust(int count);
122 116
123 // Forget count elements from the top of the frame all in-memory 117 // Forget count elements from the top of the frame all in-memory
124 // (including synced) and adjust the stack pointer downward, to 118 // (including synced) and adjust the stack pointer downward, to
125 // match an external frame effect (examples include a call removing 119 // match an external frame effect (examples include a call removing
126 // its arguments, and exiting a try/catch removing an exception 120 // its arguments, and exiting a try/catch removing an exception
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 // An element of the expression stack as an assembly operand. 204 // An element of the expression stack as an assembly operand.
211 Operand ElementAt(int index) const { 205 Operand ElementAt(int index) const {
212 return Operand(esp, index * kPointerSize); 206 return Operand(esp, index * kPointerSize);
213 } 207 }
214 208
215 // Random-access store to a frame-top relative frame element. The result 209 // Random-access store to a frame-top relative frame element. The result
216 // becomes owned by the frame and is invalidated. 210 // becomes owned by the frame and is invalidated.
217 void SetElementAt(int index, Result* value); 211 void SetElementAt(int index, Result* value);
218 212
219 // Set a frame element to a constant. The index is frame-top relative. 213 // Set a frame element to a constant. The index is frame-top relative.
220 void SetElementAt(int index, Handle<Object> value) { 214 inline void SetElementAt(int index, Handle<Object> value);
221 Result temp(value);
222 SetElementAt(index, &temp);
223 }
224 215
225 void PushElementAt(int index) { 216 void PushElementAt(int index) {
226 PushFrameSlotAt(element_count() - index - 1); 217 PushFrameSlotAt(element_count() - index - 1);
227 } 218 }
228 219
229 void StoreToElementAt(int index) { 220 void StoreToElementAt(int index) {
230 StoreToFrameSlotAt(element_count() - index - 1); 221 StoreToFrameSlotAt(element_count() - index - 1);
231 } 222 }
232 223
233 // A frame-allocated local as an assembly operand. 224 // A frame-allocated local as an assembly operand.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 // The receiver frame slot. 299 // The receiver frame slot.
309 Operand Receiver() { 300 Operand Receiver() {
310 return ParameterAt(-1); 301 return ParameterAt(-1);
311 } 302 }
312 303
313 // Push a try-catch or try-finally handler on top of the virtual frame. 304 // Push a try-catch or try-finally handler on top of the virtual frame.
314 void PushTryHandler(HandlerType type); 305 void PushTryHandler(HandlerType type);
315 306
316 // Call stub given the number of arguments it expects on (and 307 // Call stub given the number of arguments it expects on (and
317 // removes from) the stack. 308 // removes from) the stack.
318 Result CallStub(CodeStub* stub, int arg_count) { 309 inline Result CallStub(CodeStub* stub, int arg_count);
319 PrepareForCall(arg_count, arg_count);
320 return RawCallStub(stub);
321 }
322 310
323 // Call stub that takes a single argument passed in eax. The 311 // Call stub that takes a single argument passed in eax. The
324 // argument is given as a result which does not have to be eax or 312 // argument is given as a result which does not have to be eax or
325 // even a register. The argument is consumed by the call. 313 // even a register. The argument is consumed by the call.
326 Result CallStub(CodeStub* stub, Result* arg); 314 Result CallStub(CodeStub* stub, Result* arg);
327 315
328 // Call stub that takes a pair of arguments passed in edx (arg0) and 316 // Call stub that takes a pair of arguments passed in edx (arg0) and
329 // eax (arg1). The arguments are given as results which do not have 317 // eax (arg1). The arguments are given as results which do not have
330 // to be in the proper registers or even in registers. The 318 // to be in the proper registers or even in registers. The
331 // arguments are consumed by the call. 319 // arguments are consumed by the call.
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 454
467 // The index of the element that is at the processor's stack pointer 455 // The index of the element that is at the processor's stack pointer
468 // (the esp register). 456 // (the esp register).
469 int stack_pointer_; 457 int stack_pointer_;
470 458
471 // The index of the register frame element using each register, or 459 // The index of the register frame element using each register, or
472 // kIllegalIndex if a register is not on the frame. 460 // kIllegalIndex if a register is not on the frame.
473 int register_locations_[RegisterAllocator::kNumRegisters]; 461 int register_locations_[RegisterAllocator::kNumRegisters];
474 462
475 // The number of frame-allocated locals and parameters respectively. 463 // The number of frame-allocated locals and parameters respectively.
476 int parameter_count() { 464 inline int parameter_count();
477 return cgen()->scope()->num_parameters(); 465
478 } 466 inline int local_count();
479 int local_count() {
480 return cgen()->scope()->num_stack_slots();
481 }
482 467
483 // The index of the element that is at the processor's frame pointer 468 // The index of the element that is at the processor's frame pointer
484 // (the ebp register). The parameters, receiver, and return address 469 // (the ebp register). The parameters, receiver, and return address
485 // are below the frame pointer. 470 // are below the frame pointer.
486 int frame_pointer() { 471 int frame_pointer() {
487 return parameter_count() + 2; 472 return parameter_count() + 2;
488 } 473 }
489 474
490 // The index of the first parameter. The receiver lies below the first 475 // The index of the first parameter. The receiver lies below the first
491 // parameter. 476 // parameter.
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 inline bool Equals(VirtualFrame* other); 612 inline bool Equals(VirtualFrame* other);
628 613
629 // Classes that need raw access to the elements_ array. 614 // Classes that need raw access to the elements_ array.
630 friend class DeferredCode; 615 friend class DeferredCode;
631 friend class JumpTarget; 616 friend class JumpTarget;
632 }; 617 };
633 618
634 } } // namespace v8::internal 619 } } // namespace v8::internal
635 620
636 #endif // V8_IA32_VIRTUAL_FRAME_IA32_H_ 621 #endif // V8_IA32_VIRTUAL_FRAME_IA32_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698