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

Unified Diff: runtime/vm/assembler_ia32.cc

Issue 388863002: Better sequences for class id loading on ia32. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 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
Index: runtime/vm/assembler_ia32.cc
===================================================================
--- runtime/vm/assembler_ia32.cc (revision 38158)
+++ runtime/vm/assembler_ia32.cc (working copy)
@@ -290,6 +290,14 @@
}
+void Assembler::cmovne(Register dst, Register src) {
+ AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+ EmitUint8(0x0F);
+ EmitUint8(0x45);
+ EmitRegisterOperand(dst, src);
+}
+
+
void Assembler::cmovs(Register dst, Register src) {
AssemblerBuffer::EnsureCapacity ensured(&buffer_);
EmitUint8(0x0F);
@@ -2708,24 +2716,26 @@
Register result, Register object, Register tmp) {
ASSERT(object != tmp);
ASSERT(result != tmp);
+ static const intptr_t kSmiCidSource = kSmiCid << RawObject::kClassIdTagPos;
- // Make a copy of object since result and object can be the same register.
- movl(tmp, object);
- // Load up a null object. We only need it so we can use LoadClassId on it in
- // the case that object is a Smi.
- movl(result, Immediate(reinterpret_cast<intptr_t>(Object::null())));
- // Check if the object is a Smi.
+ if (result == object) {
+ movl(tmp, object);
+ } else {
+ tmp = object;
+ }
+
+ // Make a dummy "Object" whose cid is kSmiCid.
+ movl(result, Immediate(reinterpret_cast<int32_t>(&kSmiCidSource) + 1));
+
+ // Check if object (in tmp) is a Smi.
testl(tmp, Immediate(kSmiTagMask));
- // If the object *is* a Smi, load the null object into tmp. o/w leave alone.
- cmove(tmp, result);
- // Loads either the cid of the object if it isn't a Smi, or the cid of null
- // if it is a Smi, which will be ignored.
- LoadClassId(result, tmp);
- movl(tmp, Immediate(kSmiCid));
- // If object is a Smi, move the Smi cid into result. o/w leave alone.
- cmove(result, tmp);
- // Finally, tag the result.
+ // If the object is not a Smi, use the original object to load the cid.
+ // Otherwise, the dummy object is used, and the result is kSmiCid.
+ cmovne(result, tmp);
+ LoadClassId(result, result);
+
+ // Tag the result.
SmiTag(result);
}

Powered by Google App Engine
This is Rietveld 408576698