DBC: Remove special case from CheckClassInstr. Cleanup.

R=vegorov@google.com

Review URL: https://codereview.chromium.org/2111803003 .
This commit is contained in:
Zachary Anderson 2016-07-01 10:19:21 -07:00
parent 7f0273f83e
commit 1c783dea87
6 changed files with 43 additions and 47 deletions

View file

@ -532,6 +532,9 @@ class FlowGraphCompiler : public ValueObject {
void EmitDeopt(intptr_t deopt_id,
ICData::DeoptReasonId reason,
uint32_t flags = 0);
// If the cid does not fit in 16 bits, then this will cause a bailout.
uint16_t ToEmbeddableCid(intptr_t cid, Instruction* instruction);
#endif // defined(TARGET_ARCH_DBC)
void AddDeoptIndexAtCall(intptr_t deopt_id, TokenPosition token_pos);

View file

@ -397,6 +397,16 @@ void FlowGraphCompiler::CompileGraph() {
}
uint16_t FlowGraphCompiler::ToEmbeddableCid(intptr_t cid,
Instruction* instruction) {
if (!Utils::IsUint(16, cid)) {
instruction->Unsupported(this);
UNREACHABLE();
}
return static_cast<uint16_t>(cid);
}
#undef __
#define __ compiler_->assembler()->
@ -416,6 +426,7 @@ void ParallelMoveResolver::EmitMove(int index) {
__ LoadConstant(destination.reg(), source.constant());
} else {
compiler_->Bailout("Unsupported move");
UNREACHABLE();
}
move->Eliminate();

View file

@ -1275,8 +1275,15 @@ const char* Environment::ToCString() const {
return Thread::Current()->zone()->MakeCopyOfString(buffer);
}
#else // PRODUCT
const char* Instruction::ToCString() const {
return DebugName();
}
void FlowGraphPrinter::PrintOneInstruction(Instruction* instr,
bool print_locations) {
UNREACHABLE();

View file

@ -126,6 +126,12 @@ bool Instruction::Equals(Instruction* other) const {
}
void Instruction::Unsupported(FlowGraphCompiler* compiler) {
compiler->Bailout(ToCString());
UNREACHABLE();
}
bool Value::Equals(Value* other) const {
return definition() == other->definition();
}

View file

@ -891,6 +891,8 @@ FOR_EACH_ABSTRACT_INSTRUCTION(INSTRUCTION_TYPE_CHECK)
void ClearEnv() { env_ = NULL; }
void Unsupported(FlowGraphCompiler* compiler);
protected:
// GetDeoptId and/or CopyDeoptIdFrom.
friend class CallSiteInliner;

View file

@ -228,11 +228,8 @@ LocationSummary* PolymorphicInstanceCallInstr::MakeLocationSummary(
void PolymorphicInstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
#if defined(PRODUCT)
compiler->Bailout("PolymorphicInstanceCallInstr::EmitNativeCode");
#else // defined(PRODUCT)
compiler->Bailout(ToCString());
#endif // defined(PRODUCT)
Unsupported(compiler);
UNREACHABLE();
}
@ -565,13 +562,9 @@ EMIT_NATIVE_CODE(CreateArray,
EMIT_NATIVE_CODE(StoreIndexed, 3) {
if (compiler->is_optimizing()) {
if (class_id() != kArrayCid) {
#if defined(PRODUCT)
compiler->Bailout("StoreIndexed");
#else // defined(PRODUCT)
compiler->Bailout(ToCString());
#endif // defined(PRODUCT)
Unsupported(compiler);
UNREACHABLE();
}
__ StoreIndexed(locs()->in(kArrayPos).reg(),
locs()->in(kIndexPos).reg(),
locs()->in(kValuePos).reg());
@ -1015,24 +1008,13 @@ EMIT_NATIVE_CODE(CheckEitherNonSmi, 2) {
EMIT_NATIVE_CODE(CheckClassId, 1) {
if (!Utils::IsUint(16, cid_)) {
#if defined(PRODUCT)
compiler->Bailout("CheckClassInstr::EmitNativeCode");
#else // defined(PRODUCT)
compiler->Bailout(ToCString());
#endif // defined(PRODUCT)
}
__ CheckClassId(locs()->in(0).reg(), cid_);
__ CheckClassId(locs()->in(0).reg(),
compiler->ToEmbeddableCid(cid_, this));
compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckClass);
}
EMIT_NATIVE_CODE(CheckClass, 1) {
#if defined(PRODUCT)
const char* bailout_msg = "CheckClassInstr::EmitNativeCode";
#else // defined(PRODUCT)
const char* bailout_msg = ToCString();
#endif // defined(PRODUCT)
const Register value = locs()->in(0).reg();
if (IsNullCheck()) {
ASSERT(DeoptIfNull() || DeoptIfNotNull());
@ -1049,12 +1031,9 @@ EMIT_NATIVE_CODE(CheckClass, 1) {
if (IsDenseSwitch()) {
ASSERT(cids_[0] < cids_[cids_.length() - 1]);
const intptr_t low_cid = cids_[0];
if (!Utils::IsUint(16, low_cid)) {
compiler->Bailout(bailout_msg);
}
const intptr_t cid_mask = ComputeCidMask();
__ CheckDenseSwitch(value, may_be_smi);
__ Nop(low_cid);
__ Nop(compiler->ToEmbeddableCid(low_cid, this));
__ Nop(__ AddConstant(Smi::Handle(Smi::New(cid_mask))));
} else {
GrowableArray<CidTarget> sorted_ic_data;
@ -1062,25 +1041,13 @@ EMIT_NATIVE_CODE(CheckClass, 1) {
&sorted_ic_data,
/* drop_smi = */ true);
const intptr_t sorted_length = sorted_ic_data.length();
ASSERT(sorted_length >= 1);
if (sorted_length == 1) {
const intptr_t cid = sorted_ic_data[0].cid;
if (!Utils::IsUint(16, cid)) {
compiler->Bailout(bailout_msg);
}
__ CheckClassId(value, cid);
} else {
if (!Utils::IsUint(8, sorted_length)) {
compiler->Bailout(bailout_msg);
}
__ CheckCids(value, may_be_smi, sorted_length);
for (intptr_t i = 0; i < sorted_length; i++) {
const intptr_t cid = sorted_ic_data[i].cid;
if (!Utils::IsUint(16, cid)) {
compiler->Bailout(bailout_msg);
}
__ Nop(cid);
}
if (!Utils::IsUint(8, sorted_length)) {
Unsupported(compiler);
UNREACHABLE();
}
__ CheckCids(value, may_be_smi, sorted_length);
for (intptr_t i = 0; i < sorted_length; i++) {
__ Nop(compiler->ToEmbeddableCid(sorted_ic_data[i].cid, this));
}
}
}