| 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 2051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2062 | 2062 |
| 2063 if (names_cache->enumerable() == object()) { | 2063 if (names_cache->enumerable() == object()) { |
| 2064 HForInCacheArray* index_cache = | 2064 HForInCacheArray* index_cache = |
| 2065 names_cache->index_cache(); | 2065 names_cache->index_cache(); |
| 2066 HCheckMapValue* map_check = | 2066 HCheckMapValue* map_check = |
| 2067 new(block()->zone()) HCheckMapValue(object(), names_cache->map()); | 2067 new(block()->zone()) HCheckMapValue(object(), names_cache->map()); |
| 2068 HInstruction* index = new(block()->zone()) HLoadKeyed( | 2068 HInstruction* index = new(block()->zone()) HLoadKeyed( |
| 2069 index_cache, | 2069 index_cache, |
| 2070 key_load->key(), | 2070 key_load->key(), |
| 2071 key_load->key(), | 2071 key_load->key(), |
| 2072 key_load->elements_kind()); | 2072 key_load->elements_kind(), |
| 2073 block()->zone()); |
| 2073 map_check->InsertBefore(this); | 2074 map_check->InsertBefore(this); |
| 2074 index->InsertBefore(this); | 2075 index->InsertBefore(this); |
| 2075 HLoadFieldByIndex* load = new(block()->zone()) HLoadFieldByIndex( | 2076 HLoadFieldByIndex* load = new(block()->zone()) HLoadFieldByIndex( |
| 2076 object(), index); | 2077 object(), index); |
| 2077 load->InsertBefore(this); | 2078 load->InsertBefore(this); |
| 2078 return load; | 2079 return load; |
| 2079 } | 2080 } |
| 2080 } | 2081 } |
| 2081 } | 2082 } |
| 2082 | 2083 |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2714 all_uses_require = use_rep; | 2715 all_uses_require = use_rep; |
| 2715 } | 2716 } |
| 2716 if (all_uses_require_the_same) { | 2717 if (all_uses_require_the_same) { |
| 2717 return all_uses_require; | 2718 return all_uses_require; |
| 2718 } | 2719 } |
| 2719 | 2720 |
| 2720 return Representation::None(); | 2721 return Representation::None(); |
| 2721 } | 2722 } |
| 2722 | 2723 |
| 2723 | 2724 |
| 2725 TransitionElementsBookmark::TransitionElementsBookmark( |
| 2726 HTransitionElementsKind* transition, |
| 2727 Handle<Map> map_from, Handle<Map> map_to, Isolate* isolate) |
| 2728 : transition_(transition), |
| 2729 from_(map_from), |
| 2730 to_(map_to), |
| 2731 pessimistic_holey_() { |
| 2732 |
| 2733 // When transition records are created, we have the chance to create map |
| 2734 // transitions we might need later. Transitions are unified during |
| 2735 // optimization, and we may need to transition from a packed fastmap to a |
| 2736 // holey version of same. But we can't create those transitions during |
| 2737 // optimization. Do it now, recognizing that when the handle disappears these |
| 2738 // maps may be collected if they didn't make it into usage in the optimized |
| 2739 // graph. |
| 2740 |
| 2741 // TODO(mvstanton): generalize this service into |
| 2742 // "MakeWorstCaseMapForElementsKindTransition" (ie, not "holey") |
| 2743 if (IsFastPackedElementsKind(map_to->elements_kind())) { |
| 2744 ElementsKind holey_kind = GetHoleyElementsKind(map_to->elements_kind()); |
| 2745 // The transition might already exist |
| 2746 Handle<Map> holey_map_handle(FindClosestElementsTransition(*map_to, |
| 2747 holey_kind)); |
| 2748 ASSERT(!holey_map_handle.is_null()); |
| 2749 if (holey_map_handle->elements_kind() != holey_kind) { |
| 2750 MaybeObject* holey_map = map_to->AddMissingElementsTransitions( |
| 2751 holey_kind); |
| 2752 holey_map->ToHandle<Map>(&pessimistic_holey_, isolate); |
| 2753 } else { |
| 2754 pessimistic_holey_ = holey_map_handle; |
| 2755 } |
| 2756 } else { |
| 2757 pessimistic_holey_ = map_to; |
| 2758 } |
| 2759 |
| 2760 ASSERT(!pessimistic_holey_.is_null()); |
| 2761 |
| 2762 // fill in map_family_ |
| 2763 // Walk up to the base map from the map_to(); |
| 2764 Handle<Map> end_map(FindClosestElementsTransition(*map_to, |
| 2765 TERMINAL_FAST_ELEMENTS_KIND)); |
| 2766 ASSERT(!end_map.is_null()); |
| 2767 family_ = end_map; |
| 2768 } |
| 2769 |
| 2770 |
| 2771 void ArrayInstruction::PrintElementPlacementTo(StringStream* stream) { |
| 2772 stream->Add("SITE: block%d %d: ", block()->block_id(), |
| 2773 id()); |
| 2774 PrintTo(stream); |
| 2775 stream->Add("\n"); |
| 2776 |
| 2777 // Print validness |
| 2778 stream->Add(" HOISTABLE: %s\n", hoistable() ? "true" : "false"); |
| 2779 |
| 2780 // Print score |
| 2781 // stream->Add(" SCORE: (+%d,%d,-%d)\n", score_[0], score_[1], score_[2]); |
| 2782 |
| 2783 // Find the def point for the instruction |
| 2784 HValue *element = elements(); |
| 2785 ASSERT(element != NULL); |
| 2786 // Now get the item from the elements |
| 2787 ASSERT(element->IsLoadElements()); |
| 2788 HValue *elements_value = HLoadElements::cast(element)->value(); |
| 2789 stream->Add(" OBJECT: "); |
| 2790 elements_value->PrintNameTo(stream); |
| 2791 stream->Add(" "); |
| 2792 elements_value->PrintTo(stream); |
| 2793 stream->Add(" %s\n", elements_value->IsPhi() ? "PHI" : ""); |
| 2794 stream->Add(" TRANSITIONS:\n"); |
| 2795 ElementsKind transitionElementsKind = FAST_SMI_ELEMENTS; |
| 2796 for (int i = 0; i < bookmarks(); i++) { |
| 2797 TransitionElementsBookmark* b = bookmark(i); |
| 2798 stream->Add(" %s", ElementsKindToString(b->elementskind_from())); |
| 2799 stream->Add("(0x%p)-> ", *(b->from())); |
| 2800 transitionElementsKind = b->elementskind_to(); |
| 2801 stream->Add("%s", ElementsKindToString(transitionElementsKind)); |
| 2802 stream->Add("(0x%p)\n", *(b->to())); |
| 2803 } |
| 2804 |
| 2805 /* |
| 2806 // Print possibly externally computed map |
| 2807 const char *signifier = (transitionElementsKind != |
| 2808 most_general_map()->elements_kind()) |
| 2809 ? "*" : ""; |
| 2810 stream->Add(" COMPUTED MOST GENERAL MAP: %s%s(0x%p)\n", signifier, |
| 2811 ElementsKindToString(most_general_map()->elements_kind()), |
| 2812 most_general_map()); |
| 2813 |
| 2814 // Print terminal nodes if available |
| 2815 |
| 2816 stream->Add(" TRANSITION INPUT VALUES:\n"); |
| 2817 for (int j = 0; j < transition_inputs(); j++) { |
| 2818 HValue* node = transition_input(j); |
| 2819 stream->Add(" block%d %d: ", node->block()->block_id(), node->id()); |
| 2820 node->PrintNameTo(stream); |
| 2821 stream->Add(" "); |
| 2822 node->PrintTo(stream); |
| 2823 stream->Add("\n"); |
| 2824 } |
| 2825 */ |
| 2826 } |
| 2827 |
| 2828 |
| 2829 void ArrayInstruction::AddBookmarks(const ZoneList<TransitionElementsBookmark>& |
| 2830 records) { |
| 2831 ASSERT(records.length() > 0); |
| 2832 Map* first_to_map = *(records[0].to().location()); |
| 2833 |
| 2834 // Doesn't check for duplicates. |
| 2835 // The "to" map values should be the same for the whole group |
| 2836 for (int i = 0; i < records.length(); i++) { |
| 2837 bookmarks_->Add(records[i], zone_); |
| 2838 ASSERT(first_to_map == *(records[i].to().location())); |
| 2839 } |
| 2840 |
| 2841 // set_most_general_map(first_to_map); |
| 2842 } |
| 2843 |
| 2844 |
| 2845 Map* ArrayInstruction::map_family() { |
| 2846 Map* family = NULL; |
| 2847 if (bookmarks()) { |
| 2848 family = *(bookmark(0)->family().location()); |
| 2849 } |
| 2850 |
| 2851 #ifdef DEBUG |
| 2852 for (int i = 1; i < bookmarks(); i++) { |
| 2853 TransitionElementsBookmark* tr = bookmark(i); |
| 2854 ASSERT(*(tr->family().location()) == family); |
| 2855 } |
| 2856 #endif |
| 2857 return family; |
| 2858 } |
| 2859 |
| 2860 |
| 2724 // Node-specific verification code is only included in debug mode. | 2861 // Node-specific verification code is only included in debug mode. |
| 2725 #ifdef DEBUG | 2862 #ifdef DEBUG |
| 2726 | 2863 |
| 2727 void HPhi::Verify() { | 2864 void HPhi::Verify() { |
| 2728 ASSERT(OperandCount() == block()->predecessors()->length()); | 2865 ASSERT(OperandCount() == block()->predecessors()->length()); |
| 2729 for (int i = 0; i < OperandCount(); ++i) { | 2866 for (int i = 0; i < OperandCount(); ++i) { |
| 2730 HValue* value = OperandAt(i); | 2867 HValue* value = OperandAt(i); |
| 2731 HBasicBlock* defining_block = value->block(); | 2868 HBasicBlock* defining_block = value->block(); |
| 2732 HBasicBlock* predecessor_block = block()->predecessors()->at(i); | 2869 HBasicBlock* predecessor_block = block()->predecessors()->at(i); |
| 2733 ASSERT(defining_block == predecessor_block || | 2870 ASSERT(defining_block == predecessor_block || |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2755 | 2892 |
| 2756 | 2893 |
| 2757 void HCheckFunction::Verify() { | 2894 void HCheckFunction::Verify() { |
| 2758 HInstruction::Verify(); | 2895 HInstruction::Verify(); |
| 2759 ASSERT(HasNoUses()); | 2896 ASSERT(HasNoUses()); |
| 2760 } | 2897 } |
| 2761 | 2898 |
| 2762 #endif | 2899 #endif |
| 2763 | 2900 |
| 2764 } } // namespace v8::internal | 2901 } } // namespace v8::internal |
| OLD | NEW |