From 1c783dea87675a0e65e780f64de17258ff82ce4f Mon Sep 17 00:00:00 2001 From: Zachary Anderson Date: Fri, 1 Jul 2016 10:19:21 -0700 Subject: [PATCH] DBC: Remove special case from CheckClassInstr. Cleanup. R=vegorov@google.com Review URL: https://codereview.chromium.org/2111803003 . --- runtime/vm/flow_graph_compiler.h | 3 ++ runtime/vm/flow_graph_compiler_dbc.cc | 11 +++++ runtime/vm/il_printer.cc | 7 +++ runtime/vm/intermediate_language.cc | 6 +++ runtime/vm/intermediate_language.h | 2 + runtime/vm/intermediate_language_dbc.cc | 61 ++++++------------------- 6 files changed, 43 insertions(+), 47 deletions(-) diff --git a/runtime/vm/flow_graph_compiler.h b/runtime/vm/flow_graph_compiler.h index e728582f8b0..0a30dc9da57 100644 --- a/runtime/vm/flow_graph_compiler.h +++ b/runtime/vm/flow_graph_compiler.h @@ -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); diff --git a/runtime/vm/flow_graph_compiler_dbc.cc b/runtime/vm/flow_graph_compiler_dbc.cc index 855730e7593..8fb0b4c54f1 100644 --- a/runtime/vm/flow_graph_compiler_dbc.cc +++ b/runtime/vm/flow_graph_compiler_dbc.cc @@ -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(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(); diff --git a/runtime/vm/il_printer.cc b/runtime/vm/il_printer.cc index 204725c7821..51045452203 100644 --- a/runtime/vm/il_printer.cc +++ b/runtime/vm/il_printer.cc @@ -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(); diff --git a/runtime/vm/intermediate_language.cc b/runtime/vm/intermediate_language.cc index 43c10c6227b..689d535ed0c 100644 --- a/runtime/vm/intermediate_language.cc +++ b/runtime/vm/intermediate_language.cc @@ -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(); } diff --git a/runtime/vm/intermediate_language.h b/runtime/vm/intermediate_language.h index 44cf12105cf..73073443856 100644 --- a/runtime/vm/intermediate_language.h +++ b/runtime/vm/intermediate_language.h @@ -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; diff --git a/runtime/vm/intermediate_language_dbc.cc b/runtime/vm/intermediate_language_dbc.cc index cfbfaa8ca07..8c954b66fda 100644 --- a/runtime/vm/intermediate_language_dbc.cc +++ b/runtime/vm/intermediate_language_dbc.cc @@ -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 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)); } } }