| 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 11 matching lines...) Expand all Loading... |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 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 #include "v8.h" | 28 #include "v8.h" |
| 29 | 29 |
| 30 #include "codegen-inl.h" | 30 #include "codegen-inl.h" |
| 31 #include "register-allocator-inl.h" | 31 #include "register-allocator-inl.h" |
| 32 #include "virtual-frame-inl.h" |
| 32 | 33 |
| 33 namespace v8 { | 34 namespace v8 { |
| 34 namespace internal { | 35 namespace internal { |
| 35 | 36 |
| 36 // ------------------------------------------------------------------------- | 37 // ------------------------------------------------------------------------- |
| 37 // VirtualFrame implementation. | 38 // VirtualFrame implementation. |
| 38 | 39 |
| 39 // When cloned, a frame is a deep copy of the original. | |
| 40 VirtualFrame::VirtualFrame(VirtualFrame* original) | |
| 41 : elements_(original->element_count()), | |
| 42 stack_pointer_(original->stack_pointer_) { | |
| 43 elements_.AddAll(original->elements_); | |
| 44 // Copy register locations from original. | |
| 45 memcpy(®ister_locations_, | |
| 46 original->register_locations_, | |
| 47 sizeof(register_locations_)); | |
| 48 } | |
| 49 | |
| 50 | |
| 51 // Create a duplicate of an existing valid frame element. | 40 // Create a duplicate of an existing valid frame element. |
| 52 // We can pass an optional number type information that will override the | 41 // We can pass an optional number type information that will override the |
| 53 // existing information about the backing element. The new information must | 42 // existing information about the backing element. The new information must |
| 54 // not conflict with the existing type information and must be equally or | 43 // not conflict with the existing type information and must be equally or |
| 55 // more precise. The default parameter value kUninitialized means that there | 44 // more precise. The default parameter value kUninitialized means that there |
| 56 // is no additional information. | 45 // is no additional information. |
| 57 FrameElement VirtualFrame::CopyElementAt(int index, NumberInfo::Type info) { | 46 FrameElement VirtualFrame::CopyElementAt(int index, NumberInfo::Type info) { |
| 58 ASSERT(index >= 0); | 47 ASSERT(index >= 0); |
| 59 ASSERT(index < element_count()); | 48 ASSERT(index < element_count()); |
| 60 | 49 |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 } else { | 320 } else { |
| 332 ASSERT(value->is_constant()); | 321 ASSERT(value->is_constant()); |
| 333 elements_[frame_index] = | 322 elements_[frame_index] = |
| 334 FrameElement::ConstantElement(value->handle(), | 323 FrameElement::ConstantElement(value->handle(), |
| 335 FrameElement::NOT_SYNCED); | 324 FrameElement::NOT_SYNCED); |
| 336 } | 325 } |
| 337 value->Unuse(); | 326 value->Unuse(); |
| 338 } | 327 } |
| 339 | 328 |
| 340 | 329 |
| 341 void VirtualFrame::PushFrameSlotAt(int index) { | |
| 342 elements_.Add(CopyElementAt(index)); | |
| 343 } | |
| 344 | |
| 345 | |
| 346 void VirtualFrame::Push(Register reg, NumberInfo::Type info) { | |
| 347 if (is_used(reg)) { | |
| 348 int index = register_location(reg); | |
| 349 FrameElement element = CopyElementAt(index, info); | |
| 350 elements_.Add(element); | |
| 351 } else { | |
| 352 Use(reg, element_count()); | |
| 353 FrameElement element = | |
| 354 FrameElement::RegisterElement(reg, FrameElement::NOT_SYNCED, info); | |
| 355 elements_.Add(element); | |
| 356 } | |
| 357 } | |
| 358 | |
| 359 | |
| 360 void VirtualFrame::Push(Handle<Object> value) { | |
| 361 FrameElement element = | |
| 362 FrameElement::ConstantElement(value, FrameElement::NOT_SYNCED); | |
| 363 elements_.Add(element); | |
| 364 } | |
| 365 | |
| 366 | |
| 367 void VirtualFrame::Nip(int num_dropped) { | |
| 368 ASSERT(num_dropped >= 0); | |
| 369 if (num_dropped == 0) return; | |
| 370 Result tos = Pop(); | |
| 371 if (num_dropped > 1) { | |
| 372 Drop(num_dropped - 1); | |
| 373 } | |
| 374 SetElementAt(0, &tos); | |
| 375 } | |
| 376 | |
| 377 | |
| 378 bool VirtualFrame::Equals(VirtualFrame* other) { | |
| 379 #ifdef DEBUG | |
| 380 for (int i = 0; i < RegisterAllocator::kNumRegisters; i++) { | |
| 381 if (register_location(i) != other->register_location(i)) { | |
| 382 return false; | |
| 383 } | |
| 384 } | |
| 385 if (element_count() != other->element_count()) return false; | |
| 386 #endif | |
| 387 if (stack_pointer_ != other->stack_pointer_) return false; | |
| 388 for (int i = 0; i < element_count(); i++) { | |
| 389 if (!elements_[i].Equals(other->elements_[i])) return false; | |
| 390 } | |
| 391 | |
| 392 return true; | |
| 393 } | |
| 394 | |
| 395 | |
| 396 // Specialization of List::ResizeAdd to non-inlined version for FrameElements. | 330 // Specialization of List::ResizeAdd to non-inlined version for FrameElements. |
| 397 // The function ResizeAdd becomes a real function, whose implementation is the | 331 // The function ResizeAdd becomes a real function, whose implementation is the |
| 398 // inlined ResizeAddInternal. | 332 // inlined ResizeAddInternal. |
| 399 template <> | 333 template <> |
| 400 void List<FrameElement, | 334 void List<FrameElement, |
| 401 FreeStoreAllocationPolicy>::ResizeAdd(const FrameElement& element) { | 335 FreeStoreAllocationPolicy>::ResizeAdd(const FrameElement& element) { |
| 402 ResizeAddInternal(element); | 336 ResizeAddInternal(element); |
| 403 } | 337 } |
| 404 | 338 |
| 405 } } // namespace v8::internal | 339 } } // namespace v8::internal |
| OLD | NEW |