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 6298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6309 : public HTemplateInstruction<3>, public ArrayInstructionInterface { | 6309 : public HTemplateInstruction<3>, public ArrayInstructionInterface { |
6310 public: | 6310 public: |
6311 DECLARE_INSTRUCTION_FACTORY_P4(HLoadKeyed, HValue*, HValue*, HValue*, | 6311 DECLARE_INSTRUCTION_FACTORY_P4(HLoadKeyed, HValue*, HValue*, HValue*, |
6312 ElementsKind); | 6312 ElementsKind); |
6313 DECLARE_INSTRUCTION_FACTORY_P5(HLoadKeyed, HValue*, HValue*, HValue*, | 6313 DECLARE_INSTRUCTION_FACTORY_P5(HLoadKeyed, HValue*, HValue*, HValue*, |
6314 ElementsKind, LoadKeyedHoleMode); | 6314 ElementsKind, LoadKeyedHoleMode); |
6315 | 6315 |
6316 bool is_external() const { | 6316 bool is_external() const { |
6317 return IsExternalArrayElementsKind(elements_kind()); | 6317 return IsExternalArrayElementsKind(elements_kind()); |
6318 } | 6318 } |
6319 bool is_fixed_typed_array() const { | |
6320 return IsFixedTypedArrayElementsKind(elements_kind()); | |
6321 } | |
6319 HValue* elements() { return OperandAt(0); } | 6322 HValue* elements() { return OperandAt(0); } |
6320 HValue* key() { return OperandAt(1); } | 6323 HValue* key() { return OperandAt(1); } |
6321 HValue* dependency() { | 6324 HValue* dependency() { |
6322 ASSERT(HasDependency()); | 6325 ASSERT(HasDependency()); |
6323 return OperandAt(2); | 6326 return OperandAt(2); |
6324 } | 6327 } |
6325 bool HasDependency() const { return OperandAt(0) != OperandAt(2); } | 6328 bool HasDependency() const { return OperandAt(0) != OperandAt(2); } |
6326 uint32_t index_offset() { return IndexOffsetField::decode(bit_field_); } | 6329 uint32_t index_offset() { return IndexOffsetField::decode(bit_field_); } |
6327 void SetIndexOffset(uint32_t index_offset) { | 6330 void SetIndexOffset(uint32_t index_offset) { |
6328 bit_field_ = IndexOffsetField::update(bit_field_, index_offset); | 6331 bit_field_ = IndexOffsetField::update(bit_field_, index_offset); |
6329 } | 6332 } |
6330 virtual int MaxIndexOffsetBits() { | 6333 virtual int MaxIndexOffsetBits() { |
6331 return kBitsForIndexOffset; | 6334 return kBitsForIndexOffset; |
6332 } | 6335 } |
6333 HValue* GetKey() { return key(); } | 6336 HValue* GetKey() { return key(); } |
6334 void SetKey(HValue* key) { SetOperandAt(1, key); } | 6337 void SetKey(HValue* key) { SetOperandAt(1, key); } |
6335 bool IsDehoisted() { return IsDehoistedField::decode(bit_field_); } | 6338 bool IsDehoisted() { return IsDehoistedField::decode(bit_field_); } |
6336 void SetDehoisted(bool is_dehoisted) { | 6339 void SetDehoisted(bool is_dehoisted) { |
6337 bit_field_ = IsDehoistedField::update(bit_field_, is_dehoisted); | 6340 bit_field_ = IsDehoistedField::update(bit_field_, is_dehoisted); |
6338 } | 6341 } |
6339 ElementsKind elements_kind() const { | 6342 ElementsKind elements_kind() const { |
6340 return ElementsKindField::decode(bit_field_); | 6343 return ElementsKindField::decode(bit_field_); |
6341 } | 6344 } |
6342 LoadKeyedHoleMode hole_mode() const { | 6345 LoadKeyedHoleMode hole_mode() const { |
6343 return HoleModeField::decode(bit_field_); | 6346 return HoleModeField::decode(bit_field_); |
6344 } | 6347 } |
6345 | 6348 |
6346 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { | 6349 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { |
6347 // kind_fast: tagged[int32] (none) | 6350 // kind_fast: tagged[int32] (none) |
6348 // kind_double: tagged[int32] (none) | 6351 // kind_double: tagged[int32] (none) |
6349 // kind_external: external[int32] (none) | 6352 // kind_fixed_typed_array: tagged[int32] (none) |
6353 // kind_external: external[int32] (none) | |
6350 if (index == 0) { | 6354 if (index == 0) { |
6351 return is_external() ? Representation::External() | 6355 return is_external() ? Representation::External() |
6352 : Representation::Tagged(); | 6356 : Representation::Tagged(); |
6353 } | 6357 } |
6354 if (index == 1) { | 6358 if (index == 1) { |
6355 return ArrayInstructionInterface::KeyedAccessIndexRequirement( | 6359 return ArrayInstructionInterface::KeyedAccessIndexRequirement( |
6356 OperandAt(1)->representation()); | 6360 OperandAt(1)->representation()); |
6357 } | 6361 } |
6358 return Representation::None(); | 6362 return Representation::None(); |
6359 } | 6363 } |
(...skipping 29 matching lines...) Expand all Loading... | |
6389 ElementsKind elements_kind, | 6393 ElementsKind elements_kind, |
6390 LoadKeyedHoleMode mode = NEVER_RETURN_HOLE) | 6394 LoadKeyedHoleMode mode = NEVER_RETURN_HOLE) |
6391 : bit_field_(0) { | 6395 : bit_field_(0) { |
6392 bit_field_ = ElementsKindField::encode(elements_kind) | | 6396 bit_field_ = ElementsKindField::encode(elements_kind) | |
6393 HoleModeField::encode(mode); | 6397 HoleModeField::encode(mode); |
6394 | 6398 |
6395 SetOperandAt(0, obj); | 6399 SetOperandAt(0, obj); |
6396 SetOperandAt(1, key); | 6400 SetOperandAt(1, key); |
6397 SetOperandAt(2, dependency != NULL ? dependency : obj); | 6401 SetOperandAt(2, dependency != NULL ? dependency : obj); |
6398 | 6402 |
6399 if (!is_external()) { | 6403 if (!is_external() && !is_fixed_typed_array()) { |
6400 // I can detect the case between storing double (holey and fast) and | 6404 // I can detect the case between storing double (holey and fast) and |
6401 // smi/object by looking at elements_kind_. | 6405 // smi/object by looking at elements_kind_. |
6402 ASSERT(IsFastSmiOrObjectElementsKind(elements_kind) || | 6406 ASSERT(IsFastSmiOrObjectElementsKind(elements_kind) || |
6403 IsFastDoubleElementsKind(elements_kind)); | 6407 IsFastDoubleElementsKind(elements_kind)); |
6404 | 6408 |
6405 if (IsFastSmiOrObjectElementsKind(elements_kind)) { | 6409 if (IsFastSmiOrObjectElementsKind(elements_kind)) { |
6406 if (IsFastSmiElementsKind(elements_kind) && | 6410 if (IsFastSmiElementsKind(elements_kind) && |
6407 (!IsHoleyElementsKind(elements_kind) || | 6411 (!IsHoleyElementsKind(elements_kind) || |
6408 mode == NEVER_RETURN_HOLE)) { | 6412 mode == NEVER_RETURN_HOLE)) { |
6409 set_type(HType::Smi()); | 6413 set_type(HType::Smi()); |
6410 if (SmiValuesAre32Bits() && !RequiresHoleCheck()) { | 6414 if (SmiValuesAre32Bits() && !RequiresHoleCheck()) { |
6411 set_representation(Representation::Integer32()); | 6415 set_representation(Representation::Integer32()); |
6412 } else { | 6416 } else { |
6413 set_representation(Representation::Smi()); | 6417 set_representation(Representation::Smi()); |
6414 } | 6418 } |
6415 } else { | 6419 } else { |
6416 set_representation(Representation::Tagged()); | 6420 set_representation(Representation::Tagged()); |
6417 } | 6421 } |
6418 | 6422 |
6419 SetGVNFlag(kDependsOnArrayElements); | 6423 SetGVNFlag(kDependsOnArrayElements); |
6420 } else { | 6424 } else { |
6421 set_representation(Representation::Double()); | 6425 set_representation(Representation::Double()); |
6422 SetGVNFlag(kDependsOnDoubleArrayElements); | 6426 SetGVNFlag(kDependsOnDoubleArrayElements); |
6423 } | 6427 } |
6424 } else { | 6428 } else { |
6425 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS || | 6429 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS || |
6426 elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { | 6430 elements_kind == EXTERNAL_DOUBLE_ELEMENTS || |
6431 elements_kind == FLOAT32_ELEMENTS || | |
6432 elements_kind == FLOAT64_ELEMENTS) { | |
6427 set_representation(Representation::Double()); | 6433 set_representation(Representation::Double()); |
6428 } else { | 6434 } else { |
6429 set_representation(Representation::Integer32()); | 6435 set_representation(Representation::Integer32()); |
6430 } | 6436 } |
6431 | 6437 |
6432 SetGVNFlag(kDependsOnExternalMemory); | 6438 if (is_external()) { |
6439 SetGVNFlag(kDependsOnExternalMemory); | |
6440 } else if (is_fixed_typed_array()) { | |
6441 SetGVNFlag(kDependsOnArrayElements); | |
Toon Verwaest
2013/12/23 10:40:32
Don't you want to make a separate DependsOnTypedAr
Dmitry Lomov (no reviews)
2014/01/07 15:48:43
Done. Good suggestion.
| |
6442 } else { | |
6443 UNREACHABLE(); | |
6444 } | |
6433 // Native code could change the specialized array. | 6445 // Native code could change the specialized array. |
6434 SetGVNFlag(kDependsOnCalls); | 6446 SetGVNFlag(kDependsOnCalls); |
6435 } | 6447 } |
6436 | 6448 |
6437 SetFlag(kUseGVN); | 6449 SetFlag(kUseGVN); |
6438 } | 6450 } |
6439 | 6451 |
6440 virtual bool IsDeletable() const V8_OVERRIDE { | 6452 virtual bool IsDeletable() const V8_OVERRIDE { |
6441 return !RequiresHoleCheck(); | 6453 return !RequiresHoleCheck(); |
6442 } | 6454 } |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6681 | 6693 |
6682 class HStoreKeyed V8_FINAL | 6694 class HStoreKeyed V8_FINAL |
6683 : public HTemplateInstruction<3>, public ArrayInstructionInterface { | 6695 : public HTemplateInstruction<3>, public ArrayInstructionInterface { |
6684 public: | 6696 public: |
6685 DECLARE_INSTRUCTION_FACTORY_P4(HStoreKeyed, HValue*, HValue*, HValue*, | 6697 DECLARE_INSTRUCTION_FACTORY_P4(HStoreKeyed, HValue*, HValue*, HValue*, |
6686 ElementsKind); | 6698 ElementsKind); |
6687 DECLARE_INSTRUCTION_FACTORY_P5(HStoreKeyed, HValue*, HValue*, HValue*, | 6699 DECLARE_INSTRUCTION_FACTORY_P5(HStoreKeyed, HValue*, HValue*, HValue*, |
6688 ElementsKind, StoreFieldOrKeyedMode); | 6700 ElementsKind, StoreFieldOrKeyedMode); |
6689 | 6701 |
6690 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { | 6702 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { |
6691 // kind_fast: tagged[int32] = tagged | 6703 // kind_fast: tagged[int32] = tagged |
6692 // kind_double: tagged[int32] = double | 6704 // kind_double: tagged[int32] = double |
6693 // kind_smi : tagged[int32] = smi | 6705 // kind_smi : tagged[int32] = smi |
6694 // kind_external: external[int32] = (double | int32) | 6706 // kind_fixed_typed_array: tagged[int32] = (double | int32) |
6707 // kind_external: external[int32] = (double | int32) | |
6695 if (index == 0) { | 6708 if (index == 0) { |
6696 return is_external() ? Representation::External() | 6709 return is_external() ? Representation::External() |
6697 : Representation::Tagged(); | 6710 : Representation::Tagged(); |
6698 } else if (index == 1) { | 6711 } else if (index == 1) { |
6699 return ArrayInstructionInterface::KeyedAccessIndexRequirement( | 6712 return ArrayInstructionInterface::KeyedAccessIndexRequirement( |
6700 OperandAt(1)->representation()); | 6713 OperandAt(1)->representation()); |
6701 } | 6714 } |
6702 | 6715 |
6703 ASSERT_EQ(index, 2); | 6716 ASSERT_EQ(index, 2); |
6704 if (IsDoubleOrFloatElementsKind(elements_kind())) { | 6717 if (IsDoubleOrFloatElementsKind(elements_kind())) { |
6705 return Representation::Double(); | 6718 return Representation::Double(); |
6706 } | 6719 } |
6707 if (SmiValuesAre32Bits() && store_mode_ == STORE_TO_INITIALIZED_ENTRY) { | 6720 if (SmiValuesAre32Bits() && store_mode_ == STORE_TO_INITIALIZED_ENTRY) { |
6708 return Representation::Integer32(); | 6721 return Representation::Integer32(); |
6709 } | 6722 } |
6710 if (IsFastSmiElementsKind(elements_kind())) { | 6723 if (IsFastSmiElementsKind(elements_kind())) { |
6711 return Representation::Smi(); | 6724 return Representation::Smi(); |
6712 } | 6725 } |
6713 | 6726 |
6714 return is_external() ? Representation::Integer32() | 6727 return is_external() || is_fixed_typed_array() |
6728 ? Representation::Integer32() | |
Toon Verwaest
2013/12/23 10:40:32
4-space indent if you put the ? on a new line.
Dmitry Lomov (no reviews)
2014/01/07 15:48:43
Done.
| |
6715 : Representation::Tagged(); | 6729 : Representation::Tagged(); |
6716 } | 6730 } |
6717 | 6731 |
6718 bool is_external() const { | 6732 bool is_external() const { |
6719 return IsExternalArrayElementsKind(elements_kind()); | 6733 return IsExternalArrayElementsKind(elements_kind()); |
6720 } | 6734 } |
6721 | 6735 |
6736 bool is_fixed_typed_array() const { | |
6737 return IsFixedTypedArrayElementsKind(elements_kind()); | |
6738 } | |
6739 | |
6722 virtual Representation observed_input_representation(int index) V8_OVERRIDE { | 6740 virtual Representation observed_input_representation(int index) V8_OVERRIDE { |
6723 if (index < 2) return RequiredInputRepresentation(index); | 6741 if (index < 2) return RequiredInputRepresentation(index); |
6724 if (IsUninitialized()) { | 6742 if (IsUninitialized()) { |
6725 return Representation::None(); | 6743 return Representation::None(); |
6726 } | 6744 } |
6727 if (IsDoubleOrFloatElementsKind(elements_kind())) { | 6745 if (IsDoubleOrFloatElementsKind(elements_kind())) { |
6728 return Representation::Double(); | 6746 return Representation::Double(); |
6729 } | 6747 } |
6730 if (SmiValuesAre32Bits() && store_mode_ == STORE_TO_INITIALIZED_ENTRY) { | 6748 if (SmiValuesAre32Bits() && store_mode_ == STORE_TO_INITIALIZED_ENTRY) { |
6731 return Representation::Integer32(); | 6749 return Representation::Integer32(); |
6732 } | 6750 } |
6733 if (IsFastSmiElementsKind(elements_kind())) { | 6751 if (IsFastSmiElementsKind(elements_kind())) { |
6734 return Representation::Smi(); | 6752 return Representation::Smi(); |
6735 } | 6753 } |
6736 if (is_external()) { | 6754 if (is_external() || is_fixed_typed_array()) { |
6737 return Representation::Integer32(); | 6755 return Representation::Integer32(); |
6738 } | 6756 } |
6739 // For fast object elements kinds, don't assume anything. | 6757 // For fast object elements kinds, don't assume anything. |
6740 return Representation::None(); | 6758 return Representation::None(); |
6741 } | 6759 } |
6742 | 6760 |
6743 HValue* elements() { return OperandAt(0); } | 6761 HValue* elements() { return OperandAt(0); } |
6744 HValue* key() { return OperandAt(1); } | 6762 HValue* key() { return OperandAt(1); } |
6745 HValue* value() { return OperandAt(2); } | 6763 HValue* value() { return OperandAt(2); } |
6746 bool value_is_smi() const { | 6764 bool value_is_smi() const { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6811 SetFlag(kTrackSideEffectDominators); | 6829 SetFlag(kTrackSideEffectDominators); |
6812 SetGVNFlag(kDependsOnNewSpacePromotion); | 6830 SetGVNFlag(kDependsOnNewSpacePromotion); |
6813 } | 6831 } |
6814 if (is_external()) { | 6832 if (is_external()) { |
6815 SetGVNFlag(kChangesExternalMemory); | 6833 SetGVNFlag(kChangesExternalMemory); |
6816 SetFlag(kAllowUndefinedAsNaN); | 6834 SetFlag(kAllowUndefinedAsNaN); |
6817 } else if (IsFastDoubleElementsKind(elements_kind)) { | 6835 } else if (IsFastDoubleElementsKind(elements_kind)) { |
6818 SetGVNFlag(kChangesDoubleArrayElements); | 6836 SetGVNFlag(kChangesDoubleArrayElements); |
6819 } else if (IsFastSmiElementsKind(elements_kind)) { | 6837 } else if (IsFastSmiElementsKind(elements_kind)) { |
6820 SetGVNFlag(kChangesArrayElements); | 6838 SetGVNFlag(kChangesArrayElements); |
6839 } else if (is_fixed_typed_array()) { | |
6840 SetGVNFlag(kChangesArrayElements); | |
6841 SetFlag(kAllowUndefinedAsNaN); | |
6821 } else { | 6842 } else { |
6822 SetGVNFlag(kChangesArrayElements); | 6843 SetGVNFlag(kChangesArrayElements); |
6823 } | 6844 } |
6824 | 6845 |
6825 // EXTERNAL_{UNSIGNED_,}{BYTE,SHORT,INT}_ELEMENTS are truncating. | 6846 // EXTERNAL_{UNSIGNED_,}{BYTE,SHORT,INT}_ELEMENTS are truncating. |
6826 if (elements_kind >= EXTERNAL_BYTE_ELEMENTS && | 6847 if ((elements_kind >= EXTERNAL_BYTE_ELEMENTS && |
6827 elements_kind <= EXTERNAL_UNSIGNED_INT_ELEMENTS) { | 6848 elements_kind <= EXTERNAL_UNSIGNED_INT_ELEMENTS) || |
6849 (elements_kind >= UINT8_ELEMENTS && | |
6850 elements_kind <= INT32_ELEMENTS)) { | |
6828 SetFlag(kTruncatingToInt32); | 6851 SetFlag(kTruncatingToInt32); |
6829 } | 6852 } |
6830 } | 6853 } |
6831 | 6854 |
6832 ElementsKind elements_kind_; | 6855 ElementsKind elements_kind_; |
6833 uint32_t index_offset_; | 6856 uint32_t index_offset_; |
6834 bool is_dehoisted_ : 1; | 6857 bool is_dehoisted_ : 1; |
6835 bool is_uninitialized_ : 1; | 6858 bool is_uninitialized_ : 1; |
6836 StoreFieldOrKeyedMode store_mode_: 1; | 6859 StoreFieldOrKeyedMode store_mode_: 1; |
6837 HValue* new_space_dominator_; | 6860 HValue* new_space_dominator_; |
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7516 virtual bool IsDeletable() const V8_OVERRIDE { return true; } | 7539 virtual bool IsDeletable() const V8_OVERRIDE { return true; } |
7517 }; | 7540 }; |
7518 | 7541 |
7519 | 7542 |
7520 #undef DECLARE_INSTRUCTION | 7543 #undef DECLARE_INSTRUCTION |
7521 #undef DECLARE_CONCRETE_INSTRUCTION | 7544 #undef DECLARE_CONCRETE_INSTRUCTION |
7522 | 7545 |
7523 } } // namespace v8::internal | 7546 } } // namespace v8::internal |
7524 | 7547 |
7525 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 7548 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |