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

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

Issue 113764: Add an elements_.length() accessor to the VirtualFrame class and use... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 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
« no previous file with comments | « src/virtual-frame.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 75
76 // Construct a virtual frame as a clone of an existing one. 76 // Construct a virtual frame as a clone of an existing one.
77 explicit VirtualFrame(VirtualFrame* original); 77 explicit VirtualFrame(VirtualFrame* original);
78 78
79 CodeGenerator* cgen() { return CodeGeneratorScope::Current(); } 79 CodeGenerator* cgen() { return CodeGeneratorScope::Current(); }
80 MacroAssembler* masm() { return cgen()->masm(); } 80 MacroAssembler* masm() { return cgen()->masm(); }
81 81
82 // Create a duplicate of an existing valid frame element. 82 // Create a duplicate of an existing valid frame element.
83 FrameElement CopyElementAt(int index); 83 FrameElement CopyElementAt(int index);
84 84
85 // The number of elements on the virtual frame.
86 int element_count() { return elements_.length(); }
87
85 // The height of the virtual expression stack. 88 // The height of the virtual expression stack.
86 int height() { 89 int height() {
87 return elements_.length() - expression_base_index(); 90 return element_count() - expression_base_index();
88 } 91 }
89 92
90 int register_index(Register reg) { 93 int register_index(Register reg) {
91 return register_locations_[reg.code()]; 94 return register_locations_[reg.code()];
92 } 95 }
93 96
94 bool is_used(int reg_code) { 97 bool is_used(int reg_code) {
95 return register_locations_[reg_code] != kIllegalIndex; 98 return register_locations_[reg_code] != kIllegalIndex;
96 } 99 }
97 100
98 bool is_used(Register reg) { 101 bool is_used(Register reg) {
99 return is_used(reg.code()); 102 return is_used(reg.code());
100 } 103 }
101 104
102 // Add extra in-memory elements to the top of the frame to match an actual 105 // Add extra in-memory elements to the top of the frame to match an actual
103 // frame (eg, the frame after an exception handler is pushed). No code is 106 // frame (eg, the frame after an exception handler is pushed). No code is
104 // emitted. 107 // emitted.
105 void Adjust(int count); 108 void Adjust(int count);
106 109
107 // Forget count elements from the top of the frame all in-memory 110 // Forget count elements from the top of the frame all in-memory
108 // (including synced) and adjust the stack pointer downward, to 111 // (including synced) and adjust the stack pointer downward, to
109 // match an external frame effect (examples include a call removing 112 // match an external frame effect (examples include a call removing
110 // its arguments, and exiting a try/catch removing an exception 113 // its arguments, and exiting a try/catch removing an exception
111 // handler). No code will be emitted. 114 // handler). No code will be emitted.
112 void Forget(int count) { 115 void Forget(int count) {
113 ASSERT(count >= 0); 116 ASSERT(count >= 0);
114 ASSERT(stack_pointer_ == elements_.length() - 1); 117 ASSERT(stack_pointer_ == element_count() - 1);
115 stack_pointer_ -= count; 118 stack_pointer_ -= count;
116 ForgetElements(count); 119 ForgetElements(count);
117 } 120 }
118 121
119 // Forget count elements from the top of the frame without adjusting 122 // Forget count elements from the top of the frame without adjusting
120 // the stack pointer downward. This is used, for example, before 123 // the stack pointer downward. This is used, for example, before
121 // merging frames at break, continue, and return targets. 124 // merging frames at break, continue, and return targets.
122 void ForgetElements(int count); 125 void ForgetElements(int count);
123 126
124 // Spill all values from the frame to memory. 127 // Spill all values from the frame to memory.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 // becomes owned by the frame and is invalidated. 206 // becomes owned by the frame and is invalidated.
204 void SetElementAt(int index, Result* value); 207 void SetElementAt(int index, Result* value);
205 208
206 // Set a frame element to a constant. The index is frame-top relative. 209 // Set a frame element to a constant. The index is frame-top relative.
207 void SetElementAt(int index, Handle<Object> value) { 210 void SetElementAt(int index, Handle<Object> value) {
208 Result temp(value); 211 Result temp(value);
209 SetElementAt(index, &temp); 212 SetElementAt(index, &temp);
210 } 213 }
211 214
212 void PushElementAt(int index) { 215 void PushElementAt(int index) {
213 PushFrameSlotAt(elements_.length() - index - 1); 216 PushFrameSlotAt(element_count() - index - 1);
214 } 217 }
215 218
216 void StoreToElementAt(int index) { 219 void StoreToElementAt(int index) {
217 StoreToFrameSlotAt(elements_.length() - index - 1); 220 StoreToFrameSlotAt(element_count() - index - 1);
218 } 221 }
219 222
220 // A frame-allocated local as an assembly operand. 223 // A frame-allocated local as an assembly operand.
221 Operand LocalAt(int index) { 224 Operand LocalAt(int index) {
222 ASSERT(0 <= index); 225 ASSERT(0 <= index);
223 ASSERT(index < local_count()); 226 ASSERT(index < local_count());
224 return Operand(rbp, kLocal0Offset - index * kPointerSize); 227 return Operand(rbp, kLocal0Offset - index * kPointerSize);
225 } 228 }
226 229
227 // Push a copy of the value of a local frame slot on top of the frame. 230 // Push a copy of the value of a local frame slot on top of the frame.
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 347
345 // Drop a number of elements from the top of the expression stack. May 348 // Drop a number of elements from the top of the expression stack. May
346 // emit code to affect the physical frame. Does not clobber any registers 349 // emit code to affect the physical frame. Does not clobber any registers
347 // excepting possibly the stack pointer. 350 // excepting possibly the stack pointer.
348 void Drop(int count); 351 void Drop(int count);
349 352
350 // Drop one element. 353 // Drop one element.
351 void Drop() { Drop(1); } 354 void Drop() { Drop(1); }
352 355
353 // Duplicate the top element of the frame. 356 // Duplicate the top element of the frame.
354 void Dup() { PushFrameSlotAt(elements_.length() - 1); } 357 void Dup() { PushFrameSlotAt(element_count() - 1); }
355 358
356 // Pop an element from the top of the expression stack. Returns a 359 // Pop an element from the top of the expression stack. Returns a
357 // Result, which may be a constant or a register. 360 // Result, which may be a constant or a register.
358 Result Pop(); 361 Result Pop();
359 362
360 // Pop and save an element from the top of the expression stack and 363 // Pop and save an element from the top of the expression stack and
361 // emit a corresponding pop instruction. 364 // emit a corresponding pop instruction.
362 void EmitPop(Register reg); 365 void EmitPop(Register reg);
363 void EmitPop(Operand operand); 366 void EmitPop(Operand operand);
364 367
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 // The index of the first local. Between the frame pointer and the 435 // The index of the first local. Between the frame pointer and the
433 // locals lie the context and the function. 436 // locals lie the context and the function.
434 int local0_index() { return frame_pointer() + 3; } 437 int local0_index() { return frame_pointer() + 3; }
435 438
436 // The index of the base of the expression stack. 439 // The index of the base of the expression stack.
437 int expression_base_index() { return local0_index() + local_count(); } 440 int expression_base_index() { return local0_index() + local_count(); }
438 441
439 // Convert a frame index into a frame pointer relative offset into the 442 // Convert a frame index into a frame pointer relative offset into the
440 // actual stack. 443 // actual stack.
441 int fp_relative(int index) { 444 int fp_relative(int index) {
442 ASSERT(index < elements_.length()); 445 ASSERT(index < element_count());
443 ASSERT(frame_pointer() < elements_.length()); // FP is on the frame. 446 ASSERT(frame_pointer() < element_count()); // FP is on the frame.
444 return (frame_pointer() - index) * kPointerSize; 447 return (frame_pointer() - index) * kPointerSize;
445 } 448 }
446 449
447 // Record an occurrence of a register in the virtual frame. This has the 450 // Record an occurrence of a register in the virtual frame. This has the
448 // effect of incrementing the register's external reference count and 451 // effect of incrementing the register's external reference count and
449 // of updating the index of the register's location in the frame. 452 // of updating the index of the register's location in the frame.
450 void Use(Register reg, int index) { 453 void Use(Register reg, int index) {
451 ASSERT(!is_used(reg)); 454 ASSERT(!is_used(reg));
452 register_locations_[reg.code()] = index; 455 register_locations_[reg.code()] = index;
453 cgen()->allocator()->Use(reg); 456 cgen()->allocator()->Use(reg);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 539
537 bool Equals(VirtualFrame* other); 540 bool Equals(VirtualFrame* other);
538 541
539 friend class JumpTarget; 542 friend class JumpTarget;
540 }; 543 };
541 544
542 545
543 } } // namespace v8::internal 546 } } // namespace v8::internal
544 547
545 #endif // V8_X64_VIRTUAL_FRAME_X64_H_ 548 #endif // V8_X64_VIRTUAL_FRAME_X64_H_
OLDNEW
« no previous file with comments | « src/virtual-frame.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698