13ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch// Copyright 2012 the V8 project authors. All rights reserved. 2b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch// Use of this source code is governed by a BSD-style license that can be 3b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch// found in the LICENSE file. 4b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 5014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch#include "src/crankshaft/x64/lithium-x64.h" 6958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 7014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch#include <sstream> 8b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 9b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch#if V8_TARGET_ARCH_X64 10b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 11014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch#include "src/crankshaft/hydrogen-osr.h" 12014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch#include "src/crankshaft/lithium-inl.h" 13014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch#include "src/crankshaft/x64/lithium-codegen-x64.h" 149fac840a46e8b7e26894f4792ba26dde14c56b04Steve Block 15086aeeaae12517475c22695a200be45495516549Ben Murdochnamespace v8 { 16086aeeaae12517475c22695a200be45495516549Ben Murdochnamespace internal { 179fac840a46e8b7e26894f4792ba26dde14c56b04Steve Block 18b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch#define DEFINE_COMPILE(type) \ 19b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch void L##type::CompileToNative(LCodeGen* generator) { \ 20b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch generator->Do##type(this); \ 21b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } 22b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLITHIUM_CONCRETE_INSTRUCTION_LIST(DEFINE_COMPILE) 23b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch#undef DEFINE_COMPILE 24b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 25b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 261e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block#ifdef DEBUG 271e0659c275bb392c045087af4f6b0d7565cb3d77Steve Blockvoid LInstruction::VerifyCall() { 28257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch // Call instructions can use only fixed registers as temporaries and 29257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch // outputs because all registers are blocked by the calling convention. 30257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch // Inputs operands must use a fixed register or use-at-start policy or 31257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch // a non-register policy. 32b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(Output() == NULL || 331e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block LUnallocated::cast(Output())->HasFixedPolicy() || 341e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block !LUnallocated::cast(Output())->HasRegisterPolicy()); 353fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch for (UseIterator it(this); !it.Done(); it.Advance()) { 363fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch LUnallocated* operand = LUnallocated::cast(it.Current()); 37b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(operand->HasFixedPolicy() || 38257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch operand->IsUsedAtStart()); 391e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } 403fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch for (TempIterator it(this); !it.Done(); it.Advance()) { 413fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch LUnallocated* operand = LUnallocated::cast(it.Current()); 42b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(operand->HasFixedPolicy() ||!operand->HasRegisterPolicy()); 431e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } 441e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block} 451e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block#endif 461e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block 471e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block 48b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdochvoid LInstruction::PrintTo(StringStream* stream) { 49b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch stream->Add("%s ", this->Mnemonic()); 501e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block 511e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block PrintOutputOperandTo(stream); 52b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 53b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch PrintDataTo(stream); 54b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 55b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch if (HasEnvironment()) { 56b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch stream->Add(" "); 57b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch environment()->PrintTo(stream); 58b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } 59b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 60b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch if (HasPointerMap()) { 61b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch stream->Add(" "); 62b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch pointer_map()->PrintTo(stream); 63b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } 64b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 65b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 66b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 67b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochvoid LInstruction::PrintDataTo(StringStream* stream) { 68b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch stream->Add("= "); 69b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch for (int i = 0; i < InputCount(); i++) { 703fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch if (i > 0) stream->Add(" "); 71b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (InputAt(i) == NULL) { 72b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch stream->Add("NULL"); 73b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 74b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch InputAt(i)->PrintTo(stream); 75b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 763fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch } 77b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 78b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 79b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 80b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochvoid LInstruction::PrintOutputOperandTo(StringStream* stream) { 81b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (HasResult()) result()->PrintTo(stream); 82b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 83b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 84b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 85b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdochvoid LLabel::PrintDataTo(StringStream* stream) { 86b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch LGap::PrintDataTo(stream); 87b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch LLabel* rep = replacement(); 88b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch if (rep != NULL) { 89b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch stream->Add(" Dead block replaced with B%d", rep->block_id()); 90b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } 91b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 92b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 93b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 94b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdochbool LGap::IsRedundant() const { 95b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch for (int i = 0; i < 4; i++) { 96b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch if (parallel_moves_[i] != NULL && !parallel_moves_[i]->IsRedundant()) { 97b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return false; 98b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } 99b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } 100b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 101b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return true; 102b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 103b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 104b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 105b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdochvoid LGap::PrintDataTo(StringStream* stream) { 106b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch for (int i = 0; i < 4; i++) { 107b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch stream->Add("("); 108b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch if (parallel_moves_[i] != NULL) { 109b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch parallel_moves_[i]->PrintDataTo(stream); 110b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } 111b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch stream->Add(") "); 112b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } 113b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 114b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 115b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 116b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdochconst char* LArithmeticD::Mnemonic() const { 117b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch switch (op()) { 118b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch case Token::ADD: return "add-d"; 119b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch case Token::SUB: return "sub-d"; 120b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch case Token::MUL: return "mul-d"; 121b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch case Token::DIV: return "div-d"; 122b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch case Token::MOD: return "mod-d"; 123b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch default: 124b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch UNREACHABLE(); 125b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return NULL; 126b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } 127b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 128b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 129b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 130b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdochconst char* LArithmeticT::Mnemonic() const { 131b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch switch (op()) { 132b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch case Token::ADD: return "add-t"; 133b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch case Token::SUB: return "sub-t"; 134b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch case Token::MUL: return "mul-t"; 135b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch case Token::MOD: return "mod-t"; 136b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch case Token::DIV: return "div-t"; 1371e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block case Token::BIT_AND: return "bit-and-t"; 1381e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block case Token::BIT_OR: return "bit-or-t"; 1391e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block case Token::BIT_XOR: return "bit-xor-t"; 140b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch case Token::ROR: return "ror-t"; 1411e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block case Token::SHL: return "sal-t"; 1421e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block case Token::SAR: return "sar-t"; 1431e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block case Token::SHR: return "shr-t"; 144b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch default: 145b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch UNREACHABLE(); 146b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return NULL; 147b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } 148b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 149b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 150b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 151b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochbool LGoto::HasInterestingComment(LCodeGen* gen) const { 152b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return !gen->IsNextEmittedBlock(block_id()); 153b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 154b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 155b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 156b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochtemplate<int R> 157b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochbool LTemplateResultInstruction<R>::MustSignExtendResult( 158b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LPlatformChunk* chunk) const { 159b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch HValue* hvalue = this->hydrogen_value(); 160b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return hvalue != NULL && 161b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch hvalue->representation().IsInteger32() && 162b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch chunk->GetDehoistedKeyIds()->Contains(hvalue->id()); 163b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 164b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 165b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 166b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdochvoid LGoto::PrintDataTo(StringStream* stream) { 167b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch stream->Add("B%d", block_id()); 168b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 169b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 170b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 171b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdochvoid LBranch::PrintDataTo(StringStream* stream) { 172b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch stream->Add("B%d | B%d on ", true_block_id(), false_block_id()); 173b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch value()->PrintTo(stream); 174b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 175b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 176b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 177b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochvoid LCompareNumericAndBranch::PrintDataTo(StringStream* stream) { 178b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch stream->Add("if "); 179b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch left()->PrintTo(stream); 180b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch stream->Add(" %s ", Token::String(op())); 181b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch right()->PrintTo(stream); 182b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch stream->Add(" then B%d else B%d", true_block_id(), false_block_id()); 183b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 184b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 185b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1863ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochvoid LIsStringAndBranch::PrintDataTo(StringStream* stream) { 1873ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch stream->Add("if is_string("); 188b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch value()->PrintTo(stream); 1893ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch stream->Add(") then B%d else B%d", true_block_id(), false_block_id()); 1903ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch} 1913ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 1923ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 193b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdochvoid LIsSmiAndBranch::PrintDataTo(StringStream* stream) { 194b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch stream->Add("if is_smi("); 195b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch value()->PrintTo(stream); 196b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch stream->Add(") then B%d else B%d", true_block_id(), false_block_id()); 197b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 198b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 199b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 200257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdochvoid LIsUndetectableAndBranch::PrintDataTo(StringStream* stream) { 201257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch stream->Add("if is_undetectable("); 202b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch value()->PrintTo(stream); 203257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch stream->Add(") then B%d else B%d", true_block_id(), false_block_id()); 204257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch} 205257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch 206257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch 2073ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochvoid LStringCompareAndBranch::PrintDataTo(StringStream* stream) { 2083ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch stream->Add("if string_compare("); 209b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch left()->PrintTo(stream); 210b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch right()->PrintTo(stream); 2113ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch stream->Add(") then B%d else B%d", true_block_id(), false_block_id()); 2123ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch} 2133ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 2143ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 215b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdochvoid LHasInstanceTypeAndBranch::PrintDataTo(StringStream* stream) { 216b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch stream->Add("if has_instance_type("); 217b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch value()->PrintTo(stream); 218b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch stream->Add(") then B%d else B%d", true_block_id(), false_block_id()); 219b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 220b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 221b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 222b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdochvoid LHasCachedArrayIndexAndBranch::PrintDataTo(StringStream* stream) { 223b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch stream->Add("if has_cached_array_index("); 224b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch value()->PrintTo(stream); 225b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch stream->Add(") then B%d else B%d", true_block_id(), false_block_id()); 226b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 227b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 228b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 229b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdochvoid LClassOfTestAndBranch::PrintDataTo(StringStream* stream) { 230b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch stream->Add("if class_of_test("); 231b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch value()->PrintTo(stream); 232b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch stream->Add(", \"%o\") then B%d else B%d", 233b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch *hydrogen()->class_name(), 234b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch true_block_id(), 235b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch false_block_id()); 236b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 237b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 238b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 239b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdochvoid LTypeofIsAndBranch::PrintDataTo(StringStream* stream) { 240b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch stream->Add("if typeof "); 241b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch value()->PrintTo(stream); 242b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch stream->Add(" == \"%s\" then B%d else B%d", 243b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch hydrogen()->type_literal()->ToCString().get(), 244b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch true_block_id(), false_block_id()); 245b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 246b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 247b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 248b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochvoid LStoreCodeEntry::PrintDataTo(StringStream* stream) { 249b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch stream->Add(" = "); 250b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch function()->PrintTo(stream); 251b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch stream->Add(".code_entry = "); 252b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch code_object()->PrintTo(stream); 253b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 254b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 255b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 256b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochvoid LInnerAllocatedObject::PrintDataTo(StringStream* stream) { 257b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch stream->Add(" = "); 258b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch base_object()->PrintTo(stream); 259b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch stream->Add(" + "); 260b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch offset()->PrintTo(stream); 261b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 262b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 263b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 264b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochvoid LCallWithDescriptor::PrintDataTo(StringStream* stream) { 265b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch for (int i = 0; i < InputCount(); i++) { 266b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch InputAt(i)->PrintTo(stream); 267b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch stream->Add(" "); 268b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 269b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch stream->Add("#%d / ", arity()); 270b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 271b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 272b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 273b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdochvoid LLoadContextSlot::PrintDataTo(StringStream* stream) { 274b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch context()->PrintTo(stream); 2751e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block stream->Add("[%d]", slot_index()); 276b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 277b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 278b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 279e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdochvoid LStoreContextSlot::PrintDataTo(StringStream* stream) { 280b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch context()->PrintTo(stream); 281e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch stream->Add("[%d] <- ", slot_index()); 282b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch value()->PrintTo(stream); 283e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch} 284e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch 285e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch 286257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdochvoid LInvokeFunction::PrintDataTo(StringStream* stream) { 287257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch stream->Add("= "); 288b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch function()->PrintTo(stream); 289257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch stream->Add(" #%d / ", arity()); 290257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch} 291257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch 292257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch 293b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochvoid LCallNewArray::PrintDataTo(StringStream* stream) { 294b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch stream->Add("= "); 295b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch constructor()->PrintTo(stream); 296b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch stream->Add(" #%d / ", arity()); 297b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch ElementsKind kind = hydrogen()->elements_kind(); 298b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch stream->Add(" (%s) ", ElementsKindToString(kind)); 299b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 300b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 301b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 302b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdochvoid LAccessArgumentsAt::PrintDataTo(StringStream* stream) { 303b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch arguments()->PrintTo(stream); 304b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 305b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch stream->Add(" length "); 306b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch length()->PrintTo(stream); 307b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 308b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch stream->Add(" index "); 309b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch index()->PrintTo(stream); 310b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 311b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 312b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 313b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochint LPlatformChunk::GetNextSpillIndex(RegisterKind kind) { 314b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (kind == DOUBLE_REGISTERS && kDoubleSize == 2 * kPointerSize) { 315b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // Skip a slot if for a double-width slot for x32 port. 316342c50ce1624b485728b9a4fc41d8bbf37eb46cfBen Murdoch current_frame_slots_++; 317b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // The spill slot's address is at rbp - (index + 1) * kPointerSize - 318b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // StandardFrameConstants::kFixedFrameSizeFromFp. kFixedFrameSizeFromFp is 319b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // 2 * kPointerSize, if rbp is aligned at 8-byte boundary, the below "|= 1" 320b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // will make sure the spilled doubles are aligned at 8-byte boundary. 321b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // TODO(haitao): make sure rbp is aligned at 8-byte boundary for x32 port. 322342c50ce1624b485728b9a4fc41d8bbf37eb46cfBen Murdoch current_frame_slots_ |= 1; 323b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 324342c50ce1624b485728b9a4fc41d8bbf37eb46cfBen Murdoch return current_frame_slots_++; 325b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 326b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 327b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 328b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLOperand* LPlatformChunk::GetNextSpillSlot(RegisterKind kind) { 329b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch // All stack slots are Double stack slots on x64. 330b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch // Alternatively, at some point, start using half-size 331b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch // stack slots for int32 values. 332b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch int index = GetNextSpillIndex(kind); 333b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (kind == DOUBLE_REGISTERS) { 334b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return LDoubleStackSlot::Create(index, zone()); 335b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } else { 336b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(kind == GENERAL_REGISTERS); 337b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return LStackSlot::Create(index, zone()); 338b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } 339b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 340b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 341b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 342e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdochvoid LStoreNamedField::PrintDataTo(StringStream* stream) { 343e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch object()->PrintTo(stream); 344958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier std::ostringstream os; 345b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch os << hydrogen()->access() << " <- "; 346958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier stream->Add(os.str().c_str()); 347e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch value()->PrintTo(stream); 348e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch} 349e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch 350e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch 351e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdochvoid LStoreNamedGeneric::PrintDataTo(StringStream* stream) { 352b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch object()->PrintTo(stream); 353b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch stream->Add("."); 354b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch stream->Add(String::cast(*name())->ToCString().get()); 355b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch stream->Add(" <- "); 356b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch value()->PrintTo(stream); 357b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 358b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 359b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 360b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochvoid LLoadKeyed::PrintDataTo(StringStream* stream) { 361b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch elements()->PrintTo(stream); 362e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch stream->Add("["); 363e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch key()->PrintTo(stream); 364b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (hydrogen()->IsDehoisted()) { 365b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch stream->Add(" + %d]", base_offset()); 366b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 367b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch stream->Add("]"); 368b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 369e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch} 370e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch 371e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch 372b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochvoid LStoreKeyed::PrintDataTo(StringStream* stream) { 3733fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch elements()->PrintTo(stream); 3743fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch stream->Add("["); 3753fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch key()->PrintTo(stream); 376b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (hydrogen()->IsDehoisted()) { 377b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch stream->Add(" + %d] <-", base_offset()); 378b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 379b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch stream->Add("] <- "); 380b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 381b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 382b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (value() == NULL) { 383b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(hydrogen()->IsConstantHoleStore() && 384b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch hydrogen()->value()->representation().IsDouble()); 385b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch stream->Add("<the hole(nan)>"); 386b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 387b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch value()->PrintTo(stream); 388b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 3893fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch} 3903fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch 3913fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch 392e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdochvoid LStoreKeyedGeneric::PrintDataTo(StringStream* stream) { 393b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch object()->PrintTo(stream); 394b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch stream->Add("["); 395b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch key()->PrintTo(stream); 396b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch stream->Add("] <- "); 397b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch value()->PrintTo(stream); 398b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 399b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 400b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 4013ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochvoid LTransitionElementsKind::PrintDataTo(StringStream* stream) { 4023ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch object()->PrintTo(stream); 4033ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch stream->Add(" %p -> %p", *original_map(), *transitioned_map()); 4043ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch} 4053ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 4063ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 407b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLPlatformChunk* LChunkBuilder::Build() { 408b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(is_unused()); 409b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch chunk_ = new(zone()) LPlatformChunk(info(), graph()); 410b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LPhase phase("L_Building chunk", chunk_); 411b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch status_ = BUILDING; 412b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 413b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // If compiling for OSR, reserve space for the unoptimized frame, 414b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // which will be subsumed into this frame. 415b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (graph()->has_osr()) { 416b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch for (int i = graph()->osr()->UnoptimizedFrameSlots(); i > 0; i--) { 417b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch chunk_->GetNextSpillIndex(GENERAL_REGISTERS); 418b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 419b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 420b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 421086aeeaae12517475c22695a200be45495516549Ben Murdoch const ZoneList<HBasicBlock*>* blocks = graph()->blocks(); 422086aeeaae12517475c22695a200be45495516549Ben Murdoch for (int i = 0; i < blocks->length(); i++) { 423086aeeaae12517475c22695a200be45495516549Ben Murdoch HBasicBlock* next = NULL; 424086aeeaae12517475c22695a200be45495516549Ben Murdoch if (i < blocks->length() - 1) next = blocks->at(i + 1); 425086aeeaae12517475c22695a200be45495516549Ben Murdoch DoBasicBlock(blocks->at(i), next); 426086aeeaae12517475c22695a200be45495516549Ben Murdoch if (is_aborted()) return NULL; 427086aeeaae12517475c22695a200be45495516549Ben Murdoch } 428086aeeaae12517475c22695a200be45495516549Ben Murdoch status_ = DONE; 429086aeeaae12517475c22695a200be45495516549Ben Murdoch return chunk_; 4309fac840a46e8b7e26894f4792ba26dde14c56b04Steve Block} 4319fac840a46e8b7e26894f4792ba26dde14c56b04Steve Block 4329fac840a46e8b7e26894f4792ba26dde14c56b04Steve Block 433b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLUnallocated* LChunkBuilder::ToUnallocated(Register reg) { 434014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return new (zone()) LUnallocated(LUnallocated::FIXED_REGISTER, reg.code()); 435b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 436b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 437b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 438b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLUnallocated* LChunkBuilder::ToUnallocated(XMMRegister reg) { 439014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return new (zone()) 440014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LUnallocated(LUnallocated::FIXED_DOUBLE_REGISTER, reg.code()); 441b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 442b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 443b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 444b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLOperand* LChunkBuilder::UseFixed(HValue* value, Register fixed_register) { 445b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return Use(value, ToUnallocated(fixed_register)); 446b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 447b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 448b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 449b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLOperand* LChunkBuilder::UseFixedDouble(HValue* value, XMMRegister reg) { 450b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return Use(value, ToUnallocated(reg)); 451b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 452b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 453b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 454b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLOperand* LChunkBuilder::UseRegister(HValue* value) { 4553ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return Use(value, new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER)); 456b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 457b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 458b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 459b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLOperand* LChunkBuilder::UseRegisterAtStart(HValue* value) { 460b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return Use(value, 4613ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER, 462b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch LUnallocated::USED_AT_START)); 463b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 464b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 465b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 466b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLOperand* LChunkBuilder::UseTempRegister(HValue* value) { 4673ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return Use(value, new(zone()) LUnallocated(LUnallocated::WRITABLE_REGISTER)); 468b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 469b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 470b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 471b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLOperand* LChunkBuilder::UseTempRegisterOrConstant(HValue* value) { 472b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return value->IsConstant() 473b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch ? chunk_->DefineConstantOperand(HConstant::cast(value)) 474b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch : UseTempRegister(value); 475b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 476b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 477b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 478b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLOperand* LChunkBuilder::Use(HValue* value) { 4793ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return Use(value, new(zone()) LUnallocated(LUnallocated::NONE)); 480b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 481b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 482b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 483b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLOperand* LChunkBuilder::UseAtStart(HValue* value) { 4843ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return Use(value, new(zone()) LUnallocated(LUnallocated::NONE, 485b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch LUnallocated::USED_AT_START)); 486b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 487b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 488b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 489b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLOperand* LChunkBuilder::UseOrConstant(HValue* value) { 490b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return value->IsConstant() 491b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch ? chunk_->DefineConstantOperand(HConstant::cast(value)) 492b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch : Use(value); 493b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 494b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 495b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 496b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLOperand* LChunkBuilder::UseOrConstantAtStart(HValue* value) { 497b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return value->IsConstant() 498b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch ? chunk_->DefineConstantOperand(HConstant::cast(value)) 499b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch : UseAtStart(value); 500b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 501b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 502b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 503b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLOperand* LChunkBuilder::UseRegisterOrConstant(HValue* value) { 504b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return value->IsConstant() 505b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch ? chunk_->DefineConstantOperand(HConstant::cast(value)) 506b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch : UseRegister(value); 507b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 508b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 509b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 510b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLOperand* LChunkBuilder::UseRegisterOrConstantAtStart(HValue* value) { 511b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return value->IsConstant() 512b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch ? chunk_->DefineConstantOperand(HConstant::cast(value)) 513b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch : UseRegisterAtStart(value); 514b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 515b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 516b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 517b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLOperand* LChunkBuilder::UseConstant(HValue* value) { 518b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return chunk_->DefineConstantOperand(HConstant::cast(value)); 519b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 520b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 521b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 522b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLOperand* LChunkBuilder::UseAny(HValue* value) { 523b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return value->IsConstant() 524b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch ? chunk_->DefineConstantOperand(HConstant::cast(value)) 5253ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch : Use(value, new(zone()) LUnallocated(LUnallocated::ANY)); 526b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 527b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 528b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 529b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLOperand* LChunkBuilder::Use(HValue* value, LUnallocated* operand) { 530b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch if (value->EmitAtUses()) { 531b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch HInstruction* instr = HInstruction::cast(value); 532b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch VisitInstruction(instr); 533b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } 5343ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch operand->set_virtual_register(value->id()); 535b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return operand; 536b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 537b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 538b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 539b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::Define(LTemplateResultInstruction<1>* instr, 540b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch LUnallocated* result) { 5413ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch result->set_virtual_register(current_instruction_->id()); 542b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch instr->set_result(result); 543b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return instr; 544b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 545b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 546b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 547b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DefineAsRegister( 548b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LTemplateResultInstruction<1>* instr) { 5493ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return Define(instr, 5503ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER)); 551b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 552b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 553b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 554b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DefineAsSpilled( 555b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LTemplateResultInstruction<1>* instr, 556b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch int index) { 5573ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return Define(instr, 5583ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch new(zone()) LUnallocated(LUnallocated::FIXED_SLOT, index)); 559b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 560b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 561b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 562b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DefineSameAsFirst( 563b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LTemplateResultInstruction<1>* instr) { 5643ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return Define(instr, 5653ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch new(zone()) LUnallocated(LUnallocated::SAME_AS_FIRST_INPUT)); 566b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 567b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 568b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 569b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DefineFixed(LTemplateResultInstruction<1>* instr, 570b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch Register reg) { 571b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return Define(instr, ToUnallocated(reg)); 572b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 573b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 574b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 575b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DefineFixedDouble( 576b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LTemplateResultInstruction<1>* instr, 577b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch XMMRegister reg) { 578b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return Define(instr, ToUnallocated(reg)); 579b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 580b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 581b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 582b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { 583b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch HEnvironment* hydrogen_env = current_block_->last_environment(); 5841b268ca467c924004286c97bac133db489cf43d0Ben Murdoch return LChunkBuilderBase::AssignEnvironment(instr, hydrogen_env); 585b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 586b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 587b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 588b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, 589b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch HInstruction* hinstr, 590b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch CanDeoptimize can_deoptimize) { 591b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch info()->MarkAsNonDeferredCalling(); 592b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 5931e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block#ifdef DEBUG 5941e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block instr->VerifyCall(); 5951e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block#endif 5961e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block instr->MarkAsCall(); 597b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch instr = AssignPointerMap(instr); 598b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 599b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch // If instruction does not have side-effects lazy deoptimization 600b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch // after the call will try to deoptimize to the point before the call. 601b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch // Thus we still need to attach environment to this call even if 602b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch // call sequence can not deoptimize eagerly. 603b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch bool needs_environment = 6043ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch (can_deoptimize == CAN_DEOPTIMIZE_EAGERLY) || 6053ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch !hinstr->HasObservableSideEffects(); 606b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch if (needs_environment && !instr->HasEnvironment()) { 607b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch instr = AssignEnvironment(instr); 608b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // We can't really figure out if the environment is needed or not. 609b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->environment()->set_has_been_used(); 610b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } 611b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 612b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return instr; 613b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 614b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 615b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 616b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::AssignPointerMap(LInstruction* instr) { 617b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(!instr->HasPointerMap()); 618b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->set_pointer_map(new(zone()) LPointerMap(zone())); 619b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return instr; 620b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 621b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 622b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 623b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLUnallocated* LChunkBuilder::TempRegister() { 6243ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LUnallocated* operand = 6253ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER); 626b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch int vreg = allocator_->GetVirtualRegister(); 627b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (!allocator_->AllocationOk()) { 628b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch Abort(kOutOfVirtualRegistersWhileTryingToAllocateTempRegister); 629b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch vreg = 0; 630b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 631b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch operand->set_virtual_register(vreg); 632b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return operand; 633b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 634b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 635b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 636b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLOperand* LChunkBuilder::FixedTemp(Register reg) { 637b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch LUnallocated* operand = ToUnallocated(reg); 638b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(operand->HasFixedPolicy()); 639b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return operand; 640b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 641b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 642b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 643b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLOperand* LChunkBuilder::FixedTemp(XMMRegister reg) { 644b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch LUnallocated* operand = ToUnallocated(reg); 645b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(operand->HasFixedPolicy()); 646b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return operand; 647b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 648b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 649b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 650b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoBlockEntry(HBlockEntry* instr) { 6513ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return new(zone()) LLabel(instr->block()); 652b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 653b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 654b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 655b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoDummyUse(HDummyUse* instr) { 656b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineAsRegister(new(zone()) LDummyUse(UseAny(instr->value()))); 657b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 658b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 659b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 660b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoEnvironmentMarker(HEnvironmentMarker* instr) { 661b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch UNREACHABLE(); 662b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return NULL; 6633fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch} 6643fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch 6653fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch 666b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoDeoptimize(HDeoptimize* instr) { 6673ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return AssignEnvironment(new(zone()) LDeoptimize); 668b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 669b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 670b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 6711e0659c275bb392c045087af4f6b0d7565cb3d77Steve BlockLInstruction* LChunkBuilder::DoShift(Token::Value op, 6721e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block HBitwiseBinaryOperation* instr) { 673b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->representation().IsSmiOrInteger32()) { 674b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().Equals(instr->representation())); 675b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->right()->representation().Equals(instr->representation())); 676b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* left = UseRegisterAtStart(instr->left()); 6771e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block 678b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch HValue* right_value = instr->right(); 679b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* right = NULL; 680b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch int constant_value = 0; 681b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch bool does_deopt = false; 682b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (right_value->IsConstant()) { 683b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch HConstant* constant = HConstant::cast(right_value); 684b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch right = chunk_->DefineConstantOperand(constant); 685b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch constant_value = constant->Integer32Value() & 0x1f; 686b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (SmiValuesAre31Bits() && instr->representation().IsSmi() && 687b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch constant_value > 0) { 688b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // Left shift can deoptimize if we shift by > 0 and the result 689b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // cannot be truncated to smi. 690b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch does_deopt = !instr->CheckUsesForFlag(HValue::kTruncatingToSmi); 691b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 692b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 693b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch right = UseFixed(right_value, rcx); 694b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 6951e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block 696b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // Shift operations can only deoptimize if we do a logical shift by 0 and 697b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // the result cannot be truncated to int32. 698b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (op == Token::SHR && constant_value == 0) { 699958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier does_deopt = !instr->CheckFlag(HInstruction::kUint32); 7001e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } 7011e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block 702b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = 703b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DefineSameAsFirst(new(zone()) LShiftI(op, left, right, does_deopt)); 704b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return does_deopt ? AssignEnvironment(result) : result; 705b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 706b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoArithmeticT(op, instr); 707b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 708b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 709b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 710b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 711b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoArithmeticD(Token::Value op, 712b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch HArithmeticBinaryOperation* instr) { 713b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->representation().IsDouble()); 714b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().IsDouble()); 715b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->right()->representation().IsDouble()); 716b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (op == Token::MOD) { 71721efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch LOperand* left = UseFixedDouble(instr->BetterLeftOperand(), xmm0); 718b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* right = UseFixedDouble(instr->BetterRightOperand(), xmm1); 719b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LArithmeticD* result = new(zone()) LArithmeticD(op, left, right); 72021efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch return MarkAsCall(DefineFixedDouble(result, xmm0), instr); 721b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 722b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); 723b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* right = UseRegisterAtStart(instr->BetterRightOperand()); 724b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LArithmeticD* result = new(zone()) LArithmeticD(op, left, right); 725014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return CpuFeatures::IsSupported(AVX) ? DefineAsRegister(result) 726014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch : DefineSameAsFirst(result); 727b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 728b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 729b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 730b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 731b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoArithmeticT(Token::Value op, 732b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch HBinaryOperation* instr) { 733b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch HValue* left = instr->left(); 734b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch HValue* right = instr->right(); 735b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(left->representation().IsTagged()); 736b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(right->representation().IsTagged()); 737b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseFixed(instr->context(), rsi); 738b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch LOperand* left_operand = UseFixed(left, rdx); 739b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch LOperand* right_operand = UseFixed(right, rax); 7403ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LArithmeticT* result = 741b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch new(zone()) LArithmeticT(op, context, left_operand, right_operand); 742b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return MarkAsCall(DefineFixed(result, rax), instr); 743b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 744b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 745b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 746b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdochvoid LChunkBuilder::DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block) { 747b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(is_building()); 748b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch current_block_ = block; 749b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch next_block_ = next_block; 750b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch if (block->IsStartBlock()) { 751b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch block->UpdateEnvironment(graph_->start_environment()); 752b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch argument_count_ = 0; 753b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } else if (block->predecessors()->length() == 1) { 754b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch // We have a single predecessor => copy environment and outgoing 755b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch // argument count from the predecessor. 756b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(block->phis()->length() == 0); 757b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch HBasicBlock* pred = block->predecessors()->at(0); 758b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch HEnvironment* last_environment = pred->last_environment(); 759b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(last_environment != NULL); 760b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch // Only copy the environment, if it is later used again. 761b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch if (pred->end()->SecondSuccessor() == NULL) { 762b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(pred->end()->FirstSuccessor() == block); 763b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } else { 764b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch if (pred->end()->FirstSuccessor()->block_id() > block->block_id() || 765b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch pred->end()->SecondSuccessor()->block_id() > block->block_id()) { 766b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch last_environment = last_environment->Copy(); 767b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } 768b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } 769b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch block->UpdateEnvironment(last_environment); 770b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(pred->argument_count() >= 0); 771b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch argument_count_ = pred->argument_count(); 772b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } else { 773b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch // We are at a state join => process phis. 774b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch HBasicBlock* pred = block->predecessors()->at(0); 775b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch // No need to copy the environment, it cannot be used later. 776b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch HEnvironment* last_environment = pred->last_environment(); 777b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch for (int i = 0; i < block->phis()->length(); ++i) { 778b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch HPhi* phi = block->phis()->at(i); 779b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (phi->HasMergedIndex()) { 780b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch last_environment->SetValueAt(phi->merged_index(), phi); 781b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 782b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } 783b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch for (int i = 0; i < block->deleted_phis()->length(); ++i) { 784b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (block->deleted_phis()->at(i) < last_environment->length()) { 785b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch last_environment->SetValueAt(block->deleted_phis()->at(i), 786b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch graph_->GetConstantUndefined()); 787b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 788b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } 789b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch block->UpdateEnvironment(last_environment); 790b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch // Pick up the outgoing argument count of one of the predecessors. 791b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch argument_count_ = pred->argument_count(); 792b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } 793b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch HInstruction* current = block->first(); 794b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch int start = chunk_->instructions()->length(); 795b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch while (current != NULL && !is_aborted()) { 796b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch // Code for constants in registers is generated lazily. 797b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch if (!current->EmitAtUses()) { 798b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch VisitInstruction(current); 799b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } 800b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch current = current->next(); 801b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } 802b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch int end = chunk_->instructions()->length() - 1; 803b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch if (end >= start) { 804b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch block->set_first_instruction_index(start); 805b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch block->set_last_instruction_index(end); 806b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } 807b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch block->set_argument_count(argument_count_); 808b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch next_block_ = NULL; 809b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch current_block_ = NULL; 810b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 811b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 812b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 813b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdochvoid LChunkBuilder::VisitInstruction(HInstruction* current) { 814b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch HInstruction* old_current = current_instruction_; 815b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch current_instruction_ = current; 816b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 817b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* instr = NULL; 818b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (current->CanReplaceWithDummyUses()) { 819b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (current->OperandCount() == 0) { 820b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr = DefineAsRegister(new(zone()) LDummy()); 821b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 822b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(!current->OperandAt(0)->IsControlInstruction()); 823b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr = DefineAsRegister(new(zone()) 824b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LDummyUse(UseAny(current->OperandAt(0)))); 825b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } 826b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch for (int i = 1; i < current->OperandCount(); ++i) { 827b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (current->OperandAt(i)->IsControlInstruction()) continue; 828b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* dummy = 829b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch new(zone()) LDummyUse(UseAny(current->OperandAt(i))); 830b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch dummy->set_hydrogen_value(current); 831b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch chunk_->AddInstruction(dummy, current_block_); 832b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } 833b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 834b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch HBasicBlock* successor; 835b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (current->IsControlInstruction() && 836b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch HControlInstruction::cast(current)->KnownSuccessorBlock(&successor) && 837b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch successor != NULL) { 838b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr = new(zone()) LGoto(successor); 839b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 840b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr = current->CompileToLithium(this); 841b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 842b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 843b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 844b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch argument_count_ += current->argument_delta(); 845b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(argument_count_ >= 0); 846b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 847b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr != NULL) { 848b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch AddInstruction(instr, current); 849b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } 850b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 851b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch current_instruction_ = old_current; 852b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 853b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 854b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 855b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochvoid LChunkBuilder::AddInstruction(LInstruction* instr, 856b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch HInstruction* hydrogen_val) { 857b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // Associate the hydrogen instruction first, since we may need it for 858b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // the ClobbersRegisters() or ClobbersDoubleRegisters() calls below. 859b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->set_hydrogen_value(hydrogen_val); 860b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 861b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch#if DEBUG 862b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // Make sure that the lithium instruction has either no fixed register 863b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // constraints in temps or the result OR no uses that are only used at 864b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // start. If this invariant doesn't hold, the register allocator can decide 865b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // to insert a split of a range immediately before the instruction due to an 866b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // already allocated register needing to be used for the instruction's fixed 867b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // register constraint. In this case, The register allocator won't see an 868b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // interference between the split child and the use-at-start (it would if 869b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // the it was just a plain use), so it is free to move the split child into 870b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // the same register that is used for the use-at-start. 871b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // See https://code.google.com/p/chromium/issues/detail?id=201590 872b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (!(instr->ClobbersRegisters() && 873b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->ClobbersDoubleRegisters(isolate()))) { 874b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch int fixed = 0; 875b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch int used_at_start = 0; 876b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch for (UseIterator it(instr); !it.Done(); it.Advance()) { 877b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LUnallocated* operand = LUnallocated::cast(it.Current()); 878b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (operand->IsUsedAtStart()) ++used_at_start; 879b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 880b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->Output() != NULL) { 881b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (LUnallocated::cast(instr->Output())->HasFixedPolicy()) ++fixed; 882b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } 883b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch for (TempIterator it(instr); !it.Done(); it.Advance()) { 884b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LUnallocated* operand = LUnallocated::cast(it.Current()); 885b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (operand->HasFixedPolicy()) ++fixed; 886b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 887b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(fixed == 0 || used_at_start == 0); 888b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } 889b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch#endif 890b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 891b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) { 892b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr = AssignPointerMap(instr); 893b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 894b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (FLAG_stress_environments && !instr->HasEnvironment()) { 895b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr = AssignEnvironment(instr); 896b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 897b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch chunk_->AddInstruction(instr, current_block_); 898b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 8991b268ca467c924004286c97bac133db489cf43d0Ben Murdoch CreateLazyBailoutForCall(current_block_, instr, hydrogen_val); 900b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 901b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 902b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 903b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoGoto(HGoto* instr) { 904b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return new(zone()) LGoto(instr->FirstSuccessor()); 905b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 906b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 907b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 908014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochLInstruction* LChunkBuilder::DoPrologue(HPrologue* instr) { 9091b268ca467c924004286c97bac133db489cf43d0Ben Murdoch LInstruction* result = new (zone()) LPrologue(); 910537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch if (info_->scope()->num_heap_slots() > 0) { 9111b268ca467c924004286c97bac133db489cf43d0Ben Murdoch result = MarkAsCall(result, instr); 9121b268ca467c924004286c97bac133db489cf43d0Ben Murdoch } 9131b268ca467c924004286c97bac133db489cf43d0Ben Murdoch return result; 914014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 915014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 916014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 917b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoDebugBreak(HDebugBreak* instr) { 918b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return new(zone()) LDebugBreak(); 919b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 920b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 921b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 9223fb3ca8c7ca439d408449a395897395c0faae8d1Ben MurdochLInstruction* LChunkBuilder::DoBranch(HBranch* instr) { 9233ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch HValue* value = instr->value(); 924b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch Representation r = value->representation(); 9253ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch HType type = value->type(); 9261b268ca467c924004286c97bac133db489cf43d0Ben Murdoch ToBooleanICStub::Types expected = instr->expected_input_types(); 9271b268ca467c924004286c97bac133db489cf43d0Ben Murdoch if (expected.IsEmpty()) expected = ToBooleanICStub::Types::Generic(); 928b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 929b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch bool easy_case = !r.IsTagged() || type.IsBoolean() || type.IsSmi() || 930b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch type.IsJSArray() || type.IsHeapNumber() || type.IsString(); 931b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* branch = new(zone()) LBranch(UseRegister(value)); 932b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (!easy_case && 9331b268ca467c924004286c97bac133db489cf43d0Ben Murdoch ((!expected.Contains(ToBooleanICStub::SMI) && expected.NeedsMap()) || 934b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch !expected.IsGeneric())) { 935b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch branch = AssignEnvironment(branch); 9363ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch } 937b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return branch; 938b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 939b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 940b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 9411e0659c275bb392c045087af4f6b0d7565cb3d77Steve BlockLInstruction* LChunkBuilder::DoCompareMap(HCompareMap* instr) { 942b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->value()->representation().IsTagged()); 9431e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block LOperand* value = UseRegisterAtStart(instr->value()); 9443ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return new(zone()) LCmpMapAndBranch(value); 945b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 946b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 947b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 948b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoArgumentsLength(HArgumentsLength* length) { 949b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch info()->MarkAsRequiresFrame(); 9503ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return DefineAsRegister(new(zone()) LArgumentsLength(Use(length->value()))); 951b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 952b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 953b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 954b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoArgumentsElements(HArgumentsElements* elems) { 955b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch info()->MarkAsRequiresFrame(); 9563ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return DefineAsRegister(new(zone()) LArgumentsElements); 957b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 958b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 959b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 960014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochLInstruction* LChunkBuilder::DoHasInPrototypeChainAndBranch( 961014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch HHasInPrototypeChainAndBranch* instr) { 962014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LOperand* object = UseRegister(instr->object()); 963014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LOperand* prototype = UseRegister(instr->prototype()); 964014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LHasInPrototypeChainAndBranch* result = 965014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch new (zone()) LHasInPrototypeChainAndBranch(object, prototype); 966014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return AssignEnvironment(result); 967b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 968b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 969b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 9703ef787dbeca8a5fb1086949cda830dccee07bfbdBen MurdochLInstruction* LChunkBuilder::DoWrapReceiver(HWrapReceiver* instr) { 9713ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* receiver = UseRegister(instr->receiver()); 9723ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* function = UseRegisterAtStart(instr->function()); 9733ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LWrapReceiver* result = new(zone()) LWrapReceiver(receiver, function); 9743ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return AssignEnvironment(DefineSameAsFirst(result)); 9753ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch} 9763ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 9773ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 978b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoApplyArguments(HApplyArguments* instr) { 979e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch LOperand* function = UseFixed(instr->function(), rdi); 980e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch LOperand* receiver = UseFixed(instr->receiver(), rax); 981e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch LOperand* length = UseFixed(instr->length(), rbx); 982e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch LOperand* elements = UseFixed(instr->elements(), rcx); 9833ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LApplyArguments* result = new(zone()) LApplyArguments(function, 984e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch receiver, 985e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch length, 986e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch elements); 987e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch return MarkAsCall(DefineFixed(result, rax), instr, CAN_DEOPTIMIZE_EAGERLY); 988b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 989b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 990b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 991b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoPushArguments(HPushArguments* instr) { 992b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch int argc = instr->OperandCount(); 993b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch for (int i = 0; i < argc; ++i) { 994b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* argument = UseOrConstant(instr->argument(i)); 995b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch AddInstruction(new(zone()) LPushArgument(argument), instr); 996b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 997b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return NULL; 998b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 999b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1000b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1001b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoStoreCodeEntry( 1002b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch HStoreCodeEntry* store_code_entry) { 1003b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* function = UseRegister(store_code_entry->function()); 1004b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* code_object = UseTempRegister(store_code_entry->code_object()); 1005b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return new(zone()) LStoreCodeEntry(function, code_object); 1006b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 1007b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1008b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1009b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoInnerAllocatedObject( 1010b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch HInnerAllocatedObject* instr) { 1011b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* base_object = UseRegisterAtStart(instr->base_object()); 1012b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* offset = UseRegisterOrConstantAtStart(instr->offset()); 1013b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineAsRegister( 1014b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch new(zone()) LInnerAllocatedObject(base_object, offset)); 10151e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block} 10161e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block 10171e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block 10183fb3ca8c7ca439d408449a395897395c0faae8d1Ben MurdochLInstruction* LChunkBuilder::DoThisFunction(HThisFunction* instr) { 10193ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return instr->HasNoUses() 10203ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch ? NULL 10213ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch : DefineAsRegister(new(zone()) LThisFunction); 10223fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch} 10233fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch 10243fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch 10251e0659c275bb392c045087af4f6b0d7565cb3d77Steve BlockLInstruction* LChunkBuilder::DoContext(HContext* instr) { 1026b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->HasNoUses()) return NULL; 10271e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block 1028b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (info()->IsStub()) { 1029b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineFixed(new(zone()) LContext, rsi); 1030b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 10311e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block 1032b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineAsRegister(new(zone()) LContext); 10333ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch} 10343ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 10353ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 10363ef787dbeca8a5fb1086949cda830dccee07bfbdBen MurdochLInstruction* LChunkBuilder::DoDeclareGlobals(HDeclareGlobals* instr) { 1037b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseFixed(instr->context(), rsi); 1038b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return MarkAsCall(new(zone()) LDeclareGlobals(context), instr); 1039b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1040b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1041b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1042b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoCallWithDescriptor( 1043b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch HCallWithDescriptor* instr) { 1044b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch CallInterfaceDescriptor descriptor = instr->descriptor(); 1045b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1046b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* target = UseRegisterOrConstantAtStart(instr->target()); 1047b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch ZoneList<LOperand*> ops(instr->OperandCount(), zone()); 1048014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // Target 1049b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch ops.Add(target, zone()); 1050014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // Context 1051014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LOperand* op = UseFixed(instr->OperandAt(1), rsi); 1052014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch ops.Add(op, zone()); 1053014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // Other register parameters 1054014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch for (int i = LCallWithDescriptor::kImplicitRegisterParameterCount; 1055014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch i < instr->OperandCount(); i++) { 1056014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch op = 1057014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch UseFixed(instr->OperandAt(i), 1058014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch descriptor.GetRegisterParameter( 1059014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch i - LCallWithDescriptor::kImplicitRegisterParameterCount)); 1060b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch ops.Add(op, zone()); 1061b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1062b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1063b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LCallWithDescriptor* result = new(zone()) LCallWithDescriptor( 1064b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch descriptor, ops, zone()); 10651b268ca467c924004286c97bac133db489cf43d0Ben Murdoch if (instr->syntactic_tail_call_mode() == TailCallMode::kAllow) { 10661b268ca467c924004286c97bac133db489cf43d0Ben Murdoch result->MarkAsSyntacticTailCall(); 10671b268ca467c924004286c97bac133db489cf43d0Ben Murdoch } 1068b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return MarkAsCall(DefineFixed(result, rax), instr); 1069b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1070b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1071b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1072257744e915dfc84d6d07a6b2accf8402d9ffc708Ben MurdochLInstruction* LChunkBuilder::DoInvokeFunction(HInvokeFunction* instr) { 1073b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseFixed(instr->context(), rsi); 1074257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch LOperand* function = UseFixed(instr->function(), rdi); 1075b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInvokeFunction* result = new(zone()) LInvokeFunction(context, function); 10761b268ca467c924004286c97bac133db489cf43d0Ben Murdoch if (instr->syntactic_tail_call_mode() == TailCallMode::kAllow) { 10771b268ca467c924004286c97bac133db489cf43d0Ben Murdoch result->MarkAsSyntacticTailCall(); 10781b268ca467c924004286c97bac133db489cf43d0Ben Murdoch } 1079257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch return MarkAsCall(DefineFixed(result, rax), instr, CANNOT_DEOPTIMIZE_EAGERLY); 1080257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch} 1081257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch 1082257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch 1083b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) { 1084b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch switch (instr->op()) { 1085b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch case kMathFloor: 1086b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoMathFloor(instr); 1087b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch case kMathRound: 1088b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoMathRound(instr); 1089b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch case kMathFround: 1090b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoMathFround(instr); 1091b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch case kMathAbs: 1092b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoMathAbs(instr); 109321efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch case kMathCos: 109421efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch return DoMathCos(instr); 1095b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch case kMathLog: 1096b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoMathLog(instr); 1097b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch case kMathExp: 1098b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoMathExp(instr); 109921efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch case kMathSin: 110021efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch return DoMathSin(instr); 1101b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch case kMathSqrt: 1102b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoMathSqrt(instr); 1103b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch case kMathPowHalf: 1104b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoMathPowHalf(instr); 1105b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch case kMathClz32: 1106b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoMathClz32(instr); 1107b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch default: 1108b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch UNREACHABLE(); 1109b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return NULL; 1110e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch } 1111b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1112b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1113b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoMathFloor(HUnaryMathOperation* instr) { 11141b268ca467c924004286c97bac133db489cf43d0Ben Murdoch DCHECK(instr->value()->representation().IsDouble()); 1115b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* input = UseRegisterAtStart(instr->value()); 11161b268ca467c924004286c97bac133db489cf43d0Ben Murdoch if (instr->representation().IsInteger32()) { 11171b268ca467c924004286c97bac133db489cf43d0Ben Murdoch LMathFloorI* result = new (zone()) LMathFloorI(input); 11181b268ca467c924004286c97bac133db489cf43d0Ben Murdoch return AssignEnvironment(AssignPointerMap(DefineAsRegister(result))); 11191b268ca467c924004286c97bac133db489cf43d0Ben Murdoch } else { 11201b268ca467c924004286c97bac133db489cf43d0Ben Murdoch DCHECK(instr->representation().IsDouble()); 11211b268ca467c924004286c97bac133db489cf43d0Ben Murdoch LMathFloorD* result = new (zone()) LMathFloorD(input); 11221b268ca467c924004286c97bac133db489cf43d0Ben Murdoch return DefineAsRegister(result); 11231b268ca467c924004286c97bac133db489cf43d0Ben Murdoch } 1124b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1125b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1126b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoMathRound(HUnaryMathOperation* instr) { 11271b268ca467c924004286c97bac133db489cf43d0Ben Murdoch DCHECK(instr->value()->representation().IsDouble()); 1128b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* input = UseRegister(instr->value()); 11291b268ca467c924004286c97bac133db489cf43d0Ben Murdoch if (instr->representation().IsInteger32()) { 11301b268ca467c924004286c97bac133db489cf43d0Ben Murdoch LOperand* temp = FixedTemp(xmm4); 11311b268ca467c924004286c97bac133db489cf43d0Ben Murdoch LMathRoundI* result = new (zone()) LMathRoundI(input, temp); 11321b268ca467c924004286c97bac133db489cf43d0Ben Murdoch return AssignEnvironment(AssignPointerMap(DefineAsRegister(result))); 11331b268ca467c924004286c97bac133db489cf43d0Ben Murdoch } else { 11341b268ca467c924004286c97bac133db489cf43d0Ben Murdoch DCHECK(instr->representation().IsDouble()); 11351b268ca467c924004286c97bac133db489cf43d0Ben Murdoch LMathRoundD* result = new (zone()) LMathRoundD(input); 11361b268ca467c924004286c97bac133db489cf43d0Ben Murdoch return DefineAsRegister(result); 11371b268ca467c924004286c97bac133db489cf43d0Ben Murdoch } 1138b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1139b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1140b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoMathFround(HUnaryMathOperation* instr) { 1141b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* input = UseRegister(instr->value()); 1142b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LMathFround* result = new (zone()) LMathFround(input); 1143b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineAsRegister(result); 1144b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1145b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1146b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1147b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoMathAbs(HUnaryMathOperation* instr) { 1148b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseAny(instr->context()); 1149b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* input = UseRegisterAtStart(instr->value()); 1150b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = 1151b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DefineSameAsFirst(new(zone()) LMathAbs(context, input)); 1152b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch Representation r = instr->value()->representation(); 1153b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (!r.IsDouble() && !r.IsSmiOrInteger32()) result = AssignPointerMap(result); 1154b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (!r.IsDouble()) result = AssignEnvironment(result); 1155b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 1156b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1157b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1158b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1159b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoMathLog(HUnaryMathOperation* instr) { 1160b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->representation().IsDouble()); 1161b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->value()->representation().IsDouble()); 116221efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch LOperand* input = UseFixedDouble(instr->value(), xmm0); 116321efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch return MarkAsCall(DefineFixedDouble(new (zone()) LMathLog(input), xmm0), 116421efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch instr); 1165b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1166b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1167b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1168b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoMathClz32(HUnaryMathOperation* instr) { 1169b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* input = UseRegisterAtStart(instr->value()); 1170b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LMathClz32* result = new(zone()) LMathClz32(input); 1171b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineAsRegister(result); 1172b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1173b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 117421efce637eb329c94f1323b6a2334a1c977e1a9dBen MurdochLInstruction* LChunkBuilder::DoMathCos(HUnaryMathOperation* instr) { 117521efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch DCHECK(instr->representation().IsDouble()); 117621efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch DCHECK(instr->value()->representation().IsDouble()); 117721efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch LOperand* input = UseFixedDouble(instr->value(), xmm0); 117821efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch return MarkAsCall(DefineFixedDouble(new (zone()) LMathCos(input), xmm0), 117921efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch instr); 118021efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch} 1181b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1182b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoMathExp(HUnaryMathOperation* instr) { 1183b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->representation().IsDouble()); 1184b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->value()->representation().IsDouble()); 118521efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch LOperand* input = UseFixedDouble(instr->value(), xmm0); 118621efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch return MarkAsCall(DefineFixedDouble(new (zone()) LMathExp(input), xmm0), 118721efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch instr); 1188b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1189b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 119021efce637eb329c94f1323b6a2334a1c977e1a9dBen MurdochLInstruction* LChunkBuilder::DoMathSin(HUnaryMathOperation* instr) { 119121efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch DCHECK(instr->representation().IsDouble()); 119221efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch DCHECK(instr->value()->representation().IsDouble()); 119321efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch LOperand* input = UseFixedDouble(instr->value(), xmm0); 119421efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch return MarkAsCall(DefineFixedDouble(new (zone()) LMathSin(input), xmm0), 119521efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch instr); 119621efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch} 1197b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1198b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoMathSqrt(HUnaryMathOperation* instr) { 1199b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* input = UseAtStart(instr->value()); 1200b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineAsRegister(new(zone()) LMathSqrt(input)); 1201b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1202b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1203b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1204b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoMathPowHalf(HUnaryMathOperation* instr) { 1205b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* input = UseRegisterAtStart(instr->value()); 1206b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LMathPowHalf* result = new(zone()) LMathPowHalf(input); 1207b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineSameAsFirst(result); 1208b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1209b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1210b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1211b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoCallNewArray(HCallNewArray* instr) { 1212b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseFixed(instr->context(), rsi); 1213b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* constructor = UseFixed(instr->constructor(), rdi); 1214b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LCallNewArray* result = new(zone()) LCallNewArray(context, constructor); 1215b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return MarkAsCall(DefineFixed(result, rax), instr); 1216b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 12173ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 12183ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 1219b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoCallRuntime(HCallRuntime* instr) { 1220b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseFixed(instr->context(), rsi); 1221b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LCallRuntime* result = new(zone()) LCallRuntime(context); 1222b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return MarkAsCall(DefineFixed(result, rax), instr); 1223b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 1224b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1225b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1226b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoRor(HRor* instr) { 1227b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoShift(Token::ROR, instr); 1228b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 1229b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1230b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1231b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoShr(HShr* instr) { 1232b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoShift(Token::SHR, instr); 1233b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 1234b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1235b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1236b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoSar(HSar* instr) { 1237b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoShift(Token::SAR, instr); 1238b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 1239b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1240b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1241b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoShl(HShl* instr) { 1242b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoShift(Token::SHL, instr); 1243b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 1244b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1245b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1246b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoBitwise(HBitwise* instr) { 1247b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->representation().IsSmiOrInteger32()) { 1248b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().Equals(instr->representation())); 1249b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->right()->representation().Equals(instr->representation())); 1250b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->CheckFlag(HValue::kTruncatingToInt32)); 1251b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1252b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); 1253014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LOperand* right; 1254014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch if (SmiValuesAre32Bits() && instr->representation().IsSmi()) { 1255014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // We don't support tagged immediates, so we request it in a register. 1256014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch right = UseRegisterAtStart(instr->BetterRightOperand()); 1257014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch } else { 1258014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch right = UseOrConstantAtStart(instr->BetterRightOperand()); 1259014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch } 1260b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineSameAsFirst(new(zone()) LBitI(left, right)); 1261b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 1262b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoArithmeticT(instr->op(), instr); 12633ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch } 1264b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1265b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1266b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1267b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoDivByPowerOf2I(HDiv* instr) { 1268b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->representation().IsSmiOrInteger32()); 1269b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().Equals(instr->representation())); 1270b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->right()->representation().Equals(instr->representation())); 1271b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* dividend = UseRegister(instr->left()); 1272b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch int32_t divisor = instr->right()->GetInteger32Constant(); 1273b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = DefineAsRegister(new(zone()) LDivByPowerOf2I( 1274b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch dividend, divisor)); 1275b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if ((instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) || 1276b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch (instr->CheckFlag(HValue::kCanOverflow) && divisor == -1) || 1277b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch (!instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32) && 1278b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch divisor != 1 && divisor != -1)) { 1279b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch result = AssignEnvironment(result); 1280b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1281b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 1282b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 1283b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1284b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1285b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoDivByConstI(HDiv* instr) { 1286b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->representation().IsInteger32()); 1287b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().Equals(instr->representation())); 1288b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->right()->representation().Equals(instr->representation())); 1289b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* dividend = UseRegister(instr->left()); 1290b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch int32_t divisor = instr->right()->GetInteger32Constant(); 1291b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* temp1 = FixedTemp(rax); 1292b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* temp2 = FixedTemp(rdx); 1293b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = DefineFixed(new(zone()) LDivByConstI( 1294b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch dividend, divisor, temp1, temp2), rdx); 1295b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (divisor == 0 || 1296b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) || 1297b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch !instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)) { 1298b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch result = AssignEnvironment(result); 1299b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1300b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 1301b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 1302b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1303b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1304b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoDivI(HDiv* instr) { 1305b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->representation().IsSmiOrInteger32()); 1306b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().Equals(instr->representation())); 1307b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->right()->representation().Equals(instr->representation())); 1308b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* dividend = UseFixed(instr->left(), rax); 1309b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* divisor = UseRegister(instr->right()); 1310b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* temp = FixedTemp(rdx); 1311b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = DefineFixed(new(zone()) LDivI( 1312b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch dividend, divisor, temp), rax); 1313b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->CheckFlag(HValue::kCanBeDivByZero) || 1314b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->CheckFlag(HValue::kBailoutOnMinusZero) || 1315b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->CheckFlag(HValue::kCanOverflow) || 1316b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch !instr->CheckFlag(HValue::kAllUsesTruncatingToInt32)) { 1317b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch result = AssignEnvironment(result); 1318b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1319b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 1320b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1321b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1322b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1323b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoDiv(HDiv* instr) { 1324b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->representation().IsSmiOrInteger32()) { 1325b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->RightIsPowerOf2()) { 1326b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoDivByPowerOf2I(instr); 1327b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else if (instr->right()->IsConstant()) { 1328b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoDivByConstI(instr); 1329b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 1330b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoDivI(instr); 1331b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1332b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else if (instr->representation().IsDouble()) { 13331e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block return DoArithmeticD(Token::DIV, instr); 13341e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } else { 13351e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block return DoArithmeticT(Token::DIV, instr); 13361e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } 1337b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1338b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1339b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1340b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr) { 1341b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* dividend = UseRegisterAtStart(instr->left()); 1342b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch int32_t divisor = instr->right()->GetInteger32Constant(); 1343b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = DefineSameAsFirst(new(zone()) LFlooringDivByPowerOf2I( 1344b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch dividend, divisor)); 1345b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if ((instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) || 1346b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch (instr->CheckFlag(HValue::kLeftCanBeMinInt) && divisor == -1)) { 1347b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch result = AssignEnvironment(result); 1348b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1349b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 1350b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 1351b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1352b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1353b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoFlooringDivByConstI(HMathFloorOfDiv* instr) { 1354b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->representation().IsInteger32()); 1355b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().Equals(instr->representation())); 1356b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->right()->representation().Equals(instr->representation())); 1357b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* dividend = UseRegister(instr->left()); 1358b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch int32_t divisor = instr->right()->GetInteger32Constant(); 1359b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* temp1 = FixedTemp(rax); 1360b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* temp2 = FixedTemp(rdx); 1361b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* temp3 = 1362b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch ((divisor > 0 && !instr->CheckFlag(HValue::kLeftCanBeNegative)) || 1363b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch (divisor < 0 && !instr->CheckFlag(HValue::kLeftCanBePositive))) ? 1364b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch NULL : TempRegister(); 1365b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = 1366b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DefineFixed(new(zone()) LFlooringDivByConstI(dividend, 1367b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch divisor, 1368b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch temp1, 1369b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch temp2, 1370b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch temp3), 1371b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch rdx); 1372b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (divisor == 0 || 1373b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0)) { 1374b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch result = AssignEnvironment(result); 1375b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1376b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 1377b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 1378b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1379b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1380b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoFlooringDivI(HMathFloorOfDiv* instr) { 1381b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->representation().IsSmiOrInteger32()); 1382b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().Equals(instr->representation())); 1383b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->right()->representation().Equals(instr->representation())); 1384b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* dividend = UseFixed(instr->left(), rax); 1385b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* divisor = UseRegister(instr->right()); 1386b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* temp = FixedTemp(rdx); 1387b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = DefineFixed(new(zone()) LFlooringDivI( 1388b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch dividend, divisor, temp), rax); 1389b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->CheckFlag(HValue::kCanBeDivByZero) || 1390b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->CheckFlag(HValue::kBailoutOnMinusZero) || 1391b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->CheckFlag(HValue::kCanOverflow)) { 1392b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch result = AssignEnvironment(result); 1393b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1394b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 1395b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 1396b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1397b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1398b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { 1399b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->RightIsPowerOf2()) { 1400b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoFlooringDivByPowerOf2I(instr); 1401b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else if (instr->right()->IsConstant()) { 1402b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoFlooringDivByConstI(instr); 1403b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 1404b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoFlooringDivI(instr); 1405b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1406b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 1407b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1408b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1409b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoModByPowerOf2I(HMod* instr) { 1410b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->representation().IsSmiOrInteger32()); 1411b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().Equals(instr->representation())); 1412b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->right()->representation().Equals(instr->representation())); 1413b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* dividend = UseRegisterAtStart(instr->left()); 1414b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch int32_t divisor = instr->right()->GetInteger32Constant(); 1415b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = DefineSameAsFirst(new(zone()) LModByPowerOf2I( 1416b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch dividend, divisor)); 1417b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->CheckFlag(HValue::kLeftCanBeNegative) && 1418b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->CheckFlag(HValue::kBailoutOnMinusZero)) { 1419b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch result = AssignEnvironment(result); 1420b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1421b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 1422b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 1423b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1424b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1425b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoModByConstI(HMod* instr) { 1426b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->representation().IsSmiOrInteger32()); 1427b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().Equals(instr->representation())); 1428b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->right()->representation().Equals(instr->representation())); 1429b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* dividend = UseRegister(instr->left()); 1430b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch int32_t divisor = instr->right()->GetInteger32Constant(); 1431b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* temp1 = FixedTemp(rax); 1432b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* temp2 = FixedTemp(rdx); 1433b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = DefineFixed(new(zone()) LModByConstI( 1434b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch dividend, divisor, temp1, temp2), rax); 1435b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (divisor == 0 || instr->CheckFlag(HValue::kBailoutOnMinusZero)) { 1436b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch result = AssignEnvironment(result); 1437b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1438b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 1439b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 1440b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1441b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1442b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoModI(HMod* instr) { 1443b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->representation().IsSmiOrInteger32()); 1444b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().Equals(instr->representation())); 1445b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->right()->representation().Equals(instr->representation())); 1446b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* dividend = UseFixed(instr->left(), rax); 1447b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* divisor = UseRegister(instr->right()); 1448b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* temp = FixedTemp(rdx); 1449b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = DefineFixed(new(zone()) LModI( 1450b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch dividend, divisor, temp), rdx); 1451b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->CheckFlag(HValue::kCanBeDivByZero) || 1452b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->CheckFlag(HValue::kBailoutOnMinusZero)) { 1453b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch result = AssignEnvironment(result); 1454b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1455b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 1456b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 1457b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1458b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1459b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoMod(HMod* instr) { 1460b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->representation().IsSmiOrInteger32()) { 1461b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->RightIsPowerOf2()) { 1462b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoModByPowerOf2I(instr); 1463b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else if (instr->right()->IsConstant()) { 1464b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoModByConstI(instr); 146544f0eee88ff00398ff7f715fab053374d808c90dSteve Block } else { 1466b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoModI(instr); 146744f0eee88ff00398ff7f715fab053374d808c90dSteve Block } 1468b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else if (instr->representation().IsDouble()) { 1469b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoArithmeticD(Token::MOD, instr); 1470e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch } else { 1471b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoArithmeticT(Token::MOD, instr); 1472e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch } 1473b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1474b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1475b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1476b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoMul(HMul* instr) { 1477b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->representation().IsSmiOrInteger32()) { 1478b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().Equals(instr->representation())); 1479b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->right()->representation().Equals(instr->representation())); 1480b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); 1481342c50ce1624b485728b9a4fc41d8bbf37eb46cfBen Murdoch HValue* h_right = instr->BetterRightOperand(); 1482342c50ce1624b485728b9a4fc41d8bbf37eb46cfBen Murdoch LOperand* right = UseOrConstant(h_right); 14833ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LMulI* mul = new(zone()) LMulI(left, right); 1484342c50ce1624b485728b9a4fc41d8bbf37eb46cfBen Murdoch int constant_value = 1485342c50ce1624b485728b9a4fc41d8bbf37eb46cfBen Murdoch h_right->IsConstant() ? HConstant::cast(h_right)->Integer32Value() : 0; 1486342c50ce1624b485728b9a4fc41d8bbf37eb46cfBen Murdoch // |needs_environment| must mirror the cases where LCodeGen::DoMulI calls 1487342c50ce1624b485728b9a4fc41d8bbf37eb46cfBen Murdoch // |DeoptimizeIf|. 1488342c50ce1624b485728b9a4fc41d8bbf37eb46cfBen Murdoch bool needs_environment = 1489342c50ce1624b485728b9a4fc41d8bbf37eb46cfBen Murdoch instr->CheckFlag(HValue::kCanOverflow) || 1490342c50ce1624b485728b9a4fc41d8bbf37eb46cfBen Murdoch (instr->CheckFlag(HValue::kBailoutOnMinusZero) && 1491342c50ce1624b485728b9a4fc41d8bbf37eb46cfBen Murdoch (!right->IsConstantOperand() || constant_value <= 0)); 1492342c50ce1624b485728b9a4fc41d8bbf37eb46cfBen Murdoch if (needs_environment) { 14933ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch AssignEnvironment(mul); 14943ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch } 14953ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return DefineSameAsFirst(mul); 14961e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } else if (instr->representation().IsDouble()) { 14971e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block return DoArithmeticD(Token::MUL, instr); 14981e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } else { 14991e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block return DoArithmeticT(Token::MUL, instr); 15001e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } 1501b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1502b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1503b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1504b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoSub(HSub* instr) { 1505b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->representation().IsSmiOrInteger32()) { 1506b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().Equals(instr->representation())); 1507b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->right()->representation().Equals(instr->representation())); 15081e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block LOperand* left = UseRegisterAtStart(instr->left()); 1509014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LOperand* right; 1510014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch if (SmiValuesAre32Bits() && instr->representation().IsSmi()) { 1511014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // We don't support tagged immediates, so we request it in a register. 1512014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch right = UseRegisterAtStart(instr->right()); 1513014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch } else { 1514014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch right = UseOrConstantAtStart(instr->right()); 1515014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch } 15163ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LSubI* sub = new(zone()) LSubI(left, right); 15171e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block LInstruction* result = DefineSameAsFirst(sub); 15181e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block if (instr->CheckFlag(HValue::kCanOverflow)) { 15191e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block result = AssignEnvironment(result); 15201e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } 15211e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block return result; 15221e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } else if (instr->representation().IsDouble()) { 15231e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block return DoArithmeticD(Token::SUB, instr); 15241e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } else { 15251e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block return DoArithmeticT(Token::SUB, instr); 15261e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } 1527b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1528b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1529b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1530b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoAdd(HAdd* instr) { 1531b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->representation().IsSmiOrInteger32()) { 1532b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // Check to see if it would be advantageous to use an lea instruction rather 1533b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // than an add. This is the case when no overflow check is needed and there 1534b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // are multiple uses of the add's inputs, so using a 3-register add will 1535b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // preserve all input values for later uses. 1536b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch bool use_lea = LAddI::UseLea(instr); 1537b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().Equals(instr->representation())); 1538b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->right()->representation().Equals(instr->representation())); 1539b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); 1540b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch HValue* right_candidate = instr->BetterRightOperand(); 1541b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* right; 1542b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (SmiValuesAre32Bits() && instr->representation().IsSmi()) { 1543b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // We cannot add a tagged immediate to a tagged value, 1544b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // so we request it in a register. 1545b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch right = UseRegisterAtStart(right_candidate); 1546b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 1547b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch right = use_lea ? UseRegisterOrConstantAtStart(right_candidate) 1548b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch : UseOrConstantAtStart(right_candidate); 1549b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 15503ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LAddI* add = new(zone()) LAddI(left, right); 1551b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch bool can_overflow = instr->CheckFlag(HValue::kCanOverflow); 1552b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = use_lea ? DefineAsRegister(add) 1553b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch : DefineSameAsFirst(add); 1554b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (can_overflow) { 1555b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch result = AssignEnvironment(result); 1556b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } 1557b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return result; 1558b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else if (instr->representation().IsExternal()) { 1559014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch DCHECK(instr->IsConsistentExternalRepresentation()); 1560b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(!instr->CheckFlag(HValue::kCanOverflow)); 1561b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch bool use_lea = LAddI::UseLea(instr); 1562b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* left = UseRegisterAtStart(instr->left()); 1563b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch HValue* right_candidate = instr->right(); 1564b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* right = use_lea 1565b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch ? UseRegisterOrConstantAtStart(right_candidate) 1566b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch : UseOrConstantAtStart(right_candidate); 1567b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LAddI* add = new(zone()) LAddI(left, right); 1568b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = use_lea 1569b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch ? DefineAsRegister(add) 1570b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch : DefineSameAsFirst(add); 1571b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 1572b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } else if (instr->representation().IsDouble()) { 1573e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch return DoArithmeticD(Token::ADD, instr); 1574b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } else { 1575b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return DoArithmeticT(Token::ADD, instr); 1576b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } 1577b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return NULL; 1578b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1579b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1580b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1581b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoMathMinMax(HMathMinMax* instr) { 1582b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* left = NULL; 1583b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* right = NULL; 1584b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().Equals(instr->representation())); 1585b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->right()->representation().Equals(instr->representation())); 1586b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->representation().IsSmi()) { 1587b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch left = UseRegisterAtStart(instr->BetterLeftOperand()); 1588b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch right = UseAtStart(instr->BetterRightOperand()); 1589b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else if (instr->representation().IsInteger32()) { 1590b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch left = UseRegisterAtStart(instr->BetterLeftOperand()); 1591b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch right = UseOrConstantAtStart(instr->BetterRightOperand()); 1592b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 1593b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->representation().IsDouble()); 1594b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch left = UseRegisterAtStart(instr->left()); 1595b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch right = UseRegisterAtStart(instr->right()); 1596b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1597b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LMathMinMax* minmax = new(zone()) LMathMinMax(left, right); 1598b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineSameAsFirst(minmax); 1599b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 1600b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1601b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1602b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoPower(HPower* instr) { 1603b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->representation().IsDouble()); 1604e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch // We call a C function for double power. It can't trigger a GC. 1605e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch // We need to use fixed result register for the call. 1606e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch Representation exponent_type = instr->right()->representation(); 1607b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().IsDouble()); 1608e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch LOperand* left = UseFixedDouble(instr->left(), xmm2); 1609b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* right = 1610b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch exponent_type.IsDouble() 1611b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch ? UseFixedDouble(instr->right(), xmm1) 1612b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch : UseFixed(instr->right(), MathPowTaggedDescriptor::exponent()); 16133ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LPower* result = new(zone()) LPower(left, right); 16143ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return MarkAsCall(DefineFixedDouble(result, xmm3), instr, 1615e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch CAN_DEOPTIMIZE_EAGERLY); 1616b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1617b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1618b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 16193fb3ca8c7ca439d408449a395897395c0faae8d1Ben MurdochLInstruction* LChunkBuilder::DoCompareGeneric(HCompareGeneric* instr) { 1620b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().IsTagged()); 1621b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->right()->representation().IsTagged()); 1622b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseFixed(instr->context(), rsi); 16233ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* left = UseFixed(instr->left(), rdx); 16243ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* right = UseFixed(instr->right(), rax); 1625b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LCmpT* result = new(zone()) LCmpT(context, left, right); 16263fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch return MarkAsCall(DefineFixed(result, rax), instr); 16273fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch} 16283fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch 16293fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch 1630b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoCompareNumericAndBranch( 1631b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch HCompareNumericAndBranch* instr) { 1632b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch Representation r = instr->representation(); 1633b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (r.IsSmiOrInteger32()) { 1634b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().Equals(r)); 1635b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->right()->representation().Equals(r)); 16363ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* left = UseRegisterOrConstantAtStart(instr->left()); 16371e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block LOperand* right = UseOrConstantAtStart(instr->right()); 1638b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return new(zone()) LCompareNumericAndBranch(left, right); 16393fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch } else { 1640b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(r.IsDouble()); 1641b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().IsDouble()); 1642b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->right()->representation().IsDouble()); 16433ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* left; 16443ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* right; 16453ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch if (instr->left()->IsConstant() && instr->right()->IsConstant()) { 16463ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch left = UseRegisterOrConstantAtStart(instr->left()); 16473ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch right = UseRegisterOrConstantAtStart(instr->right()); 16483ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch } else { 16493ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch left = UseRegisterAtStart(instr->left()); 16503ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch right = UseRegisterAtStart(instr->right()); 16513ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch } 1652b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return new(zone()) LCompareNumericAndBranch(left, right); 16531e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } 1654b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1655b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1656b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 16573fb3ca8c7ca439d408449a395897395c0faae8d1Ben MurdochLInstruction* LChunkBuilder::DoCompareObjectEqAndBranch( 16583fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch HCompareObjectEqAndBranch* instr) { 16591e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block LOperand* left = UseRegisterAtStart(instr->left()); 1660b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* right = UseRegisterOrConstantAtStart(instr->right()); 16613ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return new(zone()) LCmpObjectEqAndBranch(left, right); 1662b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1663b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1664b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1665b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoCompareHoleAndBranch( 1666b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch HCompareHoleAndBranch* instr) { 16673ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* value = UseRegisterAtStart(instr->value()); 1668b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return new(zone()) LCmpHoleAndBranch(value); 1669257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch} 1670257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch 1671257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch 16723ef787dbeca8a5fb1086949cda830dccee07bfbdBen MurdochLInstruction* LChunkBuilder::DoIsStringAndBranch(HIsStringAndBranch* instr) { 1673b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->value()->representation().IsTagged()); 16743ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* value = UseRegisterAtStart(instr->value()); 16753ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* temp = TempRegister(); 16763ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return new(zone()) LIsStringAndBranch(value, temp); 1677592a9fc1d8ea420377a2e7efd0600e20b058be2bBen Murdoch} 1678592a9fc1d8ea420377a2e7efd0600e20b058be2bBen Murdoch 1679592a9fc1d8ea420377a2e7efd0600e20b058be2bBen Murdoch 16803fb3ca8c7ca439d408449a395897395c0faae8d1Ben MurdochLInstruction* LChunkBuilder::DoIsSmiAndBranch(HIsSmiAndBranch* instr) { 1681b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->value()->representation().IsTagged()); 16823ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return new(zone()) LIsSmiAndBranch(Use(instr->value())); 1683b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1684b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1685b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 16863fb3ca8c7ca439d408449a395897395c0faae8d1Ben MurdochLInstruction* LChunkBuilder::DoIsUndetectableAndBranch( 16873fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch HIsUndetectableAndBranch* instr) { 1688b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->value()->representation().IsTagged()); 16893ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* value = UseRegisterAtStart(instr->value()); 16903ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* temp = TempRegister(); 16913ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return new(zone()) LIsUndetectableAndBranch(value, temp); 16923ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch} 16933ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 16943ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 16953ef787dbeca8a5fb1086949cda830dccee07bfbdBen MurdochLInstruction* LChunkBuilder::DoStringCompareAndBranch( 16963ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch HStringCompareAndBranch* instr) { 16973ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 1698b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().IsTagged()); 1699b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->right()->representation().IsTagged()); 1700b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseFixed(instr->context(), rsi); 17013ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* left = UseFixed(instr->left(), rdx); 17023ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* right = UseFixed(instr->right(), rax); 17033ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LStringCompareAndBranch* result = 1704b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch new(zone()) LStringCompareAndBranch(context, left, right); 17053ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 17063ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return MarkAsCall(result, instr); 1707592a9fc1d8ea420377a2e7efd0600e20b058be2bBen Murdoch} 1708592a9fc1d8ea420377a2e7efd0600e20b058be2bBen Murdoch 1709592a9fc1d8ea420377a2e7efd0600e20b058be2bBen Murdoch 17103fb3ca8c7ca439d408449a395897395c0faae8d1Ben MurdochLInstruction* LChunkBuilder::DoHasInstanceTypeAndBranch( 17113fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch HHasInstanceTypeAndBranch* instr) { 1712b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->value()->representation().IsTagged()); 17133ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* value = UseRegisterAtStart(instr->value()); 17143ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return new(zone()) LHasInstanceTypeAndBranch(value); 1715e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch} 1716e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch 1717e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch 1718e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen MurdochLInstruction* LChunkBuilder::DoGetCachedArrayIndex( 1719e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch HGetCachedArrayIndex* instr) { 1720b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->value()->representation().IsTagged()); 1721e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch LOperand* value = UseRegisterAtStart(instr->value()); 1722e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch 17233ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return DefineAsRegister(new(zone()) LGetCachedArrayIndex(value)); 1724b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1725b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1726b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 17273fb3ca8c7ca439d408449a395897395c0faae8d1Ben MurdochLInstruction* LChunkBuilder::DoHasCachedArrayIndexAndBranch( 17283fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch HHasCachedArrayIndexAndBranch* instr) { 1729b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->value()->representation().IsTagged()); 17303ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* value = UseRegisterAtStart(instr->value()); 17313ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return new(zone()) LHasCachedArrayIndexAndBranch(value); 1732b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1733b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1734b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 17353fb3ca8c7ca439d408449a395897395c0faae8d1Ben MurdochLInstruction* LChunkBuilder::DoClassOfTestAndBranch( 17363fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch HClassOfTestAndBranch* instr) { 17373ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* value = UseRegister(instr->value()); 17383ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return new(zone()) LClassOfTestAndBranch(value, 17393ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch TempRegister(), 17403ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch TempRegister()); 1741b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1742b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1743b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1744b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoSeqStringGetChar(HSeqStringGetChar* instr) { 1745b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* string = UseRegisterAtStart(instr->string()); 1746b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* index = UseRegisterOrConstantAtStart(instr->index()); 1747b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineAsRegister(new(zone()) LSeqStringGetChar(string, index)); 17483fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch} 17493fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch 17503fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch 1751b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoSeqStringSetChar(HSeqStringSetChar* instr) { 1752b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* string = UseRegisterAtStart(instr->string()); 1753b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* index = FLAG_debug_code 1754b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch ? UseRegisterAtStart(instr->index()) 1755b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch : UseRegisterOrConstantAtStart(instr->index()); 1756b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* value = FLAG_debug_code 1757b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch ? UseRegisterAtStart(instr->value()) 1758b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch : UseRegisterOrConstantAtStart(instr->value()); 1759b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = FLAG_debug_code ? UseFixed(instr->context(), rsi) : NULL; 1760b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = new(zone()) LSeqStringSetChar(context, string, 1761b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch index, value); 1762b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (FLAG_debug_code) { 1763b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch result = MarkAsCall(result, instr); 1764b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1765b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 17663ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch} 17673ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 17683ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 1769b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) { 1770b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (!FLAG_debug_code && instr->skip_check()) return NULL; 1771b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* index = UseRegisterOrConstantAtStart(instr->index()); 1772b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* length = !index->IsConstantOperand() 1773b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch ? UseOrConstantAtStart(instr->length()) 1774b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch : UseAtStart(instr->length()); 1775b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = new(zone()) LBoundsCheck(index, length); 1776b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (!FLAG_debug_code || !instr->skip_check()) { 1777b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch result = AssignEnvironment(result); 1778b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1779b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 17805d4cdbf7a67d3662fa0bee4efdb7edd8daec9b0bBen Murdoch} 17815d4cdbf7a67d3662fa0bee4efdb7edd8daec9b0bBen Murdoch 17825d4cdbf7a67d3662fa0bee4efdb7edd8daec9b0bBen Murdoch 17831e0659c275bb392c045087af4f6b0d7565cb3d77Steve BlockLInstruction* LChunkBuilder::DoAbnormalExit(HAbnormalExit* instr) { 17841e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block // The control instruction marking the end of a block that completed 17851e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block // abruptly (e.g., threw an exception). There is nothing specific to do. 1786b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return NULL; 1787b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1788b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1789b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 17903fb3ca8c7ca439d408449a395897395c0faae8d1Ben MurdochLInstruction* LChunkBuilder::DoUseConst(HUseConst* instr) { 17913fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch return NULL; 17923fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch} 17933fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch 17943fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch 1795257744e915dfc84d6d07a6b2accf8402d9ffc708Ben MurdochLInstruction* LChunkBuilder::DoForceRepresentation(HForceRepresentation* bad) { 1796257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch // All HForceRepresentation instructions should be eliminated in the 1797257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch // representation change phase of Hydrogen. 1798257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch UNREACHABLE(); 1799257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch return NULL; 1800257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch} 1801257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch 1802257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch 1803b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoChange(HChange* instr) { 18041e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block Representation from = instr->from(); 18051e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block Representation to = instr->to(); 1806b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch HValue* val = instr->value(); 1807b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (from.IsSmi()) { 1808b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (to.IsTagged()) { 1809b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* value = UseRegister(val); 1810b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineSameAsFirst(new(zone()) LDummyUse(value)); 1811b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1812b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch from = Representation::Tagged(); 1813b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 18141e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block if (from.IsTagged()) { 18151e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block if (to.IsDouble()) { 1816b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* value = UseRegister(val); 1817b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = DefineAsRegister(new(zone()) LNumberUntagD(value)); 1818b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (!val->representation().IsSmi()) result = AssignEnvironment(result); 1819b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 1820b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else if (to.IsSmi()) { 1821b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* value = UseRegister(val); 1822b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (val->type().IsSmi()) { 1823b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineSameAsFirst(new(zone()) LDummyUse(value)); 1824b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1825b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return AssignEnvironment(DefineSameAsFirst(new(zone()) LCheckSmi(value))); 18261e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } else { 1827b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(to.IsInteger32()); 1828b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (val->type().IsSmi() || val->representation().IsSmi()) { 1829b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* value = UseRegister(val); 1830b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineSameAsFirst(new(zone()) LSmiUntag(value, false)); 1831b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 1832b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* value = UseRegister(val); 18333fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch bool truncating = instr->CanTruncateToInt32(); 18343fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch LOperand* xmm_temp = truncating ? NULL : FixedTemp(xmm1); 1835b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = 1836b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DefineSameAsFirst(new(zone()) LTaggedToI(value, xmm_temp)); 1837b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (!val->representation().IsSmi()) result = AssignEnvironment(result); 1838b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 18391e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } 18401e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } 18411e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } else if (from.IsDouble()) { 18421e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block if (to.IsTagged()) { 1843b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch info()->MarkAsDeferredCalling(); 1844b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* value = UseRegister(val); 18451e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block LOperand* temp = TempRegister(); 18461e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block LUnallocated* result_temp = TempRegister(); 18473ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LNumberTagD* result = new(zone()) LNumberTagD(value, temp); 18481e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block return AssignPointerMap(Define(result, result_temp)); 1849b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else if (to.IsSmi()) { 1850b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* value = UseRegister(val); 1851b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return AssignEnvironment( 1852b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DefineAsRegister(new(zone()) LDoubleToSmi(value))); 18531e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } else { 1854b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(to.IsInteger32()); 1855b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* value = UseRegister(val); 1856b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = DefineAsRegister(new(zone()) LDoubleToI(value)); 1857b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (!instr->CanTruncateToInt32()) result = AssignEnvironment(result); 1858b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 18591e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } 18601e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } else if (from.IsInteger32()) { 1861b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch info()->MarkAsDeferredCalling(); 18621e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block if (to.IsTagged()) { 1863b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (!instr->CheckFlag(HValue::kCanOverflow)) { 1864b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* value = UseRegister(val); 1865b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineAsRegister(new(zone()) LSmiTag(value)); 1866b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else if (val->CheckFlag(HInstruction::kUint32)) { 1867b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* value = UseRegister(val); 1868b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* temp1 = TempRegister(); 1869b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* temp2 = FixedTemp(xmm1); 1870b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LNumberTagU* result = new(zone()) LNumberTagU(value, temp1, temp2); 1871b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return AssignPointerMap(DefineSameAsFirst(result)); 18721e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } else { 1873b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* value = UseRegister(val); 1874b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* temp1 = SmiValuesAre32Bits() ? NULL : TempRegister(); 1875b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* temp2 = SmiValuesAre32Bits() ? NULL : FixedTemp(xmm1); 1876b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LNumberTagI* result = new(zone()) LNumberTagI(value, temp1, temp2); 1877b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return AssignPointerMap(DefineSameAsFirst(result)); 18781e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } 1879b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else if (to.IsSmi()) { 1880b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* value = UseRegister(val); 1881b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = DefineAsRegister(new(zone()) LSmiTag(value)); 1882b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->CheckFlag(HValue::kCanOverflow)) { 1883b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch result = AssignEnvironment(result); 1884b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1885b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 18861e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } else { 1887b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(to.IsDouble()); 1888b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (val->CheckFlag(HInstruction::kUint32)) { 1889b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineAsRegister(new(zone()) LUint32ToDouble(UseRegister(val))); 1890b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 1891b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* value = Use(val); 1892b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineAsRegister(new(zone()) LInteger32ToDouble(value)); 1893b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 18941e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } 18951e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } 18961e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block UNREACHABLE(); 1897b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return NULL; 1898b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1899b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1900b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1901b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoCheckHeapObject(HCheckHeapObject* instr) { 19021e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block LOperand* value = UseRegisterAtStart(instr->value()); 1903b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = new(zone()) LCheckNonSmi(value); 1904b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (!instr->value()->type().IsHeapObject()) { 1905b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch result = AssignEnvironment(result); 1906b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1907b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 1908b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1909b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1910b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1911b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoCheckSmi(HCheckSmi* instr) { 19121e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block LOperand* value = UseRegisterAtStart(instr->value()); 1913b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return AssignEnvironment(new(zone()) LCheckSmi(value)); 1914b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1915b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1916b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1917014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochLInstruction* LChunkBuilder::DoCheckArrayBufferNotNeutered( 1918014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch HCheckArrayBufferNotNeutered* instr) { 1919014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LOperand* view = UseRegisterAtStart(instr->value()); 1920014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LCheckArrayBufferNotNeutered* result = 1921014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch new (zone()) LCheckArrayBufferNotNeutered(view); 1922014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return AssignEnvironment(result); 1923014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 1924014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 1925014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 1926b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoCheckInstanceType(HCheckInstanceType* instr) { 19271e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block LOperand* value = UseRegisterAtStart(instr->value()); 1928b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LCheckInstanceType* result = new(zone()) LCheckInstanceType(value); 1929b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return AssignEnvironment(result); 1930b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1931b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1932b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1933b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoCheckValue(HCheckValue* instr) { 19341e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block LOperand* value = UseRegisterAtStart(instr->value()); 1935b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return AssignEnvironment(new(zone()) LCheckValue(value)); 1936b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1937b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1938b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1939b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoCheckMaps(HCheckMaps* instr) { 1940b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->IsStabilityCheck()) return new(zone()) LCheckMaps; 19411e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block LOperand* value = UseRegisterAtStart(instr->value()); 1942b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = AssignEnvironment(new(zone()) LCheckMaps(value)); 1943b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->HasMigrationTarget()) { 1944b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch info()->MarkAsDeferredCalling(); 1945b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch result = AssignPointerMap(result); 1946b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1947b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 1948b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1949b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1950b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1951257744e915dfc84d6d07a6b2accf8402d9ffc708Ben MurdochLInstruction* LChunkBuilder::DoClampToUint8(HClampToUint8* instr) { 1952257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch HValue* value = instr->value(); 1953257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch Representation input_rep = value->representation(); 1954257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch LOperand* reg = UseRegister(value); 1955257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch if (input_rep.IsDouble()) { 1956b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineAsRegister(new(zone()) LClampDToUint8(reg)); 1957257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch } else if (input_rep.IsInteger32()) { 19583ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return DefineSameAsFirst(new(zone()) LClampIToUint8(reg)); 1959257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch } else { 1960b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(input_rep.IsSmiOrTagged()); 1961257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch // Register allocator doesn't (yet) support allocation of double 1962257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch // temps. Reserve xmm1 explicitly. 19633ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LClampTToUint8* result = new(zone()) LClampTToUint8(reg, 19643ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch FixedTemp(xmm1)); 1965257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch return AssignEnvironment(DefineSameAsFirst(result)); 1966257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch } 1967257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch} 1968257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch 1969257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch 1970b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoDoubleBits(HDoubleBits* instr) { 1971b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch HValue* value = instr->value(); 1972b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(value->representation().IsDouble()); 1973b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineAsRegister(new(zone()) LDoubleBits(UseRegister(value))); 1974b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 1975b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1976b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1977b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoReturn(HReturn* instr) { 1978b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = info()->IsStub() ? UseFixed(instr->context(), rsi) : NULL; 1979b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* parameter_count = UseRegisterOrConstant(instr->parameter_count()); 1980b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return new(zone()) LReturn( 1981b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch UseFixed(instr->value(), rax), context, parameter_count); 1982b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1983b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1984b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1985b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoConstant(HConstant* instr) { 1986b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch Representation r = instr->representation(); 1987b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (r.IsSmi()) { 1988b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineAsRegister(new(zone()) LConstantS); 1989b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else if (r.IsInteger32()) { 19903ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return DefineAsRegister(new(zone()) LConstantI); 1991b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } else if (r.IsDouble()) { 1992014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return DefineAsRegister(new (zone()) LConstantD); 1993b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else if (r.IsExternal()) { 1994b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineAsRegister(new(zone()) LConstantE); 1995b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } else if (r.IsTagged()) { 19963ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return DefineAsRegister(new(zone()) LConstantT); 1997b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } else { 1998b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch UNREACHABLE(); 1999b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return NULL; 2000b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } 2001b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2002b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2003b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 20048b112d2025046f85ef7f6be087c6129c872ebad2Ben MurdochLInstruction* LChunkBuilder::DoLoadGlobalGeneric(HLoadGlobalGeneric* instr) { 2005b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseFixed(instr->context(), rsi); 200621efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch LOperand* vector = FixedTemp(LoadWithVectorDescriptor::VectorRegister()); 2007b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 200821efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch LLoadGlobalGeneric* result = new (zone()) LLoadGlobalGeneric(context, vector); 20098b112d2025046f85ef7f6be087c6129c872ebad2Ben Murdoch return MarkAsCall(DefineFixed(result, rax), instr); 20108b112d2025046f85ef7f6be087c6129c872ebad2Ben Murdoch} 20118b112d2025046f85ef7f6be087c6129c872ebad2Ben Murdoch 20128b112d2025046f85ef7f6be087c6129c872ebad2Ben Murdoch 2013b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoLoadContextSlot(HLoadContextSlot* instr) { 2014e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch LOperand* context = UseRegisterAtStart(instr->value()); 20153ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LInstruction* result = 20163ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch DefineAsRegister(new(zone()) LLoadContextSlot(context)); 2017b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->RequiresHoleCheck() && instr->DeoptimizesOnHole()) { 2018b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch result = AssignEnvironment(result); 2019b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 2020b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 2021b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2022b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2023b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 20241e0659c275bb392c045087af4f6b0d7565cb3d77Steve BlockLInstruction* LChunkBuilder::DoStoreContextSlot(HStoreContextSlot* instr) { 2025e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch LOperand* context; 2026e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch LOperand* value; 2027e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch LOperand* temp; 2028b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch context = UseRegister(instr->context()); 2029e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch if (instr->NeedsWriteBarrier()) { 2030e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch value = UseTempRegister(instr->value()); 2031e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch temp = TempRegister(); 2032e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch } else { 2033e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch value = UseRegister(instr->value()); 2034e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch temp = NULL; 2035e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch } 20363ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LInstruction* result = new(zone()) LStoreContextSlot(context, value, temp); 2037b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->RequiresHoleCheck() && instr->DeoptimizesOnHole()) { 2038b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch result = AssignEnvironment(result); 2039b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 2040b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 2041b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2042b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2043b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 20441e0659c275bb392c045087af4f6b0d7565cb3d77Steve BlockLInstruction* LChunkBuilder::DoLoadNamedField(HLoadNamedField* instr) { 2045b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // Use the special mov rax, moffs64 encoding for external 2046b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // memory accesses with 64-bit word-sized values. 2047b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->access().IsExternalMemory() && 2048b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->access().offset() == 0 && 2049b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch (instr->access().representation().IsSmi() || 2050b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->access().representation().IsTagged() || 2051b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->access().representation().IsHeapObject() || 2052b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->access().representation().IsExternal())) { 2053b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* obj = UseRegisterOrConstantAtStart(instr->object()); 2054b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineFixed(new(zone()) LLoadNamedField(obj), rax); 2055b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 20561e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block LOperand* obj = UseRegisterAtStart(instr->object()); 20573ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return DefineAsRegister(new(zone()) LLoadNamedField(obj)); 20581e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block} 20591e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block 20601e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block 2061b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoLoadNamedGeneric(HLoadNamedGeneric* instr) { 2062b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseFixed(instr->context(), rsi); 2063b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* object = 2064b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch UseFixed(instr->object(), LoadDescriptor::ReceiverRegister()); 206521efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch LOperand* vector = FixedTemp(LoadWithVectorDescriptor::VectorRegister()); 2066b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LLoadNamedGeneric* result = new(zone()) LLoadNamedGeneric( 2067b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch context, object, vector); 20681e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block return MarkAsCall(DefineFixed(result, rax), instr); 2069b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2070b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2071b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2072b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoLoadFunctionPrototype( 2073b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch HLoadFunctionPrototype* instr) { 20741e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block return AssignEnvironment(DefineAsRegister( 20753ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch new(zone()) LLoadFunctionPrototype(UseRegister(instr->function())))); 2076b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2077b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2078b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2079b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoLoadRoot(HLoadRoot* instr) { 2080b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineAsRegister(new(zone()) LLoadRoot); 20811e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block} 20821e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block 20831e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block 2084b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochvoid LChunkBuilder::FindDehoistedKeyDefinitions(HValue* candidate) { 2085b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // We sign extend the dehoisted key at the definition point when the pointer 2086b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // size is 64-bit. For x32 port, we sign extend the dehoisted key at the use 2087b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // points and should not invoke this function. We can't use STATIC_ASSERT 2088b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // here as the pointer size is 32-bit for x32. 2089b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(kPointerSize == kInt64Size); 2090b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch BitVector* dehoisted_key_ids = chunk_->GetDehoistedKeyIds(); 2091b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (dehoisted_key_ids->Contains(candidate->id())) return; 2092b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch dehoisted_key_ids->Add(candidate->id()); 2093b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (!candidate->IsPhi()) return; 2094b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch for (int i = 0; i < candidate->OperandCount(); ++i) { 2095b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch FindDehoistedKeyDefinitions(candidate->OperandAt(i)); 2096b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 2097b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2098b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2099b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2100b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) { 2101b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK((kPointerSize == kInt64Size && 2102b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->key()->representation().IsInteger32()) || 2103b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch (kPointerSize == kInt32Size && 2104b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->key()->representation().IsSmiOrInteger32())); 2105b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch ElementsKind elements_kind = instr->elements_kind(); 2106b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* key = NULL; 2107b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = NULL; 21081e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block 2109b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (kPointerSize == kInt64Size) { 2110b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch key = UseRegisterOrConstantAtStart(instr->key()); 2111b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 2112b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch bool clobbers_key = ExternalArrayOpRequiresTemp( 2113b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->key()->representation(), elements_kind); 2114b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch key = clobbers_key 2115b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch ? UseTempRegister(instr->key()) 2116b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch : UseRegisterOrConstantAtStart(instr->key()); 2117b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 21181e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block 2119b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if ((kPointerSize == kInt64Size) && instr->IsDehoisted()) { 2120b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch FindDehoistedKeyDefinitions(instr->key()); 2121b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 21223fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch 2123014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch if (!instr->is_fixed_typed_array()) { 2124b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* obj = UseRegisterAtStart(instr->elements()); 2125014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch result = DefineAsRegister(new (zone()) LLoadKeyed(obj, key, nullptr)); 2126b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 2127b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK( 2128b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch (instr->representation().IsInteger32() && 2129b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch !(IsDoubleOrFloatElementsKind(elements_kind))) || 2130b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch (instr->representation().IsDouble() && 2131b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch (IsDoubleOrFloatElementsKind(elements_kind)))); 2132b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* backing_store = UseRegister(instr->elements()); 2133014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LOperand* backing_store_owner = UseAny(instr->backing_store_owner()); 2134014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch result = DefineAsRegister( 2135014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch new (zone()) LLoadKeyed(backing_store, key, backing_store_owner)); 2136014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch } 2137014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 2138014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch bool needs_environment; 2139014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch if (instr->is_fixed_typed_array()) { 2140014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // see LCodeGen::DoLoadKeyedExternalArray 2141014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch needs_environment = elements_kind == UINT32_ELEMENTS && 2142014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch !instr->CheckFlag(HInstruction::kUint32); 2143014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch } else { 2144014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // see LCodeGen::DoLoadKeyedFixedDoubleArray and 2145014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // LCodeGen::DoLoadKeyedFixedArray 2146014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch needs_environment = 2147014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch instr->RequiresHoleCheck() || 2148014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch (instr->hole_mode() == CONVERT_HOLE_TO_UNDEFINED && info()->IsStub()); 2149b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 21503fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch 2151014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch if (needs_environment) { 2152b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch result = AssignEnvironment(result); 2153b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 2154b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 2155b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2156b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2157b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2158b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) { 2159b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseFixed(instr->context(), rsi); 2160b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* object = 2161b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch UseFixed(instr->object(), LoadDescriptor::ReceiverRegister()); 2162b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* key = UseFixed(instr->key(), LoadDescriptor::NameRegister()); 216321efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch LOperand* vector = FixedTemp(LoadWithVectorDescriptor::VectorRegister()); 2164e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch 2165b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LLoadKeyedGeneric* result = 2166b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch new(zone()) LLoadKeyedGeneric(context, object, key, vector); 2167e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch return MarkAsCall(DefineFixed(result, rax), instr); 2168b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2169b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2170b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2171b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { 2172b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch ElementsKind elements_kind = instr->elements_kind(); 21733fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch 2174b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if ((kPointerSize == kInt64Size) && instr->IsDehoisted()) { 2175b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch FindDehoistedKeyDefinitions(instr->key()); 2176b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 21773fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch 2178014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch if (!instr->is_fixed_typed_array()) { 2179b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->elements()->representation().IsTagged()); 2180b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch bool needs_write_barrier = instr->NeedsWriteBarrier(); 2181b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* object = NULL; 2182b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* key = NULL; 2183b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* val = NULL; 2184b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 2185b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch Representation value_representation = instr->value()->representation(); 2186b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (value_representation.IsDouble()) { 2187b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch object = UseRegisterAtStart(instr->elements()); 2188b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch val = UseRegisterAtStart(instr->value()); 2189b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch key = UseRegisterOrConstantAtStart(instr->key()); 2190b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 2191b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(value_representation.IsSmiOrTagged() || 2192b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch value_representation.IsInteger32()); 2193b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (needs_write_barrier) { 2194b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch object = UseTempRegister(instr->elements()); 2195b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch val = UseTempRegister(instr->value()); 2196b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch key = UseTempRegister(instr->key()); 2197b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 2198b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch object = UseRegisterAtStart(instr->elements()); 2199b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch val = UseRegisterOrConstantAtStart(instr->value()); 2200b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch key = UseRegisterOrConstantAtStart(instr->key()); 2201b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 2202b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 22033fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch 2204014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return new (zone()) LStoreKeyed(object, key, val, nullptr); 2205b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 22063fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch 2207b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK( 2208b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch (instr->value()->representation().IsInteger32() && 2209b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch !IsDoubleOrFloatElementsKind(elements_kind)) || 2210b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch (instr->value()->representation().IsDouble() && 2211b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch IsDoubleOrFloatElementsKind(elements_kind))); 2212014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch DCHECK(instr->elements()->representation().IsExternal()); 2213014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch bool val_is_temp_register = elements_kind == UINT8_CLAMPED_ELEMENTS || 2214014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch elements_kind == FLOAT32_ELEMENTS; 2215b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* val = val_is_temp_register ? UseTempRegister(instr->value()) 22168b112d2025046f85ef7f6be087c6129c872ebad2Ben Murdoch : UseRegister(instr->value()); 2217b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* key = NULL; 2218b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (kPointerSize == kInt64Size) { 2219b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch key = UseRegisterOrConstantAtStart(instr->key()); 2220b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 2221b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch bool clobbers_key = ExternalArrayOpRequiresTemp( 2222b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->key()->representation(), elements_kind); 2223b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch key = clobbers_key 2224b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch ? UseTempRegister(instr->key()) 2225b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch : UseRegisterOrConstantAtStart(instr->key()); 2226b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 2227b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* backing_store = UseRegister(instr->elements()); 2228014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LOperand* backing_store_owner = UseAny(instr->backing_store_owner()); 2229014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return new (zone()) LStoreKeyed(backing_store, key, val, backing_store_owner); 2230e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch} 2231e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch 2232e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch 2233b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) { 2234b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseFixed(instr->context(), rsi); 2235b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* object = 2236b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch UseFixed(instr->object(), StoreDescriptor::ReceiverRegister()); 2237b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* key = UseFixed(instr->key(), StoreDescriptor::NameRegister()); 2238b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* value = UseFixed(instr->value(), StoreDescriptor::ValueRegister()); 2239e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch 2240b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->object()->representation().IsTagged()); 2241b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->key()->representation().IsTagged()); 2242b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->value()->representation().IsTagged()); 2243e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch 224421efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch LOperand* slot = FixedTemp(VectorStoreICDescriptor::SlotRegister()); 224521efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch LOperand* vector = FixedTemp(VectorStoreICDescriptor::VectorRegister()); 2246014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 2247014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LStoreKeyedGeneric* result = new (zone()) 2248014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LStoreKeyedGeneric(context, object, key, value, slot, vector); 2249e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch return MarkAsCall(result, instr); 2250b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2251b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2252b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 22533ef787dbeca8a5fb1086949cda830dccee07bfbdBen MurdochLInstruction* LChunkBuilder::DoTransitionElementsKind( 22543ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch HTransitionElementsKind* instr) { 2255b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (IsSimpleMapChangeTransition(instr->from_kind(), instr->to_kind())) { 22563ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* object = UseRegister(instr->object()); 22573ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* new_map_reg = TempRegister(); 22583ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* temp_reg = TempRegister(); 2259b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LTransitionElementsKind* result = new(zone()) LTransitionElementsKind( 2260b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch object, NULL, new_map_reg, temp_reg); 2261b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 22623ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch } else { 22633ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* object = UseFixed(instr->object(), rax); 2264b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseFixed(instr->context(), rsi); 22653ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LTransitionElementsKind* result = 2266b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch new(zone()) LTransitionElementsKind(object, context, NULL, NULL); 2267b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return MarkAsCall(result, instr); 22683ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch } 22693ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch} 22703ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 22713ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 2272b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoTrapAllocationMemento( 2273b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch HTrapAllocationMemento* instr) { 2274b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* object = UseRegister(instr->object()); 2275b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* temp = TempRegister(); 2276b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LTrapAllocationMemento* result = 2277b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch new(zone()) LTrapAllocationMemento(object, temp); 2278b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return AssignEnvironment(result); 2279b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 2280b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 2281b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 2282014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochLInstruction* LChunkBuilder::DoMaybeGrowElements(HMaybeGrowElements* instr) { 2283014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch info()->MarkAsDeferredCalling(); 2284014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LOperand* context = UseFixed(instr->context(), rsi); 2285014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LOperand* object = Use(instr->object()); 2286014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LOperand* elements = Use(instr->elements()); 2287014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LOperand* key = UseRegisterOrConstant(instr->key()); 2288014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LOperand* current_capacity = UseRegisterOrConstant(instr->current_capacity()); 2289014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 2290014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LMaybeGrowElements* result = new (zone()) 2291014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LMaybeGrowElements(context, object, elements, key, current_capacity); 2292014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch DefineFixed(result, rax); 2293014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return AssignPointerMap(AssignEnvironment(result)); 2294014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 2295014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 2296014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 2297b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { 2298b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch bool is_in_object = instr->access().IsInobject(); 2299b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch bool is_external_location = instr->access().IsExternalMemory() && 2300b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->access().offset() == 0; 23011e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block bool needs_write_barrier = instr->NeedsWriteBarrier(); 2302b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch bool needs_write_barrier_for_map = instr->has_transition() && 2303b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->NeedsWriteBarrierForMap(); 2304b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 2305b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* obj; 2306b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (needs_write_barrier) { 2307b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch obj = is_in_object 2308b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch ? UseRegister(instr->object()) 2309b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch : UseTempRegister(instr->object()); 2310b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else if (is_external_location) { 2311b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(!is_in_object); 2312b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(!needs_write_barrier); 2313b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(!needs_write_barrier_for_map); 2314b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch obj = UseRegisterOrConstant(instr->object()); 2315b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 2316b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch obj = needs_write_barrier_for_map 2317b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch ? UseRegister(instr->object()) 2318b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch : UseRegisterAtStart(instr->object()); 2319b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 23201e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block 2321b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch bool can_be_constant = instr->value()->IsConstant() && 2322b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch HConstant::cast(instr->value())->NotInNewSpace() && 2323b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch !instr->field_representation().IsDouble(); 2324b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 2325b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* val; 2326b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (needs_write_barrier) { 2327b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch val = UseTempRegister(instr->value()); 2328b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else if (is_external_location) { 2329b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch val = UseFixed(instr->value(), rax); 2330b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else if (can_be_constant) { 2331b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch val = UseRegisterOrConstant(instr->value()); 2332b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else if (instr->field_representation().IsDouble()) { 2333b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch val = UseRegisterAtStart(instr->value()); 2334b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 2335b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch val = UseRegister(instr->value()); 2336b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 23371e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block 23381e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block // We only need a scratch register if we have a write barrier or we 23391e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block // have a store into the properties array (not in-object-property). 2340b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* temp = (!is_in_object || needs_write_barrier || 2341b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch needs_write_barrier_for_map) ? TempRegister() : NULL; 23421e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block 23433ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return new(zone()) LStoreNamedField(obj, val, temp); 2344b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2345b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2346b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2347b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoStoreNamedGeneric(HStoreNamedGeneric* instr) { 2348b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseFixed(instr->context(), rsi); 2349b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* object = 2350b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch UseFixed(instr->object(), StoreDescriptor::ReceiverRegister()); 2351b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* value = UseFixed(instr->value(), StoreDescriptor::ValueRegister()); 235221efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch LOperand* slot = FixedTemp(VectorStoreICDescriptor::SlotRegister()); 235321efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch LOperand* vector = FixedTemp(VectorStoreICDescriptor::VectorRegister()); 2354e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch 2355b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LStoreNamedGeneric* result = 2356014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch new (zone()) LStoreNamedGeneric(context, object, value, slot, vector); 2357e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch return MarkAsCall(result, instr); 2358b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2359b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2360b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2361257744e915dfc84d6d07a6b2accf8402d9ffc708Ben MurdochLInstruction* LChunkBuilder::DoStringAdd(HStringAdd* instr) { 2362b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseFixed(instr->context(), rsi); 2363b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* left = UseFixed(instr->left(), rdx); 2364b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* right = UseFixed(instr->right(), rax); 2365b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return MarkAsCall( 2366b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DefineFixed(new(zone()) LStringAdd(context, left, right), rax), instr); 2367257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch} 2368257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch 2369257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch 23701e0659c275bb392c045087af4f6b0d7565cb3d77Steve BlockLInstruction* LChunkBuilder::DoStringCharCodeAt(HStringCharCodeAt* instr) { 237169a99ed0b2b2ef69d393c371b03db3a98aaf880eBen Murdoch LOperand* string = UseTempRegister(instr->string()); 237269a99ed0b2b2ef69d393c371b03db3a98aaf880eBen Murdoch LOperand* index = UseTempRegister(instr->index()); 2373b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseAny(instr->context()); 2374b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LStringCharCodeAt* result = 2375b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch new(zone()) LStringCharCodeAt(context, string, index); 2376b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return AssignPointerMap(DefineAsRegister(result)); 2377b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2378b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2379b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 238044f0eee88ff00398ff7f715fab053374d808c90dSteve BlockLInstruction* LChunkBuilder::DoStringCharFromCode(HStringCharFromCode* instr) { 238144f0eee88ff00398ff7f715fab053374d808c90dSteve Block LOperand* char_code = UseRegister(instr->value()); 2382b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseAny(instr->context()); 2383b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LStringCharFromCode* result = 2384b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch new(zone()) LStringCharFromCode(context, char_code); 238544f0eee88ff00398ff7f715fab053374d808c90dSteve Block return AssignPointerMap(DefineAsRegister(result)); 238644f0eee88ff00398ff7f715fab053374d808c90dSteve Block} 238744f0eee88ff00398ff7f715fab053374d808c90dSteve Block 238844f0eee88ff00398ff7f715fab053374d808c90dSteve Block 2389b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoAllocate(HAllocate* instr) { 2390537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch LOperand* size = instr->size()->IsConstant() ? UseConstant(instr->size()) 2391537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch : UseRegister(instr->size()); 2392537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch if (instr->IsAllocationFolded()) { 2393537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch LOperand* temp = TempRegister(); 2394537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch LFastAllocate* result = new (zone()) LFastAllocate(size, temp); 2395537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch return DefineAsRegister(result); 2396537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch } else { 2397537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch info()->MarkAsDeferredCalling(); 2398537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch LOperand* context = UseAny(instr->context()); 2399537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch LOperand* temp = TempRegister(); 2400537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch LAllocate* result = new (zone()) LAllocate(context, size, temp); 2401537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch return AssignPointerMap(DefineAsRegister(result)); 2402537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch } 24033ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch} 24043ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 24053ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 2406b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoOsrEntry(HOsrEntry* instr) { 2407b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(argument_count_ == 0); 2408e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch allocator_->MarkAsOsrEntry(); 2409e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch current_block_->last_environment()->set_ast_id(instr->ast_id()); 24103ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return AssignEnvironment(new(zone()) LOsrEntry); 2411b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2412b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2413b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2414b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoParameter(HParameter* instr) { 2415b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LParameter* result = new(zone()) LParameter; 2416b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->kind() == HParameter::STACK_PARAMETER) { 2417b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch int spill_index = chunk()->GetParameterStackSlot(instr->index()); 2418b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineAsSpilled(result, spill_index); 2419b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 2420b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(info()->IsStub()); 2421342c50ce1624b485728b9a4fc41d8bbf37eb46cfBen Murdoch CallInterfaceDescriptor descriptor = graph()->descriptor(); 2422b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch int index = static_cast<int>(instr->index()); 2423014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Register reg = descriptor.GetRegisterParameter(index); 2424b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineFixed(result, reg); 2425b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 2426b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2427b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2428b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2429b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) { 2430b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // Use an index that corresponds to the location in the unoptimized frame, 2431b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // which the optimized frame will subsume. 2432b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch int env_index = instr->index(); 2433b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch int spill_index = 0; 2434b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->environment()->is_parameter_index(env_index)) { 2435b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch spill_index = chunk()->GetParameterStackSlot(env_index); 2436b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 2437b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch spill_index = env_index - instr->environment()->first_local_index(); 2438b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (spill_index > LUnallocated::kMaxFixedSlotIndex) { 2439b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch Retry(kTooManySpillSlotsNeededForOSR); 2440b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch spill_index = 0; 2441b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 2442342c50ce1624b485728b9a4fc41d8bbf37eb46cfBen Murdoch spill_index += StandardFrameConstants::kFixedSlotCount; 24437d3e7fc4b65010eabe860313ee0c64f50843f6e3Ben Murdoch } 24443ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return DefineAsSpilled(new(zone()) LUnknownOSRValue, spill_index); 2445b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2446b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2447b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2448b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) { 2449e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch // There are no real uses of the arguments object. 2450e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch // arguments.length and element access are supported directly on 2451e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch // stack arguments, and any real arguments object use causes a bailout. 2452e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch // So this value is never used. 2453b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return NULL; 2454b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2455b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2456b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2457b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoCapturedObject(HCapturedObject* instr) { 2458b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->ReplayEnvironment(current_block_->last_environment()); 2459b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 2460b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // There are no real uses of a captured object. 2461b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return NULL; 2462b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 2463b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 2464b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 2465b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) { 2466b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch info()->MarkAsRequiresFrame(); 2467b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* args = UseRegister(instr->arguments()); 2468b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* length; 2469b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* index; 2470b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->length()->IsConstant() && instr->index()->IsConstant()) { 2471b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch length = UseRegisterOrConstant(instr->length()); 2472b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch index = UseOrConstant(instr->index()); 2473b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 2474b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch length = UseTempRegister(instr->length()); 2475b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch index = Use(instr->index()); 2476b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 2477b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineAsRegister(new(zone()) LAccessArgumentsAt(args, length, index)); 2478b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2479b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2480b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2481b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoTypeof(HTypeof* instr) { 2482b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseFixed(instr->context(), rsi); 2483014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LOperand* value = UseFixed(instr->value(), rbx); 2484b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LTypeof* result = new(zone()) LTypeof(context, value); 2485e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch return MarkAsCall(DefineFixed(result, rax), instr); 2486b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2487b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2488b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 24893fb3ca8c7ca439d408449a395897395c0faae8d1Ben MurdochLInstruction* LChunkBuilder::DoTypeofIsAndBranch(HTypeofIsAndBranch* instr) { 24903ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return new(zone()) LTypeofIsAndBranch(UseTempRegister(instr->value())); 2491b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2492b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 24931e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block 2494b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) { 2495b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->ReplayEnvironment(current_block_->last_environment()); 2496b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return NULL; 2497b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2498b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2499b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2500b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { 2501b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch info()->MarkAsDeferredCalling(); 25023fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch if (instr->is_function_entry()) { 2503b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseFixed(instr->context(), rsi); 2504b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return MarkAsCall(new(zone()) LStackCheck(context), instr); 25053fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch } else { 2506b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->is_backwards_branch()); 2507b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseAny(instr->context()); 2508b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return AssignEnvironment( 2509b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch AssignPointerMap(new(zone()) LStackCheck(context))); 25103fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch } 2511b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2512b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2513b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2514b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) { 25151e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block HEnvironment* outer = current_block_->last_environment(); 2516b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch outer->set_ast_id(instr->ReturnId()); 25171e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block HConstant* undefined = graph()->GetConstantUndefined(); 25181b268ca467c924004286c97bac133db489cf43d0Ben Murdoch HEnvironment* inner = outer->CopyForInlining( 25191b268ca467c924004286c97bac133db489cf43d0Ben Murdoch instr->closure(), instr->arguments_count(), instr->function(), undefined, 25201b268ca467c924004286c97bac133db489cf43d0Ben Murdoch instr->inlining_kind(), instr->syntactic_tail_call_mode()); 2521b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // Only replay binding of arguments object if it wasn't removed from graph. 2522b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->arguments_var() != NULL && instr->arguments_object()->IsLinked()) { 2523b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch inner->Bind(instr->arguments_var(), instr->arguments_object()); 25243ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch } 2525b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch inner->BindContext(instr->closure_context()); 2526b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch inner->set_entry(instr); 25271e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block current_block_->UpdateEnvironment(inner); 2528014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch chunk_->AddInlinedFunction(instr->shared()); 2529b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return NULL; 2530b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2531b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2532b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2533b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { 2534b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* pop = NULL; 2535b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 2536b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch HEnvironment* env = current_block_->last_environment(); 2537b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 2538b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (env->entry()->arguments_pushed()) { 2539b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch int argument_count = env->arguments_environment()->parameter_count(); 2540b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch pop = new(zone()) LDrop(argument_count); 2541b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->argument_delta() == -argument_count); 2542b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 2543b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 25443ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch HEnvironment* outer = current_block_->last_environment()-> 25453ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch DiscardInlined(false); 25461e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block current_block_->UpdateEnvironment(outer); 2547b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2548b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return pop; 2549257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch} 2550257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch 2551257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch 25523ef787dbeca8a5fb1086949cda830dccee07bfbdBen MurdochLInstruction* LChunkBuilder::DoForInPrepareMap(HForInPrepareMap* instr) { 2553b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseFixed(instr->context(), rsi); 25543ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* object = UseFixed(instr->enumerable(), rax); 2555b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LForInPrepareMap* result = new(zone()) LForInPrepareMap(context, object); 25563ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return MarkAsCall(DefineFixed(result, rax), instr, CAN_DEOPTIMIZE_EAGERLY); 25573ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch} 25583ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 25593ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 25603ef787dbeca8a5fb1086949cda830dccee07bfbdBen MurdochLInstruction* LChunkBuilder::DoForInCacheArray(HForInCacheArray* instr) { 25613ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* map = UseRegister(instr->map()); 25623ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return AssignEnvironment(DefineAsRegister( 25633ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch new(zone()) LForInCacheArray(map))); 25643ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch} 25653ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 25663ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 25673ef787dbeca8a5fb1086949cda830dccee07bfbdBen MurdochLInstruction* LChunkBuilder::DoCheckMapValue(HCheckMapValue* instr) { 25683ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* value = UseRegisterAtStart(instr->value()); 25693ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* map = UseRegisterAtStart(instr->map()); 25703ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return AssignEnvironment(new(zone()) LCheckMapValue(value, map)); 25713ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch} 25723ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 25733ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 25743ef787dbeca8a5fb1086949cda830dccee07bfbdBen MurdochLInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { 25753ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* object = UseRegister(instr->object()); 25763ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* index = UseTempRegister(instr->index()); 2577b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LLoadFieldByIndex* load = new(zone()) LLoadFieldByIndex(object, index); 2578b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = DefineSameAsFirst(load); 2579b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return AssignPointerMap(result); 2580b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 2581b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 2582014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} // namespace internal 2583014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} // namespace v8 2584b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2585b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch#endif // V8_TARGET_ARCH_X64 2586