OLD | NEW |
---|---|
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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
126 V(IsSmiAndBranch) \ | 126 V(IsSmiAndBranch) \ |
127 V(IsUndetectableAndBranch) \ | 127 V(IsUndetectableAndBranch) \ |
128 V(JSArrayLength) \ | 128 V(JSArrayLength) \ |
129 V(LeaveInlined) \ | 129 V(LeaveInlined) \ |
130 V(LoadContextSlot) \ | 130 V(LoadContextSlot) \ |
131 V(LoadElements) \ | 131 V(LoadElements) \ |
132 V(LoadExternalArrayPointer) \ | 132 V(LoadExternalArrayPointer) \ |
133 V(LoadFunctionPrototype) \ | 133 V(LoadFunctionPrototype) \ |
134 V(LoadGlobalCell) \ | 134 V(LoadGlobalCell) \ |
135 V(LoadGlobalGeneric) \ | 135 V(LoadGlobalGeneric) \ |
136 V(LoadKeyedFastDoubleElement) \ | 136 V(LoadKeyed) \ |
137 V(LoadKeyedFastElement) \ | |
138 V(LoadKeyedGeneric) \ | 137 V(LoadKeyedGeneric) \ |
139 V(LoadKeyedSpecializedArrayElement) \ | |
140 V(LoadNamedField) \ | 138 V(LoadNamedField) \ |
141 V(LoadNamedFieldPolymorphic) \ | 139 V(LoadNamedFieldPolymorphic) \ |
142 V(LoadNamedGeneric) \ | 140 V(LoadNamedGeneric) \ |
143 V(MapEnumLength) \ | 141 V(MapEnumLength) \ |
144 V(MathFloorOfDiv) \ | 142 V(MathFloorOfDiv) \ |
145 V(MathMinMax) \ | 143 V(MathMinMax) \ |
146 V(Mod) \ | 144 V(Mod) \ |
147 V(Mul) \ | 145 V(Mul) \ |
148 V(ObjectLiteral) \ | 146 V(ObjectLiteral) \ |
149 V(OsrEntry) \ | 147 V(OsrEntry) \ |
150 V(OuterContext) \ | 148 V(OuterContext) \ |
151 V(Parameter) \ | 149 V(Parameter) \ |
152 V(Power) \ | 150 V(Power) \ |
153 V(PushArgument) \ | 151 V(PushArgument) \ |
154 V(Random) \ | 152 V(Random) \ |
155 V(RegExpLiteral) \ | 153 V(RegExpLiteral) \ |
156 V(Return) \ | 154 V(Return) \ |
157 V(Sar) \ | 155 V(Sar) \ |
158 V(Shl) \ | 156 V(Shl) \ |
159 V(Shr) \ | 157 V(Shr) \ |
160 V(Simulate) \ | 158 V(Simulate) \ |
161 V(SoftDeoptimize) \ | 159 V(SoftDeoptimize) \ |
162 V(StackCheck) \ | 160 V(StackCheck) \ |
163 V(StoreContextSlot) \ | 161 V(StoreContextSlot) \ |
164 V(StoreGlobalCell) \ | 162 V(StoreGlobalCell) \ |
165 V(StoreGlobalGeneric) \ | 163 V(StoreGlobalGeneric) \ |
166 V(StoreKeyedFastDoubleElement) \ | 164 V(StoreKeyed) \ |
167 V(StoreKeyedFastElement) \ | |
168 V(StoreKeyedGeneric) \ | 165 V(StoreKeyedGeneric) \ |
169 V(StoreKeyedSpecializedArrayElement) \ | |
170 V(StoreNamedField) \ | 166 V(StoreNamedField) \ |
171 V(StoreNamedGeneric) \ | 167 V(StoreNamedGeneric) \ |
172 V(StringAdd) \ | 168 V(StringAdd) \ |
173 V(StringCharCodeAt) \ | 169 V(StringCharCodeAt) \ |
174 V(StringCharFromCode) \ | 170 V(StringCharFromCode) \ |
175 V(StringCompareAndBranch) \ | 171 V(StringCompareAndBranch) \ |
176 V(StringLength) \ | 172 V(StringLength) \ |
177 V(Sub) \ | 173 V(Sub) \ |
178 V(ThisFunction) \ | 174 V(ThisFunction) \ |
179 V(Throw) \ | 175 V(Throw) \ |
(...skipping 4056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4236 class ArrayInstructionInterface { | 4232 class ArrayInstructionInterface { |
4237 public: | 4233 public: |
4238 virtual HValue* GetKey() = 0; | 4234 virtual HValue* GetKey() = 0; |
4239 virtual void SetKey(HValue* key) = 0; | 4235 virtual void SetKey(HValue* key) = 0; |
4240 virtual void SetIndexOffset(uint32_t index_offset) = 0; | 4236 virtual void SetIndexOffset(uint32_t index_offset) = 0; |
4241 virtual bool IsDehoisted() = 0; | 4237 virtual bool IsDehoisted() = 0; |
4242 virtual void SetDehoisted(bool is_dehoisted) = 0; | 4238 virtual void SetDehoisted(bool is_dehoisted) = 0; |
4243 virtual ~ArrayInstructionInterface() { }; | 4239 virtual ~ArrayInstructionInterface() { }; |
4244 }; | 4240 }; |
4245 | 4241 |
4246 class HLoadKeyedFastElement | 4242 |
4243 class HLoadKeyed | |
4247 : public HTemplateInstruction<3>, public ArrayInstructionInterface { | 4244 : public HTemplateInstruction<3>, public ArrayInstructionInterface { |
4248 public: | 4245 public: |
4249 HLoadKeyedFastElement(HValue* obj, | 4246 HLoadKeyed(HValue* obj, |
4250 HValue* key, | 4247 HValue* key, |
4251 HValue* dependency, | 4248 HValue* dependency, |
4252 ElementsKind elements_kind = FAST_ELEMENTS) | 4249 ElementsKind elements_kind, |
4250 bool is_external) | |
4253 : bit_field_(0) { | 4251 : bit_field_(0) { |
4254 ASSERT(IsFastSmiOrObjectElementsKind(elements_kind)); | |
4255 bit_field_ = ElementsKindField::encode(elements_kind); | 4252 bit_field_ = ElementsKindField::encode(elements_kind); |
4256 if (IsFastSmiElementsKind(elements_kind) && | 4253 |
4257 IsFastPackedElementsKind(elements_kind)) { | |
4258 set_type(HType::Smi()); | |
4259 } | |
4260 SetOperandAt(0, obj); | 4254 SetOperandAt(0, obj); |
4261 SetOperandAt(1, key); | 4255 SetOperandAt(1, key); |
4262 SetOperandAt(2, dependency); | 4256 SetOperandAt(2, dependency); |
4263 set_representation(Representation::Tagged()); | 4257 |
4264 SetGVNFlag(kDependsOnArrayElements); | 4258 if (!is_external) { |
danno
2012/10/21 20:44:41
use IsExternalArrayElementsKind here
| |
4259 // I can detect the case between storing double (holey and fast) and | |
4260 // smi/object by looking at elements_kind_. | |
4261 ASSERT(IsFastSmiOrObjectElementsKind(elements_kind) || | |
4262 IsFastDoubleElementsKind(elements_kind)); | |
4263 | |
4264 if (IsFastSmiOrObjectElementsKind(elements_kind)) { | |
4265 if (IsFastSmiElementsKind(elements_kind) && | |
4266 IsFastPackedElementsKind(elements_kind)) { | |
4267 set_type(HType::Smi()); | |
4268 } | |
4269 | |
4270 set_representation(Representation::Tagged()); | |
4271 SetGVNFlag(kDependsOnArrayElements); | |
4272 } else { | |
4273 set_representation(Representation::Double()); | |
4274 SetGVNFlag(kDependsOnDoubleArrayElements); | |
4275 } | |
4276 } else { | |
4277 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS || | |
4278 elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { | |
4279 set_representation(Representation::Double()); | |
4280 } else { | |
4281 set_representation(Representation::Integer32()); | |
4282 } | |
4283 | |
4284 SetGVNFlag(kDependsOnSpecializedArrayElements); | |
4285 // Native code could change the specialized array. | |
4286 SetGVNFlag(kDependsOnCalls); | |
4287 } | |
4288 | |
4265 SetFlag(kUseGVN); | 4289 SetFlag(kUseGVN); |
4266 } | 4290 } |
4267 | 4291 |
4268 HValue* object() { return OperandAt(0); } | 4292 bool is_external() const { return |
danno
2012/10/21 20:44:41
use IsExternalArrayElementsKind(elements_kind()) t
| |
4293 CheckGVNFlag(kDependsOnSpecializedArrayElements); } | |
4294 HValue* object() { | |
4295 ASSERT(!is_external()); | |
4296 return OperandAt(0); | |
4297 } | |
4298 HValue* external_pointer() { | |
4299 ASSERT(is_external()); | |
4300 return OperandAt(0); | |
4301 } | |
4269 HValue* key() { return OperandAt(1); } | 4302 HValue* key() { return OperandAt(1); } |
4270 HValue* dependency() { return OperandAt(2); } | 4303 HValue* dependency() { return OperandAt(2); } |
4271 uint32_t index_offset() { return IndexOffsetField::decode(bit_field_); } | 4304 uint32_t index_offset() { return IndexOffsetField::decode(bit_field_); } |
4272 void SetIndexOffset(uint32_t index_offset) { | 4305 void SetIndexOffset(uint32_t index_offset) { |
4273 bit_field_ = IndexOffsetField::update(bit_field_, index_offset); | 4306 bit_field_ = IndexOffsetField::update(bit_field_, index_offset); |
4274 } | 4307 } |
4275 HValue* GetKey() { return key(); } | 4308 HValue* GetKey() { return key(); } |
4276 void SetKey(HValue* key) { SetOperandAt(1, key); } | 4309 void SetKey(HValue* key) { SetOperandAt(1, key); } |
4310 | |
4277 bool IsDehoisted() { return IsDehoistedField::decode(bit_field_); } | 4311 bool IsDehoisted() { return IsDehoistedField::decode(bit_field_); } |
4278 void SetDehoisted(bool is_dehoisted) { | 4312 void SetDehoisted(bool is_dehoisted) { |
4279 bit_field_ = IsDehoistedField::update(bit_field_, is_dehoisted); | 4313 bit_field_ = IsDehoistedField::update(bit_field_, is_dehoisted); |
4280 } | 4314 } |
4281 ElementsKind elements_kind() const { | 4315 ElementsKind elements_kind() const { |
4282 return ElementsKindField::decode(bit_field_); | 4316 return ElementsKindField::decode(bit_field_); |
4283 } | 4317 } |
4284 | 4318 |
4285 virtual Representation RequiredInputRepresentation(int index) { | 4319 virtual Representation RequiredInputRepresentation(int index) { |
4320 // <tagged | external>[int] (dependency = none) | |
4286 // The key is supposed to be Integer32. | 4321 // The key is supposed to be Integer32. |
4287 if (index == 0) return Representation::Tagged(); | 4322 if (index == 0) { |
4323 return is_external() ? Representation::External() | |
4324 : Representation::Tagged(); | |
4325 } | |
4288 if (index == 1) return Representation::Integer32(); | 4326 if (index == 1) return Representation::Integer32(); |
4289 return Representation::None(); | 4327 return Representation::None(); |
4290 } | 4328 } |
4291 | 4329 |
4292 virtual void PrintDataTo(StringStream* stream); | 4330 virtual void PrintDataTo(StringStream* stream); |
4293 | 4331 |
4294 bool RequiresHoleCheck() const; | 4332 bool RequiresHoleCheck() const; |
4295 | 4333 |
4296 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastElement) | 4334 virtual Range* InferRange(Zone* zone); |
4335 | |
4336 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed) | |
4297 | 4337 |
4298 protected: | 4338 protected: |
4299 virtual bool DataEquals(HValue* other) { | 4339 virtual bool DataEquals(HValue* other) { |
4300 if (!other->IsLoadKeyedFastElement()) return false; | 4340 if (!other->IsLoadKeyed()) return false; |
4301 HLoadKeyedFastElement* other_load = HLoadKeyedFastElement::cast(other); | 4341 HLoadKeyed* other_load = HLoadKeyed::cast(other); |
4342 | |
4343 // TODO(mvstanton): doing a special check for external here, because | |
4344 // external didn't care about hoisting state and index offset. | |
4345 // Is this nessecary at all? | |
danno
2012/10/21 20:44:41
We should be able to treat all array accesses unif
mvstanton
2012/10/23 23:44:20
Done.
| |
4346 if (is_external() && other_load->is_external()) { | |
4347 return elements_kind() == other_load->elements_kind(); | |
4348 } | |
4349 | |
4302 if (IsDehoisted() && index_offset() != other_load->index_offset()) | 4350 if (IsDehoisted() && index_offset() != other_load->index_offset()) |
4303 return false; | 4351 return false; |
4304 return elements_kind() == other_load->elements_kind(); | 4352 return elements_kind() == other_load->elements_kind(); |
4305 } | 4353 } |
4306 | 4354 |
4307 private: | 4355 private: |
4308 virtual bool IsDeletable() const { return !RequiresHoleCheck(); } | 4356 virtual bool IsDeletable() const { |
4357 return is_external() ? true : !RequiresHoleCheck(); | |
danno
2012/10/21 20:44:41
RequiresHoleCheck should return false for external
mvstanton
2012/10/23 23:44:20
Done.
| |
4358 } | |
4309 | 4359 |
4310 class ElementsKindField: public BitField<ElementsKind, 0, 4> {}; | 4360 // TODO(mvstanton) - to deal with some of the external element |
4311 class IndexOffsetField: public BitField<uint32_t, 4, 27> {}; | 4361 // kinds (PIXEL_ARRAY) I gave the ElementsKindField another bit, |
4362 // taking it from the index offset. | |
4363 // Is this okay? | |
4364 class ElementsKindField: public BitField<ElementsKind, 0, 5> {}; | |
4365 class IndexOffsetField: public BitField<uint32_t, 5, 26> {}; | |
4312 class IsDehoistedField: public BitField<bool, 31, 1> {}; | 4366 class IsDehoistedField: public BitField<bool, 31, 1> {}; |
4313 uint32_t bit_field_; | 4367 uint32_t bit_field_; |
4314 }; | 4368 }; |
4315 | 4369 |
4316 | 4370 |
4317 enum HoleCheckMode { PERFORM_HOLE_CHECK, OMIT_HOLE_CHECK }; | |
4318 | |
4319 | |
4320 class HLoadKeyedFastDoubleElement | |
4321 : public HTemplateInstruction<3>, public ArrayInstructionInterface { | |
4322 public: | |
4323 HLoadKeyedFastDoubleElement( | |
4324 HValue* elements, | |
4325 HValue* key, | |
4326 HValue* dependency, | |
4327 HoleCheckMode hole_check_mode = PERFORM_HOLE_CHECK) | |
4328 : index_offset_(0), | |
4329 is_dehoisted_(false), | |
4330 hole_check_mode_(hole_check_mode) { | |
4331 SetOperandAt(0, elements); | |
4332 SetOperandAt(1, key); | |
4333 SetOperandAt(2, dependency); | |
4334 set_representation(Representation::Double()); | |
4335 SetGVNFlag(kDependsOnDoubleArrayElements); | |
4336 SetFlag(kUseGVN); | |
4337 } | |
4338 | |
4339 HValue* elements() { return OperandAt(0); } | |
4340 HValue* key() { return OperandAt(1); } | |
4341 HValue* dependency() { return OperandAt(2); } | |
4342 uint32_t index_offset() { return index_offset_; } | |
4343 void SetIndexOffset(uint32_t index_offset) { index_offset_ = index_offset; } | |
4344 HValue* GetKey() { return key(); } | |
4345 void SetKey(HValue* key) { SetOperandAt(1, key); } | |
4346 bool IsDehoisted() { return is_dehoisted_; } | |
4347 void SetDehoisted(bool is_dehoisted) { is_dehoisted_ = is_dehoisted; } | |
4348 | |
4349 virtual Representation RequiredInputRepresentation(int index) { | |
4350 // The key is supposed to be Integer32. | |
4351 if (index == 0) return Representation::Tagged(); | |
4352 if (index == 1) return Representation::Integer32(); | |
4353 return Representation::None(); | |
4354 } | |
4355 | |
4356 bool RequiresHoleCheck() const { | |
4357 return hole_check_mode_ == PERFORM_HOLE_CHECK; | |
4358 } | |
4359 | |
4360 virtual void PrintDataTo(StringStream* stream); | |
4361 | |
4362 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastDoubleElement) | |
4363 | |
4364 protected: | |
4365 virtual bool DataEquals(HValue* other) { | |
4366 if (!other->IsLoadKeyedFastDoubleElement()) return false; | |
4367 HLoadKeyedFastDoubleElement* other_load = | |
4368 HLoadKeyedFastDoubleElement::cast(other); | |
4369 return hole_check_mode_ == other_load->hole_check_mode_; | |
4370 } | |
4371 | |
4372 private: | |
4373 virtual bool IsDeletable() const { return !RequiresHoleCheck(); } | |
4374 | |
4375 uint32_t index_offset_; | |
4376 bool is_dehoisted_; | |
4377 HoleCheckMode hole_check_mode_; | |
4378 }; | |
4379 | |
4380 | |
4381 class HLoadKeyedSpecializedArrayElement | |
4382 : public HTemplateInstruction<3>, public ArrayInstructionInterface { | |
4383 public: | |
4384 HLoadKeyedSpecializedArrayElement(HValue* external_elements, | |
4385 HValue* key, | |
4386 HValue* dependency, | |
4387 ElementsKind elements_kind) | |
4388 : elements_kind_(elements_kind), | |
4389 index_offset_(0), | |
4390 is_dehoisted_(false) { | |
4391 SetOperandAt(0, external_elements); | |
4392 SetOperandAt(1, key); | |
4393 SetOperandAt(2, dependency); | |
4394 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS || | |
4395 elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { | |
4396 set_representation(Representation::Double()); | |
4397 } else { | |
4398 set_representation(Representation::Integer32()); | |
4399 } | |
4400 SetGVNFlag(kDependsOnSpecializedArrayElements); | |
4401 // Native code could change the specialized array. | |
4402 SetGVNFlag(kDependsOnCalls); | |
4403 SetFlag(kUseGVN); | |
4404 } | |
4405 | |
4406 virtual void PrintDataTo(StringStream* stream); | |
4407 | |
4408 virtual Representation RequiredInputRepresentation(int index) { | |
4409 // The key is supposed to be Integer32. | |
4410 if (index == 0) return Representation::External(); | |
4411 if (index == 1) return Representation::Integer32(); | |
4412 return Representation::None(); | |
4413 } | |
4414 | |
4415 HValue* external_pointer() { return OperandAt(0); } | |
4416 HValue* key() { return OperandAt(1); } | |
4417 HValue* dependency() { return OperandAt(2); } | |
4418 ElementsKind elements_kind() const { return elements_kind_; } | |
4419 uint32_t index_offset() { return index_offset_; } | |
4420 void SetIndexOffset(uint32_t index_offset) { index_offset_ = index_offset; } | |
4421 HValue* GetKey() { return key(); } | |
4422 void SetKey(HValue* key) { SetOperandAt(1, key); } | |
4423 bool IsDehoisted() { return is_dehoisted_; } | |
4424 void SetDehoisted(bool is_dehoisted) { is_dehoisted_ = is_dehoisted; } | |
4425 | |
4426 virtual Range* InferRange(Zone* zone); | |
4427 | |
4428 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedSpecializedArrayElement) | |
4429 | |
4430 protected: | |
4431 virtual bool DataEquals(HValue* other) { | |
4432 if (!other->IsLoadKeyedSpecializedArrayElement()) return false; | |
4433 HLoadKeyedSpecializedArrayElement* cast_other = | |
4434 HLoadKeyedSpecializedArrayElement::cast(other); | |
4435 return elements_kind_ == cast_other->elements_kind(); | |
4436 } | |
4437 | |
4438 private: | |
4439 virtual bool IsDeletable() const { return true; } | |
4440 | |
4441 ElementsKind elements_kind_; | |
4442 uint32_t index_offset_; | |
4443 bool is_dehoisted_; | |
4444 }; | |
4445 | |
4446 | |
4447 class HLoadKeyedGeneric: public HTemplateInstruction<3> { | 4371 class HLoadKeyedGeneric: public HTemplateInstruction<3> { |
4448 public: | 4372 public: |
4449 HLoadKeyedGeneric(HValue* context, HValue* obj, HValue* key) { | 4373 HLoadKeyedGeneric(HValue* context, HValue* obj, HValue* key) { |
4450 set_representation(Representation::Tagged()); | 4374 set_representation(Representation::Tagged()); |
4451 SetOperandAt(0, obj); | 4375 SetOperandAt(0, obj); |
4452 SetOperandAt(1, key); | 4376 SetOperandAt(1, key); |
4453 SetOperandAt(2, context); | 4377 SetOperandAt(2, context); |
4454 SetAllSideEffects(); | 4378 SetAllSideEffects(); |
4455 } | 4379 } |
4456 | 4380 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4559 } | 4483 } |
4560 | 4484 |
4561 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric) | 4485 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric) |
4562 | 4486 |
4563 private: | 4487 private: |
4564 Handle<String> name_; | 4488 Handle<String> name_; |
4565 StrictModeFlag strict_mode_flag_; | 4489 StrictModeFlag strict_mode_flag_; |
4566 }; | 4490 }; |
4567 | 4491 |
4568 | 4492 |
4569 class HStoreKeyedFastElement | 4493 class HStoreKeyed |
4570 : public HTemplateInstruction<3>, public ArrayInstructionInterface { | 4494 : public HTemplateInstruction<3>, public ArrayInstructionInterface { |
4571 public: | 4495 public: |
4572 HStoreKeyedFastElement(HValue* obj, HValue* key, HValue* val, | 4496 HStoreKeyed(HValue* obj, HValue* key, HValue* val, |
4573 ElementsKind elements_kind = FAST_ELEMENTS) | 4497 ElementsKind elements_kind, bool is_external) |
danno
2012/10/21 20:44:41
Same feedback here about is_external as in the loa
mvstanton
2012/10/23 23:44:20
Done.
| |
4574 : elements_kind_(elements_kind), index_offset_(0), is_dehoisted_(false) { | 4498 : elements_kind_(elements_kind), index_offset_(0), is_dehoisted_(false) { |
4575 SetOperandAt(0, obj); | 4499 SetOperandAt(0, obj); |
4576 SetOperandAt(1, key); | 4500 SetOperandAt(1, key); |
4577 SetOperandAt(2, val); | 4501 SetOperandAt(2, val); |
4578 SetGVNFlag(kChangesArrayElements); | 4502 |
4503 if (is_external) { | |
4504 SetGVNFlag(kChangesSpecializedArrayElements); | |
4505 } else if (!IsFastDoubleElementsKind(elements_kind)) { | |
4506 SetGVNFlag(kChangesArrayElements); | |
4507 } else { | |
4508 SetFlag(kDeoptimizeOnUndefined); | |
4509 SetGVNFlag(kChangesDoubleArrayElements); | |
4510 } | |
4579 } | 4511 } |
4580 | 4512 |
4581 virtual Representation RequiredInputRepresentation(int index) { | 4513 virtual Representation RequiredInputRepresentation(int index) { |
4582 // The key is supposed to be Integer32. | 4514 // The key is supposed to be Integer32. |
4583 return index == 1 | 4515 // (<tagged> | <external>>[int32] = <tagged> | double | int |
danno
2012/10/21 20:44:41
nit: (<tagged> | <external>)[int32] = (<tagged> |
mvstanton
2012/10/23 23:44:20
Done.
| |
4584 ? Representation::Integer32() | 4516 if (index == 0) { |
4585 : Representation::Tagged(); | 4517 return is_external() ? Representation::External() |
4518 : Representation::Tagged(); | |
4519 } else if (index == 1) { | |
4520 return Representation::Integer32(); | |
4521 } | |
4522 | |
4523 ASSERT_EQ(index, 2); | |
danno
2012/10/21 20:44:41
Perhaps add a new predicate in elements-kind.h tha
mvstanton
2012/10/23 23:44:20
Wow, that was quite a knot, thanks!
Actually, hav
| |
4524 if (is_external()) { | |
4525 bool float_or_double_elements = | |
4526 elements_kind() == EXTERNAL_FLOAT_ELEMENTS || | |
4527 elements_kind() == EXTERNAL_DOUBLE_ELEMENTS; | |
4528 return float_or_double_elements ? Representation::Double() | |
4529 : Representation::Integer32(); | |
4530 } | |
4531 | |
4532 return IsFastDoubleElementsKind(elements_kind()) ? Representation::Double() | |
4533 : Representation::Tagged(); | |
4586 } | 4534 } |
4587 | 4535 |
4588 HValue* object() { return OperandAt(0); } | 4536 bool is_external() const { return |
4537 CheckGVNFlag(kChangesSpecializedArrayElements); } | |
4538 HValue* external_pointer() { | |
4539 ASSERT(is_external()); | |
4540 return OperandAt(0); | |
4541 } | |
4542 HValue* object() { | |
4543 ASSERT(!is_external()); | |
4544 return OperandAt(0); | |
4545 } | |
4589 HValue* key() { return OperandAt(1); } | 4546 HValue* key() { return OperandAt(1); } |
4590 HValue* value() { return OperandAt(2); } | 4547 HValue* value() { return OperandAt(2); } |
4591 bool value_is_smi() { | 4548 bool value_is_smi() const { |
4592 return IsFastSmiElementsKind(elements_kind_); | 4549 return IsFastSmiElementsKind(elements_kind_); |
4593 } | 4550 } |
4551 ElementsKind elements_kind() const { return elements_kind_; } | |
4594 uint32_t index_offset() { return index_offset_; } | 4552 uint32_t index_offset() { return index_offset_; } |
4595 void SetIndexOffset(uint32_t index_offset) { index_offset_ = index_offset; } | 4553 void SetIndexOffset(uint32_t index_offset) { index_offset_ = index_offset; } |
4596 HValue* GetKey() { return key(); } | 4554 HValue* GetKey() { return key(); } |
4597 void SetKey(HValue* key) { SetOperandAt(1, key); } | 4555 void SetKey(HValue* key) { SetOperandAt(1, key); } |
4598 bool IsDehoisted() { return is_dehoisted_; } | 4556 bool IsDehoisted() { return is_dehoisted_; } |
4599 void SetDehoisted(bool is_dehoisted) { is_dehoisted_ = is_dehoisted; } | 4557 void SetDehoisted(bool is_dehoisted) { is_dehoisted_ = is_dehoisted; } |
4600 | 4558 |
4601 bool NeedsWriteBarrier() { | 4559 bool NeedsWriteBarrier() { |
4602 if (value_is_smi()) { | 4560 if (value_is_smi()) { |
4603 return false; | 4561 return false; |
4604 } else { | 4562 } else { |
4605 return StoringValueNeedsWriteBarrier(value()); | 4563 return StoringValueNeedsWriteBarrier(value()); |
4606 } | 4564 } |
4607 } | 4565 } |
4608 | 4566 |
4609 virtual void PrintDataTo(StringStream* stream); | |
4610 | |
4611 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFastElement) | |
4612 | |
4613 private: | |
4614 ElementsKind elements_kind_; | |
4615 uint32_t index_offset_; | |
4616 bool is_dehoisted_; | |
4617 }; | |
4618 | |
4619 | |
4620 class HStoreKeyedFastDoubleElement | |
4621 : public HTemplateInstruction<3>, public ArrayInstructionInterface { | |
4622 public: | |
4623 HStoreKeyedFastDoubleElement(HValue* elements, | |
4624 HValue* key, | |
4625 HValue* val) | |
4626 : index_offset_(0), is_dehoisted_(false) { | |
4627 SetOperandAt(0, elements); | |
4628 SetOperandAt(1, key); | |
4629 SetOperandAt(2, val); | |
4630 SetFlag(kDeoptimizeOnUndefined); | |
4631 SetGVNFlag(kChangesDoubleArrayElements); | |
4632 } | |
4633 | |
4634 virtual Representation RequiredInputRepresentation(int index) { | |
4635 if (index == 1) { | |
4636 return Representation::Integer32(); | |
4637 } else if (index == 2) { | |
4638 return Representation::Double(); | |
4639 } else { | |
4640 return Representation::Tagged(); | |
4641 } | |
4642 } | |
4643 | |
4644 HValue* elements() { return OperandAt(0); } | |
4645 HValue* key() { return OperandAt(1); } | |
4646 HValue* value() { return OperandAt(2); } | |
4647 uint32_t index_offset() { return index_offset_; } | |
4648 void SetIndexOffset(uint32_t index_offset) { index_offset_ = index_offset; } | |
4649 HValue* GetKey() { return key(); } | |
4650 void SetKey(HValue* key) { SetOperandAt(1, key); } | |
4651 bool IsDehoisted() { return is_dehoisted_; } | |
4652 void SetDehoisted(bool is_dehoisted) { is_dehoisted_ = is_dehoisted; } | |
4653 | |
4654 bool NeedsWriteBarrier() { | |
4655 return StoringValueNeedsWriteBarrier(value()); | |
4656 } | |
4657 | |
4658 bool NeedsCanonicalization(); | 4567 bool NeedsCanonicalization(); |
4659 | 4568 |
4660 virtual void PrintDataTo(StringStream* stream); | 4569 virtual void PrintDataTo(StringStream* stream); |
4661 | 4570 |
4662 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFastDoubleElement) | 4571 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed) |
4663 | |
4664 private: | |
4665 uint32_t index_offset_; | |
4666 bool is_dehoisted_; | |
4667 }; | |
4668 | |
4669 | |
4670 class HStoreKeyedSpecializedArrayElement | |
4671 : public HTemplateInstruction<3>, public ArrayInstructionInterface { | |
4672 public: | |
4673 HStoreKeyedSpecializedArrayElement(HValue* external_elements, | |
4674 HValue* key, | |
4675 HValue* val, | |
4676 ElementsKind elements_kind) | |
4677 : elements_kind_(elements_kind), index_offset_(0), is_dehoisted_(false) { | |
4678 SetGVNFlag(kChangesSpecializedArrayElements); | |
4679 SetOperandAt(0, external_elements); | |
4680 SetOperandAt(1, key); | |
4681 SetOperandAt(2, val); | |
4682 } | |
4683 | |
4684 virtual void PrintDataTo(StringStream* stream); | |
4685 | |
4686 virtual Representation RequiredInputRepresentation(int index) { | |
4687 if (index == 0) { | |
4688 return Representation::External(); | |
4689 } else { | |
4690 bool float_or_double_elements = | |
4691 elements_kind() == EXTERNAL_FLOAT_ELEMENTS || | |
4692 elements_kind() == EXTERNAL_DOUBLE_ELEMENTS; | |
4693 if (index == 2 && float_or_double_elements) { | |
4694 return Representation::Double(); | |
4695 } else { | |
4696 return Representation::Integer32(); | |
4697 } | |
4698 } | |
4699 } | |
4700 | |
4701 HValue* external_pointer() { return OperandAt(0); } | |
4702 HValue* key() { return OperandAt(1); } | |
4703 HValue* value() { return OperandAt(2); } | |
4704 ElementsKind elements_kind() const { return elements_kind_; } | |
4705 uint32_t index_offset() { return index_offset_; } | |
4706 void SetIndexOffset(uint32_t index_offset) { index_offset_ = index_offset; } | |
4707 HValue* GetKey() { return key(); } | |
4708 void SetKey(HValue* key) { SetOperandAt(1, key); } | |
4709 bool IsDehoisted() { return is_dehoisted_; } | |
4710 void SetDehoisted(bool is_dehoisted) { is_dehoisted_ = is_dehoisted; } | |
4711 | |
4712 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedSpecializedArrayElement) | |
4713 | 4572 |
4714 private: | 4573 private: |
4715 ElementsKind elements_kind_; | 4574 ElementsKind elements_kind_; |
4716 uint32_t index_offset_; | 4575 uint32_t index_offset_; |
4717 bool is_dehoisted_; | 4576 bool is_dehoisted_; |
4718 }; | 4577 }; |
4719 | 4578 |
4720 | 4579 |
4721 class HStoreKeyedGeneric: public HTemplateInstruction<4> { | 4580 class HStoreKeyedGeneric: public HTemplateInstruction<4> { |
4722 public: | 4581 public: |
(...skipping 10 matching lines...) Expand all Loading... | |
4733 SetAllSideEffects(); | 4592 SetAllSideEffects(); |
4734 } | 4593 } |
4735 | 4594 |
4736 HValue* object() { return OperandAt(0); } | 4595 HValue* object() { return OperandAt(0); } |
4737 HValue* key() { return OperandAt(1); } | 4596 HValue* key() { return OperandAt(1); } |
4738 HValue* value() { return OperandAt(2); } | 4597 HValue* value() { return OperandAt(2); } |
4739 HValue* context() { return OperandAt(3); } | 4598 HValue* context() { return OperandAt(3); } |
4740 StrictModeFlag strict_mode_flag() { return strict_mode_flag_; } | 4599 StrictModeFlag strict_mode_flag() { return strict_mode_flag_; } |
4741 | 4600 |
4742 virtual Representation RequiredInputRepresentation(int index) { | 4601 virtual Representation RequiredInputRepresentation(int index) { |
4602 // <tagged>[<tagged>] = <tagged> | |
4743 return Representation::Tagged(); | 4603 return Representation::Tagged(); |
4744 } | 4604 } |
4745 | 4605 |
4746 virtual void PrintDataTo(StringStream* stream); | 4606 virtual void PrintDataTo(StringStream* stream); |
4747 | 4607 |
4748 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric) | 4608 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric) |
4749 | 4609 |
4750 private: | 4610 private: |
4751 StrictModeFlag strict_mode_flag_; | 4611 StrictModeFlag strict_mode_flag_; |
4752 }; | 4612 }; |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5412 virtual bool IsDeletable() const { return true; } | 5272 virtual bool IsDeletable() const { return true; } |
5413 }; | 5273 }; |
5414 | 5274 |
5415 | 5275 |
5416 #undef DECLARE_INSTRUCTION | 5276 #undef DECLARE_INSTRUCTION |
5417 #undef DECLARE_CONCRETE_INSTRUCTION | 5277 #undef DECLARE_CONCRETE_INSTRUCTION |
5418 | 5278 |
5419 } } // namespace v8::internal | 5279 } } // namespace v8::internal |
5420 | 5280 |
5421 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 5281 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |