lithium-x64.cc revision 1b268ca467c924004286c97bac133db489cf43d0
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) { 717b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); 718b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* right = UseFixedDouble(instr->BetterRightOperand(), xmm1); 719b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LArithmeticD* result = new(zone()) LArithmeticD(op, left, right); 720b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return MarkAsCall(DefineSameAsFirst(result), 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(); 9101b268ca467c924004286c97bac133db489cf43d0Ben Murdoch if (info_->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 960b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoInstanceOf(HInstanceOf* instr) { 961014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LOperand* left = 962014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch UseFixed(instr->left(), InstanceOfDescriptor::LeftRegister()); 963014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LOperand* right = 964014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch UseFixed(instr->right(), InstanceOfDescriptor::RightRegister()); 965b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseFixed(instr->context(), rsi); 966014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LInstanceOf* result = new (zone()) LInstanceOf(context, left, right); 967e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch return MarkAsCall(DefineFixed(result, rax), instr); 968b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 969b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 970b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 971014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochLInstruction* LChunkBuilder::DoHasInPrototypeChainAndBranch( 972014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch HHasInPrototypeChainAndBranch* instr) { 973014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LOperand* object = UseRegister(instr->object()); 974014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LOperand* prototype = UseRegister(instr->prototype()); 975014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LHasInPrototypeChainAndBranch* result = 976014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch new (zone()) LHasInPrototypeChainAndBranch(object, prototype); 977014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return AssignEnvironment(result); 978b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 979b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 980b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 9813ef787dbeca8a5fb1086949cda830dccee07bfbdBen MurdochLInstruction* LChunkBuilder::DoWrapReceiver(HWrapReceiver* instr) { 9823ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* receiver = UseRegister(instr->receiver()); 9833ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* function = UseRegisterAtStart(instr->function()); 9843ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LWrapReceiver* result = new(zone()) LWrapReceiver(receiver, function); 9853ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return AssignEnvironment(DefineSameAsFirst(result)); 9863ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch} 9873ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 9883ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 989b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoApplyArguments(HApplyArguments* instr) { 990e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch LOperand* function = UseFixed(instr->function(), rdi); 991e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch LOperand* receiver = UseFixed(instr->receiver(), rax); 992e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch LOperand* length = UseFixed(instr->length(), rbx); 993e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch LOperand* elements = UseFixed(instr->elements(), rcx); 9943ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LApplyArguments* result = new(zone()) LApplyArguments(function, 995e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch receiver, 996e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch length, 997e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch elements); 998e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch return MarkAsCall(DefineFixed(result, rax), instr, CAN_DEOPTIMIZE_EAGERLY); 999b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1000b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1001b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1002b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoPushArguments(HPushArguments* instr) { 1003b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch int argc = instr->OperandCount(); 1004b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch for (int i = 0; i < argc; ++i) { 1005b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* argument = UseOrConstant(instr->argument(i)); 1006b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch AddInstruction(new(zone()) LPushArgument(argument), instr); 1007b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1008b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return NULL; 1009b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 1010b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1011b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1012b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoStoreCodeEntry( 1013b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch HStoreCodeEntry* store_code_entry) { 1014b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* function = UseRegister(store_code_entry->function()); 1015b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* code_object = UseTempRegister(store_code_entry->code_object()); 1016b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return new(zone()) LStoreCodeEntry(function, code_object); 1017b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 1018b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1019b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1020b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoInnerAllocatedObject( 1021b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch HInnerAllocatedObject* instr) { 1022b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* base_object = UseRegisterAtStart(instr->base_object()); 1023b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* offset = UseRegisterOrConstantAtStart(instr->offset()); 1024b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineAsRegister( 1025b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch new(zone()) LInnerAllocatedObject(base_object, offset)); 10261e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block} 10271e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block 10281e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block 10293fb3ca8c7ca439d408449a395897395c0faae8d1Ben MurdochLInstruction* LChunkBuilder::DoThisFunction(HThisFunction* instr) { 10303ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return instr->HasNoUses() 10313ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch ? NULL 10323ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch : DefineAsRegister(new(zone()) LThisFunction); 10333fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch} 10343fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch 10353fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch 10361e0659c275bb392c045087af4f6b0d7565cb3d77Steve BlockLInstruction* LChunkBuilder::DoContext(HContext* instr) { 1037b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->HasNoUses()) return NULL; 10381e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block 1039b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (info()->IsStub()) { 1040b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineFixed(new(zone()) LContext, rsi); 1041b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 10421e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block 1043b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineAsRegister(new(zone()) LContext); 10443ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch} 10453ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 10463ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 10473ef787dbeca8a5fb1086949cda830dccee07bfbdBen MurdochLInstruction* LChunkBuilder::DoDeclareGlobals(HDeclareGlobals* instr) { 1048b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseFixed(instr->context(), rsi); 1049b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return MarkAsCall(new(zone()) LDeclareGlobals(context), instr); 1050b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1051b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1052b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1053b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoCallWithDescriptor( 1054b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch HCallWithDescriptor* instr) { 1055b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch CallInterfaceDescriptor descriptor = instr->descriptor(); 1056b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1057b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* target = UseRegisterOrConstantAtStart(instr->target()); 1058b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch ZoneList<LOperand*> ops(instr->OperandCount(), zone()); 1059014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // Target 1060b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch ops.Add(target, zone()); 1061014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // Context 1062014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LOperand* op = UseFixed(instr->OperandAt(1), rsi); 1063014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch ops.Add(op, zone()); 1064014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // Other register parameters 1065014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch for (int i = LCallWithDescriptor::kImplicitRegisterParameterCount; 1066014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch i < instr->OperandCount(); i++) { 1067014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch op = 1068014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch UseFixed(instr->OperandAt(i), 1069014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch descriptor.GetRegisterParameter( 1070014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch i - LCallWithDescriptor::kImplicitRegisterParameterCount)); 1071b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch ops.Add(op, zone()); 1072b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1073b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1074b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LCallWithDescriptor* result = new(zone()) LCallWithDescriptor( 1075b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch descriptor, ops, zone()); 10761b268ca467c924004286c97bac133db489cf43d0Ben Murdoch if (instr->syntactic_tail_call_mode() == TailCallMode::kAllow) { 10771b268ca467c924004286c97bac133db489cf43d0Ben Murdoch result->MarkAsSyntacticTailCall(); 10781b268ca467c924004286c97bac133db489cf43d0Ben Murdoch } 1079b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return MarkAsCall(DefineFixed(result, rax), instr); 1080b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1081b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1082b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1083257744e915dfc84d6d07a6b2accf8402d9ffc708Ben MurdochLInstruction* LChunkBuilder::DoInvokeFunction(HInvokeFunction* instr) { 1084b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseFixed(instr->context(), rsi); 1085257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch LOperand* function = UseFixed(instr->function(), rdi); 1086b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInvokeFunction* result = new(zone()) LInvokeFunction(context, function); 10871b268ca467c924004286c97bac133db489cf43d0Ben Murdoch if (instr->syntactic_tail_call_mode() == TailCallMode::kAllow) { 10881b268ca467c924004286c97bac133db489cf43d0Ben Murdoch result->MarkAsSyntacticTailCall(); 10891b268ca467c924004286c97bac133db489cf43d0Ben Murdoch } 1090257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch return MarkAsCall(DefineFixed(result, rax), instr, CANNOT_DEOPTIMIZE_EAGERLY); 1091257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch} 1092257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch 1093257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch 1094b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) { 1095b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch switch (instr->op()) { 1096b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch case kMathFloor: 1097b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoMathFloor(instr); 1098b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch case kMathRound: 1099b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoMathRound(instr); 1100b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch case kMathFround: 1101b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoMathFround(instr); 1102b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch case kMathAbs: 1103b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoMathAbs(instr); 1104b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch case kMathLog: 1105b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoMathLog(instr); 1106b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch case kMathExp: 1107b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoMathExp(instr); 1108b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch case kMathSqrt: 1109b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoMathSqrt(instr); 1110b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch case kMathPowHalf: 1111b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoMathPowHalf(instr); 1112b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch case kMathClz32: 1113b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoMathClz32(instr); 1114b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch default: 1115b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch UNREACHABLE(); 1116b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return NULL; 1117e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch } 1118b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1119b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1120b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoMathFloor(HUnaryMathOperation* instr) { 11211b268ca467c924004286c97bac133db489cf43d0Ben Murdoch DCHECK(instr->value()->representation().IsDouble()); 1122b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* input = UseRegisterAtStart(instr->value()); 11231b268ca467c924004286c97bac133db489cf43d0Ben Murdoch if (instr->representation().IsInteger32()) { 11241b268ca467c924004286c97bac133db489cf43d0Ben Murdoch LMathFloorI* result = new (zone()) LMathFloorI(input); 11251b268ca467c924004286c97bac133db489cf43d0Ben Murdoch return AssignEnvironment(AssignPointerMap(DefineAsRegister(result))); 11261b268ca467c924004286c97bac133db489cf43d0Ben Murdoch } else { 11271b268ca467c924004286c97bac133db489cf43d0Ben Murdoch DCHECK(instr->representation().IsDouble()); 11281b268ca467c924004286c97bac133db489cf43d0Ben Murdoch LMathFloorD* result = new (zone()) LMathFloorD(input); 11291b268ca467c924004286c97bac133db489cf43d0Ben Murdoch return DefineAsRegister(result); 11301b268ca467c924004286c97bac133db489cf43d0Ben Murdoch } 1131b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1132b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1133b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoMathRound(HUnaryMathOperation* instr) { 11341b268ca467c924004286c97bac133db489cf43d0Ben Murdoch DCHECK(instr->value()->representation().IsDouble()); 1135b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* input = UseRegister(instr->value()); 11361b268ca467c924004286c97bac133db489cf43d0Ben Murdoch if (instr->representation().IsInteger32()) { 11371b268ca467c924004286c97bac133db489cf43d0Ben Murdoch LOperand* temp = FixedTemp(xmm4); 11381b268ca467c924004286c97bac133db489cf43d0Ben Murdoch LMathRoundI* result = new (zone()) LMathRoundI(input, temp); 11391b268ca467c924004286c97bac133db489cf43d0Ben Murdoch return AssignEnvironment(AssignPointerMap(DefineAsRegister(result))); 11401b268ca467c924004286c97bac133db489cf43d0Ben Murdoch } else { 11411b268ca467c924004286c97bac133db489cf43d0Ben Murdoch DCHECK(instr->representation().IsDouble()); 11421b268ca467c924004286c97bac133db489cf43d0Ben Murdoch LMathRoundD* result = new (zone()) LMathRoundD(input); 11431b268ca467c924004286c97bac133db489cf43d0Ben Murdoch return DefineAsRegister(result); 11441b268ca467c924004286c97bac133db489cf43d0Ben Murdoch } 1145b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1146b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1147b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoMathFround(HUnaryMathOperation* instr) { 1148b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* input = UseRegister(instr->value()); 1149b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LMathFround* result = new (zone()) LMathFround(input); 1150b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineAsRegister(result); 1151b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1152b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1153b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1154b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoMathAbs(HUnaryMathOperation* instr) { 1155b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseAny(instr->context()); 1156b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* input = UseRegisterAtStart(instr->value()); 1157b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = 1158b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DefineSameAsFirst(new(zone()) LMathAbs(context, input)); 1159b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch Representation r = instr->value()->representation(); 1160b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (!r.IsDouble() && !r.IsSmiOrInteger32()) result = AssignPointerMap(result); 1161b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (!r.IsDouble()) result = AssignEnvironment(result); 1162b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 1163b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1164b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1165b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1166b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoMathLog(HUnaryMathOperation* instr) { 1167b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->representation().IsDouble()); 1168b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->value()->representation().IsDouble()); 1169b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* input = UseRegisterAtStart(instr->value()); 1170b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return MarkAsCall(DefineSameAsFirst(new(zone()) LMathLog(input)), instr); 1171b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1172b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1173b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1174b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoMathClz32(HUnaryMathOperation* instr) { 1175b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* input = UseRegisterAtStart(instr->value()); 1176b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LMathClz32* result = new(zone()) LMathClz32(input); 1177b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineAsRegister(result); 1178b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1179b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1180b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1181b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoMathExp(HUnaryMathOperation* instr) { 1182b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->representation().IsDouble()); 1183b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->value()->representation().IsDouble()); 1184b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* value = UseTempRegister(instr->value()); 1185b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* temp1 = TempRegister(); 1186b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* temp2 = TempRegister(); 1187b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LMathExp* result = new(zone()) LMathExp(value, temp1, temp2); 1188b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineAsRegister(result); 1189b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1190b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1191b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1192b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoMathSqrt(HUnaryMathOperation* instr) { 1193b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* input = UseAtStart(instr->value()); 1194b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineAsRegister(new(zone()) LMathSqrt(input)); 1195b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1196b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1197b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1198b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoMathPowHalf(HUnaryMathOperation* instr) { 1199b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* input = UseRegisterAtStart(instr->value()); 1200b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LMathPowHalf* result = new(zone()) LMathPowHalf(input); 1201b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineSameAsFirst(result); 1202b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1203b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1204b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1205b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoCallNewArray(HCallNewArray* instr) { 1206b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseFixed(instr->context(), rsi); 1207b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* constructor = UseFixed(instr->constructor(), rdi); 1208b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LCallNewArray* result = new(zone()) LCallNewArray(context, constructor); 1209b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return MarkAsCall(DefineFixed(result, rax), instr); 1210b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 12113ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 12123ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 1213b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoCallRuntime(HCallRuntime* instr) { 1214b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseFixed(instr->context(), rsi); 1215b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LCallRuntime* result = new(zone()) LCallRuntime(context); 1216b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return MarkAsCall(DefineFixed(result, rax), instr); 1217b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 1218b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1219b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1220b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoRor(HRor* instr) { 1221b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoShift(Token::ROR, instr); 1222b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 1223b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1224b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1225b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoShr(HShr* instr) { 1226b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoShift(Token::SHR, instr); 1227b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 1228b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1229b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1230b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoSar(HSar* instr) { 1231b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoShift(Token::SAR, instr); 1232b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 1233b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1234b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1235b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoShl(HShl* instr) { 1236b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoShift(Token::SHL, instr); 1237b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 1238b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1239b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1240b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoBitwise(HBitwise* instr) { 1241b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->representation().IsSmiOrInteger32()) { 1242b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().Equals(instr->representation())); 1243b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->right()->representation().Equals(instr->representation())); 1244b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->CheckFlag(HValue::kTruncatingToInt32)); 1245b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1246b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); 1247014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LOperand* right; 1248014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch if (SmiValuesAre32Bits() && instr->representation().IsSmi()) { 1249014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // We don't support tagged immediates, so we request it in a register. 1250014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch right = UseRegisterAtStart(instr->BetterRightOperand()); 1251014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch } else { 1252014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch right = UseOrConstantAtStart(instr->BetterRightOperand()); 1253014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch } 1254b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineSameAsFirst(new(zone()) LBitI(left, right)); 1255b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 1256b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoArithmeticT(instr->op(), instr); 12573ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch } 1258b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1259b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1260b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1261b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoDivByPowerOf2I(HDiv* instr) { 1262b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->representation().IsSmiOrInteger32()); 1263b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().Equals(instr->representation())); 1264b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->right()->representation().Equals(instr->representation())); 1265b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* dividend = UseRegister(instr->left()); 1266b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch int32_t divisor = instr->right()->GetInteger32Constant(); 1267b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = DefineAsRegister(new(zone()) LDivByPowerOf2I( 1268b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch dividend, divisor)); 1269b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if ((instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) || 1270b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch (instr->CheckFlag(HValue::kCanOverflow) && divisor == -1) || 1271b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch (!instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32) && 1272b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch divisor != 1 && divisor != -1)) { 1273b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch result = AssignEnvironment(result); 1274b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1275b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 1276b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 1277b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1278b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1279b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoDivByConstI(HDiv* instr) { 1280b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->representation().IsInteger32()); 1281b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().Equals(instr->representation())); 1282b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->right()->representation().Equals(instr->representation())); 1283b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* dividend = UseRegister(instr->left()); 1284b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch int32_t divisor = instr->right()->GetInteger32Constant(); 1285b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* temp1 = FixedTemp(rax); 1286b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* temp2 = FixedTemp(rdx); 1287b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = DefineFixed(new(zone()) LDivByConstI( 1288b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch dividend, divisor, temp1, temp2), rdx); 1289b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (divisor == 0 || 1290b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) || 1291b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch !instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)) { 1292b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch result = AssignEnvironment(result); 1293b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1294b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 1295b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 1296b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1297b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1298b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoDivI(HDiv* instr) { 1299b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->representation().IsSmiOrInteger32()); 1300b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().Equals(instr->representation())); 1301b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->right()->representation().Equals(instr->representation())); 1302b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* dividend = UseFixed(instr->left(), rax); 1303b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* divisor = UseRegister(instr->right()); 1304b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* temp = FixedTemp(rdx); 1305b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = DefineFixed(new(zone()) LDivI( 1306b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch dividend, divisor, temp), rax); 1307b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->CheckFlag(HValue::kCanBeDivByZero) || 1308b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->CheckFlag(HValue::kBailoutOnMinusZero) || 1309b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->CheckFlag(HValue::kCanOverflow) || 1310b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch !instr->CheckFlag(HValue::kAllUsesTruncatingToInt32)) { 1311b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch result = AssignEnvironment(result); 1312b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1313b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 1314b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1315b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1316b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1317b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoDiv(HDiv* instr) { 1318b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->representation().IsSmiOrInteger32()) { 1319b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->RightIsPowerOf2()) { 1320b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoDivByPowerOf2I(instr); 1321b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else if (instr->right()->IsConstant()) { 1322b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoDivByConstI(instr); 1323b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 1324b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoDivI(instr); 1325b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1326b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else if (instr->representation().IsDouble()) { 13271e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block return DoArithmeticD(Token::DIV, instr); 13281e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } else { 13291e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block return DoArithmeticT(Token::DIV, instr); 13301e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } 1331b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1332b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1333b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1334b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr) { 1335b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* dividend = UseRegisterAtStart(instr->left()); 1336b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch int32_t divisor = instr->right()->GetInteger32Constant(); 1337b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = DefineSameAsFirst(new(zone()) LFlooringDivByPowerOf2I( 1338b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch dividend, divisor)); 1339b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if ((instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) || 1340b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch (instr->CheckFlag(HValue::kLeftCanBeMinInt) && divisor == -1)) { 1341b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch result = AssignEnvironment(result); 1342b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1343b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 1344b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 1345b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1346b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1347b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoFlooringDivByConstI(HMathFloorOfDiv* instr) { 1348b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->representation().IsInteger32()); 1349b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().Equals(instr->representation())); 1350b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->right()->representation().Equals(instr->representation())); 1351b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* dividend = UseRegister(instr->left()); 1352b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch int32_t divisor = instr->right()->GetInteger32Constant(); 1353b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* temp1 = FixedTemp(rax); 1354b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* temp2 = FixedTemp(rdx); 1355b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* temp3 = 1356b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch ((divisor > 0 && !instr->CheckFlag(HValue::kLeftCanBeNegative)) || 1357b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch (divisor < 0 && !instr->CheckFlag(HValue::kLeftCanBePositive))) ? 1358b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch NULL : TempRegister(); 1359b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = 1360b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DefineFixed(new(zone()) LFlooringDivByConstI(dividend, 1361b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch divisor, 1362b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch temp1, 1363b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch temp2, 1364b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch temp3), 1365b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch rdx); 1366b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (divisor == 0 || 1367b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0)) { 1368b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch result = AssignEnvironment(result); 1369b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1370b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 1371b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 1372b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1373b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1374b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoFlooringDivI(HMathFloorOfDiv* instr) { 1375b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->representation().IsSmiOrInteger32()); 1376b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().Equals(instr->representation())); 1377b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->right()->representation().Equals(instr->representation())); 1378b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* dividend = UseFixed(instr->left(), rax); 1379b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* divisor = UseRegister(instr->right()); 1380b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* temp = FixedTemp(rdx); 1381b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = DefineFixed(new(zone()) LFlooringDivI( 1382b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch dividend, divisor, temp), rax); 1383b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->CheckFlag(HValue::kCanBeDivByZero) || 1384b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->CheckFlag(HValue::kBailoutOnMinusZero) || 1385b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->CheckFlag(HValue::kCanOverflow)) { 1386b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch result = AssignEnvironment(result); 1387b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1388b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 1389b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 1390b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1391b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1392b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { 1393b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->RightIsPowerOf2()) { 1394b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoFlooringDivByPowerOf2I(instr); 1395b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else if (instr->right()->IsConstant()) { 1396b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoFlooringDivByConstI(instr); 1397b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 1398b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoFlooringDivI(instr); 1399b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1400b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 1401b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1402b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1403b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoModByPowerOf2I(HMod* instr) { 1404b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->representation().IsSmiOrInteger32()); 1405b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().Equals(instr->representation())); 1406b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->right()->representation().Equals(instr->representation())); 1407b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* dividend = UseRegisterAtStart(instr->left()); 1408b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch int32_t divisor = instr->right()->GetInteger32Constant(); 1409b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = DefineSameAsFirst(new(zone()) LModByPowerOf2I( 1410b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch dividend, divisor)); 1411b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->CheckFlag(HValue::kLeftCanBeNegative) && 1412b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->CheckFlag(HValue::kBailoutOnMinusZero)) { 1413b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch result = AssignEnvironment(result); 1414b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1415b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 1416b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 1417b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1418b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1419b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoModByConstI(HMod* instr) { 1420b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->representation().IsSmiOrInteger32()); 1421b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().Equals(instr->representation())); 1422b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->right()->representation().Equals(instr->representation())); 1423b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* dividend = UseRegister(instr->left()); 1424b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch int32_t divisor = instr->right()->GetInteger32Constant(); 1425b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* temp1 = FixedTemp(rax); 1426b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* temp2 = FixedTemp(rdx); 1427b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = DefineFixed(new(zone()) LModByConstI( 1428b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch dividend, divisor, temp1, temp2), rax); 1429b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (divisor == 0 || instr->CheckFlag(HValue::kBailoutOnMinusZero)) { 1430b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch result = AssignEnvironment(result); 1431b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1432b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 1433b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 1434b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1435b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1436b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoModI(HMod* instr) { 1437b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->representation().IsSmiOrInteger32()); 1438b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().Equals(instr->representation())); 1439b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->right()->representation().Equals(instr->representation())); 1440b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* dividend = UseFixed(instr->left(), rax); 1441b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* divisor = UseRegister(instr->right()); 1442b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* temp = FixedTemp(rdx); 1443b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = DefineFixed(new(zone()) LModI( 1444b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch dividend, divisor, temp), rdx); 1445b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->CheckFlag(HValue::kCanBeDivByZero) || 1446b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->CheckFlag(HValue::kBailoutOnMinusZero)) { 1447b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch result = AssignEnvironment(result); 1448b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1449b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 1450b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 1451b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1452b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1453b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoMod(HMod* instr) { 1454b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->representation().IsSmiOrInteger32()) { 1455b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->RightIsPowerOf2()) { 1456b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoModByPowerOf2I(instr); 1457b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else if (instr->right()->IsConstant()) { 1458b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoModByConstI(instr); 145944f0eee88ff00398ff7f715fab053374d808c90dSteve Block } else { 1460b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoModI(instr); 146144f0eee88ff00398ff7f715fab053374d808c90dSteve Block } 1462b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else if (instr->representation().IsDouble()) { 1463b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoArithmeticD(Token::MOD, instr); 1464e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch } else { 1465b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DoArithmeticT(Token::MOD, instr); 1466e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch } 1467b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1468b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1469b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1470b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoMul(HMul* instr) { 1471b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->representation().IsSmiOrInteger32()) { 1472b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().Equals(instr->representation())); 1473b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->right()->representation().Equals(instr->representation())); 1474b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); 1475342c50ce1624b485728b9a4fc41d8bbf37eb46cfBen Murdoch HValue* h_right = instr->BetterRightOperand(); 1476342c50ce1624b485728b9a4fc41d8bbf37eb46cfBen Murdoch LOperand* right = UseOrConstant(h_right); 14773ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LMulI* mul = new(zone()) LMulI(left, right); 1478342c50ce1624b485728b9a4fc41d8bbf37eb46cfBen Murdoch int constant_value = 1479342c50ce1624b485728b9a4fc41d8bbf37eb46cfBen Murdoch h_right->IsConstant() ? HConstant::cast(h_right)->Integer32Value() : 0; 1480342c50ce1624b485728b9a4fc41d8bbf37eb46cfBen Murdoch // |needs_environment| must mirror the cases where LCodeGen::DoMulI calls 1481342c50ce1624b485728b9a4fc41d8bbf37eb46cfBen Murdoch // |DeoptimizeIf|. 1482342c50ce1624b485728b9a4fc41d8bbf37eb46cfBen Murdoch bool needs_environment = 1483342c50ce1624b485728b9a4fc41d8bbf37eb46cfBen Murdoch instr->CheckFlag(HValue::kCanOverflow) || 1484342c50ce1624b485728b9a4fc41d8bbf37eb46cfBen Murdoch (instr->CheckFlag(HValue::kBailoutOnMinusZero) && 1485342c50ce1624b485728b9a4fc41d8bbf37eb46cfBen Murdoch (!right->IsConstantOperand() || constant_value <= 0)); 1486342c50ce1624b485728b9a4fc41d8bbf37eb46cfBen Murdoch if (needs_environment) { 14873ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch AssignEnvironment(mul); 14883ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch } 14893ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return DefineSameAsFirst(mul); 14901e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } else if (instr->representation().IsDouble()) { 14911e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block return DoArithmeticD(Token::MUL, instr); 14921e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } else { 14931e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block return DoArithmeticT(Token::MUL, instr); 14941e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } 1495b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1496b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1497b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1498b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoSub(HSub* instr) { 1499b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->representation().IsSmiOrInteger32()) { 1500b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().Equals(instr->representation())); 1501b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->right()->representation().Equals(instr->representation())); 15021e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block LOperand* left = UseRegisterAtStart(instr->left()); 1503014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LOperand* right; 1504014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch if (SmiValuesAre32Bits() && instr->representation().IsSmi()) { 1505014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // We don't support tagged immediates, so we request it in a register. 1506014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch right = UseRegisterAtStart(instr->right()); 1507014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch } else { 1508014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch right = UseOrConstantAtStart(instr->right()); 1509014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch } 15103ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LSubI* sub = new(zone()) LSubI(left, right); 15111e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block LInstruction* result = DefineSameAsFirst(sub); 15121e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block if (instr->CheckFlag(HValue::kCanOverflow)) { 15131e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block result = AssignEnvironment(result); 15141e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } 15151e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block return result; 15161e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } else if (instr->representation().IsDouble()) { 15171e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block return DoArithmeticD(Token::SUB, instr); 15181e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } else { 15191e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block return DoArithmeticT(Token::SUB, instr); 15201e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } 1521b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1522b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1523b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1524b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoAdd(HAdd* instr) { 1525b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->representation().IsSmiOrInteger32()) { 1526b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // Check to see if it would be advantageous to use an lea instruction rather 1527b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // than an add. This is the case when no overflow check is needed and there 1528b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // are multiple uses of the add's inputs, so using a 3-register add will 1529b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // preserve all input values for later uses. 1530b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch bool use_lea = LAddI::UseLea(instr); 1531b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().Equals(instr->representation())); 1532b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->right()->representation().Equals(instr->representation())); 1533b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); 1534b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch HValue* right_candidate = instr->BetterRightOperand(); 1535b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* right; 1536b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (SmiValuesAre32Bits() && instr->representation().IsSmi()) { 1537b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // We cannot add a tagged immediate to a tagged value, 1538b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // so we request it in a register. 1539b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch right = UseRegisterAtStart(right_candidate); 1540b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 1541b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch right = use_lea ? UseRegisterOrConstantAtStart(right_candidate) 1542b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch : UseOrConstantAtStart(right_candidate); 1543b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 15443ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LAddI* add = new(zone()) LAddI(left, right); 1545b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch bool can_overflow = instr->CheckFlag(HValue::kCanOverflow); 1546b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = use_lea ? DefineAsRegister(add) 1547b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch : DefineSameAsFirst(add); 1548b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (can_overflow) { 1549b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch result = AssignEnvironment(result); 1550b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } 1551b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return result; 1552b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else if (instr->representation().IsExternal()) { 1553014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch DCHECK(instr->IsConsistentExternalRepresentation()); 1554b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(!instr->CheckFlag(HValue::kCanOverflow)); 1555b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch bool use_lea = LAddI::UseLea(instr); 1556b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* left = UseRegisterAtStart(instr->left()); 1557b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch HValue* right_candidate = instr->right(); 1558b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* right = use_lea 1559b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch ? UseRegisterOrConstantAtStart(right_candidate) 1560b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch : UseOrConstantAtStart(right_candidate); 1561b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LAddI* add = new(zone()) LAddI(left, right); 1562b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = use_lea 1563b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch ? DefineAsRegister(add) 1564b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch : DefineSameAsFirst(add); 1565b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 1566b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } else if (instr->representation().IsDouble()) { 1567e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch return DoArithmeticD(Token::ADD, instr); 1568b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } else { 1569b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return DoArithmeticT(Token::ADD, instr); 1570b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } 1571b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return NULL; 1572b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1573b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1574b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1575b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoMathMinMax(HMathMinMax* instr) { 1576b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* left = NULL; 1577b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* right = NULL; 1578b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().Equals(instr->representation())); 1579b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->right()->representation().Equals(instr->representation())); 1580b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->representation().IsSmi()) { 1581b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch left = UseRegisterAtStart(instr->BetterLeftOperand()); 1582b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch right = UseAtStart(instr->BetterRightOperand()); 1583b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else if (instr->representation().IsInteger32()) { 1584b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch left = UseRegisterAtStart(instr->BetterLeftOperand()); 1585b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch right = UseOrConstantAtStart(instr->BetterRightOperand()); 1586b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 1587b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->representation().IsDouble()); 1588b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch left = UseRegisterAtStart(instr->left()); 1589b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch right = UseRegisterAtStart(instr->right()); 1590b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1591b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LMathMinMax* minmax = new(zone()) LMathMinMax(left, right); 1592b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineSameAsFirst(minmax); 1593b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 1594b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1595b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1596b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoPower(HPower* instr) { 1597b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->representation().IsDouble()); 1598e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch // We call a C function for double power. It can't trigger a GC. 1599e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch // We need to use fixed result register for the call. 1600e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch Representation exponent_type = instr->right()->representation(); 1601b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().IsDouble()); 1602e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch LOperand* left = UseFixedDouble(instr->left(), xmm2); 1603b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* right = 1604b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch exponent_type.IsDouble() 1605b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch ? UseFixedDouble(instr->right(), xmm1) 1606b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch : UseFixed(instr->right(), MathPowTaggedDescriptor::exponent()); 16073ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LPower* result = new(zone()) LPower(left, right); 16083ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return MarkAsCall(DefineFixedDouble(result, xmm3), instr, 1609e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch CAN_DEOPTIMIZE_EAGERLY); 1610b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1611b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1612b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 16133fb3ca8c7ca439d408449a395897395c0faae8d1Ben MurdochLInstruction* LChunkBuilder::DoCompareGeneric(HCompareGeneric* instr) { 1614b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().IsTagged()); 1615b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->right()->representation().IsTagged()); 1616b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseFixed(instr->context(), rsi); 16173ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* left = UseFixed(instr->left(), rdx); 16183ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* right = UseFixed(instr->right(), rax); 1619b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LCmpT* result = new(zone()) LCmpT(context, left, right); 16203fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch return MarkAsCall(DefineFixed(result, rax), instr); 16213fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch} 16223fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch 16233fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch 1624b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoCompareNumericAndBranch( 1625b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch HCompareNumericAndBranch* instr) { 1626b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch Representation r = instr->representation(); 1627b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (r.IsSmiOrInteger32()) { 1628b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().Equals(r)); 1629b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->right()->representation().Equals(r)); 16303ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* left = UseRegisterOrConstantAtStart(instr->left()); 16311e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block LOperand* right = UseOrConstantAtStart(instr->right()); 1632b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return new(zone()) LCompareNumericAndBranch(left, right); 16333fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch } else { 1634b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(r.IsDouble()); 1635b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().IsDouble()); 1636b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->right()->representation().IsDouble()); 16373ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* left; 16383ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* right; 16393ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch if (instr->left()->IsConstant() && instr->right()->IsConstant()) { 16403ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch left = UseRegisterOrConstantAtStart(instr->left()); 16413ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch right = UseRegisterOrConstantAtStart(instr->right()); 16423ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch } else { 16433ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch left = UseRegisterAtStart(instr->left()); 16443ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch right = UseRegisterAtStart(instr->right()); 16453ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch } 1646b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return new(zone()) LCompareNumericAndBranch(left, right); 16471e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } 1648b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1649b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1650b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 16513fb3ca8c7ca439d408449a395897395c0faae8d1Ben MurdochLInstruction* LChunkBuilder::DoCompareObjectEqAndBranch( 16523fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch HCompareObjectEqAndBranch* instr) { 16531e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block LOperand* left = UseRegisterAtStart(instr->left()); 1654b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* right = UseRegisterOrConstantAtStart(instr->right()); 16553ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return new(zone()) LCmpObjectEqAndBranch(left, right); 1656b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1657b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1658b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1659b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoCompareHoleAndBranch( 1660b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch HCompareHoleAndBranch* instr) { 16613ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* value = UseRegisterAtStart(instr->value()); 1662b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return new(zone()) LCmpHoleAndBranch(value); 1663257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch} 1664257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch 1665257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch 16663ef787dbeca8a5fb1086949cda830dccee07bfbdBen MurdochLInstruction* LChunkBuilder::DoIsStringAndBranch(HIsStringAndBranch* instr) { 1667b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->value()->representation().IsTagged()); 16683ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* value = UseRegisterAtStart(instr->value()); 16693ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* temp = TempRegister(); 16703ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return new(zone()) LIsStringAndBranch(value, temp); 1671592a9fc1d8ea420377a2e7efd0600e20b058be2bBen Murdoch} 1672592a9fc1d8ea420377a2e7efd0600e20b058be2bBen Murdoch 1673592a9fc1d8ea420377a2e7efd0600e20b058be2bBen Murdoch 16743fb3ca8c7ca439d408449a395897395c0faae8d1Ben MurdochLInstruction* LChunkBuilder::DoIsSmiAndBranch(HIsSmiAndBranch* instr) { 1675b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->value()->representation().IsTagged()); 16763ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return new(zone()) LIsSmiAndBranch(Use(instr->value())); 1677b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1678b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1679b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 16803fb3ca8c7ca439d408449a395897395c0faae8d1Ben MurdochLInstruction* LChunkBuilder::DoIsUndetectableAndBranch( 16813fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch HIsUndetectableAndBranch* instr) { 1682b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->value()->representation().IsTagged()); 16833ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* value = UseRegisterAtStart(instr->value()); 16843ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* temp = TempRegister(); 16853ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return new(zone()) LIsUndetectableAndBranch(value, temp); 16863ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch} 16873ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 16883ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 16893ef787dbeca8a5fb1086949cda830dccee07bfbdBen MurdochLInstruction* LChunkBuilder::DoStringCompareAndBranch( 16903ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch HStringCompareAndBranch* instr) { 16913ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 1692b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->left()->representation().IsTagged()); 1693b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->right()->representation().IsTagged()); 1694b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseFixed(instr->context(), rsi); 16953ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* left = UseFixed(instr->left(), rdx); 16963ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* right = UseFixed(instr->right(), rax); 16973ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LStringCompareAndBranch* result = 1698b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch new(zone()) LStringCompareAndBranch(context, left, right); 16993ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 17003ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return MarkAsCall(result, instr); 1701592a9fc1d8ea420377a2e7efd0600e20b058be2bBen Murdoch} 1702592a9fc1d8ea420377a2e7efd0600e20b058be2bBen Murdoch 1703592a9fc1d8ea420377a2e7efd0600e20b058be2bBen Murdoch 17043fb3ca8c7ca439d408449a395897395c0faae8d1Ben MurdochLInstruction* LChunkBuilder::DoHasInstanceTypeAndBranch( 17053fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch HHasInstanceTypeAndBranch* instr) { 1706b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->value()->representation().IsTagged()); 17073ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* value = UseRegisterAtStart(instr->value()); 17083ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return new(zone()) LHasInstanceTypeAndBranch(value); 1709e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch} 1710e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch 1711e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch 1712e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen MurdochLInstruction* LChunkBuilder::DoGetCachedArrayIndex( 1713e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch HGetCachedArrayIndex* instr) { 1714b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->value()->representation().IsTagged()); 1715e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch LOperand* value = UseRegisterAtStart(instr->value()); 1716e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch 17173ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return DefineAsRegister(new(zone()) LGetCachedArrayIndex(value)); 1718b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1719b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1720b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 17213fb3ca8c7ca439d408449a395897395c0faae8d1Ben MurdochLInstruction* LChunkBuilder::DoHasCachedArrayIndexAndBranch( 17223fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch HHasCachedArrayIndexAndBranch* instr) { 1723b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->value()->representation().IsTagged()); 17243ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* value = UseRegisterAtStart(instr->value()); 17253ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return new(zone()) LHasCachedArrayIndexAndBranch(value); 1726b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1727b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1728b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 17293fb3ca8c7ca439d408449a395897395c0faae8d1Ben MurdochLInstruction* LChunkBuilder::DoClassOfTestAndBranch( 17303fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch HClassOfTestAndBranch* instr) { 17313ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* value = UseRegister(instr->value()); 17323ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return new(zone()) LClassOfTestAndBranch(value, 17333ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch TempRegister(), 17343ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch TempRegister()); 1735b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1736b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1737b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1738b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoSeqStringGetChar(HSeqStringGetChar* instr) { 1739b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* string = UseRegisterAtStart(instr->string()); 1740b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* index = UseRegisterOrConstantAtStart(instr->index()); 1741b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineAsRegister(new(zone()) LSeqStringGetChar(string, index)); 17423fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch} 17433fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch 17443fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch 1745b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoSeqStringSetChar(HSeqStringSetChar* instr) { 1746b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* string = UseRegisterAtStart(instr->string()); 1747b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* index = FLAG_debug_code 1748b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch ? UseRegisterAtStart(instr->index()) 1749b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch : UseRegisterOrConstantAtStart(instr->index()); 1750b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* value = FLAG_debug_code 1751b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch ? UseRegisterAtStart(instr->value()) 1752b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch : UseRegisterOrConstantAtStart(instr->value()); 1753b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = FLAG_debug_code ? UseFixed(instr->context(), rsi) : NULL; 1754b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = new(zone()) LSeqStringSetChar(context, string, 1755b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch index, value); 1756b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (FLAG_debug_code) { 1757b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch result = MarkAsCall(result, instr); 1758b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1759b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 17603ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch} 17613ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 17623ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 1763b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) { 1764b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (!FLAG_debug_code && instr->skip_check()) return NULL; 1765b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* index = UseRegisterOrConstantAtStart(instr->index()); 1766b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* length = !index->IsConstantOperand() 1767b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch ? UseOrConstantAtStart(instr->length()) 1768b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch : UseAtStart(instr->length()); 1769b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = new(zone()) LBoundsCheck(index, length); 1770b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (!FLAG_debug_code || !instr->skip_check()) { 1771b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch result = AssignEnvironment(result); 1772b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1773b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 17745d4cdbf7a67d3662fa0bee4efdb7edd8daec9b0bBen Murdoch} 17755d4cdbf7a67d3662fa0bee4efdb7edd8daec9b0bBen Murdoch 17765d4cdbf7a67d3662fa0bee4efdb7edd8daec9b0bBen Murdoch 17771e0659c275bb392c045087af4f6b0d7565cb3d77Steve BlockLInstruction* LChunkBuilder::DoAbnormalExit(HAbnormalExit* instr) { 17781e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block // The control instruction marking the end of a block that completed 17791e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block // abruptly (e.g., threw an exception). There is nothing specific to do. 1780b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return NULL; 1781b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1782b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1783b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 17843fb3ca8c7ca439d408449a395897395c0faae8d1Ben MurdochLInstruction* LChunkBuilder::DoUseConst(HUseConst* instr) { 17853fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch return NULL; 17863fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch} 17873fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch 17883fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch 1789257744e915dfc84d6d07a6b2accf8402d9ffc708Ben MurdochLInstruction* LChunkBuilder::DoForceRepresentation(HForceRepresentation* bad) { 1790257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch // All HForceRepresentation instructions should be eliminated in the 1791257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch // representation change phase of Hydrogen. 1792257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch UNREACHABLE(); 1793257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch return NULL; 1794257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch} 1795257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch 1796257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch 1797b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoChange(HChange* instr) { 17981e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block Representation from = instr->from(); 17991e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block Representation to = instr->to(); 1800b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch HValue* val = instr->value(); 1801b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (from.IsSmi()) { 1802b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (to.IsTagged()) { 1803b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* value = UseRegister(val); 1804b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineSameAsFirst(new(zone()) LDummyUse(value)); 1805b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1806b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch from = Representation::Tagged(); 1807b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 18081e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block if (from.IsTagged()) { 18091e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block if (to.IsDouble()) { 1810b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* value = UseRegister(val); 1811b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = DefineAsRegister(new(zone()) LNumberUntagD(value)); 1812b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (!val->representation().IsSmi()) result = AssignEnvironment(result); 1813b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 1814b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else if (to.IsSmi()) { 1815b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* value = UseRegister(val); 1816b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (val->type().IsSmi()) { 1817b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineSameAsFirst(new(zone()) LDummyUse(value)); 1818b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1819b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return AssignEnvironment(DefineSameAsFirst(new(zone()) LCheckSmi(value))); 18201e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } else { 1821b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(to.IsInteger32()); 1822b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (val->type().IsSmi() || val->representation().IsSmi()) { 1823b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* value = UseRegister(val); 1824b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineSameAsFirst(new(zone()) LSmiUntag(value, false)); 1825b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 1826b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* value = UseRegister(val); 18273fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch bool truncating = instr->CanTruncateToInt32(); 18283fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch LOperand* xmm_temp = truncating ? NULL : FixedTemp(xmm1); 1829b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = 1830b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DefineSameAsFirst(new(zone()) LTaggedToI(value, xmm_temp)); 1831b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (!val->representation().IsSmi()) result = AssignEnvironment(result); 1832b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 18331e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } 18341e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } 18351e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } else if (from.IsDouble()) { 18361e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block if (to.IsTagged()) { 1837b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch info()->MarkAsDeferredCalling(); 1838b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* value = UseRegister(val); 18391e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block LOperand* temp = TempRegister(); 18401e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block LUnallocated* result_temp = TempRegister(); 18413ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LNumberTagD* result = new(zone()) LNumberTagD(value, temp); 18421e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block return AssignPointerMap(Define(result, result_temp)); 1843b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else if (to.IsSmi()) { 1844b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* value = UseRegister(val); 1845b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return AssignEnvironment( 1846b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DefineAsRegister(new(zone()) LDoubleToSmi(value))); 18471e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } else { 1848b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(to.IsInteger32()); 1849b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* value = UseRegister(val); 1850b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = DefineAsRegister(new(zone()) LDoubleToI(value)); 1851b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (!instr->CanTruncateToInt32()) result = AssignEnvironment(result); 1852b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 18531e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } 18541e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } else if (from.IsInteger32()) { 1855b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch info()->MarkAsDeferredCalling(); 18561e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block if (to.IsTagged()) { 1857b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (!instr->CheckFlag(HValue::kCanOverflow)) { 1858b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* value = UseRegister(val); 1859b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineAsRegister(new(zone()) LSmiTag(value)); 1860b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else if (val->CheckFlag(HInstruction::kUint32)) { 1861b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* value = UseRegister(val); 1862b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* temp1 = TempRegister(); 1863b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* temp2 = FixedTemp(xmm1); 1864b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LNumberTagU* result = new(zone()) LNumberTagU(value, temp1, temp2); 1865b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return AssignPointerMap(DefineSameAsFirst(result)); 18661e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } else { 1867b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* value = UseRegister(val); 1868b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* temp1 = SmiValuesAre32Bits() ? NULL : TempRegister(); 1869b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* temp2 = SmiValuesAre32Bits() ? NULL : FixedTemp(xmm1); 1870b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LNumberTagI* result = new(zone()) LNumberTagI(value, temp1, temp2); 1871b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return AssignPointerMap(DefineSameAsFirst(result)); 18721e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } 1873b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else if (to.IsSmi()) { 1874b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* value = UseRegister(val); 1875b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = DefineAsRegister(new(zone()) LSmiTag(value)); 1876b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->CheckFlag(HValue::kCanOverflow)) { 1877b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch result = AssignEnvironment(result); 1878b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1879b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 18801e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } else { 1881b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(to.IsDouble()); 1882b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (val->CheckFlag(HInstruction::kUint32)) { 1883b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineAsRegister(new(zone()) LUint32ToDouble(UseRegister(val))); 1884b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 1885b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* value = Use(val); 1886b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineAsRegister(new(zone()) LInteger32ToDouble(value)); 1887b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 18881e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } 18891e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block } 18901e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block UNREACHABLE(); 1891b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return NULL; 1892b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1893b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1894b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1895b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoCheckHeapObject(HCheckHeapObject* instr) { 18961e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block LOperand* value = UseRegisterAtStart(instr->value()); 1897b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = new(zone()) LCheckNonSmi(value); 1898b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (!instr->value()->type().IsHeapObject()) { 1899b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch result = AssignEnvironment(result); 1900b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1901b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 1902b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1903b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1904b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1905b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoCheckSmi(HCheckSmi* instr) { 19061e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block LOperand* value = UseRegisterAtStart(instr->value()); 1907b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return AssignEnvironment(new(zone()) LCheckSmi(value)); 1908b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1909b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1910b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1911014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochLInstruction* LChunkBuilder::DoCheckArrayBufferNotNeutered( 1912014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch HCheckArrayBufferNotNeutered* instr) { 1913014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LOperand* view = UseRegisterAtStart(instr->value()); 1914014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LCheckArrayBufferNotNeutered* result = 1915014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch new (zone()) LCheckArrayBufferNotNeutered(view); 1916014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return AssignEnvironment(result); 1917014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 1918014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 1919014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 1920b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoCheckInstanceType(HCheckInstanceType* instr) { 19211e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block LOperand* value = UseRegisterAtStart(instr->value()); 1922b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LCheckInstanceType* result = new(zone()) LCheckInstanceType(value); 1923b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return AssignEnvironment(result); 1924b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1925b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1926b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1927b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoCheckValue(HCheckValue* instr) { 19281e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block LOperand* value = UseRegisterAtStart(instr->value()); 1929b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return AssignEnvironment(new(zone()) LCheckValue(value)); 1930b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1931b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1932b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1933b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoCheckMaps(HCheckMaps* instr) { 1934b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->IsStabilityCheck()) return new(zone()) LCheckMaps; 19351e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block LOperand* value = UseRegisterAtStart(instr->value()); 1936b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = AssignEnvironment(new(zone()) LCheckMaps(value)); 1937b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->HasMigrationTarget()) { 1938b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch info()->MarkAsDeferredCalling(); 1939b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch result = AssignPointerMap(result); 1940b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 1941b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 1942b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1943b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1944b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1945257744e915dfc84d6d07a6b2accf8402d9ffc708Ben MurdochLInstruction* LChunkBuilder::DoClampToUint8(HClampToUint8* instr) { 1946257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch HValue* value = instr->value(); 1947257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch Representation input_rep = value->representation(); 1948257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch LOperand* reg = UseRegister(value); 1949257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch if (input_rep.IsDouble()) { 1950b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineAsRegister(new(zone()) LClampDToUint8(reg)); 1951257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch } else if (input_rep.IsInteger32()) { 19523ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return DefineSameAsFirst(new(zone()) LClampIToUint8(reg)); 1953257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch } else { 1954b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(input_rep.IsSmiOrTagged()); 1955257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch // Register allocator doesn't (yet) support allocation of double 1956257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch // temps. Reserve xmm1 explicitly. 19573ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LClampTToUint8* result = new(zone()) LClampTToUint8(reg, 19583ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch FixedTemp(xmm1)); 1959257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch return AssignEnvironment(DefineSameAsFirst(result)); 1960257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch } 1961257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch} 1962257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch 1963257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch 1964b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoDoubleBits(HDoubleBits* instr) { 1965b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch HValue* value = instr->value(); 1966b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(value->representation().IsDouble()); 1967b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineAsRegister(new(zone()) LDoubleBits(UseRegister(value))); 1968b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 1969b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1970b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1971b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoConstructDouble(HConstructDouble* instr) { 1972b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* lo = UseRegister(instr->lo()); 1973b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* hi = UseRegister(instr->hi()); 1974b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineAsRegister(new(zone()) LConstructDouble(hi, lo)); 1975b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 1976b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1977b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 1978b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoReturn(HReturn* instr) { 1979b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = info()->IsStub() ? UseFixed(instr->context(), rsi) : NULL; 1980b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* parameter_count = UseRegisterOrConstant(instr->parameter_count()); 1981b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return new(zone()) LReturn( 1982b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch UseFixed(instr->value(), rax), context, parameter_count); 1983b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 1984b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1985b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 1986b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoConstant(HConstant* instr) { 1987b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch Representation r = instr->representation(); 1988b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (r.IsSmi()) { 1989b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineAsRegister(new(zone()) LConstantS); 1990b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else if (r.IsInteger32()) { 19913ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return DefineAsRegister(new(zone()) LConstantI); 1992b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } else if (r.IsDouble()) { 1993014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return DefineAsRegister(new (zone()) LConstantD); 1994b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else if (r.IsExternal()) { 1995b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineAsRegister(new(zone()) LConstantE); 1996b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } else if (r.IsTagged()) { 19973ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return DefineAsRegister(new(zone()) LConstantT); 1998b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } else { 1999b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch UNREACHABLE(); 2000b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return NULL; 2001b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch } 2002b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2003b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2004b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 20058b112d2025046f85ef7f6be087c6129c872ebad2Ben MurdochLInstruction* LChunkBuilder::DoLoadGlobalGeneric(HLoadGlobalGeneric* instr) { 2006b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseFixed(instr->context(), rsi); 2007b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* global_object = 2008b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch UseFixed(instr->global_object(), LoadDescriptor::ReceiverRegister()); 2009b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* vector = NULL; 2010958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier if (instr->HasVectorAndSlot()) { 2011014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch vector = FixedTemp(LoadWithVectorDescriptor::VectorRegister()); 2012b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 2013b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 2014b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LLoadGlobalGeneric* result = 2015b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch new(zone()) LLoadGlobalGeneric(context, global_object, vector); 20168b112d2025046f85ef7f6be087c6129c872ebad2Ben Murdoch return MarkAsCall(DefineFixed(result, rax), instr); 20178b112d2025046f85ef7f6be087c6129c872ebad2Ben Murdoch} 20188b112d2025046f85ef7f6be087c6129c872ebad2Ben Murdoch 20198b112d2025046f85ef7f6be087c6129c872ebad2Ben Murdoch 2020b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoLoadContextSlot(HLoadContextSlot* instr) { 2021e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch LOperand* context = UseRegisterAtStart(instr->value()); 20223ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LInstruction* result = 20233ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch DefineAsRegister(new(zone()) LLoadContextSlot(context)); 2024b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->RequiresHoleCheck() && instr->DeoptimizesOnHole()) { 2025b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch result = AssignEnvironment(result); 2026b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 2027b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 2028b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2029b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2030b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 20311e0659c275bb392c045087af4f6b0d7565cb3d77Steve BlockLInstruction* LChunkBuilder::DoStoreContextSlot(HStoreContextSlot* instr) { 2032e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch LOperand* context; 2033e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch LOperand* value; 2034e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch LOperand* temp; 2035b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch context = UseRegister(instr->context()); 2036e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch if (instr->NeedsWriteBarrier()) { 2037e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch value = UseTempRegister(instr->value()); 2038e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch temp = TempRegister(); 2039e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch } else { 2040e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch value = UseRegister(instr->value()); 2041e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch temp = NULL; 2042e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch } 20433ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LInstruction* result = new(zone()) LStoreContextSlot(context, value, temp); 2044b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->RequiresHoleCheck() && instr->DeoptimizesOnHole()) { 2045b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch result = AssignEnvironment(result); 2046b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 2047b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 2048b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2049b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2050b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 20511e0659c275bb392c045087af4f6b0d7565cb3d77Steve BlockLInstruction* LChunkBuilder::DoLoadNamedField(HLoadNamedField* instr) { 2052b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // Use the special mov rax, moffs64 encoding for external 2053b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // memory accesses with 64-bit word-sized values. 2054b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->access().IsExternalMemory() && 2055b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->access().offset() == 0 && 2056b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch (instr->access().representation().IsSmi() || 2057b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->access().representation().IsTagged() || 2058b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->access().representation().IsHeapObject() || 2059b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->access().representation().IsExternal())) { 2060b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* obj = UseRegisterOrConstantAtStart(instr->object()); 2061b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineFixed(new(zone()) LLoadNamedField(obj), rax); 2062b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 20631e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block LOperand* obj = UseRegisterAtStart(instr->object()); 20643ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return DefineAsRegister(new(zone()) LLoadNamedField(obj)); 20651e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block} 20661e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block 20671e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block 2068b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoLoadNamedGeneric(HLoadNamedGeneric* instr) { 2069b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseFixed(instr->context(), rsi); 2070b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* object = 2071b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch UseFixed(instr->object(), LoadDescriptor::ReceiverRegister()); 2072b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* vector = NULL; 2073958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier if (instr->HasVectorAndSlot()) { 2074014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch vector = FixedTemp(LoadWithVectorDescriptor::VectorRegister()); 2075b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 2076b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LLoadNamedGeneric* result = new(zone()) LLoadNamedGeneric( 2077b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch context, object, vector); 20781e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block return MarkAsCall(DefineFixed(result, rax), instr); 2079b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2080b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2081b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2082b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoLoadFunctionPrototype( 2083b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch HLoadFunctionPrototype* instr) { 20841e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block return AssignEnvironment(DefineAsRegister( 20853ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch new(zone()) LLoadFunctionPrototype(UseRegister(instr->function())))); 2086b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2087b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2088b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2089b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoLoadRoot(HLoadRoot* instr) { 2090b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineAsRegister(new(zone()) LLoadRoot); 20911e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block} 20921e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block 20931e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block 2094b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochvoid LChunkBuilder::FindDehoistedKeyDefinitions(HValue* candidate) { 2095b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // We sign extend the dehoisted key at the definition point when the pointer 2096b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // size is 64-bit. For x32 port, we sign extend the dehoisted key at the use 2097b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // points and should not invoke this function. We can't use STATIC_ASSERT 2098b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // here as the pointer size is 32-bit for x32. 2099b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(kPointerSize == kInt64Size); 2100b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch BitVector* dehoisted_key_ids = chunk_->GetDehoistedKeyIds(); 2101b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (dehoisted_key_ids->Contains(candidate->id())) return; 2102b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch dehoisted_key_ids->Add(candidate->id()); 2103b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (!candidate->IsPhi()) return; 2104b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch for (int i = 0; i < candidate->OperandCount(); ++i) { 2105b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch FindDehoistedKeyDefinitions(candidate->OperandAt(i)); 2106b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 2107b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2108b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2109b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2110b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) { 2111b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK((kPointerSize == kInt64Size && 2112b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->key()->representation().IsInteger32()) || 2113b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch (kPointerSize == kInt32Size && 2114b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->key()->representation().IsSmiOrInteger32())); 2115b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch ElementsKind elements_kind = instr->elements_kind(); 2116b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* key = NULL; 2117b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = NULL; 21181e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block 2119b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (kPointerSize == kInt64Size) { 2120b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch key = UseRegisterOrConstantAtStart(instr->key()); 2121b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 2122b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch bool clobbers_key = ExternalArrayOpRequiresTemp( 2123b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->key()->representation(), elements_kind); 2124b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch key = clobbers_key 2125b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch ? UseTempRegister(instr->key()) 2126b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch : UseRegisterOrConstantAtStart(instr->key()); 2127b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 21281e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block 2129b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if ((kPointerSize == kInt64Size) && instr->IsDehoisted()) { 2130b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch FindDehoistedKeyDefinitions(instr->key()); 2131b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 21323fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch 2133014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch if (!instr->is_fixed_typed_array()) { 2134b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* obj = UseRegisterAtStart(instr->elements()); 2135014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch result = DefineAsRegister(new (zone()) LLoadKeyed(obj, key, nullptr)); 2136b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 2137b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK( 2138b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch (instr->representation().IsInteger32() && 2139b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch !(IsDoubleOrFloatElementsKind(elements_kind))) || 2140b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch (instr->representation().IsDouble() && 2141b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch (IsDoubleOrFloatElementsKind(elements_kind)))); 2142b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* backing_store = UseRegister(instr->elements()); 2143014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LOperand* backing_store_owner = UseAny(instr->backing_store_owner()); 2144014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch result = DefineAsRegister( 2145014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch new (zone()) LLoadKeyed(backing_store, key, backing_store_owner)); 2146014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch } 2147014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 2148014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch bool needs_environment; 2149014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch if (instr->is_fixed_typed_array()) { 2150014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // see LCodeGen::DoLoadKeyedExternalArray 2151014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch needs_environment = elements_kind == UINT32_ELEMENTS && 2152014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch !instr->CheckFlag(HInstruction::kUint32); 2153014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch } else { 2154014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // see LCodeGen::DoLoadKeyedFixedDoubleArray and 2155014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // LCodeGen::DoLoadKeyedFixedArray 2156014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch needs_environment = 2157014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch instr->RequiresHoleCheck() || 2158014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch (instr->hole_mode() == CONVERT_HOLE_TO_UNDEFINED && info()->IsStub()); 2159b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 21603fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch 2161014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch if (needs_environment) { 2162b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch result = AssignEnvironment(result); 2163b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 2164b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 2165b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2166b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2167b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2168b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) { 2169b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseFixed(instr->context(), rsi); 2170b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* object = 2171b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch UseFixed(instr->object(), LoadDescriptor::ReceiverRegister()); 2172b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* key = UseFixed(instr->key(), LoadDescriptor::NameRegister()); 2173b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* vector = NULL; 2174958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier if (instr->HasVectorAndSlot()) { 2175014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch vector = FixedTemp(LoadWithVectorDescriptor::VectorRegister()); 2176b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 2177e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch 2178b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LLoadKeyedGeneric* result = 2179b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch new(zone()) LLoadKeyedGeneric(context, object, key, vector); 2180e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch return MarkAsCall(DefineFixed(result, rax), instr); 2181b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2182b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2183b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2184b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { 2185b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch ElementsKind elements_kind = instr->elements_kind(); 21863fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch 2187b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if ((kPointerSize == kInt64Size) && instr->IsDehoisted()) { 2188b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch FindDehoistedKeyDefinitions(instr->key()); 2189b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 21903fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch 2191014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch if (!instr->is_fixed_typed_array()) { 2192b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->elements()->representation().IsTagged()); 2193b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch bool needs_write_barrier = instr->NeedsWriteBarrier(); 2194b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* object = NULL; 2195b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* key = NULL; 2196b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* val = NULL; 2197b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 2198b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch Representation value_representation = instr->value()->representation(); 2199b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (value_representation.IsDouble()) { 2200b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch object = UseRegisterAtStart(instr->elements()); 2201b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch val = UseRegisterAtStart(instr->value()); 2202b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch key = UseRegisterOrConstantAtStart(instr->key()); 2203b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 2204b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(value_representation.IsSmiOrTagged() || 2205b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch value_representation.IsInteger32()); 2206b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (needs_write_barrier) { 2207b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch object = UseTempRegister(instr->elements()); 2208b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch val = UseTempRegister(instr->value()); 2209b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch key = UseTempRegister(instr->key()); 2210b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 2211b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch object = UseRegisterAtStart(instr->elements()); 2212b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch val = UseRegisterOrConstantAtStart(instr->value()); 2213b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch key = UseRegisterOrConstantAtStart(instr->key()); 2214b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 2215b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 22163fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch 2217014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return new (zone()) LStoreKeyed(object, key, val, nullptr); 2218b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 22193fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch 2220b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK( 2221b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch (instr->value()->representation().IsInteger32() && 2222b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch !IsDoubleOrFloatElementsKind(elements_kind)) || 2223b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch (instr->value()->representation().IsDouble() && 2224b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch IsDoubleOrFloatElementsKind(elements_kind))); 2225014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch DCHECK(instr->elements()->representation().IsExternal()); 2226014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch bool val_is_temp_register = elements_kind == UINT8_CLAMPED_ELEMENTS || 2227014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch elements_kind == FLOAT32_ELEMENTS; 2228b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* val = val_is_temp_register ? UseTempRegister(instr->value()) 22298b112d2025046f85ef7f6be087c6129c872ebad2Ben Murdoch : UseRegister(instr->value()); 2230b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* key = NULL; 2231b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (kPointerSize == kInt64Size) { 2232b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch key = UseRegisterOrConstantAtStart(instr->key()); 2233b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 2234b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch bool clobbers_key = ExternalArrayOpRequiresTemp( 2235b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->key()->representation(), elements_kind); 2236b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch key = clobbers_key 2237b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch ? UseTempRegister(instr->key()) 2238b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch : UseRegisterOrConstantAtStart(instr->key()); 2239b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 2240b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* backing_store = UseRegister(instr->elements()); 2241014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LOperand* backing_store_owner = UseAny(instr->backing_store_owner()); 2242014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return new (zone()) LStoreKeyed(backing_store, key, val, backing_store_owner); 2243e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch} 2244e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch 2245e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch 2246b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) { 2247b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseFixed(instr->context(), rsi); 2248b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* object = 2249b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch UseFixed(instr->object(), StoreDescriptor::ReceiverRegister()); 2250b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* key = UseFixed(instr->key(), StoreDescriptor::NameRegister()); 2251b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* value = UseFixed(instr->value(), StoreDescriptor::ValueRegister()); 2252e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch 2253b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->object()->representation().IsTagged()); 2254b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->key()->representation().IsTagged()); 2255b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->value()->representation().IsTagged()); 2256e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch 2257014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LOperand* slot = NULL; 2258014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LOperand* vector = NULL; 2259014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch if (instr->HasVectorAndSlot()) { 2260014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch slot = FixedTemp(VectorStoreICDescriptor::SlotRegister()); 2261014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch vector = FixedTemp(VectorStoreICDescriptor::VectorRegister()); 2262014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch } 2263014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 2264014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LStoreKeyedGeneric* result = new (zone()) 2265014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LStoreKeyedGeneric(context, object, key, value, slot, vector); 2266e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch return MarkAsCall(result, instr); 2267b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2268b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2269b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 22703ef787dbeca8a5fb1086949cda830dccee07bfbdBen MurdochLInstruction* LChunkBuilder::DoTransitionElementsKind( 22713ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch HTransitionElementsKind* instr) { 2272b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (IsSimpleMapChangeTransition(instr->from_kind(), instr->to_kind())) { 22733ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* object = UseRegister(instr->object()); 22743ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* new_map_reg = TempRegister(); 22753ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* temp_reg = TempRegister(); 2276b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LTransitionElementsKind* result = new(zone()) LTransitionElementsKind( 2277b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch object, NULL, new_map_reg, temp_reg); 2278b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return result; 22793ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch } else { 22803ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* object = UseFixed(instr->object(), rax); 2281b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseFixed(instr->context(), rsi); 22823ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LTransitionElementsKind* result = 2283b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch new(zone()) LTransitionElementsKind(object, context, NULL, NULL); 2284b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return MarkAsCall(result, instr); 22853ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch } 22863ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch} 22873ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 22883ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 2289b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoTrapAllocationMemento( 2290b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch HTrapAllocationMemento* instr) { 2291b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* object = UseRegister(instr->object()); 2292b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* temp = TempRegister(); 2293b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LTrapAllocationMemento* result = 2294b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch new(zone()) LTrapAllocationMemento(object, temp); 2295b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return AssignEnvironment(result); 2296b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 2297b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 2298b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 2299014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochLInstruction* LChunkBuilder::DoMaybeGrowElements(HMaybeGrowElements* instr) { 2300014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch info()->MarkAsDeferredCalling(); 2301014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LOperand* context = UseFixed(instr->context(), rsi); 2302014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LOperand* object = Use(instr->object()); 2303014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LOperand* elements = Use(instr->elements()); 2304014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LOperand* key = UseRegisterOrConstant(instr->key()); 2305014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LOperand* current_capacity = UseRegisterOrConstant(instr->current_capacity()); 2306014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 2307014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LMaybeGrowElements* result = new (zone()) 2308014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LMaybeGrowElements(context, object, elements, key, current_capacity); 2309014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch DefineFixed(result, rax); 2310014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return AssignPointerMap(AssignEnvironment(result)); 2311014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 2312014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 2313014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 2314b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { 2315b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch bool is_in_object = instr->access().IsInobject(); 2316b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch bool is_external_location = instr->access().IsExternalMemory() && 2317b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->access().offset() == 0; 23181e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block bool needs_write_barrier = instr->NeedsWriteBarrier(); 2319b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch bool needs_write_barrier_for_map = instr->has_transition() && 2320b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->NeedsWriteBarrierForMap(); 2321b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 2322b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* obj; 2323b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (needs_write_barrier) { 2324b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch obj = is_in_object 2325b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch ? UseRegister(instr->object()) 2326b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch : UseTempRegister(instr->object()); 2327b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else if (is_external_location) { 2328b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(!is_in_object); 2329b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(!needs_write_barrier); 2330b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(!needs_write_barrier_for_map); 2331b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch obj = UseRegisterOrConstant(instr->object()); 2332b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 2333b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch obj = needs_write_barrier_for_map 2334b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch ? UseRegister(instr->object()) 2335b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch : UseRegisterAtStart(instr->object()); 2336b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 23371e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block 2338b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch bool can_be_constant = instr->value()->IsConstant() && 2339b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch HConstant::cast(instr->value())->NotInNewSpace() && 2340b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch !instr->field_representation().IsDouble(); 2341b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 2342b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* val; 2343b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (needs_write_barrier) { 2344b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch val = UseTempRegister(instr->value()); 2345b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else if (is_external_location) { 2346b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch val = UseFixed(instr->value(), rax); 2347b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else if (can_be_constant) { 2348b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch val = UseRegisterOrConstant(instr->value()); 2349b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else if (instr->field_representation().IsDouble()) { 2350b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch val = UseRegisterAtStart(instr->value()); 2351b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 2352b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch val = UseRegister(instr->value()); 2353b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 23541e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block 23551e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block // We only need a scratch register if we have a write barrier or we 23561e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block // have a store into the properties array (not in-object-property). 2357b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* temp = (!is_in_object || needs_write_barrier || 2358b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch needs_write_barrier_for_map) ? TempRegister() : NULL; 23591e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block 23603ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return new(zone()) LStoreNamedField(obj, val, temp); 2361b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2362b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2363b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2364b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoStoreNamedGeneric(HStoreNamedGeneric* instr) { 2365b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseFixed(instr->context(), rsi); 2366b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* object = 2367b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch UseFixed(instr->object(), StoreDescriptor::ReceiverRegister()); 2368b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* value = UseFixed(instr->value(), StoreDescriptor::ValueRegister()); 2369014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LOperand* slot = NULL; 2370014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LOperand* vector = NULL; 2371014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch if (instr->HasVectorAndSlot()) { 2372014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch slot = FixedTemp(VectorStoreICDescriptor::SlotRegister()); 2373014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch vector = FixedTemp(VectorStoreICDescriptor::VectorRegister()); 2374014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch } 2375e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch 2376b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LStoreNamedGeneric* result = 2377014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch new (zone()) LStoreNamedGeneric(context, object, value, slot, vector); 2378e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch return MarkAsCall(result, instr); 2379b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2380b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2381b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2382257744e915dfc84d6d07a6b2accf8402d9ffc708Ben MurdochLInstruction* LChunkBuilder::DoStringAdd(HStringAdd* instr) { 2383b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseFixed(instr->context(), rsi); 2384b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* left = UseFixed(instr->left(), rdx); 2385b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* right = UseFixed(instr->right(), rax); 2386b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return MarkAsCall( 2387b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DefineFixed(new(zone()) LStringAdd(context, left, right), rax), instr); 2388257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch} 2389257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch 2390257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch 23911e0659c275bb392c045087af4f6b0d7565cb3d77Steve BlockLInstruction* LChunkBuilder::DoStringCharCodeAt(HStringCharCodeAt* instr) { 239269a99ed0b2b2ef69d393c371b03db3a98aaf880eBen Murdoch LOperand* string = UseTempRegister(instr->string()); 239369a99ed0b2b2ef69d393c371b03db3a98aaf880eBen Murdoch LOperand* index = UseTempRegister(instr->index()); 2394b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseAny(instr->context()); 2395b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LStringCharCodeAt* result = 2396b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch new(zone()) LStringCharCodeAt(context, string, index); 2397b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return AssignPointerMap(DefineAsRegister(result)); 2398b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2399b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2400b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 240144f0eee88ff00398ff7f715fab053374d808c90dSteve BlockLInstruction* LChunkBuilder::DoStringCharFromCode(HStringCharFromCode* instr) { 240244f0eee88ff00398ff7f715fab053374d808c90dSteve Block LOperand* char_code = UseRegister(instr->value()); 2403b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseAny(instr->context()); 2404b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LStringCharFromCode* result = 2405b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch new(zone()) LStringCharFromCode(context, char_code); 240644f0eee88ff00398ff7f715fab053374d808c90dSteve Block return AssignPointerMap(DefineAsRegister(result)); 240744f0eee88ff00398ff7f715fab053374d808c90dSteve Block} 240844f0eee88ff00398ff7f715fab053374d808c90dSteve Block 240944f0eee88ff00398ff7f715fab053374d808c90dSteve Block 2410b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoAllocate(HAllocate* instr) { 2411b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch info()->MarkAsDeferredCalling(); 2412b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseAny(instr->context()); 2413b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* size = instr->size()->IsConstant() 2414b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch ? UseConstant(instr->size()) 2415b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch : UseTempRegister(instr->size()); 2416b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* temp = TempRegister(); 2417b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LAllocate* result = new(zone()) LAllocate(context, size, temp); 24183ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return AssignPointerMap(DefineAsRegister(result)); 24193ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch} 24203ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 24213ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 2422b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoOsrEntry(HOsrEntry* instr) { 2423b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(argument_count_ == 0); 2424e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch allocator_->MarkAsOsrEntry(); 2425e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch current_block_->last_environment()->set_ast_id(instr->ast_id()); 24263ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return AssignEnvironment(new(zone()) LOsrEntry); 2427b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2428b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2429b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2430b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoParameter(HParameter* instr) { 2431b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LParameter* result = new(zone()) LParameter; 2432b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->kind() == HParameter::STACK_PARAMETER) { 2433b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch int spill_index = chunk()->GetParameterStackSlot(instr->index()); 2434b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineAsSpilled(result, spill_index); 2435b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 2436b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(info()->IsStub()); 2437342c50ce1624b485728b9a4fc41d8bbf37eb46cfBen Murdoch CallInterfaceDescriptor descriptor = graph()->descriptor(); 2438b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch int index = static_cast<int>(instr->index()); 2439014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Register reg = descriptor.GetRegisterParameter(index); 2440b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineFixed(result, reg); 2441b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 2442b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2443b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2444b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2445b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) { 2446b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // Use an index that corresponds to the location in the unoptimized frame, 2447b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // which the optimized frame will subsume. 2448b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch int env_index = instr->index(); 2449b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch int spill_index = 0; 2450b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->environment()->is_parameter_index(env_index)) { 2451b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch spill_index = chunk()->GetParameterStackSlot(env_index); 2452b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 2453b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch spill_index = env_index - instr->environment()->first_local_index(); 2454b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (spill_index > LUnallocated::kMaxFixedSlotIndex) { 2455b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch Retry(kTooManySpillSlotsNeededForOSR); 2456b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch spill_index = 0; 2457b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 2458342c50ce1624b485728b9a4fc41d8bbf37eb46cfBen Murdoch spill_index += StandardFrameConstants::kFixedSlotCount; 24597d3e7fc4b65010eabe860313ee0c64f50843f6e3Ben Murdoch } 24603ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return DefineAsSpilled(new(zone()) LUnknownOSRValue, spill_index); 2461b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2462b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2463b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2464b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) { 2465e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch // There are no real uses of the arguments object. 2466e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch // arguments.length and element access are supported directly on 2467e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch // stack arguments, and any real arguments object use causes a bailout. 2468e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch // So this value is never used. 2469b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return NULL; 2470b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2471b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2472b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2473b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochLInstruction* LChunkBuilder::DoCapturedObject(HCapturedObject* instr) { 2474b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->ReplayEnvironment(current_block_->last_environment()); 2475b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 2476b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // There are no real uses of a captured object. 2477b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return NULL; 2478b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 2479b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 2480b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 2481b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) { 2482b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch info()->MarkAsRequiresFrame(); 2483b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* args = UseRegister(instr->arguments()); 2484b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* length; 2485b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* index; 2486b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->length()->IsConstant() && instr->index()->IsConstant()) { 2487b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch length = UseRegisterOrConstant(instr->length()); 2488b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch index = UseOrConstant(instr->index()); 2489b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 2490b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch length = UseTempRegister(instr->length()); 2491b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch index = Use(instr->index()); 2492b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 2493b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return DefineAsRegister(new(zone()) LAccessArgumentsAt(args, length, index)); 2494b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2495b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2496b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2497b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoTypeof(HTypeof* instr) { 2498b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseFixed(instr->context(), rsi); 2499014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch LOperand* value = UseFixed(instr->value(), rbx); 2500b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LTypeof* result = new(zone()) LTypeof(context, value); 2501e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch return MarkAsCall(DefineFixed(result, rax), instr); 2502b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2503b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2504b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 25053fb3ca8c7ca439d408449a395897395c0faae8d1Ben MurdochLInstruction* LChunkBuilder::DoTypeofIsAndBranch(HTypeofIsAndBranch* instr) { 25063ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return new(zone()) LTypeofIsAndBranch(UseTempRegister(instr->value())); 2507b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2508b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 25091e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block 2510b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) { 2511b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch instr->ReplayEnvironment(current_block_->last_environment()); 2512b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return NULL; 2513b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2514b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2515b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2516b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { 2517b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch info()->MarkAsDeferredCalling(); 25183fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch if (instr->is_function_entry()) { 2519b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseFixed(instr->context(), rsi); 2520b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return MarkAsCall(new(zone()) LStackCheck(context), instr); 25213fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch } else { 2522b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->is_backwards_branch()); 2523b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseAny(instr->context()); 2524b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return AssignEnvironment( 2525b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch AssignPointerMap(new(zone()) LStackCheck(context))); 25263fb3ca8c7ca439d408449a395897395c0faae8d1Ben Murdoch } 2527b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2528b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2529b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2530b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) { 25311e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block HEnvironment* outer = current_block_->last_environment(); 2532b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch outer->set_ast_id(instr->ReturnId()); 25331e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block HConstant* undefined = graph()->GetConstantUndefined(); 25341b268ca467c924004286c97bac133db489cf43d0Ben Murdoch HEnvironment* inner = outer->CopyForInlining( 25351b268ca467c924004286c97bac133db489cf43d0Ben Murdoch instr->closure(), instr->arguments_count(), instr->function(), undefined, 25361b268ca467c924004286c97bac133db489cf43d0Ben Murdoch instr->inlining_kind(), instr->syntactic_tail_call_mode()); 2537b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // Only replay binding of arguments object if it wasn't removed from graph. 2538b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (instr->arguments_var() != NULL && instr->arguments_object()->IsLinked()) { 2539b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch inner->Bind(instr->arguments_var(), instr->arguments_object()); 25403ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch } 2541b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch inner->BindContext(instr->closure_context()); 2542b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch inner->set_entry(instr); 25431e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block current_block_->UpdateEnvironment(inner); 2544014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch chunk_->AddInlinedFunction(instr->shared()); 2545b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch return NULL; 2546b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch} 2547b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2548b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2549b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben MurdochLInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { 2550b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* pop = NULL; 2551b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 2552b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch HEnvironment* env = current_block_->last_environment(); 2553b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 2554b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (env->entry()->arguments_pushed()) { 2555b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch int argument_count = env->arguments_environment()->parameter_count(); 2556b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch pop = new(zone()) LDrop(argument_count); 2557b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch DCHECK(instr->argument_delta() == -argument_count); 2558b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 2559b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 25603ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch HEnvironment* outer = current_block_->last_environment()-> 25613ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch DiscardInlined(false); 25621e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block current_block_->UpdateEnvironment(outer); 2563b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2564b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return pop; 2565257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch} 2566257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch 2567257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch 25683ef787dbeca8a5fb1086949cda830dccee07bfbdBen MurdochLInstruction* LChunkBuilder::DoForInPrepareMap(HForInPrepareMap* instr) { 2569b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LOperand* context = UseFixed(instr->context(), rsi); 25703ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* object = UseFixed(instr->enumerable(), rax); 2571b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LForInPrepareMap* result = new(zone()) LForInPrepareMap(context, object); 25723ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return MarkAsCall(DefineFixed(result, rax), instr, CAN_DEOPTIMIZE_EAGERLY); 25733ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch} 25743ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 25753ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 25763ef787dbeca8a5fb1086949cda830dccee07bfbdBen MurdochLInstruction* LChunkBuilder::DoForInCacheArray(HForInCacheArray* instr) { 25773ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* map = UseRegister(instr->map()); 25783ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return AssignEnvironment(DefineAsRegister( 25793ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch new(zone()) LForInCacheArray(map))); 25803ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch} 25813ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 25823ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 25833ef787dbeca8a5fb1086949cda830dccee07bfbdBen MurdochLInstruction* LChunkBuilder::DoCheckMapValue(HCheckMapValue* instr) { 25843ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* value = UseRegisterAtStart(instr->value()); 25853ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* map = UseRegisterAtStart(instr->map()); 25863ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch return AssignEnvironment(new(zone()) LCheckMapValue(value, map)); 25873ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch} 25883ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 25893ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 25903ef787dbeca8a5fb1086949cda830dccee07bfbdBen MurdochLInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { 25913ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* object = UseRegister(instr->object()); 25923ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch LOperand* index = UseTempRegister(instr->index()); 2593b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LLoadFieldByIndex* load = new(zone()) LLoadFieldByIndex(object, index); 2594b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch LInstruction* result = DefineSameAsFirst(load); 2595b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return AssignPointerMap(result); 2596b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 2597b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 2598014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} // namespace internal 2599014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} // namespace v8 2600b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch 2601b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch#endif // V8_TARGET_ARCH_X64 2602