Ben Murdoch | 086aeea | 2011-05-13 15:57:08 +0100 | [diff] [blame] | 1 | // Copyright 2011 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 | #include "lithium.h" |
| 29 | |
| 30 | namespace v8 { |
| 31 | namespace internal { |
| 32 | |
Ben Murdoch | b8e0da2 | 2011-05-16 14:20:40 +0100 | [diff] [blame^] | 33 | bool LParallelMove::IsRedundant() const { |
| 34 | for (int i = 0; i < move_operands_.length(); ++i) { |
| 35 | if (!move_operands_[i].IsRedundant()) return false; |
Ben Murdoch | 086aeea | 2011-05-13 15:57:08 +0100 | [diff] [blame] | 36 | } |
Ben Murdoch | b8e0da2 | 2011-05-16 14:20:40 +0100 | [diff] [blame^] | 37 | return true; |
Ben Murdoch | 086aeea | 2011-05-13 15:57:08 +0100 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | |
Ben Murdoch | b8e0da2 | 2011-05-16 14:20:40 +0100 | [diff] [blame^] | 41 | void LParallelMove::PrintDataTo(StringStream* stream) const { |
| 42 | bool first = true; |
| 43 | for (int i = 0; i < move_operands_.length(); ++i) { |
| 44 | if (!move_operands_[i].IsEliminated()) { |
| 45 | LOperand* source = move_operands_[i].source(); |
| 46 | LOperand* destination = move_operands_[i].destination(); |
| 47 | if (!first) stream->Add(" "); |
| 48 | first = false; |
| 49 | if (source->Equals(destination)) { |
| 50 | destination->PrintTo(stream); |
| 51 | } else { |
| 52 | destination->PrintTo(stream); |
| 53 | stream->Add(" = "); |
| 54 | source->PrintTo(stream); |
Ben Murdoch | 086aeea | 2011-05-13 15:57:08 +0100 | [diff] [blame] | 55 | } |
Ben Murdoch | b8e0da2 | 2011-05-16 14:20:40 +0100 | [diff] [blame^] | 56 | stream->Add(";"); |
Ben Murdoch | 086aeea | 2011-05-13 15:57:08 +0100 | [diff] [blame] | 57 | } |
Ben Murdoch | 086aeea | 2011-05-13 15:57:08 +0100 | [diff] [blame] | 58 | } |
| 59 | } |
| 60 | |
| 61 | |
Ben Murdoch | b8e0da2 | 2011-05-16 14:20:40 +0100 | [diff] [blame^] | 62 | void LEnvironment::PrintTo(StringStream* stream) { |
| 63 | stream->Add("[id=%d|", ast_id()); |
| 64 | stream->Add("[parameters=%d|", parameter_count()); |
| 65 | stream->Add("[arguments_stack_height=%d|", arguments_stack_height()); |
| 66 | for (int i = 0; i < values_.length(); ++i) { |
| 67 | if (i != 0) stream->Add(";"); |
| 68 | if (values_[i] == NULL) { |
| 69 | stream->Add("[hole]"); |
| 70 | } else { |
| 71 | values_[i]->PrintTo(stream); |
Ben Murdoch | 086aeea | 2011-05-13 15:57:08 +0100 | [diff] [blame] | 72 | } |
Ben Murdoch | 086aeea | 2011-05-13 15:57:08 +0100 | [diff] [blame] | 73 | } |
Ben Murdoch | b8e0da2 | 2011-05-16 14:20:40 +0100 | [diff] [blame^] | 74 | stream->Add("]"); |
Ben Murdoch | 086aeea | 2011-05-13 15:57:08 +0100 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | |
Ben Murdoch | b8e0da2 | 2011-05-16 14:20:40 +0100 | [diff] [blame^] | 78 | void LPointerMap::RecordPointer(LOperand* op) { |
| 79 | // Do not record arguments as pointers. |
| 80 | if (op->IsStackSlot() && op->index() < 0) return; |
| 81 | ASSERT(!op->IsDoubleRegister() && !op->IsDoubleStackSlot()); |
| 82 | pointer_operands_.Add(op); |
| 83 | } |
Ben Murdoch | 086aeea | 2011-05-13 15:57:08 +0100 | [diff] [blame] | 84 | |
Ben Murdoch | b8e0da2 | 2011-05-16 14:20:40 +0100 | [diff] [blame^] | 85 | |
| 86 | void LPointerMap::PrintTo(StringStream* stream) { |
| 87 | stream->Add("{"); |
| 88 | for (int i = 0; i < pointer_operands_.length(); ++i) { |
| 89 | if (i != 0) stream->Add(";"); |
| 90 | pointer_operands_[i]->PrintTo(stream); |
| 91 | } |
| 92 | stream->Add("} @%d", position()); |
Ben Murdoch | 086aeea | 2011-05-13 15:57:08 +0100 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | |
| 96 | } } // namespace v8::internal |