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

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

Issue 10382055: Array index computation dehoisting. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 7 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 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 3936 matching lines...) Expand 10 before | Expand all | Expand 10 after
3947 }; 3947 };
3948 3948
3949 3949
3950 class HLoadKeyedFastElement: public HTemplateInstruction<2> { 3950 class HLoadKeyedFastElement: public HTemplateInstruction<2> {
3951 public: 3951 public:
3952 enum HoleCheckMode { PERFORM_HOLE_CHECK, OMIT_HOLE_CHECK }; 3952 enum HoleCheckMode { PERFORM_HOLE_CHECK, OMIT_HOLE_CHECK };
3953 3953
3954 HLoadKeyedFastElement(HValue* obj, 3954 HLoadKeyedFastElement(HValue* obj,
3955 HValue* key, 3955 HValue* key,
3956 HoleCheckMode hole_check_mode = PERFORM_HOLE_CHECK) 3956 HoleCheckMode hole_check_mode = PERFORM_HOLE_CHECK)
3957 : hole_check_mode_(hole_check_mode) { 3957 : hole_check_mode_(hole_check_mode), index_offset_(0) {
3958 SetOperandAt(0, obj); 3958 SetOperandAt(0, obj);
3959 SetOperandAt(1, key); 3959 SetOperandAt(1, key);
3960 set_representation(Representation::Tagged()); 3960 set_representation(Representation::Tagged());
3961 SetGVNFlag(kDependsOnArrayElements); 3961 SetGVNFlag(kDependsOnArrayElements);
3962 SetFlag(kUseGVN); 3962 SetFlag(kUseGVN);
3963 } 3963 }
3964 3964
3965 HValue* object() { return OperandAt(0); } 3965 HValue* object() { return OperandAt(0); }
3966 HValue* key() { return OperandAt(1); } 3966 HValue* key() { return OperandAt(1); }
3967 uint32_t index_offset() { return index_offset_; }
3968 void SetIndexOffset(uint32_t index_offset) { index_offset_ = index_offset; }
3967 3969
3968 virtual Representation RequiredInputRepresentation(int index) { 3970 virtual Representation RequiredInputRepresentation(int index) {
3969 // The key is supposed to be Integer32. 3971 // The key is supposed to be Integer32.
3970 return index == 0 3972 return index == 0
3971 ? Representation::Tagged() 3973 ? Representation::Tagged()
3972 : Representation::Integer32(); 3974 : Representation::Integer32();
3973 } 3975 }
3974 3976
3975 virtual void PrintDataTo(StringStream* stream); 3977 virtual void PrintDataTo(StringStream* stream);
3976 3978
3977 bool RequiresHoleCheck(); 3979 bool RequiresHoleCheck();
3978 3980
3979 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastElement) 3981 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastElement)
3980 3982
3981 protected: 3983 protected:
3982 virtual bool DataEquals(HValue* other) { 3984 virtual bool DataEquals(HValue* other) {
3983 if (!other->IsLoadKeyedFastElement()) return false; 3985 if (!other->IsLoadKeyedFastElement()) return false;
3984 HLoadKeyedFastElement* other_load = HLoadKeyedFastElement::cast(other); 3986 HLoadKeyedFastElement* other_load = HLoadKeyedFastElement::cast(other);
3985 return hole_check_mode_ == other_load->hole_check_mode_; 3987 return hole_check_mode_ == other_load->hole_check_mode_;
3986 } 3988 }
3987 3989
3988 private: 3990 private:
3989 HoleCheckMode hole_check_mode_; 3991 HoleCheckMode hole_check_mode_;
3992 uint32_t index_offset_;
Jakob Kummerow 2012/05/08 13:46:26 Why is this a uint32_t? In hydrogen.cc, you're pas
Massi 2012/05/14 13:48:52 This is unsigned because on ia32 and x64 we can on
3990 }; 3993 };
3991 3994
3992 3995
3993 class HLoadKeyedFastDoubleElement: public HTemplateInstruction<2> { 3996 class HLoadKeyedFastDoubleElement: public HTemplateInstruction<2> {
3994 public: 3997 public:
3995 HLoadKeyedFastDoubleElement(HValue* elements, HValue* key) { 3998 HLoadKeyedFastDoubleElement(HValue* elements, HValue* key) :
Jakob Kummerow 2012/05/08 13:46:26 nit: the colon goes in the next line (see HLoadKey
Massi 2012/05/14 13:48:52 Done.
3999 index_offset_(0) {
3996 SetOperandAt(0, elements); 4000 SetOperandAt(0, elements);
3997 SetOperandAt(1, key); 4001 SetOperandAt(1, key);
3998 set_representation(Representation::Double()); 4002 set_representation(Representation::Double());
3999 SetGVNFlag(kDependsOnDoubleArrayElements); 4003 SetGVNFlag(kDependsOnDoubleArrayElements);
4000 SetFlag(kUseGVN); 4004 SetFlag(kUseGVN);
4001 } 4005 }
4002 4006
4003 HValue* elements() { return OperandAt(0); } 4007 HValue* elements() { return OperandAt(0); }
4004 HValue* key() { return OperandAt(1); } 4008 HValue* key() { return OperandAt(1); }
4009 uint32_t index_offset() { return index_offset_; }
4010 void SetIndexOffset(uint32_t index_offset) { index_offset_ = index_offset; }
4005 4011
4006 virtual Representation RequiredInputRepresentation(int index) { 4012 virtual Representation RequiredInputRepresentation(int index) {
4007 // The key is supposed to be Integer32. 4013 // The key is supposed to be Integer32.
4008 return index == 0 4014 return index == 0
4009 ? Representation::Tagged() 4015 ? Representation::Tagged()
4010 : Representation::Integer32(); 4016 : Representation::Integer32();
4011 } 4017 }
4012 4018
4013 virtual void PrintDataTo(StringStream* stream); 4019 virtual void PrintDataTo(StringStream* stream);
4014 4020
4015 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastDoubleElement) 4021 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastDoubleElement)
4016 4022
4017 protected: 4023 protected:
4018 virtual bool DataEquals(HValue* other) { return true; } 4024 virtual bool DataEquals(HValue* other) { return true; }
4025
4026 private:
4027 uint32_t index_offset_;
4019 }; 4028 };
4020 4029
4021 4030
4022 class HLoadKeyedSpecializedArrayElement: public HTemplateInstruction<2> { 4031 class HLoadKeyedSpecializedArrayElement: public HTemplateInstruction<2> {
4023 public: 4032 public:
4024 HLoadKeyedSpecializedArrayElement(HValue* external_elements, 4033 HLoadKeyedSpecializedArrayElement(HValue* external_elements,
4025 HValue* key, 4034 HValue* key,
4026 ElementsKind elements_kind) 4035 ElementsKind elements_kind)
4027 : elements_kind_(elements_kind) { 4036 : elements_kind_(elements_kind), index_offset_(0) {
4028 SetOperandAt(0, external_elements); 4037 SetOperandAt(0, external_elements);
4029 SetOperandAt(1, key); 4038 SetOperandAt(1, key);
4030 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS || 4039 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS ||
4031 elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { 4040 elements_kind == EXTERNAL_DOUBLE_ELEMENTS) {
4032 set_representation(Representation::Double()); 4041 set_representation(Representation::Double());
4033 } else { 4042 } else {
4034 set_representation(Representation::Integer32()); 4043 set_representation(Representation::Integer32());
4035 } 4044 }
4036 SetGVNFlag(kDependsOnSpecializedArrayElements); 4045 SetGVNFlag(kDependsOnSpecializedArrayElements);
4037 // Native code could change the specialized array. 4046 // Native code could change the specialized array.
4038 SetGVNFlag(kDependsOnCalls); 4047 SetGVNFlag(kDependsOnCalls);
4039 SetFlag(kUseGVN); 4048 SetFlag(kUseGVN);
4040 } 4049 }
4041 4050
4042 virtual void PrintDataTo(StringStream* stream); 4051 virtual void PrintDataTo(StringStream* stream);
4043 4052
4044 virtual Representation RequiredInputRepresentation(int index) { 4053 virtual Representation RequiredInputRepresentation(int index) {
4045 // The key is supposed to be Integer32, but the base pointer 4054 // The key is supposed to be Integer32, but the base pointer
4046 // for the element load is a naked pointer. 4055 // for the element load is a naked pointer.
4047 return index == 0 4056 return index == 0
4048 ? Representation::External() 4057 ? Representation::External()
4049 : Representation::Integer32(); 4058 : Representation::Integer32();
4050 } 4059 }
4051 4060
4052 HValue* external_pointer() { return OperandAt(0); } 4061 HValue* external_pointer() { return OperandAt(0); }
4053 HValue* key() { return OperandAt(1); } 4062 HValue* key() { return OperandAt(1); }
4054 ElementsKind elements_kind() const { return elements_kind_; } 4063 ElementsKind elements_kind() const { return elements_kind_; }
4064 uint32_t index_offset() { return index_offset_; }
4065 void SetIndexOffset(uint32_t index_offset) { index_offset_ = index_offset; }
4055 4066
4056 virtual Range* InferRange(Zone* zone); 4067 virtual Range* InferRange(Zone* zone);
4057 4068
4058 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedSpecializedArrayElement) 4069 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedSpecializedArrayElement)
4059 4070
4060 protected: 4071 protected:
4061 virtual bool DataEquals(HValue* other) { 4072 virtual bool DataEquals(HValue* other) {
4062 if (!other->IsLoadKeyedSpecializedArrayElement()) return false; 4073 if (!other->IsLoadKeyedSpecializedArrayElement()) return false;
4063 HLoadKeyedSpecializedArrayElement* cast_other = 4074 HLoadKeyedSpecializedArrayElement* cast_other =
4064 HLoadKeyedSpecializedArrayElement::cast(other); 4075 HLoadKeyedSpecializedArrayElement::cast(other);
4065 return elements_kind_ == cast_other->elements_kind(); 4076 return elements_kind_ == cast_other->elements_kind();
4066 } 4077 }
4067 4078
4068 private: 4079 private:
4069 ElementsKind elements_kind_; 4080 ElementsKind elements_kind_;
4081 uint32_t index_offset_;
4070 }; 4082 };
4071 4083
4072 4084
4073 class HLoadKeyedGeneric: public HTemplateInstruction<3> { 4085 class HLoadKeyedGeneric: public HTemplateInstruction<3> {
4074 public: 4086 public:
4075 HLoadKeyedGeneric(HValue* context, HValue* obj, HValue* key) { 4087 HLoadKeyedGeneric(HValue* context, HValue* obj, HValue* key) {
4076 set_representation(Representation::Tagged()); 4088 set_representation(Representation::Tagged());
4077 SetOperandAt(0, obj); 4089 SetOperandAt(0, obj);
4078 SetOperandAt(1, key); 4090 SetOperandAt(1, key);
4079 SetOperandAt(2, context); 4091 SetOperandAt(2, context);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
4185 private: 4197 private:
4186 Handle<String> name_; 4198 Handle<String> name_;
4187 StrictModeFlag strict_mode_flag_; 4199 StrictModeFlag strict_mode_flag_;
4188 }; 4200 };
4189 4201
4190 4202
4191 class HStoreKeyedFastElement: public HTemplateInstruction<3> { 4203 class HStoreKeyedFastElement: public HTemplateInstruction<3> {
4192 public: 4204 public:
4193 HStoreKeyedFastElement(HValue* obj, HValue* key, HValue* val, 4205 HStoreKeyedFastElement(HValue* obj, HValue* key, HValue* val,
4194 ElementsKind elements_kind = FAST_ELEMENTS) 4206 ElementsKind elements_kind = FAST_ELEMENTS)
4195 : elements_kind_(elements_kind) { 4207 : elements_kind_(elements_kind), index_offset_(0) {
4196 SetOperandAt(0, obj); 4208 SetOperandAt(0, obj);
4197 SetOperandAt(1, key); 4209 SetOperandAt(1, key);
4198 SetOperandAt(2, val); 4210 SetOperandAt(2, val);
4199 SetGVNFlag(kChangesArrayElements); 4211 SetGVNFlag(kChangesArrayElements);
4200 } 4212 }
4201 4213
4202 virtual Representation RequiredInputRepresentation(int index) { 4214 virtual Representation RequiredInputRepresentation(int index) {
4203 // The key is supposed to be Integer32. 4215 // The key is supposed to be Integer32.
4204 return index == 1 4216 return index == 1
4205 ? Representation::Integer32() 4217 ? Representation::Integer32()
4206 : Representation::Tagged(); 4218 : Representation::Tagged();
4207 } 4219 }
4208 4220
4209 HValue* object() { return OperandAt(0); } 4221 HValue* object() { return OperandAt(0); }
4210 HValue* key() { return OperandAt(1); } 4222 HValue* key() { return OperandAt(1); }
4211 HValue* value() { return OperandAt(2); } 4223 HValue* value() { return OperandAt(2); }
4212 bool value_is_smi() { 4224 bool value_is_smi() {
4213 return elements_kind_ == FAST_SMI_ONLY_ELEMENTS; 4225 return elements_kind_ == FAST_SMI_ONLY_ELEMENTS;
4214 } 4226 }
4227 uint32_t index_offset() { return index_offset_; }
4228 void SetIndexOffset(uint32_t index_offset) { index_offset_ = index_offset; }
4215 4229
4216 bool NeedsWriteBarrier() { 4230 bool NeedsWriteBarrier() {
4217 if (value_is_smi()) { 4231 if (value_is_smi()) {
4218 return false; 4232 return false;
4219 } else { 4233 } else {
4220 return StoringValueNeedsWriteBarrier(value()); 4234 return StoringValueNeedsWriteBarrier(value());
4221 } 4235 }
4222 } 4236 }
4223 4237
4224 virtual void PrintDataTo(StringStream* stream); 4238 virtual void PrintDataTo(StringStream* stream);
4225 4239
4226 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFastElement) 4240 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFastElement)
4227 4241
4228 private: 4242 private:
4229 ElementsKind elements_kind_; 4243 ElementsKind elements_kind_;
4244 uint32_t index_offset_;
4230 }; 4245 };
4231 4246
4232 4247
4233 class HStoreKeyedFastDoubleElement: public HTemplateInstruction<3> { 4248 class HStoreKeyedFastDoubleElement: public HTemplateInstruction<3> {
4234 public: 4249 public:
4235 HStoreKeyedFastDoubleElement(HValue* elements, 4250 HStoreKeyedFastDoubleElement(HValue* elements,
4236 HValue* key, 4251 HValue* key,
4237 HValue* val) { 4252 HValue* val) : index_offset_(0) {
4238 SetOperandAt(0, elements); 4253 SetOperandAt(0, elements);
4239 SetOperandAt(1, key); 4254 SetOperandAt(1, key);
4240 SetOperandAt(2, val); 4255 SetOperandAt(2, val);
4241 SetGVNFlag(kChangesDoubleArrayElements); 4256 SetGVNFlag(kChangesDoubleArrayElements);
4242 } 4257 }
4243 4258
4244 virtual Representation RequiredInputRepresentation(int index) { 4259 virtual Representation RequiredInputRepresentation(int index) {
4245 if (index == 1) { 4260 if (index == 1) {
4246 return Representation::Integer32(); 4261 return Representation::Integer32();
4247 } else if (index == 2) { 4262 } else if (index == 2) {
4248 return Representation::Double(); 4263 return Representation::Double();
4249 } else { 4264 } else {
4250 return Representation::Tagged(); 4265 return Representation::Tagged();
4251 } 4266 }
4252 } 4267 }
4253 4268
4254 HValue* elements() { return OperandAt(0); } 4269 HValue* elements() { return OperandAt(0); }
4255 HValue* key() { return OperandAt(1); } 4270 HValue* key() { return OperandAt(1); }
4256 HValue* value() { return OperandAt(2); } 4271 HValue* value() { return OperandAt(2); }
4272 uint32_t index_offset() { return index_offset_; }
4273 void SetIndexOffset(uint32_t index_offset) { index_offset_ = index_offset; }
4257 4274
4258 bool NeedsWriteBarrier() { 4275 bool NeedsWriteBarrier() {
4259 return StoringValueNeedsWriteBarrier(value()); 4276 return StoringValueNeedsWriteBarrier(value());
4260 } 4277 }
4261 4278
4262 bool NeedsCanonicalization(); 4279 bool NeedsCanonicalization();
4263 4280
4264 virtual void PrintDataTo(StringStream* stream); 4281 virtual void PrintDataTo(StringStream* stream);
4265 4282
4266 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFastDoubleElement) 4283 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFastDoubleElement)
4284
4285 private:
4286 uint32_t index_offset_;
4267 }; 4287 };
4268 4288
4269 4289
4270 class HStoreKeyedSpecializedArrayElement: public HTemplateInstruction<3> { 4290 class HStoreKeyedSpecializedArrayElement: public HTemplateInstruction<3> {
4271 public: 4291 public:
4272 HStoreKeyedSpecializedArrayElement(HValue* external_elements, 4292 HStoreKeyedSpecializedArrayElement(HValue* external_elements,
4273 HValue* key, 4293 HValue* key,
4274 HValue* val, 4294 HValue* val,
4275 ElementsKind elements_kind) 4295 ElementsKind elements_kind)
4276 : elements_kind_(elements_kind) { 4296 : elements_kind_(elements_kind), index_offset_(0) {
4277 SetGVNFlag(kChangesSpecializedArrayElements); 4297 SetGVNFlag(kChangesSpecializedArrayElements);
4278 SetOperandAt(0, external_elements); 4298 SetOperandAt(0, external_elements);
4279 SetOperandAt(1, key); 4299 SetOperandAt(1, key);
4280 SetOperandAt(2, val); 4300 SetOperandAt(2, val);
4281 } 4301 }
4282 4302
4283 virtual void PrintDataTo(StringStream* stream); 4303 virtual void PrintDataTo(StringStream* stream);
4284 4304
4285 virtual Representation RequiredInputRepresentation(int index) { 4305 virtual Representation RequiredInputRepresentation(int index) {
4286 if (index == 0) { 4306 if (index == 0) {
4287 return Representation::External(); 4307 return Representation::External();
4288 } else { 4308 } else {
4289 bool float_or_double_elements = 4309 bool float_or_double_elements =
4290 elements_kind() == EXTERNAL_FLOAT_ELEMENTS || 4310 elements_kind() == EXTERNAL_FLOAT_ELEMENTS ||
4291 elements_kind() == EXTERNAL_DOUBLE_ELEMENTS; 4311 elements_kind() == EXTERNAL_DOUBLE_ELEMENTS;
4292 if (index == 2 && float_or_double_elements) { 4312 if (index == 2 && float_or_double_elements) {
4293 return Representation::Double(); 4313 return Representation::Double();
4294 } else { 4314 } else {
4295 return Representation::Integer32(); 4315 return Representation::Integer32();
4296 } 4316 }
4297 } 4317 }
4298 } 4318 }
4299 4319
4300 HValue* external_pointer() { return OperandAt(0); } 4320 HValue* external_pointer() { return OperandAt(0); }
4301 HValue* key() { return OperandAt(1); } 4321 HValue* key() { return OperandAt(1); }
4302 HValue* value() { return OperandAt(2); } 4322 HValue* value() { return OperandAt(2); }
4303 ElementsKind elements_kind() const { return elements_kind_; } 4323 ElementsKind elements_kind() const { return elements_kind_; }
4324 uint32_t index_offset() { return index_offset_; }
4325 void SetIndexOffset(uint32_t index_offset) { index_offset_ = index_offset; }
4304 4326
4305 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedSpecializedArrayElement) 4327 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedSpecializedArrayElement)
4306 4328
4307 private: 4329 private:
4308 ElementsKind elements_kind_; 4330 ElementsKind elements_kind_;
4331 uint32_t index_offset_;
4309 }; 4332 };
4310 4333
4311 4334
4312 class HStoreKeyedGeneric: public HTemplateInstruction<4> { 4335 class HStoreKeyedGeneric: public HTemplateInstruction<4> {
4313 public: 4336 public:
4314 HStoreKeyedGeneric(HValue* context, 4337 HStoreKeyedGeneric(HValue* context,
4315 HValue* object, 4338 HValue* object,
4316 HValue* key, 4339 HValue* key,
4317 HValue* value, 4340 HValue* value,
4318 StrictModeFlag strict_mode_flag) 4341 StrictModeFlag strict_mode_flag)
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
4959 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex); 4982 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex);
4960 }; 4983 };
4961 4984
4962 4985
4963 #undef DECLARE_INSTRUCTION 4986 #undef DECLARE_INSTRUCTION
4964 #undef DECLARE_CONCRETE_INSTRUCTION 4987 #undef DECLARE_CONCRETE_INSTRUCTION
4965 4988
4966 } } // namespace v8::internal 4989 } } // namespace v8::internal
4967 4990
4968 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 4991 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698