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

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

Issue 10695136: Use class id instead of class in subtype test cache. (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
« no previous file with comments | « no previous file | runtime/vm/object.h » ('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) 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/code_generator.h" 5 #include "vm/code_generator.h"
6 6
7 #include "vm/assembler_macros.h" 7 #include "vm/assembler_macros.h"
8 #include "vm/ast.h" 8 #include "vm/ast.h"
9 #include "vm/code_patcher.h" 9 #include "vm/code_patcher.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 const AbstractType& type, 344 const AbstractType& type,
345 const AbstractTypeArguments& instantiator_type_arguments, 345 const AbstractTypeArguments& instantiator_type_arguments,
346 const Bool& result) { 346 const Bool& result) {
347 DartFrameIterator iterator; 347 DartFrameIterator iterator;
348 StackFrame* caller_frame = iterator.NextFrame(); 348 StackFrame* caller_frame = iterator.NextFrame();
349 ASSERT(caller_frame != NULL); 349 ASSERT(caller_frame != NULL);
350 350
351 const Type& instance_type = Type::Handle(instance.GetType()); 351 const Type& instance_type = Type::Handle(instance.GetType());
352 ASSERT(instance_type.IsInstantiated()); 352 ASSERT(instance_type.IsInstantiated());
353 if (type.IsInstantiated()) { 353 if (type.IsInstantiated()) {
354 OS::Print("%s: '%s' %s '%s' (pc: 0x%x).\n", 354 OS::Print("%s: '%s' %d %s '%s' %d (pc: 0x%x).\n",
355 message, 355 message,
356 String::Handle(instance_type.Name()).ToCString(), 356 String::Handle(instance_type.Name()).ToCString(),
357 Class::Handle(instance_type.type_class()).id(),
357 (result.raw() == Bool::True()) ? "is" : "is !", 358 (result.raw() == Bool::True()) ? "is" : "is !",
358 String::Handle(type.Name()).ToCString(), 359 String::Handle(type.Name()).ToCString(),
360 Class::Handle(type.type_class()).id(),
359 caller_frame->pc()); 361 caller_frame->pc());
360 } else { 362 } else {
361 // Instantiate type before printing. 363 // Instantiate type before printing.
362 const AbstractType& instantiated_type = 364 const AbstractType& instantiated_type =
363 AbstractType::Handle(type.InstantiateFrom(instantiator_type_arguments)); 365 AbstractType::Handle(type.InstantiateFrom(instantiator_type_arguments));
364 OS::Print("%s: '%s' %s '%s' instantiated from '%s' (pc: 0x%x).\n", 366 OS::Print("%s: '%s' %s '%s' instantiated from '%s' (pc: 0x%x).\n",
365 message, 367 message,
366 String::Handle(instance_type.Name()).ToCString(), 368 String::Handle(instance_type.Name()).ToCString(),
367 (result.raw() == Bool::True()) ? "is" : "is !", 369 (result.raw() == Bool::True()) ? "is" : "is !",
368 String::Handle(instantiated_type.Name()).ToCString(), 370 String::Handle(instantiated_type.Name()).ToCString(),
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 instance, type, instantiator_type_arguments, result); 470 instance, type, instantiator_type_arguments, result);
469 } 471 }
470 return; 472 return;
471 } 473 }
472 if (replaced) { 474 if (replaced) {
473 type_arguments_replaced = true; 475 type_arguments_replaced = true;
474 } 476 }
475 instantiator_type_arguments = instantiator.GetTypeArguments(); 477 instantiator_type_arguments = instantiator.GetTypeArguments();
476 } 478 }
477 479
478 Class& last_instance_class = Class::Handle(); 480 intptr_t last_instance_class_id = -1;
479 AbstractTypeArguments& last_instance_type_arguments = 481 AbstractTypeArguments& last_instance_type_arguments =
480 AbstractTypeArguments::Handle(); 482 AbstractTypeArguments::Handle();
481 AbstractTypeArguments& last_instantiator_type_arguments = 483 AbstractTypeArguments& last_instantiator_type_arguments =
482 AbstractTypeArguments::Handle(); 484 AbstractTypeArguments::Handle();
483 Bool& last_result = Bool::Handle(); 485 Bool& last_result = Bool::Handle();
484 intptr_t len = new_cache.NumberOfChecks(); 486 intptr_t len = new_cache.NumberOfChecks();
485 for (intptr_t i = 0; i < len; ++i) { 487 for (intptr_t i = 0; i < len; ++i) {
486 new_cache.GetCheck( 488 new_cache.GetCheck(
487 i, 489 i,
488 &last_instance_class, 490 &last_instance_class_id,
489 &last_instance_type_arguments, 491 &last_instance_type_arguments,
490 &last_instantiator_type_arguments, 492 &last_instantiator_type_arguments,
491 &last_result); 493 &last_result);
492 if ((last_instance_class.raw() == instance_class.raw()) && 494 if ((last_instance_class_id == instance_class.id()) &&
493 (last_instance_type_arguments.raw() == instance_type_arguments.raw()) && 495 (last_instance_type_arguments.raw() == instance_type_arguments.raw()) &&
494 (last_instantiator_type_arguments.raw() == 496 (last_instantiator_type_arguments.raw() ==
495 instantiator_type_arguments.raw())) { 497 instantiator_type_arguments.raw())) {
496 if (FLAG_trace_type_checks) { 498 if (FLAG_trace_type_checks) {
497 OS::Print("%d ", i); 499 OS::Print("%d ", i);
498 if (type_arguments_replaced) { 500 if (type_arguments_replaced) {
499 PrintTypeCheck("Duplicate cache entry (canonical.)", instance, type, 501 PrintTypeCheck("Duplicate cache entry (canonical.)", instance, type,
500 instantiator_type_arguments, result); 502 instantiator_type_arguments, result);
501 } else { 503 } else {
502 PrintTypeCheck("WARNING Duplicate cache entry", instance, type, 504 PrintTypeCheck("WARNING Duplicate cache entry", instance, type,
503 instantiator_type_arguments, result); 505 instantiator_type_arguments, result);
504 } 506 }
505 } 507 }
506 // Can occur if we have canonicalized arguments. 508 // Can occur if we have canonicalized arguments.
507 // TODO(srdjan): Investigate why this assert can fail. 509 // TODO(srdjan): Investigate why this assert can fail.
508 // ASSERT(type_arguments_replaced); 510 // ASSERT(type_arguments_replaced);
509 return; 511 return;
510 } 512 }
511 } 513 }
512 new_cache.AddCheck(instance_class, 514 new_cache.AddCheck(instance_class.id(),
513 instance_type_arguments, 515 instance_type_arguments,
514 instantiator_type_arguments, 516 instantiator_type_arguments,
515 result); 517 result);
516 if (FLAG_trace_type_checks) { 518 if (FLAG_trace_type_checks) {
517 AbstractType& test_type = AbstractType::Handle(type.raw()); 519 AbstractType& test_type = AbstractType::Handle(type.raw());
518 if (!test_type.IsInstantiated()) { 520 if (!test_type.IsInstantiated()) {
519 test_type = type.InstantiateFrom(instantiator_type_arguments); 521 test_type = type.InstantiateFrom(instantiator_type_arguments);
520 } 522 }
521 OS::Print(" Updated test cache 0x%x ix:%d:\n" 523 OS::Print(" Updated test cache 0x%x ix:%d:\n"
522 " [0x%x %s, 0x%x %s]\n" 524 " [0x%x %s %d, 0x%x %s]\n"
523 " [0x%x %s, 0x%x %s] %s\n", 525 " [0x%x %s %d, 0x%x %s] %s\n",
524 new_cache.raw(), 526 new_cache.raw(),
525 len, 527 len,
526 instance_class.raw(), 528 instance_class.raw(),
527 instance_class.ToCString(), 529 instance_class.ToCString(),
530 instance_class.id(),
528 instance_type_arguments.raw(), 531 instance_type_arguments.raw(),
529 instance_type_arguments.ToCString(), 532 instance_type_arguments.ToCString(),
530 test_type.type_class(), 533 test_type.type_class(),
531 Class::Handle(test_type.type_class()).ToCString(), 534 Class::Handle(test_type.type_class()).ToCString(),
535 Class::Handle(test_type.type_class()).id(),
532 instantiator_type_arguments.raw(), 536 instantiator_type_arguments.raw(),
533 instantiator_type_arguments.ToCString(), 537 instantiator_type_arguments.ToCString(),
534 result.ToCString()); 538 result.ToCString());
535 } 539 }
536 } 540 }
537 541
538 542
539 // Check that the given instance is an instance of the given type. 543 // Check that the given instance is an instance of the given type.
540 // Tested instance may not be null, because the null test is inlined. 544 // Tested instance may not be null, because the null test is inlined.
541 // Arg0: node id of the instanceof node. 545 // Arg0: node id of the instanceof node.
(...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after
1532 } 1536 }
1533 } 1537 }
1534 } 1538 }
1535 // The cache is null terminated, therefore the loop above should never 1539 // The cache is null terminated, therefore the loop above should never
1536 // terminate by itself. 1540 // terminate by itself.
1537 UNREACHABLE(); 1541 UNREACHABLE();
1538 return Code::null(); 1542 return Code::null();
1539 } 1543 }
1540 1544
1541 } // namespace dart 1545 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698