v8  3.11.10(node0.8.26)
V8 is Google's open source JavaScript engine
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
lithium.cc
Go to the documentation of this file.
1 // Copyright 2012 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 "v8.h"
29 #include "lithium.h"
30 
31 namespace v8 {
32 namespace internal {
33 
34 
36  LUnallocated* unalloc = NULL;
37  switch (kind()) {
38  case INVALID:
39  stream->Add("(0)");
40  break;
41  case UNALLOCATED:
42  unalloc = LUnallocated::cast(this);
43  stream->Add("v%d", unalloc->virtual_register());
44  switch (unalloc->policy()) {
45  case LUnallocated::NONE:
46  break;
48  const char* register_name =
50  stream->Add("(=%s)", register_name);
51  break;
52  }
54  const char* double_register_name =
56  stream->Add("(=%s)", double_register_name);
57  break;
58  }
60  stream->Add("(=%dS)", unalloc->fixed_index());
61  break;
63  stream->Add("(R)");
64  break;
66  stream->Add("(WR)");
67  break;
69  stream->Add("(1)");
70  break;
71  case LUnallocated::ANY:
72  stream->Add("(-)");
73  break;
74  }
75  break;
76  case CONSTANT_OPERAND:
77  stream->Add("[constant:%d]", index());
78  break;
79  case STACK_SLOT:
80  stream->Add("[stack:%d]", index());
81  break;
82  case DOUBLE_STACK_SLOT:
83  stream->Add("[double_stack:%d]", index());
84  break;
85  case REGISTER:
86  stream->Add("[%s|R]", Register::AllocationIndexToString(index()));
87  break;
88  case DOUBLE_REGISTER:
90  break;
91  case ARGUMENT:
92  stream->Add("[arg:%d]", index());
93  break;
94  }
95 }
96 
97 #define DEFINE_OPERAND_CACHE(name, type) \
98  L##name* L##name::cache = NULL; \
99  \
100  void L##name::SetUpCache() { \
101  if (cache) return; \
102  cache = new L##name[kNumCachedOperands]; \
103  for (int i = 0; i < kNumCachedOperands; i++) { \
104  cache[i].ConvertTo(type, i); \
105  } \
106  } \
107  \
108  void L##name::TearDownCache() { \
109  delete[] cache; \
110  }
111 
113 #undef DEFINE_OPERAND_CACHE
114 
116 #define LITHIUM_OPERAND_SETUP(name, type) L##name::SetUpCache();
118 #undef LITHIUM_OPERAND_SETUP
119 }
120 
121 
123 #define LITHIUM_OPERAND_TEARDOWN(name, type) L##name::TearDownCache();
125 #undef LITHIUM_OPERAND_TEARDOWN
126 }
127 
128 
130  for (int i = 0; i < move_operands_.length(); ++i) {
131  if (!move_operands_[i].IsRedundant()) return false;
132  }
133  return true;
134 }
135 
136 
138  bool first = true;
139  for (int i = 0; i < move_operands_.length(); ++i) {
140  if (!move_operands_[i].IsEliminated()) {
141  LOperand* source = move_operands_[i].source();
142  LOperand* destination = move_operands_[i].destination();
143  if (!first) stream->Add(" ");
144  first = false;
145  if (source->Equals(destination)) {
146  destination->PrintTo(stream);
147  } else {
148  destination->PrintTo(stream);
149  stream->Add(" = ");
150  source->PrintTo(stream);
151  }
152  stream->Add(";");
153  }
154  }
155 }
156 
157 
159  stream->Add("[id=%d|", ast_id());
160  stream->Add("[parameters=%d|", parameter_count());
161  stream->Add("[arguments_stack_height=%d|", arguments_stack_height());
162  for (int i = 0; i < values_.length(); ++i) {
163  if (i != 0) stream->Add(";");
164  if (values_[i] == NULL) {
165  stream->Add("[hole]");
166  } else {
167  values_[i]->PrintTo(stream);
168  }
169  }
170  stream->Add("]");
171 }
172 
173 
175  // Do not record arguments as pointers.
176  if (op->IsStackSlot() && op->index() < 0) return;
177  ASSERT(!op->IsDoubleRegister() && !op->IsDoubleStackSlot());
178  pointer_operands_.Add(op, zone);
179 }
180 
181 
183  // Do not record arguments as pointers.
184  if (op->IsStackSlot() && op->index() < 0) return;
185  ASSERT(!op->IsDoubleRegister() && !op->IsDoubleStackSlot());
186  for (int i = 0; i < pointer_operands_.length(); ++i) {
187  if (pointer_operands_[i]->Equals(op)) {
188  pointer_operands_.Remove(i);
189  --i;
190  }
191  }
192 }
193 
194 
196  // Do not record arguments as pointers.
197  if (op->IsStackSlot() && op->index() < 0) return;
198  ASSERT(!op->IsDoubleRegister() && !op->IsDoubleStackSlot());
199  untagged_operands_.Add(op, zone);
200 }
201 
202 
204  stream->Add("{");
205  for (int i = 0; i < pointer_operands_.length(); ++i) {
206  if (i != 0) stream->Add(";");
207  pointer_operands_[i]->PrintTo(stream);
208  }
209  stream->Add("} @%d", position());
210 }
211 
212 
214  switch (elements_kind) {
218  return 0;
221  return 1;
225  return 2;
229  return 3;
230  case FAST_SMI_ELEMENTS:
231  case FAST_ELEMENTS:
233  case FAST_HOLEY_ELEMENTS:
234  case DICTIONARY_ELEMENTS:
236  return kPointerSizeLog2;
237  }
238  UNREACHABLE();
239  return 0;
240 }
241 
242 
243 } } // namespace v8::internal
int index() const
Definition: lithium.h:62
static LUnallocated * cast(LOperand *op)
Definition: lithium.h:196
#define DEFINE_OPERAND_CACHE(name, type)
Definition: lithium.cc:97
static void TearDownCaches()
Definition: lithium.cc:122
void RemovePointer(LOperand *op)
Definition: lithium.cc:182
#define ASSERT(condition)
Definition: checks.h:270
const int kPointerSizeLog2
Definition: globals.h:246
static void SetUpCaches()
Definition: lithium.cc:115
void PrintTo(StringStream *stream)
Definition: lithium.cc:203
int position() const
Definition: lithium.h:433
bool Equals(LOperand *other) const
Definition: lithium.h:70
static const char * AllocationIndexToString(int index)
void RecordUntagged(LOperand *op, Zone *zone)
Definition: lithium.cc:195
void Add(Vector< const char > format, Vector< FmtElm > elms)
int virtual_register() const
Definition: lithium.h:182
#define UNREACHABLE()
Definition: checks.h:50
void PrintTo(StringStream *stream)
Definition: lithium.cc:158
Policy policy() const
Definition: lithium.h:174
void RecordPointer(LOperand *op, Zone *zone)
Definition: lithium.cc:174
#define LITHIUM_OPERAND_TEARDOWN(name, type)
Kind kind() const
Definition: lithium.h:61
bool IsRedundant() const
Definition: lithium.cc:129
int ElementsKindToShiftSize(ElementsKind elements_kind)
Definition: lithium.cc:213
int parameter_count() const
Definition: lithium.h:485
void PrintDataTo(StringStream *stream) const
Definition: lithium.cc:137
int fixed_index() const
Definition: lithium.h:178
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination trace on stack replacement optimize closures functions with arguments object optimize functions containing for in loops profiler considers IC stability primitive functions trigger their own optimization re try self optimization if it failed insert an interrupt check at function exit execution budget before interrupt is triggered call count before self optimization self_optimization count_based_interrupts weighted_back_edges trace_opt emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 enable use of ARMv7 instructions if enable use of MIPS FPU instructions if NULL
Definition: flags.cc:274
static const char * AllocationIndexToString(int index)
Definition: assembler-arm.h:87
#define LITHIUM_OPERAND_LIST(V)
Definition: lithium.h:38
#define LITHIUM_OPERAND_SETUP(name, type)
void PrintTo(StringStream *stream)
Definition: lithium.cc:35
int arguments_stack_height() const
Definition: lithium.h:481