Chromium Code Reviews| 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 2203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2214 return check_map; | 2214 return check_map; |
| 2215 } | 2215 } |
| 2216 | 2216 |
| 2217 virtual Representation RequiredInputRepresentation(int index) { | 2217 virtual Representation RequiredInputRepresentation(int index) { |
| 2218 return Representation::Tagged(); | 2218 return Representation::Tagged(); |
| 2219 } | 2219 } |
| 2220 virtual void PrintDataTo(StringStream* stream); | 2220 virtual void PrintDataTo(StringStream* stream); |
| 2221 virtual HType CalculateInferredType(); | 2221 virtual HType CalculateInferredType(); |
| 2222 | 2222 |
| 2223 HValue* value() { return OperandAt(0); } | 2223 HValue* value() { return OperandAt(0); } |
| 2224 bool has_typecheck() const { return OperandAt(0) != OperandAt(1); } | |
|
danno
2012/11/14 15:28:18
HasTypeCheck()
mvstanton
2012/11/16 15:15:06
Done.
| |
| 2224 SmallMapList* map_set() { return &map_set_; } | 2225 SmallMapList* map_set() { return &map_set_; } |
| 2225 | 2226 |
| 2226 DECLARE_CONCRETE_INSTRUCTION(CheckMaps) | 2227 DECLARE_CONCRETE_INSTRUCTION(CheckMaps) |
| 2227 | 2228 |
| 2228 protected: | 2229 protected: |
| 2229 virtual bool DataEquals(HValue* other) { | 2230 virtual bool DataEquals(HValue* other) { |
| 2230 HCheckMaps* b = HCheckMaps::cast(other); | 2231 HCheckMaps* b = HCheckMaps::cast(other); |
| 2231 // Relies on the fact that map_set has been sorted before. | 2232 // Relies on the fact that map_set has been sorted before. |
| 2232 if (map_set()->length() != b->map_set()->length()) return false; | 2233 if (map_set()->length() != b->map_set()->length()) return false; |
| 2233 for (int i = 0; i < map_set()->length(); i++) { | 2234 for (int i = 0; i < map_set()->length(); i++) { |
| (...skipping 2021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4255 virtual ~ArrayInstructionInterface() { }; | 4256 virtual ~ArrayInstructionInterface() { }; |
| 4256 }; | 4257 }; |
| 4257 | 4258 |
| 4258 | 4259 |
| 4259 class HLoadKeyed | 4260 class HLoadKeyed |
| 4260 : public HTemplateInstruction<3>, public ArrayInstructionInterface { | 4261 : public HTemplateInstruction<3>, public ArrayInstructionInterface { |
| 4261 public: | 4262 public: |
| 4262 HLoadKeyed(HValue* obj, | 4263 HLoadKeyed(HValue* obj, |
| 4263 HValue* key, | 4264 HValue* key, |
| 4264 HValue* dependency, | 4265 HValue* dependency, |
| 4265 ElementsKind elements_kind) | 4266 ElementsKind elements_kind, |
| 4267 bool defer_initialization=false) | |
|
danno
2012/11/14 15:28:18
nit: separate all operators from variable names an
mvstanton
2012/11/16 15:15:06
Done.
| |
| 4266 : bit_field_(0) { | 4268 : bit_field_(0) { |
| 4267 bit_field_ = ElementsKindField::encode(elements_kind); | 4269 bit_field_ = ElementsKindField::encode(elements_kind); |
| 4268 | 4270 |
| 4271 #ifdef DEBUG | |
| 4272 initialized_ = !defer_initialization; | |
| 4273 #endif | |
| 4274 | |
| 4269 SetOperandAt(0, obj); | 4275 SetOperandAt(0, obj); |
| 4270 SetOperandAt(1, key); | 4276 SetOperandAt(1, key); |
| 4271 SetOperandAt(2, dependency); | 4277 SetOperandAt(2, dependency); |
| 4272 | 4278 |
| 4273 if (!is_external()) { | 4279 if (!defer_initialization) { |
| 4274 // I can detect the case between storing double (holey and fast) and | 4280 InitializeFields(); |
| 4275 // smi/object by looking at elements_kind_. | 4281 } |
| 4276 ASSERT(IsFastSmiOrObjectElementsKind(elements_kind) || | 4282 |
| 4277 IsFastDoubleElementsKind(elements_kind)); | 4283 SetFlag(kUseGVN); |
| 4284 } | |
| 4278 | 4285 |
| 4279 if (IsFastSmiOrObjectElementsKind(elements_kind)) { | 4286 #ifdef DEBUG |
| 4280 if (IsFastSmiElementsKind(elements_kind) && | 4287 bool Initialized() const { return initialized_; } |
| 4281 IsFastPackedElementsKind(elements_kind)) { | 4288 #endif |
| 4282 set_type(HType::Smi()); | 4289 |
| 4283 } | 4290 void PerformDeferredInitialization(ElementsKind new_elements_kind) { |
| 4284 | 4291 #ifdef DEBUG |
| 4285 set_representation(Representation::Tagged()); | 4292 ASSERT(!initialized_); |
| 4286 SetGVNFlag(kDependsOnArrayElements); | 4293 initialized_ = true; |
| 4287 } else { | 4294 #endif |
| 4288 set_representation(Representation::Double()); | 4295 if (new_elements_kind != elements_kind()) { |
| 4289 SetGVNFlag(kDependsOnDoubleArrayElements); | 4296 bit_field_ = ElementsKindField::encode(new_elements_kind); |
| 4290 } | |
| 4291 } else { | |
| 4292 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS || | |
| 4293 elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { | |
| 4294 set_representation(Representation::Double()); | |
| 4295 } else { | |
| 4296 set_representation(Representation::Integer32()); | |
| 4297 } | |
| 4298 | |
| 4299 SetGVNFlag(kDependsOnSpecializedArrayElements); | |
| 4300 // Native code could change the specialized array. | |
| 4301 SetGVNFlag(kDependsOnCalls); | |
| 4302 } | 4297 } |
| 4303 | 4298 |
| 4304 SetFlag(kUseGVN); | 4299 InitializeFields(); |
| 4305 } | 4300 } |
| 4306 | 4301 |
| 4307 bool is_external() const { | 4302 bool is_external() const { |
| 4308 return IsExternalArrayElementsKind(elements_kind()); | 4303 return IsExternalArrayElementsKind(elements_kind()); |
| 4309 } | 4304 } |
| 4310 HValue* elements() { return OperandAt(0); } | 4305 HValue* elements() { return OperandAt(0); } |
| 4311 HValue* key() { return OperandAt(1); } | 4306 HValue* key() { return OperandAt(1); } |
| 4312 HValue* dependency() { return OperandAt(2); } | 4307 HValue* dependency() { return OperandAt(2); } |
| 4313 uint32_t index_offset() { return IndexOffsetField::decode(bit_field_); } | 4308 uint32_t index_offset() { return IndexOffsetField::decode(bit_field_); } |
| 4314 void SetIndexOffset(uint32_t index_offset) { | 4309 void SetIndexOffset(uint32_t index_offset) { |
| 4315 bit_field_ = IndexOffsetField::update(bit_field_, index_offset); | 4310 bit_field_ = IndexOffsetField::update(bit_field_, index_offset); |
| 4316 } | 4311 } |
| 4317 HValue* GetKey() { return key(); } | 4312 HValue* GetKey() { return key(); } |
| 4318 void SetKey(HValue* key) { SetOperandAt(1, key); } | 4313 void SetKey(HValue* key) { SetOperandAt(1, key); } |
| 4319 bool IsDehoisted() { return IsDehoistedField::decode(bit_field_); } | 4314 bool IsDehoisted() { return IsDehoistedField::decode(bit_field_); } |
| 4320 void SetDehoisted(bool is_dehoisted) { | 4315 void SetDehoisted(bool is_dehoisted) { |
| 4321 bit_field_ = IsDehoistedField::update(bit_field_, is_dehoisted); | 4316 bit_field_ = IsDehoistedField::update(bit_field_, is_dehoisted); |
| 4322 } | 4317 } |
| 4323 ElementsKind elements_kind() const { | 4318 ElementsKind elements_kind() const { |
| 4324 return ElementsKindField::decode(bit_field_); | 4319 return ElementsKindField::decode(bit_field_); |
| 4325 } | 4320 } |
| 4326 | 4321 |
| 4327 virtual Representation RequiredInputRepresentation(int index) { | 4322 virtual Representation RequiredInputRepresentation(int index) { |
| 4323 #ifdef DEBUG | |
| 4324 ASSERT(initialized_); | |
| 4325 #endif | |
| 4328 // kind_fast: tagged[int32] (none) | 4326 // kind_fast: tagged[int32] (none) |
| 4329 // kind_double: tagged[int32] (none) | 4327 // kind_double: tagged[int32] (none) |
| 4330 // kind_external: external[int32] (none) | 4328 // kind_external: external[int32] (none) |
| 4331 if (index == 0) { | 4329 if (index == 0) { |
| 4332 return is_external() ? Representation::External() | 4330 return is_external() ? Representation::External() |
| 4333 : Representation::Tagged(); | 4331 : Representation::Tagged(); |
| 4334 } | 4332 } |
| 4335 if (index == 1) return Representation::Integer32(); | 4333 if (index == 1) return Representation::Integer32(); |
| 4336 return Representation::None(); | 4334 return Representation::None(); |
| 4337 } | 4335 } |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 4348 virtual bool DataEquals(HValue* other) { | 4346 virtual bool DataEquals(HValue* other) { |
| 4349 if (!other->IsLoadKeyed()) return false; | 4347 if (!other->IsLoadKeyed()) return false; |
| 4350 HLoadKeyed* other_load = HLoadKeyed::cast(other); | 4348 HLoadKeyed* other_load = HLoadKeyed::cast(other); |
| 4351 | 4349 |
| 4352 if (IsDehoisted() && index_offset() != other_load->index_offset()) | 4350 if (IsDehoisted() && index_offset() != other_load->index_offset()) |
| 4353 return false; | 4351 return false; |
| 4354 return elements_kind() == other_load->elements_kind(); | 4352 return elements_kind() == other_load->elements_kind(); |
| 4355 } | 4353 } |
| 4356 | 4354 |
| 4357 private: | 4355 private: |
| 4356 void InitializeFields() { | |
|
danno
2012/11/14 15:28:18
Move implementation this to the .cc file.
And oh
mvstanton
2012/11/16 15:15:06
Done.
| |
| 4357 if (!is_external()) { | |
| 4358 // I can detect the case between storing double (holey and fast) and | |
| 4359 // smi/object by looking at elements_kind_. | |
| 4360 ASSERT(IsFastSmiOrObjectElementsKind(elements_kind()) || | |
| 4361 IsFastDoubleElementsKind(elements_kind())); | |
| 4362 | |
| 4363 if (IsFastSmiOrObjectElementsKind(elements_kind())) { | |
| 4364 if (IsFastSmiElementsKind(elements_kind()) && | |
| 4365 IsFastPackedElementsKind(elements_kind())) { | |
| 4366 set_type(HType::Smi()); | |
| 4367 } | |
| 4368 | |
| 4369 set_representation(Representation::Tagged()); | |
| 4370 SetGVNFlag(kDependsOnArrayElements); | |
| 4371 } else { | |
| 4372 set_representation(Representation::Double()); | |
| 4373 SetGVNFlag(kDependsOnDoubleArrayElements); | |
| 4374 } | |
| 4375 } else { | |
| 4376 if (elements_kind() == EXTERNAL_FLOAT_ELEMENTS || | |
| 4377 elements_kind() == EXTERNAL_DOUBLE_ELEMENTS) { | |
| 4378 set_representation(Representation::Double()); | |
| 4379 } else { | |
| 4380 set_representation(Representation::Integer32()); | |
| 4381 } | |
| 4382 | |
| 4383 SetGVNFlag(kDependsOnSpecializedArrayElements); | |
| 4384 // Native code could change the specialized array. | |
| 4385 SetGVNFlag(kDependsOnCalls); | |
| 4386 } | |
| 4387 } | |
| 4388 | |
| 4358 virtual bool IsDeletable() const { | 4389 virtual bool IsDeletable() const { |
| 4359 return !RequiresHoleCheck(); | 4390 return !RequiresHoleCheck(); |
| 4360 } | 4391 } |
| 4361 | 4392 |
| 4362 // Establish some checks around our packed fields | 4393 // Establish some checks around our packed fields |
| 4363 enum LoadKeyedBits { | 4394 enum LoadKeyedBits { |
| 4364 kBitsForElementsKind = 5, | 4395 kBitsForElementsKind = 5, |
| 4365 kBitsForIndexOffset = 26, | 4396 kBitsForIndexOffset = 26, |
| 4366 kBitsForIsDehoisted = 1, | 4397 kBitsForIsDehoisted = 1, |
| 4367 | 4398 |
| 4368 kStartElementsKind = 0, | 4399 kStartElementsKind = 0, |
| 4369 kStartIndexOffset = kStartElementsKind + kBitsForElementsKind, | 4400 kStartIndexOffset = kStartElementsKind + kBitsForElementsKind, |
| 4370 kStartIsDehoisted = kStartIndexOffset + kBitsForIndexOffset | 4401 kStartIsDehoisted = kStartIndexOffset + kBitsForIndexOffset |
| 4371 }; | 4402 }; |
| 4372 | 4403 |
| 4373 STATIC_ASSERT((kBitsForElementsKind + kBitsForIndexOffset + | 4404 STATIC_ASSERT((kBitsForElementsKind + kBitsForIndexOffset + |
| 4374 kBitsForIsDehoisted) <= sizeof(uint32_t)*8); | 4405 kBitsForIsDehoisted) <= sizeof(uint32_t)*8); |
| 4375 STATIC_ASSERT(kElementsKindCount <= (1 << kBitsForElementsKind)); | 4406 STATIC_ASSERT(kElementsKindCount <= (1 << kBitsForElementsKind)); |
| 4376 class ElementsKindField: | 4407 class ElementsKindField: |
| 4377 public BitField<ElementsKind, kStartElementsKind, kBitsForElementsKind> | 4408 public BitField<ElementsKind, kStartElementsKind, kBitsForElementsKind> |
| 4378 {}; // NOLINT | 4409 {}; // NOLINT |
| 4379 class IndexOffsetField: | 4410 class IndexOffsetField: |
| 4380 public BitField<uint32_t, kStartIndexOffset, kBitsForIndexOffset> | 4411 public BitField<uint32_t, kStartIndexOffset, kBitsForIndexOffset> |
| 4381 {}; // NOLINT | 4412 {}; // NOLINT |
| 4382 class IsDehoistedField: | 4413 class IsDehoistedField: |
| 4383 public BitField<bool, kStartIsDehoisted, kBitsForIsDehoisted> | 4414 public BitField<bool, kStartIsDehoisted, kBitsForIsDehoisted> |
| 4384 {}; // NOLINT | 4415 {}; // NOLINT |
| 4385 uint32_t bit_field_; | 4416 uint32_t bit_field_; |
| 4417 #ifdef DEBUG | |
| 4418 bool initialized_; | |
| 4419 #endif | |
| 4386 }; | 4420 }; |
| 4387 | 4421 |
| 4388 | 4422 |
| 4389 class HLoadKeyedGeneric: public HTemplateInstruction<3> { | 4423 class HLoadKeyedGeneric: public HTemplateInstruction<3> { |
| 4390 public: | 4424 public: |
| 4391 HLoadKeyedGeneric(HValue* context, HValue* obj, HValue* key) { | 4425 HLoadKeyedGeneric(HValue* context, HValue* obj, HValue* key) { |
| 4392 set_representation(Representation::Tagged()); | 4426 set_representation(Representation::Tagged()); |
| 4393 SetOperandAt(0, obj); | 4427 SetOperandAt(0, obj); |
| 4394 SetOperandAt(1, key); | 4428 SetOperandAt(1, key); |
| 4395 SetOperandAt(2, context); | 4429 SetOperandAt(2, context); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4506 private: | 4540 private: |
| 4507 Handle<String> name_; | 4541 Handle<String> name_; |
| 4508 StrictModeFlag strict_mode_flag_; | 4542 StrictModeFlag strict_mode_flag_; |
| 4509 }; | 4543 }; |
| 4510 | 4544 |
| 4511 | 4545 |
| 4512 class HStoreKeyed | 4546 class HStoreKeyed |
| 4513 : public HTemplateInstruction<3>, public ArrayInstructionInterface { | 4547 : public HTemplateInstruction<3>, public ArrayInstructionInterface { |
| 4514 public: | 4548 public: |
| 4515 HStoreKeyed(HValue* obj, HValue* key, HValue* val, | 4549 HStoreKeyed(HValue* obj, HValue* key, HValue* val, |
| 4516 ElementsKind elements_kind) | 4550 ElementsKind elements_kind, |
| 4551 bool defer_initialization=false) | |
|
danno
2012/11/14 15:28:18
spaces b/a =
mvstanton
2012/11/16 15:15:06
Done.
| |
| 4517 : elements_kind_(elements_kind), index_offset_(0), is_dehoisted_(false) { | 4552 : elements_kind_(elements_kind), index_offset_(0), is_dehoisted_(false) { |
| 4518 SetOperandAt(0, obj); | 4553 SetOperandAt(0, obj); |
| 4519 SetOperandAt(1, key); | 4554 SetOperandAt(1, key); |
| 4520 SetOperandAt(2, val); | 4555 SetOperandAt(2, val); |
| 4521 | 4556 |
| 4522 if (is_external()) { | 4557 #ifdef DEBUG |
| 4523 SetGVNFlag(kChangesSpecializedArrayElements); | 4558 initialized_ = !defer_initialization; |
| 4524 } else if (IsFastDoubleElementsKind(elements_kind)) { | 4559 #endif |
| 4525 SetGVNFlag(kChangesDoubleArrayElements); | 4560 |
| 4526 SetFlag(kDeoptimizeOnUndefined); | 4561 InitializeFlags(); |
| 4527 } else { | |
| 4528 SetGVNFlag(kChangesArrayElements); | |
| 4529 } | |
| 4530 } | 4562 } |
| 4531 | 4563 |
| 4564 #ifdef DEBUG | |
| 4565 bool Initialized() const { return initialized_; } | |
| 4566 #endif | |
| 4567 | |
| 4568 void PerformDeferredInitialization(ElementsKind new_elements_kind) { | |
| 4569 #ifdef DEBUG | |
| 4570 ASSERT(!initialized_); | |
| 4571 initialized_ = true; | |
| 4572 #endif | |
| 4573 if (new_elements_kind != elements_kind_) { | |
| 4574 elements_kind_ = new_elements_kind; | |
| 4575 } | |
| 4576 | |
| 4577 InitializeFlags(); | |
| 4578 } | |
| 4579 | |
| 4532 virtual Representation RequiredInputRepresentation(int index) { | 4580 virtual Representation RequiredInputRepresentation(int index) { |
| 4581 #ifdef DEBUG | |
| 4582 ASSERT(initialized_); | |
| 4583 #endif | |
| 4533 // kind_fast: tagged[int32] = tagged | 4584 // kind_fast: tagged[int32] = tagged |
| 4534 // kind_double: tagged[int32] = double | 4585 // kind_double: tagged[int32] = double |
| 4535 // kind_external: external[int32] = (double | int32) | 4586 // kind_external: external[int32] = (double | int32) |
| 4536 if (index == 0) { | 4587 if (index == 0) { |
| 4537 return is_external() ? Representation::External() | 4588 return is_external() ? Representation::External() |
| 4538 : Representation::Tagged(); | 4589 : Representation::Tagged(); |
| 4539 } else if (index == 1) { | 4590 } else if (index == 1) { |
| 4540 return Representation::Integer32(); | 4591 return Representation::Integer32(); |
| 4541 } | 4592 } |
| 4542 | 4593 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4574 } | 4625 } |
| 4575 } | 4626 } |
| 4576 | 4627 |
| 4577 bool NeedsCanonicalization(); | 4628 bool NeedsCanonicalization(); |
| 4578 | 4629 |
| 4579 virtual void PrintDataTo(StringStream* stream); | 4630 virtual void PrintDataTo(StringStream* stream); |
| 4580 | 4631 |
| 4581 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed) | 4632 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed) |
| 4582 | 4633 |
| 4583 private: | 4634 private: |
| 4635 void InitializeFlags() { | |
|
danno
2012/11/14 15:28:18
Again, how about just "Initialize"?
mvstanton
2012/11/16 15:15:06
Done.
| |
| 4636 if (is_external()) { | |
| 4637 SetGVNFlag(kChangesSpecializedArrayElements); | |
| 4638 } else if (IsFastDoubleElementsKind(elements_kind())) { | |
| 4639 SetGVNFlag(kChangesDoubleArrayElements); | |
| 4640 SetFlag(kDeoptimizeOnUndefined); | |
| 4641 } else { | |
| 4642 SetGVNFlag(kChangesArrayElements); | |
| 4643 } | |
| 4644 } | |
| 4584 ElementsKind elements_kind_; | 4645 ElementsKind elements_kind_; |
| 4585 uint32_t index_offset_; | 4646 uint32_t index_offset_; |
| 4586 bool is_dehoisted_; | 4647 bool is_dehoisted_; |
| 4648 #ifdef DEBUG | |
| 4649 bool initialized_; | |
| 4650 #endif | |
| 4587 }; | 4651 }; |
| 4588 | 4652 |
| 4589 | 4653 |
| 4590 class HStoreKeyedGeneric: public HTemplateInstruction<4> { | 4654 class HStoreKeyedGeneric: public HTemplateInstruction<4> { |
| 4591 public: | 4655 public: |
| 4592 HStoreKeyedGeneric(HValue* context, | 4656 HStoreKeyedGeneric(HValue* context, |
| 4593 HValue* object, | 4657 HValue* object, |
| 4594 HValue* key, | 4658 HValue* key, |
| 4595 HValue* value, | 4659 HValue* value, |
| 4596 StrictModeFlag strict_mode_flag) | 4660 StrictModeFlag strict_mode_flag) |
| (...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5282 virtual bool IsDeletable() const { return true; } | 5346 virtual bool IsDeletable() const { return true; } |
| 5283 }; | 5347 }; |
| 5284 | 5348 |
| 5285 | 5349 |
| 5286 #undef DECLARE_INSTRUCTION | 5350 #undef DECLARE_INSTRUCTION |
| 5287 #undef DECLARE_CONCRETE_INSTRUCTION | 5351 #undef DECLARE_CONCRETE_INSTRUCTION |
| 5288 | 5352 |
| 5289 } } // namespace v8::internal | 5353 } } // namespace v8::internal |
| 5290 | 5354 |
| 5291 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 5355 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
| OLD | NEW |