Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/code_patcher.h" | 7 #include "vm/code_patcher.h" |
| 8 #include "vm/compiler.h" | 8 #include "vm/compiler.h" |
| 9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 424 const Class& type_class = Class::ZoneHandle(instance.clazz()); | 424 const Class& type_class = Class::ZoneHandle(instance.clazz()); |
| 425 if (!type_class.HasTypeArguments()) { | 425 if (!type_class.HasTypeArguments()) { |
| 426 return true; | 426 return true; |
| 427 } | 427 } |
| 428 const AbstractTypeArguments& type_arguments = | 428 const AbstractTypeArguments& type_arguments = |
| 429 AbstractTypeArguments::Handle(instance.GetTypeArguments()); | 429 AbstractTypeArguments::Handle(instance.GetTypeArguments()); |
| 430 if (type_arguments.IsNull()) { | 430 if (type_arguments.IsNull()) { |
| 431 return true; | 431 return true; |
| 432 } | 432 } |
| 433 if (type_arguments.IsInstantiatedTypeArguments()) { | 433 if (type_arguments.IsInstantiatedTypeArguments()) { |
| 434 AbstractTypeArguments& temp_type_arguments = | |
|
regis
2012/05/07 21:13:04
Why do you need temp_type_arguments instead of usi
srdjan
2012/05/07 21:23:12
Good point, eliminating temp_type_arguments.
| |
| 435 AbstractTypeArguments::Handle(type_arguments.raw()); | |
| 436 do { | |
| 437 InstantiatedTypeArguments& instantiated_type_arguments = | |
| 438 InstantiatedTypeArguments::Handle(); | |
| 439 instantiated_type_arguments ^= temp_type_arguments.raw(); | |
| 440 const AbstractTypeArguments& uninstantiated = | |
| 441 AbstractTypeArguments::Handle( | |
| 442 instantiated_type_arguments.uninstantiated_type_arguments()); | |
| 443 const AbstractTypeArguments& instantiator = | |
| 444 AbstractTypeArguments::Handle( | |
| 445 instantiated_type_arguments.instantiator_type_arguments()); | |
| 446 temp_type_arguments = uninstantiated.InstantiateFrom(instantiator); | |
| 447 } while (temp_type_arguments.IsInstantiatedTypeArguments()); | |
| 434 TypeArguments& new_type_arguments = TypeArguments::Handle(); | 448 TypeArguments& new_type_arguments = TypeArguments::Handle(); |
| 435 InstantiatedTypeArguments& instantiated_type_arguments = | 449 new_type_arguments ^= temp_type_arguments.raw(); |
| 436 InstantiatedTypeArguments::Handle(); | |
| 437 instantiated_type_arguments ^= type_arguments.raw(); | |
| 438 const AbstractTypeArguments& uninstantiated = | |
| 439 AbstractTypeArguments::Handle( | |
| 440 instantiated_type_arguments.uninstantiated_type_arguments()); | |
| 441 const AbstractTypeArguments& instantiator = | |
| 442 AbstractTypeArguments::Handle( | |
| 443 instantiated_type_arguments.instantiator_type_arguments()); | |
| 444 AbstractTypeArguments& temp = AbstractTypeArguments::Handle(); | |
| 445 temp = uninstantiated.InstantiateFrom(instantiator); | |
| 446 if (!temp.IsTypeArguments()) { | |
| 447 // TODO(srdjan): Figure out why it does not want to convert to | |
| 448 // TypeArguments. | |
| 449 return false; | |
| 450 } | |
| 451 new_type_arguments ^= temp.raw(); | |
| 452 new_type_arguments ^= new_type_arguments.Canonicalize(); | 450 new_type_arguments ^= new_type_arguments.Canonicalize(); |
| 453 instance.SetTypeArguments(new_type_arguments); | 451 instance.SetTypeArguments(new_type_arguments); |
| 454 *type_arguments_replaced = true; | 452 *type_arguments_replaced = true; |
| 455 } else if (!type_arguments.IsCanonical()) { | 453 } else if (!type_arguments.IsCanonical()) { |
| 456 AbstractTypeArguments& new_type_arguments = | 454 AbstractTypeArguments& new_type_arguments = |
| 457 AbstractTypeArguments::Handle(); | 455 AbstractTypeArguments::Handle(); |
| 458 new_type_arguments ^= type_arguments.Canonicalize(); | 456 new_type_arguments ^= type_arguments.Canonicalize(); |
| 459 instance.SetTypeArguments(new_type_arguments); | 457 instance.SetTypeArguments(new_type_arguments); |
| 460 *type_arguments_replaced = true; | 458 *type_arguments_replaced = true; |
| 461 } | 459 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 533 &last_instance_class, | 531 &last_instance_class, |
| 534 &last_instance_type_arguments, | 532 &last_instance_type_arguments, |
| 535 &last_instantiator_type_arguments, | 533 &last_instantiator_type_arguments, |
| 536 &last_result); | 534 &last_result); |
| 537 if ((last_instance_class.raw() == instance_class.raw()) && | 535 if ((last_instance_class.raw() == instance_class.raw()) && |
| 538 (last_instance_type_arguments.raw() == instance_type_arguments.raw()) && | 536 (last_instance_type_arguments.raw() == instance_type_arguments.raw()) && |
| 539 (last_instantiator_type_arguments.raw() == | 537 (last_instantiator_type_arguments.raw() == |
| 540 instantiator_type_arguments.raw())) { | 538 instantiator_type_arguments.raw())) { |
| 541 if (FLAG_trace_type_checks) { | 539 if (FLAG_trace_type_checks) { |
| 542 OS::Print("%d ", i); | 540 OS::Print("%d ", i); |
| 543 PrintTypeCheck("WARNING duplicate cache entry", instance, type, | 541 if (type_arguments_replaced) { |
| 544 instantiator_type_arguments, result); | 542 PrintTypeCheck("Duplicate cache entry (canonical.)", instance, type, |
| 543 instantiator_type_arguments, result); | |
| 544 } else { | |
| 545 PrintTypeCheck("WARNING Duplicate cache entry", instance, type, | |
| 546 instantiator_type_arguments, result); | |
| 547 } | |
| 545 } | 548 } |
| 546 // Can occur if we have canonicalized arguments. | 549 // Can occur if we have canonicalized arguments. |
| 547 // TODO(srdjan): Investigate why this assert can fail. | 550 // TODO(srdjan): Investigate why this assert can fail. |
| 548 // ASSERT(type_arguments_replaced); | 551 // ASSERT(type_arguments_replaced); |
| 549 return; | 552 return; |
| 550 } | 553 } |
| 551 } | 554 } |
| 552 new_cache.AddCheck(instance_class, | 555 new_cache.AddCheck(instance_class, |
| 553 instance_type_arguments, | 556 instance_type_arguments, |
| 554 instantiator_type_arguments, | 557 instantiator_type_arguments, |
| 555 result); | 558 result); |
| 556 if (FLAG_trace_type_checks) { | 559 if (FLAG_trace_type_checks) { |
| 560 AbstractType& test_type = AbstractType::Handle(type.raw()); | |
| 561 if (!test_type.IsInstantiated()) { | |
| 562 test_type = type.InstantiateFrom(instantiator_type_arguments); | |
| 563 } | |
| 557 OS::Print(" Updated test cache 0x%x ix:%d:\n" | 564 OS::Print(" Updated test cache 0x%x ix:%d:\n" |
| 558 " [0x%x %s, 0x%x %s]\n" | 565 " [0x%x %s, 0x%x %s]\n" |
| 559 " [0x%x %s, 0x%x %s] %s\n", | 566 " [0x%x %s, 0x%x %s] %s\n", |
| 560 new_cache.raw(), | 567 new_cache.raw(), |
| 561 len, | 568 len, |
| 562 instance_class.raw(), | 569 instance_class.raw(), |
| 563 instance_class.ToCString(), | 570 instance_class.ToCString(), |
| 564 instance_type_arguments.raw(), | 571 instance_type_arguments.raw(), |
| 565 instance_type_arguments.ToCString(), | 572 instance_type_arguments.ToCString(), |
| 566 type.type_class(), | 573 test_type.type_class(), |
| 567 Class::Handle(type.type_class()).ToCString(), | 574 Class::Handle(test_type.type_class()).ToCString(), |
| 568 instantiator_type_arguments.raw(), | 575 instantiator_type_arguments.raw(), |
| 569 instantiator_type_arguments.ToCString(), | 576 instantiator_type_arguments.ToCString(), |
| 570 result.ToCString()); | 577 result.ToCString()); |
| 571 } | 578 } |
| 572 } | 579 } |
| 573 | 580 |
| 574 | 581 |
| 575 // Check that the given instance is an instance of the given type. | 582 // Check that the given instance is an instance of the given type. |
| 576 // Tested instance may not be null, because the null test is inlined. | 583 // Tested instance may not be null, because the null test is inlined. |
| 577 // Arg0: index of the token of the instanceof test (source location). | 584 // Arg0: index of the token of the instanceof test (source location). |
| (...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1542 } | 1549 } |
| 1543 } | 1550 } |
| 1544 } | 1551 } |
| 1545 // The cache is null terminated, therefore the loop above should never | 1552 // The cache is null terminated, therefore the loop above should never |
| 1546 // terminate by itself. | 1553 // terminate by itself. |
| 1547 UNREACHABLE(); | 1554 UNREACHABLE(); |
| 1548 return Code::null(); | 1555 return Code::null(); |
| 1549 } | 1556 } |
| 1550 | 1557 |
| 1551 } // namespace dart | 1558 } // namespace dart |
| OLD | NEW |