| 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 Handle<Code>::cast(object)->is_compare_nil_ic_stub()) { |
| 649 return Handle<Code>::cast(object)->compare_nil_state(); |
| 650 } else { |
| 651 return CompareNilICStub::kFullCompare; |
| 652 } |
| 653 } |
| 654 |
| 655 |
| 634 // Things are a bit tricky here: The iterator for the RelocInfos and the infos | 656 // 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 | 657 // 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 | 658 // dictionary (possibly triggering GC), and finally we relocate the collected |
| 637 // infos before we process them. | 659 // infos before we process them. |
| 638 void TypeFeedbackOracle::BuildDictionary(Handle<Code> code) { | 660 void TypeFeedbackOracle::BuildDictionary(Handle<Code> code) { |
| 639 AssertNoAllocation no_allocation; | 661 AssertNoAllocation no_allocation; |
| 640 ZoneList<RelocInfo> infos(16, zone()); | 662 ZoneList<RelocInfo> infos(16, zone()); |
| 641 HandleScope scope(isolate_); | 663 HandleScope scope(isolate_); |
| 642 GetRelocInfos(code, &infos); | 664 GetRelocInfos(code, &infos); |
| 643 CreateDictionary(code, &infos); | 665 CreateDictionary(code, &infos); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 if (target->ic_state() == MONOMORPHIC || | 739 if (target->ic_state() == MONOMORPHIC || |
| 718 target->ic_state() == POLYMORPHIC) { | 740 target->ic_state() == POLYMORPHIC) { |
| 719 SetInfo(ast_id, target); | 741 SetInfo(ast_id, target); |
| 720 } | 742 } |
| 721 break; | 743 break; |
| 722 | 744 |
| 723 case Code::UNARY_OP_IC: | 745 case Code::UNARY_OP_IC: |
| 724 case Code::BINARY_OP_IC: | 746 case Code::BINARY_OP_IC: |
| 725 case Code::COMPARE_IC: | 747 case Code::COMPARE_IC: |
| 726 case Code::TO_BOOLEAN_IC: | 748 case Code::TO_BOOLEAN_IC: |
| 749 case Code::COMPARE_NIL_IC: |
| 727 SetInfo(ast_id, target); | 750 SetInfo(ast_id, target); |
| 728 break; | 751 break; |
| 729 | 752 |
| 730 default: | 753 default: |
| 731 break; | 754 break; |
| 732 } | 755 } |
| 733 } | 756 } |
| 734 } | 757 } |
| 735 | 758 |
| 736 | 759 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 759 USE(maybe_result); | 782 USE(maybe_result); |
| 760 #ifdef DEBUG | 783 #ifdef DEBUG |
| 761 Object* result = NULL; | 784 Object* result = NULL; |
| 762 // Dictionary has been allocated with sufficient size for all elements. | 785 // Dictionary has been allocated with sufficient size for all elements. |
| 763 ASSERT(maybe_result->ToObject(&result)); | 786 ASSERT(maybe_result->ToObject(&result)); |
| 764 ASSERT(*dictionary_ == result); | 787 ASSERT(*dictionary_ == result); |
| 765 #endif | 788 #endif |
| 766 } | 789 } |
| 767 | 790 |
| 768 } } // namespace v8::internal | 791 } } // namespace v8::internal |
| OLD | NEW |