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

Unified Diff: runtime/vm/assembler_x64.cc

Issue 10458031: In generated code for x64 don't load object's class directly from class_ field. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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_x64.cc
diff --git a/runtime/vm/assembler_x64.cc b/runtime/vm/assembler_x64.cc
index d7e8aac433060be3d82abea01de8859063d74a56..eb47498980675467607d18959c5fa8fa3349c38f 100644
--- a/runtime/vm/assembler_x64.cc
+++ b/runtime/vm/assembler_x64.cc
@@ -1540,6 +1540,41 @@ void Assembler::EmitGenericShift(bool wide,
}
+void Assembler::LoadClassIndexOfObject(Register result, Register object) {
+ ASSERT(RawObject::kClassTagBit == 16);
+ ASSERT(RawObject::kClassTagSize == 16);
+ const intptr_t class_id_offset = Object::tags_offset() +
+ RawObject::kClassTagBit / kBitsPerByte;
+ movzxw(result, FieldAddress(object, class_id_offset));
+}
+
+
+void Assembler::LoadClassByIndex(Register result, Register class_index) {
+ ASSERT(result != class_index);
+ movq(result, FieldAddress(CTX, Context::isolate_offset()));
+ const intptr_t table_offset_in_isolate =
+ Isolate::class_table_offset() + ClassTable::table_offset();
+ movq(result, Address(result, table_offset_in_isolate));
+ movq(result, Address(result, class_index, TIMES_8, 0));
+}
+
+
+void Assembler::LoadClassOfObject(Register result,
+ Register object,
+ Register scratch) {
srdjan 2012/05/30 16:44:00 You do not need to pass scratch, use TMP register
+ LoadClassIndexOfObject(scratch, object);
+ LoadClassByIndex(result, scratch);
+}
+
+
+void Assembler::CompareClassOfObject(Register object,
+ const Class& clazz,
+ Register scratch) {
srdjan 2012/05/30 16:44:00 ditto
+ LoadClassIndexOfObject(scratch, object);
+ cmpl(scratch, Immediate(clazz.index()));
+}
+
+
void Assembler::Comment(const char* format, ...) {
if (FLAG_code_comments) {
char buffer[1024];

Powered by Google App Engine
This is Rietveld 408576698