2011-01-05 12:31:31 +00:00
|
|
|
// Copyright 2011 the V8 project authors. All rights reserved.
|
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are
|
|
|
|
// met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright
|
|
|
|
// notice, this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above
|
|
|
|
// copyright notice, this list of conditions and the following
|
|
|
|
// disclaimer in the documentation and/or other materials provided
|
|
|
|
// with the distribution.
|
|
|
|
// * Neither the name of Google Inc. nor the names of its
|
|
|
|
// contributors may be used to endorse or promote products derived
|
|
|
|
// from this software without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
2011-01-13 14:10:26 +00:00
|
|
|
#include "v8.h"
|
|
|
|
|
|
|
|
#if defined(V8_TARGET_ARCH_X64)
|
|
|
|
|
2011-02-04 13:28:23 +00:00
|
|
|
#include "lithium-allocator-inl.h"
|
2011-01-05 12:31:31 +00:00
|
|
|
#include "x64/lithium-x64.h"
|
|
|
|
#include "x64/lithium-codegen-x64.h"
|
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
|
2011-01-13 10:04:02 +00:00
|
|
|
#define DEFINE_COMPILE(type) \
|
|
|
|
void L##type::CompileToNative(LCodeGen* generator) { \
|
|
|
|
generator->Do##type(this); \
|
|
|
|
}
|
|
|
|
LITHIUM_CONCRETE_INSTRUCTION_LIST(DEFINE_COMPILE)
|
|
|
|
#undef DEFINE_COMPILE
|
|
|
|
|
2011-01-11 11:33:52 +00:00
|
|
|
LOsrEntry::LOsrEntry() {
|
|
|
|
for (int i = 0; i < Register::kNumAllocatableRegisters; ++i) {
|
|
|
|
register_spills_[i] = NULL;
|
|
|
|
}
|
|
|
|
for (int i = 0; i < DoubleRegister::kNumAllocatableRegisters; ++i) {
|
|
|
|
double_register_spills_[i] = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LOsrEntry::MarkSpilledRegister(int allocation_index,
|
|
|
|
LOperand* spill_operand) {
|
|
|
|
ASSERT(spill_operand->IsStackSlot());
|
|
|
|
ASSERT(register_spills_[allocation_index] == NULL);
|
|
|
|
register_spills_[allocation_index] = spill_operand;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LOsrEntry::MarkSpilledDoubleRegister(int allocation_index,
|
|
|
|
LOperand* spill_operand) {
|
|
|
|
ASSERT(spill_operand->IsDoubleStackSlot());
|
|
|
|
ASSERT(double_register_spills_[allocation_index] == NULL);
|
|
|
|
double_register_spills_[allocation_index] = spill_operand;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-04 13:28:23 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
void LInstruction::VerifyCall() {
|
|
|
|
// Call instructions can use only fixed registers as
|
|
|
|
// temporaries and outputs because all registers
|
|
|
|
// are blocked by the calling convention.
|
|
|
|
// Inputs can use either fixed register or have a short lifetime (be
|
|
|
|
// used at start of the instruction).
|
|
|
|
ASSERT(Output() == NULL ||
|
|
|
|
LUnallocated::cast(Output())->HasFixedPolicy() ||
|
|
|
|
!LUnallocated::cast(Output())->HasRegisterPolicy());
|
|
|
|
for (UseIterator it(this); it.HasNext(); it.Advance()) {
|
|
|
|
LOperand* operand = it.Next();
|
|
|
|
ASSERT(LUnallocated::cast(operand)->HasFixedPolicy() ||
|
|
|
|
LUnallocated::cast(operand)->IsUsedAtStart() ||
|
|
|
|
!LUnallocated::cast(operand)->HasRegisterPolicy());
|
|
|
|
}
|
|
|
|
for (TempIterator it(this); it.HasNext(); it.Advance()) {
|
|
|
|
LOperand* operand = it.Next();
|
|
|
|
ASSERT(LUnallocated::cast(operand)->HasFixedPolicy() ||
|
|
|
|
!LUnallocated::cast(operand)->HasRegisterPolicy());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2011-01-11 11:33:52 +00:00
|
|
|
void LInstruction::PrintTo(StringStream* stream) {
|
|
|
|
stream->Add("%s ", this->Mnemonic());
|
2011-02-04 13:28:23 +00:00
|
|
|
|
|
|
|
PrintOutputOperandTo(stream);
|
2011-01-13 10:04:02 +00:00
|
|
|
|
2011-01-11 11:33:52 +00:00
|
|
|
PrintDataTo(stream);
|
|
|
|
|
|
|
|
if (HasEnvironment()) {
|
|
|
|
stream->Add(" ");
|
2011-01-13 10:04:02 +00:00
|
|
|
environment()->PrintTo(stream);
|
2011-01-11 11:33:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (HasPointerMap()) {
|
|
|
|
stream->Add(" ");
|
2011-01-13 10:04:02 +00:00
|
|
|
pointer_map()->PrintTo(stream);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<int R, int I, int T>
|
|
|
|
void LTemplateInstruction<R, I, T>::PrintDataTo(StringStream* stream) {
|
2011-01-17 13:51:59 +00:00
|
|
|
stream->Add("= ");
|
|
|
|
inputs_.PrintOperandsTo(stream);
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<int R, int I, int T>
|
|
|
|
void LTemplateInstruction<R, I, T>::PrintOutputOperandTo(StringStream* stream) {
|
2011-01-17 13:51:59 +00:00
|
|
|
results_.PrintOperandsTo(stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename T, int N>
|
|
|
|
void OperandContainer<T, N>::PrintOperandsTo(StringStream* stream) {
|
|
|
|
for (int i = 0; i < N; i++) {
|
|
|
|
if (i > 0) stream->Add(" ");
|
|
|
|
elems_[i]->PrintTo(stream);
|
2011-01-11 11:33:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LLabel::PrintDataTo(StringStream* stream) {
|
|
|
|
LGap::PrintDataTo(stream);
|
|
|
|
LLabel* rep = replacement();
|
|
|
|
if (rep != NULL) {
|
|
|
|
stream->Add(" Dead block replaced with B%d", rep->block_id());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-10 11:31:21 +00:00
|
|
|
bool LGap::IsRedundant() const {
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
if (parallel_moves_[i] != NULL && !parallel_moves_[i]->IsRedundant()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-11 11:33:52 +00:00
|
|
|
void LGap::PrintDataTo(StringStream* stream) {
|
2011-01-10 11:31:21 +00:00
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
stream->Add("(");
|
|
|
|
if (parallel_moves_[i] != NULL) {
|
|
|
|
parallel_moves_[i]->PrintDataTo(stream);
|
|
|
|
}
|
|
|
|
stream->Add(") ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-13 10:04:02 +00:00
|
|
|
const char* LArithmeticD::Mnemonic() const {
|
|
|
|
switch (op()) {
|
|
|
|
case Token::ADD: return "add-d";
|
|
|
|
case Token::SUB: return "sub-d";
|
|
|
|
case Token::MUL: return "mul-d";
|
|
|
|
case Token::DIV: return "div-d";
|
|
|
|
case Token::MOD: return "mod-d";
|
|
|
|
default:
|
|
|
|
UNREACHABLE();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const char* LArithmeticT::Mnemonic() const {
|
|
|
|
switch (op()) {
|
|
|
|
case Token::ADD: return "add-t";
|
|
|
|
case Token::SUB: return "sub-t";
|
|
|
|
case Token::MUL: return "mul-t";
|
|
|
|
case Token::MOD: return "mod-t";
|
|
|
|
case Token::DIV: return "div-t";
|
2011-02-04 11:10:39 +00:00
|
|
|
case Token::BIT_AND: return "bit-and-t";
|
|
|
|
case Token::BIT_OR: return "bit-or-t";
|
|
|
|
case Token::BIT_XOR: return "bit-xor-t";
|
|
|
|
case Token::SHL: return "sal-t";
|
|
|
|
case Token::SAR: return "sar-t";
|
|
|
|
case Token::SHR: return "shr-t";
|
2011-01-13 10:04:02 +00:00
|
|
|
default:
|
|
|
|
UNREACHABLE();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-11 11:33:52 +00:00
|
|
|
void LGoto::PrintDataTo(StringStream* stream) {
|
|
|
|
stream->Add("B%d", block_id());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-13 10:04:02 +00:00
|
|
|
void LBranch::PrintDataTo(StringStream* stream) {
|
|
|
|
stream->Add("B%d | B%d on ", true_block_id(), false_block_id());
|
2011-01-17 13:51:59 +00:00
|
|
|
InputAt(0)->PrintTo(stream);
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LCmpIDAndBranch::PrintDataTo(StringStream* stream) {
|
|
|
|
stream->Add("if ");
|
2011-01-17 13:51:59 +00:00
|
|
|
InputAt(0)->PrintTo(stream);
|
2011-01-13 10:04:02 +00:00
|
|
|
stream->Add(" %s ", Token::String(op()));
|
2011-01-17 13:51:59 +00:00
|
|
|
InputAt(1)->PrintTo(stream);
|
2011-01-13 10:04:02 +00:00
|
|
|
stream->Add(" then B%d else B%d", true_block_id(), false_block_id());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LIsNullAndBranch::PrintDataTo(StringStream* stream) {
|
|
|
|
stream->Add("if ");
|
2011-01-17 13:51:59 +00:00
|
|
|
InputAt(0)->PrintTo(stream);
|
2011-01-13 10:04:02 +00:00
|
|
|
stream->Add(is_strict() ? " === null" : " == null");
|
|
|
|
stream->Add(" then B%d else B%d", true_block_id(), false_block_id());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LIsObjectAndBranch::PrintDataTo(StringStream* stream) {
|
|
|
|
stream->Add("if is_object(");
|
2011-01-17 13:51:59 +00:00
|
|
|
InputAt(0)->PrintTo(stream);
|
2011-01-13 10:04:02 +00:00
|
|
|
stream->Add(") then B%d else B%d", true_block_id(), false_block_id());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LIsSmiAndBranch::PrintDataTo(StringStream* stream) {
|
|
|
|
stream->Add("if is_smi(");
|
2011-01-17 13:51:59 +00:00
|
|
|
InputAt(0)->PrintTo(stream);
|
2011-01-13 10:04:02 +00:00
|
|
|
stream->Add(") then B%d else B%d", true_block_id(), false_block_id());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LHasInstanceTypeAndBranch::PrintDataTo(StringStream* stream) {
|
|
|
|
stream->Add("if has_instance_type(");
|
2011-01-17 13:51:59 +00:00
|
|
|
InputAt(0)->PrintTo(stream);
|
2011-01-13 10:04:02 +00:00
|
|
|
stream->Add(") then B%d else B%d", true_block_id(), false_block_id());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LHasCachedArrayIndexAndBranch::PrintDataTo(StringStream* stream) {
|
|
|
|
stream->Add("if has_cached_array_index(");
|
2011-01-17 13:51:59 +00:00
|
|
|
InputAt(0)->PrintTo(stream);
|
2011-01-13 10:04:02 +00:00
|
|
|
stream->Add(") then B%d else B%d", true_block_id(), false_block_id());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LClassOfTestAndBranch::PrintDataTo(StringStream* stream) {
|
|
|
|
stream->Add("if class_of_test(");
|
2011-01-17 13:51:59 +00:00
|
|
|
InputAt(0)->PrintTo(stream);
|
2011-01-13 10:04:02 +00:00
|
|
|
stream->Add(", \"%o\") then B%d else B%d",
|
|
|
|
*hydrogen()->class_name(),
|
|
|
|
true_block_id(),
|
|
|
|
false_block_id());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LTypeofIs::PrintDataTo(StringStream* stream) {
|
2011-01-17 13:51:59 +00:00
|
|
|
InputAt(0)->PrintTo(stream);
|
2011-01-13 10:04:02 +00:00
|
|
|
stream->Add(" == \"%s\"", *hydrogen()->type_literal()->ToCString());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LTypeofIsAndBranch::PrintDataTo(StringStream* stream) {
|
|
|
|
stream->Add("if typeof ");
|
2011-01-17 13:51:59 +00:00
|
|
|
InputAt(0)->PrintTo(stream);
|
2011-01-13 10:04:02 +00:00
|
|
|
stream->Add(" == \"%s\" then B%d else B%d",
|
|
|
|
*hydrogen()->type_literal()->ToCString(),
|
|
|
|
true_block_id(), false_block_id());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LCallConstantFunction::PrintDataTo(StringStream* stream) {
|
|
|
|
stream->Add("#%d / ", arity());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LUnaryMathOperation::PrintDataTo(StringStream* stream) {
|
|
|
|
stream->Add("/%s ", hydrogen()->OpName());
|
2011-01-17 13:51:59 +00:00
|
|
|
InputAt(0)->PrintTo(stream);
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-17 08:11:03 +00:00
|
|
|
void LLoadContextSlot::PrintDataTo(StringStream* stream) {
|
2011-02-03 13:10:28 +00:00
|
|
|
InputAt(0)->PrintTo(stream);
|
|
|
|
stream->Add("[%d]", slot_index());
|
2011-01-17 08:11:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-13 10:04:02 +00:00
|
|
|
void LCallKeyed::PrintDataTo(StringStream* stream) {
|
2011-01-17 13:51:59 +00:00
|
|
|
stream->Add("[ecx] #%d / ", arity());
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LCallNamed::PrintDataTo(StringStream* stream) {
|
|
|
|
SmartPointer<char> name_string = name()->ToCString();
|
|
|
|
stream->Add("%s #%d / ", *name_string, arity());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LCallGlobal::PrintDataTo(StringStream* stream) {
|
|
|
|
SmartPointer<char> name_string = name()->ToCString();
|
|
|
|
stream->Add("%s #%d / ", *name_string, arity());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LCallKnownGlobal::PrintDataTo(StringStream* stream) {
|
|
|
|
stream->Add("#%d / ", arity());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LCallNew::PrintDataTo(StringStream* stream) {
|
|
|
|
stream->Add("= ");
|
2011-01-17 13:51:59 +00:00
|
|
|
InputAt(0)->PrintTo(stream);
|
2011-01-13 10:04:02 +00:00
|
|
|
stream->Add(" #%d / ", arity());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LClassOfTest::PrintDataTo(StringStream* stream) {
|
|
|
|
stream->Add("= class_of_test(");
|
2011-01-17 13:51:59 +00:00
|
|
|
InputAt(0)->PrintTo(stream);
|
2011-01-13 10:04:02 +00:00
|
|
|
stream->Add(", \"%o\")", *hydrogen()->class_name());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LAccessArgumentsAt::PrintDataTo(StringStream* stream) {
|
|
|
|
arguments()->PrintTo(stream);
|
|
|
|
|
|
|
|
stream->Add(" length ");
|
|
|
|
length()->PrintTo(stream);
|
|
|
|
|
|
|
|
stream->Add(" index ");
|
|
|
|
index()->PrintTo(stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int LChunk::GetNextSpillIndex(bool is_double) {
|
2011-01-14 13:16:48 +00:00
|
|
|
return spill_slot_count_++;
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-04 11:10:39 +00:00
|
|
|
LOperand* LChunk::GetNextSpillSlot(bool is_double) {
|
2011-01-14 13:16:48 +00:00
|
|
|
// All stack slots are Double stack slots on x64.
|
|
|
|
// Alternatively, at some point, start using half-size
|
|
|
|
// stack slots for int32 values.
|
|
|
|
int index = GetNextSpillIndex(is_double);
|
|
|
|
if (is_double) {
|
|
|
|
return LDoubleStackSlot::Create(index);
|
|
|
|
} else {
|
|
|
|
return LStackSlot::Create(index);
|
|
|
|
}
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LChunk::MarkEmptyBlocks() {
|
|
|
|
HPhase phase("Mark empty blocks", this);
|
|
|
|
for (int i = 0; i < graph()->blocks()->length(); ++i) {
|
|
|
|
HBasicBlock* block = graph()->blocks()->at(i);
|
|
|
|
int first = block->first_instruction_index();
|
|
|
|
int last = block->last_instruction_index();
|
|
|
|
LInstruction* first_instr = instructions()->at(first);
|
|
|
|
LInstruction* last_instr = instructions()->at(last);
|
|
|
|
|
|
|
|
LLabel* label = LLabel::cast(first_instr);
|
|
|
|
if (last_instr->IsGoto()) {
|
|
|
|
LGoto* goto_instr = LGoto::cast(last_instr);
|
|
|
|
if (!goto_instr->include_stack_check() &&
|
|
|
|
label->IsRedundant() &&
|
|
|
|
!label->is_loop_header()) {
|
|
|
|
bool can_eliminate = true;
|
|
|
|
for (int i = first + 1; i < last && can_eliminate; ++i) {
|
|
|
|
LInstruction* cur = instructions()->at(i);
|
|
|
|
if (cur->IsGap()) {
|
|
|
|
LGap* gap = LGap::cast(cur);
|
|
|
|
if (!gap->IsRedundant()) {
|
|
|
|
can_eliminate = false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
can_eliminate = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (can_eliminate) {
|
|
|
|
label->set_replacement(GetLabel(goto_instr->block_id()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LStoreNamed::PrintDataTo(StringStream* stream) {
|
|
|
|
object()->PrintTo(stream);
|
|
|
|
stream->Add(".");
|
|
|
|
stream->Add(*String::cast(*name())->ToCString());
|
|
|
|
stream->Add(" <- ");
|
|
|
|
value()->PrintTo(stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LStoreKeyed::PrintDataTo(StringStream* stream) {
|
|
|
|
object()->PrintTo(stream);
|
|
|
|
stream->Add("[");
|
|
|
|
key()->PrintTo(stream);
|
|
|
|
stream->Add("] <- ");
|
|
|
|
value()->PrintTo(stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-04 13:28:23 +00:00
|
|
|
void LChunk::AddInstruction(LInstruction* instr, HBasicBlock* block) {
|
2011-01-13 10:04:02 +00:00
|
|
|
LGap* gap = new LGap(block);
|
|
|
|
int index = -1;
|
|
|
|
if (instr->IsControl()) {
|
|
|
|
instructions_.Add(gap);
|
|
|
|
index = instructions_.length();
|
|
|
|
instructions_.Add(instr);
|
|
|
|
} else {
|
|
|
|
index = instructions_.length();
|
|
|
|
instructions_.Add(instr);
|
|
|
|
instructions_.Add(gap);
|
|
|
|
}
|
|
|
|
if (instr->HasPointerMap()) {
|
|
|
|
pointer_maps_.Add(instr->pointer_map());
|
|
|
|
instr->pointer_map()->set_lithium_position(index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LConstantOperand* LChunk::DefineConstantOperand(HConstant* constant) {
|
|
|
|
return LConstantOperand::Create(constant->id());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int LChunk::GetParameterStackSlot(int index) const {
|
|
|
|
// The receiver is at index 0, the first parameter at index 1, so we
|
|
|
|
// shift all parameter indexes down by the number of parameters, and
|
|
|
|
// make sure they end up negative so they are distinguishable from
|
|
|
|
// spill slots.
|
|
|
|
int result = index - graph()->info()->scope()->num_parameters() - 1;
|
|
|
|
ASSERT(result < 0);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
// A parameter relative to ebp in the arguments stub.
|
|
|
|
int LChunk::ParameterAt(int index) {
|
|
|
|
ASSERT(-1 <= index); // -1 is the receiver.
|
|
|
|
return (1 + graph()->info()->scope()->num_parameters() - index) *
|
|
|
|
kPointerSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LGap* LChunk::GetGapAt(int index) const {
|
|
|
|
return LGap::cast(instructions_[index]);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool LChunk::IsGapAt(int index) const {
|
|
|
|
return instructions_[index]->IsGap();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int LChunk::NearestGapPos(int index) const {
|
|
|
|
while (!IsGapAt(index)) index--;
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LChunk::AddGapMove(int index, LOperand* from, LOperand* to) {
|
|
|
|
GetGapAt(index)->GetOrCreateParallelMove(LGap::START)->AddMove(from, to);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Handle<Object> LChunk::LookupLiteral(LConstantOperand* operand) const {
|
|
|
|
return HConstant::cast(graph_->LookupValue(operand->index()))->handle();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Representation LChunk::LookupLiteralRepresentation(
|
|
|
|
LConstantOperand* operand) const {
|
|
|
|
return graph_->LookupValue(operand->index())->representation();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-05 12:31:31 +00:00
|
|
|
LChunk* LChunkBuilder::Build() {
|
|
|
|
ASSERT(is_unused());
|
|
|
|
chunk_ = new LChunk(graph());
|
|
|
|
HPhase phase("Building chunk", chunk_);
|
|
|
|
status_ = BUILDING;
|
|
|
|
const ZoneList<HBasicBlock*>* blocks = graph()->blocks();
|
|
|
|
for (int i = 0; i < blocks->length(); i++) {
|
|
|
|
HBasicBlock* next = NULL;
|
|
|
|
if (i < blocks->length() - 1) next = blocks->at(i + 1);
|
|
|
|
DoBasicBlock(blocks->at(i), next);
|
|
|
|
if (is_aborted()) return NULL;
|
|
|
|
}
|
|
|
|
status_ = DONE;
|
|
|
|
return chunk_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LChunkBuilder::Abort(const char* format, ...) {
|
|
|
|
if (FLAG_trace_bailout) {
|
|
|
|
SmartPointer<char> debug_name = graph()->debug_name()->ToCString();
|
|
|
|
PrintF("Aborting LChunk building in @\"%s\": ", *debug_name);
|
|
|
|
va_list arguments;
|
|
|
|
va_start(arguments, format);
|
|
|
|
OS::VPrint(format, arguments);
|
|
|
|
va_end(arguments);
|
|
|
|
PrintF("\n");
|
|
|
|
}
|
|
|
|
status_ = ABORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-13 10:04:02 +00:00
|
|
|
LRegister* LChunkBuilder::ToOperand(Register reg) {
|
|
|
|
return LRegister::Create(Register::ToAllocationIndex(reg));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LUnallocated* LChunkBuilder::ToUnallocated(Register reg) {
|
|
|
|
return new LUnallocated(LUnallocated::FIXED_REGISTER,
|
|
|
|
Register::ToAllocationIndex(reg));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LUnallocated* LChunkBuilder::ToUnallocated(XMMRegister reg) {
|
|
|
|
return new LUnallocated(LUnallocated::FIXED_DOUBLE_REGISTER,
|
|
|
|
XMMRegister::ToAllocationIndex(reg));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LOperand* LChunkBuilder::UseFixed(HValue* value, Register fixed_register) {
|
|
|
|
return Use(value, ToUnallocated(fixed_register));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LOperand* LChunkBuilder::UseFixedDouble(HValue* value, XMMRegister reg) {
|
|
|
|
return Use(value, ToUnallocated(reg));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LOperand* LChunkBuilder::UseRegister(HValue* value) {
|
|
|
|
return Use(value, new LUnallocated(LUnallocated::MUST_HAVE_REGISTER));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LOperand* LChunkBuilder::UseRegisterAtStart(HValue* value) {
|
|
|
|
return Use(value,
|
|
|
|
new LUnallocated(LUnallocated::MUST_HAVE_REGISTER,
|
|
|
|
LUnallocated::USED_AT_START));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LOperand* LChunkBuilder::UseTempRegister(HValue* value) {
|
|
|
|
return Use(value, new LUnallocated(LUnallocated::WRITABLE_REGISTER));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LOperand* LChunkBuilder::Use(HValue* value) {
|
|
|
|
return Use(value, new LUnallocated(LUnallocated::NONE));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LOperand* LChunkBuilder::UseAtStart(HValue* value) {
|
|
|
|
return Use(value, new LUnallocated(LUnallocated::NONE,
|
|
|
|
LUnallocated::USED_AT_START));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LOperand* LChunkBuilder::UseOrConstant(HValue* value) {
|
|
|
|
return value->IsConstant()
|
|
|
|
? chunk_->DefineConstantOperand(HConstant::cast(value))
|
|
|
|
: Use(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LOperand* LChunkBuilder::UseOrConstantAtStart(HValue* value) {
|
|
|
|
return value->IsConstant()
|
|
|
|
? chunk_->DefineConstantOperand(HConstant::cast(value))
|
|
|
|
: UseAtStart(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LOperand* LChunkBuilder::UseRegisterOrConstant(HValue* value) {
|
|
|
|
return value->IsConstant()
|
|
|
|
? chunk_->DefineConstantOperand(HConstant::cast(value))
|
|
|
|
: UseRegister(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LOperand* LChunkBuilder::UseRegisterOrConstantAtStart(HValue* value) {
|
|
|
|
return value->IsConstant()
|
|
|
|
? chunk_->DefineConstantOperand(HConstant::cast(value))
|
|
|
|
: UseRegisterAtStart(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-17 12:54:52 +00:00
|
|
|
LOperand* LChunkBuilder::UseAny(HValue* value) {
|
|
|
|
return value->IsConstant()
|
|
|
|
? chunk_->DefineConstantOperand(HConstant::cast(value))
|
|
|
|
: Use(value, new LUnallocated(LUnallocated::ANY));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-13 10:04:02 +00:00
|
|
|
LOperand* LChunkBuilder::Use(HValue* value, LUnallocated* operand) {
|
|
|
|
if (value->EmitAtUses()) {
|
|
|
|
HInstruction* instr = HInstruction::cast(value);
|
|
|
|
VisitInstruction(instr);
|
|
|
|
}
|
|
|
|
allocator_->RecordUse(value, operand);
|
|
|
|
return operand;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<int I, int T>
|
|
|
|
LInstruction* LChunkBuilder::Define(LTemplateInstruction<1, I, T>* instr,
|
|
|
|
LUnallocated* result) {
|
|
|
|
allocator_->RecordDefinition(current_instruction_, result);
|
|
|
|
instr->set_result(result);
|
|
|
|
return instr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<int I, int T>
|
|
|
|
LInstruction* LChunkBuilder::Define(LTemplateInstruction<1, I, T>* instr) {
|
|
|
|
return Define(instr, new LUnallocated(LUnallocated::NONE));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<int I, int T>
|
|
|
|
LInstruction* LChunkBuilder::DefineAsRegister(
|
|
|
|
LTemplateInstruction<1, I, T>* instr) {
|
|
|
|
return Define(instr, new LUnallocated(LUnallocated::MUST_HAVE_REGISTER));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<int I, int T>
|
|
|
|
LInstruction* LChunkBuilder::DefineAsSpilled(
|
|
|
|
LTemplateInstruction<1, I, T>* instr,
|
|
|
|
int index) {
|
|
|
|
return Define(instr, new LUnallocated(LUnallocated::FIXED_SLOT, index));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<int I, int T>
|
|
|
|
LInstruction* LChunkBuilder::DefineSameAsFirst(
|
|
|
|
LTemplateInstruction<1, I, T>* instr) {
|
|
|
|
return Define(instr, new LUnallocated(LUnallocated::SAME_AS_FIRST_INPUT));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<int I, int T>
|
|
|
|
LInstruction* LChunkBuilder::DefineFixed(LTemplateInstruction<1, I, T>* instr,
|
|
|
|
Register reg) {
|
|
|
|
return Define(instr, ToUnallocated(reg));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<int I, int T>
|
|
|
|
LInstruction* LChunkBuilder::DefineFixedDouble(
|
|
|
|
LTemplateInstruction<1, I, T>* instr,
|
|
|
|
XMMRegister reg) {
|
|
|
|
return Define(instr, ToUnallocated(reg));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) {
|
|
|
|
HEnvironment* hydrogen_env = current_block_->last_environment();
|
|
|
|
instr->set_environment(CreateEnvironment(hydrogen_env));
|
|
|
|
return instr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-26 08:03:48 +00:00
|
|
|
LInstruction* LChunkBuilder::SetInstructionPendingDeoptimizationEnvironment(
|
|
|
|
LInstruction* instr, int ast_id) {
|
2011-02-02 14:08:30 +00:00
|
|
|
ASSERT(instruction_pending_deoptimization_environment_ == NULL);
|
2011-01-26 08:03:48 +00:00
|
|
|
ASSERT(pending_deoptimization_ast_id_ == AstNode::kNoNumber);
|
2011-02-02 13:55:29 +00:00
|
|
|
instruction_pending_deoptimization_environment_ = instr;
|
2011-01-26 08:03:48 +00:00
|
|
|
pending_deoptimization_ast_id_ = ast_id;
|
|
|
|
return instr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LChunkBuilder::ClearInstructionPendingDeoptimizationEnvironment() {
|
2011-02-02 13:55:29 +00:00
|
|
|
instruction_pending_deoptimization_environment_ = NULL;
|
2011-01-26 08:03:48 +00:00
|
|
|
pending_deoptimization_ast_id_ = AstNode::kNoNumber;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-13 10:04:02 +00:00
|
|
|
LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr,
|
|
|
|
HInstruction* hinstr,
|
|
|
|
CanDeoptimize can_deoptimize) {
|
2011-02-04 13:28:23 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
instr->VerifyCall();
|
|
|
|
#endif
|
|
|
|
instr->MarkAsCall();
|
2011-01-13 10:04:02 +00:00
|
|
|
instr = AssignPointerMap(instr);
|
|
|
|
|
|
|
|
if (hinstr->HasSideEffects()) {
|
|
|
|
ASSERT(hinstr->next()->IsSimulate());
|
|
|
|
HSimulate* sim = HSimulate::cast(hinstr->next());
|
2011-01-26 08:03:48 +00:00
|
|
|
instr = SetInstructionPendingDeoptimizationEnvironment(
|
|
|
|
instr, sim->ast_id());
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// If instruction does not have side-effects lazy deoptimization
|
|
|
|
// after the call will try to deoptimize to the point before the call.
|
|
|
|
// Thus we still need to attach environment to this call even if
|
|
|
|
// call sequence can not deoptimize eagerly.
|
|
|
|
bool needs_environment =
|
|
|
|
(can_deoptimize == CAN_DEOPTIMIZE_EAGERLY) || !hinstr->HasSideEffects();
|
|
|
|
if (needs_environment && !instr->HasEnvironment()) {
|
|
|
|
instr = AssignEnvironment(instr);
|
|
|
|
}
|
|
|
|
|
|
|
|
return instr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::MarkAsSaveDoubles(LInstruction* instr) {
|
2011-02-04 13:28:23 +00:00
|
|
|
instr->MarkAsSaveDoubles();
|
2011-01-13 10:04:02 +00:00
|
|
|
return instr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::AssignPointerMap(LInstruction* instr) {
|
|
|
|
ASSERT(!instr->HasPointerMap());
|
|
|
|
instr->set_pointer_map(new LPointerMap(position_));
|
|
|
|
return instr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LUnallocated* LChunkBuilder::TempRegister() {
|
|
|
|
LUnallocated* operand = new LUnallocated(LUnallocated::MUST_HAVE_REGISTER);
|
|
|
|
allocator_->RecordTemporary(operand);
|
|
|
|
return operand;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LOperand* LChunkBuilder::FixedTemp(Register reg) {
|
|
|
|
LUnallocated* operand = ToUnallocated(reg);
|
|
|
|
allocator_->RecordTemporary(operand);
|
|
|
|
return operand;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LOperand* LChunkBuilder::FixedTemp(XMMRegister reg) {
|
|
|
|
LUnallocated* operand = ToUnallocated(reg);
|
|
|
|
allocator_->RecordTemporary(operand);
|
|
|
|
return operand;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoBlockEntry(HBlockEntry* instr) {
|
|
|
|
return new LLabel(instr->block());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoDeoptimize(HDeoptimize* instr) {
|
|
|
|
return AssignEnvironment(new LDeoptimize);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoBit(Token::Value op,
|
|
|
|
HBitwiseBinaryOperation* instr) {
|
2011-02-04 11:10:39 +00:00
|
|
|
if (instr->representation().IsInteger32()) {
|
|
|
|
ASSERT(instr->left()->representation().IsInteger32());
|
|
|
|
ASSERT(instr->right()->representation().IsInteger32());
|
|
|
|
|
|
|
|
LOperand* left = UseRegisterAtStart(instr->LeastConstantOperand());
|
|
|
|
LOperand* right = UseOrConstantAtStart(instr->MostConstantOperand());
|
|
|
|
return DefineSameAsFirst(new LBitI(op, left, right));
|
|
|
|
} else {
|
|
|
|
ASSERT(instr->representation().IsTagged());
|
|
|
|
ASSERT(instr->left()->representation().IsTagged());
|
|
|
|
ASSERT(instr->right()->representation().IsTagged());
|
|
|
|
|
|
|
|
LOperand* left = UseFixed(instr->left(), rdx);
|
|
|
|
LOperand* right = UseFixed(instr->right(), rax);
|
|
|
|
LArithmeticT* result = new LArithmeticT(op, left, right);
|
|
|
|
return MarkAsCall(DefineFixed(result, rax), instr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoShift(Token::Value op,
|
|
|
|
HBitwiseBinaryOperation* instr) {
|
|
|
|
if (instr->representation().IsTagged()) {
|
|
|
|
ASSERT(instr->left()->representation().IsTagged());
|
|
|
|
ASSERT(instr->right()->representation().IsTagged());
|
|
|
|
|
|
|
|
LOperand* left = UseFixed(instr->left(), rdx);
|
|
|
|
LOperand* right = UseFixed(instr->right(), rax);
|
|
|
|
LArithmeticT* result = new LArithmeticT(op, left, right);
|
|
|
|
return MarkAsCall(DefineFixed(result, rax), instr);
|
|
|
|
}
|
|
|
|
|
|
|
|
ASSERT(instr->representation().IsInteger32());
|
|
|
|
ASSERT(instr->OperandAt(0)->representation().IsInteger32());
|
|
|
|
ASSERT(instr->OperandAt(1)->representation().IsInteger32());
|
|
|
|
LOperand* left = UseRegisterAtStart(instr->OperandAt(0));
|
|
|
|
|
|
|
|
HValue* right_value = instr->OperandAt(1);
|
|
|
|
LOperand* right = NULL;
|
|
|
|
int constant_value = 0;
|
|
|
|
if (right_value->IsConstant()) {
|
|
|
|
HConstant* constant = HConstant::cast(right_value);
|
|
|
|
right = chunk_->DefineConstantOperand(constant);
|
|
|
|
constant_value = constant->Integer32Value() & 0x1f;
|
|
|
|
} else {
|
|
|
|
right = UseFixed(right_value, rcx);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Shift operations can only deoptimize if we do a logical shift
|
|
|
|
// by 0 and the result cannot be truncated to int32.
|
|
|
|
bool can_deopt = (op == Token::SHR && constant_value == 0);
|
|
|
|
if (can_deopt) {
|
|
|
|
bool can_truncate = true;
|
|
|
|
for (int i = 0; i < instr->uses()->length(); i++) {
|
|
|
|
if (!instr->uses()->at(i)->CheckFlag(HValue::kTruncatingToInt32)) {
|
|
|
|
can_truncate = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
can_deopt = !can_truncate;
|
|
|
|
}
|
|
|
|
|
|
|
|
LShiftI* result = new LShiftI(op, left, right, can_deopt);
|
|
|
|
return can_deopt
|
|
|
|
? AssignEnvironment(DefineSameAsFirst(result))
|
|
|
|
: DefineSameAsFirst(result);
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op,
|
|
|
|
HArithmeticBinaryOperation* instr) {
|
|
|
|
Abort("Unimplemented: %s", "DoArithmeticD");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoArithmeticT(Token::Value op,
|
|
|
|
HArithmeticBinaryOperation* instr) {
|
2011-01-18 14:32:13 +00:00
|
|
|
ASSERT(op == Token::ADD ||
|
|
|
|
op == Token::DIV ||
|
|
|
|
op == Token::MOD ||
|
|
|
|
op == Token::MUL ||
|
|
|
|
op == Token::SUB);
|
|
|
|
HValue* left = instr->left();
|
|
|
|
HValue* right = instr->right();
|
|
|
|
ASSERT(left->representation().IsTagged());
|
|
|
|
ASSERT(right->representation().IsTagged());
|
|
|
|
LOperand* left_operand = UseFixed(left, rdx);
|
|
|
|
LOperand* right_operand = UseFixed(right, rax);
|
|
|
|
LArithmeticT* result = new LArithmeticT(op, left_operand, right_operand);
|
|
|
|
return MarkAsCall(DefineFixed(result, rax), instr);
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
2011-01-14 13:16:48 +00:00
|
|
|
|
2011-01-05 12:31:31 +00:00
|
|
|
void LChunkBuilder::DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block) {
|
2011-01-14 10:27:25 +00:00
|
|
|
ASSERT(is_building());
|
|
|
|
current_block_ = block;
|
|
|
|
next_block_ = next_block;
|
|
|
|
if (block->IsStartBlock()) {
|
|
|
|
block->UpdateEnvironment(graph_->start_environment());
|
|
|
|
argument_count_ = 0;
|
|
|
|
} else if (block->predecessors()->length() == 1) {
|
|
|
|
// We have a single predecessor => copy environment and outgoing
|
|
|
|
// argument count from the predecessor.
|
|
|
|
ASSERT(block->phis()->length() == 0);
|
|
|
|
HBasicBlock* pred = block->predecessors()->at(0);
|
|
|
|
HEnvironment* last_environment = pred->last_environment();
|
|
|
|
ASSERT(last_environment != NULL);
|
|
|
|
// Only copy the environment, if it is later used again.
|
|
|
|
if (pred->end()->SecondSuccessor() == NULL) {
|
|
|
|
ASSERT(pred->end()->FirstSuccessor() == block);
|
|
|
|
} else {
|
|
|
|
if (pred->end()->FirstSuccessor()->block_id() > block->block_id() ||
|
|
|
|
pred->end()->SecondSuccessor()->block_id() > block->block_id()) {
|
|
|
|
last_environment = last_environment->Copy();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
block->UpdateEnvironment(last_environment);
|
|
|
|
ASSERT(pred->argument_count() >= 0);
|
|
|
|
argument_count_ = pred->argument_count();
|
|
|
|
} else {
|
|
|
|
// We are at a state join => process phis.
|
|
|
|
HBasicBlock* pred = block->predecessors()->at(0);
|
|
|
|
// No need to copy the environment, it cannot be used later.
|
|
|
|
HEnvironment* last_environment = pred->last_environment();
|
|
|
|
for (int i = 0; i < block->phis()->length(); ++i) {
|
|
|
|
HPhi* phi = block->phis()->at(i);
|
|
|
|
last_environment->SetValueAt(phi->merged_index(), phi);
|
|
|
|
}
|
|
|
|
for (int i = 0; i < block->deleted_phis()->length(); ++i) {
|
|
|
|
last_environment->SetValueAt(block->deleted_phis()->at(i),
|
|
|
|
graph_->GetConstantUndefined());
|
|
|
|
}
|
|
|
|
block->UpdateEnvironment(last_environment);
|
|
|
|
// Pick up the outgoing argument count of one of the predecessors.
|
|
|
|
argument_count_ = pred->argument_count();
|
|
|
|
}
|
|
|
|
HInstruction* current = block->first();
|
|
|
|
int start = chunk_->instructions()->length();
|
|
|
|
while (current != NULL && !is_aborted()) {
|
|
|
|
// Code for constants in registers is generated lazily.
|
|
|
|
if (!current->EmitAtUses()) {
|
|
|
|
VisitInstruction(current);
|
|
|
|
}
|
|
|
|
current = current->next();
|
|
|
|
}
|
|
|
|
int end = chunk_->instructions()->length() - 1;
|
|
|
|
if (end >= start) {
|
|
|
|
block->set_first_instruction_index(start);
|
|
|
|
block->set_last_instruction_index(end);
|
|
|
|
}
|
|
|
|
block->set_argument_count(argument_count_);
|
|
|
|
next_block_ = NULL;
|
|
|
|
current_block_ = NULL;
|
2011-01-05 12:31:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-13 10:04:02 +00:00
|
|
|
void LChunkBuilder::VisitInstruction(HInstruction* current) {
|
|
|
|
HInstruction* old_current = current_instruction_;
|
|
|
|
current_instruction_ = current;
|
|
|
|
if (current->has_position()) position_ = current->position();
|
|
|
|
LInstruction* instr = current->CompileToLithium(this);
|
|
|
|
|
|
|
|
if (instr != NULL) {
|
|
|
|
if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) {
|
|
|
|
instr = AssignPointerMap(instr);
|
|
|
|
}
|
|
|
|
if (FLAG_stress_environments && !instr->HasEnvironment()) {
|
|
|
|
instr = AssignEnvironment(instr);
|
|
|
|
}
|
2011-01-20 12:56:34 +00:00
|
|
|
if (current->IsTest() && !instr->IsGoto()) {
|
2011-01-17 13:51:59 +00:00
|
|
|
ASSERT(instr->IsControl());
|
2011-01-20 12:56:34 +00:00
|
|
|
HTest* test = HTest::cast(current);
|
|
|
|
instr->set_hydrogen_value(test->value());
|
|
|
|
HBasicBlock* first = test->FirstSuccessor();
|
|
|
|
HBasicBlock* second = test->SecondSuccessor();
|
2011-01-17 13:51:59 +00:00
|
|
|
ASSERT(first != NULL && second != NULL);
|
|
|
|
instr->SetBranchTargets(first->block_id(), second->block_id());
|
2011-01-13 10:04:02 +00:00
|
|
|
} else {
|
|
|
|
instr->set_hydrogen_value(current);
|
|
|
|
}
|
|
|
|
|
2011-02-04 13:28:23 +00:00
|
|
|
chunk_->AddInstruction(instr, current_block_);
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
current_instruction_ = old_current;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LEnvironment* LChunkBuilder::CreateEnvironment(HEnvironment* hydrogen_env) {
|
|
|
|
if (hydrogen_env == NULL) return NULL;
|
|
|
|
|
|
|
|
LEnvironment* outer = CreateEnvironment(hydrogen_env->outer());
|
|
|
|
int ast_id = hydrogen_env->ast_id();
|
|
|
|
ASSERT(ast_id != AstNode::kNoNumber);
|
|
|
|
int value_count = hydrogen_env->length();
|
|
|
|
LEnvironment* result = new LEnvironment(hydrogen_env->closure(),
|
|
|
|
ast_id,
|
|
|
|
hydrogen_env->parameter_count(),
|
|
|
|
argument_count_,
|
|
|
|
value_count,
|
|
|
|
outer);
|
|
|
|
int argument_index = 0;
|
|
|
|
for (int i = 0; i < value_count; ++i) {
|
|
|
|
HValue* value = hydrogen_env->values()->at(i);
|
|
|
|
LOperand* op = NULL;
|
|
|
|
if (value->IsArgumentsObject()) {
|
|
|
|
op = NULL;
|
|
|
|
} else if (value->IsPushArgument()) {
|
|
|
|
op = new LArgument(argument_index++);
|
|
|
|
} else {
|
2011-01-17 12:54:52 +00:00
|
|
|
op = UseAny(value);
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
result->AddValue(op, value->representation());
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoGoto(HGoto* instr) {
|
2011-01-14 10:27:25 +00:00
|
|
|
LGoto* result = new LGoto(instr->FirstSuccessor()->block_id(),
|
|
|
|
instr->include_stack_check());
|
|
|
|
return (instr->include_stack_check())
|
|
|
|
? AssignPointerMap(result)
|
|
|
|
: result;
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-20 12:56:34 +00:00
|
|
|
LInstruction* LChunkBuilder::DoTest(HTest* instr) {
|
2011-01-19 10:17:18 +00:00
|
|
|
HValue* v = instr->value();
|
|
|
|
if (v->EmitAtUses()) {
|
|
|
|
if (v->IsClassOfTest()) {
|
|
|
|
HClassOfTest* compare = HClassOfTest::cast(v);
|
|
|
|
ASSERT(compare->value()->representation().IsTagged());
|
|
|
|
|
|
|
|
return new LClassOfTestAndBranch(UseTempRegister(compare->value()),
|
|
|
|
TempRegister());
|
|
|
|
} else if (v->IsCompare()) {
|
|
|
|
HCompare* compare = HCompare::cast(v);
|
|
|
|
Token::Value op = compare->token();
|
|
|
|
HValue* left = compare->left();
|
|
|
|
HValue* right = compare->right();
|
|
|
|
Representation r = compare->GetInputRepresentation();
|
|
|
|
if (r.IsInteger32()) {
|
|
|
|
ASSERT(left->representation().IsInteger32());
|
|
|
|
ASSERT(right->representation().IsInteger32());
|
|
|
|
|
|
|
|
return new LCmpIDAndBranch(UseRegisterAtStart(left),
|
|
|
|
UseOrConstantAtStart(right));
|
|
|
|
} else if (r.IsDouble()) {
|
|
|
|
ASSERT(left->representation().IsDouble());
|
|
|
|
ASSERT(right->representation().IsDouble());
|
|
|
|
|
|
|
|
return new LCmpIDAndBranch(UseRegisterAtStart(left),
|
|
|
|
UseRegisterAtStart(right));
|
|
|
|
} else {
|
|
|
|
ASSERT(left->representation().IsTagged());
|
|
|
|
ASSERT(right->representation().IsTagged());
|
|
|
|
bool reversed = op == Token::GT || op == Token::LTE;
|
|
|
|
LOperand* left_operand = UseFixed(left, reversed ? rax : rdx);
|
|
|
|
LOperand* right_operand = UseFixed(right, reversed ? rdx : rax);
|
|
|
|
LCmpTAndBranch* result = new LCmpTAndBranch(left_operand,
|
|
|
|
right_operand);
|
|
|
|
return MarkAsCall(result, instr);
|
|
|
|
}
|
|
|
|
} else if (v->IsIsSmi()) {
|
|
|
|
HIsSmi* compare = HIsSmi::cast(v);
|
|
|
|
ASSERT(compare->value()->representation().IsTagged());
|
|
|
|
|
|
|
|
return new LIsSmiAndBranch(Use(compare->value()));
|
|
|
|
} else if (v->IsHasInstanceType()) {
|
|
|
|
HHasInstanceType* compare = HHasInstanceType::cast(v);
|
|
|
|
ASSERT(compare->value()->representation().IsTagged());
|
|
|
|
|
|
|
|
return new LHasInstanceTypeAndBranch(
|
|
|
|
UseRegisterAtStart(compare->value()));
|
|
|
|
} else if (v->IsHasCachedArrayIndex()) {
|
|
|
|
HHasCachedArrayIndex* compare = HHasCachedArrayIndex::cast(v);
|
|
|
|
ASSERT(compare->value()->representation().IsTagged());
|
|
|
|
|
|
|
|
return new LHasCachedArrayIndexAndBranch(
|
|
|
|
UseRegisterAtStart(compare->value()));
|
|
|
|
} else if (v->IsIsNull()) {
|
|
|
|
HIsNull* compare = HIsNull::cast(v);
|
|
|
|
ASSERT(compare->value()->representation().IsTagged());
|
|
|
|
|
|
|
|
// We only need a temp register for non-strict compare.
|
|
|
|
LOperand* temp = compare->is_strict() ? NULL : TempRegister();
|
|
|
|
return new LIsNullAndBranch(UseRegisterAtStart(compare->value()),
|
|
|
|
temp);
|
|
|
|
} else if (v->IsIsObject()) {
|
|
|
|
HIsObject* compare = HIsObject::cast(v);
|
|
|
|
ASSERT(compare->value()->representation().IsTagged());
|
2011-01-25 11:30:47 +00:00
|
|
|
return new LIsObjectAndBranch(UseRegisterAtStart(compare->value()));
|
2011-01-19 10:17:18 +00:00
|
|
|
} else if (v->IsCompareJSObjectEq()) {
|
|
|
|
HCompareJSObjectEq* compare = HCompareJSObjectEq::cast(v);
|
|
|
|
return new LCmpJSObjectEqAndBranch(UseRegisterAtStart(compare->left()),
|
|
|
|
UseRegisterAtStart(compare->right()));
|
|
|
|
} else if (v->IsInstanceOf()) {
|
|
|
|
HInstanceOf* instance_of = HInstanceOf::cast(v);
|
|
|
|
LInstanceOfAndBranch* result =
|
|
|
|
new LInstanceOfAndBranch(
|
|
|
|
UseFixed(instance_of->left(), InstanceofStub::left()),
|
|
|
|
UseFixed(instance_of->right(), InstanceofStub::right()));
|
|
|
|
return MarkAsCall(result, instr);
|
|
|
|
} else if (v->IsTypeofIs()) {
|
|
|
|
HTypeofIs* typeof_is = HTypeofIs::cast(v);
|
|
|
|
return new LTypeofIsAndBranch(UseTempRegister(typeof_is->value()));
|
|
|
|
} else {
|
|
|
|
if (v->IsConstant()) {
|
|
|
|
if (HConstant::cast(v)->handle()->IsTrue()) {
|
|
|
|
return new LGoto(instr->FirstSuccessor()->block_id());
|
|
|
|
} else if (HConstant::cast(v)->handle()->IsFalse()) {
|
|
|
|
return new LGoto(instr->SecondSuccessor()->block_id());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Abort("Undefined compare before branch");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return new LBranch(UseRegisterAtStart(v));
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-20 12:56:34 +00:00
|
|
|
LInstruction* LChunkBuilder::DoCompareMap(HCompareMap* instr) {
|
2011-02-03 15:40:20 +00:00
|
|
|
ASSERT(instr->value()->representation().IsTagged());
|
|
|
|
LOperand* value = UseRegisterAtStart(instr->value());
|
|
|
|
return new LCmpMapAndBranch(value);
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoArgumentsLength(HArgumentsLength* length) {
|
|
|
|
Abort("Unimplemented: %s", "DoArgumentsLength");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoArgumentsElements(HArgumentsElements* elems) {
|
|
|
|
Abort("Unimplemented: %s", "DoArgumentsElements");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoInstanceOf(HInstanceOf* instr) {
|
|
|
|
Abort("Unimplemented: %s", "DoInstanceOf");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoInstanceOfKnownGlobal(
|
|
|
|
HInstanceOfKnownGlobal* instr) {
|
|
|
|
Abort("Unimplemented: %s", "DoInstanceOfKnownGlobal");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoApplyArguments(HApplyArguments* instr) {
|
|
|
|
Abort("Unimplemented: %s", "DoApplyArguments");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoPushArgument(HPushArgument* instr) {
|
2011-01-27 11:58:31 +00:00
|
|
|
++argument_count_;
|
|
|
|
LOperand* argument = UseOrConstant(instr->argument());
|
|
|
|
return new LPushArgument(argument);
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-03 13:10:28 +00:00
|
|
|
LInstruction* LChunkBuilder::DoContext(HContext* instr) {
|
|
|
|
Abort("Unimplemented: DoContext");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoOuterContext(HOuterContext* instr) {
|
|
|
|
Abort("Unimplemented: DoOuterContext");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-13 10:04:02 +00:00
|
|
|
LInstruction* LChunkBuilder::DoGlobalObject(HGlobalObject* instr) {
|
2011-01-25 11:33:03 +00:00
|
|
|
return DefineAsRegister(new LGlobalObject);
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoGlobalReceiver(HGlobalReceiver* instr) {
|
2011-01-27 16:41:43 +00:00
|
|
|
return DefineAsRegister(new LGlobalReceiver);
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoCallConstantFunction(
|
|
|
|
HCallConstantFunction* instr) {
|
2011-02-03 15:40:20 +00:00
|
|
|
argument_count_ -= instr->argument_count();
|
|
|
|
return MarkAsCall(DefineFixed(new LCallConstantFunction, rax), instr);
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) {
|
|
|
|
Abort("Unimplemented: %s", "DoUnaryMathOperation");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoCallKeyed(HCallKeyed* instr) {
|
|
|
|
Abort("Unimplemented: %s", "DoCallKeyed");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoCallNamed(HCallNamed* instr) {
|
2011-02-04 14:09:03 +00:00
|
|
|
argument_count_ -= instr->argument_count();
|
|
|
|
return MarkAsCall(DefineFixed(new LCallNamed, rax), instr);
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoCallGlobal(HCallGlobal* instr) {
|
|
|
|
Abort("Unimplemented: %s", "DoCallGlobal");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoCallKnownGlobal(HCallKnownGlobal* instr) {
|
2011-02-04 14:09:03 +00:00
|
|
|
argument_count_ -= instr->argument_count();
|
|
|
|
return MarkAsCall(DefineFixed(new LCallKnownGlobal, rax), instr);
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoCallNew(HCallNew* instr) {
|
2011-01-27 11:58:31 +00:00
|
|
|
LOperand* constructor = UseFixed(instr->constructor(), rdi);
|
|
|
|
argument_count_ -= instr->argument_count();
|
|
|
|
LCallNew* result = new LCallNew(constructor);
|
|
|
|
return MarkAsCall(DefineFixed(result, rax), instr);
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoCallFunction(HCallFunction* instr) {
|
|
|
|
Abort("Unimplemented: %s", "DoCallFunction");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoCallRuntime(HCallRuntime* instr) {
|
2011-02-04 06:54:45 +00:00
|
|
|
argument_count_ -= instr->argument_count();
|
|
|
|
return MarkAsCall(DefineFixed(new LCallRuntime, rax), instr);
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoShr(HShr* instr) {
|
2011-02-04 11:10:39 +00:00
|
|
|
return DoShift(Token::SHR, instr);
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoSar(HSar* instr) {
|
2011-02-04 11:10:39 +00:00
|
|
|
return DoShift(Token::SAR, instr);
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoShl(HShl* instr) {
|
2011-02-04 11:10:39 +00:00
|
|
|
return DoShift(Token::SHL, instr);
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoBitAnd(HBitAnd* instr) {
|
2011-02-04 11:10:39 +00:00
|
|
|
return DoBit(Token::BIT_AND, instr);
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoBitNot(HBitNot* instr) {
|
2011-02-04 11:10:39 +00:00
|
|
|
ASSERT(instr->value()->representation().IsInteger32());
|
|
|
|
ASSERT(instr->representation().IsInteger32());
|
|
|
|
LOperand* input = UseRegisterAtStart(instr->value());
|
|
|
|
LBitNotI* result = new LBitNotI(input);
|
|
|
|
return DefineSameAsFirst(result);
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoBitOr(HBitOr* instr) {
|
2011-02-04 11:10:39 +00:00
|
|
|
return DoBit(Token::BIT_OR, instr);
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoBitXor(HBitXor* instr) {
|
2011-02-04 11:10:39 +00:00
|
|
|
return DoBit(Token::BIT_XOR, instr);
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoDiv(HDiv* instr) {
|
|
|
|
Abort("Unimplemented: %s", "DoDiv");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoMod(HMod* instr) {
|
|
|
|
Abort("Unimplemented: %s", "DoMod");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoMul(HMul* instr) {
|
|
|
|
Abort("Unimplemented: %s", "DoMul");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoSub(HSub* instr) {
|
2011-01-25 11:33:03 +00:00
|
|
|
if (instr->representation().IsInteger32()) {
|
|
|
|
ASSERT(instr->left()->representation().IsInteger32());
|
|
|
|
ASSERT(instr->right()->representation().IsInteger32());
|
|
|
|
LOperand* left = UseRegisterAtStart(instr->left());
|
|
|
|
LOperand* right = UseOrConstantAtStart(instr->right());
|
|
|
|
LSubI* sub = new LSubI(left, right);
|
|
|
|
LInstruction* result = DefineSameAsFirst(sub);
|
|
|
|
if (instr->CheckFlag(HValue::kCanOverflow)) {
|
|
|
|
result = AssignEnvironment(result);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
} else if (instr->representation().IsDouble()) {
|
|
|
|
return DoArithmeticD(Token::SUB, instr);
|
|
|
|
} else {
|
|
|
|
ASSERT(instr->representation().IsTagged());
|
|
|
|
return DoArithmeticT(Token::SUB, instr);
|
|
|
|
}
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoAdd(HAdd* instr) {
|
2011-01-18 14:32:13 +00:00
|
|
|
if (instr->representation().IsInteger32()) {
|
|
|
|
ASSERT(instr->left()->representation().IsInteger32());
|
|
|
|
ASSERT(instr->right()->representation().IsInteger32());
|
|
|
|
LOperand* left = UseRegisterAtStart(instr->LeastConstantOperand());
|
|
|
|
LOperand* right = UseOrConstantAtStart(instr->MostConstantOperand());
|
|
|
|
LAddI* add = new LAddI(left, right);
|
|
|
|
LInstruction* result = DefineSameAsFirst(add);
|
|
|
|
if (instr->CheckFlag(HValue::kCanOverflow)) {
|
|
|
|
result = AssignEnvironment(result);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
} else if (instr->representation().IsDouble()) {
|
|
|
|
Abort("Unimplemented: %s", "DoAdd on Doubles");
|
|
|
|
} else {
|
|
|
|
ASSERT(instr->representation().IsTagged());
|
|
|
|
return DoArithmeticT(Token::ADD, instr);
|
|
|
|
}
|
2011-01-13 10:04:02 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoPower(HPower* instr) {
|
|
|
|
Abort("Unimplemented: %s", "DoPower");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoCompare(HCompare* instr) {
|
2011-01-19 10:17:18 +00:00
|
|
|
Token::Value op = instr->token();
|
|
|
|
Representation r = instr->GetInputRepresentation();
|
|
|
|
if (r.IsInteger32()) {
|
|
|
|
ASSERT(instr->left()->representation().IsInteger32());
|
|
|
|
ASSERT(instr->right()->representation().IsInteger32());
|
|
|
|
LOperand* left = UseRegisterAtStart(instr->left());
|
|
|
|
LOperand* right = UseOrConstantAtStart(instr->right());
|
|
|
|
return DefineAsRegister(new LCmpID(left, right));
|
|
|
|
} else if (r.IsDouble()) {
|
|
|
|
ASSERT(instr->left()->representation().IsDouble());
|
|
|
|
ASSERT(instr->right()->representation().IsDouble());
|
|
|
|
LOperand* left = UseRegisterAtStart(instr->left());
|
|
|
|
LOperand* right = UseRegisterAtStart(instr->right());
|
|
|
|
return DefineAsRegister(new LCmpID(left, right));
|
|
|
|
} else {
|
|
|
|
ASSERT(instr->left()->representation().IsTagged());
|
|
|
|
ASSERT(instr->right()->representation().IsTagged());
|
|
|
|
bool reversed = (op == Token::GT || op == Token::LTE);
|
|
|
|
LOperand* left = UseFixed(instr->left(), reversed ? rax : rdx);
|
|
|
|
LOperand* right = UseFixed(instr->right(), reversed ? rdx : rax);
|
|
|
|
LCmpT* result = new LCmpT(left, right);
|
|
|
|
return MarkAsCall(DefineFixed(result, rax), instr);
|
|
|
|
}
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoCompareJSObjectEq(
|
|
|
|
HCompareJSObjectEq* instr) {
|
2011-01-25 11:30:47 +00:00
|
|
|
LOperand* left = UseRegisterAtStart(instr->left());
|
|
|
|
LOperand* right = UseRegisterAtStart(instr->right());
|
|
|
|
LCmpJSObjectEq* result = new LCmpJSObjectEq(left, right);
|
|
|
|
return DefineAsRegister(result);
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoIsNull(HIsNull* instr) {
|
2011-01-25 11:30:47 +00:00
|
|
|
ASSERT(instr->value()->representation().IsTagged());
|
|
|
|
LOperand* value = UseRegisterAtStart(instr->value());
|
|
|
|
|
|
|
|
return DefineAsRegister(new LIsNull(value));
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoIsObject(HIsObject* instr) {
|
2011-01-25 11:30:47 +00:00
|
|
|
ASSERT(instr->value()->representation().IsTagged());
|
|
|
|
LOperand* value = UseRegister(instr->value());
|
|
|
|
|
|
|
|
return DefineAsRegister(new LIsObject(value));
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoIsSmi(HIsSmi* instr) {
|
2011-01-25 11:30:47 +00:00
|
|
|
ASSERT(instr->value()->representation().IsTagged());
|
|
|
|
LOperand* value = UseAtStart(instr->value());
|
|
|
|
|
|
|
|
return DefineAsRegister(new LIsSmi(value));
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoHasInstanceType(HHasInstanceType* instr) {
|
|
|
|
Abort("Unimplemented: %s", "DoHasInstanceType");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoHasCachedArrayIndex(
|
|
|
|
HHasCachedArrayIndex* instr) {
|
|
|
|
Abort("Unimplemented: %s", "DoHasCachedArrayIndex");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoClassOfTest(HClassOfTest* instr) {
|
|
|
|
Abort("Unimplemented: %s", "DoClassOfTest");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoJSArrayLength(HJSArrayLength* instr) {
|
2011-02-04 14:09:03 +00:00
|
|
|
LOperand* array = UseRegisterAtStart(instr->value());
|
|
|
|
return DefineAsRegister(new LJSArrayLength(array));
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoFixedArrayLength(HFixedArrayLength* instr) {
|
2011-02-03 17:01:10 +00:00
|
|
|
LOperand* array = UseRegisterAtStart(instr->value());
|
|
|
|
return DefineAsRegister(new LFixedArrayLength(array));
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoValueOf(HValueOf* instr) {
|
|
|
|
Abort("Unimplemented: %s", "DoValueOf");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) {
|
2011-02-03 17:01:10 +00:00
|
|
|
return AssignEnvironment(new LBoundsCheck(UseRegisterAtStart(instr->index()),
|
|
|
|
Use(instr->length())));
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-02 13:55:29 +00:00
|
|
|
LInstruction* LChunkBuilder::DoAbnormalExit(HAbnormalExit* instr) {
|
|
|
|
// The control instruction marking the end of a block that completed
|
|
|
|
// abruptly (e.g., threw an exception). There is nothing specific to do.
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-13 10:04:02 +00:00
|
|
|
LInstruction* LChunkBuilder::DoThrow(HThrow* instr) {
|
|
|
|
Abort("Unimplemented: %s", "DoThrow");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoChange(HChange* instr) {
|
2011-01-25 11:30:47 +00:00
|
|
|
Representation from = instr->from();
|
|
|
|
Representation to = instr->to();
|
|
|
|
if (from.IsTagged()) {
|
|
|
|
if (to.IsDouble()) {
|
|
|
|
LOperand* value = UseRegister(instr->value());
|
|
|
|
LNumberUntagD* res = new LNumberUntagD(value);
|
|
|
|
return AssignEnvironment(DefineAsRegister(res));
|
|
|
|
} else {
|
|
|
|
ASSERT(to.IsInteger32());
|
|
|
|
LOperand* value = UseRegister(instr->value());
|
|
|
|
bool needs_check = !instr->value()->type().IsSmi();
|
|
|
|
if (needs_check) {
|
|
|
|
LOperand* xmm_temp =
|
|
|
|
(instr->CanTruncateToInt32() && CpuFeatures::IsSupported(SSE3))
|
|
|
|
? NULL
|
|
|
|
: FixedTemp(xmm1);
|
|
|
|
LTaggedToI* res = new LTaggedToI(value, xmm_temp);
|
|
|
|
return AssignEnvironment(DefineSameAsFirst(res));
|
|
|
|
} else {
|
|
|
|
return DefineSameAsFirst(new LSmiUntag(value, needs_check));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (from.IsDouble()) {
|
|
|
|
if (to.IsTagged()) {
|
|
|
|
LOperand* value = UseRegister(instr->value());
|
|
|
|
LOperand* temp = TempRegister();
|
|
|
|
|
|
|
|
// Make sure that temp and result_temp are different registers.
|
|
|
|
LUnallocated* result_temp = TempRegister();
|
|
|
|
LNumberTagD* result = new LNumberTagD(value, temp);
|
|
|
|
return AssignPointerMap(Define(result, result_temp));
|
|
|
|
} else {
|
|
|
|
ASSERT(to.IsInteger32());
|
|
|
|
bool needs_temp = instr->CanTruncateToInt32() &&
|
|
|
|
!CpuFeatures::IsSupported(SSE3);
|
|
|
|
LOperand* value = needs_temp ?
|
|
|
|
UseTempRegister(instr->value()) : UseRegister(instr->value());
|
|
|
|
LOperand* temp = needs_temp ? TempRegister() : NULL;
|
|
|
|
return AssignEnvironment(DefineAsRegister(new LDoubleToI(value, temp)));
|
|
|
|
}
|
|
|
|
} else if (from.IsInteger32()) {
|
|
|
|
if (to.IsTagged()) {
|
|
|
|
HValue* val = instr->value();
|
|
|
|
LOperand* value = UseRegister(val);
|
|
|
|
if (val->HasRange() && val->range()->IsInSmiRange()) {
|
|
|
|
return DefineSameAsFirst(new LSmiTag(value));
|
|
|
|
} else {
|
|
|
|
LNumberTagI* result = new LNumberTagI(value);
|
|
|
|
return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result)));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ASSERT(to.IsDouble());
|
|
|
|
return DefineAsRegister(new LInteger32ToDouble(Use(instr->value())));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
UNREACHABLE();
|
2011-01-13 10:04:02 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoCheckNonSmi(HCheckNonSmi* instr) {
|
2011-01-27 11:58:31 +00:00
|
|
|
LOperand* value = UseRegisterAtStart(instr->value());
|
|
|
|
return AssignEnvironment(new LCheckSmi(value, zero));
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoCheckInstanceType(HCheckInstanceType* instr) {
|
2011-02-04 14:09:03 +00:00
|
|
|
LOperand* value = UseRegisterAtStart(instr->value());
|
|
|
|
LCheckInstanceType* result = new LCheckInstanceType(value);
|
|
|
|
return AssignEnvironment(result);
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoCheckPrototypeMaps(HCheckPrototypeMaps* instr) {
|
2011-01-27 13:02:48 +00:00
|
|
|
LOperand* temp = TempRegister();
|
|
|
|
LCheckPrototypeMaps* result = new LCheckPrototypeMaps(temp);
|
|
|
|
return AssignEnvironment(result);
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoCheckSmi(HCheckSmi* instr) {
|
2011-01-27 11:58:31 +00:00
|
|
|
LOperand* value = UseRegisterAtStart(instr->value());
|
|
|
|
return AssignEnvironment(new LCheckSmi(value, not_zero));
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoCheckFunction(HCheckFunction* instr) {
|
2011-01-27 16:41:43 +00:00
|
|
|
LOperand* value = UseRegisterAtStart(instr->value());
|
|
|
|
return AssignEnvironment(new LCheckFunction(value));
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoCheckMap(HCheckMap* instr) {
|
2011-01-27 11:58:31 +00:00
|
|
|
LOperand* value = UseRegisterAtStart(instr->value());
|
|
|
|
LCheckMap* result = new LCheckMap(value);
|
|
|
|
return AssignEnvironment(result);
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoReturn(HReturn* instr) {
|
2011-01-14 10:27:25 +00:00
|
|
|
return new LReturn(UseFixed(instr->value(), rax));
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoConstant(HConstant* instr) {
|
2011-01-14 10:27:25 +00:00
|
|
|
Representation r = instr->representation();
|
|
|
|
if (r.IsInteger32()) {
|
|
|
|
int32_t value = instr->Integer32Value();
|
|
|
|
return DefineAsRegister(new LConstantI(value));
|
|
|
|
} else if (r.IsDouble()) {
|
|
|
|
double value = instr->DoubleValue();
|
2011-01-17 13:51:59 +00:00
|
|
|
LOperand* temp = TempRegister();
|
|
|
|
return DefineAsRegister(new LConstantD(value, temp));
|
2011-01-14 10:27:25 +00:00
|
|
|
} else if (r.IsTagged()) {
|
|
|
|
return DefineAsRegister(new LConstantT(instr->handle()));
|
|
|
|
} else {
|
|
|
|
UNREACHABLE();
|
|
|
|
return NULL;
|
|
|
|
}
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoLoadGlobal(HLoadGlobal* instr) {
|
2011-01-27 11:58:31 +00:00
|
|
|
LLoadGlobal* result = new LLoadGlobal;
|
|
|
|
return instr->check_hole_value()
|
|
|
|
? AssignEnvironment(DefineAsRegister(result))
|
|
|
|
: DefineAsRegister(result);
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoStoreGlobal(HStoreGlobal* instr) {
|
2011-02-04 14:09:03 +00:00
|
|
|
LStoreGlobal* result = new LStoreGlobal(UseRegister(instr->value()),
|
|
|
|
TempRegister());
|
|
|
|
return instr->check_hole_value() ? AssignEnvironment(result) : result;
|
2011-02-03 13:10:28 +00:00
|
|
|
}
|
2011-01-13 10:04:02 +00:00
|
|
|
|
|
|
|
|
2011-01-17 08:11:03 +00:00
|
|
|
LInstruction* LChunkBuilder::DoLoadContextSlot(HLoadContextSlot* instr) {
|
|
|
|
Abort("Unimplemented: %s", "DoLoadContextSlot");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-03 13:10:28 +00:00
|
|
|
LInstruction* LChunkBuilder::DoStoreContextSlot(HStoreContextSlot* instr) {
|
|
|
|
Abort("Unimplemented: DoStoreContextSlot");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-13 10:04:02 +00:00
|
|
|
LInstruction* LChunkBuilder::DoLoadNamedField(HLoadNamedField* instr) {
|
2011-01-27 13:02:48 +00:00
|
|
|
ASSERT(instr->representation().IsTagged());
|
|
|
|
LOperand* obj = UseRegisterAtStart(instr->object());
|
|
|
|
return DefineAsRegister(new LLoadNamedField(obj));
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoLoadNamedGeneric(HLoadNamedGeneric* instr) {
|
|
|
|
Abort("Unimplemented: %s", "DoLoadNamedGeneric");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoLoadFunctionPrototype(
|
|
|
|
HLoadFunctionPrototype* instr) {
|
|
|
|
Abort("Unimplemented: %s", "DoLoadFunctionPrototype");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoLoadElements(HLoadElements* instr) {
|
2011-02-03 17:01:10 +00:00
|
|
|
LOperand* input = UseRegisterAtStart(instr->value());
|
|
|
|
return DefineSameAsFirst(new LLoadElements(input));
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoLoadKeyedFastElement(
|
|
|
|
HLoadKeyedFastElement* instr) {
|
2011-02-03 17:01:10 +00:00
|
|
|
ASSERT(instr->representation().IsTagged());
|
|
|
|
ASSERT(instr->key()->representation().IsInteger32());
|
|
|
|
LOperand* obj = UseRegisterAtStart(instr->object());
|
|
|
|
LOperand* key = UseRegisterAtStart(instr->key());
|
|
|
|
LLoadKeyedFastElement* result = new LLoadKeyedFastElement(obj, key);
|
|
|
|
return AssignEnvironment(DefineSameAsFirst(result));
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) {
|
|
|
|
Abort("Unimplemented: %s", "DoLoadKeyedGeneric");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoStoreKeyedFastElement(
|
|
|
|
HStoreKeyedFastElement* instr) {
|
|
|
|
Abort("Unimplemented: %s", "DoStoreKeyedFastElement");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) {
|
|
|
|
Abort("Unimplemented: %s", "DoStoreKeyedGeneric");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) {
|
2011-01-27 13:02:48 +00:00
|
|
|
bool needs_write_barrier = instr->NeedsWriteBarrier();
|
|
|
|
|
|
|
|
LOperand* obj = needs_write_barrier
|
|
|
|
? UseTempRegister(instr->object())
|
|
|
|
: UseRegisterAtStart(instr->object());
|
|
|
|
|
|
|
|
LOperand* val = needs_write_barrier
|
|
|
|
? UseTempRegister(instr->value())
|
|
|
|
: UseRegister(instr->value());
|
|
|
|
|
|
|
|
// We only need a scratch register if we have a write barrier or we
|
|
|
|
// have a store into the properties array (not in-object-property).
|
|
|
|
LOperand* temp = (!instr->is_in_object() || needs_write_barrier)
|
|
|
|
? TempRegister() : NULL;
|
|
|
|
|
|
|
|
return new LStoreNamedField(obj, val, temp);
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoStoreNamedGeneric(HStoreNamedGeneric* instr) {
|
|
|
|
Abort("Unimplemented: %s", "DoStoreNamedGeneric");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-19 20:05:22 +00:00
|
|
|
LInstruction* LChunkBuilder::DoStringCharCodeAt(HStringCharCodeAt* instr) {
|
|
|
|
Abort("Unimplemented: %s", "DoStringCharCodeAt");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoStringLength(HStringLength* instr) {
|
|
|
|
Abort("Unimplemented: %s", "DoStringLength");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-13 10:04:02 +00:00
|
|
|
LInstruction* LChunkBuilder::DoArrayLiteral(HArrayLiteral* instr) {
|
2011-02-04 06:54:45 +00:00
|
|
|
return MarkAsCall(DefineFixed(new LArrayLiteral, rax), instr);
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoObjectLiteral(HObjectLiteral* instr) {
|
2011-02-04 06:54:45 +00:00
|
|
|
return MarkAsCall(DefineFixed(new LObjectLiteral, rax), instr);
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoRegExpLiteral(HRegExpLiteral* instr) {
|
|
|
|
Abort("Unimplemented: %s", "DoRegExpLiteral");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoFunctionLiteral(HFunctionLiteral* instr) {
|
2011-02-04 06:54:45 +00:00
|
|
|
return MarkAsCall(DefineFixed(new LFunctionLiteral, rax), instr);
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoDeleteProperty(HDeleteProperty* instr) {
|
|
|
|
Abort("Unimplemented: %s", "DoDeleteProperty");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoOsrEntry(HOsrEntry* instr) {
|
|
|
|
Abort("Unimplemented: %s", "DoOsrEntry");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoParameter(HParameter* instr) {
|
2011-01-14 10:27:25 +00:00
|
|
|
int spill_index = chunk()->GetParameterStackSlot(instr->index());
|
|
|
|
return DefineAsSpilled(new LParameter, spill_index);
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) {
|
|
|
|
Abort("Unimplemented: %s", "DoUnknownOSRValue");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoCallStub(HCallStub* instr) {
|
|
|
|
Abort("Unimplemented: %s", "DoCallStub");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) {
|
|
|
|
Abort("Unimplemented: %s", "DoArgumentsObject");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) {
|
|
|
|
Abort("Unimplemented: %s", "DoAccessArgumentsAt");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoTypeof(HTypeof* instr) {
|
|
|
|
Abort("Unimplemented: %s", "DoTypeof");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoTypeofIs(HTypeofIs* instr) {
|
|
|
|
Abort("Unimplemented: %s", "DoTypeofIs");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) {
|
2011-01-14 10:27:25 +00:00
|
|
|
HEnvironment* env = current_block_->last_environment();
|
|
|
|
ASSERT(env != NULL);
|
|
|
|
|
|
|
|
env->set_ast_id(instr->ast_id());
|
|
|
|
|
|
|
|
env->Drop(instr->pop_count());
|
|
|
|
for (int i = 0; i < instr->values()->length(); ++i) {
|
|
|
|
HValue* value = instr->values()->at(i);
|
|
|
|
if (instr->HasAssignedIndexAt(i)) {
|
|
|
|
env->Bind(instr->GetAssignedIndexAt(i), value);
|
|
|
|
} else {
|
|
|
|
env->Push(value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ASSERT(env->length() == instr->environment_length());
|
|
|
|
|
|
|
|
// If there is an instruction pending deoptimization environment create a
|
|
|
|
// lazy bailout instruction to capture the environment.
|
2011-01-26 08:03:48 +00:00
|
|
|
if (pending_deoptimization_ast_id_ == instr->ast_id()) {
|
2011-01-14 10:27:25 +00:00
|
|
|
LLazyBailout* lazy_bailout = new LLazyBailout;
|
|
|
|
LInstruction* result = AssignEnvironment(lazy_bailout);
|
2011-02-02 13:55:29 +00:00
|
|
|
instruction_pending_deoptimization_environment_->
|
2011-01-26 08:03:48 +00:00
|
|
|
set_deoptimization_environment(result->environment());
|
|
|
|
ClearInstructionPendingDeoptimizationEnvironment();
|
2011-01-14 10:27:25 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2011-01-13 10:04:02 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) {
|
2011-01-14 10:27:25 +00:00
|
|
|
return MarkAsCall(new LStackCheck, instr);
|
2011-01-13 10:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) {
|
2011-01-27 13:02:48 +00:00
|
|
|
HEnvironment* outer = current_block_->last_environment();
|
|
|
|
HConstant* undefined = graph()->GetConstantUndefined();
|
|
|
|
HEnvironment* inner = outer->CopyForInlining(instr->closure(),
|
|
|
|
instr->function(),
|
|
|
|
false,
|
|
|
|
undefined);
|
|
|
|
current_block_->UpdateEnvironment(inner);
|
|
|
|
chunk_->AddInlinedClosure(instr->closure());
|
2011-01-13 10:04:02 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) {
|
2011-02-03 15:40:20 +00:00
|
|
|
HEnvironment* outer = current_block_->last_environment()->outer();
|
|
|
|
current_block_->UpdateEnvironment(outer);
|
2011-01-13 10:04:02 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-01-05 12:31:31 +00:00
|
|
|
} } // namespace v8::internal
|
2011-01-13 14:10:26 +00:00
|
|
|
|
|
|
|
#endif // V8_TARGET_ARCH_X64
|