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

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

Issue 1377453005: Cleanups and preemptively pass Heap::kOld whenever subtype testing in compiler (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: sync Created 5 years, 2 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
« no previous file with comments | « runtime/vm/flow_graph_compiler_mips.cc ('k') | runtime/vm/flow_graph_optimizer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
7 7
8 #include "vm/flow_graph_compiler.h" 8 #include "vm/flow_graph_compiler.h"
9 9
10 #include "vm/ast_printer.h" 10 #include "vm/ast_printer.h"
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 const AbstractType& type, 259 const AbstractType& type,
260 Label* is_instance_lbl, 260 Label* is_instance_lbl,
261 Label* is_not_instance_lbl) { 261 Label* is_not_instance_lbl) {
262 __ Comment("InstantiatedTypeWithArgumentsTest"); 262 __ Comment("InstantiatedTypeWithArgumentsTest");
263 ASSERT(type.IsInstantiated()); 263 ASSERT(type.IsInstantiated());
264 const Class& type_class = Class::ZoneHandle(zone(), type.type_class()); 264 const Class& type_class = Class::ZoneHandle(zone(), type.type_class());
265 ASSERT((type_class.NumTypeArguments() > 0) || type_class.IsSignatureClass()); 265 ASSERT((type_class.NumTypeArguments() > 0) || type_class.IsSignatureClass());
266 const Register kInstanceReg = RAX; 266 const Register kInstanceReg = RAX;
267 Error& malformed_error = Error::Handle(zone()); 267 Error& malformed_error = Error::Handle(zone());
268 const Type& int_type = Type::Handle(zone(), Type::IntType()); 268 const Type& int_type = Type::Handle(zone(), Type::IntType());
269 const bool smi_is_ok = int_type.IsSubtypeOf(type, &malformed_error); 269 const bool smi_is_ok =
270 int_type.IsSubtypeOf(type, &malformed_error, Heap::kOld);
270 // Malformed type should have been handled at graph construction time. 271 // Malformed type should have been handled at graph construction time.
271 ASSERT(smi_is_ok || malformed_error.IsNull()); 272 ASSERT(smi_is_ok || malformed_error.IsNull());
272 __ testq(kInstanceReg, Immediate(kSmiTagMask)); 273 __ testq(kInstanceReg, Immediate(kSmiTagMask));
273 if (smi_is_ok) { 274 if (smi_is_ok) {
274 __ j(ZERO, is_instance_lbl); 275 __ j(ZERO, is_instance_lbl);
275 } else { 276 } else {
276 __ j(ZERO, is_not_instance_lbl); 277 __ j(ZERO, is_not_instance_lbl);
277 } 278 }
278 const intptr_t num_type_args = type_class.NumTypeArguments(); 279 const intptr_t num_type_args = type_class.NumTypeArguments();
279 const intptr_t num_type_params = type_class.NumTypeParameters(); 280 const intptr_t num_type_params = type_class.NumTypeParameters();
(...skipping 19 matching lines...) Expand all
299 } 300 }
300 // If one type argument only, check if type argument is Object or dynamic. 301 // If one type argument only, check if type argument is Object or dynamic.
301 if (type_arguments.Length() == 1) { 302 if (type_arguments.Length() == 1) {
302 const AbstractType& tp_argument = AbstractType::ZoneHandle(zone(), 303 const AbstractType& tp_argument = AbstractType::ZoneHandle(zone(),
303 type_arguments.TypeAt(0)); 304 type_arguments.TypeAt(0));
304 ASSERT(!tp_argument.IsMalformed()); 305 ASSERT(!tp_argument.IsMalformed());
305 if (tp_argument.IsType()) { 306 if (tp_argument.IsType()) {
306 ASSERT(tp_argument.HasResolvedTypeClass()); 307 ASSERT(tp_argument.HasResolvedTypeClass());
307 // Check if type argument is dynamic or Object. 308 // Check if type argument is dynamic or Object.
308 const Type& object_type = Type::Handle(zone(), Type::ObjectType()); 309 const Type& object_type = Type::Handle(zone(), Type::ObjectType());
309 if (object_type.IsSubtypeOf(tp_argument, NULL)) { 310 if (object_type.IsSubtypeOf(tp_argument, NULL, Heap::kOld)) {
310 // Instance class test only necessary. 311 // Instance class test only necessary.
311 return GenerateSubtype1TestCacheLookup( 312 return GenerateSubtype1TestCacheLookup(
312 token_pos, type_class, is_instance_lbl, is_not_instance_lbl); 313 token_pos, type_class, is_instance_lbl, is_not_instance_lbl);
313 } 314 }
314 } 315 }
315 } 316 }
316 } 317 }
317 // Regular subtype test cache involving instance's type arguments. 318 // Regular subtype test cache involving instance's type arguments.
318 const Register kTypeArgumentsReg = kNoRegister; 319 const Register kTypeArgumentsReg = kNoRegister;
319 const Register kTempReg = R10; 320 const Register kTempReg = R10;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 const Class& type_class = Class::Handle(zone(), type.type_class()); 354 const Class& type_class = Class::Handle(zone(), type.type_class());
354 ASSERT(type_class.NumTypeArguments() == 0); 355 ASSERT(type_class.NumTypeArguments() == 0);
355 356
356 const Register kInstanceReg = RAX; 357 const Register kInstanceReg = RAX;
357 __ testq(kInstanceReg, Immediate(kSmiTagMask)); 358 __ testq(kInstanceReg, Immediate(kSmiTagMask));
358 // If instance is Smi, check directly. 359 // If instance is Smi, check directly.
359 const Class& smi_class = Class::Handle(zone(), Smi::Class()); 360 const Class& smi_class = Class::Handle(zone(), Smi::Class());
360 if (smi_class.IsSubtypeOf(TypeArguments::Handle(zone()), 361 if (smi_class.IsSubtypeOf(TypeArguments::Handle(zone()),
361 type_class, 362 type_class,
362 TypeArguments::Handle(zone()), 363 TypeArguments::Handle(zone()),
363 NULL)) { 364 NULL,
365 Heap::kOld)) {
364 __ j(ZERO, is_instance_lbl); 366 __ j(ZERO, is_instance_lbl);
365 } else { 367 } else {
366 __ j(ZERO, is_not_instance_lbl); 368 __ j(ZERO, is_not_instance_lbl);
367 } 369 }
368 // Compare if the classes are equal. 370 // Compare if the classes are equal.
369 const Register kClassIdReg = R10; 371 const Register kClassIdReg = R10;
370 __ LoadClassId(kClassIdReg, kInstanceReg); 372 __ LoadClassId(kClassIdReg, kInstanceReg);
371 __ cmpl(kClassIdReg, Immediate(type_class.id())); 373 __ cmpl(kClassIdReg, Immediate(type_class.id()));
372 __ j(EQUAL, is_instance_lbl); 374 __ j(EQUAL, is_instance_lbl);
373 // See ClassFinalizer::ResolveSuperTypeAndInterfaces for list of restricted 375 // See ClassFinalizer::ResolveSuperTypeAndInterfaces for list of restricted
374 // interfaces. 376 // interfaces.
375 // Bool interface can be implemented only by core class Bool. 377 // Bool interface can be implemented only by core class Bool.
376 if (type.IsBoolType()) { 378 if (type.IsBoolType()) {
377 __ cmpl(kClassIdReg, Immediate(kBoolCid)); 379 __ cmpl(kClassIdReg, Immediate(kBoolCid));
378 __ j(EQUAL, is_instance_lbl); 380 __ j(EQUAL, is_instance_lbl);
379 __ jmp(is_not_instance_lbl); 381 __ jmp(is_not_instance_lbl);
380 return false; 382 return false;
381 } 383 }
382 if (type.IsFunctionType()) { 384 if (type.IsFunctionType()) {
383 // Check if instance is a closure. 385 // Check if instance is a closure.
384 __ LoadClassById(R13, kClassIdReg); 386 __ LoadClassById(R13, kClassIdReg);
385 __ movq(R13, FieldAddress(R13, Class::signature_function_offset())); 387 __ movq(R13, FieldAddress(R13, Class::signature_function_offset()));
386 __ CompareObject(R13, Object::null_object()); 388 __ CompareObject(R13, Object::null_object());
387 __ j(NOT_EQUAL, is_instance_lbl); 389 __ j(NOT_EQUAL, is_instance_lbl);
388 } 390 }
389 // Custom checking for numbers (Smi, Mint, Bigint and Double). 391 // Custom checking for numbers (Smi, Mint, Bigint and Double).
390 // Note that instance is not Smi (checked above). 392 // Note that instance is not Smi (checked above).
391 if (type.IsSubtypeOf(Type::Handle(zone(), Type::Number()), NULL)) { 393 if (type.IsSubtypeOf(
394 Type::Handle(zone(), Type::Number()), NULL, Heap::kOld)) {
392 GenerateNumberTypeCheck( 395 GenerateNumberTypeCheck(
393 kClassIdReg, type, is_instance_lbl, is_not_instance_lbl); 396 kClassIdReg, type, is_instance_lbl, is_not_instance_lbl);
394 return false; 397 return false;
395 } 398 }
396 if (type.IsStringType()) { 399 if (type.IsStringType()) {
397 GenerateStringTypeCheck(kClassIdReg, is_instance_lbl, is_not_instance_lbl); 400 GenerateStringTypeCheck(kClassIdReg, is_instance_lbl, is_not_instance_lbl);
398 return false; 401 return false;
399 } 402 }
400 // Otherwise fallthrough. 403 // Otherwise fallthrough.
401 return true; 404 return true;
(...skipping 1348 matching lines...) Expand 10 before | Expand all | Expand 10 after
1750 __ movups(reg, Address(RSP, 0)); 1753 __ movups(reg, Address(RSP, 0));
1751 __ AddImmediate(RSP, Immediate(kFpuRegisterSize)); 1754 __ AddImmediate(RSP, Immediate(kFpuRegisterSize));
1752 } 1755 }
1753 1756
1754 1757
1755 #undef __ 1758 #undef __
1756 1759
1757 } // namespace dart 1760 } // namespace dart
1758 1761
1759 #endif // defined TARGET_ARCH_X64 1762 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_mips.cc ('k') | runtime/vm/flow_graph_optimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698