OLD | NEW |
(Empty) | |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. |
| 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_VIRTUAL_FRAME_INL_H_ |
| 29 #define V8_VIRTUAL_FRAME_INL_H_ |
| 30 |
| 31 #include "virtual-frame.h" |
| 32 |
| 33 namespace v8 { |
| 34 namespace internal { |
| 35 |
| 36 // When cloned, a frame is a deep copy of the original. |
| 37 VirtualFrame::VirtualFrame(VirtualFrame* original) |
| 38 : elements_(original->element_count()), |
| 39 stack_pointer_(original->stack_pointer_) { |
| 40 elements_.AddAll(original->elements_); |
| 41 // Copy register locations from original. |
| 42 memcpy(®ister_locations_, |
| 43 original->register_locations_, |
| 44 sizeof(register_locations_)); |
| 45 } |
| 46 |
| 47 |
| 48 void VirtualFrame::PushFrameSlotAt(int index) { |
| 49 elements_.Add(CopyElementAt(index)); |
| 50 } |
| 51 |
| 52 |
| 53 void VirtualFrame::Push(Register reg, NumberInfo::Type info) { |
| 54 if (is_used(reg)) { |
| 55 int index = register_location(reg); |
| 56 FrameElement element = CopyElementAt(index, info); |
| 57 elements_.Add(element); |
| 58 } else { |
| 59 Use(reg, element_count()); |
| 60 FrameElement element = |
| 61 FrameElement::RegisterElement(reg, FrameElement::NOT_SYNCED, info); |
| 62 elements_.Add(element); |
| 63 } |
| 64 } |
| 65 |
| 66 |
| 67 void VirtualFrame::Push(Handle<Object> value) { |
| 68 FrameElement element = |
| 69 FrameElement::ConstantElement(value, FrameElement::NOT_SYNCED); |
| 70 elements_.Add(element); |
| 71 } |
| 72 |
| 73 |
| 74 void VirtualFrame::Push(Smi* value) { |
| 75 Push(Handle<Object> (value)); |
| 76 } |
| 77 |
| 78 |
| 79 void VirtualFrame::Nip(int num_dropped) { |
| 80 ASSERT(num_dropped >= 0); |
| 81 if (num_dropped == 0) return; |
| 82 Result tos = Pop(); |
| 83 if (num_dropped > 1) { |
| 84 Drop(num_dropped - 1); |
| 85 } |
| 86 SetElementAt(0, &tos); |
| 87 } |
| 88 |
| 89 |
| 90 bool VirtualFrame::Equals(VirtualFrame* other) { |
| 91 #ifdef DEBUG |
| 92 for (int i = 0; i < RegisterAllocator::kNumRegisters; i++) { |
| 93 if (register_location(i) != other->register_location(i)) { |
| 94 return false; |
| 95 } |
| 96 } |
| 97 if (element_count() != other->element_count()) return false; |
| 98 #endif |
| 99 if (stack_pointer_ != other->stack_pointer_) return false; |
| 100 for (int i = 0; i < element_count(); i++) { |
| 101 if (!elements_[i].Equals(other->elements_[i])) return false; |
| 102 } |
| 103 |
| 104 return true; |
| 105 } |
| 106 |
| 107 } } // namespace v8::internal |
| 108 |
| 109 #endif // V8_VIRTUAL_FRAME_INL_H_ |
OLD | NEW |