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

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

Issue 6656001: Support external arrays in Crankshaft (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: stub out arm Created 9 years, 9 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
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 V(LeaveInlined) \ 122 V(LeaveInlined) \
123 V(LoadContextSlot) \ 123 V(LoadContextSlot) \
124 V(LoadElements) \ 124 V(LoadElements) \
125 V(LoadExternalArrayPointer) \ 125 V(LoadExternalArrayPointer) \
126 V(LoadFunctionPrototype) \ 126 V(LoadFunctionPrototype) \
127 V(LoadGlobal) \ 127 V(LoadGlobal) \
128 V(LoadKeyedFastElement) \ 128 V(LoadKeyedFastElement) \
129 V(LoadKeyedGeneric) \ 129 V(LoadKeyedGeneric) \
130 V(LoadNamedField) \ 130 V(LoadNamedField) \
131 V(LoadNamedGeneric) \ 131 V(LoadNamedGeneric) \
132 V(LoadPixelArrayElement) \ 132 V(LoadKeyedSpecializedArrayElement) \
133 V(Mod) \ 133 V(Mod) \
134 V(Mul) \ 134 V(Mul) \
135 V(ObjectLiteral) \ 135 V(ObjectLiteral) \
136 V(OsrEntry) \ 136 V(OsrEntry) \
137 V(OuterContext) \ 137 V(OuterContext) \
138 V(Parameter) \ 138 V(Parameter) \
139 V(Power) \ 139 V(Power) \
140 V(PushArgument) \ 140 V(PushArgument) \
141 V(RegExpLiteral) \ 141 V(RegExpLiteral) \
142 V(Return) \ 142 V(Return) \
143 V(Sar) \ 143 V(Sar) \
144 V(Shl) \ 144 V(Shl) \
145 V(Shr) \ 145 V(Shr) \
146 V(Simulate) \ 146 V(Simulate) \
147 V(StackCheck) \ 147 V(StackCheck) \
148 V(StoreContextSlot) \ 148 V(StoreContextSlot) \
149 V(StoreGlobal) \ 149 V(StoreGlobal) \
150 V(StoreKeyedFastElement) \ 150 V(StoreKeyedFastElement) \
151 V(StorePixelArrayElement) \ 151 V(StoreKeyedSpecializedArrayElement) \
152 V(StoreKeyedGeneric) \ 152 V(StoreKeyedGeneric) \
153 V(StoreNamedField) \ 153 V(StoreNamedField) \
154 V(StoreNamedGeneric) \ 154 V(StoreNamedGeneric) \
155 V(StringCharCodeAt) \ 155 V(StringCharCodeAt) \
156 V(StringCharFromCode) \ 156 V(StringCharFromCode) \
157 V(StringLength) \ 157 V(StringLength) \
158 V(Sub) \ 158 V(Sub) \
159 V(Test) \ 159 V(Test) \
160 V(Throw) \ 160 V(Throw) \
161 V(ToFastProperties) \ 161 V(ToFastProperties) \
162 V(Typeof) \ 162 V(Typeof) \
163 V(TypeofIs) \ 163 V(TypeofIs) \
164 V(UnaryMathOperation) \ 164 V(UnaryMathOperation) \
165 V(UnknownOSRValue) \ 165 V(UnknownOSRValue) \
166 V(ValueOf) 166 V(ValueOf)
167 167
168 #define GVN_FLAG_LIST(V) \ 168 #define GVN_FLAG_LIST(V) \
169 V(Calls) \ 169 V(Calls) \
170 V(InobjectFields) \ 170 V(InobjectFields) \
171 V(BackingStoreFields) \ 171 V(BackingStoreFields) \
172 V(ArrayElements) \ 172 V(ArrayElements) \
173 V(PixelArrayElements) \ 173 V(SpecializedArrayElements) \
174 V(GlobalVars) \ 174 V(GlobalVars) \
175 V(Maps) \ 175 V(Maps) \
176 V(ArrayLengths) \ 176 V(ArrayLengths) \
177 V(ContextSlots) \ 177 V(ContextSlots) \
178 V(OsrEntries) 178 V(OsrEntries)
179 179
180 #define DECLARE_INSTRUCTION(type) \ 180 #define DECLARE_INSTRUCTION(type) \
181 virtual bool Is##type() const { return true; } \ 181 virtual bool Is##type() const { return true; } \
182 static H##type* cast(HValue* value) { \ 182 static H##type* cast(HValue* value) { \
183 ASSERT(value->Is##type()); \ 183 ASSERT(value->Is##type()); \
(...skipping 1394 matching lines...) Expand 10 before | Expand all | Expand 10 after
1578 virtual bool DataEquals(HValue* other) { return true; } 1578 virtual bool DataEquals(HValue* other) { return true; }
1579 }; 1579 };
1580 1580
1581 1581
1582 class HLoadExternalArrayPointer: public HUnaryOperation { 1582 class HLoadExternalArrayPointer: public HUnaryOperation {
1583 public: 1583 public:
1584 explicit HLoadExternalArrayPointer(HValue* value) 1584 explicit HLoadExternalArrayPointer(HValue* value)
1585 : HUnaryOperation(value) { 1585 : HUnaryOperation(value) {
1586 set_representation(Representation::External()); 1586 set_representation(Representation::External());
1587 // The result of this instruction is idempotent as long as its inputs don't 1587 // The result of this instruction is idempotent as long as its inputs don't
1588 // change. The external array of a pixel array elements object cannot 1588 // change. The external array of a specialized array elements object cannot
1589 // change once set, so it's no necessary to introduce any additional 1589 // change once set, so it's no necessary to introduce any additional
1590 // dependencies on top of the inputs. 1590 // dependencies on top of the inputs.
1591 SetFlag(kUseGVN); 1591 SetFlag(kUseGVN);
1592 } 1592 }
1593 1593
1594 virtual Representation RequiredInputRepresentation(int index) const { 1594 virtual Representation RequiredInputRepresentation(int index) const {
1595 return Representation::Tagged(); 1595 return Representation::Tagged();
1596 } 1596 }
1597 1597
1598 DECLARE_CONCRETE_INSTRUCTION(LoadExternalArrayPointer, 1598 DECLARE_CONCRETE_INSTRUCTION(LoadExternalArrayPointer,
(...skipping 1438 matching lines...) Expand 10 before | Expand all | Expand 10 after
3037 virtual void PrintDataTo(StringStream* stream); 3037 virtual void PrintDataTo(StringStream* stream);
3038 3038
3039 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastElement, 3039 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastElement,
3040 "load_keyed_fast_element") 3040 "load_keyed_fast_element")
3041 3041
3042 protected: 3042 protected:
3043 virtual bool DataEquals(HValue* other) { return true; } 3043 virtual bool DataEquals(HValue* other) { return true; }
3044 }; 3044 };
3045 3045
3046 3046
3047 class HLoadPixelArrayElement: public HBinaryOperation { 3047 class HLoadKeyedSpecializedArrayElement: public HBinaryOperation {
3048 public: 3048 public:
3049 HLoadPixelArrayElement(HValue* external_elements, HValue* key) 3049 HLoadKeyedSpecializedArrayElement(HValue* external_elements,
3050 : HBinaryOperation(external_elements, key) { 3050 HValue* key,
3051 set_representation(Representation::Integer32()); 3051 ExternalArrayType array_type)
3052 SetFlag(kDependsOnPixelArrayElements); 3052 : HBinaryOperation(external_elements, key),
3053 // Native code could change the pixel array. 3053 array_type_(array_type) {
3054 if (array_type == kExternalFloatArray) {
3055 set_representation(Representation::Double());
3056 } else {
3057 set_representation(Representation::Integer32());
3058 }
3059 SetFlag(kDependsOnSpecializedArrayElements);
3060 // Native code could change the specialized array.
3054 SetFlag(kDependsOnCalls); 3061 SetFlag(kDependsOnCalls);
3055 SetFlag(kUseGVN); 3062 SetFlag(kUseGVN);
3056 } 3063 }
3057 3064
3058 virtual void PrintDataTo(StringStream* stream); 3065 virtual void PrintDataTo(StringStream* stream);
3059 3066
3060 virtual Representation RequiredInputRepresentation(int index) const { 3067 virtual Representation RequiredInputRepresentation(int index) const {
3061 // The key is supposed to be Integer32, but the base pointer 3068 // The key is supposed to be Integer32, but the base pointer
3062 // for the element load is a naked pointer. 3069 // for the element load is a naked pointer.
3063 return (index == 1) ? Representation::Integer32() 3070 return (index == 1) ? Representation::Integer32()
3064 : Representation::External(); 3071 : Representation::External();
3065 } 3072 }
3066 3073
3067 HValue* external_pointer() { return OperandAt(0); } 3074 HValue* external_pointer() { return OperandAt(0); }
3068 HValue* key() { return OperandAt(1); } 3075 HValue* key() { return OperandAt(1); }
3076 ExternalArrayType array_type() const { return array_type_; }
3069 3077
3070 DECLARE_CONCRETE_INSTRUCTION(LoadPixelArrayElement, 3078 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedSpecializedArrayElement,
3071 "load_pixel_array_element") 3079 "load_keyed_specialized_array_element")
3072 3080
3073 protected: 3081 protected:
3074 virtual bool DataEquals(HValue* other) { return true; } 3082 virtual bool DataEquals(HValue* other) { return true; }
Kevin Millikin (Chromium) 2011/03/24 11:21:00 This function needs to compare the two array types
danno 2011/03/24 13:18:38 good catch. done.
3083
3084 private:
3085 ExternalArrayType array_type_;
3075 }; 3086 };
3076 3087
3077 3088
3078 class HLoadKeyedGeneric: public HTemplateInstruction<3> { 3089 class HLoadKeyedGeneric: public HTemplateInstruction<3> {
3079 public: 3090 public:
3080 HLoadKeyedGeneric(HContext* context, HValue* obj, HValue* key) { 3091 HLoadKeyedGeneric(HContext* context, HValue* obj, HValue* key) {
3081 set_representation(Representation::Tagged()); 3092 set_representation(Representation::Tagged());
3082 SetOperandAt(0, obj); 3093 SetOperandAt(0, obj);
3083 SetOperandAt(1, key); 3094 SetOperandAt(1, key);
3084 SetOperandAt(2, context); 3095 SetOperandAt(2, context);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
3199 return StoringValueNeedsWriteBarrier(value()); 3210 return StoringValueNeedsWriteBarrier(value());
3200 } 3211 }
3201 3212
3202 virtual void PrintDataTo(StringStream* stream); 3213 virtual void PrintDataTo(StringStream* stream);
3203 3214
3204 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFastElement, 3215 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFastElement,
3205 "store_keyed_fast_element") 3216 "store_keyed_fast_element")
3206 }; 3217 };
3207 3218
3208 3219
3209 class HStorePixelArrayElement: public HTemplateInstruction<3> { 3220 class HStoreKeyedSpecializedArrayElement: public HTemplateInstruction<3> {
3210 public: 3221 public:
3211 HStorePixelArrayElement(HValue* external_elements, HValue* key, HValue* val) { 3222 HStoreKeyedSpecializedArrayElement(HValue* external_elements,
3212 SetFlag(kChangesPixelArrayElements); 3223 HValue* key,
3224 HValue* val,
3225 ExternalArrayType array_type)
3226 : array_type_(array_type) {
3227 SetFlag(kChangesSpecializedArrayElements);
3213 SetOperandAt(0, external_elements); 3228 SetOperandAt(0, external_elements);
3214 SetOperandAt(1, key); 3229 SetOperandAt(1, key);
3215 SetOperandAt(2, val); 3230 SetOperandAt(2, val);
3216 } 3231 }
3217 3232
3218 virtual void PrintDataTo(StringStream* stream); 3233 virtual void PrintDataTo(StringStream* stream);
3219 3234
3220 virtual Representation RequiredInputRepresentation(int index) const { 3235 virtual Representation RequiredInputRepresentation(int index) const {
3221 if (index == 0) { 3236 if (index == 0) {
3222 return Representation::External(); 3237 return Representation::External();
3223 } else { 3238 } else {
3224 return Representation::Integer32(); 3239 if (index == 2 && array_type() == kExternalFloatArray) {
3240 return Representation::Double();
3241 } else {
3242 return Representation::Integer32();
3243 }
3225 } 3244 }
3226 } 3245 }
3227 3246
3228 HValue* external_pointer() { return OperandAt(0); } 3247 HValue* external_pointer() { return OperandAt(0); }
3229 HValue* key() { return OperandAt(1); } 3248 HValue* key() { return OperandAt(1); }
3230 HValue* value() { return OperandAt(2); } 3249 HValue* value() { return OperandAt(2); }
3250 ExternalArrayType array_type() const { return array_type_; }
3231 3251
3232 DECLARE_CONCRETE_INSTRUCTION(StorePixelArrayElement, 3252 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedSpecializedArrayElement,
3233 "store_pixel_array_element") 3253 "store_keyed_specialized_array_element")
3254 private:
3255 ExternalArrayType array_type_;
3234 }; 3256 };
3235 3257
3236 3258
3237 class HStoreKeyedGeneric: public HTemplateInstruction<4> { 3259 class HStoreKeyedGeneric: public HTemplateInstruction<4> {
3238 public: 3260 public:
3239 HStoreKeyedGeneric(HValue* context, 3261 HStoreKeyedGeneric(HValue* context,
3240 HValue* object, 3262 HValue* object,
3241 HValue* key, 3263 HValue* key,
3242 HValue* value) { 3264 HValue* value) {
3243 SetOperandAt(0, object); 3265 SetOperandAt(0, object);
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
3522 HValue* object() { return left(); } 3544 HValue* object() { return left(); }
3523 HValue* key() { return right(); } 3545 HValue* key() { return right(); }
3524 }; 3546 };
3525 3547
3526 #undef DECLARE_INSTRUCTION 3548 #undef DECLARE_INSTRUCTION
3527 #undef DECLARE_CONCRETE_INSTRUCTION 3549 #undef DECLARE_CONCRETE_INSTRUCTION
3528 3550
3529 } } // namespace v8::internal 3551 } } // namespace v8::internal
3530 3552
3531 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 3553 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698