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

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

Issue 23697002: Implement proper map checks of captured objects. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Toon Verwaest. Created 7 years, 3 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-escape-analysis.cc ('k') | src/hydrogen-instructions.cc » ('j') | 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 V(CallGlobal) \ 81 V(CallGlobal) \
82 V(CallKeyed) \ 82 V(CallKeyed) \
83 V(CallKnownGlobal) \ 83 V(CallKnownGlobal) \
84 V(CallNamed) \ 84 V(CallNamed) \
85 V(CallNew) \ 85 V(CallNew) \
86 V(CallNewArray) \ 86 V(CallNewArray) \
87 V(CallRuntime) \ 87 V(CallRuntime) \
88 V(CallStub) \ 88 V(CallStub) \
89 V(CapturedObject) \ 89 V(CapturedObject) \
90 V(Change) \ 90 V(Change) \
91 V(CheckFunction) \
92 V(CheckHeapObject) \ 91 V(CheckHeapObject) \
93 V(CheckInstanceType) \ 92 V(CheckInstanceType) \
94 V(CheckMaps) \ 93 V(CheckMaps) \
95 V(CheckMapValue) \ 94 V(CheckMapValue) \
96 V(CheckSmi) \ 95 V(CheckSmi) \
96 V(CheckValue) \
97 V(ClampToUint8) \ 97 V(ClampToUint8) \
98 V(ClassOfTestAndBranch) \ 98 V(ClassOfTestAndBranch) \
99 V(CompareNumericAndBranch) \ 99 V(CompareNumericAndBranch) \
100 V(CompareHoleAndBranch) \ 100 V(CompareHoleAndBranch) \
101 V(CompareGeneric) \ 101 V(CompareGeneric) \
102 V(CompareObjectEqAndBranch) \ 102 V(CompareObjectEqAndBranch) \
103 V(CompareMap) \ 103 V(CompareMap) \
104 V(Constant) \ 104 V(Constant) \
105 V(Context) \ 105 V(Context) \
106 V(DateField) \ 106 V(DateField) \
(...skipping 2442 matching lines...) Expand 10 before | Expand all | Expand 10 after
2549 virtual bool HasEscapingOperandAt(int index) V8_OVERRIDE { return false; } 2549 virtual bool HasEscapingOperandAt(int index) V8_OVERRIDE { return false; }
2550 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { 2550 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
2551 return Representation::Tagged(); 2551 return Representation::Tagged();
2552 } 2552 }
2553 virtual void HandleSideEffectDominator(GVNFlag side_effect, 2553 virtual void HandleSideEffectDominator(GVNFlag side_effect,
2554 HValue* dominator) V8_OVERRIDE; 2554 HValue* dominator) V8_OVERRIDE;
2555 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; 2555 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2556 2556
2557 HValue* value() { return OperandAt(0); } 2557 HValue* value() { return OperandAt(0); }
2558 SmallMapList* map_set() { return &map_set_; } 2558 SmallMapList* map_set() { return &map_set_; }
2559 ZoneList<UniqueValueId>* map_unique_ids() { return &map_unique_ids_; }
2559 2560
2560 bool has_migration_target() { 2561 bool has_migration_target() {
2561 return has_migration_target_; 2562 return has_migration_target_;
2562 } 2563 }
2563 2564
2564 virtual void FinalizeUniqueValueId() V8_OVERRIDE; 2565 virtual void FinalizeUniqueValueId() V8_OVERRIDE;
2565 2566
2566 DECLARE_CONCRETE_INSTRUCTION(CheckMaps) 2567 DECLARE_CONCRETE_INSTRUCTION(CheckMaps)
2567 2568
2568 protected: 2569 protected:
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2617 } 2618 }
2618 } 2619 }
2619 2620
2620 bool omit_; 2621 bool omit_;
2621 bool has_migration_target_; 2622 bool has_migration_target_;
2622 SmallMapList map_set_; 2623 SmallMapList map_set_;
2623 ZoneList<UniqueValueId> map_unique_ids_; 2624 ZoneList<UniqueValueId> map_unique_ids_;
2624 }; 2625 };
2625 2626
2626 2627
2627 class HCheckFunction V8_FINAL : public HUnaryOperation { 2628 class HCheckValue V8_FINAL : public HUnaryOperation {
2628 public: 2629 public:
2629 DECLARE_INSTRUCTION_FACTORY_P2(HCheckFunction, HValue*, Handle<JSFunction>); 2630 static HCheckValue* New(Zone* zone, HValue* context,
2631 HValue* value, Handle<JSFunction> target) {
2632 bool in_new_space = Isolate::Current()->heap()->InNewSpace(*target);
2633 HCheckValue* check = new(zone) HCheckValue(value, target, in_new_space);
2634 return check;
2635 }
2636 static HCheckValue* New(Zone* zone, HValue* context,
2637 HValue* value, Handle<Map> map, UniqueValueId id) {
2638 HCheckValue* check = new(zone) HCheckValue(value, map, false);
2639 check->object_unique_id_ = id;
2640 return check;
2641 }
2630 2642
2631 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { 2643 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
2632 return Representation::Tagged(); 2644 return Representation::Tagged();
2633 } 2645 }
2634 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; 2646 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2635 2647
2636 virtual HValue* Canonicalize() V8_OVERRIDE; 2648 virtual HValue* Canonicalize() V8_OVERRIDE;
2637 2649
2638 #ifdef DEBUG 2650 #ifdef DEBUG
2639 virtual void Verify() V8_OVERRIDE; 2651 virtual void Verify() V8_OVERRIDE;
2640 #endif 2652 #endif
2641 2653
2642 virtual void FinalizeUniqueValueId() V8_OVERRIDE { 2654 virtual void FinalizeUniqueValueId() V8_OVERRIDE {
2643 target_unique_id_ = UniqueValueId(target_); 2655 object_unique_id_ = UniqueValueId(object_);
2644 } 2656 }
2645 2657
2646 Handle<JSFunction> target() const { return target_; } 2658 Handle<HeapObject> object() const { return object_; }
2647 bool target_in_new_space() const { return target_in_new_space_; } 2659 bool object_in_new_space() const { return object_in_new_space_; }
2648 2660
2649 DECLARE_CONCRETE_INSTRUCTION(CheckFunction) 2661 DECLARE_CONCRETE_INSTRUCTION(CheckValue)
2650 2662
2651 protected: 2663 protected:
2652 virtual bool DataEquals(HValue* other) V8_OVERRIDE { 2664 virtual bool DataEquals(HValue* other) V8_OVERRIDE {
2653 HCheckFunction* b = HCheckFunction::cast(other); 2665 HCheckValue* b = HCheckValue::cast(other);
2654 return target_unique_id_ == b->target_unique_id_; 2666 return object_unique_id_ == b->object_unique_id_;
2655 } 2667 }
2656 2668
2657 private: 2669 private:
2658 HCheckFunction(HValue* value, Handle<JSFunction> function) 2670 HCheckValue(HValue* value, Handle<HeapObject> object, bool in_new_space)
2659 : HUnaryOperation(value, value->type()), 2671 : HUnaryOperation(value, value->type()),
2660 target_(function), target_unique_id_() { 2672 object_(object), object_in_new_space_(in_new_space) {
2661 set_representation(Representation::Tagged()); 2673 set_representation(Representation::Tagged());
2662 SetFlag(kUseGVN); 2674 SetFlag(kUseGVN);
2663 target_in_new_space_ = Isolate::Current()->heap()->InNewSpace(*function);
2664 } 2675 }
2665 2676
2666 Handle<JSFunction> target_; 2677 Handle<HeapObject> object_;
2667 UniqueValueId target_unique_id_; 2678 UniqueValueId object_unique_id_;
2668 bool target_in_new_space_; 2679 bool object_in_new_space_;
2669 }; 2680 };
2670 2681
2671 2682
2672 class HCheckInstanceType V8_FINAL : public HUnaryOperation { 2683 class HCheckInstanceType V8_FINAL : public HUnaryOperation {
2673 public: 2684 public:
2674 static HCheckInstanceType* NewIsSpecObject(HValue* value, Zone* zone) { 2685 static HCheckInstanceType* NewIsSpecObject(HValue* value, Zone* zone) {
2675 return new(zone) HCheckInstanceType(value, IS_SPEC_OBJECT); 2686 return new(zone) HCheckInstanceType(value, IS_SPEC_OBJECT);
2676 } 2687 }
2677 static HCheckInstanceType* NewIsJSArray(HValue* value, Zone* zone) { 2688 static HCheckInstanceType* NewIsJSArray(HValue* value, Zone* zone) {
2678 return new(zone) HCheckInstanceType(value, IS_JS_ARRAY); 2689 return new(zone) HCheckInstanceType(value, IS_JS_ARRAY);
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
3217 values_.AddBlock(NULL, length, zone); // Resize list. 3228 values_.AddBlock(NULL, length, zone); // Resize list.
3218 } 3229 }
3219 3230
3220 // The values contain a list of all in-object properties inside the 3231 // The values contain a list of all in-object properties inside the
3221 // captured object and is index by field index. Properties in the 3232 // captured object and is index by field index. Properties in the
3222 // properties or elements backing store are not tracked here. 3233 // properties or elements backing store are not tracked here.
3223 const ZoneList<HValue*>* values() const { return &values_; } 3234 const ZoneList<HValue*>* values() const { return &values_; }
3224 int length() const { return values_.length(); } 3235 int length() const { return values_.length(); }
3225 int capture_id() const { return capture_id_; } 3236 int capture_id() const { return capture_id_; }
3226 3237
3238 // Shortcut for the map value of this captured object.
3239 HValue* map_value() const { return values()->first(); }
3240
3227 // Replay effects of this instruction on the given environment. 3241 // Replay effects of this instruction on the given environment.
3228 void ReplayEnvironment(HEnvironment* env); 3242 void ReplayEnvironment(HEnvironment* env);
3229 3243
3230 DECLARE_CONCRETE_INSTRUCTION(CapturedObject) 3244 DECLARE_CONCRETE_INSTRUCTION(CapturedObject)
3231 3245
3232 private: 3246 private:
3233 int capture_id_; 3247 int capture_id_;
3234 }; 3248 };
3235 3249
3236 3250
(...skipping 3607 matching lines...) Expand 10 before | Expand all | Expand 10 after
6844 virtual bool IsDeletable() const V8_OVERRIDE { return true; } 6858 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
6845 }; 6859 };
6846 6860
6847 6861
6848 #undef DECLARE_INSTRUCTION 6862 #undef DECLARE_INSTRUCTION
6849 #undef DECLARE_CONCRETE_INSTRUCTION 6863 #undef DECLARE_CONCRETE_INSTRUCTION
6850 6864
6851 } } // namespace v8::internal 6865 } } // namespace v8::internal
6852 6866
6853 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 6867 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « src/hydrogen-escape-analysis.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698