Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(737)

Unified Diff: runtime/vm/intermediate_language_ia32.cc

Issue 1897983002: VM: Avoid smi-check when loading class-ids from known non-smi values (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: addressed comments Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/intermediate_language_arm64.cc ('k') | runtime/vm/intermediate_language_mips.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intermediate_language_ia32.cc
diff --git a/runtime/vm/intermediate_language_ia32.cc b/runtime/vm/intermediate_language_ia32.cc
index 8cae0874c69766dadc1a9c0a81570e5bbd6fbe06..d71cf0287060b8ba3480c309d12e1c5c6062c415 100644
--- a/runtime/vm/intermediate_language_ia32.cc
+++ b/runtime/vm/intermediate_language_ia32.cc
@@ -953,19 +953,25 @@ LocationSummary* LoadClassIdInstr::MakeLocationSummary(Zone* zone,
void LoadClassIdInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
const Register object = locs()->in(0).reg();
const Register result = locs()->out(0).reg();
- Label done;
-
- // We don't use Assembler::LoadTaggedClassIdMayBeSmi() here---which uses
- // a conditional move instead, and requires an additional register---because
- // it is slower, probably due to branch prediction usually working just fine
- // in this case.
- ASSERT(result != object);
- __ movl(result, Immediate(kSmiCid << 1));
- __ testl(object, Immediate(kSmiTagMask));
- __ j(EQUAL, &done, Assembler::kNearJump);
- __ LoadClassId(result, object);
- __ SmiTag(result);
- __ Bind(&done);
+ const AbstractType& value_type = *this->object()->Type()->ToAbstractType();
+ if (CompileType::Smi().IsAssignableTo(value_type) ||
+ value_type.IsTypeParameter()) {
+ // We don't use Assembler::LoadTaggedClassIdMayBeSmi() here---which uses
+ // a conditional move instead, and requires an additional register---because
+ // it is slower, probably due to branch prediction usually working just fine
+ // in this case.
+ ASSERT(result != object);
+ Label done;
+ __ movl(result, Immediate(kSmiCid << 1));
+ __ testl(object, Immediate(kSmiTagMask));
+ __ j(EQUAL, &done, Assembler::kNearJump);
+ __ LoadClassId(result, object);
+ __ SmiTag(result);
+ __ Bind(&done);
+ } else {
+ __ LoadClassId(result, object);
+ __ SmiTag(result);
+ }
}
« no previous file with comments | « runtime/vm/intermediate_language_arm64.cc ('k') | runtime/vm/intermediate_language_mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698