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

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

Issue 316023002: --debug-code: sanity-checking instrumentation for Lithium object accesses (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed Igor's comments Created 6 years, 6 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/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 "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/allocation.h" 10 #include "src/allocation.h"
(...skipping 5892 matching lines...) Expand 10 before | Expand all | Expand 10 after
5903 5903
5904 int slot_index_; 5904 int slot_index_;
5905 Mode mode_; 5905 Mode mode_;
5906 }; 5906 };
5907 5907
5908 5908
5909 // Represents an access to a portion of an object, such as the map pointer, 5909 // Represents an access to a portion of an object, such as the map pointer,
5910 // array elements pointer, etc, but not accesses to array elements themselves. 5910 // array elements pointer, etc, but not accesses to array elements themselves.
5911 class HObjectAccess V8_FINAL { 5911 class HObjectAccess V8_FINAL {
5912 public: 5912 public:
5913 enum Purpose {
5914 UNKNOWN_PURPOSE,
5915 FOR_ALLOCATION_MEMENTO_SITE,
5916 FOR_ALLOCATION_SITE_LIST,
5917 FOR_ALLOCATION_SITE_OFFSET,
5918 FOR_ARRAY_LENGTH,
5919 FOR_BACKING_STORE_OFFSET,
5920 FOR_CELL_PAYLOAD,
5921 FOR_CELL_VALUE,
5922 FOR_CODE_ENTRY_POINTER,
5923 FOR_CODE_OFFSET,
5924 FOR_CONS_STRING_FIRST,
5925 FOR_CONS_STRING_SECOND,
5926 FOR_CONTEXT_SLOT,
5927 FOR_COUNTER,
5928 FOR_ELEMENTS_POINTER,
5929 FOR_EXTERNAL_ARRAY_EXTERNAL_POINTER,
5930 FOR_FIELD,
5931 FOR_FIXED_ARRAY_HEADER,
5932 FOR_FIXED_ARRAY_LENGTH,
5933 FOR_FUNCTION_CONTEXT_POINTER,
5934 FOR_GLOBAL_OBJECT_NATIVE_CONTEXT,
5935 FOR_HEAP_NUMBER_VALUE_HIGHEST_BITS,
5936 FOR_HEAP_NUMBER_VALUE_LOWEST_BITS,
5937 FOR_HEAP_NUMBER_VALUE,
5938 FOR_JSARRAY_OFFSET,
5939 FOR_JSARRAYBUFFER_BACKING_STORE,
5940 FOR_JSARRAYBUFFER_BYTE_LENGTH,
5941 FOR_JSARRAYBUFFER_WEAK_FIRST_VIEW,
5942 FOR_JSARRAYBUFFERVIEW_BUFFER,
5943 FOR_JSARRAYBUFFERVIEW_BYTE_LENGTH,
5944 FOR_JSARRAYBUFFERVIEW_BYTE_OFFSET,
5945 FOR_JSARRAYBUFFERVIEW_WEAK_NEXT,
5946 FOR_JSTYPEDARRAY_LENGTH,
5947 FOR_LITERALS_POINTER,
5948 FOR_MAP_INSTANCE_SIZE,
5949 FOR_MAP_INSTANCE_TYPE,
5950 FOR_MAP,
5951 FOR_NEXT_FUNCTION_LINK_POINTER,
5952 FOR_OPTIMIZED_CODE_MAP,
5953 FOR_PROPERTIES_POINTER,
5954 FOR_PROPERTY_CELL_VALUE,
5955 FOR_PROTOTYPE_OR_INITIAL_MAP,
5956 FOR_SHARED_FUNCTION_INFO_POINTER,
5957 FOR_STRING_HASH_FIELD,
5958 FOR_STRING_LENGTH
5959 };
5913 inline bool IsInobject() const { 5960 inline bool IsInobject() const {
5914 return portion() != kBackingStore && portion() != kExternalMemory; 5961 return portion() != kBackingStore && portion() != kExternalMemory;
5915 } 5962 }
5916 5963
5917 inline bool IsExternalMemory() const { 5964 inline bool IsExternalMemory() const {
5918 return portion() == kExternalMemory; 5965 return portion() == kExternalMemory;
5919 } 5966 }
5920 5967
5921 inline bool IsStringLength() const { 5968 inline bool IsStringLength() const {
5922 return portion() == kStringLengths; 5969 return portion() == kStringLengths;
(...skipping 19 matching lines...) Expand all
5942 return ImmutableField::decode(value_); 5989 return ImmutableField::decode(value_);
5943 } 5990 }
5944 5991
5945 // Returns true if access is being made to an in-object property that 5992 // Returns true if access is being made to an in-object property that
5946 // was already added to the object. 5993 // was already added to the object.
5947 inline bool existing_inobject_property() const { 5994 inline bool existing_inobject_property() const {
5948 return ExistingInobjectPropertyField::decode(value_); 5995 return ExistingInobjectPropertyField::decode(value_);
5949 } 5996 }
5950 5997
5951 inline HObjectAccess WithRepresentation(Representation representation) { 5998 inline HObjectAccess WithRepresentation(Representation representation) {
5952 return HObjectAccess(portion(), offset(), representation, name(), 5999 Purpose p =
6000 #ifdef DEBUG
6001 purpose();
6002 #else
6003 UNKNOWN_PURPOSE;
6004 #endif
6005 return HObjectAccess(portion(), offset(), p, representation, name(),
5953 immutable(), existing_inobject_property()); 6006 immutable(), existing_inobject_property());
5954 } 6007 }
5955 6008
5956 static HObjectAccess ForHeapNumberValue() { 6009 static HObjectAccess ForHeapNumberValue() {
5957 return HObjectAccess( 6010 return HObjectAccess(
5958 kDouble, HeapNumber::kValueOffset, Representation::Double()); 6011 kDouble, HeapNumber::kValueOffset, FOR_HEAP_NUMBER_VALUE,
6012 Representation::Double());
5959 } 6013 }
5960 6014
5961 static HObjectAccess ForHeapNumberValueLowestBits() { 6015 static HObjectAccess ForHeapNumberValueLowestBits() {
5962 return HObjectAccess(kDouble, 6016 return HObjectAccess(kDouble,
5963 HeapNumber::kValueOffset, 6017 HeapNumber::kValueOffset,
6018 FOR_HEAP_NUMBER_VALUE_LOWEST_BITS,
5964 Representation::Integer32()); 6019 Representation::Integer32());
5965 } 6020 }
5966 6021
5967 static HObjectAccess ForHeapNumberValueHighestBits() { 6022 static HObjectAccess ForHeapNumberValueHighestBits() {
5968 return HObjectAccess(kDouble, 6023 return HObjectAccess(kDouble,
5969 HeapNumber::kValueOffset + kIntSize, 6024 HeapNumber::kValueOffset + kIntSize,
6025 FOR_HEAP_NUMBER_VALUE_HIGHEST_BITS,
5970 Representation::Integer32()); 6026 Representation::Integer32());
5971 } 6027 }
5972 6028
5973 static HObjectAccess ForElementsPointer() { 6029 static HObjectAccess ForElementsPointer() {
5974 return HObjectAccess(kElementsPointer, JSObject::kElementsOffset); 6030 return HObjectAccess(kElementsPointer, JSObject::kElementsOffset,
6031 FOR_ELEMENTS_POINTER);
5975 } 6032 }
5976 6033
5977 static HObjectAccess ForLiteralsPointer() { 6034 static HObjectAccess ForLiteralsPointer() {
5978 return HObjectAccess(kInobject, JSFunction::kLiteralsOffset); 6035 return HObjectAccess(kInobject, JSFunction::kLiteralsOffset,
6036 FOR_LITERALS_POINTER);
5979 } 6037 }
5980 6038
5981 static HObjectAccess ForNextFunctionLinkPointer() { 6039 static HObjectAccess ForNextFunctionLinkPointer() {
5982 return HObjectAccess(kInobject, JSFunction::kNextFunctionLinkOffset); 6040 return HObjectAccess(kInobject, JSFunction::kNextFunctionLinkOffset,
6041 FOR_NEXT_FUNCTION_LINK_POINTER);
5983 } 6042 }
5984 6043
5985 static HObjectAccess ForArrayLength(ElementsKind elements_kind) { 6044 static HObjectAccess ForArrayLength(ElementsKind elements_kind) {
5986 return HObjectAccess( 6045 return HObjectAccess(
5987 kArrayLengths, 6046 kArrayLengths,
5988 JSArray::kLengthOffset, 6047 JSArray::kLengthOffset,
6048 FOR_ARRAY_LENGTH,
5989 IsFastElementsKind(elements_kind) 6049 IsFastElementsKind(elements_kind)
5990 ? Representation::Smi() : Representation::Tagged()); 6050 ? Representation::Smi() : Representation::Tagged());
5991 } 6051 }
5992 6052
5993 static HObjectAccess ForAllocationSiteOffset(int offset); 6053 static HObjectAccess ForAllocationSiteOffset(int offset);
5994 6054
5995 static HObjectAccess ForAllocationSiteList() { 6055 static HObjectAccess ForAllocationSiteList() {
5996 return HObjectAccess(kExternalMemory, 0, Representation::Tagged(), 6056 return HObjectAccess(kExternalMemory, 0, FOR_ALLOCATION_SITE_LIST,
6057 Representation::Tagged(),
5997 Handle<String>::null(), false, false); 6058 Handle<String>::null(), false, false);
5998 } 6059 }
5999 6060
6000 static HObjectAccess ForFixedArrayLength() { 6061 static HObjectAccess ForFixedArrayLength() {
6001 return HObjectAccess( 6062 return HObjectAccess(kArrayLengths, FixedArray::kLengthOffset,
6002 kArrayLengths, 6063 FOR_FIXED_ARRAY_LENGTH, Representation::Smi());
6003 FixedArray::kLengthOffset,
6004 Representation::Smi());
6005 } 6064 }
6006 6065
6007 static HObjectAccess ForStringHashField() { 6066 static HObjectAccess ForStringHashField() {
6008 return HObjectAccess(kInobject, 6067 return HObjectAccess(kInobject, String::kHashFieldOffset,
6009 String::kHashFieldOffset, 6068 FOR_STRING_HASH_FIELD, Representation::Integer32());
6010 Representation::Integer32());
6011 } 6069 }
6012 6070
6013 static HObjectAccess ForStringLength() { 6071 static HObjectAccess ForStringLength() {
6014 STATIC_ASSERT(String::kMaxLength <= Smi::kMaxValue); 6072 STATIC_ASSERT(String::kMaxLength <= Smi::kMaxValue);
6015 return HObjectAccess( 6073 return HObjectAccess(kStringLengths, String::kLengthOffset,
6016 kStringLengths, 6074 FOR_STRING_LENGTH, Representation::Smi());
6017 String::kLengthOffset,
6018 Representation::Smi());
6019 } 6075 }
6020 6076
6021 static HObjectAccess ForConsStringFirst() { 6077 static HObjectAccess ForConsStringFirst() {
6022 return HObjectAccess(kInobject, ConsString::kFirstOffset); 6078 return HObjectAccess(kInobject, ConsString::kFirstOffset,
6079 FOR_CONS_STRING_FIRST);
6023 } 6080 }
6024 6081
6025 static HObjectAccess ForConsStringSecond() { 6082 static HObjectAccess ForConsStringSecond() {
6026 return HObjectAccess(kInobject, ConsString::kSecondOffset); 6083 return HObjectAccess(kInobject, ConsString::kSecondOffset,
6084 FOR_CONS_STRING_SECOND);
6027 } 6085 }
6028 6086
6029 static HObjectAccess ForPropertiesPointer() { 6087 static HObjectAccess ForPropertiesPointer() {
6030 return HObjectAccess(kInobject, JSObject::kPropertiesOffset); 6088 return HObjectAccess(kInobject, JSObject::kPropertiesOffset,
6089 FOR_PROPERTIES_POINTER);
6031 } 6090 }
6032 6091
6033 static HObjectAccess ForPrototypeOrInitialMap() { 6092 static HObjectAccess ForPrototypeOrInitialMap() {
6034 return HObjectAccess(kInobject, JSFunction::kPrototypeOrInitialMapOffset); 6093 return HObjectAccess(kInobject, JSFunction::kPrototypeOrInitialMapOffset,
6094 FOR_PROTOTYPE_OR_INITIAL_MAP);
6035 } 6095 }
6036 6096
6037 static HObjectAccess ForSharedFunctionInfoPointer() { 6097 static HObjectAccess ForSharedFunctionInfoPointer() {
6038 return HObjectAccess(kInobject, JSFunction::kSharedFunctionInfoOffset); 6098 return HObjectAccess(kInobject, JSFunction::kSharedFunctionInfoOffset,
6099 FOR_SHARED_FUNCTION_INFO_POINTER);
6039 } 6100 }
6040 6101
6041 static HObjectAccess ForCodeEntryPointer() { 6102 static HObjectAccess ForCodeEntryPointer() {
6042 return HObjectAccess(kInobject, JSFunction::kCodeEntryOffset); 6103 return HObjectAccess(kInobject, JSFunction::kCodeEntryOffset,
6104 FOR_CODE_ENTRY_POINTER);
6043 } 6105 }
6044 6106
6045 static HObjectAccess ForCodeOffset() { 6107 static HObjectAccess ForCodeOffset() {
6046 return HObjectAccess(kInobject, SharedFunctionInfo::kCodeOffset); 6108 return HObjectAccess(kInobject, SharedFunctionInfo::kCodeOffset,
6109 FOR_CODE_OFFSET);
6047 } 6110 }
6048 6111
6049 static HObjectAccess ForOptimizedCodeMap() { 6112 static HObjectAccess ForOptimizedCodeMap() {
6050 return HObjectAccess(kInobject, 6113 return HObjectAccess(kInobject,
6051 SharedFunctionInfo::kOptimizedCodeMapOffset); 6114 SharedFunctionInfo::kOptimizedCodeMapOffset,
6115 FOR_OPTIMIZED_CODE_MAP);
6052 } 6116 }
6053 6117
6054 static HObjectAccess ForFunctionContextPointer() { 6118 static HObjectAccess ForFunctionContextPointer() {
6055 return HObjectAccess(kInobject, JSFunction::kContextOffset); 6119 return HObjectAccess(kInobject, JSFunction::kContextOffset,
6120 FOR_FUNCTION_CONTEXT_POINTER);
6056 } 6121 }
6057 6122
6058 static HObjectAccess ForMap() { 6123 static HObjectAccess ForMap() {
6059 return HObjectAccess(kMaps, JSObject::kMapOffset); 6124 return HObjectAccess(kMaps, JSObject::kMapOffset, FOR_MAP);
6060 } 6125 }
6061 6126
6062 static HObjectAccess ForMapInstanceSize() { 6127 static HObjectAccess ForMapInstanceSize() {
6063 return HObjectAccess(kInobject, 6128 return HObjectAccess(kInobject,
6064 Map::kInstanceSizeOffset, 6129 Map::kInstanceSizeOffset,
6130 FOR_MAP_INSTANCE_SIZE,
6065 Representation::UInteger8()); 6131 Representation::UInteger8());
6066 } 6132 }
6067 6133
6068 static HObjectAccess ForMapInstanceType() { 6134 static HObjectAccess ForMapInstanceType() {
6069 return HObjectAccess(kInobject, 6135 return HObjectAccess(kInobject,
6070 Map::kInstanceTypeOffset, 6136 Map::kInstanceTypeOffset,
6137 FOR_MAP_INSTANCE_TYPE,
6071 Representation::UInteger8()); 6138 Representation::UInteger8());
6072 } 6139 }
6073 6140
6074 static HObjectAccess ForPropertyCellValue() { 6141 static HObjectAccess ForPropertyCellValue() {
6075 return HObjectAccess(kInobject, PropertyCell::kValueOffset); 6142 return HObjectAccess(kInobject, PropertyCell::kValueOffset,
6143 FOR_PROPERTY_CELL_VALUE);
6076 } 6144 }
6077 6145
6078 static HObjectAccess ForCellValue() { 6146 static HObjectAccess ForCellValue() {
6079 return HObjectAccess(kInobject, Cell::kValueOffset); 6147 return HObjectAccess(kInobject, Cell::kValueOffset, FOR_CELL_VALUE);
6080 } 6148 }
6081 6149
6082 static HObjectAccess ForAllocationMementoSite() { 6150 static HObjectAccess ForAllocationMementoSite() {
6083 return HObjectAccess(kInobject, AllocationMemento::kAllocationSiteOffset); 6151 return HObjectAccess(kInobject, AllocationMemento::kAllocationSiteOffset,
6152 FOR_ALLOCATION_MEMENTO_SITE);
6084 } 6153 }
6085 6154
6086 static HObjectAccess ForCounter() { 6155 static HObjectAccess ForCounter() {
6087 return HObjectAccess(kExternalMemory, 0, Representation::Integer32(), 6156 return HObjectAccess(kExternalMemory, 0, FOR_COUNTER,
6157 Representation::Integer32(),
6088 Handle<String>::null(), false, false); 6158 Handle<String>::null(), false, false);
6089 } 6159 }
6090 6160
6091 // Create an access to an offset in a fixed array header. 6161 // Create an access to an offset in a fixed array header.
6092 static HObjectAccess ForFixedArrayHeader(int offset); 6162 static HObjectAccess ForFixedArrayHeader(int offset);
6093 6163
6094 // Create an access to an in-object property in a JSObject. 6164 // Create an access to an in-object property in a JSObject.
6095 // This kind of access must be used when the object |map| is known and 6165 // This kind of access must be used when the object |map| is known and
6096 // in-object properties are being accessed. Accesses of the in-object 6166 // in-object properties are being accessed. Accesses of the in-object
6097 // properties can have different semantics depending on whether corresponding 6167 // properties can have different semantics depending on whether corresponding
6098 // property was added to the map or not. 6168 // property was added to the map or not.
6099 static HObjectAccess ForMapAndOffset(Handle<Map> map, int offset, 6169 static HObjectAccess ForMapAndOffset(Handle<Map> map, int offset,
6170 Purpose purpose = FOR_FIELD,
6100 Representation representation = Representation::Tagged()); 6171 Representation representation = Representation::Tagged());
6101 6172
6102 // Create an access to an in-object property in a JSObject. 6173 // Create an access to an in-object property in a JSObject.
6103 // This kind of access can be used for accessing object header fields or 6174 // This kind of access can be used for accessing object header fields or
6104 // in-object properties if the map of the object is not known. 6175 // in-object properties if the map of the object is not known.
6105 static HObjectAccess ForObservableJSObjectOffset(int offset, 6176 static HObjectAccess ForObservableJSObjectOffset(int offset,
6177 Purpose purpose = FOR_FIELD,
6106 Representation representation = Representation::Tagged()) { 6178 Representation representation = Representation::Tagged()) {
6107 return ForMapAndOffset(Handle<Map>::null(), offset, representation); 6179 return ForMapAndOffset(Handle<Map>::null(), offset, purpose,
6180 representation);
6108 } 6181 }
6109 6182
6110 // Create an access to an in-object property in a JSArray. 6183 // Create an access to an in-object property in a JSArray.
6111 static HObjectAccess ForJSArrayOffset(int offset); 6184 static HObjectAccess ForJSArrayOffset(int offset);
6112 6185
6113 static HObjectAccess ForContextSlot(int index); 6186 static HObjectAccess ForContextSlot(int index);
6114 6187
6115 // Create an access to the backing store of an object. 6188 // Create an access to the backing store of an object.
6116 static HObjectAccess ForBackingStoreOffset(int offset, 6189 static HObjectAccess ForBackingStoreOffset(int offset,
6117 Representation representation = Representation::Tagged()); 6190 Representation representation = Representation::Tagged());
6118 6191
6119 // Create an access to a resolved field (in-object or backing store). 6192 // Create an access to a resolved field (in-object or backing store).
6120 static HObjectAccess ForField(Handle<Map> map, 6193 static HObjectAccess ForField(Handle<Map> map,
6121 LookupResult *lookup, Handle<String> name = Handle<String>::null()); 6194 LookupResult *lookup, Handle<String> name = Handle<String>::null());
6122 6195
6123 // Create an access for the payload of a Cell or JSGlobalPropertyCell. 6196 // Create an access for the payload of a Cell or JSGlobalPropertyCell.
6124 static HObjectAccess ForCellPayload(Isolate* isolate); 6197 static HObjectAccess ForCellPayload(Isolate* isolate);
6125 6198
6126 static HObjectAccess ForJSTypedArrayLength() { 6199 static HObjectAccess ForJSTypedArrayLength() {
6127 return HObjectAccess::ForObservableJSObjectOffset( 6200 return HObjectAccess(
6128 JSTypedArray::kLengthOffset); 6201 kInobject, JSTypedArray::kLengthOffset, FOR_JSTYPEDARRAY_LENGTH);
6129 } 6202 }
6130 6203
6131 static HObjectAccess ForJSArrayBufferBackingStore() { 6204 static HObjectAccess ForJSArrayBufferBackingStore() {
6132 return HObjectAccess::ForObservableJSObjectOffset( 6205 return HObjectAccess(
6133 JSArrayBuffer::kBackingStoreOffset, Representation::External()); 6206 kInobject, JSArrayBuffer::kBackingStoreOffset,
6207 FOR_JSARRAYBUFFER_BACKING_STORE, Representation::External());
6134 } 6208 }
6135 6209
6136 static HObjectAccess ForJSArrayBufferByteLength() { 6210 static HObjectAccess ForJSArrayBufferByteLength() {
6137 return HObjectAccess::ForObservableJSObjectOffset( 6211 return HObjectAccess(
6138 JSArrayBuffer::kByteLengthOffset, Representation::Tagged()); 6212 kInobject, JSArrayBuffer::kByteLengthOffset,
6213 FOR_JSARRAYBUFFER_BYTE_LENGTH);
6139 } 6214 }
6140 6215
6141 static HObjectAccess ForExternalArrayExternalPointer() { 6216 static HObjectAccess ForExternalArrayExternalPointer() {
6142 return HObjectAccess::ForObservableJSObjectOffset( 6217 return HObjectAccess(
6143 ExternalArray::kExternalPointerOffset, Representation::External()); 6218 kInobject, ExternalArray::kExternalPointerOffset,
6219 FOR_EXTERNAL_ARRAY_EXTERNAL_POINTER, Representation::External());
6144 } 6220 }
6145 6221
6146 static HObjectAccess ForJSArrayBufferViewWeakNext() { 6222 static HObjectAccess ForJSArrayBufferViewWeakNext() {
6147 return HObjectAccess::ForObservableJSObjectOffset( 6223 return HObjectAccess(
6148 JSArrayBufferView::kWeakNextOffset); 6224 kInobject, JSArrayBufferView::kWeakNextOffset,
6225 FOR_JSARRAYBUFFERVIEW_WEAK_NEXT);
6149 } 6226 }
6150 6227
6151 static HObjectAccess ForJSArrayBufferWeakFirstView() { 6228 static HObjectAccess ForJSArrayBufferWeakFirstView() {
6152 return HObjectAccess::ForObservableJSObjectOffset( 6229 return HObjectAccess(
6153 JSArrayBuffer::kWeakFirstViewOffset); 6230 kInobject, JSArrayBuffer::kWeakFirstViewOffset,
6231 FOR_JSARRAYBUFFER_WEAK_FIRST_VIEW);
6154 } 6232 }
6155 6233
6156 static HObjectAccess ForJSArrayBufferViewBuffer() { 6234 static HObjectAccess ForJSArrayBufferViewBuffer() {
6157 return HObjectAccess::ForObservableJSObjectOffset( 6235 return HObjectAccess(
6158 JSArrayBufferView::kBufferOffset); 6236 kInobject, JSArrayBufferView::kBufferOffset,
6237 FOR_JSARRAYBUFFERVIEW_BUFFER);
6159 } 6238 }
6160 6239
6161 static HObjectAccess ForJSArrayBufferViewByteOffset() { 6240 static HObjectAccess ForJSArrayBufferViewByteOffset() {
6162 return HObjectAccess::ForObservableJSObjectOffset( 6241 return HObjectAccess(
6163 JSArrayBufferView::kByteOffsetOffset); 6242 kInobject, JSArrayBufferView::kByteOffsetOffset,
6243 FOR_JSARRAYBUFFERVIEW_BYTE_OFFSET);
6164 } 6244 }
6165 6245
6166 static HObjectAccess ForJSArrayBufferViewByteLength() { 6246 static HObjectAccess ForJSArrayBufferViewByteLength() {
6167 return HObjectAccess::ForObservableJSObjectOffset( 6247 return HObjectAccess(
6168 JSArrayBufferView::kByteLengthOffset); 6248 kInobject, JSArrayBufferView::kByteLengthOffset,
6249 FOR_JSARRAYBUFFERVIEW_BYTE_LENGTH);
6169 } 6250 }
6170 6251
6171 static HObjectAccess ForGlobalObjectNativeContext() { 6252 static HObjectAccess ForGlobalObjectNativeContext() {
6172 return HObjectAccess(kInobject, GlobalObject::kNativeContextOffset); 6253 return HObjectAccess(kInobject, GlobalObject::kNativeContextOffset,
6254 FOR_GLOBAL_OBJECT_NATIVE_CONTEXT);
6173 } 6255 }
6174 6256
6175 void PrintTo(StringStream* stream) const; 6257 void PrintTo(StringStream* stream) const;
6176 6258
6177 inline bool Equals(HObjectAccess that) const { 6259 inline bool Equals(HObjectAccess that) const {
6178 return value_ == that.value_; // portion and offset must match 6260 return value_ == that.value_; // portion and offset must match
6179 } 6261 }
6180 6262
6263 #ifdef DEBUG
6264 Purpose purpose() const { return purpose_; }
6265 #endif
6266
6181 protected: 6267 protected:
6182 void SetGVNFlags(HValue *instr, PropertyAccessType access_type); 6268 void SetGVNFlags(HValue *instr, PropertyAccessType access_type);
6183 6269
6184 private: 6270 private:
6185 // internal use only; different parts of an object or array 6271 // internal use only; different parts of an object or array
6186 enum Portion { 6272 enum Portion {
6187 kMaps, // map of an object 6273 kMaps, // map of an object
6188 kArrayLengths, // the length of an array 6274 kArrayLengths, // the length of an array
6189 kStringLengths, // the length of a string 6275 kStringLengths, // the length of a string
6190 kElementsPointer, // elements pointer 6276 kElementsPointer, // elements pointer
6191 kBackingStore, // some field in the backing store 6277 kBackingStore, // some field in the backing store
6192 kDouble, // some double field 6278 kDouble, // some double field
6193 kInobject, // some other in-object field 6279 kInobject, // some other in-object field
6194 kExternalMemory // some field in external memory 6280 kExternalMemory // some field in external memory
6195 }; 6281 };
6196 6282
6197 HObjectAccess() : value_(0) {} 6283 HObjectAccess() : value_(0) {}
6198 6284
6199 HObjectAccess(Portion portion, int offset, 6285 HObjectAccess(Portion portion, int offset, Purpose purpose,
6200 Representation representation = Representation::Tagged(), 6286 Representation representation = Representation::Tagged(),
6201 Handle<String> name = Handle<String>::null(), 6287 Handle<String> name = Handle<String>::null(),
6202 bool immutable = false, 6288 bool immutable = false,
6203 bool existing_inobject_property = true) 6289 bool existing_inobject_property = true)
6204 : value_(PortionField::encode(portion) | 6290 : value_(PortionField::encode(portion) |
6205 RepresentationField::encode(representation.kind()) | 6291 RepresentationField::encode(representation.kind()) |
6206 ImmutableField::encode(immutable ? 1 : 0) | 6292 ImmutableField::encode(immutable ? 1 : 0) |
6207 ExistingInobjectPropertyField::encode( 6293 ExistingInobjectPropertyField::encode(
6208 existing_inobject_property ? 1 : 0) | 6294 existing_inobject_property ? 1 : 0) |
6209 OffsetField::encode(offset)), 6295 OffsetField::encode(offset)),
6210 name_(name) { 6296 #ifdef DEBUG
6297 purpose_(purpose),
6298 #endif
6299 name_(name) {
6211 // assert that the fields decode correctly 6300 // assert that the fields decode correctly
6212 ASSERT(this->offset() == offset); 6301 ASSERT(this->offset() == offset);
6213 ASSERT(this->portion() == portion); 6302 ASSERT(this->portion() == portion);
6214 ASSERT(this->immutable() == immutable); 6303 ASSERT(this->immutable() == immutable);
6215 ASSERT(this->existing_inobject_property() == existing_inobject_property); 6304 ASSERT(this->existing_inobject_property() == existing_inobject_property);
6216 ASSERT(RepresentationField::decode(value_) == representation.kind()); 6305 ASSERT(this->representation().Equals(representation));
6217 ASSERT(!this->existing_inobject_property() || IsInobject()); 6306 ASSERT(!this->existing_inobject_property() || IsInobject());
6218 } 6307 }
6219 6308
6220 class PortionField : public BitField<Portion, 0, 3> {}; 6309 class PortionField : public BitField<Portion, 0, 3> {};
6221 class RepresentationField : public BitField<Representation::Kind, 3, 4> {}; 6310 class RepresentationField : public BitField<Representation::Kind, 3, 4> {};
6222 class ImmutableField : public BitField<bool, 7, 1> {}; 6311 class ImmutableField : public BitField<bool, 7, 1> {};
6223 class ExistingInobjectPropertyField : public BitField<bool, 8, 1> {}; 6312 class ExistingInobjectPropertyField : public BitField<bool, 8, 1> {};
6224 class OffsetField : public BitField<int, 9, 23> {}; 6313 class OffsetField : public BitField<int, 9, 23> {};
6225 6314
6226 uint32_t value_; // encodes portion, representation, immutable, and offset 6315 uint32_t value_; // encodes portion, representation, immutable, and offset
6316 #ifdef DEBUG
6317 Purpose purpose_;
6318 #endif
6227 Handle<String> name_; 6319 Handle<String> name_;
6228 6320
6229 friend class HLoadNamedField; 6321 friend class HLoadNamedField;
6230 friend class HStoreNamedField; 6322 friend class HStoreNamedField;
6231 friend class SideEffectsTracker; 6323 friend class SideEffectsTracker;
6232 6324
6233 inline Portion portion() const { 6325 inline Portion portion() const {
6234 return PortionField::decode(value_); 6326 return PortionField::decode(value_);
6235 } 6327 }
6236 }; 6328 };
(...skipping 1479 matching lines...) Expand 10 before | Expand all | Expand 10 after
7716 virtual bool IsDeletable() const V8_OVERRIDE { return true; } 7808 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
7717 }; 7809 };
7718 7810
7719 7811
7720 #undef DECLARE_INSTRUCTION 7812 #undef DECLARE_INSTRUCTION
7721 #undef DECLARE_CONCRETE_INSTRUCTION 7813 #undef DECLARE_CONCRETE_INSTRUCTION
7722 7814
7723 } } // namespace v8::internal 7815 } } // namespace v8::internal
7724 7816
7725 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 7817 #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