Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(856)

Side by Side Diff: src/hydrogen-instructions.h

Issue 14367023: Refactor HCheckMaps to have a private constructor, removing duplicated code and simplifying calls i… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Alphabetize gitignore. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/hydrogen.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2662 matching lines...) Expand 10 before | Expand all | Expand 10 after
2673 protected: 2673 protected:
2674 virtual bool DataEquals(HValue* other) { return true; } 2674 virtual bool DataEquals(HValue* other) { return true; }
2675 2675
2676 private: 2676 private:
2677 virtual bool IsDeletable() const { return true; } 2677 virtual bool IsDeletable() const { return true; }
2678 }; 2678 };
2679 2679
2680 2680
2681 class HCheckMaps: public HTemplateInstruction<2> { 2681 class HCheckMaps: public HTemplateInstruction<2> {
2682 public: 2682 public:
2683 HCheckMaps(HValue* value, Handle<Map> map, Zone* zone, 2683 static HCheckMaps* New(HValue* value, Handle<Map> map, Zone* zone,
2684 HValue* typecheck = NULL) 2684 HValue *typecheck = NULL) {
2685 : map_unique_ids_(0, zone) { 2685 HCheckMaps* check_map = new(zone) HCheckMaps(value, zone, typecheck);
2686 SetOperandAt(0, value); 2686 check_map->map_set_.Add(map, zone);
2687 // If callers don't depend on a typecheck, they can pass in NULL. In that 2687 return check_map;
2688 // case we use a copy of the |value| argument as a dummy value.
2689 SetOperandAt(1, typecheck != NULL ? typecheck : value);
2690 set_representation(Representation::Tagged());
2691 SetFlag(kUseGVN);
2692 SetFlag(kTrackSideEffectDominators);
2693 SetGVNFlag(kDependsOnMaps);
2694 SetGVNFlag(kDependsOnElementsKind);
2695 map_set()->Add(map, zone);
2696 }
2697 HCheckMaps(HValue* value, SmallMapList* maps, Zone* zone)
2698 : map_unique_ids_(0, zone) {
2699 SetOperandAt(0, value);
2700 SetOperandAt(1, value);
2701 set_representation(Representation::Tagged());
2702 SetFlag(kUseGVN);
2703 SetFlag(kTrackSideEffectDominators);
2704 SetGVNFlag(kDependsOnMaps);
2705 SetGVNFlag(kDependsOnElementsKind);
2706 for (int i = 0; i < maps->length(); i++) {
2707 map_set()->Add(maps->at(i), zone);
2708 }
2709 map_set()->Sort();
2710 } 2688 }
2711 2689
2712 static HCheckMaps* NewWithTransitions(HValue* object, Handle<Map> map, 2690 static HCheckMaps* New(HValue* value, SmallMapList* maps, Zone* zone,
2691 HValue *typecheck = NULL) {
2692 HCheckMaps* check_map = new(zone) HCheckMaps(value, zone, typecheck);
2693 for (int i = 0; i < maps->length(); i++) {
2694 check_map->map_set_.Add(maps->at(i), zone);
2695 }
2696 check_map->map_set_.Sort();
2697 return check_map;
2698 }
2699
2700 static HCheckMaps* NewWithTransitions(HValue* value, Handle<Map> map,
2713 Zone* zone) { 2701 Zone* zone) {
2714 HCheckMaps* check_map = new(zone) HCheckMaps(object, map, zone); 2702 HCheckMaps* check_map = new(zone) HCheckMaps(value, zone, value);
2715 SmallMapList* map_set = check_map->map_set(); 2703 check_map->map_set_.Add(map, zone);
2716 2704
2717 // Since transitioned elements maps of the initial map don't fail the map 2705 // Since transitioned elements maps of the initial map don't fail the map
2718 // check, the CheckMaps instruction doesn't need to depend on ElementsKinds. 2706 // check, the CheckMaps instruction doesn't need to depend on ElementsKinds.
2719 check_map->ClearGVNFlag(kDependsOnElementsKind); 2707 check_map->ClearGVNFlag(kDependsOnElementsKind);
2720 2708
2721 ElementsKind kind = map->elements_kind(); 2709 ElementsKind kind = map->elements_kind();
2722 bool packed = IsFastPackedElementsKind(kind); 2710 bool packed = IsFastPackedElementsKind(kind);
2723 while (CanTransitionToMoreGeneralFastElementsKind(kind, packed)) { 2711 while (CanTransitionToMoreGeneralFastElementsKind(kind, packed)) {
2724 kind = GetNextMoreGeneralFastElementsKind(kind, packed); 2712 kind = GetNextMoreGeneralFastElementsKind(kind, packed);
2725 Map* transitioned_map = 2713 Map* transitioned_map =
2726 map->LookupElementsTransitionMap(kind); 2714 map->LookupElementsTransitionMap(kind);
2727 if (transitioned_map) { 2715 if (transitioned_map) {
2728 map_set->Add(Handle<Map>(transitioned_map), zone); 2716 check_map->map_set_.Add(Handle<Map>(transitioned_map), zone);
2729 } 2717 }
2730 }; 2718 };
2731 map_set->Sort(); 2719 check_map->map_set_.Sort();
2732 return check_map; 2720 return check_map;
2733 } 2721 }
2734 2722
2735 virtual Representation RequiredInputRepresentation(int index) { 2723 virtual Representation RequiredInputRepresentation(int index) {
2736 return Representation::Tagged(); 2724 return Representation::Tagged();
2737 } 2725 }
2738 virtual void SetSideEffectDominator(GVNFlag side_effect, HValue* dominator); 2726 virtual void SetSideEffectDominator(GVNFlag side_effect, HValue* dominator);
2739 virtual void PrintDataTo(StringStream* stream); 2727 virtual void PrintDataTo(StringStream* stream);
2740 virtual HType CalculateInferredType(); 2728 virtual HType CalculateInferredType();
2741 2729
(...skipping 14 matching lines...) Expand all
2756 } 2744 }
2757 for (int i = 0; i < map_unique_ids_.length(); i++) { 2745 for (int i = 0; i < map_unique_ids_.length(); i++) {
2758 if (map_unique_ids_.at(i) != b->map_unique_ids_.at(i)) { 2746 if (map_unique_ids_.at(i) != b->map_unique_ids_.at(i)) {
2759 return false; 2747 return false;
2760 } 2748 }
2761 } 2749 }
2762 return true; 2750 return true;
2763 } 2751 }
2764 2752
2765 private: 2753 private:
2754 // Clients should use one of the static New* methods above.
2755 HCheckMaps(HValue* value, Zone *zone, HValue* typecheck)
2756 : map_unique_ids_(0, zone) {
2757 SetOperandAt(0, value);
2758 // Use the object value for the dependency if NULL is passed.
2759 // TODO(titzer): do GVN flags already express this dependency?
2760 SetOperandAt(1, typecheck != NULL ? typecheck : value);
2761 set_representation(Representation::Tagged());
2762 SetFlag(kUseGVN);
2763 SetFlag(kTrackSideEffectDominators);
2764 SetGVNFlag(kDependsOnMaps);
2765 SetGVNFlag(kDependsOnElementsKind);
2766 }
2767
2766 SmallMapList map_set_; 2768 SmallMapList map_set_;
2767 ZoneList<UniqueValueId> map_unique_ids_; 2769 ZoneList<UniqueValueId> map_unique_ids_;
2768 }; 2770 };
2769 2771
2770 2772
2771 class HCheckFunction: public HUnaryOperation { 2773 class HCheckFunction: public HUnaryOperation {
2772 public: 2774 public:
2773 HCheckFunction(HValue* value, Handle<JSFunction> function) 2775 HCheckFunction(HValue* value, Handle<JSFunction> function)
2774 : HUnaryOperation(value), target_(function), target_unique_id_() { 2776 : HUnaryOperation(value), target_(function), target_unique_id_() {
2775 set_representation(Representation::Tagged()); 2777 set_representation(Representation::Tagged());
(...skipping 3713 matching lines...) Expand 10 before | Expand all | Expand 10 after
6489 virtual bool IsDeletable() const { return true; } 6491 virtual bool IsDeletable() const { return true; }
6490 }; 6492 };
6491 6493
6492 6494
6493 #undef DECLARE_INSTRUCTION 6495 #undef DECLARE_INSTRUCTION
6494 #undef DECLARE_CONCRETE_INSTRUCTION 6496 #undef DECLARE_CONCRETE_INSTRUCTION
6495 6497
6496 } } // namespace v8::internal 6498 } } // namespace v8::internal
6497 6499
6498 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 6500 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698