 Chromium Code Reviews
 Chromium Code Reviews Issue 6390003:
  Introduce a hydrogen value for contexts, support context slot assignment.  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
    
  
    Issue 6390003:
  Introduce a hydrogen value for contexts, support context slot assignment.  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge| Index: src/hydrogen-instructions.h | 
| diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h | 
| index ff8170012e6b025e0a0d7b6ded6652e6075beb6c..86a85c5bfafbfd054ac0e07ee6801057296d2dd8 100644 | 
| --- a/src/hydrogen-instructions.h | 
| +++ b/src/hydrogen-instructions.h | 
| @@ -97,6 +97,7 @@ class LChunkBuilder; | 
| V(CompareJSObjectEq) \ | 
| V(CompareMap) \ | 
| V(Constant) \ | 
| + V(Context) \ | 
| V(DeleteProperty) \ | 
| V(Deoptimize) \ | 
| V(Div) \ | 
| @@ -128,6 +129,7 @@ class LChunkBuilder; | 
| V(Mul) \ | 
| V(ObjectLiteral) \ | 
| V(OsrEntry) \ | 
| + V(OuterContext) \ | 
| V(Parameter) \ | 
| V(Power) \ | 
| V(PushArgument) \ | 
| @@ -138,6 +140,7 @@ class LChunkBuilder; | 
| V(Shr) \ | 
| V(Simulate) \ | 
| V(StackCheck) \ | 
| + V(StoreContextSlot) \ | 
| V(StoreGlobal) \ | 
| V(StoreKeyedFastElement) \ | 
| V(StoreKeyedGeneric) \ | 
| @@ -162,6 +165,7 @@ class LChunkBuilder; | 
| V(GlobalVars) \ | 
| V(Maps) \ | 
| V(ArrayLengths) \ | 
| + V(ContextSlots) \ | 
| V(OsrEntries) | 
| #define DECLARE_INSTRUCTION(type) \ | 
| @@ -1046,12 +1050,39 @@ class HPushArgument: public HUnaryOperation { | 
| }; | 
| -class HGlobalObject: public HInstruction { | 
| +class HContext: public HInstruction { | 
| public: | 
| - HGlobalObject() { | 
| + HContext() { | 
| + set_representation(Representation::Tagged()); | 
| + SetFlag(kUseGVN); | 
| + } | 
| + | 
| + DECLARE_CONCRETE_INSTRUCTION(Context, "context"); | 
| + | 
| + protected: | 
| + virtual bool DataEquals(HValue* other) const { return true; } | 
| +}; | 
| + | 
| + | 
| +class HOuterContext: public HUnaryOperation { | 
| + public: | 
| + explicit HOuterContext(HValue* inner) : HUnaryOperation(inner) { | 
| + set_representation(Representation::Tagged()); | 
| + SetFlag(kUseGVN); | 
| + } | 
| + | 
| + DECLARE_CONCRETE_INSTRUCTION(OuterContext, "outer_context"); | 
| + | 
| + protected: | 
| + virtual bool DataEquals(HValue* other) const { return true; } | 
| +}; | 
| + | 
| + | 
| +class HGlobalObject: public HUnaryOperation { | 
| + public: | 
| + explicit HGlobalObject(HValue* context) : HUnaryOperation(context) { | 
| set_representation(Representation::Tagged()); | 
| SetFlag(kUseGVN); | 
| - SetFlag(kDependsOnCalls); | 
| } | 
| DECLARE_CONCRETE_INSTRUCTION(GlobalObject, "global_object") | 
| @@ -1061,12 +1092,12 @@ class HGlobalObject: public HInstruction { | 
| }; | 
| -class HGlobalReceiver: public HInstruction { | 
| +class HGlobalReceiver: public HUnaryOperation { | 
| public: | 
| - HGlobalReceiver() { | 
| + explicit HGlobalReceiver(HValue* global_object) | 
| + : HUnaryOperation(global_object) { | 
| set_representation(Representation::Tagged()); | 
| SetFlag(kUseGVN); | 
| - SetFlag(kDependsOnCalls); | 
| } | 
| DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver, "global_receiver") | 
| @@ -2600,35 +2631,56 @@ class HStoreGlobal: public HUnaryOperation { | 
| }; | 
| -class HLoadContextSlot: public HInstruction { | 
| +class HLoadContextSlot: public HUnaryOperation { | 
| public: | 
| - HLoadContextSlot(int context_chain_length , int slot_index) | 
| - : context_chain_length_(context_chain_length), slot_index_(slot_index) { | 
| + HLoadContextSlot(HValue* context , int slot_index) | 
| + : HUnaryOperation(context), slot_index_(slot_index) { | 
| set_representation(Representation::Tagged()); | 
| SetFlag(kUseGVN); | 
| - SetFlag(kDependsOnCalls); | 
| + SetFlag(kDependsOnContextSlots); | 
| } | 
| - int context_chain_length() const { return context_chain_length_; } | 
| int slot_index() const { return slot_index_; } | 
| - virtual void PrintDataTo(StringStream* stream) const; | 
| - | 
| - virtual intptr_t Hashcode() const { | 
| - return context_chain_length() * 29 + slot_index(); | 
| + virtual Representation RequiredInputRepresentation(int index) const { | 
| 
fschneider
2011/01/28 11:54:50
I think we are not consistent with when to overrid
 
Kevin Millikin (Chromium)
2011/02/03 08:37:23
Do you think that's a good idea?  It seems like an
 | 
| + return Representation::Tagged(); | 
| } | 
| + virtual void PrintDataTo(StringStream* stream) const; | 
| + | 
| DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load_context_slot") | 
| protected: | 
| virtual bool DataEquals(HValue* other) const { | 
| HLoadContextSlot* b = HLoadContextSlot::cast(other); | 
| - return (context_chain_length() == b->context_chain_length()) | 
| - && (slot_index() == b->slot_index()); | 
| + return (slot_index() == b->slot_index()); | 
| } | 
| private: | 
| - int context_chain_length_; | 
| + int slot_index_; | 
| +}; | 
| + | 
| + | 
| +class HStoreContextSlot: public HBinaryOperation { | 
| + public: | 
| + HStoreContextSlot(HValue* context, int slot_index, HValue* value) | 
| + : HBinaryOperation(context, value), slot_index_(slot_index) { | 
| + SetFlag(kChangesContextSlots); | 
| + } | 
| + | 
| + HValue* context() const { return OperandAt(0); } | 
| + HValue* value() const { return OperandAt(1); } | 
| + int slot_index() const { return slot_index_; } | 
| + | 
| + virtual Representation RequiredInputRepresentation(int index) const { | 
| + return Representation::Tagged(); | 
| + } | 
| + | 
| + virtual void PrintDataTo(StringStream* stream) const; | 
| + | 
| + DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store_context_slot") | 
| + | 
| + private: | 
| int slot_index_; | 
| }; | 
| @@ -2818,7 +2870,7 @@ class HStoreNamedField: public HStoreNamed { | 
| DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store_named_field") | 
| virtual Representation RequiredInputRepresentation(int index) const { | 
| - return Representation::Tagged(); | 
| + return Representation::Tagged(); | 
| } | 
| virtual void PrintDataTo(StringStream* stream) const; |