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

Side by Side Diff: runtime/vm/flow_graph_compiler_ia32.cc

Issue 10823022: Improve static type propagation. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32.
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
7 7
8 #include "vm/flow_graph_compiler.h" 8 #include "vm/flow_graph_compiler.h"
9 9
10 #include "lib/error.h" 10 #include "lib/error.h"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 } 176 }
177 // If one type argument only, check if type argument is Object or Dynamic. 177 // If one type argument only, check if type argument is Object or Dynamic.
178 if (type_arguments.Length() == 1) { 178 if (type_arguments.Length() == 1) {
179 const AbstractType& tp_argument = AbstractType::ZoneHandle( 179 const AbstractType& tp_argument = AbstractType::ZoneHandle(
180 type_arguments.TypeAt(0)); 180 type_arguments.TypeAt(0));
181 ASSERT(!tp_argument.IsMalformed()); 181 ASSERT(!tp_argument.IsMalformed());
182 if (tp_argument.IsType()) { 182 if (tp_argument.IsType()) {
183 ASSERT(tp_argument.HasResolvedTypeClass()); 183 ASSERT(tp_argument.HasResolvedTypeClass());
184 // Check if type argument is dynamic or Object. 184 // Check if type argument is dynamic or Object.
185 const Type& object_type = Type::Handle(Type::ObjectType()); 185 const Type& object_type = Type::Handle(Type::ObjectType());
186 Error& malformed_error = Error::Handle(); 186 if (object_type.IsSubtypeOf(tp_argument, NULL)) {
187 if (object_type.IsSubtypeOf(tp_argument, &malformed_error)) {
188 // Instance class test only necessary. 187 // Instance class test only necessary.
189 return GenerateSubtype1TestCacheLookup( 188 return GenerateSubtype1TestCacheLookup(
190 cid, token_pos, type_class, is_instance_lbl, is_not_instance_lbl); 189 cid, token_pos, type_class, is_instance_lbl, is_not_instance_lbl);
191 } 190 }
192 } 191 }
193 } 192 }
194 // Regular subtype test cache involving instance's type arguments. 193 // Regular subtype test cache involving instance's type arguments.
195 const Register kTypeArgumentsReg = kNoRegister; 194 const Register kTypeArgumentsReg = kNoRegister;
196 const Register kTempReg = EDI; 195 const Register kTempReg = EDI;
197 return GenerateCallSubtypeTestStub(kTestTypeTwoArgs, 196 return GenerateCallSubtypeTestStub(kTestTypeTwoArgs,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 ASSERT(type.IsInstantiated()); 228 ASSERT(type.IsInstantiated());
230 const Class& type_class = Class::Handle(type.type_class()); 229 const Class& type_class = Class::Handle(type.type_class());
231 ASSERT(!type_class.HasTypeArguments()); 230 ASSERT(!type_class.HasTypeArguments());
232 231
233 const Register kInstanceReg = EAX; 232 const Register kInstanceReg = EAX;
234 Label compare_classes; 233 Label compare_classes;
235 __ testl(kInstanceReg, Immediate(kSmiTagMask)); 234 __ testl(kInstanceReg, Immediate(kSmiTagMask));
236 __ j(NOT_ZERO, &compare_classes, Assembler::kNearJump); 235 __ j(NOT_ZERO, &compare_classes, Assembler::kNearJump);
237 // Instance is Smi, check directly. 236 // Instance is Smi, check directly.
238 const Class& smi_class = Class::Handle(Smi::Class()); 237 const Class& smi_class = Class::Handle(Smi::Class());
239 Error& malformed_error = Error::Handle();
240 if (smi_class.IsSubtypeOf(TypeArguments::Handle(), 238 if (smi_class.IsSubtypeOf(TypeArguments::Handle(),
241 type_class, 239 type_class,
242 TypeArguments::Handle(), 240 TypeArguments::Handle(),
243 &malformed_error)) { 241 NULL)) {
244 __ jmp(is_instance_lbl); 242 __ jmp(is_instance_lbl);
245 } else { 243 } else {
246 __ jmp(is_not_instance_lbl); 244 __ jmp(is_not_instance_lbl);
247 } 245 }
248 // Compare if the classes are equal. 246 // Compare if the classes are equal.
249 __ Bind(&compare_classes); 247 __ Bind(&compare_classes);
250 const Register kClassIdReg = ECX; 248 const Register kClassIdReg = ECX;
251 __ LoadClassId(kClassIdReg, kInstanceReg); 249 __ LoadClassId(kClassIdReg, kInstanceReg);
252 // If type is an interface, we can skip the class equality check. 250 // If type is an interface, we can skip the class equality check.
253 if (!type_class.is_interface()) { 251 if (!type_class.is_interface()) {
(...skipping 14 matching lines...) Expand all
268 Immediate(reinterpret_cast<intptr_t>(Object::null())); 266 Immediate(reinterpret_cast<intptr_t>(Object::null()));
269 __ LoadClassById(EDI, kClassIdReg); 267 __ LoadClassById(EDI, kClassIdReg);
270 __ movl(EDI, FieldAddress(EDI, Class::signature_function_offset())); 268 __ movl(EDI, FieldAddress(EDI, Class::signature_function_offset()));
271 __ cmpl(EDI, raw_null); 269 __ cmpl(EDI, raw_null);
272 __ j(NOT_EQUAL, is_instance_lbl); 270 __ j(NOT_EQUAL, is_instance_lbl);
273 __ jmp(is_not_instance_lbl); 271 __ jmp(is_not_instance_lbl);
274 return false; 272 return false;
275 } 273 }
276 // Custom checking for numbers (Smi, Mint, Bigint and Double). 274 // Custom checking for numbers (Smi, Mint, Bigint and Double).
277 // Note that instance is not Smi (checked above). 275 // Note that instance is not Smi (checked above).
278 if (type.IsSubtypeOf( 276 if (type.IsSubtypeOf(Type::Handle(Type::NumberInterface()), NULL)) {
279 Type::Handle(Type::NumberInterface()), &malformed_error)) {
280 GenerateNumberTypeCheck( 277 GenerateNumberTypeCheck(
281 kClassIdReg, type, is_instance_lbl, is_not_instance_lbl); 278 kClassIdReg, type, is_instance_lbl, is_not_instance_lbl);
282 return false; 279 return false;
283 } 280 }
284 if (type.IsStringInterface()) { 281 if (type.IsStringInterface()) {
285 GenerateStringTypeCheck(kClassIdReg, is_instance_lbl, is_not_instance_lbl); 282 GenerateStringTypeCheck(kClassIdReg, is_instance_lbl, is_not_instance_lbl);
286 return false; 283 return false;
287 } 284 }
288 // Otherwise fallthrough. 285 // Otherwise fallthrough.
289 return true; 286 return true;
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 __ popl(ECX); 1224 __ popl(ECX);
1228 __ popl(EAX); 1225 __ popl(EAX);
1229 } 1226 }
1230 1227
1231 1228
1232 #undef __ 1229 #undef __
1233 1230
1234 } // namespace dart 1231 } // namespace dart
1235 1232
1236 #endif // defined TARGET_ARCH_IA32 1233 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698