OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 TypeHandleList types; | 673 TypeHandleList types; |
674 CodeHandleList handlers; | 674 CodeHandleList handlers; |
675 | 675 |
676 TargetTypes(&types); | 676 TargetTypes(&types); |
677 int number_of_types = types.length(); | 677 int number_of_types = types.length(); |
678 int deprecated_types = 0; | 678 int deprecated_types = 0; |
679 int handler_to_overwrite = -1; | 679 int handler_to_overwrite = -1; |
680 | 680 |
681 for (int i = 0; i < number_of_types; i++) { | 681 for (int i = 0; i < number_of_types; i++) { |
682 Handle<HeapType> current_type = types.at(i); | 682 Handle<HeapType> current_type = types.at(i); |
683 if (current_type->IsClass() && | 683 if (current_type->IsClass() && current_type->AsClass()->is_deprecated()) { |
684 current_type->AsClass()->Map()->is_deprecated()) { | |
685 // Filter out deprecated maps to ensure their instances get migrated. | 684 // Filter out deprecated maps to ensure their instances get migrated. |
686 ++deprecated_types; | 685 ++deprecated_types; |
687 } else if (type->NowIs(current_type)) { | 686 } else if (type->NowIs(current_type)) { |
688 // If the receiver type is already in the polymorphic IC, this indicates | 687 // If the receiver type is already in the polymorphic IC, this indicates |
689 // there was a prototoype chain failure. In that case, just overwrite the | 688 // there was a prototoype chain failure. In that case, just overwrite the |
690 // handler. | 689 // handler. |
691 handler_to_overwrite = i; | 690 handler_to_overwrite = i; |
692 } else if (handler_to_overwrite == -1 && | 691 } else if (handler_to_overwrite == -1 && |
693 current_type->IsClass() && | 692 current_type->IsClass() && |
694 type->IsClass() && | 693 type->IsClass() && |
695 IsTransitionOfMonomorphicTarget(*current_type->AsClass()->Map(), | 694 IsTransitionOfMonomorphicTarget(*current_type->AsClass(), |
696 *type->AsClass()->Map())) { | 695 *type->AsClass())) { |
697 handler_to_overwrite = i; | 696 handler_to_overwrite = i; |
698 } | 697 } |
699 } | 698 } |
700 | 699 |
701 int number_of_valid_types = | 700 int number_of_valid_types = |
702 number_of_types - deprecated_types - (handler_to_overwrite != -1); | 701 number_of_types - deprecated_types - (handler_to_overwrite != -1); |
703 | 702 |
704 if (number_of_valid_types >= 4) return false; | 703 if (number_of_valid_types >= 4) return false; |
705 if (number_of_types == 0) return false; | 704 if (number_of_types == 0) return false; |
706 if (!target()->FindHandlers(&handlers, types.length())) return false; | 705 if (!target()->FindHandlers(&handlers, types.length())) return false; |
(...skipping 21 matching lines...) Expand all Loading... |
728 ? HeapType::Constant(Handle<JSGlobalObject>::cast(object), isolate) | 727 ? HeapType::Constant(Handle<JSGlobalObject>::cast(object), isolate) |
729 : HeapType::NowOf(object, isolate); | 728 : HeapType::NowOf(object, isolate); |
730 } | 729 } |
731 | 730 |
732 | 731 |
733 Handle<Map> IC::TypeToMap(HeapType* type, Isolate* isolate) { | 732 Handle<Map> IC::TypeToMap(HeapType* type, Isolate* isolate) { |
734 if (type->Is(HeapType::Number())) | 733 if (type->Is(HeapType::Number())) |
735 return isolate->factory()->heap_number_map(); | 734 return isolate->factory()->heap_number_map(); |
736 if (type->Is(HeapType::Boolean())) return isolate->factory()->boolean_map(); | 735 if (type->Is(HeapType::Boolean())) return isolate->factory()->boolean_map(); |
737 if (type->IsConstant()) { | 736 if (type->IsConstant()) { |
738 return handle( | 737 return handle(Handle<JSGlobalObject>::cast(type->AsConstant())->map()); |
739 Handle<JSGlobalObject>::cast(type->AsConstant()->Value())->map()); | |
740 } | 738 } |
741 ASSERT(type->IsClass()); | 739 ASSERT(type->IsClass()); |
742 return type->AsClass()->Map(); | 740 return type->AsClass(); |
743 } | 741 } |
744 | 742 |
745 | 743 |
746 template <class T> | 744 template <class T> |
747 typename T::TypeHandle IC::MapToType(Handle<Map> map, | 745 typename T::TypeHandle IC::MapToType(Handle<Map> map, |
748 typename T::Region* region) { | 746 typename T::Region* region) { |
749 if (map->instance_type() == HEAP_NUMBER_TYPE) { | 747 if (map->instance_type() == HEAP_NUMBER_TYPE) { |
750 return T::Number(region); | 748 return T::Number(region); |
751 } else if (map->instance_type() == ODDBALL_TYPE) { | 749 } else if (map->instance_type() == ODDBALL_TYPE) { |
752 // The only oddballs that can be recorded in ICs are booleans. | 750 // The only oddballs that can be recorded in ICs are booleans. |
(...skipping 2195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2948 #undef ADDR | 2946 #undef ADDR |
2949 }; | 2947 }; |
2950 | 2948 |
2951 | 2949 |
2952 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 2950 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
2953 return IC_utilities[id]; | 2951 return IC_utilities[id]; |
2954 } | 2952 } |
2955 | 2953 |
2956 | 2954 |
2957 } } // namespace v8::internal | 2955 } } // namespace v8::internal |
OLD | NEW |