| 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 Map* first_map = code->FindFirstMap(); | 211 Map* first_map = code->FindFirstMap(); |
| 212 ASSERT(first_map != NULL); | 212 ASSERT(first_map != NULL); |
| 213 return CanRetainOtherContext(first_map, *native_context_) | 213 return CanRetainOtherContext(first_map, *native_context_) |
| 214 ? Handle<Map>::null() | 214 ? Handle<Map>::null() |
| 215 : Handle<Map>(first_map); | 215 : Handle<Map>(first_map); |
| 216 } | 216 } |
| 217 return Handle<Map>::cast(map_or_code); | 217 return Handle<Map>::cast(map_or_code); |
| 218 } | 218 } |
| 219 | 219 |
| 220 | 220 |
| 221 Handle<Map> TypeFeedbackOracle::CompareNilMonomorphicReceiverType( |
| 222 TypeFeedbackId id) { |
| 223 Handle<Object> maybe_code = GetInfo(id); |
| 224 if (maybe_code->IsCode()) { |
| 225 Map* first_map = Handle<Code>::cast(maybe_code)->FindFirstMap(); |
| 226 if (first_map != NULL) return Handle<Map>(first_map); |
| 227 } |
| 228 return Handle<Map>(); |
| 229 } |
| 230 |
| 231 |
| 221 KeyedAccessStoreMode TypeFeedbackOracle::GetStoreMode( | 232 KeyedAccessStoreMode TypeFeedbackOracle::GetStoreMode( |
| 222 TypeFeedbackId ast_id) { | 233 TypeFeedbackId ast_id) { |
| 223 Handle<Object> map_or_code = GetInfo(ast_id); | 234 Handle<Object> map_or_code = GetInfo(ast_id); |
| 224 if (map_or_code->IsCode()) { | 235 if (map_or_code->IsCode()) { |
| 225 Handle<Code> code = Handle<Code>::cast(map_or_code); | 236 Handle<Code> code = Handle<Code>::cast(map_or_code); |
| 226 if (code->kind() == Code::KEYED_STORE_IC) { | 237 if (code->kind() == Code::KEYED_STORE_IC) { |
| 227 return Code::GetKeyedAccessStoreMode(code->extra_ic_state()); | 238 return Code::GetKeyedAccessStoreMode(code->extra_ic_state()); |
| 228 } | 239 } |
| 229 } | 240 } |
| 230 return STANDARD_STORE; | 241 return STANDARD_STORE; |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 Handle<Object> object = GetInfo(ast_id); | 629 Handle<Object> object = GetInfo(ast_id); |
| 619 if (!object->IsCode()) return; | 630 if (!object->IsCode()) return; |
| 620 Handle<Code> code = Handle<Code>::cast(object); | 631 Handle<Code> code = Handle<Code>::cast(object); |
| 621 if (code->kind() == Code::KEYED_LOAD_IC || | 632 if (code->kind() == Code::KEYED_LOAD_IC || |
| 622 code->kind() == Code::KEYED_STORE_IC) { | 633 code->kind() == Code::KEYED_STORE_IC) { |
| 623 CollectPolymorphicMaps(code, types); | 634 CollectPolymorphicMaps(code, types); |
| 624 } | 635 } |
| 625 } | 636 } |
| 626 | 637 |
| 627 | 638 |
| 628 byte TypeFeedbackOracle::ToBooleanTypes(TypeFeedbackId ast_id) { | 639 byte TypeFeedbackOracle::ToBooleanTypes(TypeFeedbackId id) { |
| 629 Handle<Object> object = GetInfo(ast_id); | 640 Handle<Object> object = GetInfo(id); |
| 630 return object->IsCode() ? Handle<Code>::cast(object)->to_boolean_state() : 0; | 641 return object->IsCode() ? Handle<Code>::cast(object)->to_boolean_state() : 0; |
| 631 } | 642 } |
| 632 | 643 |
| 633 | 644 |
| 645 byte TypeFeedbackOracle::CompareNilTypes(TypeFeedbackId id) { |
| 646 Handle<Object> object = GetInfo(id); |
| 647 if (object->IsCode()) { |
| 648 return Handle<Code>::cast(object)->compare_nil_state(); |
| 649 } else { |
| 650 return 0; |
| 651 } |
| 652 } |
| 653 |
| 654 |
| 634 // Things are a bit tricky here: The iterator for the RelocInfos and the infos | 655 // Things are a bit tricky here: The iterator for the RelocInfos and the infos |
| 635 // themselves are not GC-safe, so we first get all infos, then we create the | 656 // themselves are not GC-safe, so we first get all infos, then we create the |
| 636 // dictionary (possibly triggering GC), and finally we relocate the collected | 657 // dictionary (possibly triggering GC), and finally we relocate the collected |
| 637 // infos before we process them. | 658 // infos before we process them. |
| 638 void TypeFeedbackOracle::BuildDictionary(Handle<Code> code) { | 659 void TypeFeedbackOracle::BuildDictionary(Handle<Code> code) { |
| 639 AssertNoAllocation no_allocation; | 660 AssertNoAllocation no_allocation; |
| 640 ZoneList<RelocInfo> infos(16, zone()); | 661 ZoneList<RelocInfo> infos(16, zone()); |
| 641 HandleScope scope(isolate_); | 662 HandleScope scope(isolate_); |
| 642 GetRelocInfos(code, &infos); | 663 GetRelocInfos(code, &infos); |
| 643 CreateDictionary(code, &infos); | 664 CreateDictionary(code, &infos); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 if (target->ic_state() == MONOMORPHIC || | 738 if (target->ic_state() == MONOMORPHIC || |
| 718 target->ic_state() == POLYMORPHIC) { | 739 target->ic_state() == POLYMORPHIC) { |
| 719 SetInfo(ast_id, target); | 740 SetInfo(ast_id, target); |
| 720 } | 741 } |
| 721 break; | 742 break; |
| 722 | 743 |
| 723 case Code::UNARY_OP_IC: | 744 case Code::UNARY_OP_IC: |
| 724 case Code::BINARY_OP_IC: | 745 case Code::BINARY_OP_IC: |
| 725 case Code::COMPARE_IC: | 746 case Code::COMPARE_IC: |
| 726 case Code::TO_BOOLEAN_IC: | 747 case Code::TO_BOOLEAN_IC: |
| 748 case Code::COMPARE_NIL_IC: |
| 727 SetInfo(ast_id, target); | 749 SetInfo(ast_id, target); |
| 728 break; | 750 break; |
| 729 | 751 |
| 730 default: | 752 default: |
| 731 break; | 753 break; |
| 732 } | 754 } |
| 733 } | 755 } |
| 734 } | 756 } |
| 735 | 757 |
| 736 | 758 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 759 USE(maybe_result); | 781 USE(maybe_result); |
| 760 #ifdef DEBUG | 782 #ifdef DEBUG |
| 761 Object* result = NULL; | 783 Object* result = NULL; |
| 762 // Dictionary has been allocated with sufficient size for all elements. | 784 // Dictionary has been allocated with sufficient size for all elements. |
| 763 ASSERT(maybe_result->ToObject(&result)); | 785 ASSERT(maybe_result->ToObject(&result)); |
| 764 ASSERT(*dictionary_ == result); | 786 ASSERT(*dictionary_ == result); |
| 765 #endif | 787 #endif |
| 766 } | 788 } |
| 767 | 789 |
| 768 } } // namespace v8::internal | 790 } } // namespace v8::internal |
| OLD | NEW |