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

Unified Diff: runtime/vm/code_generator_ia32.cc

Issue 8508035: For instanceof inline check against right hand class id possible and interface String for OneByte... (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 1 month 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
« runtime/vm/code_generator.cc ('K') | « runtime/vm/code_generator.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/code_generator_ia32.cc
===================================================================
--- runtime/vm/code_generator_ia32.cc (revision 1375)
+++ runtime/vm/code_generator_ia32.cc (working copy)
@@ -1415,11 +1415,32 @@
const Class& type_class = Class::ZoneHandle(type.type_class());
const bool requires_type_arguments = type_class.HasTypeArguments();
// A Smi object cannot be the instance of a parameterized class.
- // A class equality check is only applicable to a non-parameterized class.
+ // A class equality check is only applicable with a dst type of a
+ // non-parameterized class or with a raw dst type of a parameterized class.
// TODO(regis): Should we still inline a Smi type check when checking for a
regis 2011/11/10 03:09:51 I think you can remove this TODO now.
srdjan 2011/11/10 17:24:41 Done.
// parameterized type and return false for a Smi's without calling the
// runtime?
- if (!requires_type_arguments) {
+ if (requires_type_arguments) {
+ const TypeArguments& type_arguments =
+ TypeArguments::Handle(type.arguments());
+ const bool is_raw_type = type_arguments.IsNull() ||
+ type_arguments.IsDynamicTypes(type_arguments.Length());
+ if (is_raw_type) {
+ if (!type_class.is_interface()) {
+ Label runtime_call;
+ __ testl(EAX, Immediate(kSmiTagMask));
+ __ j(ZERO, &runtime_call, Assembler::kNearJump);
regis 2011/11/10 03:09:51 Can't you perform this Smi check even if the type
srdjan 2011/11/10 17:24:41 Done.
+ // Object not Smi.
+ __ movl(ECX, FieldAddress(EAX, Object::class_offset()));
+ __ CompareObject(ECX, type_class);
+ __ j(NOT_EQUAL, &runtime_call, Assembler::kNearJump);
+ __ PushObject(negate_result ? bool_false : bool_true);
+ __ jmp(&done, Assembler::kNearJump);
+ __ Bind(&runtime_call);
+ // Fall through to runtime call.
+ }
+ }
+ } else {
Label compare_classes;
__ testl(EAX, Immediate(kSmiTagMask));
__ j(NOT_ZERO, &compare_classes, Assembler::kNearJump);
@@ -1437,9 +1458,19 @@
// Compare if the classes are equal.
__ Bind(&compare_classes);
- // If type is an interface, we can skip the class equality check,
- // because instances cannot be of an interface type.
- if (!type_class.is_interface()) {
+ if (type_class.is_interface()) {
+ if (type.IsStringInterface()) {
+ Label runtime_call;
+ __ movl(ECX, FieldAddress(EAX, Object::class_offset()));
+ const Class& one_byte_string_class = Class::ZoneHandle(
+ Isolate::Current()->object_store()->one_byte_string_class());
+ __ CompareObject(ECX, one_byte_string_class);
+ __ j(NOT_EQUAL, &runtime_call, Assembler::kNearJump);
+ __ PushObject(negate_result ? bool_false : bool_true);
+ __ jmp(&done, Assembler::kNearJump);
+ __ Bind(&runtime_call);
+ }
+ } else { // type_class is not an interface.
Label runtime_call;
__ movl(ECX, FieldAddress(EAX, Object::class_offset()));
__ CompareObject(ECX, type_class);
@@ -1565,7 +1596,7 @@
}
// Fall through to runtime class.
}
- } else {
+ } else { // dst_type has NO type parameters.
regis 2011/11/10 03:09:51 Sorry to be picky, but "type parameters" is the wr
srdjan 2011/11/10 17:24:41 Done.
Label compare_classes;
__ testl(EAX, Immediate(kSmiTagMask));
__ j(NOT_ZERO, &compare_classes, Assembler::kNearJump);
« runtime/vm/code_generator.cc ('K') | « runtime/vm/code_generator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698