| 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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 V(Calls) \ | 203 V(Calls) \ |
| 204 V(ContextSlots) \ | 204 V(ContextSlots) \ |
| 205 V(DoubleArrayElements) \ | 205 V(DoubleArrayElements) \ |
| 206 V(DoubleFields) \ | 206 V(DoubleFields) \ |
| 207 V(ElementsKind) \ | 207 V(ElementsKind) \ |
| 208 V(ElementsPointer) \ | 208 V(ElementsPointer) \ |
| 209 V(GlobalVars) \ | 209 V(GlobalVars) \ |
| 210 V(InobjectFields) \ | 210 V(InobjectFields) \ |
| 211 V(OsrEntries) \ | 211 V(OsrEntries) \ |
| 212 V(ExternalMemory) \ | 212 V(ExternalMemory) \ |
| 213 V(StringChars) | 213 V(StringChars) \ |
| 214 V(TypedArrayElements) |
| 214 | 215 |
| 215 | 216 |
| 216 #define DECLARE_ABSTRACT_INSTRUCTION(type) \ | 217 #define DECLARE_ABSTRACT_INSTRUCTION(type) \ |
| 217 virtual bool Is##type() const V8_FINAL V8_OVERRIDE { return true; } \ | 218 virtual bool Is##type() const V8_FINAL V8_OVERRIDE { return true; } \ |
| 218 static H##type* cast(HValue* value) { \ | 219 static H##type* cast(HValue* value) { \ |
| 219 ASSERT(value->Is##type()); \ | 220 ASSERT(value->Is##type()); \ |
| 220 return reinterpret_cast<H##type*>(value); \ | 221 return reinterpret_cast<H##type*>(value); \ |
| 221 } | 222 } |
| 222 | 223 |
| 223 | 224 |
| (...skipping 6144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6368 : public HTemplateInstruction<3>, public ArrayInstructionInterface { | 6369 : public HTemplateInstruction<3>, public ArrayInstructionInterface { |
| 6369 public: | 6370 public: |
| 6370 DECLARE_INSTRUCTION_FACTORY_P4(HLoadKeyed, HValue*, HValue*, HValue*, | 6371 DECLARE_INSTRUCTION_FACTORY_P4(HLoadKeyed, HValue*, HValue*, HValue*, |
| 6371 ElementsKind); | 6372 ElementsKind); |
| 6372 DECLARE_INSTRUCTION_FACTORY_P5(HLoadKeyed, HValue*, HValue*, HValue*, | 6373 DECLARE_INSTRUCTION_FACTORY_P5(HLoadKeyed, HValue*, HValue*, HValue*, |
| 6373 ElementsKind, LoadKeyedHoleMode); | 6374 ElementsKind, LoadKeyedHoleMode); |
| 6374 | 6375 |
| 6375 bool is_external() const { | 6376 bool is_external() const { |
| 6376 return IsExternalArrayElementsKind(elements_kind()); | 6377 return IsExternalArrayElementsKind(elements_kind()); |
| 6377 } | 6378 } |
| 6379 bool is_fixed_typed_array() const { |
| 6380 return IsFixedTypedArrayElementsKind(elements_kind()); |
| 6381 } |
| 6378 HValue* elements() { return OperandAt(0); } | 6382 HValue* elements() { return OperandAt(0); } |
| 6379 HValue* key() { return OperandAt(1); } | 6383 HValue* key() { return OperandAt(1); } |
| 6380 HValue* dependency() { | 6384 HValue* dependency() { |
| 6381 ASSERT(HasDependency()); | 6385 ASSERT(HasDependency()); |
| 6382 return OperandAt(2); | 6386 return OperandAt(2); |
| 6383 } | 6387 } |
| 6384 bool HasDependency() const { return OperandAt(0) != OperandAt(2); } | 6388 bool HasDependency() const { return OperandAt(0) != OperandAt(2); } |
| 6385 uint32_t index_offset() { return IndexOffsetField::decode(bit_field_); } | 6389 uint32_t index_offset() { return IndexOffsetField::decode(bit_field_); } |
| 6386 void SetIndexOffset(uint32_t index_offset) { | 6390 void SetIndexOffset(uint32_t index_offset) { |
| 6387 bit_field_ = IndexOffsetField::update(bit_field_, index_offset); | 6391 bit_field_ = IndexOffsetField::update(bit_field_, index_offset); |
| 6388 } | 6392 } |
| 6389 virtual int MaxIndexOffsetBits() { | 6393 virtual int MaxIndexOffsetBits() { |
| 6390 return kBitsForIndexOffset; | 6394 return kBitsForIndexOffset; |
| 6391 } | 6395 } |
| 6392 HValue* GetKey() { return key(); } | 6396 HValue* GetKey() { return key(); } |
| 6393 void SetKey(HValue* key) { SetOperandAt(1, key); } | 6397 void SetKey(HValue* key) { SetOperandAt(1, key); } |
| 6394 bool IsDehoisted() { return IsDehoistedField::decode(bit_field_); } | 6398 bool IsDehoisted() { return IsDehoistedField::decode(bit_field_); } |
| 6395 void SetDehoisted(bool is_dehoisted) { | 6399 void SetDehoisted(bool is_dehoisted) { |
| 6396 bit_field_ = IsDehoistedField::update(bit_field_, is_dehoisted); | 6400 bit_field_ = IsDehoistedField::update(bit_field_, is_dehoisted); |
| 6397 } | 6401 } |
| 6398 ElementsKind elements_kind() const { | 6402 ElementsKind elements_kind() const { |
| 6399 return ElementsKindField::decode(bit_field_); | 6403 return ElementsKindField::decode(bit_field_); |
| 6400 } | 6404 } |
| 6401 LoadKeyedHoleMode hole_mode() const { | 6405 LoadKeyedHoleMode hole_mode() const { |
| 6402 return HoleModeField::decode(bit_field_); | 6406 return HoleModeField::decode(bit_field_); |
| 6403 } | 6407 } |
| 6404 | 6408 |
| 6405 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { | 6409 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { |
| 6406 // kind_fast: tagged[int32] (none) | 6410 // kind_fast: tagged[int32] (none) |
| 6407 // kind_double: tagged[int32] (none) | 6411 // kind_double: tagged[int32] (none) |
| 6408 // kind_external: external[int32] (none) | 6412 // kind_fixed_typed_array: tagged[int32] (none) |
| 6413 // kind_external: external[int32] (none) |
| 6409 if (index == 0) { | 6414 if (index == 0) { |
| 6410 return is_external() ? Representation::External() | 6415 return is_external() ? Representation::External() |
| 6411 : Representation::Tagged(); | 6416 : Representation::Tagged(); |
| 6412 } | 6417 } |
| 6413 if (index == 1) { | 6418 if (index == 1) { |
| 6414 return ArrayInstructionInterface::KeyedAccessIndexRequirement( | 6419 return ArrayInstructionInterface::KeyedAccessIndexRequirement( |
| 6415 OperandAt(1)->representation()); | 6420 OperandAt(1)->representation()); |
| 6416 } | 6421 } |
| 6417 return Representation::None(); | 6422 return Representation::None(); |
| 6418 } | 6423 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 6448 ElementsKind elements_kind, | 6453 ElementsKind elements_kind, |
| 6449 LoadKeyedHoleMode mode = NEVER_RETURN_HOLE) | 6454 LoadKeyedHoleMode mode = NEVER_RETURN_HOLE) |
| 6450 : bit_field_(0) { | 6455 : bit_field_(0) { |
| 6451 bit_field_ = ElementsKindField::encode(elements_kind) | | 6456 bit_field_ = ElementsKindField::encode(elements_kind) | |
| 6452 HoleModeField::encode(mode); | 6457 HoleModeField::encode(mode); |
| 6453 | 6458 |
| 6454 SetOperandAt(0, obj); | 6459 SetOperandAt(0, obj); |
| 6455 SetOperandAt(1, key); | 6460 SetOperandAt(1, key); |
| 6456 SetOperandAt(2, dependency != NULL ? dependency : obj); | 6461 SetOperandAt(2, dependency != NULL ? dependency : obj); |
| 6457 | 6462 |
| 6458 if (!is_external()) { | 6463 if (!is_external() && !is_fixed_typed_array()) { |
| 6459 // I can detect the case between storing double (holey and fast) and | 6464 // I can detect the case between storing double (holey and fast) and |
| 6460 // smi/object by looking at elements_kind_. | 6465 // smi/object by looking at elements_kind_. |
| 6461 ASSERT(IsFastSmiOrObjectElementsKind(elements_kind) || | 6466 ASSERT(IsFastSmiOrObjectElementsKind(elements_kind) || |
| 6462 IsFastDoubleElementsKind(elements_kind)); | 6467 IsFastDoubleElementsKind(elements_kind)); |
| 6463 | 6468 |
| 6464 if (IsFastSmiOrObjectElementsKind(elements_kind)) { | 6469 if (IsFastSmiOrObjectElementsKind(elements_kind)) { |
| 6465 if (IsFastSmiElementsKind(elements_kind) && | 6470 if (IsFastSmiElementsKind(elements_kind) && |
| 6466 (!IsHoleyElementsKind(elements_kind) || | 6471 (!IsHoleyElementsKind(elements_kind) || |
| 6467 mode == NEVER_RETURN_HOLE)) { | 6472 mode == NEVER_RETURN_HOLE)) { |
| 6468 set_type(HType::Smi()); | 6473 set_type(HType::Smi()); |
| 6469 if (SmiValuesAre32Bits() && !RequiresHoleCheck()) { | 6474 if (SmiValuesAre32Bits() && !RequiresHoleCheck()) { |
| 6470 set_representation(Representation::Integer32()); | 6475 set_representation(Representation::Integer32()); |
| 6471 } else { | 6476 } else { |
| 6472 set_representation(Representation::Smi()); | 6477 set_representation(Representation::Smi()); |
| 6473 } | 6478 } |
| 6474 } else { | 6479 } else { |
| 6475 set_representation(Representation::Tagged()); | 6480 set_representation(Representation::Tagged()); |
| 6476 } | 6481 } |
| 6477 | 6482 |
| 6478 SetGVNFlag(kDependsOnArrayElements); | 6483 SetGVNFlag(kDependsOnArrayElements); |
| 6479 } else { | 6484 } else { |
| 6480 set_representation(Representation::Double()); | 6485 set_representation(Representation::Double()); |
| 6481 SetGVNFlag(kDependsOnDoubleArrayElements); | 6486 SetGVNFlag(kDependsOnDoubleArrayElements); |
| 6482 } | 6487 } |
| 6483 } else { | 6488 } else { |
| 6484 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS || | 6489 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS || |
| 6485 elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { | 6490 elements_kind == EXTERNAL_DOUBLE_ELEMENTS || |
| 6491 elements_kind == FLOAT32_ELEMENTS || |
| 6492 elements_kind == FLOAT64_ELEMENTS) { |
| 6486 set_representation(Representation::Double()); | 6493 set_representation(Representation::Double()); |
| 6487 } else { | 6494 } else { |
| 6488 set_representation(Representation::Integer32()); | 6495 set_representation(Representation::Integer32()); |
| 6489 } | 6496 } |
| 6490 | 6497 |
| 6491 SetGVNFlag(kDependsOnExternalMemory); | 6498 if (is_external()) { |
| 6499 SetGVNFlag(kDependsOnExternalMemory); |
| 6500 } else if (is_fixed_typed_array()) { |
| 6501 SetGVNFlag(kDependsOnTypedArrayElements); |
| 6502 } else { |
| 6503 UNREACHABLE(); |
| 6504 } |
| 6492 // Native code could change the specialized array. | 6505 // Native code could change the specialized array. |
| 6493 SetGVNFlag(kDependsOnCalls); | 6506 SetGVNFlag(kDependsOnCalls); |
| 6494 } | 6507 } |
| 6495 | 6508 |
| 6496 SetFlag(kUseGVN); | 6509 SetFlag(kUseGVN); |
| 6497 } | 6510 } |
| 6498 | 6511 |
| 6499 virtual bool IsDeletable() const V8_OVERRIDE { | 6512 virtual bool IsDeletable() const V8_OVERRIDE { |
| 6500 return !RequiresHoleCheck(); | 6513 return !RequiresHoleCheck(); |
| 6501 } | 6514 } |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6740 | 6753 |
| 6741 class HStoreKeyed V8_FINAL | 6754 class HStoreKeyed V8_FINAL |
| 6742 : public HTemplateInstruction<3>, public ArrayInstructionInterface { | 6755 : public HTemplateInstruction<3>, public ArrayInstructionInterface { |
| 6743 public: | 6756 public: |
| 6744 DECLARE_INSTRUCTION_FACTORY_P4(HStoreKeyed, HValue*, HValue*, HValue*, | 6757 DECLARE_INSTRUCTION_FACTORY_P4(HStoreKeyed, HValue*, HValue*, HValue*, |
| 6745 ElementsKind); | 6758 ElementsKind); |
| 6746 DECLARE_INSTRUCTION_FACTORY_P5(HStoreKeyed, HValue*, HValue*, HValue*, | 6759 DECLARE_INSTRUCTION_FACTORY_P5(HStoreKeyed, HValue*, HValue*, HValue*, |
| 6747 ElementsKind, StoreFieldOrKeyedMode); | 6760 ElementsKind, StoreFieldOrKeyedMode); |
| 6748 | 6761 |
| 6749 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { | 6762 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { |
| 6750 // kind_fast: tagged[int32] = tagged | 6763 // kind_fast: tagged[int32] = tagged |
| 6751 // kind_double: tagged[int32] = double | 6764 // kind_double: tagged[int32] = double |
| 6752 // kind_smi : tagged[int32] = smi | 6765 // kind_smi : tagged[int32] = smi |
| 6753 // kind_external: external[int32] = (double | int32) | 6766 // kind_fixed_typed_array: tagged[int32] = (double | int32) |
| 6767 // kind_external: external[int32] = (double | int32) |
| 6754 if (index == 0) { | 6768 if (index == 0) { |
| 6755 return is_external() ? Representation::External() | 6769 return is_external() ? Representation::External() |
| 6756 : Representation::Tagged(); | 6770 : Representation::Tagged(); |
| 6757 } else if (index == 1) { | 6771 } else if (index == 1) { |
| 6758 return ArrayInstructionInterface::KeyedAccessIndexRequirement( | 6772 return ArrayInstructionInterface::KeyedAccessIndexRequirement( |
| 6759 OperandAt(1)->representation()); | 6773 OperandAt(1)->representation()); |
| 6760 } | 6774 } |
| 6761 | 6775 |
| 6762 ASSERT_EQ(index, 2); | 6776 ASSERT_EQ(index, 2); |
| 6763 if (IsDoubleOrFloatElementsKind(elements_kind())) { | 6777 if (IsDoubleOrFloatElementsKind(elements_kind())) { |
| 6764 return Representation::Double(); | 6778 return Representation::Double(); |
| 6765 } | 6779 } |
| 6766 if (SmiValuesAre32Bits() && store_mode_ == STORE_TO_INITIALIZED_ENTRY) { | 6780 if (SmiValuesAre32Bits() && store_mode_ == STORE_TO_INITIALIZED_ENTRY) { |
| 6767 return Representation::Integer32(); | 6781 return Representation::Integer32(); |
| 6768 } | 6782 } |
| 6769 if (IsFastSmiElementsKind(elements_kind())) { | 6783 if (IsFastSmiElementsKind(elements_kind())) { |
| 6770 return Representation::Smi(); | 6784 return Representation::Smi(); |
| 6771 } | 6785 } |
| 6772 | 6786 |
| 6773 return is_external() ? Representation::Integer32() | 6787 return is_external() || is_fixed_typed_array() |
| 6774 : Representation::Tagged(); | 6788 ? Representation::Integer32() |
| 6789 : Representation::Tagged(); |
| 6775 } | 6790 } |
| 6776 | 6791 |
| 6777 bool is_external() const { | 6792 bool is_external() const { |
| 6778 return IsExternalArrayElementsKind(elements_kind()); | 6793 return IsExternalArrayElementsKind(elements_kind()); |
| 6779 } | 6794 } |
| 6780 | 6795 |
| 6796 bool is_fixed_typed_array() const { |
| 6797 return IsFixedTypedArrayElementsKind(elements_kind()); |
| 6798 } |
| 6799 |
| 6781 virtual Representation observed_input_representation(int index) V8_OVERRIDE { | 6800 virtual Representation observed_input_representation(int index) V8_OVERRIDE { |
| 6782 if (index < 2) return RequiredInputRepresentation(index); | 6801 if (index < 2) return RequiredInputRepresentation(index); |
| 6783 if (IsUninitialized()) { | 6802 if (IsUninitialized()) { |
| 6784 return Representation::None(); | 6803 return Representation::None(); |
| 6785 } | 6804 } |
| 6786 if (IsDoubleOrFloatElementsKind(elements_kind())) { | 6805 if (IsDoubleOrFloatElementsKind(elements_kind())) { |
| 6787 return Representation::Double(); | 6806 return Representation::Double(); |
| 6788 } | 6807 } |
| 6789 if (SmiValuesAre32Bits() && store_mode_ == STORE_TO_INITIALIZED_ENTRY) { | 6808 if (SmiValuesAre32Bits() && store_mode_ == STORE_TO_INITIALIZED_ENTRY) { |
| 6790 return Representation::Integer32(); | 6809 return Representation::Integer32(); |
| 6791 } | 6810 } |
| 6792 if (IsFastSmiElementsKind(elements_kind())) { | 6811 if (IsFastSmiElementsKind(elements_kind())) { |
| 6793 return Representation::Smi(); | 6812 return Representation::Smi(); |
| 6794 } | 6813 } |
| 6795 if (is_external()) { | 6814 if (is_external() || is_fixed_typed_array()) { |
| 6796 return Representation::Integer32(); | 6815 return Representation::Integer32(); |
| 6797 } | 6816 } |
| 6798 // For fast object elements kinds, don't assume anything. | 6817 // For fast object elements kinds, don't assume anything. |
| 6799 return Representation::None(); | 6818 return Representation::None(); |
| 6800 } | 6819 } |
| 6801 | 6820 |
| 6802 HValue* elements() { return OperandAt(0); } | 6821 HValue* elements() { return OperandAt(0); } |
| 6803 HValue* key() { return OperandAt(1); } | 6822 HValue* key() { return OperandAt(1); } |
| 6804 HValue* value() { return OperandAt(2); } | 6823 HValue* value() { return OperandAt(2); } |
| 6805 bool value_is_smi() const { | 6824 bool value_is_smi() const { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6870 SetFlag(kTrackSideEffectDominators); | 6889 SetFlag(kTrackSideEffectDominators); |
| 6871 SetGVNFlag(kDependsOnNewSpacePromotion); | 6890 SetGVNFlag(kDependsOnNewSpacePromotion); |
| 6872 } | 6891 } |
| 6873 if (is_external()) { | 6892 if (is_external()) { |
| 6874 SetGVNFlag(kChangesExternalMemory); | 6893 SetGVNFlag(kChangesExternalMemory); |
| 6875 SetFlag(kAllowUndefinedAsNaN); | 6894 SetFlag(kAllowUndefinedAsNaN); |
| 6876 } else if (IsFastDoubleElementsKind(elements_kind)) { | 6895 } else if (IsFastDoubleElementsKind(elements_kind)) { |
| 6877 SetGVNFlag(kChangesDoubleArrayElements); | 6896 SetGVNFlag(kChangesDoubleArrayElements); |
| 6878 } else if (IsFastSmiElementsKind(elements_kind)) { | 6897 } else if (IsFastSmiElementsKind(elements_kind)) { |
| 6879 SetGVNFlag(kChangesArrayElements); | 6898 SetGVNFlag(kChangesArrayElements); |
| 6899 } else if (is_fixed_typed_array()) { |
| 6900 SetGVNFlag(kChangesTypedArrayElements); |
| 6901 SetFlag(kAllowUndefinedAsNaN); |
| 6880 } else { | 6902 } else { |
| 6881 SetGVNFlag(kChangesArrayElements); | 6903 SetGVNFlag(kChangesArrayElements); |
| 6882 } | 6904 } |
| 6883 | 6905 |
| 6884 // EXTERNAL_{UNSIGNED_,}{BYTE,SHORT,INT}_ELEMENTS are truncating. | 6906 // EXTERNAL_{UNSIGNED_,}{BYTE,SHORT,INT}_ELEMENTS are truncating. |
| 6885 if (elements_kind >= EXTERNAL_BYTE_ELEMENTS && | 6907 if ((elements_kind >= EXTERNAL_BYTE_ELEMENTS && |
| 6886 elements_kind <= EXTERNAL_UNSIGNED_INT_ELEMENTS) { | 6908 elements_kind <= EXTERNAL_UNSIGNED_INT_ELEMENTS) || |
| 6909 (elements_kind >= UINT8_ELEMENTS && |
| 6910 elements_kind <= INT32_ELEMENTS)) { |
| 6887 SetFlag(kTruncatingToInt32); | 6911 SetFlag(kTruncatingToInt32); |
| 6888 } | 6912 } |
| 6889 } | 6913 } |
| 6890 | 6914 |
| 6891 ElementsKind elements_kind_; | 6915 ElementsKind elements_kind_; |
| 6892 uint32_t index_offset_; | 6916 uint32_t index_offset_; |
| 6893 bool is_dehoisted_ : 1; | 6917 bool is_dehoisted_ : 1; |
| 6894 bool is_uninitialized_ : 1; | 6918 bool is_uninitialized_ : 1; |
| 6895 StoreFieldOrKeyedMode store_mode_: 1; | 6919 StoreFieldOrKeyedMode store_mode_: 1; |
| 6896 HValue* new_space_dominator_; | 6920 HValue* new_space_dominator_; |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7585 virtual bool IsDeletable() const V8_OVERRIDE { return true; } | 7609 virtual bool IsDeletable() const V8_OVERRIDE { return true; } |
| 7586 }; | 7610 }; |
| 7587 | 7611 |
| 7588 | 7612 |
| 7589 #undef DECLARE_INSTRUCTION | 7613 #undef DECLARE_INSTRUCTION |
| 7590 #undef DECLARE_CONCRETE_INSTRUCTION | 7614 #undef DECLARE_CONCRETE_INSTRUCTION |
| 7591 | 7615 |
| 7592 } } // namespace v8::internal | 7616 } } // namespace v8::internal |
| 7593 | 7617 |
| 7594 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 7618 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
| OLD | NEW |