| Index: src/arm/virtual-frame-arm.h
|
| ===================================================================
|
| --- src/arm/virtual-frame-arm.h (revision 2055)
|
| +++ src/arm/virtual-frame-arm.h (working copy)
|
| @@ -83,21 +83,35 @@
|
| // Create a duplicate of an existing valid frame element.
|
| FrameElement CopyElementAt(int index);
|
|
|
| + // The number of elements on the virtual frame.
|
| + int element_count() { return elements_.length(); }
|
| +
|
| // The height of the virtual expression stack.
|
| int height() {
|
| - return elements_.length() - expression_base_index();
|
| + return element_count() - expression_base_index();
|
| }
|
|
|
| - int register_index(Register reg) {
|
| - return register_locations_[reg.code()];
|
| + int register_location(int num) {
|
| + ASSERT(num >= 0 && num < RegisterAllocator::kNumRegisters);
|
| + return register_locations_[num];
|
| }
|
|
|
| - bool is_used(int reg_code) {
|
| - return register_locations_[reg_code] != kIllegalIndex;
|
| + int register_location(Register reg) {
|
| + return register_locations_[RegisterAllocator::ToNumber(reg)];
|
| }
|
|
|
| + void set_register_location(Register reg, int index) {
|
| + register_locations_[RegisterAllocator::ToNumber(reg)] = index;
|
| + }
|
| +
|
| + bool is_used(int num) {
|
| + ASSERT(num >= 0 && num < RegisterAllocator::kNumRegisters);
|
| + return register_locations_[num] != kIllegalIndex;
|
| + }
|
| +
|
| bool is_used(Register reg) {
|
| - return is_used(reg.code());
|
| + return register_locations_[RegisterAllocator::ToNumber(reg)]
|
| + != kIllegalIndex;
|
| }
|
|
|
| // Add extra in-memory elements to the top of the frame to match an actual
|
| @@ -109,7 +123,7 @@
|
| // the frame after a runtime call). No code is emitted.
|
| void Forget(int count) {
|
| ASSERT(count >= 0);
|
| - ASSERT(stack_pointer_ == elements_.length() - 1);
|
| + ASSERT(stack_pointer_ == element_count() - 1);
|
| stack_pointer_ -= count;
|
| ForgetElements(count);
|
| }
|
| @@ -124,7 +138,7 @@
|
|
|
| // Spill all occurrences of a specific register from the frame.
|
| void Spill(Register reg) {
|
| - if (is_used(reg)) SpillElementAt(register_index(reg));
|
| + if (is_used(reg)) SpillElementAt(register_location(reg));
|
| }
|
|
|
| // Spill all occurrences of an arbitrary register if possible. Return the
|
| @@ -148,11 +162,8 @@
|
| // one to NULL by an unconditional jump.
|
| void DetachFromCodeGenerator() {
|
| RegisterAllocator* cgen_allocator = cgen()->allocator();
|
| - for (int i = 0; i < kNumRegisters; i++) {
|
| - if (is_used(i)) {
|
| - Register temp = { i };
|
| - cgen_allocator->Unuse(temp);
|
| - }
|
| + for (int i = 0; i < RegisterAllocator::kNumRegisters; i++) {
|
| + if (is_used(i)) cgen_allocator->Unuse(i);
|
| }
|
| }
|
|
|
| @@ -162,11 +173,8 @@
|
| // binding a label.
|
| void AttachToCodeGenerator() {
|
| RegisterAllocator* cgen_allocator = cgen()->allocator();
|
| - for (int i = 0; i < kNumRegisters; i++) {
|
| - if (is_used(i)) {
|
| - Register temp = { i };
|
| - cgen_allocator->Use(temp);
|
| - }
|
| + for (int i = 0; i < RegisterAllocator::kNumRegisters; i++) {
|
| + if (is_used(i)) cgen_allocator->Unuse(i);
|
| }
|
| }
|
|
|
| @@ -205,7 +213,7 @@
|
| }
|
|
|
| void PushElementAt(int index) {
|
| - PushFrameSlotAt(elements_.length() - index - 1);
|
| + PushFrameSlotAt(element_count() - index - 1);
|
| }
|
|
|
| // A frame-allocated local as an assembly operand.
|
| @@ -336,7 +344,7 @@
|
| void Drop() { Drop(1); }
|
|
|
| // Duplicate the top element of the frame.
|
| - void Dup() { PushFrameSlotAt(elements_.length() - 1); }
|
| + void Dup() { PushFrameSlotAt(element_count() - 1); }
|
|
|
| // Pop an element from the top of the expression stack. Returns a
|
| // Result, which may be a constant or a register.
|
| @@ -387,7 +395,7 @@
|
|
|
| // The index of the register frame element using each register, or
|
| // kIllegalIndex if a register is not on the frame.
|
| - int register_locations_[kNumRegisters];
|
| + int register_locations_[RegisterAllocator::kNumRegisters];
|
|
|
| // The number of frame-allocated locals and parameters respectively.
|
| int parameter_count() { return cgen()->scope()->num_parameters(); }
|
| @@ -420,8 +428,8 @@
|
| // Convert a frame index into a frame pointer relative offset into the
|
| // actual stack.
|
| int fp_relative(int index) {
|
| - ASSERT(index < elements_.length());
|
| - ASSERT(frame_pointer() < elements_.length()); // FP is on the frame.
|
| + ASSERT(index < element_count());
|
| + ASSERT(frame_pointer() < element_count()); // FP is on the frame.
|
| return (frame_pointer() - index) * kPointerSize;
|
| }
|
|
|
| @@ -430,7 +438,7 @@
|
| // of updating the index of the register's location in the frame.
|
| void Use(Register reg, int index) {
|
| ASSERT(!is_used(reg));
|
| - register_locations_[reg.code()] = index;
|
| + set_register_location(reg, index);
|
| cgen()->allocator()->Use(reg);
|
| }
|
|
|
| @@ -438,8 +446,8 @@
|
| // decrements the register's external reference count and invalidates the
|
| // index of the register's location in the frame.
|
| void Unuse(Register reg) {
|
| - ASSERT(register_locations_[reg.code()] != kIllegalIndex);
|
| - register_locations_[reg.code()] = kIllegalIndex;
|
| + ASSERT(is_used(reg));
|
| + set_register_location(reg, kIllegalIndex);
|
| cgen()->allocator()->Unuse(reg);
|
| }
|
|
|
| @@ -453,7 +461,7 @@
|
| // Keep the element type as register or constant, and clear the dirty bit.
|
| void SyncElementAt(int index);
|
|
|
| - // Sync the range of elements in [begin, end).
|
| + // Sync the range of elements in [begin, end] with memory.
|
| void SyncRange(int begin, int end);
|
|
|
| // Sync a single unsynced element that lies beneath or at the stack pointer.
|
|
|