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

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

Issue 101413006: Implement in-heap backing store for typed arrays. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: GC fixes Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « src/hydrogen.cc ('k') | src/ia32/lithium-codegen-ia32.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 // 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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 V(Calls) \ 200 V(Calls) \
201 V(ContextSlots) \ 201 V(ContextSlots) \
202 V(DoubleArrayElements) \ 202 V(DoubleArrayElements) \
203 V(DoubleFields) \ 203 V(DoubleFields) \
204 V(ElementsKind) \ 204 V(ElementsKind) \
205 V(ElementsPointer) \ 205 V(ElementsPointer) \
206 V(GlobalVars) \ 206 V(GlobalVars) \
207 V(InobjectFields) \ 207 V(InobjectFields) \
208 V(OsrEntries) \ 208 V(OsrEntries) \
209 V(ExternalMemory) \ 209 V(ExternalMemory) \
210 V(StringChars) 210 V(StringChars) \
211 V(TypedArrayElements)
211 212
212 213
213 #define DECLARE_ABSTRACT_INSTRUCTION(type) \ 214 #define DECLARE_ABSTRACT_INSTRUCTION(type) \
214 virtual bool Is##type() const V8_FINAL V8_OVERRIDE { return true; } \ 215 virtual bool Is##type() const V8_FINAL V8_OVERRIDE { return true; } \
215 static H##type* cast(HValue* value) { \ 216 static H##type* cast(HValue* value) { \
216 ASSERT(value->Is##type()); \ 217 ASSERT(value->Is##type()); \
217 return reinterpret_cast<H##type*>(value); \ 218 return reinterpret_cast<H##type*>(value); \
218 } 219 }
219 220
220 221
(...skipping 6138 matching lines...) Expand 10 before | Expand all | Expand 10 after
6359 : public HTemplateInstruction<3>, public ArrayInstructionInterface { 6360 : public HTemplateInstruction<3>, public ArrayInstructionInterface {
6360 public: 6361 public:
6361 DECLARE_INSTRUCTION_FACTORY_P4(HLoadKeyed, HValue*, HValue*, HValue*, 6362 DECLARE_INSTRUCTION_FACTORY_P4(HLoadKeyed, HValue*, HValue*, HValue*,
6362 ElementsKind); 6363 ElementsKind);
6363 DECLARE_INSTRUCTION_FACTORY_P5(HLoadKeyed, HValue*, HValue*, HValue*, 6364 DECLARE_INSTRUCTION_FACTORY_P5(HLoadKeyed, HValue*, HValue*, HValue*,
6364 ElementsKind, LoadKeyedHoleMode); 6365 ElementsKind, LoadKeyedHoleMode);
6365 6366
6366 bool is_external() const { 6367 bool is_external() const {
6367 return IsExternalArrayElementsKind(elements_kind()); 6368 return IsExternalArrayElementsKind(elements_kind());
6368 } 6369 }
6370 bool is_fixed_typed_array() const {
6371 return IsFixedTypedArrayElementsKind(elements_kind());
6372 }
6373 bool is_typed_elements() const {
6374 return is_external() || is_fixed_typed_array();
6375 }
6369 HValue* elements() { return OperandAt(0); } 6376 HValue* elements() { return OperandAt(0); }
6370 HValue* key() { return OperandAt(1); } 6377 HValue* key() { return OperandAt(1); }
6371 HValue* dependency() { 6378 HValue* dependency() {
6372 ASSERT(HasDependency()); 6379 ASSERT(HasDependency());
6373 return OperandAt(2); 6380 return OperandAt(2);
6374 } 6381 }
6375 bool HasDependency() const { return OperandAt(0) != OperandAt(2); } 6382 bool HasDependency() const { return OperandAt(0) != OperandAt(2); }
6376 uint32_t index_offset() { return IndexOffsetField::decode(bit_field_); } 6383 uint32_t index_offset() { return IndexOffsetField::decode(bit_field_); }
6377 void SetIndexOffset(uint32_t index_offset) { 6384 void SetIndexOffset(uint32_t index_offset) {
6378 bit_field_ = IndexOffsetField::update(bit_field_, index_offset); 6385 bit_field_ = IndexOffsetField::update(bit_field_, index_offset);
6379 } 6386 }
6380 virtual int MaxIndexOffsetBits() { 6387 virtual int MaxIndexOffsetBits() {
6381 return kBitsForIndexOffset; 6388 return kBitsForIndexOffset;
6382 } 6389 }
6383 HValue* GetKey() { return key(); } 6390 HValue* GetKey() { return key(); }
6384 void SetKey(HValue* key) { SetOperandAt(1, key); } 6391 void SetKey(HValue* key) { SetOperandAt(1, key); }
6385 bool IsDehoisted() { return IsDehoistedField::decode(bit_field_); } 6392 bool IsDehoisted() { return IsDehoistedField::decode(bit_field_); }
6386 void SetDehoisted(bool is_dehoisted) { 6393 void SetDehoisted(bool is_dehoisted) {
6387 bit_field_ = IsDehoistedField::update(bit_field_, is_dehoisted); 6394 bit_field_ = IsDehoistedField::update(bit_field_, is_dehoisted);
6388 } 6395 }
6389 ElementsKind elements_kind() const { 6396 ElementsKind elements_kind() const {
6390 return ElementsKindField::decode(bit_field_); 6397 return ElementsKindField::decode(bit_field_);
6391 } 6398 }
6392 LoadKeyedHoleMode hole_mode() const { 6399 LoadKeyedHoleMode hole_mode() const {
6393 return HoleModeField::decode(bit_field_); 6400 return HoleModeField::decode(bit_field_);
6394 } 6401 }
6395 6402
6396 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { 6403 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
6397 // kind_fast: tagged[int32] (none) 6404 // kind_fast: tagged[int32] (none)
6398 // kind_double: tagged[int32] (none) 6405 // kind_double: tagged[int32] (none)
6399 // kind_external: external[int32] (none) 6406 // kind_fixed_typed_array: tagged[int32] (none)
6407 // kind_external: external[int32] (none)
6400 if (index == 0) { 6408 if (index == 0) {
6401 return is_external() ? Representation::External() 6409 return is_external() ? Representation::External()
6402 : Representation::Tagged(); 6410 : Representation::Tagged();
6403 } 6411 }
6404 if (index == 1) { 6412 if (index == 1) {
6405 return ArrayInstructionInterface::KeyedAccessIndexRequirement( 6413 return ArrayInstructionInterface::KeyedAccessIndexRequirement(
6406 OperandAt(1)->representation()); 6414 OperandAt(1)->representation());
6407 } 6415 }
6408 return Representation::None(); 6416 return Representation::None();
6409 } 6417 }
(...skipping 29 matching lines...) Expand all
6439 ElementsKind elements_kind, 6447 ElementsKind elements_kind,
6440 LoadKeyedHoleMode mode = NEVER_RETURN_HOLE) 6448 LoadKeyedHoleMode mode = NEVER_RETURN_HOLE)
6441 : bit_field_(0) { 6449 : bit_field_(0) {
6442 bit_field_ = ElementsKindField::encode(elements_kind) | 6450 bit_field_ = ElementsKindField::encode(elements_kind) |
6443 HoleModeField::encode(mode); 6451 HoleModeField::encode(mode);
6444 6452
6445 SetOperandAt(0, obj); 6453 SetOperandAt(0, obj);
6446 SetOperandAt(1, key); 6454 SetOperandAt(1, key);
6447 SetOperandAt(2, dependency != NULL ? dependency : obj); 6455 SetOperandAt(2, dependency != NULL ? dependency : obj);
6448 6456
6449 if (!is_external()) { 6457 if (!is_typed_elements()) {
6450 // I can detect the case between storing double (holey and fast) and 6458 // I can detect the case between storing double (holey and fast) and
6451 // smi/object by looking at elements_kind_. 6459 // smi/object by looking at elements_kind_.
6452 ASSERT(IsFastSmiOrObjectElementsKind(elements_kind) || 6460 ASSERT(IsFastSmiOrObjectElementsKind(elements_kind) ||
6453 IsFastDoubleElementsKind(elements_kind)); 6461 IsFastDoubleElementsKind(elements_kind));
6454 6462
6455 if (IsFastSmiOrObjectElementsKind(elements_kind)) { 6463 if (IsFastSmiOrObjectElementsKind(elements_kind)) {
6456 if (IsFastSmiElementsKind(elements_kind) && 6464 if (IsFastSmiElementsKind(elements_kind) &&
6457 (!IsHoleyElementsKind(elements_kind) || 6465 (!IsHoleyElementsKind(elements_kind) ||
6458 mode == NEVER_RETURN_HOLE)) { 6466 mode == NEVER_RETURN_HOLE)) {
6459 set_type(HType::Smi()); 6467 set_type(HType::Smi());
6460 if (SmiValuesAre32Bits() && !RequiresHoleCheck()) { 6468 if (SmiValuesAre32Bits() && !RequiresHoleCheck()) {
6461 set_representation(Representation::Integer32()); 6469 set_representation(Representation::Integer32());
6462 } else { 6470 } else {
6463 set_representation(Representation::Smi()); 6471 set_representation(Representation::Smi());
6464 } 6472 }
6465 } else { 6473 } else {
6466 set_representation(Representation::Tagged()); 6474 set_representation(Representation::Tagged());
6467 } 6475 }
6468 6476
6469 SetGVNFlag(kDependsOnArrayElements); 6477 SetGVNFlag(kDependsOnArrayElements);
6470 } else { 6478 } else {
6471 set_representation(Representation::Double()); 6479 set_representation(Representation::Double());
6472 SetGVNFlag(kDependsOnDoubleArrayElements); 6480 SetGVNFlag(kDependsOnDoubleArrayElements);
6473 } 6481 }
6474 } else { 6482 } else {
6475 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS || 6483 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS ||
6476 elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { 6484 elements_kind == EXTERNAL_DOUBLE_ELEMENTS ||
6485 elements_kind == FLOAT32_ELEMENTS ||
6486 elements_kind == FLOAT64_ELEMENTS) {
6477 set_representation(Representation::Double()); 6487 set_representation(Representation::Double());
6478 } else { 6488 } else {
6479 set_representation(Representation::Integer32()); 6489 set_representation(Representation::Integer32());
6480 } 6490 }
6481 6491
6482 SetGVNFlag(kDependsOnExternalMemory); 6492 if (is_external()) {
6493 SetGVNFlag(kDependsOnExternalMemory);
6494 } else if (is_fixed_typed_array()) {
6495 SetGVNFlag(kDependsOnTypedArrayElements);
6496 } else {
6497 UNREACHABLE();
6498 }
6483 // Native code could change the specialized array. 6499 // Native code could change the specialized array.
6484 SetGVNFlag(kDependsOnCalls); 6500 SetGVNFlag(kDependsOnCalls);
6485 } 6501 }
6486 6502
6487 SetFlag(kUseGVN); 6503 SetFlag(kUseGVN);
6488 } 6504 }
6489 6505
6490 virtual bool IsDeletable() const V8_OVERRIDE { 6506 virtual bool IsDeletable() const V8_OVERRIDE {
6491 return !RequiresHoleCheck(); 6507 return !RequiresHoleCheck();
6492 } 6508 }
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
6731 6747
6732 class HStoreKeyed V8_FINAL 6748 class HStoreKeyed V8_FINAL
6733 : public HTemplateInstruction<3>, public ArrayInstructionInterface { 6749 : public HTemplateInstruction<3>, public ArrayInstructionInterface {
6734 public: 6750 public:
6735 DECLARE_INSTRUCTION_FACTORY_P4(HStoreKeyed, HValue*, HValue*, HValue*, 6751 DECLARE_INSTRUCTION_FACTORY_P4(HStoreKeyed, HValue*, HValue*, HValue*,
6736 ElementsKind); 6752 ElementsKind);
6737 DECLARE_INSTRUCTION_FACTORY_P5(HStoreKeyed, HValue*, HValue*, HValue*, 6753 DECLARE_INSTRUCTION_FACTORY_P5(HStoreKeyed, HValue*, HValue*, HValue*,
6738 ElementsKind, StoreFieldOrKeyedMode); 6754 ElementsKind, StoreFieldOrKeyedMode);
6739 6755
6740 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { 6756 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
6741 // kind_fast: tagged[int32] = tagged 6757 // kind_fast: tagged[int32] = tagged
6742 // kind_double: tagged[int32] = double 6758 // kind_double: tagged[int32] = double
6743 // kind_smi : tagged[int32] = smi 6759 // kind_smi : tagged[int32] = smi
6744 // kind_external: external[int32] = (double | int32) 6760 // kind_fixed_typed_array: tagged[int32] = (double | int32)
6761 // kind_external: external[int32] = (double | int32)
6745 if (index == 0) { 6762 if (index == 0) {
6746 return is_external() ? Representation::External() 6763 return is_external() ? Representation::External()
6747 : Representation::Tagged(); 6764 : Representation::Tagged();
6748 } else if (index == 1) { 6765 } else if (index == 1) {
6749 return ArrayInstructionInterface::KeyedAccessIndexRequirement( 6766 return ArrayInstructionInterface::KeyedAccessIndexRequirement(
6750 OperandAt(1)->representation()); 6767 OperandAt(1)->representation());
6751 } 6768 }
6752 6769
6753 ASSERT_EQ(index, 2); 6770 ASSERT_EQ(index, 2);
6754 if (IsDoubleOrFloatElementsKind(elements_kind())) { 6771 if (IsDoubleOrFloatElementsKind(elements_kind())) {
6755 return Representation::Double(); 6772 return Representation::Double();
6756 } 6773 }
6757 if (SmiValuesAre32Bits() && store_mode_ == STORE_TO_INITIALIZED_ENTRY) { 6774 if (SmiValuesAre32Bits() && store_mode_ == STORE_TO_INITIALIZED_ENTRY) {
6758 return Representation::Integer32(); 6775 return Representation::Integer32();
6759 } 6776 }
6760 if (IsFastSmiElementsKind(elements_kind())) { 6777 if (IsFastSmiElementsKind(elements_kind())) {
6761 return Representation::Smi(); 6778 return Representation::Smi();
6762 } 6779 }
6763 6780
6764 return is_external() ? Representation::Integer32() 6781 return is_external() || is_fixed_typed_array()
6765 : Representation::Tagged(); 6782 ? Representation::Integer32()
6783 : Representation::Tagged();
6766 } 6784 }
6767 6785
6768 bool is_external() const { 6786 bool is_external() const {
6769 return IsExternalArrayElementsKind(elements_kind()); 6787 return IsExternalArrayElementsKind(elements_kind());
6770 } 6788 }
6771 6789
6790 bool is_fixed_typed_array() const {
6791 return IsFixedTypedArrayElementsKind(elements_kind());
6792 }
6793
6794 bool is_typed_elements() const {
6795 return is_external() || is_fixed_typed_array();
6796 }
6797
6772 virtual Representation observed_input_representation(int index) V8_OVERRIDE { 6798 virtual Representation observed_input_representation(int index) V8_OVERRIDE {
6773 if (index < 2) return RequiredInputRepresentation(index); 6799 if (index < 2) return RequiredInputRepresentation(index);
6774 if (IsUninitialized()) { 6800 if (IsUninitialized()) {
6775 return Representation::None(); 6801 return Representation::None();
6776 } 6802 }
6777 if (IsDoubleOrFloatElementsKind(elements_kind())) { 6803 if (IsDoubleOrFloatElementsKind(elements_kind())) {
6778 return Representation::Double(); 6804 return Representation::Double();
6779 } 6805 }
6780 if (SmiValuesAre32Bits() && store_mode_ == STORE_TO_INITIALIZED_ENTRY) { 6806 if (SmiValuesAre32Bits() && store_mode_ == STORE_TO_INITIALIZED_ENTRY) {
6781 return Representation::Integer32(); 6807 return Representation::Integer32();
6782 } 6808 }
6783 if (IsFastSmiElementsKind(elements_kind())) { 6809 if (IsFastSmiElementsKind(elements_kind())) {
6784 return Representation::Smi(); 6810 return Representation::Smi();
6785 } 6811 }
6786 if (is_external()) { 6812 if (is_typed_elements()) {
6787 return Representation::Integer32(); 6813 return Representation::Integer32();
6788 } 6814 }
6789 // For fast object elements kinds, don't assume anything. 6815 // For fast object elements kinds, don't assume anything.
6790 return Representation::None(); 6816 return Representation::None();
6791 } 6817 }
6792 6818
6793 HValue* elements() { return OperandAt(0); } 6819 HValue* elements() { return OperandAt(0); }
6794 HValue* key() { return OperandAt(1); } 6820 HValue* key() { return OperandAt(1); }
6795 HValue* value() { return OperandAt(2); } 6821 HValue* value() { return OperandAt(2); }
6796 bool value_is_smi() const { 6822 bool value_is_smi() const {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
6861 SetFlag(kTrackSideEffectDominators); 6887 SetFlag(kTrackSideEffectDominators);
6862 SetGVNFlag(kDependsOnNewSpacePromotion); 6888 SetGVNFlag(kDependsOnNewSpacePromotion);
6863 } 6889 }
6864 if (is_external()) { 6890 if (is_external()) {
6865 SetGVNFlag(kChangesExternalMemory); 6891 SetGVNFlag(kChangesExternalMemory);
6866 SetFlag(kAllowUndefinedAsNaN); 6892 SetFlag(kAllowUndefinedAsNaN);
6867 } else if (IsFastDoubleElementsKind(elements_kind)) { 6893 } else if (IsFastDoubleElementsKind(elements_kind)) {
6868 SetGVNFlag(kChangesDoubleArrayElements); 6894 SetGVNFlag(kChangesDoubleArrayElements);
6869 } else if (IsFastSmiElementsKind(elements_kind)) { 6895 } else if (IsFastSmiElementsKind(elements_kind)) {
6870 SetGVNFlag(kChangesArrayElements); 6896 SetGVNFlag(kChangesArrayElements);
6897 } else if (is_fixed_typed_array()) {
6898 SetGVNFlag(kChangesTypedArrayElements);
6899 SetFlag(kAllowUndefinedAsNaN);
6871 } else { 6900 } else {
6872 SetGVNFlag(kChangesArrayElements); 6901 SetGVNFlag(kChangesArrayElements);
6873 } 6902 }
6874 6903
6875 // EXTERNAL_{UNSIGNED_,}{BYTE,SHORT,INT}_ELEMENTS are truncating. 6904 // EXTERNAL_{UNSIGNED_,}{BYTE,SHORT,INT}_ELEMENTS are truncating.
6876 if (elements_kind >= EXTERNAL_BYTE_ELEMENTS && 6905 if ((elements_kind >= EXTERNAL_BYTE_ELEMENTS &&
6877 elements_kind <= EXTERNAL_UNSIGNED_INT_ELEMENTS) { 6906 elements_kind <= EXTERNAL_UNSIGNED_INT_ELEMENTS) ||
6907 (elements_kind >= UINT8_ELEMENTS &&
6908 elements_kind <= INT32_ELEMENTS)) {
6878 SetFlag(kTruncatingToInt32); 6909 SetFlag(kTruncatingToInt32);
6879 } 6910 }
6880 } 6911 }
6881 6912
6882 ElementsKind elements_kind_; 6913 ElementsKind elements_kind_;
6883 uint32_t index_offset_; 6914 uint32_t index_offset_;
6884 bool is_dehoisted_ : 1; 6915 bool is_dehoisted_ : 1;
6885 bool is_uninitialized_ : 1; 6916 bool is_uninitialized_ : 1;
6886 StoreFieldOrKeyedMode store_mode_: 1; 6917 StoreFieldOrKeyedMode store_mode_: 1;
6887 HValue* new_space_dominator_; 6918 HValue* new_space_dominator_;
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
7576 virtual bool IsDeletable() const V8_OVERRIDE { return true; } 7607 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
7577 }; 7608 };
7578 7609
7579 7610
7580 #undef DECLARE_INSTRUCTION 7611 #undef DECLARE_INSTRUCTION
7581 #undef DECLARE_CONCRETE_INSTRUCTION 7612 #undef DECLARE_CONCRETE_INSTRUCTION
7582 7613
7583 } } // namespace v8::internal 7614 } } // namespace v8::internal
7584 7615
7585 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 7616 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/ia32/lithium-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698