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

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

Issue 1262583002: Reland of "Remove ExternalArray, derived types, and element kinds" (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 5 years, 4 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
« no previous file with comments | « src/hydrogen.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_HYDROGEN_INSTRUCTIONS_H_ 5 #ifndef V8_HYDROGEN_INSTRUCTIONS_H_
6 #define V8_HYDROGEN_INSTRUCTIONS_H_ 6 #define V8_HYDROGEN_INSTRUCTIONS_H_
7 7
8 #include <cstring> 8 #include <cstring>
9 #include <iosfwd> 9 #include <iosfwd>
10 10
(...skipping 6226 matching lines...) Expand 10 before | Expand all | Expand 10 after
6237 static HObjectAccess ForJSArrayBufferBitField() { 6237 static HObjectAccess ForJSArrayBufferBitField() {
6238 return HObjectAccess::ForObservableJSObjectOffset( 6238 return HObjectAccess::ForObservableJSObjectOffset(
6239 JSArrayBuffer::kBitFieldOffset, Representation::Integer32()); 6239 JSArrayBuffer::kBitFieldOffset, Representation::Integer32());
6240 } 6240 }
6241 6241
6242 static HObjectAccess ForJSArrayBufferBitFieldSlot() { 6242 static HObjectAccess ForJSArrayBufferBitFieldSlot() {
6243 return HObjectAccess::ForObservableJSObjectOffset( 6243 return HObjectAccess::ForObservableJSObjectOffset(
6244 JSArrayBuffer::kBitFieldSlot, Representation::Smi()); 6244 JSArrayBuffer::kBitFieldSlot, Representation::Smi());
6245 } 6245 }
6246 6246
6247 static HObjectAccess ForExternalArrayExternalPointer() {
6248 return HObjectAccess::ForObservableJSObjectOffset(
6249 ExternalArray::kExternalPointerOffset, Representation::External());
6250 }
6251
6252 static HObjectAccess ForJSArrayBufferViewBuffer() { 6247 static HObjectAccess ForJSArrayBufferViewBuffer() {
6253 return HObjectAccess::ForObservableJSObjectOffset( 6248 return HObjectAccess::ForObservableJSObjectOffset(
6254 JSArrayBufferView::kBufferOffset); 6249 JSArrayBufferView::kBufferOffset);
6255 } 6250 }
6256 6251
6257 static HObjectAccess ForJSArrayBufferViewByteOffset() { 6252 static HObjectAccess ForJSArrayBufferViewByteOffset() {
6258 return HObjectAccess::ForObservableJSObjectOffset( 6253 return HObjectAccess::ForObservableJSObjectOffset(
6259 JSArrayBufferView::kByteOffsetOffset); 6254 JSArrayBufferView::kByteOffsetOffset);
6260 } 6255 }
6261 6256
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
6611 class HLoadKeyed final : public HTemplateInstruction<3>, 6606 class HLoadKeyed final : public HTemplateInstruction<3>,
6612 public ArrayInstructionInterface { 6607 public ArrayInstructionInterface {
6613 public: 6608 public:
6614 DECLARE_INSTRUCTION_FACTORY_P4(HLoadKeyed, HValue*, HValue*, HValue*, 6609 DECLARE_INSTRUCTION_FACTORY_P4(HLoadKeyed, HValue*, HValue*, HValue*,
6615 ElementsKind); 6610 ElementsKind);
6616 DECLARE_INSTRUCTION_FACTORY_P5(HLoadKeyed, HValue*, HValue*, HValue*, 6611 DECLARE_INSTRUCTION_FACTORY_P5(HLoadKeyed, HValue*, HValue*, HValue*,
6617 ElementsKind, LoadKeyedHoleMode); 6612 ElementsKind, LoadKeyedHoleMode);
6618 DECLARE_INSTRUCTION_FACTORY_P6(HLoadKeyed, HValue*, HValue*, HValue*, 6613 DECLARE_INSTRUCTION_FACTORY_P6(HLoadKeyed, HValue*, HValue*, HValue*,
6619 ElementsKind, LoadKeyedHoleMode, int); 6614 ElementsKind, LoadKeyedHoleMode, int);
6620 6615
6621 bool is_external() const {
6622 return IsExternalArrayElementsKind(elements_kind());
6623 }
6624 bool is_fixed_typed_array() const { 6616 bool is_fixed_typed_array() const {
6625 return IsFixedTypedArrayElementsKind(elements_kind()); 6617 return IsFixedTypedArrayElementsKind(elements_kind());
6626 } 6618 }
6627 bool is_typed_elements() const {
6628 return is_external() || is_fixed_typed_array();
6629 }
6630 HValue* elements() const { return OperandAt(0); } 6619 HValue* elements() const { return OperandAt(0); }
6631 HValue* key() const { return OperandAt(1); } 6620 HValue* key() const { return OperandAt(1); }
6632 HValue* dependency() const { 6621 HValue* dependency() const {
6633 DCHECK(HasDependency()); 6622 DCHECK(HasDependency());
6634 return OperandAt(2); 6623 return OperandAt(2);
6635 } 6624 }
6636 bool HasDependency() const { return OperandAt(0) != OperandAt(2); } 6625 bool HasDependency() const { return OperandAt(0) != OperandAt(2); }
6637 uint32_t base_offset() const { return BaseOffsetField::decode(bit_field_); } 6626 uint32_t base_offset() const { return BaseOffsetField::decode(bit_field_); }
6638 bool TryIncreaseBaseOffset(uint32_t increase_by_value) override; 6627 bool TryIncreaseBaseOffset(uint32_t increase_by_value) override;
6639 HValue* GetKey() override { return key(); } 6628 HValue* GetKey() override { return key(); }
(...skipping 10 matching lines...) Expand all
6650 LoadKeyedHoleMode hole_mode() const { 6639 LoadKeyedHoleMode hole_mode() const {
6651 return HoleModeField::decode(bit_field_); 6640 return HoleModeField::decode(bit_field_);
6652 } 6641 }
6653 6642
6654 Representation RequiredInputRepresentation(int index) override { 6643 Representation RequiredInputRepresentation(int index) override {
6655 // kind_fast: tagged[int32] (none) 6644 // kind_fast: tagged[int32] (none)
6656 // kind_double: tagged[int32] (none) 6645 // kind_double: tagged[int32] (none)
6657 // kind_fixed_typed_array: external[int32] (none) 6646 // kind_fixed_typed_array: external[int32] (none)
6658 // kind_external: external[int32] (none) 6647 // kind_external: external[int32] (none)
6659 if (index == 0) { 6648 if (index == 0) {
6660 return is_typed_elements() ? Representation::External() 6649 return is_fixed_typed_array() ? Representation::External()
6661 : Representation::Tagged(); 6650 : Representation::Tagged();
6662 } 6651 }
6663 if (index == 1) { 6652 if (index == 1) {
6664 return ArrayInstructionInterface::KeyedAccessIndexRequirement( 6653 return ArrayInstructionInterface::KeyedAccessIndexRequirement(
6665 OperandAt(1)->representation()); 6654 OperandAt(1)->representation());
6666 } 6655 }
6667 return Representation::None(); 6656 return Representation::None();
6668 } 6657 }
6669 6658
6670 Representation observed_input_representation(int index) override { 6659 Representation observed_input_representation(int index) override {
6671 return RequiredInputRepresentation(index); 6660 return RequiredInputRepresentation(index);
(...skipping 28 matching lines...) Expand all
6700 ? GetDefaultHeaderSizeForElementsKind(elements_kind) 6689 ? GetDefaultHeaderSizeForElementsKind(elements_kind)
6701 : offset; 6690 : offset;
6702 bit_field_ = ElementsKindField::encode(elements_kind) | 6691 bit_field_ = ElementsKindField::encode(elements_kind) |
6703 HoleModeField::encode(mode) | 6692 HoleModeField::encode(mode) |
6704 BaseOffsetField::encode(offset); 6693 BaseOffsetField::encode(offset);
6705 6694
6706 SetOperandAt(0, obj); 6695 SetOperandAt(0, obj);
6707 SetOperandAt(1, key); 6696 SetOperandAt(1, key);
6708 SetOperandAt(2, dependency != NULL ? dependency : obj); 6697 SetOperandAt(2, dependency != NULL ? dependency : obj);
6709 6698
6710 if (!is_typed_elements()) { 6699 if (!is_fixed_typed_array()) {
6711 // I can detect the case between storing double (holey and fast) and 6700 // I can detect the case between storing double (holey and fast) and
6712 // smi/object by looking at elements_kind_. 6701 // smi/object by looking at elements_kind_.
6713 DCHECK(IsFastSmiOrObjectElementsKind(elements_kind) || 6702 DCHECK(IsFastSmiOrObjectElementsKind(elements_kind) ||
6714 IsFastDoubleElementsKind(elements_kind)); 6703 IsFastDoubleElementsKind(elements_kind));
6715 6704
6716 if (IsFastSmiOrObjectElementsKind(elements_kind)) { 6705 if (IsFastSmiOrObjectElementsKind(elements_kind)) {
6717 if (IsFastSmiElementsKind(elements_kind) && 6706 if (IsFastSmiElementsKind(elements_kind) &&
6718 (!IsHoleyElementsKind(elements_kind) || 6707 (!IsHoleyElementsKind(elements_kind) ||
6719 mode == NEVER_RETURN_HOLE)) { 6708 mode == NEVER_RETURN_HOLE)) {
6720 set_type(HType::Smi()); 6709 set_type(HType::Smi());
6721 if (SmiValuesAre32Bits() && !RequiresHoleCheck()) { 6710 if (SmiValuesAre32Bits() && !RequiresHoleCheck()) {
6722 set_representation(Representation::Integer32()); 6711 set_representation(Representation::Integer32());
6723 } else { 6712 } else {
6724 set_representation(Representation::Smi()); 6713 set_representation(Representation::Smi());
6725 } 6714 }
6726 } else { 6715 } else {
6727 set_representation(Representation::Tagged()); 6716 set_representation(Representation::Tagged());
6728 } 6717 }
6729 6718
6730 SetDependsOnFlag(kArrayElements); 6719 SetDependsOnFlag(kArrayElements);
6731 } else { 6720 } else {
6732 set_representation(Representation::Double()); 6721 set_representation(Representation::Double());
6733 SetDependsOnFlag(kDoubleArrayElements); 6722 SetDependsOnFlag(kDoubleArrayElements);
6734 } 6723 }
6735 } else { 6724 } else {
6736 if (elements_kind == EXTERNAL_FLOAT32_ELEMENTS || 6725 if (elements_kind == FLOAT32_ELEMENTS ||
6737 elements_kind == EXTERNAL_FLOAT64_ELEMENTS ||
6738 elements_kind == FLOAT32_ELEMENTS ||
6739 elements_kind == FLOAT64_ELEMENTS) { 6726 elements_kind == FLOAT64_ELEMENTS) {
6740 set_representation(Representation::Double()); 6727 set_representation(Representation::Double());
6741 } else { 6728 } else {
6742 set_representation(Representation::Integer32()); 6729 set_representation(Representation::Integer32());
6743 } 6730 }
6744 6731
6745 if (is_external()) { 6732 if (is_fixed_typed_array()) {
6746 SetDependsOnFlag(kExternalMemory); 6733 SetDependsOnFlag(kExternalMemory);
6747 } else if (is_fixed_typed_array()) {
6748 SetDependsOnFlag(kTypedArrayElements); 6734 SetDependsOnFlag(kTypedArrayElements);
6749 } else { 6735 } else {
6750 UNREACHABLE(); 6736 UNREACHABLE();
6751 } 6737 }
6752 // Native code could change the specialized array. 6738 // Native code could change the specialized array.
6753 SetDependsOnFlag(kCalls); 6739 SetDependsOnFlag(kCalls);
6754 } 6740 }
6755 6741
6756 SetFlag(kUseGVN); 6742 SetFlag(kUseGVN);
6757 } 6743 }
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
7106 DECLARE_INSTRUCTION_FACTORY_P6(HStoreKeyed, HValue*, HValue*, HValue*, 7092 DECLARE_INSTRUCTION_FACTORY_P6(HStoreKeyed, HValue*, HValue*, HValue*,
7107 ElementsKind, StoreFieldOrKeyedMode, int); 7093 ElementsKind, StoreFieldOrKeyedMode, int);
7108 7094
7109 Representation RequiredInputRepresentation(int index) override { 7095 Representation RequiredInputRepresentation(int index) override {
7110 // kind_fast: tagged[int32] = tagged 7096 // kind_fast: tagged[int32] = tagged
7111 // kind_double: tagged[int32] = double 7097 // kind_double: tagged[int32] = double
7112 // kind_smi : tagged[int32] = smi 7098 // kind_smi : tagged[int32] = smi
7113 // kind_fixed_typed_array: tagged[int32] = (double | int32) 7099 // kind_fixed_typed_array: tagged[int32] = (double | int32)
7114 // kind_external: external[int32] = (double | int32) 7100 // kind_external: external[int32] = (double | int32)
7115 if (index == 0) { 7101 if (index == 0) {
7116 return is_typed_elements() ? Representation::External() 7102 return is_fixed_typed_array() ? Representation::External()
7117 : Representation::Tagged(); 7103 : Representation::Tagged();
7118 } else if (index == 1) { 7104 } else if (index == 1) {
7119 return ArrayInstructionInterface::KeyedAccessIndexRequirement( 7105 return ArrayInstructionInterface::KeyedAccessIndexRequirement(
7120 OperandAt(1)->representation()); 7106 OperandAt(1)->representation());
7121 } 7107 }
7122 7108
7123 DCHECK_EQ(index, 2); 7109 DCHECK_EQ(index, 2);
7124 return RequiredValueRepresentation(elements_kind(), store_mode()); 7110 return RequiredValueRepresentation(elements_kind(), store_mode());
7125 } 7111 }
7126 7112
7127 static Representation RequiredValueRepresentation( 7113 static Representation RequiredValueRepresentation(
7128 ElementsKind kind, StoreFieldOrKeyedMode mode) { 7114 ElementsKind kind, StoreFieldOrKeyedMode mode) {
7129 if (IsDoubleOrFloatElementsKind(kind)) { 7115 if (IsDoubleOrFloatElementsKind(kind)) {
7130 return Representation::Double(); 7116 return Representation::Double();
7131 } 7117 }
7132 7118
7133 if (kind == FAST_SMI_ELEMENTS && SmiValuesAre32Bits() && 7119 if (kind == FAST_SMI_ELEMENTS && SmiValuesAre32Bits() &&
7134 mode == STORE_TO_INITIALIZED_ENTRY) { 7120 mode == STORE_TO_INITIALIZED_ENTRY) {
7135 return Representation::Integer32(); 7121 return Representation::Integer32();
7136 } 7122 }
7137 7123
7138 if (IsFastSmiElementsKind(kind)) { 7124 if (IsFastSmiElementsKind(kind)) {
7139 return Representation::Smi(); 7125 return Representation::Smi();
7140 } 7126 }
7141 7127
7142 return IsExternalArrayElementsKind(kind) || 7128 if (IsFixedTypedArrayElementsKind(kind)) {
7143 IsFixedTypedArrayElementsKind(kind) 7129 return Representation::Integer32();
7144 ? Representation::Integer32() 7130 }
7145 : Representation::Tagged(); 7131 return Representation::Tagged();
7146 }
7147
7148 bool is_external() const {
7149 return IsExternalArrayElementsKind(elements_kind());
7150 } 7132 }
7151 7133
7152 bool is_fixed_typed_array() const { 7134 bool is_fixed_typed_array() const {
7153 return IsFixedTypedArrayElementsKind(elements_kind()); 7135 return IsFixedTypedArrayElementsKind(elements_kind());
7154 } 7136 }
7155 7137
7156 bool is_typed_elements() const {
7157 return is_external() || is_fixed_typed_array();
7158 }
7159
7160 Representation observed_input_representation(int index) override { 7138 Representation observed_input_representation(int index) override {
7161 if (index < 2) return RequiredInputRepresentation(index); 7139 if (index < 2) return RequiredInputRepresentation(index);
7162 if (IsUninitialized()) { 7140 if (IsUninitialized()) {
7163 return Representation::None(); 7141 return Representation::None();
7164 } 7142 }
7165 Representation r = 7143 Representation r =
7166 RequiredValueRepresentation(elements_kind(), store_mode()); 7144 RequiredValueRepresentation(elements_kind(), store_mode());
7167 // For fast object elements kinds, don't assume anything. 7145 // For fast object elements kinds, don't assume anything.
7168 if (r.IsTagged()) return Representation::None(); 7146 if (r.IsTagged()) return Representation::None();
7169 return r; 7147 return r;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
7239 ElementsKindField::encode(elements_kind)), 7217 ElementsKindField::encode(elements_kind)),
7240 dominator_(NULL) { 7218 dominator_(NULL) {
7241 SetOperandAt(0, obj); 7219 SetOperandAt(0, obj);
7242 SetOperandAt(1, key); 7220 SetOperandAt(1, key);
7243 SetOperandAt(2, val); 7221 SetOperandAt(2, val);
7244 7222
7245 if (IsFastObjectElementsKind(elements_kind)) { 7223 if (IsFastObjectElementsKind(elements_kind)) {
7246 SetFlag(kTrackSideEffectDominators); 7224 SetFlag(kTrackSideEffectDominators);
7247 SetDependsOnFlag(kNewSpacePromotion); 7225 SetDependsOnFlag(kNewSpacePromotion);
7248 } 7226 }
7249 if (is_external()) { 7227 if (IsFastDoubleElementsKind(elements_kind)) {
7250 SetChangesFlag(kExternalMemory);
7251 SetFlag(kAllowUndefinedAsNaN);
7252 } else if (IsFastDoubleElementsKind(elements_kind)) {
7253 SetChangesFlag(kDoubleArrayElements); 7228 SetChangesFlag(kDoubleArrayElements);
7254 } else if (IsFastSmiElementsKind(elements_kind)) { 7229 } else if (IsFastSmiElementsKind(elements_kind)) {
7255 SetChangesFlag(kArrayElements); 7230 SetChangesFlag(kArrayElements);
7256 } else if (is_fixed_typed_array()) { 7231 } else if (is_fixed_typed_array()) {
7257 SetChangesFlag(kTypedArrayElements); 7232 SetChangesFlag(kTypedArrayElements);
7233 SetChangesFlag(kExternalMemory);
7258 SetFlag(kAllowUndefinedAsNaN); 7234 SetFlag(kAllowUndefinedAsNaN);
7259 } else { 7235 } else {
7260 SetChangesFlag(kArrayElements); 7236 SetChangesFlag(kArrayElements);
7261 } 7237 }
7262 7238
7263 // EXTERNAL_{UNSIGNED_,}{BYTE,SHORT,INT}_ELEMENTS are truncating. 7239 // {UNSIGNED_,}{BYTE,SHORT,INT}_ELEMENTS are truncating.
7264 if ((elements_kind >= EXTERNAL_INT8_ELEMENTS && 7240 if (elements_kind >= UINT8_ELEMENTS && elements_kind <= INT32_ELEMENTS) {
7265 elements_kind <= EXTERNAL_UINT32_ELEMENTS) ||
7266 (elements_kind >= UINT8_ELEMENTS &&
7267 elements_kind <= INT32_ELEMENTS)) {
7268 SetFlag(kTruncatingToInt32); 7241 SetFlag(kTruncatingToInt32);
7269 } 7242 }
7270 } 7243 }
7271 7244
7272 class IsDehoistedField : public BitField<bool, 0, 1> {}; 7245 class IsDehoistedField : public BitField<bool, 0, 1> {};
7273 class IsUninitializedField : public BitField<bool, 1, 1> {}; 7246 class IsUninitializedField : public BitField<bool, 1, 1> {};
7274 class StoreModeField : public BitField<StoreFieldOrKeyedMode, 2, 1> {}; 7247 class StoreModeField : public BitField<StoreFieldOrKeyedMode, 2, 1> {};
7275 class ElementsKindField : public BitField<ElementsKind, 3, 5> {}; 7248 class ElementsKindField : public BitField<ElementsKind, 3, 5> {};
7276 7249
7277 uint32_t base_offset_; 7250 uint32_t base_offset_;
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after
8085 }; 8058 };
8086 8059
8087 8060
8088 8061
8089 #undef DECLARE_INSTRUCTION 8062 #undef DECLARE_INSTRUCTION
8090 #undef DECLARE_CONCRETE_INSTRUCTION 8063 #undef DECLARE_CONCRETE_INSTRUCTION
8091 8064
8092 } } // namespace v8::internal 8065 } } // namespace v8::internal
8093 8066
8094 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 8067 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698