blob: d6cff256536a8b53ac89915e799686ddfd1979ff [file] [log] [blame]
Ben Murdoch086aeea2011-05-13 15:57:08 +01001// 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
30namespace v8 {
31namespace internal {
32
Ben Murdochb8e0da22011-05-16 14:20:40 +010033bool LParallelMove::IsRedundant() const {
34 for (int i = 0; i < move_operands_.length(); ++i) {
35 if (!move_operands_[i].IsRedundant()) return false;
Ben Murdoch086aeea2011-05-13 15:57:08 +010036 }
Ben Murdochb8e0da22011-05-16 14:20:40 +010037 return true;
Ben Murdoch086aeea2011-05-13 15:57:08 +010038}
39
40
Ben Murdochb8e0da22011-05-16 14:20:40 +010041void 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 Murdoch086aeea2011-05-13 15:57:08 +010055 }
Ben Murdochb8e0da22011-05-16 14:20:40 +010056 stream->Add(";");
Ben Murdoch086aeea2011-05-13 15:57:08 +010057 }
Ben Murdoch086aeea2011-05-13 15:57:08 +010058 }
59}
60
61
Ben Murdochb8e0da22011-05-16 14:20:40 +010062void 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 Murdoch086aeea2011-05-13 15:57:08 +010072 }
Ben Murdoch086aeea2011-05-13 15:57:08 +010073 }
Ben Murdochb8e0da22011-05-16 14:20:40 +010074 stream->Add("]");
Ben Murdoch086aeea2011-05-13 15:57:08 +010075}
76
77
Ben Murdochb8e0da22011-05-16 14:20:40 +010078void 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 Murdoch086aeea2011-05-13 15:57:08 +010084
Ben Murdochb8e0da22011-05-16 14:20:40 +010085
86void 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 Murdoch086aeea2011-05-13 15:57:08 +010093}
94
95
96} } // namespace v8::internal