erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 1 | // Copyright 2012 the V8 project authors. All rights reserved. |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 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 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 28 | #include "v8.h" |
| 29 | |
jkummerow@chromium.org | 93a47f4 | 2013-07-02 14:43:41 +0000 | [diff] [blame] | 30 | #if V8_TARGET_ARCH_IA32 |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 31 | |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 32 | #include "lithium-allocator-inl.h" |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 33 | #include "ia32/lithium-ia32.h" |
| 34 | #include "ia32/lithium-codegen-ia32.h" |
hpayer@chromium.org | c5d4971 | 2013-09-11 08:25:48 +0000 | [diff] [blame] | 35 | #include "hydrogen-osr.h" |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 36 | |
| 37 | namespace v8 { |
| 38 | namespace internal { |
| 39 | |
| 40 | #define DEFINE_COMPILE(type) \ |
| 41 | void L##type::CompileToNative(LCodeGen* generator) { \ |
| 42 | generator->Do##type(this); \ |
| 43 | } |
| 44 | LITHIUM_CONCRETE_INSTRUCTION_LIST(DEFINE_COMPILE) |
| 45 | #undef DEFINE_COMPILE |
| 46 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 47 | |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 48 | #ifdef DEBUG |
| 49 | void LInstruction::VerifyCall() { |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 50 | // Call instructions can use only fixed registers as temporaries and |
| 51 | // outputs because all registers are blocked by the calling convention. |
| 52 | // Inputs operands must use a fixed register or use-at-start policy or |
| 53 | // a non-register policy. |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 54 | ASSERT(Output() == NULL || |
| 55 | LUnallocated::cast(Output())->HasFixedPolicy() || |
| 56 | !LUnallocated::cast(Output())->HasRegisterPolicy()); |
jkummerow@chromium.org | e297f59 | 2011-06-08 10:05:15 +0000 | [diff] [blame] | 57 | for (UseIterator it(this); !it.Done(); it.Advance()) { |
| 58 | LUnallocated* operand = LUnallocated::cast(it.Current()); |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 59 | ASSERT(operand->HasFixedPolicy() || |
| 60 | operand->IsUsedAtStart()); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 61 | } |
jkummerow@chromium.org | e297f59 | 2011-06-08 10:05:15 +0000 | [diff] [blame] | 62 | for (TempIterator it(this); !it.Done(); it.Advance()) { |
| 63 | LUnallocated* operand = LUnallocated::cast(it.Current()); |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 64 | ASSERT(operand->HasFixedPolicy() ||!operand->HasRegisterPolicy()); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 65 | } |
| 66 | } |
| 67 | #endif |
| 68 | |
| 69 | |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 70 | bool LInstruction::HasDoubleRegisterResult() { |
| 71 | return HasResult() && result()->IsDoubleRegister(); |
| 72 | } |
| 73 | |
| 74 | |
| 75 | bool LInstruction::HasDoubleRegisterInput() { |
| 76 | for (int i = 0; i < InputCount(); i++) { |
| 77 | LOperand* op = InputAt(i); |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 78 | if (op != NULL && op->IsDoubleRegister()) { |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 79 | return true; |
| 80 | } |
| 81 | } |
| 82 | return false; |
| 83 | } |
| 84 | |
| 85 | |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 86 | bool LInstruction::IsDoubleInput(X87Register reg, LCodeGen* cgen) { |
| 87 | for (int i = 0; i < InputCount(); i++) { |
| 88 | LOperand* op = InputAt(i); |
| 89 | if (op != NULL && op->IsDoubleRegister()) { |
| 90 | if (cgen->ToX87Register(op).is(reg)) return true; |
| 91 | } |
| 92 | } |
| 93 | return false; |
| 94 | } |
| 95 | |
| 96 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 97 | void LInstruction::PrintTo(StringStream* stream) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 98 | stream->Add("%s ", this->Mnemonic()); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 99 | |
| 100 | PrintOutputOperandTo(stream); |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 101 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 102 | PrintDataTo(stream); |
| 103 | |
| 104 | if (HasEnvironment()) { |
| 105 | stream->Add(" "); |
| 106 | environment()->PrintTo(stream); |
| 107 | } |
| 108 | |
| 109 | if (HasPointerMap()) { |
| 110 | stream->Add(" "); |
| 111 | pointer_map()->PrintTo(stream); |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 116 | void LInstruction::PrintDataTo(StringStream* stream) { |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 117 | stream->Add("= "); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 118 | for (int i = 0; i < InputCount(); i++) { |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 119 | if (i > 0) stream->Add(" "); |
yangguo@chromium.org | 4cd70b4 | 2013-01-04 08:57:54 +0000 | [diff] [blame] | 120 | if (InputAt(i) == NULL) { |
| 121 | stream->Add("NULL"); |
| 122 | } else { |
| 123 | InputAt(i)->PrintTo(stream); |
| 124 | } |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 125 | } |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 129 | void LInstruction::PrintOutputOperandTo(StringStream* stream) { |
| 130 | if (HasResult()) result()->PrintTo(stream); |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | |
| 134 | void LLabel::PrintDataTo(StringStream* stream) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 135 | LGap::PrintDataTo(stream); |
| 136 | LLabel* rep = replacement(); |
| 137 | if (rep != NULL) { |
| 138 | stream->Add(" Dead block replaced with B%d", rep->block_id()); |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 143 | bool LGap::IsRedundant() const { |
| 144 | for (int i = 0; i < 4; i++) { |
| 145 | if (parallel_moves_[i] != NULL && !parallel_moves_[i]->IsRedundant()) { |
| 146 | return false; |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | return true; |
| 151 | } |
| 152 | |
| 153 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 154 | void LGap::PrintDataTo(StringStream* stream) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 155 | for (int i = 0; i < 4; i++) { |
| 156 | stream->Add("("); |
| 157 | if (parallel_moves_[i] != NULL) { |
| 158 | parallel_moves_[i]->PrintDataTo(stream); |
| 159 | } |
| 160 | stream->Add(") "); |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | |
| 165 | const char* LArithmeticD::Mnemonic() const { |
| 166 | switch (op()) { |
| 167 | case Token::ADD: return "add-d"; |
| 168 | case Token::SUB: return "sub-d"; |
| 169 | case Token::MUL: return "mul-d"; |
| 170 | case Token::DIV: return "div-d"; |
| 171 | case Token::MOD: return "mod-d"; |
| 172 | default: |
| 173 | UNREACHABLE(); |
| 174 | return NULL; |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | |
| 179 | const char* LArithmeticT::Mnemonic() const { |
| 180 | switch (op()) { |
| 181 | case Token::ADD: return "add-t"; |
| 182 | case Token::SUB: return "sub-t"; |
| 183 | case Token::MUL: return "mul-t"; |
| 184 | case Token::MOD: return "mod-t"; |
| 185 | case Token::DIV: return "div-t"; |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 186 | case Token::BIT_AND: return "bit-and-t"; |
| 187 | case Token::BIT_OR: return "bit-or-t"; |
| 188 | case Token::BIT_XOR: return "bit-xor-t"; |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 189 | case Token::ROR: return "ror-t"; |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 190 | case Token::SHL: return "sal-t"; |
| 191 | case Token::SAR: return "sar-t"; |
| 192 | case Token::SHR: return "shr-t"; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 193 | default: |
| 194 | UNREACHABLE(); |
| 195 | return NULL; |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 200 | bool LGoto::HasInterestingComment(LCodeGen* gen) const { |
| 201 | return !gen->IsNextEmittedBlock(block_id()); |
| 202 | } |
| 203 | |
| 204 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 205 | void LGoto::PrintDataTo(StringStream* stream) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 206 | stream->Add("B%d", block_id()); |
| 207 | } |
| 208 | |
| 209 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 210 | void LBranch::PrintDataTo(StringStream* stream) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 211 | stream->Add("B%d | B%d on ", true_block_id(), false_block_id()); |
ulan@chromium.org | 56c14af | 2012-09-20 12:51:09 +0000 | [diff] [blame] | 212 | value()->PrintTo(stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 213 | } |
| 214 | |
| 215 | |
mstarzinger@chromium.org | e0e1b0d | 2013-07-08 08:38:06 +0000 | [diff] [blame] | 216 | void LCompareNumericAndBranch::PrintDataTo(StringStream* stream) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 217 | stream->Add("if "); |
ulan@chromium.org | 56c14af | 2012-09-20 12:51:09 +0000 | [diff] [blame] | 218 | left()->PrintTo(stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 219 | stream->Add(" %s ", Token::String(op())); |
ulan@chromium.org | 56c14af | 2012-09-20 12:51:09 +0000 | [diff] [blame] | 220 | right()->PrintTo(stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 221 | stream->Add(" then B%d else B%d", true_block_id(), false_block_id()); |
| 222 | } |
| 223 | |
| 224 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 225 | void LIsObjectAndBranch::PrintDataTo(StringStream* stream) { |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 226 | stream->Add("if is_object("); |
ulan@chromium.org | 56c14af | 2012-09-20 12:51:09 +0000 | [diff] [blame] | 227 | value()->PrintTo(stream); |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 228 | stream->Add(") then B%d else B%d", true_block_id(), false_block_id()); |
| 229 | } |
| 230 | |
| 231 | |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 232 | void LIsStringAndBranch::PrintDataTo(StringStream* stream) { |
| 233 | stream->Add("if is_string("); |
ulan@chromium.org | 56c14af | 2012-09-20 12:51:09 +0000 | [diff] [blame] | 234 | value()->PrintTo(stream); |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 235 | stream->Add(") then B%d else B%d", true_block_id(), false_block_id()); |
| 236 | } |
| 237 | |
| 238 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 239 | void LIsSmiAndBranch::PrintDataTo(StringStream* stream) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 240 | stream->Add("if is_smi("); |
ulan@chromium.org | 56c14af | 2012-09-20 12:51:09 +0000 | [diff] [blame] | 241 | value()->PrintTo(stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 242 | stream->Add(") then B%d else B%d", true_block_id(), false_block_id()); |
| 243 | } |
| 244 | |
| 245 | |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 246 | void LIsUndetectableAndBranch::PrintDataTo(StringStream* stream) { |
| 247 | stream->Add("if is_undetectable("); |
ulan@chromium.org | 56c14af | 2012-09-20 12:51:09 +0000 | [diff] [blame] | 248 | value()->PrintTo(stream); |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 249 | stream->Add(") then B%d else B%d", true_block_id(), false_block_id()); |
| 250 | } |
| 251 | |
| 252 | |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 253 | void LStringCompareAndBranch::PrintDataTo(StringStream* stream) { |
| 254 | stream->Add("if string_compare("); |
ulan@chromium.org | 56c14af | 2012-09-20 12:51:09 +0000 | [diff] [blame] | 255 | left()->PrintTo(stream); |
| 256 | right()->PrintTo(stream); |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 257 | stream->Add(") then B%d else B%d", true_block_id(), false_block_id()); |
| 258 | } |
| 259 | |
| 260 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 261 | void LHasInstanceTypeAndBranch::PrintDataTo(StringStream* stream) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 262 | stream->Add("if has_instance_type("); |
ulan@chromium.org | 56c14af | 2012-09-20 12:51:09 +0000 | [diff] [blame] | 263 | value()->PrintTo(stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 264 | stream->Add(") then B%d else B%d", true_block_id(), false_block_id()); |
| 265 | } |
| 266 | |
| 267 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 268 | void LHasCachedArrayIndexAndBranch::PrintDataTo(StringStream* stream) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 269 | stream->Add("if has_cached_array_index("); |
ulan@chromium.org | 56c14af | 2012-09-20 12:51:09 +0000 | [diff] [blame] | 270 | value()->PrintTo(stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 271 | stream->Add(") then B%d else B%d", true_block_id(), false_block_id()); |
| 272 | } |
| 273 | |
| 274 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 275 | void LClassOfTestAndBranch::PrintDataTo(StringStream* stream) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 276 | stream->Add("if class_of_test("); |
ulan@chromium.org | 56c14af | 2012-09-20 12:51:09 +0000 | [diff] [blame] | 277 | value()->PrintTo(stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 278 | stream->Add(", \"%o\") then B%d else B%d", |
| 279 | *hydrogen()->class_name(), |
| 280 | true_block_id(), |
| 281 | false_block_id()); |
| 282 | } |
| 283 | |
| 284 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 285 | void LTypeofIsAndBranch::PrintDataTo(StringStream* stream) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 286 | stream->Add("if typeof "); |
ulan@chromium.org | 56c14af | 2012-09-20 12:51:09 +0000 | [diff] [blame] | 287 | value()->PrintTo(stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 288 | stream->Add(" == \"%s\" then B%d else B%d", |
| 289 | *hydrogen()->type_literal()->ToCString(), |
| 290 | true_block_id(), false_block_id()); |
| 291 | } |
| 292 | |
| 293 | |
verwaest@chromium.org | 662436e | 2013-08-28 08:41:27 +0000 | [diff] [blame] | 294 | void LStoreCodeEntry::PrintDataTo(StringStream* stream) { |
| 295 | stream->Add(" = "); |
| 296 | function()->PrintTo(stream); |
| 297 | stream->Add(".code_entry = "); |
| 298 | code_object()->PrintTo(stream); |
| 299 | } |
| 300 | |
| 301 | |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 302 | void LInnerAllocatedObject::PrintDataTo(StringStream* stream) { |
| 303 | stream->Add(" = "); |
| 304 | base_object()->PrintTo(stream); |
| 305 | stream->Add(" + %d", offset()); |
| 306 | } |
| 307 | |
| 308 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 309 | void LCallConstantFunction::PrintDataTo(StringStream* stream) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 310 | stream->Add("#%d / ", arity()); |
| 311 | } |
| 312 | |
| 313 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 314 | void LLoadContextSlot::PrintDataTo(StringStream* stream) { |
ulan@chromium.org | 56c14af | 2012-09-20 12:51:09 +0000 | [diff] [blame] | 315 | context()->PrintTo(stream); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 316 | stream->Add("[%d]", slot_index()); |
| 317 | } |
| 318 | |
| 319 | |
| 320 | void LStoreContextSlot::PrintDataTo(StringStream* stream) { |
ulan@chromium.org | 56c14af | 2012-09-20 12:51:09 +0000 | [diff] [blame] | 321 | context()->PrintTo(stream); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 322 | stream->Add("[%d] <- ", slot_index()); |
ulan@chromium.org | 56c14af | 2012-09-20 12:51:09 +0000 | [diff] [blame] | 323 | value()->PrintTo(stream); |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 324 | } |
| 325 | |
| 326 | |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 327 | void LInvokeFunction::PrintDataTo(StringStream* stream) { |
| 328 | stream->Add("= "); |
ulan@chromium.org | 56c14af | 2012-09-20 12:51:09 +0000 | [diff] [blame] | 329 | context()->PrintTo(stream); |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 330 | stream->Add(" "); |
ulan@chromium.org | 56c14af | 2012-09-20 12:51:09 +0000 | [diff] [blame] | 331 | function()->PrintTo(stream); |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 332 | stream->Add(" #%d / ", arity()); |
| 333 | } |
| 334 | |
| 335 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 336 | void LCallKeyed::PrintDataTo(StringStream* stream) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 337 | stream->Add("[ecx] #%d / ", arity()); |
| 338 | } |
| 339 | |
| 340 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 341 | void LCallNamed::PrintDataTo(StringStream* stream) { |
kmillikin@chromium.org | 83e1682 | 2011-09-13 08:21:47 +0000 | [diff] [blame] | 342 | SmartArrayPointer<char> name_string = name()->ToCString(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 343 | stream->Add("%s #%d / ", *name_string, arity()); |
| 344 | } |
| 345 | |
| 346 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 347 | void LCallGlobal::PrintDataTo(StringStream* stream) { |
kmillikin@chromium.org | 83e1682 | 2011-09-13 08:21:47 +0000 | [diff] [blame] | 348 | SmartArrayPointer<char> name_string = name()->ToCString(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 349 | stream->Add("%s #%d / ", *name_string, arity()); |
| 350 | } |
| 351 | |
| 352 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 353 | void LCallKnownGlobal::PrintDataTo(StringStream* stream) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 354 | stream->Add("#%d / ", arity()); |
| 355 | } |
| 356 | |
| 357 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 358 | void LCallNew::PrintDataTo(StringStream* stream) { |
| 359 | stream->Add("= "); |
ulan@chromium.org | 56c14af | 2012-09-20 12:51:09 +0000 | [diff] [blame] | 360 | context()->PrintTo(stream); |
| 361 | stream->Add(" "); |
| 362 | constructor()->PrintTo(stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 363 | stream->Add(" #%d / ", arity()); |
| 364 | } |
| 365 | |
| 366 | |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 367 | void LCallNewArray::PrintDataTo(StringStream* stream) { |
| 368 | stream->Add("= "); |
| 369 | context()->PrintTo(stream); |
| 370 | stream->Add(" "); |
| 371 | constructor()->PrintTo(stream); |
| 372 | stream->Add(" #%d / ", arity()); |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 373 | ElementsKind kind = hydrogen()->elements_kind(); |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 374 | stream->Add(" (%s) ", ElementsKindToString(kind)); |
| 375 | } |
| 376 | |
| 377 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 378 | void LAccessArgumentsAt::PrintDataTo(StringStream* stream) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 379 | arguments()->PrintTo(stream); |
| 380 | |
| 381 | stream->Add(" length "); |
| 382 | length()->PrintTo(stream); |
| 383 | |
| 384 | stream->Add(" index "); |
| 385 | index()->PrintTo(stream); |
| 386 | } |
| 387 | |
| 388 | |
jkummerow@chromium.org | c366976 | 2013-09-30 13:42:25 +0000 | [diff] [blame] | 389 | int LPlatformChunk::GetNextSpillIndex(RegisterKind kind) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 390 | // Skip a slot if for a double-width slot. |
jkummerow@chromium.org | c366976 | 2013-09-30 13:42:25 +0000 | [diff] [blame] | 391 | if (kind == DOUBLE_REGISTERS) { |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 392 | spill_slot_count_++; |
| 393 | spill_slot_count_ |= 1; |
| 394 | num_double_slots_++; |
| 395 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 396 | return spill_slot_count_++; |
| 397 | } |
| 398 | |
| 399 | |
jkummerow@chromium.org | c366976 | 2013-09-30 13:42:25 +0000 | [diff] [blame] | 400 | LOperand* LPlatformChunk::GetNextSpillSlot(RegisterKind kind) { |
| 401 | int index = GetNextSpillIndex(kind); |
| 402 | if (kind == DOUBLE_REGISTERS) { |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 403 | return LDoubleStackSlot::Create(index, zone()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 404 | } else { |
jkummerow@chromium.org | c366976 | 2013-09-30 13:42:25 +0000 | [diff] [blame] | 405 | ASSERT(kind == GENERAL_REGISTERS); |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 406 | return LStackSlot::Create(index, zone()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 407 | } |
| 408 | } |
| 409 | |
| 410 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 411 | void LStoreNamedField::PrintDataTo(StringStream* stream) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 412 | object()->PrintTo(stream); |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 413 | hydrogen()->access().PrintTo(stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 414 | stream->Add(" <- "); |
| 415 | value()->PrintTo(stream); |
| 416 | } |
| 417 | |
| 418 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 419 | void LStoreNamedGeneric::PrintDataTo(StringStream* stream) { |
| 420 | object()->PrintTo(stream); |
| 421 | stream->Add("."); |
| 422 | stream->Add(*String::cast(*name())->ToCString()); |
| 423 | stream->Add(" <- "); |
| 424 | value()->PrintTo(stream); |
| 425 | } |
| 426 | |
| 427 | |
ulan@chromium.org | 8e8d882 | 2012-11-23 14:36:46 +0000 | [diff] [blame] | 428 | void LLoadKeyed::PrintDataTo(StringStream* stream) { |
| 429 | elements()->PrintTo(stream); |
| 430 | stream->Add("["); |
| 431 | key()->PrintTo(stream); |
| 432 | if (hydrogen()->IsDehoisted()) { |
| 433 | stream->Add(" + %d]", additional_index()); |
| 434 | } else { |
| 435 | stream->Add("]"); |
| 436 | } |
| 437 | } |
| 438 | |
| 439 | |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 440 | void LStoreKeyed::PrintDataTo(StringStream* stream) { |
rossberg@chromium.org | 717967f | 2011-07-20 13:44:42 +0000 | [diff] [blame] | 441 | elements()->PrintTo(stream); |
| 442 | stream->Add("["); |
| 443 | key()->PrintTo(stream); |
ulan@chromium.org | 8e8d882 | 2012-11-23 14:36:46 +0000 | [diff] [blame] | 444 | if (hydrogen()->IsDehoisted()) { |
| 445 | stream->Add(" + %d] <-", additional_index()); |
| 446 | } else { |
| 447 | stream->Add("] <- "); |
| 448 | } |
verwaest@chromium.org | d4be0f0 | 2013-06-05 13:39:03 +0000 | [diff] [blame] | 449 | |
| 450 | if (value() == NULL) { |
| 451 | ASSERT(hydrogen()->IsConstantHoleStore() && |
| 452 | hydrogen()->value()->representation().IsDouble()); |
| 453 | stream->Add("<the hole(nan)>"); |
| 454 | } else { |
| 455 | value()->PrintTo(stream); |
| 456 | } |
rossberg@chromium.org | 717967f | 2011-07-20 13:44:42 +0000 | [diff] [blame] | 457 | } |
| 458 | |
| 459 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 460 | void LStoreKeyedGeneric::PrintDataTo(StringStream* stream) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 461 | object()->PrintTo(stream); |
| 462 | stream->Add("["); |
| 463 | key()->PrintTo(stream); |
| 464 | stream->Add("] <- "); |
| 465 | value()->PrintTo(stream); |
| 466 | } |
| 467 | |
| 468 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 469 | void LTransitionElementsKind::PrintDataTo(StringStream* stream) { |
| 470 | object()->PrintTo(stream); |
| 471 | stream->Add(" %p -> %p", *original_map(), *transitioned_map()); |
| 472 | } |
| 473 | |
| 474 | |
jkummerow@chromium.org | 28583c9 | 2012-07-16 11:31:55 +0000 | [diff] [blame] | 475 | LPlatformChunk* LChunkBuilder::Build() { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 476 | ASSERT(is_unused()); |
jkummerow@chromium.org | 28583c9 | 2012-07-16 11:31:55 +0000 | [diff] [blame] | 477 | chunk_ = new(zone()) LPlatformChunk(info(), graph()); |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 478 | LPhase phase("L_Building chunk", chunk_); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 479 | status_ = BUILDING; |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 480 | |
| 481 | // Reserve the first spill slot for the state of dynamic alignment. |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 482 | if (info()->IsOptimizing()) { |
jkummerow@chromium.org | c366976 | 2013-09-30 13:42:25 +0000 | [diff] [blame] | 483 | int alignment_state_index = chunk_->GetNextSpillIndex(GENERAL_REGISTERS); |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 484 | ASSERT_EQ(alignment_state_index, 0); |
| 485 | USE(alignment_state_index); |
| 486 | } |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 487 | |
hpayer@chromium.org | c5d4971 | 2013-09-11 08:25:48 +0000 | [diff] [blame] | 488 | // If compiling for OSR, reserve space for the unoptimized frame, |
| 489 | // which will be subsumed into this frame. |
| 490 | if (graph()->has_osr()) { |
| 491 | for (int i = graph()->osr()->UnoptimizedFrameSlots(); i > 0; i--) { |
jkummerow@chromium.org | c366976 | 2013-09-30 13:42:25 +0000 | [diff] [blame] | 492 | chunk_->GetNextSpillIndex(GENERAL_REGISTERS); |
hpayer@chromium.org | c5d4971 | 2013-09-11 08:25:48 +0000 | [diff] [blame] | 493 | } |
| 494 | } |
| 495 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 496 | const ZoneList<HBasicBlock*>* blocks = graph()->blocks(); |
| 497 | for (int i = 0; i < blocks->length(); i++) { |
| 498 | HBasicBlock* next = NULL; |
| 499 | if (i < blocks->length() - 1) next = blocks->at(i + 1); |
| 500 | DoBasicBlock(blocks->at(i), next); |
| 501 | if (is_aborted()) return NULL; |
| 502 | } |
| 503 | status_ = DONE; |
| 504 | return chunk_; |
| 505 | } |
| 506 | |
| 507 | |
danno@chromium.org | 5940060 | 2013-08-13 17:09:37 +0000 | [diff] [blame] | 508 | void LChunkBuilder::Abort(BailoutReason reason) { |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 509 | info()->set_bailout_reason(reason); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 510 | status_ = ABORTED; |
| 511 | } |
| 512 | |
| 513 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 514 | LUnallocated* LChunkBuilder::ToUnallocated(Register reg) { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 515 | return new(zone()) LUnallocated(LUnallocated::FIXED_REGISTER, |
| 516 | Register::ToAllocationIndex(reg)); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 517 | } |
| 518 | |
| 519 | |
| 520 | LUnallocated* LChunkBuilder::ToUnallocated(XMMRegister reg) { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 521 | return new(zone()) LUnallocated(LUnallocated::FIXED_DOUBLE_REGISTER, |
| 522 | XMMRegister::ToAllocationIndex(reg)); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 523 | } |
| 524 | |
| 525 | |
| 526 | LOperand* LChunkBuilder::UseFixed(HValue* value, Register fixed_register) { |
| 527 | return Use(value, ToUnallocated(fixed_register)); |
| 528 | } |
| 529 | |
| 530 | |
| 531 | LOperand* LChunkBuilder::UseFixedDouble(HValue* value, XMMRegister reg) { |
| 532 | return Use(value, ToUnallocated(reg)); |
| 533 | } |
| 534 | |
| 535 | |
| 536 | LOperand* LChunkBuilder::UseRegister(HValue* value) { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 537 | return Use(value, new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER)); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 538 | } |
| 539 | |
| 540 | |
| 541 | LOperand* LChunkBuilder::UseRegisterAtStart(HValue* value) { |
| 542 | return Use(value, |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 543 | new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER, |
| 544 | LUnallocated::USED_AT_START)); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 545 | } |
| 546 | |
| 547 | |
| 548 | LOperand* LChunkBuilder::UseTempRegister(HValue* value) { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 549 | return Use(value, new(zone()) LUnallocated(LUnallocated::WRITABLE_REGISTER)); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 550 | } |
| 551 | |
| 552 | |
| 553 | LOperand* LChunkBuilder::Use(HValue* value) { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 554 | return Use(value, new(zone()) LUnallocated(LUnallocated::NONE)); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 555 | } |
| 556 | |
| 557 | |
| 558 | LOperand* LChunkBuilder::UseAtStart(HValue* value) { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 559 | return Use(value, new(zone()) LUnallocated(LUnallocated::NONE, |
| 560 | LUnallocated::USED_AT_START)); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 561 | } |
| 562 | |
| 563 | |
bmeurer@chromium.org | c9913f0 | 2013-10-24 06:31:36 +0000 | [diff] [blame] | 564 | static inline bool CanBeImmediateConstant(HValue* value) { |
| 565 | return value->IsConstant() && HConstant::cast(value)->NotInNewSpace(); |
| 566 | } |
| 567 | |
| 568 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 569 | LOperand* LChunkBuilder::UseOrConstant(HValue* value) { |
bmeurer@chromium.org | c9913f0 | 2013-10-24 06:31:36 +0000 | [diff] [blame] | 570 | return CanBeImmediateConstant(value) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 571 | ? chunk_->DefineConstantOperand(HConstant::cast(value)) |
| 572 | : Use(value); |
| 573 | } |
| 574 | |
| 575 | |
| 576 | LOperand* LChunkBuilder::UseOrConstantAtStart(HValue* value) { |
bmeurer@chromium.org | c9913f0 | 2013-10-24 06:31:36 +0000 | [diff] [blame] | 577 | return CanBeImmediateConstant(value) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 578 | ? chunk_->DefineConstantOperand(HConstant::cast(value)) |
| 579 | : UseAtStart(value); |
| 580 | } |
| 581 | |
| 582 | |
machenbach@chromium.org | e8412be | 2013-11-08 10:23:52 +0000 | [diff] [blame] | 583 | LOperand* LChunkBuilder::UseFixedOrConstant(HValue* value, |
| 584 | Register fixed_register) { |
| 585 | return CanBeImmediateConstant(value) |
| 586 | ? chunk_->DefineConstantOperand(HConstant::cast(value)) |
| 587 | : UseFixed(value, fixed_register); |
| 588 | } |
| 589 | |
| 590 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 591 | LOperand* LChunkBuilder::UseRegisterOrConstant(HValue* value) { |
bmeurer@chromium.org | c9913f0 | 2013-10-24 06:31:36 +0000 | [diff] [blame] | 592 | return CanBeImmediateConstant(value) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 593 | ? chunk_->DefineConstantOperand(HConstant::cast(value)) |
| 594 | : UseRegister(value); |
| 595 | } |
| 596 | |
| 597 | |
| 598 | LOperand* LChunkBuilder::UseRegisterOrConstantAtStart(HValue* value) { |
bmeurer@chromium.org | c9913f0 | 2013-10-24 06:31:36 +0000 | [diff] [blame] | 599 | return CanBeImmediateConstant(value) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 600 | ? chunk_->DefineConstantOperand(HConstant::cast(value)) |
| 601 | : UseRegisterAtStart(value); |
| 602 | } |
| 603 | |
| 604 | |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 605 | LOperand* LChunkBuilder::UseConstant(HValue* value) { |
| 606 | return chunk_->DefineConstantOperand(HConstant::cast(value)); |
| 607 | } |
| 608 | |
| 609 | |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 610 | LOperand* LChunkBuilder::UseAny(HValue* value) { |
| 611 | return value->IsConstant() |
| 612 | ? chunk_->DefineConstantOperand(HConstant::cast(value)) |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 613 | : Use(value, new(zone()) LUnallocated(LUnallocated::ANY)); |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 614 | } |
| 615 | |
| 616 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 617 | LOperand* LChunkBuilder::Use(HValue* value, LUnallocated* operand) { |
| 618 | if (value->EmitAtUses()) { |
| 619 | HInstruction* instr = HInstruction::cast(value); |
| 620 | VisitInstruction(instr); |
| 621 | } |
rossberg@chromium.org | 994edf6 | 2012-02-06 10:12:55 +0000 | [diff] [blame] | 622 | operand->set_virtual_register(value->id()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 623 | return operand; |
| 624 | } |
| 625 | |
| 626 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 627 | template<int I, int T> |
| 628 | LInstruction* LChunkBuilder::Define(LTemplateInstruction<1, I, T>* instr, |
| 629 | LUnallocated* result) { |
rossberg@chromium.org | 994edf6 | 2012-02-06 10:12:55 +0000 | [diff] [blame] | 630 | result->set_virtual_register(current_instruction_->id()); |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 631 | instr->set_result(result); |
| 632 | return instr; |
| 633 | } |
| 634 | |
| 635 | |
| 636 | template<int I, int T> |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 637 | LInstruction* LChunkBuilder::DefineAsRegister( |
| 638 | LTemplateInstruction<1, I, T>* instr) { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 639 | return Define(instr, |
| 640 | new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER)); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 641 | } |
| 642 | |
| 643 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 644 | template<int I, int T> |
| 645 | LInstruction* LChunkBuilder::DefineAsSpilled( |
| 646 | LTemplateInstruction<1, I, T>* instr, |
| 647 | int index) { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 648 | return Define(instr, |
| 649 | new(zone()) LUnallocated(LUnallocated::FIXED_SLOT, index)); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 650 | } |
| 651 | |
| 652 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 653 | template<int I, int T> |
| 654 | LInstruction* LChunkBuilder::DefineSameAsFirst( |
| 655 | LTemplateInstruction<1, I, T>* instr) { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 656 | return Define(instr, |
| 657 | new(zone()) LUnallocated(LUnallocated::SAME_AS_FIRST_INPUT)); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 658 | } |
| 659 | |
| 660 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 661 | template<int I, int T> |
| 662 | LInstruction* LChunkBuilder::DefineFixed(LTemplateInstruction<1, I, T>* instr, |
| 663 | Register reg) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 664 | return Define(instr, ToUnallocated(reg)); |
| 665 | } |
| 666 | |
| 667 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 668 | template<int I, int T> |
| 669 | LInstruction* LChunkBuilder::DefineFixedDouble( |
| 670 | LTemplateInstruction<1, I, T>* instr, |
| 671 | XMMRegister reg) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 672 | return Define(instr, ToUnallocated(reg)); |
| 673 | } |
| 674 | |
| 675 | |
| 676 | LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { |
| 677 | HEnvironment* hydrogen_env = current_block_->last_environment(); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 678 | int argument_index_accumulator = 0; |
danno@chromium.org | 5940060 | 2013-08-13 17:09:37 +0000 | [diff] [blame] | 679 | ZoneList<HValue*> objects_to_materialize(0, zone()); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 680 | instr->set_environment(CreateEnvironment(hydrogen_env, |
danno@chromium.org | 5940060 | 2013-08-13 17:09:37 +0000 | [diff] [blame] | 681 | &argument_index_accumulator, |
| 682 | &objects_to_materialize)); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 683 | return instr; |
| 684 | } |
| 685 | |
| 686 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 687 | LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, |
| 688 | HInstruction* hinstr, |
| 689 | CanDeoptimize can_deoptimize) { |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 690 | info()->MarkAsNonDeferredCalling(); |
| 691 | |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 692 | #ifdef DEBUG |
| 693 | instr->VerifyCall(); |
| 694 | #endif |
| 695 | instr->MarkAsCall(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 696 | instr = AssignPointerMap(instr); |
| 697 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 698 | if (hinstr->HasObservableSideEffects()) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 699 | ASSERT(hinstr->next()->IsSimulate()); |
| 700 | HSimulate* sim = HSimulate::cast(hinstr->next()); |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 701 | ASSERT(instruction_pending_deoptimization_environment_ == NULL); |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 702 | ASSERT(pending_deoptimization_ast_id_.IsNone()); |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 703 | instruction_pending_deoptimization_environment_ = instr; |
| 704 | pending_deoptimization_ast_id_ = sim->ast_id(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 705 | } |
| 706 | |
| 707 | // If instruction does not have side-effects lazy deoptimization |
| 708 | // after the call will try to deoptimize to the point before the call. |
| 709 | // Thus we still need to attach environment to this call even if |
| 710 | // call sequence can not deoptimize eagerly. |
| 711 | bool needs_environment = |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 712 | (can_deoptimize == CAN_DEOPTIMIZE_EAGERLY) || |
| 713 | !hinstr->HasObservableSideEffects(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 714 | if (needs_environment && !instr->HasEnvironment()) { |
| 715 | instr = AssignEnvironment(instr); |
| 716 | } |
| 717 | |
| 718 | return instr; |
| 719 | } |
| 720 | |
| 721 | |
| 722 | LInstruction* LChunkBuilder::AssignPointerMap(LInstruction* instr) { |
| 723 | ASSERT(!instr->HasPointerMap()); |
bmeurer@chromium.org | 71f9fca | 2013-10-22 08:00:09 +0000 | [diff] [blame] | 724 | instr->set_pointer_map(new(zone()) LPointerMap(zone())); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 725 | return instr; |
| 726 | } |
| 727 | |
| 728 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 729 | LUnallocated* LChunkBuilder::TempRegister() { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 730 | LUnallocated* operand = |
| 731 | new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER); |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 732 | int vreg = allocator_->GetVirtualRegister(); |
rossberg@chromium.org | 994edf6 | 2012-02-06 10:12:55 +0000 | [diff] [blame] | 733 | if (!allocator_->AllocationOk()) { |
danno@chromium.org | 5940060 | 2013-08-13 17:09:37 +0000 | [diff] [blame] | 734 | Abort(kOutOfVirtualRegistersWhileTryingToAllocateTempRegister); |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 735 | vreg = 0; |
rossberg@chromium.org | 994edf6 | 2012-02-06 10:12:55 +0000 | [diff] [blame] | 736 | } |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 737 | operand->set_virtual_register(vreg); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 738 | return operand; |
| 739 | } |
| 740 | |
| 741 | |
| 742 | LOperand* LChunkBuilder::FixedTemp(Register reg) { |
| 743 | LUnallocated* operand = ToUnallocated(reg); |
rossberg@chromium.org | 994edf6 | 2012-02-06 10:12:55 +0000 | [diff] [blame] | 744 | ASSERT(operand->HasFixedPolicy()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 745 | return operand; |
| 746 | } |
| 747 | |
| 748 | |
| 749 | LOperand* LChunkBuilder::FixedTemp(XMMRegister reg) { |
| 750 | LUnallocated* operand = ToUnallocated(reg); |
rossberg@chromium.org | 994edf6 | 2012-02-06 10:12:55 +0000 | [diff] [blame] | 751 | ASSERT(operand->HasFixedPolicy()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 752 | return operand; |
| 753 | } |
| 754 | |
| 755 | |
| 756 | LInstruction* LChunkBuilder::DoBlockEntry(HBlockEntry* instr) { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 757 | return new(zone()) LLabel(instr->block()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 758 | } |
| 759 | |
| 760 | |
yangguo@chromium.org | 46a2a51 | 2013-01-18 16:29:40 +0000 | [diff] [blame] | 761 | LInstruction* LChunkBuilder::DoDummyUse(HDummyUse* instr) { |
| 762 | return DefineAsRegister(new(zone()) LDummyUse(UseAny(instr->value()))); |
| 763 | } |
| 764 | |
| 765 | |
verwaest@chromium.org | d4be0f0 | 2013-06-05 13:39:03 +0000 | [diff] [blame] | 766 | LInstruction* LChunkBuilder::DoEnvironmentMarker(HEnvironmentMarker* instr) { |
| 767 | UNREACHABLE(); |
| 768 | return NULL; |
| 769 | } |
| 770 | |
| 771 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 772 | LInstruction* LChunkBuilder::DoDeoptimize(HDeoptimize* instr) { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 773 | return AssignEnvironment(new(zone()) LDeoptimize); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 774 | } |
| 775 | |
| 776 | |
| 777 | LInstruction* LChunkBuilder::DoShift(Token::Value op, |
| 778 | HBitwiseBinaryOperation* instr) { |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 779 | if (instr->representation().IsSmiOrInteger32()) { |
| 780 | ASSERT(instr->left()->representation().Equals(instr->representation())); |
| 781 | ASSERT(instr->right()->representation().Equals(instr->representation())); |
| 782 | LOperand* left = UseRegisterAtStart(instr->left()); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 783 | |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 784 | HValue* right_value = instr->right(); |
| 785 | LOperand* right = NULL; |
| 786 | int constant_value = 0; |
| 787 | bool does_deopt = false; |
| 788 | if (right_value->IsConstant()) { |
| 789 | HConstant* constant = HConstant::cast(right_value); |
| 790 | right = chunk_->DefineConstantOperand(constant); |
| 791 | constant_value = constant->Integer32Value() & 0x1f; |
| 792 | // Left shifts can deoptimize if we shift by > 0 and the result cannot be |
| 793 | // truncated to smi. |
| 794 | if (instr->representation().IsSmi() && constant_value > 0) { |
| 795 | does_deopt = !instr->CheckUsesForFlag(HValue::kTruncatingToSmi); |
| 796 | } |
hpayer@chromium.org | 2f877ac | 2013-09-18 15:29:06 +0000 | [diff] [blame] | 797 | } else { |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 798 | right = UseFixed(right_value, ecx); |
hpayer@chromium.org | 2f877ac | 2013-09-18 15:29:06 +0000 | [diff] [blame] | 799 | } |
hpayer@chromium.org | 2f877ac | 2013-09-18 15:29:06 +0000 | [diff] [blame] | 800 | |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 801 | // Shift operations can only deoptimize if we do a logical shift by 0 and |
| 802 | // the result cannot be truncated to int32. |
| 803 | if (op == Token::SHR && constant_value == 0) { |
| 804 | if (FLAG_opt_safe_uint32_operations) { |
| 805 | does_deopt = !instr->CheckFlag(HInstruction::kUint32); |
| 806 | } else { |
| 807 | does_deopt = !instr->CheckUsesForFlag(HValue::kTruncatingToInt32); |
| 808 | } |
| 809 | } |
| 810 | |
| 811 | LInstruction* result = |
| 812 | DefineSameAsFirst(new(zone()) LShiftI(op, left, right, does_deopt)); |
| 813 | return does_deopt ? AssignEnvironment(result) : result; |
| 814 | } else { |
| 815 | return DoArithmeticT(op, instr); |
| 816 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 817 | } |
| 818 | |
| 819 | |
| 820 | LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op, |
| 821 | HArithmeticBinaryOperation* instr) { |
| 822 | ASSERT(instr->representation().IsDouble()); |
| 823 | ASSERT(instr->left()->representation().IsDouble()); |
| 824 | ASSERT(instr->right()->representation().IsDouble()); |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 825 | if (op == Token::MOD) { |
| 826 | LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); |
| 827 | LOperand* right = UseRegisterAtStart(instr->BetterRightOperand()); |
| 828 | LArithmeticD* result = new(zone()) LArithmeticD(op, left, right); |
| 829 | return MarkAsCall(DefineSameAsFirst(result), instr); |
| 830 | } else { |
| 831 | LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); |
| 832 | LOperand* right = UseRegisterAtStart(instr->BetterRightOperand()); |
| 833 | LArithmeticD* result = new(zone()) LArithmeticD(op, left, right); |
| 834 | return DefineSameAsFirst(result); |
| 835 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 836 | } |
| 837 | |
| 838 | |
| 839 | LInstruction* LChunkBuilder::DoArithmeticT(Token::Value op, |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 840 | HBinaryOperation* instr) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 841 | HValue* left = instr->left(); |
| 842 | HValue* right = instr->right(); |
jkummerow@chromium.org | fb732b1 | 2013-07-26 10:27:09 +0000 | [diff] [blame] | 843 | ASSERT(left->representation().IsTagged()); |
| 844 | ASSERT(right->representation().IsTagged()); |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 845 | LOperand* context = UseFixed(instr->context(), esi); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 846 | LOperand* left_operand = UseFixed(left, edx); |
| 847 | LOperand* right_operand = UseFixed(right, eax); |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 848 | LArithmeticT* result = |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 849 | new(zone()) LArithmeticT(op, context, left_operand, right_operand); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 850 | return MarkAsCall(DefineFixed(result, eax), instr); |
| 851 | } |
| 852 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 853 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 854 | void LChunkBuilder::DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block) { |
| 855 | ASSERT(is_building()); |
| 856 | current_block_ = block; |
| 857 | next_block_ = next_block; |
| 858 | if (block->IsStartBlock()) { |
| 859 | block->UpdateEnvironment(graph_->start_environment()); |
| 860 | argument_count_ = 0; |
| 861 | } else if (block->predecessors()->length() == 1) { |
| 862 | // We have a single predecessor => copy environment and outgoing |
| 863 | // argument count from the predecessor. |
| 864 | ASSERT(block->phis()->length() == 0); |
| 865 | HBasicBlock* pred = block->predecessors()->at(0); |
| 866 | HEnvironment* last_environment = pred->last_environment(); |
| 867 | ASSERT(last_environment != NULL); |
| 868 | // Only copy the environment, if it is later used again. |
| 869 | if (pred->end()->SecondSuccessor() == NULL) { |
| 870 | ASSERT(pred->end()->FirstSuccessor() == block); |
| 871 | } else { |
| 872 | if (pred->end()->FirstSuccessor()->block_id() > block->block_id() || |
| 873 | pred->end()->SecondSuccessor()->block_id() > block->block_id()) { |
| 874 | last_environment = last_environment->Copy(); |
| 875 | } |
| 876 | } |
| 877 | block->UpdateEnvironment(last_environment); |
| 878 | ASSERT(pred->argument_count() >= 0); |
| 879 | argument_count_ = pred->argument_count(); |
| 880 | } else { |
| 881 | // We are at a state join => process phis. |
| 882 | HBasicBlock* pred = block->predecessors()->at(0); |
| 883 | // No need to copy the environment, it cannot be used later. |
| 884 | HEnvironment* last_environment = pred->last_environment(); |
| 885 | for (int i = 0; i < block->phis()->length(); ++i) { |
| 886 | HPhi* phi = block->phis()->at(i); |
danno@chromium.org | ad75d6f | 2013-08-12 16:57:59 +0000 | [diff] [blame] | 887 | if (phi->HasMergedIndex()) { |
mstarzinger@chromium.org | b228be0 | 2013-04-18 14:56:59 +0000 | [diff] [blame] | 888 | last_environment->SetValueAt(phi->merged_index(), phi); |
| 889 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 890 | } |
| 891 | for (int i = 0; i < block->deleted_phis()->length(); ++i) { |
mstarzinger@chromium.org | b228be0 | 2013-04-18 14:56:59 +0000 | [diff] [blame] | 892 | if (block->deleted_phis()->at(i) < last_environment->length()) { |
| 893 | last_environment->SetValueAt(block->deleted_phis()->at(i), |
| 894 | graph_->GetConstantUndefined()); |
| 895 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 896 | } |
| 897 | block->UpdateEnvironment(last_environment); |
| 898 | // Pick up the outgoing argument count of one of the predecessors. |
| 899 | argument_count_ = pred->argument_count(); |
| 900 | } |
| 901 | HInstruction* current = block->first(); |
| 902 | int start = chunk_->instructions()->length(); |
| 903 | while (current != NULL && !is_aborted()) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 904 | // Code for constants in registers is generated lazily. |
| 905 | if (!current->EmitAtUses()) { |
| 906 | VisitInstruction(current); |
| 907 | } |
| 908 | current = current->next(); |
| 909 | } |
| 910 | int end = chunk_->instructions()->length() - 1; |
| 911 | if (end >= start) { |
| 912 | block->set_first_instruction_index(start); |
| 913 | block->set_last_instruction_index(end); |
| 914 | } |
| 915 | block->set_argument_count(argument_count_); |
| 916 | next_block_ = NULL; |
| 917 | current_block_ = NULL; |
| 918 | } |
| 919 | |
| 920 | |
| 921 | void LChunkBuilder::VisitInstruction(HInstruction* current) { |
| 922 | HInstruction* old_current = current_instruction_; |
| 923 | current_instruction_ = current; |
jkummerow@chromium.org | d8a3a14 | 2013-10-03 12:15:05 +0000 | [diff] [blame] | 924 | |
| 925 | LInstruction* instr = NULL; |
| 926 | if (current->CanReplaceWithDummyUses()) { |
machenbach@chromium.org | 935a779 | 2013-11-12 09:05:18 +0000 | [diff] [blame] | 927 | if (current->OperandCount() == 0) { |
| 928 | instr = DefineAsRegister(new(zone()) LDummy()); |
| 929 | } else { |
| 930 | instr = DefineAsRegister(new(zone()) |
| 931 | LDummyUse(UseAny(current->OperandAt(0)))); |
| 932 | } |
jkummerow@chromium.org | d8a3a14 | 2013-10-03 12:15:05 +0000 | [diff] [blame] | 933 | for (int i = 1; i < current->OperandCount(); ++i) { |
| 934 | LInstruction* dummy = |
| 935 | new(zone()) LDummyUse(UseAny(current->OperandAt(i))); |
| 936 | dummy->set_hydrogen_value(current); |
| 937 | chunk_->AddInstruction(dummy, current_block_); |
| 938 | } |
| 939 | } else { |
| 940 | instr = current->CompileToLithium(this); |
| 941 | } |
| 942 | |
| 943 | argument_count_ += current->argument_delta(); |
| 944 | ASSERT(argument_count_ >= 0); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 945 | |
| 946 | if (instr != NULL) { |
jkummerow@chromium.org | fb7a7c4 | 2013-10-02 11:41:02 +0000 | [diff] [blame] | 947 | // Associate the hydrogen instruction first, since we may need it for |
| 948 | // the ClobbersRegisters() or ClobbersDoubleRegisters() calls below. |
| 949 | instr->set_hydrogen_value(current); |
| 950 | |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 951 | #if DEBUG |
| 952 | // Make sure that the lithium instruction has either no fixed register |
| 953 | // constraints in temps or the result OR no uses that are only used at |
| 954 | // start. If this invariant doesn't hold, the register allocator can decide |
| 955 | // to insert a split of a range immediately before the instruction due to an |
| 956 | // already allocated register needing to be used for the instruction's fixed |
| 957 | // register constraint. In this case, The register allocator won't see an |
| 958 | // interference between the split child and the use-at-start (it would if |
| 959 | // the it was just a plain use), so it is free to move the split child into |
| 960 | // the same register that is used for the use-at-start. |
| 961 | // See https://code.google.com/p/chromium/issues/detail?id=201590 |
| 962 | if (!(instr->ClobbersRegisters() && instr->ClobbersDoubleRegisters())) { |
| 963 | int fixed = 0; |
| 964 | int used_at_start = 0; |
| 965 | for (UseIterator it(instr); !it.Done(); it.Advance()) { |
| 966 | LUnallocated* operand = LUnallocated::cast(it.Current()); |
| 967 | if (operand->IsUsedAtStart()) ++used_at_start; |
| 968 | } |
| 969 | if (instr->Output() != NULL) { |
| 970 | if (LUnallocated::cast(instr->Output())->HasFixedPolicy()) ++fixed; |
| 971 | } |
| 972 | for (TempIterator it(instr); !it.Done(); it.Advance()) { |
| 973 | LUnallocated* operand = LUnallocated::cast(it.Current()); |
| 974 | if (operand->HasFixedPolicy()) ++fixed; |
| 975 | } |
| 976 | ASSERT(fixed == 0 || used_at_start == 0); |
| 977 | } |
| 978 | #endif |
| 979 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 980 | if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) { |
| 981 | instr = AssignPointerMap(instr); |
| 982 | } |
| 983 | if (FLAG_stress_environments && !instr->HasEnvironment()) { |
| 984 | instr = AssignEnvironment(instr); |
| 985 | } |
dslomov@chromium.org | 4a35c5a | 2013-09-13 07:28:52 +0000 | [diff] [blame] | 986 | if (!CpuFeatures::IsSafeForSnapshot(SSE2) && instr->IsGoto() && |
| 987 | LGoto::cast(instr)->jumps_to_join()) { |
| 988 | // TODO(olivf) Since phis of spilled values are joined as registers |
| 989 | // (not in the stack slot), we need to allow the goto gaps to keep one |
| 990 | // x87 register alive. To ensure all other values are still spilled, we |
| 991 | // insert a fpu register barrier right before. |
| 992 | LClobberDoubles* clobber = new(zone()) LClobberDoubles(); |
| 993 | clobber->set_hydrogen_value(current); |
| 994 | chunk_->AddInstruction(clobber, current_block_); |
| 995 | } |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 996 | chunk_->AddInstruction(instr, current_block_); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 997 | } |
| 998 | current_instruction_ = old_current; |
| 999 | } |
| 1000 | |
| 1001 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1002 | LEnvironment* LChunkBuilder::CreateEnvironment( |
| 1003 | HEnvironment* hydrogen_env, |
danno@chromium.org | 5940060 | 2013-08-13 17:09:37 +0000 | [diff] [blame] | 1004 | int* argument_index_accumulator, |
| 1005 | ZoneList<HValue*>* objects_to_materialize) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1006 | if (hydrogen_env == NULL) return NULL; |
| 1007 | |
danno@chromium.org | 5940060 | 2013-08-13 17:09:37 +0000 | [diff] [blame] | 1008 | LEnvironment* outer = CreateEnvironment(hydrogen_env->outer(), |
| 1009 | argument_index_accumulator, |
| 1010 | objects_to_materialize); |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 1011 | BailoutId ast_id = hydrogen_env->ast_id(); |
| 1012 | ASSERT(!ast_id.IsNone() || |
ulan@chromium.org | 967e270 | 2012-02-28 09:49:15 +0000 | [diff] [blame] | 1013 | hydrogen_env->frame_type() != JS_FUNCTION); |
dslomov@chromium.org | b752d40 | 2013-06-18 11:54:54 +0000 | [diff] [blame] | 1014 | int value_count = hydrogen_env->length() - hydrogen_env->specials_count(); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1015 | LEnvironment* result = |
| 1016 | new(zone()) LEnvironment(hydrogen_env->closure(), |
ulan@chromium.org | 967e270 | 2012-02-28 09:49:15 +0000 | [diff] [blame] | 1017 | hydrogen_env->frame_type(), |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1018 | ast_id, |
| 1019 | hydrogen_env->parameter_count(), |
| 1020 | argument_count_, |
| 1021 | value_count, |
rossberg@chromium.org | 400388e | 2012-06-06 09:29:22 +0000 | [diff] [blame] | 1022 | outer, |
ulan@chromium.org | 56c14af | 2012-09-20 12:51:09 +0000 | [diff] [blame] | 1023 | hydrogen_env->entry(), |
rossberg@chromium.org | 400388e | 2012-06-06 09:29:22 +0000 | [diff] [blame] | 1024 | zone()); |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 1025 | int argument_index = *argument_index_accumulator; |
danno@chromium.org | 5940060 | 2013-08-13 17:09:37 +0000 | [diff] [blame] | 1026 | int object_index = objects_to_materialize->length(); |
dslomov@chromium.org | b752d40 | 2013-06-18 11:54:54 +0000 | [diff] [blame] | 1027 | for (int i = 0; i < hydrogen_env->length(); ++i) { |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 1028 | if (hydrogen_env->is_special_index(i)) continue; |
| 1029 | |
danno@chromium.org | 5940060 | 2013-08-13 17:09:37 +0000 | [diff] [blame] | 1030 | LOperand* op; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1031 | HValue* value = hydrogen_env->values()->at(i); |
danno@chromium.org | 5940060 | 2013-08-13 17:09:37 +0000 | [diff] [blame] | 1032 | if (value->IsArgumentsObject() || value->IsCapturedObject()) { |
| 1033 | objects_to_materialize->Add(value, zone()); |
| 1034 | op = LEnvironment::materialization_marker(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1035 | } else if (value->IsPushArgument()) { |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 1036 | op = new(zone()) LArgument(argument_index++); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1037 | } else { |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 1038 | op = UseAny(value); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1039 | } |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 1040 | result->AddValue(op, |
| 1041 | value->representation(), |
| 1042 | value->CheckFlag(HInstruction::kUint32)); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1043 | } |
| 1044 | |
danno@chromium.org | 5940060 | 2013-08-13 17:09:37 +0000 | [diff] [blame] | 1045 | for (int i = object_index; i < objects_to_materialize->length(); ++i) { |
| 1046 | HValue* object_to_materialize = objects_to_materialize->at(i); |
| 1047 | int previously_materialized_object = -1; |
| 1048 | for (int prev = 0; prev < i; ++prev) { |
| 1049 | if (objects_to_materialize->at(prev) == objects_to_materialize->at(i)) { |
| 1050 | previously_materialized_object = prev; |
| 1051 | break; |
| 1052 | } |
| 1053 | } |
| 1054 | int length = object_to_materialize->OperandCount(); |
| 1055 | bool is_arguments = object_to_materialize->IsArgumentsObject(); |
| 1056 | if (previously_materialized_object >= 0) { |
| 1057 | result->AddDuplicateObject(previously_materialized_object); |
| 1058 | continue; |
| 1059 | } else { |
| 1060 | result->AddNewObject(is_arguments ? length - 1 : length, is_arguments); |
| 1061 | } |
| 1062 | for (int i = is_arguments ? 1 : 0; i < length; ++i) { |
| 1063 | LOperand* op; |
| 1064 | HValue* value = object_to_materialize->OperandAt(i); |
| 1065 | if (value->IsArgumentsObject() || value->IsCapturedObject()) { |
| 1066 | objects_to_materialize->Add(value, zone()); |
| 1067 | op = LEnvironment::materialization_marker(); |
| 1068 | } else { |
| 1069 | ASSERT(!value->IsPushArgument()); |
| 1070 | op = UseAny(value); |
| 1071 | } |
dslomov@chromium.org | b752d40 | 2013-06-18 11:54:54 +0000 | [diff] [blame] | 1072 | result->AddValue(op, |
| 1073 | value->representation(), |
| 1074 | value->CheckFlag(HInstruction::kUint32)); |
| 1075 | } |
| 1076 | } |
| 1077 | |
ulan@chromium.org | 967e270 | 2012-02-28 09:49:15 +0000 | [diff] [blame] | 1078 | if (hydrogen_env->frame_type() == JS_FUNCTION) { |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 1079 | *argument_index_accumulator = argument_index; |
| 1080 | } |
| 1081 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1082 | return result; |
| 1083 | } |
| 1084 | |
| 1085 | |
| 1086 | LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { |
dslomov@chromium.org | 4a35c5a | 2013-09-13 07:28:52 +0000 | [diff] [blame] | 1087 | return new(zone()) LGoto(instr->FirstSuccessor()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1088 | } |
| 1089 | |
| 1090 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 1091 | LInstruction* LChunkBuilder::DoBranch(HBranch* instr) { |
jkummerow@chromium.org | d8a3a14 | 2013-10-03 12:15:05 +0000 | [diff] [blame] | 1092 | LInstruction* goto_instr = CheckElideControlInstruction(instr); |
| 1093 | if (goto_instr != NULL) return goto_instr; |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 1094 | |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 1095 | ToBooleanStub::Types expected = instr->expected_input_types(); |
| 1096 | |
| 1097 | // Tagged values that are not known smis or booleans require a |
| 1098 | // deoptimization environment. If the instruction is generic no |
| 1099 | // environment is needed since all cases are handled. |
jkummerow@chromium.org | d8a3a14 | 2013-10-03 12:15:05 +0000 | [diff] [blame] | 1100 | HValue* value = instr->value(); |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 1101 | Representation rep = value->representation(); |
| 1102 | HType type = value->type(); |
| 1103 | if (!rep.IsTagged() || type.IsSmi() || type.IsBoolean()) { |
| 1104 | return new(zone()) LBranch(UseRegister(value), NULL); |
| 1105 | } |
| 1106 | |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 1107 | bool needs_temp = expected.NeedsMap() || expected.IsEmpty(); |
| 1108 | LOperand* temp = needs_temp ? TempRegister() : NULL; |
| 1109 | |
| 1110 | // The Generic stub does not have a deopt, so we need no environment. |
| 1111 | if (expected.IsGeneric()) { |
| 1112 | return new(zone()) LBranch(UseRegister(value), temp); |
| 1113 | } |
| 1114 | |
vegorov@chromium.org | 7943d46 | 2011-08-01 11:41:52 +0000 | [diff] [blame] | 1115 | // We need a temporary register when we have to access the map *or* we have |
| 1116 | // no type info yet, in which case we handle all cases (including the ones |
| 1117 | // involving maps). |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 1118 | return AssignEnvironment(new(zone()) LBranch(UseRegister(value), temp)); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1119 | } |
| 1120 | |
| 1121 | |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 1122 | LInstruction* LChunkBuilder::DoDebugBreak(HDebugBreak* instr) { |
| 1123 | return new(zone()) LDebugBreak(); |
| 1124 | } |
| 1125 | |
| 1126 | |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 1127 | LInstruction* LChunkBuilder::DoCompareMap(HCompareMap* instr) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1128 | ASSERT(instr->value()->representation().IsTagged()); |
| 1129 | LOperand* value = UseRegisterAtStart(instr->value()); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1130 | return new(zone()) LCmpMapAndBranch(value); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1131 | } |
| 1132 | |
| 1133 | |
| 1134 | LInstruction* LChunkBuilder::DoArgumentsLength(HArgumentsLength* length) { |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 1135 | info()->MarkAsRequiresFrame(); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1136 | return DefineAsRegister(new(zone()) LArgumentsLength(Use(length->value()))); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1137 | } |
| 1138 | |
| 1139 | |
| 1140 | LInstruction* LChunkBuilder::DoArgumentsElements(HArgumentsElements* elems) { |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 1141 | info()->MarkAsRequiresFrame(); |
danno@chromium.org | b2a1c07 | 2012-03-23 15:47:56 +0000 | [diff] [blame] | 1142 | return DefineAsRegister(new(zone()) LArgumentsElements); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1143 | } |
| 1144 | |
| 1145 | |
| 1146 | LInstruction* LChunkBuilder::DoInstanceOf(HInstanceOf* instr) { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1147 | LOperand* left = UseFixed(instr->left(), InstanceofStub::left()); |
| 1148 | LOperand* right = UseFixed(instr->right(), InstanceofStub::right()); |
| 1149 | LOperand* context = UseFixed(instr->context(), esi); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1150 | LInstanceOf* result = new(zone()) LInstanceOf(context, left, right); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1151 | return MarkAsCall(DefineFixed(result, eax), instr); |
| 1152 | } |
| 1153 | |
| 1154 | |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 1155 | LInstruction* LChunkBuilder::DoInstanceOfKnownGlobal( |
| 1156 | HInstanceOfKnownGlobal* instr) { |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 1157 | LInstanceOfKnownGlobal* result = |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1158 | new(zone()) LInstanceOfKnownGlobal( |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 1159 | UseFixed(instr->context(), esi), |
| 1160 | UseFixed(instr->left(), InstanceofStub::left()), |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 1161 | FixedTemp(edi)); |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 1162 | return MarkAsCall(DefineFixed(result, eax), instr); |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 1163 | } |
| 1164 | |
| 1165 | |
yangguo@chromium.org | 154ff99 | 2012-03-13 08:09:54 +0000 | [diff] [blame] | 1166 | LInstruction* LChunkBuilder::DoWrapReceiver(HWrapReceiver* instr) { |
| 1167 | LOperand* receiver = UseRegister(instr->receiver()); |
| 1168 | LOperand* function = UseRegisterAtStart(instr->function()); |
| 1169 | LOperand* temp = TempRegister(); |
| 1170 | LWrapReceiver* result = |
| 1171 | new(zone()) LWrapReceiver(receiver, function, temp); |
| 1172 | return AssignEnvironment(DefineSameAsFirst(result)); |
| 1173 | } |
| 1174 | |
| 1175 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1176 | LInstruction* LChunkBuilder::DoApplyArguments(HApplyArguments* instr) { |
| 1177 | LOperand* function = UseFixed(instr->function(), edi); |
| 1178 | LOperand* receiver = UseFixed(instr->receiver(), eax); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1179 | LOperand* length = UseFixed(instr->length(), ebx); |
| 1180 | LOperand* elements = UseFixed(instr->elements(), ecx); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1181 | LApplyArguments* result = new(zone()) LApplyArguments(function, |
| 1182 | receiver, |
| 1183 | length, |
yangguo@chromium.org | 154ff99 | 2012-03-13 08:09:54 +0000 | [diff] [blame] | 1184 | elements); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1185 | return MarkAsCall(DefineFixed(result, eax), instr, CAN_DEOPTIMIZE_EAGERLY); |
| 1186 | } |
| 1187 | |
| 1188 | |
| 1189 | LInstruction* LChunkBuilder::DoPushArgument(HPushArgument* instr) { |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 1190 | LOperand* argument = UseAny(instr->argument()); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1191 | return new(zone()) LPushArgument(argument); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1192 | } |
| 1193 | |
| 1194 | |
verwaest@chromium.org | 662436e | 2013-08-28 08:41:27 +0000 | [diff] [blame] | 1195 | LInstruction* LChunkBuilder::DoStoreCodeEntry( |
| 1196 | HStoreCodeEntry* store_code_entry) { |
| 1197 | LOperand* function = UseRegister(store_code_entry->function()); |
| 1198 | LOperand* code_object = UseTempRegister(store_code_entry->code_object()); |
| 1199 | return new(zone()) LStoreCodeEntry(function, code_object); |
| 1200 | } |
| 1201 | |
| 1202 | |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 1203 | LInstruction* LChunkBuilder::DoInnerAllocatedObject( |
| 1204 | HInnerAllocatedObject* inner_object) { |
| 1205 | LOperand* base_object = UseRegisterAtStart(inner_object->base_object()); |
| 1206 | LInnerAllocatedObject* result = |
| 1207 | new(zone()) LInnerAllocatedObject(base_object); |
| 1208 | return DefineAsRegister(result); |
| 1209 | } |
| 1210 | |
| 1211 | |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 1212 | LInstruction* LChunkBuilder::DoThisFunction(HThisFunction* instr) { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1213 | return instr->HasNoUses() |
| 1214 | ? NULL |
| 1215 | : DefineAsRegister(new(zone()) LThisFunction); |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 1216 | } |
| 1217 | |
| 1218 | |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 1219 | LInstruction* LChunkBuilder::DoContext(HContext* instr) { |
yangguo@chromium.org | 4cd70b4 | 2013-01-04 08:57:54 +0000 | [diff] [blame] | 1220 | if (instr->HasNoUses()) return NULL; |
| 1221 | |
| 1222 | if (info()->IsStub()) { |
| 1223 | return DefineFixed(new(zone()) LContext, esi); |
| 1224 | } |
| 1225 | |
| 1226 | return DefineAsRegister(new(zone()) LContext); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 1227 | } |
| 1228 | |
| 1229 | |
| 1230 | LInstruction* LChunkBuilder::DoOuterContext(HOuterContext* instr) { |
| 1231 | LOperand* context = UseRegisterAtStart(instr->value()); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1232 | return DefineAsRegister(new(zone()) LOuterContext(context)); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 1233 | } |
| 1234 | |
| 1235 | |
yangguo@chromium.org | 5645471 | 2012-02-16 15:33:53 +0000 | [diff] [blame] | 1236 | LInstruction* LChunkBuilder::DoDeclareGlobals(HDeclareGlobals* instr) { |
| 1237 | LOperand* context = UseFixed(instr->context(), esi); |
| 1238 | return MarkAsCall(new(zone()) LDeclareGlobals(context), instr); |
| 1239 | } |
| 1240 | |
| 1241 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1242 | LInstruction* LChunkBuilder::DoGlobalObject(HGlobalObject* instr) { |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 1243 | LOperand* context = UseRegisterAtStart(instr->value()); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1244 | return DefineAsRegister(new(zone()) LGlobalObject(context)); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1245 | } |
| 1246 | |
| 1247 | |
| 1248 | LInstruction* LChunkBuilder::DoGlobalReceiver(HGlobalReceiver* instr) { |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 1249 | LOperand* global_object = UseRegisterAtStart(instr->value()); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1250 | return DefineAsRegister(new(zone()) LGlobalReceiver(global_object)); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1251 | } |
| 1252 | |
| 1253 | |
| 1254 | LInstruction* LChunkBuilder::DoCallConstantFunction( |
| 1255 | HCallConstantFunction* instr) { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1256 | return MarkAsCall(DefineFixed(new(zone()) LCallConstantFunction, eax), instr); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1257 | } |
| 1258 | |
| 1259 | |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 1260 | LInstruction* LChunkBuilder::DoInvokeFunction(HInvokeFunction* instr) { |
| 1261 | LOperand* context = UseFixed(instr->context(), esi); |
| 1262 | LOperand* function = UseFixed(instr->function(), edi); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1263 | LInvokeFunction* result = new(zone()) LInvokeFunction(context, function); |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 1264 | return MarkAsCall(DefineFixed(result, eax), instr, CANNOT_DEOPTIMIZE_EAGERLY); |
| 1265 | } |
| 1266 | |
| 1267 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1268 | LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) { |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 1269 | switch (instr->op()) { |
| 1270 | case kMathFloor: return DoMathFloor(instr); |
| 1271 | case kMathRound: return DoMathRound(instr); |
| 1272 | case kMathAbs: return DoMathAbs(instr); |
| 1273 | case kMathLog: return DoMathLog(instr); |
| 1274 | case kMathSin: return DoMathSin(instr); |
| 1275 | case kMathCos: return DoMathCos(instr); |
| 1276 | case kMathTan: return DoMathTan(instr); |
| 1277 | case kMathExp: return DoMathExp(instr); |
| 1278 | case kMathSqrt: return DoMathSqrt(instr); |
| 1279 | case kMathPowHalf: return DoMathPowHalf(instr); |
| 1280 | default: |
| 1281 | UNREACHABLE(); |
| 1282 | return NULL; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1283 | } |
| 1284 | } |
| 1285 | |
| 1286 | |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 1287 | LInstruction* LChunkBuilder::DoMathFloor(HUnaryMathOperation* instr) { |
| 1288 | LOperand* input = UseRegisterAtStart(instr->value()); |
| 1289 | LMathFloor* result = new(zone()) LMathFloor(input); |
| 1290 | return AssignEnvironment(DefineAsRegister(result)); |
| 1291 | } |
| 1292 | |
| 1293 | |
| 1294 | LInstruction* LChunkBuilder::DoMathRound(HUnaryMathOperation* instr) { |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 1295 | LOperand* input = UseRegister(instr->value()); |
| 1296 | LOperand* temp = FixedTemp(xmm4); |
machenbach@chromium.org | 935a779 | 2013-11-12 09:05:18 +0000 | [diff] [blame] | 1297 | LMathRound* result = new(zone()) LMathRound(input, temp); |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 1298 | return AssignEnvironment(DefineAsRegister(result)); |
| 1299 | } |
| 1300 | |
| 1301 | |
| 1302 | LInstruction* LChunkBuilder::DoMathAbs(HUnaryMathOperation* instr) { |
| 1303 | LOperand* context = UseAny(instr->context()); // Deferred use. |
| 1304 | LOperand* input = UseRegisterAtStart(instr->value()); |
| 1305 | LMathAbs* result = new(zone()) LMathAbs(context, input); |
| 1306 | return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); |
| 1307 | } |
| 1308 | |
| 1309 | |
| 1310 | LInstruction* LChunkBuilder::DoMathLog(HUnaryMathOperation* instr) { |
| 1311 | ASSERT(instr->representation().IsDouble()); |
| 1312 | ASSERT(instr->value()->representation().IsDouble()); |
| 1313 | LOperand* input = UseRegisterAtStart(instr->value()); |
| 1314 | LMathLog* result = new(zone()) LMathLog(input); |
| 1315 | return DefineSameAsFirst(result); |
| 1316 | } |
| 1317 | |
| 1318 | |
| 1319 | LInstruction* LChunkBuilder::DoMathSin(HUnaryMathOperation* instr) { |
| 1320 | LOperand* input = UseFixedDouble(instr->value(), xmm1); |
| 1321 | LMathSin* result = new(zone()) LMathSin(input); |
| 1322 | return MarkAsCall(DefineFixedDouble(result, xmm1), instr); |
| 1323 | } |
| 1324 | |
| 1325 | |
| 1326 | LInstruction* LChunkBuilder::DoMathCos(HUnaryMathOperation* instr) { |
| 1327 | LOperand* input = UseFixedDouble(instr->value(), xmm1); |
| 1328 | LMathCos* result = new(zone()) LMathCos(input); |
| 1329 | return MarkAsCall(DefineFixedDouble(result, xmm1), instr); |
| 1330 | } |
| 1331 | |
| 1332 | |
| 1333 | LInstruction* LChunkBuilder::DoMathTan(HUnaryMathOperation* instr) { |
| 1334 | LOperand* input = UseFixedDouble(instr->value(), xmm1); |
| 1335 | LMathTan* result = new(zone()) LMathTan(input); |
| 1336 | return MarkAsCall(DefineFixedDouble(result, xmm1), instr); |
| 1337 | } |
| 1338 | |
| 1339 | |
| 1340 | LInstruction* LChunkBuilder::DoMathExp(HUnaryMathOperation* instr) { |
| 1341 | ASSERT(instr->representation().IsDouble()); |
| 1342 | ASSERT(instr->value()->representation().IsDouble()); |
| 1343 | LOperand* value = UseTempRegister(instr->value()); |
| 1344 | LOperand* temp1 = TempRegister(); |
| 1345 | LOperand* temp2 = TempRegister(); |
| 1346 | LMathExp* result = new(zone()) LMathExp(value, temp1, temp2); |
| 1347 | return DefineAsRegister(result); |
| 1348 | } |
| 1349 | |
| 1350 | |
| 1351 | LInstruction* LChunkBuilder::DoMathSqrt(HUnaryMathOperation* instr) { |
| 1352 | LOperand* input = UseRegisterAtStart(instr->value()); |
| 1353 | LMathSqrt* result = new(zone()) LMathSqrt(input); |
| 1354 | return DefineSameAsFirst(result); |
| 1355 | } |
| 1356 | |
| 1357 | |
| 1358 | LInstruction* LChunkBuilder::DoMathPowHalf(HUnaryMathOperation* instr) { |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 1359 | LOperand* input = UseRegisterAtStart(instr->value()); |
| 1360 | LOperand* temp = TempRegister(); |
machenbach@chromium.org | 935a779 | 2013-11-12 09:05:18 +0000 | [diff] [blame] | 1361 | LMathPowHalf* result = new(zone()) LMathPowHalf(input, temp); |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 1362 | return DefineSameAsFirst(result); |
| 1363 | } |
| 1364 | |
| 1365 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1366 | LInstruction* LChunkBuilder::DoCallKeyed(HCallKeyed* instr) { |
| 1367 | ASSERT(instr->key()->representation().IsTagged()); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1368 | LOperand* context = UseFixed(instr->context(), esi); |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 1369 | LOperand* key = UseFixed(instr->key(), ecx); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1370 | LCallKeyed* result = new(zone()) LCallKeyed(context, key); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1371 | return MarkAsCall(DefineFixed(result, eax), instr); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1372 | } |
| 1373 | |
| 1374 | |
| 1375 | LInstruction* LChunkBuilder::DoCallNamed(HCallNamed* instr) { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1376 | LOperand* context = UseFixed(instr->context(), esi); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1377 | LCallNamed* result = new(zone()) LCallNamed(context); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1378 | return MarkAsCall(DefineFixed(result, eax), instr); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1379 | } |
| 1380 | |
| 1381 | |
| 1382 | LInstruction* LChunkBuilder::DoCallGlobal(HCallGlobal* instr) { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1383 | LOperand* context = UseFixed(instr->context(), esi); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1384 | LCallGlobal* result = new(zone()) LCallGlobal(context); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1385 | return MarkAsCall(DefineFixed(result, eax), instr); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1386 | } |
| 1387 | |
| 1388 | |
| 1389 | LInstruction* LChunkBuilder::DoCallKnownGlobal(HCallKnownGlobal* instr) { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1390 | return MarkAsCall(DefineFixed(new(zone()) LCallKnownGlobal, eax), instr); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1391 | } |
| 1392 | |
| 1393 | |
| 1394 | LInstruction* LChunkBuilder::DoCallNew(HCallNew* instr) { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1395 | LOperand* context = UseFixed(instr->context(), esi); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1396 | LOperand* constructor = UseFixed(instr->constructor(), edi); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1397 | LCallNew* result = new(zone()) LCallNew(context, constructor); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1398 | return MarkAsCall(DefineFixed(result, eax), instr); |
| 1399 | } |
| 1400 | |
| 1401 | |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 1402 | LInstruction* LChunkBuilder::DoCallNewArray(HCallNewArray* instr) { |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 1403 | LOperand* context = UseFixed(instr->context(), esi); |
| 1404 | LOperand* constructor = UseFixed(instr->constructor(), edi); |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 1405 | LCallNewArray* result = new(zone()) LCallNewArray(context, constructor); |
| 1406 | return MarkAsCall(DefineFixed(result, eax), instr); |
| 1407 | } |
| 1408 | |
| 1409 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1410 | LInstruction* LChunkBuilder::DoCallFunction(HCallFunction* instr) { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1411 | LOperand* context = UseFixed(instr->context(), esi); |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 1412 | LOperand* function = UseFixed(instr->function(), edi); |
machenbach@chromium.org | ea46888 | 2013-11-18 08:53:19 +0000 | [diff] [blame^] | 1413 | LCallFunction* call = new(zone()) LCallFunction(context, function); |
| 1414 | LInstruction* result = DefineFixed(call, eax); |
| 1415 | if (instr->IsTailCall()) return result; |
| 1416 | return MarkAsCall(result, instr); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1417 | } |
| 1418 | |
| 1419 | |
| 1420 | LInstruction* LChunkBuilder::DoCallRuntime(HCallRuntime* instr) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 1421 | LOperand* context = UseFixed(instr->context(), esi); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1422 | return MarkAsCall(DefineFixed(new(zone()) LCallRuntime(context), eax), instr); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1423 | } |
| 1424 | |
| 1425 | |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 1426 | LInstruction* LChunkBuilder::DoRor(HRor* instr) { |
| 1427 | return DoShift(Token::ROR, instr); |
| 1428 | } |
| 1429 | |
| 1430 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1431 | LInstruction* LChunkBuilder::DoShr(HShr* instr) { |
| 1432 | return DoShift(Token::SHR, instr); |
| 1433 | } |
| 1434 | |
| 1435 | |
| 1436 | LInstruction* LChunkBuilder::DoSar(HSar* instr) { |
| 1437 | return DoShift(Token::SAR, instr); |
| 1438 | } |
| 1439 | |
| 1440 | |
| 1441 | LInstruction* LChunkBuilder::DoShl(HShl* instr) { |
| 1442 | return DoShift(Token::SHL, instr); |
| 1443 | } |
| 1444 | |
| 1445 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1446 | LInstruction* LChunkBuilder::DoBitwise(HBitwise* instr) { |
jkummerow@chromium.org | fb732b1 | 2013-07-26 10:27:09 +0000 | [diff] [blame] | 1447 | if (instr->representation().IsSmiOrInteger32()) { |
danno@chromium.org | 5940060 | 2013-08-13 17:09:37 +0000 | [diff] [blame] | 1448 | ASSERT(instr->left()->representation().Equals(instr->representation())); |
| 1449 | ASSERT(instr->right()->representation().Equals(instr->representation())); |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 1450 | ASSERT(instr->CheckFlag(HValue::kTruncatingToInt32)); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1451 | |
ulan@chromium.org | 906e2fb | 2013-05-14 08:14:38 +0000 | [diff] [blame] | 1452 | LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); |
| 1453 | LOperand* right = UseOrConstantAtStart(instr->BetterRightOperand()); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1454 | return DefineSameAsFirst(new(zone()) LBitI(left, right)); |
| 1455 | } else { |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 1456 | return DoArithmeticT(instr->op(), instr); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1457 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1458 | } |
| 1459 | |
| 1460 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1461 | LInstruction* LChunkBuilder::DoDiv(HDiv* instr) { |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 1462 | if (instr->representation().IsSmiOrInteger32()) { |
jkummerow@chromium.org | fb732b1 | 2013-07-26 10:27:09 +0000 | [diff] [blame] | 1463 | ASSERT(instr->left()->representation().Equals(instr->representation())); |
| 1464 | ASSERT(instr->right()->representation().Equals(instr->representation())); |
jkummerow@chromium.org | 5323a9c | 2012-12-10 19:00:50 +0000 | [diff] [blame] | 1465 | if (instr->HasPowerOf2Divisor()) { |
| 1466 | ASSERT(!instr->CheckFlag(HValue::kCanBeDivByZero)); |
| 1467 | LOperand* value = UseRegisterAtStart(instr->left()); |
| 1468 | LDivI* div = |
| 1469 | new(zone()) LDivI(value, UseOrConstant(instr->right()), NULL); |
| 1470 | return AssignEnvironment(DefineSameAsFirst(div)); |
| 1471 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1472 | // The temporary operand is necessary to ensure that right is not allocated |
| 1473 | // into edx. |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 1474 | LOperand* temp = FixedTemp(edx); |
erik.corry@gmail.com | d91075f | 2011-02-10 07:45:38 +0000 | [diff] [blame] | 1475 | LOperand* dividend = UseFixed(instr->left(), eax); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1476 | LOperand* divisor = UseRegister(instr->right()); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1477 | LDivI* result = new(zone()) LDivI(dividend, divisor, temp); |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 1478 | return AssignEnvironment(DefineFixed(result, eax)); |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 1479 | } else if (instr->representation().IsDouble()) { |
| 1480 | return DoArithmeticD(Token::DIV, instr); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1481 | } else { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1482 | return DoArithmeticT(Token::DIV, instr); |
| 1483 | } |
| 1484 | } |
| 1485 | |
| 1486 | |
yangguo@chromium.org | d2899aa | 2012-06-21 11:16:20 +0000 | [diff] [blame] | 1487 | HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) { |
| 1488 | if (divisor->IsConstant() && |
| 1489 | HConstant::cast(divisor)->HasInteger32Value()) { |
| 1490 | HConstant* constant_val = HConstant::cast(divisor); |
| 1491 | return constant_val->CopyToRepresentation(Representation::Integer32(), |
| 1492 | divisor->block()->zone()); |
| 1493 | } |
yangguo@chromium.org | 4cd70b4 | 2013-01-04 08:57:54 +0000 | [diff] [blame] | 1494 | // A value with an integer representation does not need to be transformed. |
| 1495 | if (divisor->representation().IsInteger32()) { |
| 1496 | return divisor; |
| 1497 | // A change from an integer32 can be replaced by the integer32 value. |
| 1498 | } else if (divisor->IsChange() && |
| 1499 | HChange::cast(divisor)->from().IsInteger32()) { |
| 1500 | return HChange::cast(divisor)->value(); |
| 1501 | } |
yangguo@chromium.org | d2899aa | 2012-06-21 11:16:20 +0000 | [diff] [blame] | 1502 | return NULL; |
| 1503 | } |
| 1504 | |
| 1505 | |
| 1506 | LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { |
| 1507 | HValue* right = instr->right(); |
yangguo@chromium.org | 4cd70b4 | 2013-01-04 08:57:54 +0000 | [diff] [blame] | 1508 | if (!right->IsConstant()) { |
| 1509 | ASSERT(right->representation().IsInteger32()); |
| 1510 | // The temporary operand is necessary to ensure that right is not allocated |
| 1511 | // into edx. |
| 1512 | LOperand* temp = FixedTemp(edx); |
| 1513 | LOperand* dividend = UseFixed(instr->left(), eax); |
| 1514 | LOperand* divisor = UseRegister(instr->right()); |
| 1515 | LDivI* flooring_div = new(zone()) LDivI(dividend, divisor, temp); |
| 1516 | return AssignEnvironment(DefineFixed(flooring_div, eax)); |
| 1517 | } |
| 1518 | |
yangguo@chromium.org | d2899aa | 2012-06-21 11:16:20 +0000 | [diff] [blame] | 1519 | ASSERT(right->IsConstant() && HConstant::cast(right)->HasInteger32Value()); |
| 1520 | LOperand* divisor = chunk_->DefineConstantOperand(HConstant::cast(right)); |
| 1521 | int32_t divisor_si = HConstant::cast(right)->Integer32Value(); |
| 1522 | if (divisor_si == 0) { |
| 1523 | LOperand* dividend = UseRegister(instr->left()); |
| 1524 | return AssignEnvironment(DefineAsRegister( |
| 1525 | new(zone()) LMathFloorOfDiv(dividend, divisor, NULL))); |
| 1526 | } else if (IsPowerOf2(abs(divisor_si))) { |
| 1527 | // use dividend as temp if divisor < 0 && divisor != -1 |
| 1528 | LOperand* dividend = divisor_si < -1 ? UseTempRegister(instr->left()) : |
| 1529 | UseRegisterAtStart(instr->left()); |
| 1530 | LInstruction* result = DefineAsRegister( |
| 1531 | new(zone()) LMathFloorOfDiv(dividend, divisor, NULL)); |
| 1532 | return divisor_si < 0 ? AssignEnvironment(result) : result; |
| 1533 | } else { |
| 1534 | // needs edx:eax, plus a temp |
| 1535 | LOperand* dividend = UseFixed(instr->left(), eax); |
| 1536 | LOperand* temp = TempRegister(); |
| 1537 | LInstruction* result = DefineFixed( |
| 1538 | new(zone()) LMathFloorOfDiv(dividend, divisor, temp), edx); |
| 1539 | return divisor_si < 0 ? AssignEnvironment(result) : result; |
| 1540 | } |
| 1541 | } |
| 1542 | |
| 1543 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1544 | LInstruction* LChunkBuilder::DoMod(HMod* instr) { |
verwaest@chromium.org | 8a00e82 | 2013-06-10 15:11:22 +0000 | [diff] [blame] | 1545 | HValue* left = instr->left(); |
| 1546 | HValue* right = instr->right(); |
jkummerow@chromium.org | fb732b1 | 2013-07-26 10:27:09 +0000 | [diff] [blame] | 1547 | if (instr->representation().IsSmiOrInteger32()) { |
danno@chromium.org | 5940060 | 2013-08-13 17:09:37 +0000 | [diff] [blame] | 1548 | ASSERT(instr->left()->representation().Equals(instr->representation())); |
| 1549 | ASSERT(instr->right()->representation().Equals(instr->representation())); |
jkummerow@chromium.org | fb732b1 | 2013-07-26 10:27:09 +0000 | [diff] [blame] | 1550 | |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 1551 | if (instr->HasPowerOf2Divisor()) { |
verwaest@chromium.org | 8a00e82 | 2013-06-10 15:11:22 +0000 | [diff] [blame] | 1552 | ASSERT(!right->CanBeZero()); |
| 1553 | LModI* mod = new(zone()) LModI(UseRegisterAtStart(left), |
| 1554 | UseOrConstant(right), |
| 1555 | NULL); |
| 1556 | LInstruction* result = DefineSameAsFirst(mod); |
| 1557 | return (left->CanBeNegative() && |
| 1558 | instr->CheckFlag(HValue::kBailoutOnMinusZero)) |
| 1559 | ? AssignEnvironment(result) |
| 1560 | : result; |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 1561 | } else if (instr->fixed_right_arg().has_value) { |
verwaest@chromium.org | 8a00e82 | 2013-06-10 15:11:22 +0000 | [diff] [blame] | 1562 | LModI* mod = new(zone()) LModI(UseRegister(left), |
| 1563 | UseRegisterAtStart(right), |
| 1564 | NULL); |
| 1565 | return AssignEnvironment(DefineSameAsFirst(mod)); |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 1566 | } else { |
verwaest@chromium.org | 8a00e82 | 2013-06-10 15:11:22 +0000 | [diff] [blame] | 1567 | // The temporary operand is necessary to ensure that right is not |
| 1568 | // allocated into edx. |
| 1569 | LModI* mod = new(zone()) LModI(UseFixed(left, eax), |
| 1570 | UseRegister(right), |
| 1571 | FixedTemp(edx)); |
| 1572 | LInstruction* result = DefineFixed(mod, edx); |
| 1573 | return (right->CanBeZero() || |
| 1574 | (left->RangeCanInclude(kMinInt) && |
| 1575 | right->RangeCanInclude(-1) && |
| 1576 | instr->CheckFlag(HValue::kBailoutOnMinusZero)) || |
| 1577 | (left->CanBeNegative() && |
| 1578 | instr->CanBeZero() && |
| 1579 | instr->CheckFlag(HValue::kBailoutOnMinusZero))) |
| 1580 | ? AssignEnvironment(result) |
| 1581 | : result; |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 1582 | } |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 1583 | } else if (instr->representation().IsDouble()) { |
| 1584 | return DoArithmeticD(Token::MOD, instr); |
hpayer@chromium.org | 2f877ac | 2013-09-18 15:29:06 +0000 | [diff] [blame] | 1585 | } else { |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 1586 | return DoArithmeticT(Token::MOD, instr); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1587 | } |
| 1588 | } |
| 1589 | |
| 1590 | |
| 1591 | LInstruction* LChunkBuilder::DoMul(HMul* instr) { |
jkummerow@chromium.org | fb732b1 | 2013-07-26 10:27:09 +0000 | [diff] [blame] | 1592 | if (instr->representation().IsSmiOrInteger32()) { |
| 1593 | ASSERT(instr->left()->representation().Equals(instr->representation())); |
| 1594 | ASSERT(instr->right()->representation().Equals(instr->representation())); |
ulan@chromium.org | 906e2fb | 2013-05-14 08:14:38 +0000 | [diff] [blame] | 1595 | LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); |
| 1596 | LOperand* right = UseOrConstant(instr->BetterRightOperand()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1597 | LOperand* temp = NULL; |
| 1598 | if (instr->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 1599 | temp = TempRegister(); |
| 1600 | } |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1601 | LMulI* mul = new(zone()) LMulI(left, right, temp); |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 1602 | if (instr->CheckFlag(HValue::kCanOverflow) || |
| 1603 | instr->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 1604 | AssignEnvironment(mul); |
| 1605 | } |
| 1606 | return DefineSameAsFirst(mul); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1607 | } else if (instr->representation().IsDouble()) { |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 1608 | return DoArithmeticD(Token::MUL, instr); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1609 | } else { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1610 | return DoArithmeticT(Token::MUL, instr); |
| 1611 | } |
| 1612 | } |
| 1613 | |
| 1614 | |
| 1615 | LInstruction* LChunkBuilder::DoSub(HSub* instr) { |
jkummerow@chromium.org | fb732b1 | 2013-07-26 10:27:09 +0000 | [diff] [blame] | 1616 | if (instr->representation().IsSmiOrInteger32()) { |
danno@chromium.org | 5940060 | 2013-08-13 17:09:37 +0000 | [diff] [blame] | 1617 | ASSERT(instr->left()->representation().Equals(instr->representation())); |
| 1618 | ASSERT(instr->right()->representation().Equals(instr->representation())); |
ager@chromium.org | 0ee099b | 2011-01-25 14:06:47 +0000 | [diff] [blame] | 1619 | LOperand* left = UseRegisterAtStart(instr->left()); |
| 1620 | LOperand* right = UseOrConstantAtStart(instr->right()); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1621 | LSubI* sub = new(zone()) LSubI(left, right); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1622 | LInstruction* result = DefineSameAsFirst(sub); |
| 1623 | if (instr->CheckFlag(HValue::kCanOverflow)) { |
| 1624 | result = AssignEnvironment(result); |
| 1625 | } |
| 1626 | return result; |
| 1627 | } else if (instr->representation().IsDouble()) { |
| 1628 | return DoArithmeticD(Token::SUB, instr); |
| 1629 | } else { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1630 | return DoArithmeticT(Token::SUB, instr); |
| 1631 | } |
| 1632 | } |
| 1633 | |
| 1634 | |
| 1635 | LInstruction* LChunkBuilder::DoAdd(HAdd* instr) { |
jkummerow@chromium.org | fb732b1 | 2013-07-26 10:27:09 +0000 | [diff] [blame] | 1636 | if (instr->representation().IsSmiOrInteger32()) { |
danno@chromium.org | 5940060 | 2013-08-13 17:09:37 +0000 | [diff] [blame] | 1637 | ASSERT(instr->left()->representation().Equals(instr->representation())); |
| 1638 | ASSERT(instr->right()->representation().Equals(instr->representation())); |
ulan@chromium.org | 906e2fb | 2013-05-14 08:14:38 +0000 | [diff] [blame] | 1639 | // Check to see if it would be advantageous to use an lea instruction rather |
| 1640 | // than an add. This is the case when no overflow check is needed and there |
| 1641 | // are multiple uses of the add's inputs, so using a 3-register add will |
| 1642 | // preserve all input values for later uses. |
| 1643 | bool use_lea = LAddI::UseLea(instr); |
ulan@chromium.org | 906e2fb | 2013-05-14 08:14:38 +0000 | [diff] [blame] | 1644 | LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); |
| 1645 | HValue* right_candidate = instr->BetterRightOperand(); |
| 1646 | LOperand* right = use_lea |
| 1647 | ? UseRegisterOrConstantAtStart(right_candidate) |
| 1648 | : UseOrConstantAtStart(right_candidate); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1649 | LAddI* add = new(zone()) LAddI(left, right); |
ulan@chromium.org | 906e2fb | 2013-05-14 08:14:38 +0000 | [diff] [blame] | 1650 | bool can_overflow = instr->CheckFlag(HValue::kCanOverflow); |
| 1651 | LInstruction* result = use_lea |
| 1652 | ? DefineAsRegister(add) |
| 1653 | : DefineSameAsFirst(add); |
| 1654 | if (can_overflow) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1655 | result = AssignEnvironment(result); |
| 1656 | } |
| 1657 | return result; |
| 1658 | } else if (instr->representation().IsDouble()) { |
| 1659 | return DoArithmeticD(Token::ADD, instr); |
| 1660 | } else { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1661 | return DoArithmeticT(Token::ADD, instr); |
| 1662 | } |
| 1663 | } |
| 1664 | |
| 1665 | |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 1666 | LInstruction* LChunkBuilder::DoMathMinMax(HMathMinMax* instr) { |
| 1667 | LOperand* left = NULL; |
| 1668 | LOperand* right = NULL; |
jkummerow@chromium.org | fb732b1 | 2013-07-26 10:27:09 +0000 | [diff] [blame] | 1669 | if (instr->representation().IsSmiOrInteger32()) { |
danno@chromium.org | 5940060 | 2013-08-13 17:09:37 +0000 | [diff] [blame] | 1670 | ASSERT(instr->left()->representation().Equals(instr->representation())); |
| 1671 | ASSERT(instr->right()->representation().Equals(instr->representation())); |
ulan@chromium.org | 906e2fb | 2013-05-14 08:14:38 +0000 | [diff] [blame] | 1672 | left = UseRegisterAtStart(instr->BetterLeftOperand()); |
| 1673 | right = UseOrConstantAtStart(instr->BetterRightOperand()); |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 1674 | } else { |
| 1675 | ASSERT(instr->representation().IsDouble()); |
| 1676 | ASSERT(instr->left()->representation().IsDouble()); |
| 1677 | ASSERT(instr->right()->representation().IsDouble()); |
| 1678 | left = UseRegisterAtStart(instr->left()); |
| 1679 | right = UseRegisterAtStart(instr->right()); |
| 1680 | } |
| 1681 | LMathMinMax* minmax = new(zone()) LMathMinMax(left, right); |
| 1682 | return DefineSameAsFirst(minmax); |
| 1683 | } |
| 1684 | |
| 1685 | |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 1686 | LInstruction* LChunkBuilder::DoPower(HPower* instr) { |
| 1687 | ASSERT(instr->representation().IsDouble()); |
| 1688 | // We call a C function for double power. It can't trigger a GC. |
| 1689 | // We need to use fixed result register for the call. |
| 1690 | Representation exponent_type = instr->right()->representation(); |
| 1691 | ASSERT(instr->left()->representation().IsDouble()); |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 1692 | LOperand* left = UseFixedDouble(instr->left(), xmm2); |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 1693 | LOperand* right = exponent_type.IsDouble() ? |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 1694 | UseFixedDouble(instr->right(), xmm1) : |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 1695 | UseFixed(instr->right(), eax); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1696 | LPower* result = new(zone()) LPower(left, right); |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 1697 | return MarkAsCall(DefineFixedDouble(result, xmm3), instr, |
| 1698 | CAN_DEOPTIMIZE_EAGERLY); |
| 1699 | } |
| 1700 | |
| 1701 | |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 1702 | LInstruction* LChunkBuilder::DoRandom(HRandom* instr) { |
| 1703 | ASSERT(instr->representation().IsDouble()); |
dslomov@chromium.org | 4a35c5a | 2013-09-13 07:28:52 +0000 | [diff] [blame] | 1704 | ASSERT(instr->global_object()->representation().IsTagged()); |
| 1705 | LOperand* global_object = UseTempRegister(instr->global_object()); |
| 1706 | LOperand* scratch = TempRegister(); |
| 1707 | LOperand* scratch2 = TempRegister(); |
| 1708 | LOperand* scratch3 = TempRegister(); |
| 1709 | LRandom* result = new(zone()) LRandom( |
| 1710 | global_object, scratch, scratch2, scratch3); |
| 1711 | return DefineFixedDouble(result, xmm1); |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 1712 | } |
| 1713 | |
| 1714 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 1715 | LInstruction* LChunkBuilder::DoCompareGeneric(HCompareGeneric* instr) { |
svenpanne@chromium.org | 53ad175 | 2013-05-27 12:20:38 +0000 | [diff] [blame] | 1716 | ASSERT(instr->left()->representation().IsSmiOrTagged()); |
| 1717 | ASSERT(instr->right()->representation().IsSmiOrTagged()); |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 1718 | LOperand* context = UseFixed(instr->context(), esi); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1719 | LOperand* left = UseFixed(instr->left(), edx); |
| 1720 | LOperand* right = UseFixed(instr->right(), eax); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1721 | LCmpT* result = new(zone()) LCmpT(context, left, right); |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 1722 | return MarkAsCall(DefineFixed(result, eax), instr); |
| 1723 | } |
| 1724 | |
| 1725 | |
mstarzinger@chromium.org | e0e1b0d | 2013-07-08 08:38:06 +0000 | [diff] [blame] | 1726 | LInstruction* LChunkBuilder::DoCompareNumericAndBranch( |
| 1727 | HCompareNumericAndBranch* instr) { |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 1728 | Representation r = instr->representation(); |
jkummerow@chromium.org | c118402 | 2013-05-28 16:58:15 +0000 | [diff] [blame] | 1729 | if (r.IsSmiOrInteger32()) { |
danno@chromium.org | 5940060 | 2013-08-13 17:09:37 +0000 | [diff] [blame] | 1730 | ASSERT(instr->left()->representation().Equals(r)); |
| 1731 | ASSERT(instr->right()->representation().Equals(r)); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1732 | LOperand* left = UseRegisterOrConstantAtStart(instr->left()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1733 | LOperand* right = UseOrConstantAtStart(instr->right()); |
mstarzinger@chromium.org | e0e1b0d | 2013-07-08 08:38:06 +0000 | [diff] [blame] | 1734 | return new(zone()) LCompareNumericAndBranch(left, right); |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 1735 | } else { |
| 1736 | ASSERT(r.IsDouble()); |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 1737 | ASSERT(instr->left()->representation().IsDouble()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1738 | ASSERT(instr->right()->representation().IsDouble()); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1739 | LOperand* left; |
| 1740 | LOperand* right; |
jkummerow@chromium.org | 4000f22 | 2013-10-29 14:58:08 +0000 | [diff] [blame] | 1741 | if (CanBeImmediateConstant(instr->left()) && |
| 1742 | CanBeImmediateConstant(instr->right())) { |
| 1743 | // The code generator requires either both inputs to be constant |
| 1744 | // operands, or neither. |
| 1745 | left = UseConstant(instr->left()); |
| 1746 | right = UseConstant(instr->right()); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1747 | } else { |
| 1748 | left = UseRegisterAtStart(instr->left()); |
| 1749 | right = UseRegisterAtStart(instr->right()); |
| 1750 | } |
mstarzinger@chromium.org | e0e1b0d | 2013-07-08 08:38:06 +0000 | [diff] [blame] | 1751 | return new(zone()) LCompareNumericAndBranch(left, right); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1752 | } |
| 1753 | } |
| 1754 | |
| 1755 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 1756 | LInstruction* LChunkBuilder::DoCompareObjectEqAndBranch( |
| 1757 | HCompareObjectEqAndBranch* instr) { |
jkummerow@chromium.org | d8a3a14 | 2013-10-03 12:15:05 +0000 | [diff] [blame] | 1758 | LInstruction* goto_instr = CheckElideControlInstruction(instr); |
| 1759 | if (goto_instr != NULL) return goto_instr; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1760 | LOperand* left = UseRegisterAtStart(instr->left()); |
mstarzinger@chromium.org | b228be0 | 2013-04-18 14:56:59 +0000 | [diff] [blame] | 1761 | LOperand* right = UseOrConstantAtStart(instr->right()); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1762 | return new(zone()) LCmpObjectEqAndBranch(left, right); |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 1763 | } |
| 1764 | |
| 1765 | |
danno@chromium.org | c00ec2b | 2013-08-14 17:13:49 +0000 | [diff] [blame] | 1766 | LInstruction* LChunkBuilder::DoCompareHoleAndBranch( |
| 1767 | HCompareHoleAndBranch* instr) { |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 1768 | LOperand* value = UseRegisterAtStart(instr->value()); |
| 1769 | return new(zone()) LCmpHoleAndBranch(value); |
danno@chromium.org | c00ec2b | 2013-08-14 17:13:49 +0000 | [diff] [blame] | 1770 | } |
| 1771 | |
| 1772 | |
machenbach@chromium.org | 0cc0950 | 2013-11-13 12:20:55 +0000 | [diff] [blame] | 1773 | LInstruction* LChunkBuilder::DoCompareMinusZeroAndBranch( |
| 1774 | HCompareMinusZeroAndBranch* instr) { |
| 1775 | LInstruction* goto_instr = CheckElideControlInstruction(instr); |
| 1776 | if (goto_instr != NULL) return goto_instr; |
| 1777 | LOperand* value = UseRegister(instr->value()); |
| 1778 | LOperand* scratch = TempRegister(); |
| 1779 | return new(zone()) LCompareMinusZeroAndBranch(value, scratch); |
| 1780 | } |
| 1781 | |
| 1782 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 1783 | LInstruction* LChunkBuilder::DoIsObjectAndBranch(HIsObjectAndBranch* instr) { |
svenpanne@chromium.org | 53ad175 | 2013-05-27 12:20:38 +0000 | [diff] [blame] | 1784 | ASSERT(instr->value()->representation().IsSmiOrTagged()); |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 1785 | LOperand* temp = TempRegister(); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1786 | return new(zone()) LIsObjectAndBranch(UseRegister(instr->value()), temp); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1787 | } |
| 1788 | |
| 1789 | |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 1790 | LInstruction* LChunkBuilder::DoIsStringAndBranch(HIsStringAndBranch* instr) { |
| 1791 | ASSERT(instr->value()->representation().IsTagged()); |
| 1792 | LOperand* temp = TempRegister(); |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 1793 | return new(zone()) LIsStringAndBranch(UseRegister(instr->value()), temp); |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 1794 | } |
| 1795 | |
| 1796 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 1797 | LInstruction* LChunkBuilder::DoIsSmiAndBranch(HIsSmiAndBranch* instr) { |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 1798 | ASSERT(instr->value()->representation().IsTagged()); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1799 | return new(zone()) LIsSmiAndBranch(Use(instr->value())); |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 1800 | } |
| 1801 | |
| 1802 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 1803 | LInstruction* LChunkBuilder::DoIsUndetectableAndBranch( |
| 1804 | HIsUndetectableAndBranch* instr) { |
svenpanne@chromium.org | 53ad175 | 2013-05-27 12:20:38 +0000 | [diff] [blame] | 1805 | ASSERT(instr->value()->representation().IsTagged()); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1806 | return new(zone()) LIsUndetectableAndBranch( |
| 1807 | UseRegisterAtStart(instr->value()), TempRegister()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1808 | } |
| 1809 | |
| 1810 | |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 1811 | LInstruction* LChunkBuilder::DoStringCompareAndBranch( |
| 1812 | HStringCompareAndBranch* instr) { |
| 1813 | ASSERT(instr->left()->representation().IsTagged()); |
| 1814 | ASSERT(instr->right()->representation().IsTagged()); |
| 1815 | LOperand* context = UseFixed(instr->context(), esi); |
| 1816 | LOperand* left = UseFixed(instr->left(), edx); |
| 1817 | LOperand* right = UseFixed(instr->right(), eax); |
| 1818 | |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 1819 | LStringCompareAndBranch* result = new(zone()) |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 1820 | LStringCompareAndBranch(context, left, right); |
| 1821 | |
| 1822 | return MarkAsCall(result, instr); |
| 1823 | } |
| 1824 | |
| 1825 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 1826 | LInstruction* LChunkBuilder::DoHasInstanceTypeAndBranch( |
| 1827 | HHasInstanceTypeAndBranch* instr) { |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 1828 | ASSERT(instr->value()->representation().IsTagged()); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1829 | return new(zone()) LHasInstanceTypeAndBranch( |
| 1830 | UseRegisterAtStart(instr->value()), |
| 1831 | TempRegister()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1832 | } |
| 1833 | |
| 1834 | |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 1835 | LInstruction* LChunkBuilder::DoGetCachedArrayIndex( |
| 1836 | HGetCachedArrayIndex* instr) { |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 1837 | ASSERT(instr->value()->representation().IsTagged()); |
| 1838 | LOperand* value = UseRegisterAtStart(instr->value()); |
| 1839 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1840 | return DefineAsRegister(new(zone()) LGetCachedArrayIndex(value)); |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 1841 | } |
| 1842 | |
| 1843 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 1844 | LInstruction* LChunkBuilder::DoHasCachedArrayIndexAndBranch( |
| 1845 | HHasCachedArrayIndexAndBranch* instr) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1846 | ASSERT(instr->value()->representation().IsTagged()); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1847 | return new(zone()) LHasCachedArrayIndexAndBranch( |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 1848 | UseRegisterAtStart(instr->value())); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1849 | } |
| 1850 | |
| 1851 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 1852 | LInstruction* LChunkBuilder::DoClassOfTestAndBranch( |
| 1853 | HClassOfTestAndBranch* instr) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1854 | ASSERT(instr->value()->representation().IsTagged()); |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 1855 | return new(zone()) LClassOfTestAndBranch(UseRegister(instr->value()), |
| 1856 | TempRegister(), |
| 1857 | TempRegister()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1858 | } |
| 1859 | |
| 1860 | |
yangguo@chromium.org | 355cfd1 | 2012-08-29 15:32:24 +0000 | [diff] [blame] | 1861 | LInstruction* LChunkBuilder::DoMapEnumLength(HMapEnumLength* instr) { |
| 1862 | LOperand* map = UseRegisterAtStart(instr->value()); |
| 1863 | return DefineAsRegister(new(zone()) LMapEnumLength(map)); |
| 1864 | } |
| 1865 | |
| 1866 | |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 1867 | LInstruction* LChunkBuilder::DoElementsKind(HElementsKind* instr) { |
| 1868 | LOperand* object = UseRegisterAtStart(instr->value()); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1869 | return DefineAsRegister(new(zone()) LElementsKind(object)); |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 1870 | } |
| 1871 | |
| 1872 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1873 | LInstruction* LChunkBuilder::DoValueOf(HValueOf* instr) { |
| 1874 | LOperand* object = UseRegister(instr->value()); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1875 | LValueOf* result = new(zone()) LValueOf(object, TempRegister()); |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 1876 | return DefineSameAsFirst(result); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1877 | } |
| 1878 | |
| 1879 | |
svenpanne@chromium.org | 4efbdb1 | 2012-03-12 08:18:42 +0000 | [diff] [blame] | 1880 | LInstruction* LChunkBuilder::DoDateField(HDateField* instr) { |
| 1881 | LOperand* date = UseFixed(instr->value(), eax); |
| 1882 | LDateField* result = |
| 1883 | new(zone()) LDateField(date, FixedTemp(ecx), instr->index()); |
mstarzinger@chromium.org | de88679 | 2012-09-11 13:22:37 +0000 | [diff] [blame] | 1884 | return MarkAsCall(DefineFixed(result, eax), instr, CAN_DEOPTIMIZE_EAGERLY); |
svenpanne@chromium.org | 4efbdb1 | 2012-03-12 08:18:42 +0000 | [diff] [blame] | 1885 | } |
| 1886 | |
| 1887 | |
machenbach@chromium.org | e8412be | 2013-11-08 10:23:52 +0000 | [diff] [blame] | 1888 | LInstruction* LChunkBuilder::DoSeqStringGetChar(HSeqStringGetChar* instr) { |
| 1889 | LOperand* string = UseRegisterAtStart(instr->string()); |
| 1890 | LOperand* index = UseRegisterOrConstantAtStart(instr->index()); |
| 1891 | return DefineAsRegister(new(zone()) LSeqStringGetChar(string, index)); |
| 1892 | } |
| 1893 | |
| 1894 | |
mstarzinger@chromium.org | 32280cf | 2012-12-06 17:32:37 +0000 | [diff] [blame] | 1895 | LInstruction* LChunkBuilder::DoSeqStringSetChar(HSeqStringSetChar* instr) { |
machenbach@chromium.org | e8412be | 2013-11-08 10:23:52 +0000 | [diff] [blame] | 1896 | LOperand* string = UseRegisterAtStart(instr->string()); |
| 1897 | LOperand* index = UseRegisterOrConstantAtStart(instr->index()); |
| 1898 | LOperand* value = (instr->encoding() == String::ONE_BYTE_ENCODING) |
| 1899 | ? UseFixedOrConstant(instr->value(), eax) |
| 1900 | : UseRegisterOrConstantAtStart(instr->value()); |
| 1901 | return new(zone()) LSeqStringSetChar(string, index, value); |
mstarzinger@chromium.org | 32280cf | 2012-12-06 17:32:37 +0000 | [diff] [blame] | 1902 | } |
| 1903 | |
| 1904 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1905 | LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1906 | return AssignEnvironment(new(zone()) LBoundsCheck( |
danno@chromium.org | b645116 | 2011-08-17 14:33:23 +0000 | [diff] [blame] | 1907 | UseRegisterOrConstantAtStart(instr->index()), |
| 1908 | UseAtStart(instr->length()))); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1909 | } |
| 1910 | |
| 1911 | |
svenpanne@chromium.org | 876cca8 | 2013-03-18 14:43:20 +0000 | [diff] [blame] | 1912 | LInstruction* LChunkBuilder::DoBoundsCheckBaseIndexInformation( |
| 1913 | HBoundsCheckBaseIndexInformation* instr) { |
| 1914 | UNREACHABLE(); |
| 1915 | return NULL; |
| 1916 | } |
| 1917 | |
| 1918 | |
jkummerow@chromium.org | c366976 | 2013-09-30 13:42:25 +0000 | [diff] [blame] | 1919 | LInstruction* LChunkBuilder::DoAbnormalExit(HAbnormalExit* instr) { |
| 1920 | // The control instruction marking the end of a block that completed |
| 1921 | // abruptly (e.g., threw an exception). There is nothing specific to do. |
| 1922 | return NULL; |
| 1923 | } |
| 1924 | |
| 1925 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1926 | LInstruction* LChunkBuilder::DoThrow(HThrow* instr) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 1927 | LOperand* context = UseFixed(instr->context(), esi); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1928 | LOperand* value = UseFixed(instr->value(), eax); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1929 | return MarkAsCall(new(zone()) LThrow(context, value), instr); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1930 | } |
| 1931 | |
| 1932 | |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 1933 | LInstruction* LChunkBuilder::DoUseConst(HUseConst* instr) { |
| 1934 | return NULL; |
| 1935 | } |
| 1936 | |
| 1937 | |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 1938 | LInstruction* LChunkBuilder::DoForceRepresentation(HForceRepresentation* bad) { |
| 1939 | // All HForceRepresentation instructions should be eliminated in the |
| 1940 | // representation change phase of Hydrogen. |
| 1941 | UNREACHABLE(); |
| 1942 | return NULL; |
| 1943 | } |
| 1944 | |
| 1945 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1946 | LInstruction* LChunkBuilder::DoChange(HChange* instr) { |
| 1947 | Representation from = instr->from(); |
| 1948 | Representation to = instr->to(); |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 1949 | if (from.IsSmi()) { |
| 1950 | if (to.IsTagged()) { |
| 1951 | LOperand* value = UseRegister(instr->value()); |
svenpanne@chromium.org | 53ad175 | 2013-05-27 12:20:38 +0000 | [diff] [blame] | 1952 | return DefineSameAsFirst(new(zone()) LDummyUse(value)); |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 1953 | } |
| 1954 | from = Representation::Tagged(); |
| 1955 | } |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 1956 | // Only mark conversions that might need to allocate as calling rather than |
| 1957 | // all changes. This makes simple, non-allocating conversion not have to force |
| 1958 | // building a stack frame. |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1959 | if (from.IsTagged()) { |
| 1960 | if (to.IsDouble()) { |
| 1961 | LOperand* value = UseRegister(instr->value()); |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 1962 | // Temp register only necessary for minus zero check. |
dslomov@chromium.org | 4a35c5a | 2013-09-13 07:28:52 +0000 | [diff] [blame] | 1963 | LOperand* temp = TempRegister(); |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 1964 | LNumberUntagD* res = new(zone()) LNumberUntagD(value, temp); |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 1965 | return AssignEnvironment(DefineAsRegister(res)); |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 1966 | } else if (to.IsSmi()) { |
| 1967 | HValue* val = instr->value(); |
| 1968 | LOperand* value = UseRegister(val); |
| 1969 | if (val->type().IsSmi()) { |
| 1970 | return DefineSameAsFirst(new(zone()) LDummyUse(value)); |
| 1971 | } |
svenpanne@chromium.org | 53ad175 | 2013-05-27 12:20:38 +0000 | [diff] [blame] | 1972 | return AssignEnvironment(DefineSameAsFirst(new(zone()) LCheckSmi(value))); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1973 | } else { |
| 1974 | ASSERT(to.IsInteger32()); |
verwaest@chromium.org | 662436e | 2013-08-28 08:41:27 +0000 | [diff] [blame] | 1975 | HValue* val = instr->value(); |
| 1976 | if (val->type().IsSmi() || val->representation().IsSmi()) { |
| 1977 | LOperand* value = UseRegister(val); |
svenpanne@chromium.org | 53ad175 | 2013-05-27 12:20:38 +0000 | [diff] [blame] | 1978 | return DefineSameAsFirst(new(zone()) LSmiUntag(value, false)); |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 1979 | } else { |
ricow@chromium.org | c54d365 | 2011-05-30 09:20:16 +0000 | [diff] [blame] | 1980 | bool truncating = instr->CanTruncateToInt32(); |
jkummerow@chromium.org | 8fa5bd9 | 2013-09-02 11:45:09 +0000 | [diff] [blame] | 1981 | LOperand* xmm_temp = |
| 1982 | (CpuFeatures::IsSafeForSnapshot(SSE2) && !truncating) |
| 1983 | ? FixedTemp(xmm1) : NULL; |
| 1984 | LTaggedToI* res = new(zone()) LTaggedToI(UseRegister(val), xmm_temp); |
| 1985 | return AssignEnvironment(DefineSameAsFirst(res)); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1986 | } |
| 1987 | } |
| 1988 | } else if (from.IsDouble()) { |
| 1989 | if (to.IsTagged()) { |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 1990 | info()->MarkAsDeferredCalling(); |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 1991 | LOperand* value = UseRegisterAtStart(instr->value()); |
mstarzinger@chromium.org | 068ea0a | 2013-01-30 09:39:44 +0000 | [diff] [blame] | 1992 | LOperand* temp = FLAG_inline_new ? TempRegister() : NULL; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1993 | |
| 1994 | // Make sure that temp and result_temp are different registers. |
| 1995 | LUnallocated* result_temp = TempRegister(); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1996 | LNumberTagD* result = new(zone()) LNumberTagD(value, temp); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1997 | return AssignPointerMap(Define(result, result_temp)); |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 1998 | } else if (to.IsSmi()) { |
| 1999 | LOperand* value = UseRegister(instr->value()); |
| 2000 | return AssignEnvironment( |
| 2001 | DefineAsRegister(new(zone()) LDoubleToSmi(value))); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2002 | } else { |
| 2003 | ASSERT(to.IsInteger32()); |
ricow@chromium.org | c54d365 | 2011-05-30 09:20:16 +0000 | [diff] [blame] | 2004 | bool truncating = instr->CanTruncateToInt32(); |
jkummerow@chromium.org | 8fa5bd9 | 2013-09-02 11:45:09 +0000 | [diff] [blame] | 2005 | bool needs_temp = CpuFeatures::IsSafeForSnapshot(SSE2) && !truncating; |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 2006 | LOperand* value = needs_temp ? |
| 2007 | UseTempRegister(instr->value()) : UseRegister(instr->value()); |
| 2008 | LOperand* temp = needs_temp ? TempRegister() : NULL; |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2009 | return AssignEnvironment( |
| 2010 | DefineAsRegister(new(zone()) LDoubleToI(value, temp))); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2011 | } |
| 2012 | } else if (from.IsInteger32()) { |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 2013 | info()->MarkAsDeferredCalling(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2014 | if (to.IsTagged()) { |
| 2015 | HValue* val = instr->value(); |
| 2016 | LOperand* value = UseRegister(val); |
| 2017 | if (val->HasRange() && val->range()->IsInSmiRange()) { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2018 | return DefineSameAsFirst(new(zone()) LSmiTag(value)); |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 2019 | } else if (val->CheckFlag(HInstruction::kUint32)) { |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 2020 | LOperand* temp = CpuFeatures::IsSupported(SSE2) ? FixedTemp(xmm1) |
| 2021 | : NULL; |
| 2022 | LNumberTagU* result = new(zone()) LNumberTagU(value, temp); |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 2023 | return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2024 | } else { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2025 | LNumberTagI* result = new(zone()) LNumberTagI(value); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2026 | return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); |
| 2027 | } |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 2028 | } else if (to.IsSmi()) { |
| 2029 | HValue* val = instr->value(); |
| 2030 | LOperand* value = UseRegister(val); |
machenbach@chromium.org | ed29eb2 | 2013-10-31 13:30:00 +0000 | [diff] [blame] | 2031 | LInstruction* result = val->CheckFlag(HInstruction::kUint32) |
| 2032 | ? DefineSameAsFirst(new(zone()) LUint32ToSmi(value)) |
| 2033 | : DefineSameAsFirst(new(zone()) LInteger32ToSmi(value)); |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 2034 | if (val->HasRange() && val->range()->IsInSmiRange()) { |
| 2035 | return result; |
| 2036 | } |
| 2037 | return AssignEnvironment(result); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2038 | } else { |
| 2039 | ASSERT(to.IsDouble()); |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 2040 | if (instr->value()->CheckFlag(HInstruction::kUint32)) { |
| 2041 | LOperand* temp = FixedTemp(xmm1); |
| 2042 | return DefineAsRegister( |
| 2043 | new(zone()) LUint32ToDouble(UseRegister(instr->value()), temp)); |
| 2044 | } else { |
| 2045 | return DefineAsRegister( |
| 2046 | new(zone()) LInteger32ToDouble(Use(instr->value()))); |
| 2047 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2048 | } |
| 2049 | } |
| 2050 | UNREACHABLE(); |
| 2051 | return NULL; |
| 2052 | } |
| 2053 | |
| 2054 | |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 2055 | LInstruction* LChunkBuilder::DoCheckHeapObject(HCheckHeapObject* instr) { |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 2056 | LOperand* value = UseAtStart(instr->value()); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2057 | return AssignEnvironment(new(zone()) LCheckNonSmi(value)); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2058 | } |
| 2059 | |
| 2060 | |
mstarzinger@chromium.org | e0e1b0d | 2013-07-08 08:38:06 +0000 | [diff] [blame] | 2061 | LInstruction* LChunkBuilder::DoCheckSmi(HCheckSmi* instr) { |
| 2062 | LOperand* value = UseRegisterAtStart(instr->value()); |
| 2063 | return AssignEnvironment(new(zone()) LCheckSmi(value)); |
| 2064 | } |
| 2065 | |
| 2066 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2067 | LInstruction* LChunkBuilder::DoCheckInstanceType(HCheckInstanceType* instr) { |
| 2068 | LOperand* value = UseRegisterAtStart(instr->value()); |
| 2069 | LOperand* temp = TempRegister(); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2070 | LCheckInstanceType* result = new(zone()) LCheckInstanceType(value, temp); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2071 | return AssignEnvironment(result); |
| 2072 | } |
| 2073 | |
| 2074 | |
mstarzinger@chromium.org | 1f410f9 | 2013-08-29 08:13:16 +0000 | [diff] [blame] | 2075 | LInstruction* LChunkBuilder::DoCheckValue(HCheckValue* instr) { |
| 2076 | // If the object is in new space, we'll emit a global cell compare and so |
| 2077 | // want the value in a register. If the object gets promoted before we |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2078 | // emit code, we will still get the register but will do an immediate |
| 2079 | // compare instead of the cell compare. This is safe. |
mstarzinger@chromium.org | 1f410f9 | 2013-08-29 08:13:16 +0000 | [diff] [blame] | 2080 | LOperand* value = instr->object_in_new_space() |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 2081 | ? UseRegisterAtStart(instr->value()) : UseAtStart(instr->value()); |
mstarzinger@chromium.org | 1f410f9 | 2013-08-29 08:13:16 +0000 | [diff] [blame] | 2082 | return AssignEnvironment(new(zone()) LCheckValue(value)); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2083 | } |
| 2084 | |
| 2085 | |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 2086 | LInstruction* LChunkBuilder::DoCheckMaps(HCheckMaps* instr) { |
yangguo@chromium.org | c73d55b | 2013-07-24 08:18:28 +0000 | [diff] [blame] | 2087 | LOperand* value = NULL; |
danno@chromium.org | 5940060 | 2013-08-13 17:09:37 +0000 | [diff] [blame] | 2088 | if (!instr->CanOmitMapChecks()) { |
| 2089 | value = UseRegisterAtStart(instr->value()); |
| 2090 | if (instr->has_migration_target()) info()->MarkAsDeferredCalling(); |
| 2091 | } |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 2092 | LCheckMaps* result = new(zone()) LCheckMaps(value); |
danno@chromium.org | 5940060 | 2013-08-13 17:09:37 +0000 | [diff] [blame] | 2093 | if (!instr->CanOmitMapChecks()) { |
| 2094 | AssignEnvironment(result); |
| 2095 | if (instr->has_migration_target()) return AssignPointerMap(result); |
| 2096 | } |
| 2097 | return result; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2098 | } |
| 2099 | |
| 2100 | |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 2101 | LInstruction* LChunkBuilder::DoClampToUint8(HClampToUint8* instr) { |
| 2102 | HValue* value = instr->value(); |
| 2103 | Representation input_rep = value->representation(); |
| 2104 | if (input_rep.IsDouble()) { |
| 2105 | LOperand* reg = UseRegister(value); |
rossberg@chromium.org | 89e18f5 | 2012-10-22 13:09:53 +0000 | [diff] [blame] | 2106 | return DefineFixed(new(zone()) LClampDToUint8(reg), eax); |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 2107 | } else if (input_rep.IsInteger32()) { |
| 2108 | LOperand* reg = UseFixed(value, eax); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2109 | return DefineFixed(new(zone()) LClampIToUint8(reg), eax); |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 2110 | } else { |
svenpanne@chromium.org | 53ad175 | 2013-05-27 12:20:38 +0000 | [diff] [blame] | 2111 | ASSERT(input_rep.IsSmiOrTagged()); |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 2112 | if (CpuFeatures::IsSupported(SSE2)) { |
| 2113 | LOperand* reg = UseFixed(value, eax); |
| 2114 | // Register allocator doesn't (yet) support allocation of double |
| 2115 | // temps. Reserve xmm1 explicitly. |
| 2116 | LOperand* temp = FixedTemp(xmm1); |
| 2117 | LClampTToUint8* result = new(zone()) LClampTToUint8(reg, temp); |
| 2118 | return AssignEnvironment(DefineFixed(result, eax)); |
| 2119 | } else { |
| 2120 | LOperand* value = UseRegister(instr->value()); |
| 2121 | LClampTToUint8NoSSE2* res = |
| 2122 | new(zone()) LClampTToUint8NoSSE2(value, TempRegister(), |
| 2123 | TempRegister(), TempRegister()); |
| 2124 | return AssignEnvironment(DefineFixed(res, ecx)); |
| 2125 | } |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 2126 | } |
| 2127 | } |
| 2128 | |
| 2129 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2130 | LInstruction* LChunkBuilder::DoReturn(HReturn* instr) { |
machenbach@chromium.org | 935a779 | 2013-11-12 09:05:18 +0000 | [diff] [blame] | 2131 | LOperand* context = info()->IsStub() ? UseFixed(instr->context(), esi) : NULL; |
ulan@chromium.org | 6e196bf | 2013-03-13 09:38:22 +0000 | [diff] [blame] | 2132 | LOperand* parameter_count = UseRegisterOrConstant(instr->parameter_count()); |
machenbach@chromium.org | 935a779 | 2013-11-12 09:05:18 +0000 | [diff] [blame] | 2133 | return new(zone()) LReturn( |
| 2134 | UseFixed(instr->value(), eax), context, parameter_count); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2135 | } |
| 2136 | |
| 2137 | |
| 2138 | LInstruction* LChunkBuilder::DoConstant(HConstant* instr) { |
| 2139 | Representation r = instr->representation(); |
rossberg@chromium.org | b99c754 | 2013-05-31 11:40:45 +0000 | [diff] [blame] | 2140 | if (r.IsSmi()) { |
| 2141 | return DefineAsRegister(new(zone()) LConstantS); |
| 2142 | } else if (r.IsInteger32()) { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2143 | return DefineAsRegister(new(zone()) LConstantI); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2144 | } else if (r.IsDouble()) { |
| 2145 | double value = instr->DoubleValue(); |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 2146 | bool value_is_zero = BitCast<uint64_t, double>(value) == 0; |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 2147 | LOperand* temp = value_is_zero ? NULL : TempRegister(); |
| 2148 | return DefineAsRegister(new(zone()) LConstantD(temp)); |
danno@chromium.org | d3c4210 | 2013-08-01 16:58:23 +0000 | [diff] [blame] | 2149 | } else if (r.IsExternal()) { |
| 2150 | return DefineAsRegister(new(zone()) LConstantE); |
rossberg@chromium.org | b99c754 | 2013-05-31 11:40:45 +0000 | [diff] [blame] | 2151 | } else if (r.IsTagged()) { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2152 | return DefineAsRegister(new(zone()) LConstantT); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2153 | } else { |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 2154 | UNREACHABLE(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2155 | return NULL; |
| 2156 | } |
| 2157 | } |
| 2158 | |
| 2159 | |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 2160 | LInstruction* LChunkBuilder::DoLoadGlobalCell(HLoadGlobalCell* instr) { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2161 | LLoadGlobalCell* result = new(zone()) LLoadGlobalCell; |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2162 | return instr->RequiresHoleCheck() |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2163 | ? AssignEnvironment(DefineAsRegister(result)) |
| 2164 | : DefineAsRegister(result); |
| 2165 | } |
| 2166 | |
| 2167 | |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 2168 | LInstruction* LChunkBuilder::DoLoadGlobalGeneric(HLoadGlobalGeneric* instr) { |
| 2169 | LOperand* context = UseFixed(instr->context(), esi); |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 2170 | LOperand* global_object = UseFixed(instr->global_object(), edx); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2171 | LLoadGlobalGeneric* result = |
| 2172 | new(zone()) LLoadGlobalGeneric(context, global_object); |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 2173 | return MarkAsCall(DefineFixed(result, eax), instr); |
| 2174 | } |
| 2175 | |
| 2176 | |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 2177 | LInstruction* LChunkBuilder::DoStoreGlobalCell(HStoreGlobalCell* instr) { |
| 2178 | LStoreGlobalCell* result = |
danno@chromium.org | e78f9fc | 2011-12-21 08:29:34 +0000 | [diff] [blame] | 2179 | new(zone()) LStoreGlobalCell(UseRegister(instr->value())); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2180 | return instr->RequiresHoleCheck() ? AssignEnvironment(result) : result; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2181 | } |
| 2182 | |
| 2183 | |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 2184 | LInstruction* LChunkBuilder::DoStoreGlobalGeneric(HStoreGlobalGeneric* instr) { |
| 2185 | LOperand* context = UseFixed(instr->context(), esi); |
| 2186 | LOperand* global_object = UseFixed(instr->global_object(), edx); |
| 2187 | LOperand* value = UseFixed(instr->value(), eax); |
| 2188 | LStoreGlobalGeneric* result = |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2189 | new(zone()) LStoreGlobalGeneric(context, global_object, value); |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 2190 | return MarkAsCall(result, instr); |
| 2191 | } |
| 2192 | |
| 2193 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 2194 | LInstruction* LChunkBuilder::DoLoadContextSlot(HLoadContextSlot* instr) { |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 2195 | LOperand* context = UseRegisterAtStart(instr->value()); |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 2196 | LInstruction* result = |
| 2197 | DefineAsRegister(new(zone()) LLoadContextSlot(context)); |
| 2198 | return instr->RequiresHoleCheck() ? AssignEnvironment(result) : result; |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 2199 | } |
| 2200 | |
| 2201 | |
| 2202 | LInstruction* LChunkBuilder::DoStoreContextSlot(HStoreContextSlot* instr) { |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 2203 | LOperand* value; |
| 2204 | LOperand* temp; |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2205 | LOperand* context = UseRegister(instr->context()); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 2206 | if (instr->NeedsWriteBarrier()) { |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 2207 | value = UseTempRegister(instr->value()); |
| 2208 | temp = TempRegister(); |
| 2209 | } else { |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 2210 | value = UseRegister(instr->value()); |
| 2211 | temp = NULL; |
| 2212 | } |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 2213 | LInstruction* result = new(zone()) LStoreContextSlot(context, value, temp); |
| 2214 | return instr->RequiresHoleCheck() ? AssignEnvironment(result) : result; |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 2215 | } |
| 2216 | |
| 2217 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2218 | LInstruction* LChunkBuilder::DoLoadNamedField(HLoadNamedField* instr) { |
danno@chromium.org | d3c4210 | 2013-08-01 16:58:23 +0000 | [diff] [blame] | 2219 | LOperand* obj = (instr->access().IsExternalMemory() && |
| 2220 | instr->access().offset() == 0) |
| 2221 | ? UseRegisterOrConstantAtStart(instr->object()) |
| 2222 | : UseRegisterAtStart(instr->object()); |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 2223 | return DefineAsRegister(new(zone()) LLoadNamedField(obj)); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2224 | } |
| 2225 | |
| 2226 | |
| 2227 | LInstruction* LChunkBuilder::DoLoadNamedGeneric(HLoadNamedGeneric* instr) { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2228 | LOperand* context = UseFixed(instr->context(), esi); |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 2229 | LOperand* object = UseFixed(instr->object(), edx); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2230 | LLoadNamedGeneric* result = new(zone()) LLoadNamedGeneric(context, object); |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 2231 | return MarkAsCall(DefineFixed(result, eax), instr); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2232 | } |
| 2233 | |
| 2234 | |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 2235 | LInstruction* LChunkBuilder::DoLoadFunctionPrototype( |
| 2236 | HLoadFunctionPrototype* instr) { |
| 2237 | return AssignEnvironment(DefineAsRegister( |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2238 | new(zone()) LLoadFunctionPrototype(UseRegister(instr->function()), |
| 2239 | TempRegister()))); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 2240 | } |
| 2241 | |
| 2242 | |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 2243 | LInstruction* LChunkBuilder::DoLoadRoot(HLoadRoot* instr) { |
| 2244 | return DefineAsRegister(new(zone()) LLoadRoot); |
| 2245 | } |
| 2246 | |
| 2247 | |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 2248 | LInstruction* LChunkBuilder::DoLoadExternalArrayPointer( |
| 2249 | HLoadExternalArrayPointer* instr) { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2250 | LOperand* input = UseRegisterAtStart(instr->value()); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2251 | return DefineAsRegister(new(zone()) LLoadExternalArrayPointer(input)); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2252 | } |
| 2253 | |
| 2254 | |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 2255 | LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) { |
jkummerow@chromium.org | fb732b1 | 2013-07-26 10:27:09 +0000 | [diff] [blame] | 2256 | ASSERT(instr->key()->representation().IsSmiOrInteger32()); |
kmillikin@chromium.org | 83e1682 | 2011-09-13 08:21:47 +0000 | [diff] [blame] | 2257 | ElementsKind elements_kind = instr->elements_kind(); |
yangguo@chromium.org | eeb44b6 | 2012-11-13 13:56:09 +0000 | [diff] [blame] | 2258 | bool clobbers_key = ExternalArrayOpRequiresTemp( |
| 2259 | instr->key()->representation(), elements_kind); |
| 2260 | LOperand* key = clobbers_key |
yangguo@chromium.org | 304cc33 | 2012-07-24 07:59:48 +0000 | [diff] [blame] | 2261 | ? UseTempRegister(instr->key()) |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 2262 | : UseRegisterOrConstantAtStart(instr->key()); |
yangguo@chromium.org | eeb44b6 | 2012-11-13 13:56:09 +0000 | [diff] [blame] | 2263 | LLoadKeyed* result = NULL; |
yangguo@chromium.org | 304cc33 | 2012-07-24 07:59:48 +0000 | [diff] [blame] | 2264 | |
yangguo@chromium.org | eeb44b6 | 2012-11-13 13:56:09 +0000 | [diff] [blame] | 2265 | if (!instr->is_external()) { |
| 2266 | LOperand* obj = UseRegisterAtStart(instr->elements()); |
| 2267 | result = new(zone()) LLoadKeyed(obj, key); |
| 2268 | } else { |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 2269 | ASSERT( |
| 2270 | (instr->representation().IsInteger32() && |
| 2271 | (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && |
| 2272 | (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || |
| 2273 | (instr->representation().IsDouble() && |
| 2274 | ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || |
| 2275 | (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); |
yangguo@chromium.org | eeb44b6 | 2012-11-13 13:56:09 +0000 | [diff] [blame] | 2276 | LOperand* external_pointer = UseRegister(instr->elements()); |
| 2277 | result = new(zone()) LLoadKeyed(external_pointer, key); |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 2278 | } |
| 2279 | |
| 2280 | DefineAsRegister(result); |
| 2281 | bool can_deoptimize = instr->RequiresHoleCheck() || |
| 2282 | (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS); |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 2283 | // An unsigned int array load might overflow and cause a deopt, make sure it |
| 2284 | // has an environment. |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 2285 | return can_deoptimize ? AssignEnvironment(result) : result; |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2286 | } |
| 2287 | |
| 2288 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2289 | LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2290 | LOperand* context = UseFixed(instr->context(), esi); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2291 | LOperand* object = UseFixed(instr->object(), edx); |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 2292 | LOperand* key = UseFixed(instr->key(), ecx); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2293 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2294 | LLoadKeyedGeneric* result = |
| 2295 | new(zone()) LLoadKeyedGeneric(context, object, key); |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 2296 | return MarkAsCall(DefineFixed(result, eax), instr); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2297 | } |
| 2298 | |
| 2299 | |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 2300 | LOperand* LChunkBuilder::GetStoreKeyedValueOperand(HStoreKeyed* instr) { |
| 2301 | ElementsKind elements_kind = instr->elements_kind(); |
| 2302 | |
| 2303 | // Determine if we need a byte register in this case for the value. |
| 2304 | bool val_is_fixed_register = |
| 2305 | elements_kind == EXTERNAL_BYTE_ELEMENTS || |
| 2306 | elements_kind == EXTERNAL_UNSIGNED_BYTE_ELEMENTS || |
| 2307 | elements_kind == EXTERNAL_PIXEL_ELEMENTS; |
| 2308 | if (val_is_fixed_register) { |
| 2309 | return UseFixed(instr->value(), eax); |
| 2310 | } |
| 2311 | |
| 2312 | if (!CpuFeatures::IsSafeForSnapshot(SSE2) && |
| 2313 | IsDoubleOrFloatElementsKind(elements_kind)) { |
| 2314 | return UseRegisterAtStart(instr->value()); |
| 2315 | } |
| 2316 | |
| 2317 | return UseRegister(instr->value()); |
| 2318 | } |
| 2319 | |
| 2320 | |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 2321 | LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 2322 | if (!instr->is_external()) { |
| 2323 | ASSERT(instr->elements()->representation().IsTagged()); |
| 2324 | ASSERT(instr->key()->representation().IsInteger32() || |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 2325 | instr->key()->representation().IsSmi()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2326 | |
yangguo@chromium.org | eeb44b6 | 2012-11-13 13:56:09 +0000 | [diff] [blame] | 2327 | if (instr->value()->representation().IsDouble()) { |
| 2328 | LOperand* object = UseRegisterAtStart(instr->elements()); |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 2329 | LOperand* val = NULL; |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 2330 | val = UseRegisterAtStart(instr->value()); |
yangguo@chromium.org | eeb44b6 | 2012-11-13 13:56:09 +0000 | [diff] [blame] | 2331 | LOperand* key = UseRegisterOrConstantAtStart(instr->key()); |
ulan@chromium.org | 8e8d882 | 2012-11-23 14:36:46 +0000 | [diff] [blame] | 2332 | return new(zone()) LStoreKeyed(object, key, val); |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 2333 | } else { |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 2334 | ASSERT(instr->value()->representation().IsSmiOrTagged()); |
yangguo@chromium.org | eeb44b6 | 2012-11-13 13:56:09 +0000 | [diff] [blame] | 2335 | bool needs_write_barrier = instr->NeedsWriteBarrier(); |
| 2336 | |
| 2337 | LOperand* obj = UseRegister(instr->elements()); |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 2338 | LOperand* val; |
| 2339 | LOperand* key; |
| 2340 | if (needs_write_barrier) { |
| 2341 | val = UseTempRegister(instr->value()); |
| 2342 | key = UseTempRegister(instr->key()); |
| 2343 | } else { |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 2344 | val = UseRegisterOrConstantAtStart(instr->value()); |
| 2345 | key = UseRegisterOrConstantAtStart(instr->key()); |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 2346 | } |
ulan@chromium.org | 8e8d882 | 2012-11-23 14:36:46 +0000 | [diff] [blame] | 2347 | return new(zone()) LStoreKeyed(obj, key, val); |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 2348 | } |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 2349 | } |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 2350 | |
ulan@chromium.org | 8e8d882 | 2012-11-23 14:36:46 +0000 | [diff] [blame] | 2351 | ElementsKind elements_kind = instr->elements_kind(); |
| 2352 | ASSERT( |
| 2353 | (instr->value()->representation().IsInteger32() && |
| 2354 | (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && |
| 2355 | (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || |
| 2356 | (instr->value()->representation().IsDouble() && |
| 2357 | ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || |
| 2358 | (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); |
| 2359 | ASSERT(instr->elements()->representation().IsExternal()); |
| 2360 | |
| 2361 | LOperand* external_pointer = UseRegister(instr->elements()); |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 2362 | LOperand* val = GetStoreKeyedValueOperand(instr); |
ulan@chromium.org | 8e8d882 | 2012-11-23 14:36:46 +0000 | [diff] [blame] | 2363 | bool clobbers_key = ExternalArrayOpRequiresTemp( |
| 2364 | instr->key()->representation(), elements_kind); |
| 2365 | LOperand* key = clobbers_key |
| 2366 | ? UseTempRegister(instr->key()) |
| 2367 | : UseRegisterOrConstantAtStart(instr->key()); |
| 2368 | return new(zone()) LStoreKeyed(external_pointer, |
| 2369 | key, |
| 2370 | val); |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2371 | } |
| 2372 | |
| 2373 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2374 | LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2375 | LOperand* context = UseFixed(instr->context(), esi); |
| 2376 | LOperand* object = UseFixed(instr->object(), edx); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2377 | LOperand* key = UseFixed(instr->key(), ecx); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2378 | LOperand* value = UseFixed(instr->value(), eax); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2379 | |
| 2380 | ASSERT(instr->object()->representation().IsTagged()); |
| 2381 | ASSERT(instr->key()->representation().IsTagged()); |
| 2382 | ASSERT(instr->value()->representation().IsTagged()); |
| 2383 | |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2384 | LStoreKeyedGeneric* result = |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2385 | new(zone()) LStoreKeyedGeneric(context, object, key, value); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2386 | return MarkAsCall(result, instr); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2387 | } |
| 2388 | |
| 2389 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 2390 | LInstruction* LChunkBuilder::DoTransitionElementsKind( |
| 2391 | HTransitionElementsKind* instr) { |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 2392 | LOperand* object = UseRegister(instr->object()); |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 2393 | if (IsSimpleMapChangeTransition(instr->from_kind(), instr->to_kind())) { |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 2394 | LOperand* object = UseRegister(instr->object()); |
| 2395 | LOperand* new_map_reg = TempRegister(); |
| 2396 | LOperand* temp_reg = TempRegister(); |
| 2397 | LTransitionElementsKind* result = |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 2398 | new(zone()) LTransitionElementsKind(object, NULL, |
| 2399 | new_map_reg, temp_reg); |
| 2400 | return result; |
danno@chromium.org | d3c4210 | 2013-08-01 16:58:23 +0000 | [diff] [blame] | 2401 | } else { |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 2402 | LOperand* context = UseRegister(instr->context()); |
| 2403 | LTransitionElementsKind* result = |
| 2404 | new(zone()) LTransitionElementsKind(object, context, NULL, NULL); |
| 2405 | return AssignPointerMap(result); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 2406 | } |
| 2407 | } |
| 2408 | |
| 2409 | |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 2410 | LInstruction* LChunkBuilder::DoTrapAllocationMemento( |
| 2411 | HTrapAllocationMemento* instr) { |
| 2412 | LOperand* object = UseRegister(instr->object()); |
| 2413 | LOperand* temp = TempRegister(); |
| 2414 | LTrapAllocationMemento* result = |
| 2415 | new(zone()) LTrapAllocationMemento(object, temp); |
| 2416 | return AssignEnvironment(result); |
| 2417 | } |
| 2418 | |
| 2419 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2420 | LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { |
svenpanne@chromium.org | 53ad175 | 2013-05-27 12:20:38 +0000 | [diff] [blame] | 2421 | bool is_in_object = instr->access().IsInobject(); |
danno@chromium.org | d3c4210 | 2013-08-01 16:58:23 +0000 | [diff] [blame] | 2422 | bool is_external_location = instr->access().IsExternalMemory() && |
| 2423 | instr->access().offset() == 0; |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 2424 | bool needs_write_barrier = instr->NeedsWriteBarrier(); |
danno@chromium.org | 5940060 | 2013-08-13 17:09:37 +0000 | [diff] [blame] | 2425 | bool needs_write_barrier_for_map = instr->has_transition() && |
verwaest@chromium.org | 3714139 | 2012-05-31 13:27:02 +0000 | [diff] [blame] | 2426 | instr->NeedsWriteBarrierForMap(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2427 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2428 | LOperand* obj; |
| 2429 | if (needs_write_barrier) { |
svenpanne@chromium.org | 53ad175 | 2013-05-27 12:20:38 +0000 | [diff] [blame] | 2430 | obj = is_in_object |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2431 | ? UseRegister(instr->object()) |
| 2432 | : UseTempRegister(instr->object()); |
danno@chromium.org | d3c4210 | 2013-08-01 16:58:23 +0000 | [diff] [blame] | 2433 | } else if (is_external_location) { |
| 2434 | ASSERT(!is_in_object); |
| 2435 | ASSERT(!needs_write_barrier); |
| 2436 | ASSERT(!needs_write_barrier_for_map); |
| 2437 | obj = UseRegisterOrConstant(instr->object()); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2438 | } else { |
verwaest@chromium.org | 3714139 | 2012-05-31 13:27:02 +0000 | [diff] [blame] | 2439 | obj = needs_write_barrier_for_map |
| 2440 | ? UseRegister(instr->object()) |
| 2441 | : UseRegisterAtStart(instr->object()); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2442 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2443 | |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 2444 | bool can_be_constant = instr->value()->IsConstant() && |
| 2445 | HConstant::cast(instr->value())->NotInNewSpace() && |
| 2446 | !(FLAG_track_double_fields && instr->field_representation().IsDouble()); |
| 2447 | |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 2448 | LOperand* val; |
machenbach@chromium.org | 935a779 | 2013-11-12 09:05:18 +0000 | [diff] [blame] | 2449 | if (instr->field_representation().IsInteger8() || |
| 2450 | instr->field_representation().IsUInteger8()) { |
jkummerow@chromium.org | 25b0e21 | 2013-10-04 15:38:52 +0000 | [diff] [blame] | 2451 | // mov_b requires a byte register (i.e. any of eax, ebx, ecx, edx). |
| 2452 | // Just force the value to be in eax and we're safe here. |
| 2453 | val = UseFixed(instr->value(), eax); |
| 2454 | } else if (needs_write_barrier) { |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 2455 | val = UseTempRegister(instr->value()); |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 2456 | } else if (can_be_constant) { |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 2457 | val = UseRegisterOrConstant(instr->value()); |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 2458 | } else if (FLAG_track_fields && instr->field_representation().IsSmi()) { |
| 2459 | val = UseTempRegister(instr->value()); |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 2460 | } else if (FLAG_track_double_fields && |
| 2461 | instr->field_representation().IsDouble()) { |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 2462 | val = UseRegisterAtStart(instr->value()); |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 2463 | } else { |
| 2464 | val = UseRegister(instr->value()); |
| 2465 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2466 | |
| 2467 | // We only need a scratch register if we have a write barrier or we |
| 2468 | // have a store into the properties array (not in-object-property). |
svenpanne@chromium.org | 53ad175 | 2013-05-27 12:20:38 +0000 | [diff] [blame] | 2469 | LOperand* temp = (!is_in_object || needs_write_barrier || |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 2470 | needs_write_barrier_for_map) ? TempRegister() : NULL; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2471 | |
verwaest@chromium.org | 3714139 | 2012-05-31 13:27:02 +0000 | [diff] [blame] | 2472 | // We need a temporary register for write barrier of the map field. |
| 2473 | LOperand* temp_map = needs_write_barrier_for_map ? TempRegister() : NULL; |
| 2474 | |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 2475 | LStoreNamedField* result = |
| 2476 | new(zone()) LStoreNamedField(obj, val, temp, temp_map); |
danno@chromium.org | 1fd77d5 | 2013-06-07 16:01:45 +0000 | [diff] [blame] | 2477 | if (FLAG_track_heap_object_fields && |
| 2478 | instr->field_representation().IsHeapObject()) { |
| 2479 | if (!instr->value()->type().IsHeapObject()) { |
| 2480 | return AssignEnvironment(result); |
| 2481 | } |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 2482 | } |
| 2483 | return result; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2484 | } |
| 2485 | |
| 2486 | |
| 2487 | LInstruction* LChunkBuilder::DoStoreNamedGeneric(HStoreNamedGeneric* instr) { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2488 | LOperand* context = UseFixed(instr->context(), esi); |
| 2489 | LOperand* object = UseFixed(instr->object(), edx); |
| 2490 | LOperand* value = UseFixed(instr->value(), eax); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2491 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2492 | LStoreNamedGeneric* result = |
| 2493 | new(zone()) LStoreNamedGeneric(context, object, value); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2494 | return MarkAsCall(result, instr); |
| 2495 | } |
| 2496 | |
| 2497 | |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 2498 | LInstruction* LChunkBuilder::DoStringAdd(HStringAdd* instr) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 2499 | LOperand* context = UseFixed(instr->context(), esi); |
machenbach@chromium.org | 0cc0950 | 2013-11-13 12:20:55 +0000 | [diff] [blame] | 2500 | LOperand* left = FLAG_new_string_add |
| 2501 | ? UseFixed(instr->left(), edx) |
| 2502 | : UseOrConstantAtStart(instr->left()); |
| 2503 | LOperand* right = FLAG_new_string_add |
| 2504 | ? UseFixed(instr->right(), eax) |
| 2505 | : UseOrConstantAtStart(instr->right()); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2506 | LStringAdd* string_add = new(zone()) LStringAdd(context, left, right); |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 2507 | return MarkAsCall(DefineFixed(string_add, eax), instr); |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 2508 | } |
| 2509 | |
| 2510 | |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 2511 | LInstruction* LChunkBuilder::DoStringCharCodeAt(HStringCharCodeAt* instr) { |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 2512 | LOperand* string = UseTempRegister(instr->string()); |
| 2513 | LOperand* index = UseTempRegister(instr->index()); |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 2514 | LOperand* context = UseAny(instr->context()); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2515 | LStringCharCodeAt* result = |
| 2516 | new(zone()) LStringCharCodeAt(context, string, index); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 2517 | return AssignEnvironment(AssignPointerMap(DefineAsRegister(result))); |
| 2518 | } |
| 2519 | |
| 2520 | |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 2521 | LInstruction* LChunkBuilder::DoStringCharFromCode(HStringCharFromCode* instr) { |
| 2522 | LOperand* char_code = UseRegister(instr->value()); |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 2523 | LOperand* context = UseAny(instr->context()); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2524 | LStringCharFromCode* result = |
| 2525 | new(zone()) LStringCharFromCode(context, char_code); |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 2526 | return AssignPointerMap(DefineAsRegister(result)); |
| 2527 | } |
| 2528 | |
| 2529 | |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 2530 | LInstruction* LChunkBuilder::DoAllocate(HAllocate* instr) { |
| 2531 | info()->MarkAsDeferredCalling(); |
| 2532 | LOperand* context = UseAny(instr->context()); |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 2533 | LOperand* size = instr->size()->IsConstant() |
| 2534 | ? UseConstant(instr->size()) |
| 2535 | : UseTempRegister(instr->size()); |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 2536 | LOperand* temp = TempRegister(); |
| 2537 | LAllocate* result = new(zone()) LAllocate(context, size, temp); |
| 2538 | return AssignPointerMap(DefineAsRegister(result)); |
| 2539 | } |
| 2540 | |
| 2541 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2542 | LInstruction* LChunkBuilder::DoRegExpLiteral(HRegExpLiteral* instr) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 2543 | LOperand* context = UseFixed(instr->context(), esi); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2544 | return MarkAsCall( |
| 2545 | DefineFixed(new(zone()) LRegExpLiteral(context), eax), instr); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2546 | } |
| 2547 | |
| 2548 | |
| 2549 | LInstruction* LChunkBuilder::DoFunctionLiteral(HFunctionLiteral* instr) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 2550 | LOperand* context = UseFixed(instr->context(), esi); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2551 | return MarkAsCall( |
| 2552 | DefineFixed(new(zone()) LFunctionLiteral(context), eax), instr); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2553 | } |
| 2554 | |
| 2555 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2556 | LInstruction* LChunkBuilder::DoOsrEntry(HOsrEntry* instr) { |
verwaest@chromium.org | 33e09c8 | 2012-10-10 17:07:22 +0000 | [diff] [blame] | 2557 | ASSERT(argument_count_ == 0); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2558 | allocator_->MarkAsOsrEntry(); |
| 2559 | current_block_->last_environment()->set_ast_id(instr->ast_id()); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2560 | return AssignEnvironment(new(zone()) LOsrEntry); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2561 | } |
| 2562 | |
| 2563 | |
| 2564 | LInstruction* LChunkBuilder::DoParameter(HParameter* instr) { |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 2565 | LParameter* result = new(zone()) LParameter; |
mmassi@chromium.org | 2f0efde | 2013-02-06 14:12:58 +0000 | [diff] [blame] | 2566 | if (instr->kind() == HParameter::STACK_PARAMETER) { |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 2567 | int spill_index = chunk()->GetParameterStackSlot(instr->index()); |
| 2568 | return DefineAsSpilled(result, spill_index); |
| 2569 | } else { |
| 2570 | ASSERT(info()->IsStub()); |
| 2571 | CodeStubInterfaceDescriptor* descriptor = |
| 2572 | info()->code_stub()->GetInterfaceDescriptor(info()->isolate()); |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 2573 | int index = static_cast<int>(instr->index()); |
machenbach@chromium.org | 0cc0950 | 2013-11-13 12:20:55 +0000 | [diff] [blame] | 2574 | Register reg = descriptor->GetParameterRegister(index); |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 2575 | return DefineFixed(result, reg); |
| 2576 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2577 | } |
| 2578 | |
| 2579 | |
| 2580 | LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) { |
hpayer@chromium.org | c5d4971 | 2013-09-11 08:25:48 +0000 | [diff] [blame] | 2581 | // Use an index that corresponds to the location in the unoptimized frame, |
| 2582 | // which the optimized frame will subsume. |
| 2583 | int env_index = instr->index(); |
| 2584 | int spill_index = 0; |
| 2585 | if (instr->environment()->is_parameter_index(env_index)) { |
| 2586 | spill_index = chunk()->GetParameterStackSlot(env_index); |
| 2587 | } else { |
| 2588 | spill_index = env_index - instr->environment()->first_local_index(); |
| 2589 | if (spill_index > LUnallocated::kMaxFixedSlotIndex) { |
| 2590 | Abort(kNotEnoughSpillSlotsForOsr); |
| 2591 | spill_index = 0; |
| 2592 | } |
| 2593 | if (spill_index == 0) { |
| 2594 | // The dynamic frame alignment state overwrites the first local. |
| 2595 | // The first local is saved at the end of the unoptimized frame. |
| 2596 | spill_index = graph()->osr()->UnoptimizedFrameSlots(); |
| 2597 | } |
ager@chromium.org | 04921a8 | 2011-06-27 13:21:41 +0000 | [diff] [blame] | 2598 | } |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2599 | return DefineAsSpilled(new(zone()) LUnknownOSRValue, spill_index); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2600 | } |
| 2601 | |
| 2602 | |
| 2603 | LInstruction* LChunkBuilder::DoCallStub(HCallStub* instr) { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2604 | LOperand* context = UseFixed(instr->context(), esi); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2605 | LCallStub* result = new(zone()) LCallStub(context); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2606 | return MarkAsCall(DefineFixed(result, eax), instr); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2607 | } |
| 2608 | |
| 2609 | |
| 2610 | LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2611 | // There are no real uses of the arguments object. |
| 2612 | // arguments.length and element access are supported directly on |
| 2613 | // stack arguments, and any real arguments object use causes a bailout. |
| 2614 | // So this value is never used. |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2615 | return NULL; |
| 2616 | } |
| 2617 | |
| 2618 | |
danno@chromium.org | 5940060 | 2013-08-13 17:09:37 +0000 | [diff] [blame] | 2619 | LInstruction* LChunkBuilder::DoCapturedObject(HCapturedObject* instr) { |
verwaest@chromium.org | 662436e | 2013-08-28 08:41:27 +0000 | [diff] [blame] | 2620 | instr->ReplayEnvironment(current_block_->last_environment()); |
jkummerow@chromium.org | 1e8da74 | 2013-08-26 17:13:35 +0000 | [diff] [blame] | 2621 | |
danno@chromium.org | 5940060 | 2013-08-13 17:09:37 +0000 | [diff] [blame] | 2622 | // There are no real uses of a captured object. |
| 2623 | return NULL; |
| 2624 | } |
| 2625 | |
| 2626 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2627 | LInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) { |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 2628 | info()->MarkAsRequiresFrame(); |
svenpanne@chromium.org | c859c4f | 2012-10-15 11:51:39 +0000 | [diff] [blame] | 2629 | LOperand* args = UseRegister(instr->arguments()); |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 2630 | LOperand* length; |
| 2631 | LOperand* index; |
| 2632 | if (instr->length()->IsConstant() && instr->index()->IsConstant()) { |
| 2633 | length = UseRegisterOrConstant(instr->length()); |
| 2634 | index = UseOrConstant(instr->index()); |
| 2635 | } else { |
| 2636 | length = UseTempRegister(instr->length()); |
| 2637 | index = Use(instr->index()); |
| 2638 | } |
svenpanne@chromium.org | c859c4f | 2012-10-15 11:51:39 +0000 | [diff] [blame] | 2639 | return DefineAsRegister(new(zone()) LAccessArgumentsAt(args, length, index)); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2640 | } |
| 2641 | |
| 2642 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2643 | LInstruction* LChunkBuilder::DoToFastProperties(HToFastProperties* instr) { |
| 2644 | LOperand* object = UseFixed(instr->value(), eax); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2645 | LToFastProperties* result = new(zone()) LToFastProperties(object); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2646 | return MarkAsCall(DefineFixed(result, eax), instr); |
| 2647 | } |
| 2648 | |
| 2649 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2650 | LInstruction* LChunkBuilder::DoTypeof(HTypeof* instr) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 2651 | LOperand* context = UseFixed(instr->context(), esi); |
| 2652 | LOperand* value = UseAtStart(instr->value()); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2653 | LTypeof* result = new(zone()) LTypeof(context, value); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2654 | return MarkAsCall(DefineFixed(result, eax), instr); |
| 2655 | } |
| 2656 | |
| 2657 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 2658 | LInstruction* LChunkBuilder::DoTypeofIsAndBranch(HTypeofIsAndBranch* instr) { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2659 | return new(zone()) LTypeofIsAndBranch(UseTempRegister(instr->value())); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2660 | } |
| 2661 | |
erik.corry@gmail.com | d91075f | 2011-02-10 07:45:38 +0000 | [diff] [blame] | 2662 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 2663 | LInstruction* LChunkBuilder::DoIsConstructCallAndBranch( |
| 2664 | HIsConstructCallAndBranch* instr) { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2665 | return new(zone()) LIsConstructCallAndBranch(TempRegister()); |
erik.corry@gmail.com | d91075f | 2011-02-10 07:45:38 +0000 | [diff] [blame] | 2666 | } |
| 2667 | |
| 2668 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2669 | LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) { |
verwaest@chromium.org | 662436e | 2013-08-28 08:41:27 +0000 | [diff] [blame] | 2670 | instr->ReplayEnvironment(current_block_->last_environment()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2671 | |
| 2672 | // If there is an instruction pending deoptimization environment create a |
| 2673 | // lazy bailout instruction to capture the environment. |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 2674 | if (!pending_deoptimization_ast_id_.IsNone()) { |
kmillikin@chromium.org | 31b1277 | 2011-02-02 16:08:26 +0000 | [diff] [blame] | 2675 | ASSERT(pending_deoptimization_ast_id_ == instr->ast_id()); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2676 | LLazyBailout* lazy_bailout = new(zone()) LLazyBailout; |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 2677 | LInstruction* result = AssignEnvironment(lazy_bailout); |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 2678 | // Store the lazy deopt environment with the instruction if needed. Right |
| 2679 | // now it is only used for LInstanceOfKnownGlobal. |
kmillikin@chromium.org | 31b1277 | 2011-02-02 16:08:26 +0000 | [diff] [blame] | 2680 | instruction_pending_deoptimization_environment_-> |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 2681 | SetDeferredLazyDeoptimizationEnvironment(result->environment()); |
| 2682 | instruction_pending_deoptimization_environment_ = NULL; |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 2683 | pending_deoptimization_ast_id_ = BailoutId::None(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2684 | return result; |
| 2685 | } |
| 2686 | |
| 2687 | return NULL; |
| 2688 | } |
| 2689 | |
| 2690 | |
| 2691 | LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 2692 | info()->MarkAsDeferredCalling(); |
ager@chromium.org | 04921a8 | 2011-06-27 13:21:41 +0000 | [diff] [blame] | 2693 | if (instr->is_function_entry()) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 2694 | LOperand* context = UseFixed(instr->context(), esi); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2695 | return MarkAsCall(new(zone()) LStackCheck(context), instr); |
ager@chromium.org | 04921a8 | 2011-06-27 13:21:41 +0000 | [diff] [blame] | 2696 | } else { |
| 2697 | ASSERT(instr->is_backwards_branch()); |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 2698 | LOperand* context = UseAny(instr->context()); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2699 | return AssignEnvironment( |
| 2700 | AssignPointerMap(new(zone()) LStackCheck(context))); |
ager@chromium.org | 04921a8 | 2011-06-27 13:21:41 +0000 | [diff] [blame] | 2701 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2702 | } |
| 2703 | |
| 2704 | |
| 2705 | LInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) { |
| 2706 | HEnvironment* outer = current_block_->last_environment(); |
| 2707 | HConstant* undefined = graph()->GetConstantUndefined(); |
| 2708 | HEnvironment* inner = outer->CopyForInlining(instr->closure(), |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 2709 | instr->arguments_count(), |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2710 | instr->function(), |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 2711 | undefined, |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 2712 | instr->inlining_kind(), |
| 2713 | instr->undefined_receiver()); |
dslomov@chromium.org | b752d40 | 2013-06-18 11:54:54 +0000 | [diff] [blame] | 2714 | // Only replay binding of arguments object if it wasn't removed from graph. |
| 2715 | if (instr->arguments_var() != NULL && instr->arguments_object()->IsLinked()) { |
| 2716 | inner->Bind(instr->arguments_var(), instr->arguments_object()); |
danno@chromium.org | 8c0a43f | 2012-04-03 08:37:53 +0000 | [diff] [blame] | 2717 | } |
ulan@chromium.org | 56c14af | 2012-09-20 12:51:09 +0000 | [diff] [blame] | 2718 | inner->set_entry(instr); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2719 | current_block_->UpdateEnvironment(inner); |
| 2720 | chunk_->AddInlinedClosure(instr->closure()); |
| 2721 | return NULL; |
| 2722 | } |
| 2723 | |
| 2724 | |
| 2725 | LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 2726 | LInstruction* pop = NULL; |
| 2727 | |
| 2728 | HEnvironment* env = current_block_->last_environment(); |
| 2729 | |
verwaest@chromium.org | 33e09c8 | 2012-10-10 17:07:22 +0000 | [diff] [blame] | 2730 | if (env->entry()->arguments_pushed()) { |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 2731 | int argument_count = env->arguments_environment()->parameter_count(); |
| 2732 | pop = new(zone()) LDrop(argument_count); |
jkummerow@chromium.org | d8a3a14 | 2013-10-03 12:15:05 +0000 | [diff] [blame] | 2733 | ASSERT(instr->argument_delta() == -argument_count); |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 2734 | } |
| 2735 | |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 2736 | HEnvironment* outer = current_block_->last_environment()-> |
| 2737 | DiscardInlined(false); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2738 | current_block_->UpdateEnvironment(outer); |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 2739 | return pop; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2740 | } |
| 2741 | |
| 2742 | |
kmillikin@chromium.org | be6bd10 | 2012-02-23 08:45:21 +0000 | [diff] [blame] | 2743 | LInstruction* LChunkBuilder::DoForInPrepareMap(HForInPrepareMap* instr) { |
| 2744 | LOperand* context = UseFixed(instr->context(), esi); |
| 2745 | LOperand* object = UseFixed(instr->enumerable(), eax); |
| 2746 | LForInPrepareMap* result = new(zone()) LForInPrepareMap(context, object); |
| 2747 | return MarkAsCall(DefineFixed(result, eax), instr, CAN_DEOPTIMIZE_EAGERLY); |
| 2748 | } |
| 2749 | |
| 2750 | |
| 2751 | LInstruction* LChunkBuilder::DoForInCacheArray(HForInCacheArray* instr) { |
| 2752 | LOperand* map = UseRegister(instr->map()); |
| 2753 | return AssignEnvironment(DefineAsRegister( |
| 2754 | new(zone()) LForInCacheArray(map))); |
| 2755 | } |
| 2756 | |
| 2757 | |
| 2758 | LInstruction* LChunkBuilder::DoCheckMapValue(HCheckMapValue* instr) { |
| 2759 | LOperand* value = UseRegisterAtStart(instr->value()); |
| 2760 | LOperand* map = UseRegisterAtStart(instr->map()); |
| 2761 | return AssignEnvironment(new(zone()) LCheckMapValue(value, map)); |
| 2762 | } |
| 2763 | |
| 2764 | |
| 2765 | LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2766 | LOperand* object = UseRegister(instr->object()); |
| 2767 | LOperand* index = UseTempRegister(instr->index()); |
| 2768 | return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
| 2769 | } |
| 2770 | |
| 2771 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2772 | } } // namespace v8::internal |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 2773 | |
| 2774 | #endif // V8_TARGET_ARCH_IA32 |