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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/hydrogen.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen-instructions.h
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h
index 9e6f0f0c1cd380dd41eb6c592e8140577a09c10b..a2ad3e5bd13d2b22b372e1d8133be258f1ee5e77 100644
--- a/src/hydrogen-instructions.h
+++ b/src/hydrogen-instructions.h
@@ -5910,6 +5910,53 @@ class HStoreContextSlot V8_FINAL : public HTemplateInstruction<2> {
// array elements pointer, etc, but not accesses to array elements themselves.
class HObjectAccess V8_FINAL {
public:
+ enum Purpose {
+ UNKNOWN_PURPOSE,
+ FOR_ALLOCATION_MEMENTO_SITE,
+ FOR_ALLOCATION_SITE_LIST,
+ FOR_ALLOCATION_SITE_OFFSET,
+ FOR_ARRAY_LENGTH,
+ FOR_BACKING_STORE_OFFSET,
+ FOR_CELL_PAYLOAD,
+ FOR_CELL_VALUE,
+ FOR_CODE_ENTRY_POINTER,
+ FOR_CODE_OFFSET,
+ FOR_CONS_STRING_FIRST,
+ FOR_CONS_STRING_SECOND,
+ FOR_CONTEXT_SLOT,
+ FOR_COUNTER,
+ FOR_ELEMENTS_POINTER,
+ FOR_EXTERNAL_ARRAY_EXTERNAL_POINTER,
+ FOR_FIELD,
+ FOR_FIXED_ARRAY_HEADER,
+ FOR_FIXED_ARRAY_LENGTH,
+ FOR_FUNCTION_CONTEXT_POINTER,
+ FOR_GLOBAL_OBJECT_NATIVE_CONTEXT,
+ FOR_HEAP_NUMBER_VALUE_HIGHEST_BITS,
+ FOR_HEAP_NUMBER_VALUE_LOWEST_BITS,
+ FOR_HEAP_NUMBER_VALUE,
+ FOR_JSARRAY_OFFSET,
+ FOR_JSARRAYBUFFER_BACKING_STORE,
+ FOR_JSARRAYBUFFER_BYTE_LENGTH,
+ FOR_JSARRAYBUFFER_WEAK_FIRST_VIEW,
+ FOR_JSARRAYBUFFERVIEW_BUFFER,
+ FOR_JSARRAYBUFFERVIEW_BYTE_LENGTH,
+ FOR_JSARRAYBUFFERVIEW_BYTE_OFFSET,
+ FOR_JSARRAYBUFFERVIEW_WEAK_NEXT,
+ FOR_JSTYPEDARRAY_LENGTH,
+ FOR_LITERALS_POINTER,
+ FOR_MAP_INSTANCE_SIZE,
+ FOR_MAP_INSTANCE_TYPE,
+ FOR_MAP,
+ FOR_NEXT_FUNCTION_LINK_POINTER,
+ FOR_OPTIMIZED_CODE_MAP,
+ FOR_PROPERTIES_POINTER,
+ FOR_PROPERTY_CELL_VALUE,
+ FOR_PROTOTYPE_OR_INITIAL_MAP,
+ FOR_SHARED_FUNCTION_INFO_POINTER,
+ FOR_STRING_HASH_FIELD,
+ FOR_STRING_LENGTH
+ };
inline bool IsInobject() const {
return portion() != kBackingStore && portion() != kExternalMemory;
}
@@ -5949,43 +5996,56 @@ class HObjectAccess V8_FINAL {
}
inline HObjectAccess WithRepresentation(Representation representation) {
- return HObjectAccess(portion(), offset(), representation, name(),
+ Purpose p =
+#ifdef DEBUG
+ purpose();
+#else
+ UNKNOWN_PURPOSE;
+#endif
+ return HObjectAccess(portion(), offset(), p, representation, name(),
immutable(), existing_inobject_property());
}
static HObjectAccess ForHeapNumberValue() {
return HObjectAccess(
- kDouble, HeapNumber::kValueOffset, Representation::Double());
+ kDouble, HeapNumber::kValueOffset, FOR_HEAP_NUMBER_VALUE,
+ Representation::Double());
}
static HObjectAccess ForHeapNumberValueLowestBits() {
return HObjectAccess(kDouble,
HeapNumber::kValueOffset,
+ FOR_HEAP_NUMBER_VALUE_LOWEST_BITS,
Representation::Integer32());
}
static HObjectAccess ForHeapNumberValueHighestBits() {
return HObjectAccess(kDouble,
HeapNumber::kValueOffset + kIntSize,
+ FOR_HEAP_NUMBER_VALUE_HIGHEST_BITS,
Representation::Integer32());
}
static HObjectAccess ForElementsPointer() {
- return HObjectAccess(kElementsPointer, JSObject::kElementsOffset);
+ return HObjectAccess(kElementsPointer, JSObject::kElementsOffset,
+ FOR_ELEMENTS_POINTER);
}
static HObjectAccess ForLiteralsPointer() {
- return HObjectAccess(kInobject, JSFunction::kLiteralsOffset);
+ return HObjectAccess(kInobject, JSFunction::kLiteralsOffset,
+ FOR_LITERALS_POINTER);
}
static HObjectAccess ForNextFunctionLinkPointer() {
- return HObjectAccess(kInobject, JSFunction::kNextFunctionLinkOffset);
+ return HObjectAccess(kInobject, JSFunction::kNextFunctionLinkOffset,
+ FOR_NEXT_FUNCTION_LINK_POINTER);
}
static HObjectAccess ForArrayLength(ElementsKind elements_kind) {
return HObjectAccess(
kArrayLengths,
JSArray::kLengthOffset,
+ FOR_ARRAY_LENGTH,
IsFastElementsKind(elements_kind)
? Representation::Smi() : Representation::Tagged());
}
@@ -5993,98 +6053,108 @@ class HObjectAccess V8_FINAL {
static HObjectAccess ForAllocationSiteOffset(int offset);
static HObjectAccess ForAllocationSiteList() {
- return HObjectAccess(kExternalMemory, 0, Representation::Tagged(),
+ return HObjectAccess(kExternalMemory, 0, FOR_ALLOCATION_SITE_LIST,
+ Representation::Tagged(),
Handle<String>::null(), false, false);
}
static HObjectAccess ForFixedArrayLength() {
- return HObjectAccess(
- kArrayLengths,
- FixedArray::kLengthOffset,
- Representation::Smi());
+ return HObjectAccess(kArrayLengths, FixedArray::kLengthOffset,
+ FOR_FIXED_ARRAY_LENGTH, Representation::Smi());
}
static HObjectAccess ForStringHashField() {
- return HObjectAccess(kInobject,
- String::kHashFieldOffset,
- Representation::Integer32());
+ return HObjectAccess(kInobject, String::kHashFieldOffset,
+ FOR_STRING_HASH_FIELD, Representation::Integer32());
}
static HObjectAccess ForStringLength() {
STATIC_ASSERT(String::kMaxLength <= Smi::kMaxValue);
- return HObjectAccess(
- kStringLengths,
- String::kLengthOffset,
- Representation::Smi());
+ return HObjectAccess(kStringLengths, String::kLengthOffset,
+ FOR_STRING_LENGTH, Representation::Smi());
}
static HObjectAccess ForConsStringFirst() {
- return HObjectAccess(kInobject, ConsString::kFirstOffset);
+ return HObjectAccess(kInobject, ConsString::kFirstOffset,
+ FOR_CONS_STRING_FIRST);
}
static HObjectAccess ForConsStringSecond() {
- return HObjectAccess(kInobject, ConsString::kSecondOffset);
+ return HObjectAccess(kInobject, ConsString::kSecondOffset,
+ FOR_CONS_STRING_SECOND);
}
static HObjectAccess ForPropertiesPointer() {
- return HObjectAccess(kInobject, JSObject::kPropertiesOffset);
+ return HObjectAccess(kInobject, JSObject::kPropertiesOffset,
+ FOR_PROPERTIES_POINTER);
}
static HObjectAccess ForPrototypeOrInitialMap() {
- return HObjectAccess(kInobject, JSFunction::kPrototypeOrInitialMapOffset);
+ return HObjectAccess(kInobject, JSFunction::kPrototypeOrInitialMapOffset,
+ FOR_PROTOTYPE_OR_INITIAL_MAP);
}
static HObjectAccess ForSharedFunctionInfoPointer() {
- return HObjectAccess(kInobject, JSFunction::kSharedFunctionInfoOffset);
+ return HObjectAccess(kInobject, JSFunction::kSharedFunctionInfoOffset,
+ FOR_SHARED_FUNCTION_INFO_POINTER);
}
static HObjectAccess ForCodeEntryPointer() {
- return HObjectAccess(kInobject, JSFunction::kCodeEntryOffset);
+ return HObjectAccess(kInobject, JSFunction::kCodeEntryOffset,
+ FOR_CODE_ENTRY_POINTER);
}
static HObjectAccess ForCodeOffset() {
- return HObjectAccess(kInobject, SharedFunctionInfo::kCodeOffset);
+ return HObjectAccess(kInobject, SharedFunctionInfo::kCodeOffset,
+ FOR_CODE_OFFSET);
}
static HObjectAccess ForOptimizedCodeMap() {
return HObjectAccess(kInobject,
- SharedFunctionInfo::kOptimizedCodeMapOffset);
+ SharedFunctionInfo::kOptimizedCodeMapOffset,
+ FOR_OPTIMIZED_CODE_MAP);
}
static HObjectAccess ForFunctionContextPointer() {
- return HObjectAccess(kInobject, JSFunction::kContextOffset);
+ return HObjectAccess(kInobject, JSFunction::kContextOffset,
+ FOR_FUNCTION_CONTEXT_POINTER);
}
static HObjectAccess ForMap() {
- return HObjectAccess(kMaps, JSObject::kMapOffset);
+ return HObjectAccess(kMaps, JSObject::kMapOffset, FOR_MAP);
}
static HObjectAccess ForMapInstanceSize() {
return HObjectAccess(kInobject,
Map::kInstanceSizeOffset,
+ FOR_MAP_INSTANCE_SIZE,
Representation::UInteger8());
}
static HObjectAccess ForMapInstanceType() {
return HObjectAccess(kInobject,
Map::kInstanceTypeOffset,
+ FOR_MAP_INSTANCE_TYPE,
Representation::UInteger8());
}
static HObjectAccess ForPropertyCellValue() {
- return HObjectAccess(kInobject, PropertyCell::kValueOffset);
+ return HObjectAccess(kInobject, PropertyCell::kValueOffset,
+ FOR_PROPERTY_CELL_VALUE);
}
static HObjectAccess ForCellValue() {
- return HObjectAccess(kInobject, Cell::kValueOffset);
+ return HObjectAccess(kInobject, Cell::kValueOffset, FOR_CELL_VALUE);
}
static HObjectAccess ForAllocationMementoSite() {
- return HObjectAccess(kInobject, AllocationMemento::kAllocationSiteOffset);
+ return HObjectAccess(kInobject, AllocationMemento::kAllocationSiteOffset,
+ FOR_ALLOCATION_MEMENTO_SITE);
}
static HObjectAccess ForCounter() {
- return HObjectAccess(kExternalMemory, 0, Representation::Integer32(),
+ return HObjectAccess(kExternalMemory, 0, FOR_COUNTER,
+ Representation::Integer32(),
Handle<String>::null(), false, false);
}
@@ -6097,14 +6167,17 @@ class HObjectAccess V8_FINAL {
// properties can have different semantics depending on whether corresponding
// property was added to the map or not.
static HObjectAccess ForMapAndOffset(Handle<Map> map, int offset,
+ Purpose purpose = FOR_FIELD,
Representation representation = Representation::Tagged());
// Create an access to an in-object property in a JSObject.
// This kind of access can be used for accessing object header fields or
// in-object properties if the map of the object is not known.
static HObjectAccess ForObservableJSObjectOffset(int offset,
+ Purpose purpose = FOR_FIELD,
Representation representation = Representation::Tagged()) {
- return ForMapAndOffset(Handle<Map>::null(), offset, representation);
+ return ForMapAndOffset(Handle<Map>::null(), offset, purpose,
+ representation);
}
// Create an access to an in-object property in a JSArray.
@@ -6124,52 +6197,61 @@ class HObjectAccess V8_FINAL {
static HObjectAccess ForCellPayload(Isolate* isolate);
static HObjectAccess ForJSTypedArrayLength() {
- return HObjectAccess::ForObservableJSObjectOffset(
- JSTypedArray::kLengthOffset);
+ return HObjectAccess(
+ kInobject, JSTypedArray::kLengthOffset, FOR_JSTYPEDARRAY_LENGTH);
}
static HObjectAccess ForJSArrayBufferBackingStore() {
- return HObjectAccess::ForObservableJSObjectOffset(
- JSArrayBuffer::kBackingStoreOffset, Representation::External());
+ return HObjectAccess(
+ kInobject, JSArrayBuffer::kBackingStoreOffset,
+ FOR_JSARRAYBUFFER_BACKING_STORE, Representation::External());
}
static HObjectAccess ForJSArrayBufferByteLength() {
- return HObjectAccess::ForObservableJSObjectOffset(
- JSArrayBuffer::kByteLengthOffset, Representation::Tagged());
+ return HObjectAccess(
+ kInobject, JSArrayBuffer::kByteLengthOffset,
+ FOR_JSARRAYBUFFER_BYTE_LENGTH);
}
static HObjectAccess ForExternalArrayExternalPointer() {
- return HObjectAccess::ForObservableJSObjectOffset(
- ExternalArray::kExternalPointerOffset, Representation::External());
+ return HObjectAccess(
+ kInobject, ExternalArray::kExternalPointerOffset,
+ FOR_EXTERNAL_ARRAY_EXTERNAL_POINTER, Representation::External());
}
static HObjectAccess ForJSArrayBufferViewWeakNext() {
- return HObjectAccess::ForObservableJSObjectOffset(
- JSArrayBufferView::kWeakNextOffset);
+ return HObjectAccess(
+ kInobject, JSArrayBufferView::kWeakNextOffset,
+ FOR_JSARRAYBUFFERVIEW_WEAK_NEXT);
}
static HObjectAccess ForJSArrayBufferWeakFirstView() {
- return HObjectAccess::ForObservableJSObjectOffset(
- JSArrayBuffer::kWeakFirstViewOffset);
+ return HObjectAccess(
+ kInobject, JSArrayBuffer::kWeakFirstViewOffset,
+ FOR_JSARRAYBUFFER_WEAK_FIRST_VIEW);
}
static HObjectAccess ForJSArrayBufferViewBuffer() {
- return HObjectAccess::ForObservableJSObjectOffset(
- JSArrayBufferView::kBufferOffset);
+ return HObjectAccess(
+ kInobject, JSArrayBufferView::kBufferOffset,
+ FOR_JSARRAYBUFFERVIEW_BUFFER);
}
static HObjectAccess ForJSArrayBufferViewByteOffset() {
- return HObjectAccess::ForObservableJSObjectOffset(
- JSArrayBufferView::kByteOffsetOffset);
+ return HObjectAccess(
+ kInobject, JSArrayBufferView::kByteOffsetOffset,
+ FOR_JSARRAYBUFFERVIEW_BYTE_OFFSET);
}
static HObjectAccess ForJSArrayBufferViewByteLength() {
- return HObjectAccess::ForObservableJSObjectOffset(
- JSArrayBufferView::kByteLengthOffset);
+ return HObjectAccess(
+ kInobject, JSArrayBufferView::kByteLengthOffset,
+ FOR_JSARRAYBUFFERVIEW_BYTE_LENGTH);
}
static HObjectAccess ForGlobalObjectNativeContext() {
- return HObjectAccess(kInobject, GlobalObject::kNativeContextOffset);
+ return HObjectAccess(kInobject, GlobalObject::kNativeContextOffset,
+ FOR_GLOBAL_OBJECT_NATIVE_CONTEXT);
}
void PrintTo(StringStream* stream) const;
@@ -6178,6 +6260,10 @@ class HObjectAccess V8_FINAL {
return value_ == that.value_; // portion and offset must match
}
+#ifdef DEBUG
+ Purpose purpose() const { return purpose_; }
+#endif
+
protected:
void SetGVNFlags(HValue *instr, PropertyAccessType access_type);
@@ -6196,24 +6282,27 @@ class HObjectAccess V8_FINAL {
HObjectAccess() : value_(0) {}
- HObjectAccess(Portion portion, int offset,
+ HObjectAccess(Portion portion, int offset, Purpose purpose,
Representation representation = Representation::Tagged(),
Handle<String> name = Handle<String>::null(),
bool immutable = false,
bool existing_inobject_property = true)
- : value_(PortionField::encode(portion) |
- RepresentationField::encode(representation.kind()) |
- ImmutableField::encode(immutable ? 1 : 0) |
- ExistingInobjectPropertyField::encode(
- existing_inobject_property ? 1 : 0) |
- OffsetField::encode(offset)),
- name_(name) {
+ : value_(PortionField::encode(portion) |
+ RepresentationField::encode(representation.kind()) |
+ ImmutableField::encode(immutable ? 1 : 0) |
+ ExistingInobjectPropertyField::encode(
+ existing_inobject_property ? 1 : 0) |
+ OffsetField::encode(offset)),
+#ifdef DEBUG
+ purpose_(purpose),
+#endif
+ name_(name) {
// assert that the fields decode correctly
ASSERT(this->offset() == offset);
ASSERT(this->portion() == portion);
ASSERT(this->immutable() == immutable);
ASSERT(this->existing_inobject_property() == existing_inobject_property);
- ASSERT(RepresentationField::decode(value_) == representation.kind());
+ ASSERT(this->representation().Equals(representation));
ASSERT(!this->existing_inobject_property() || IsInobject());
}
@@ -6224,6 +6313,9 @@ class HObjectAccess V8_FINAL {
class OffsetField : public BitField<int, 9, 23> {};
uint32_t value_; // encodes portion, representation, immutable, and offset
+#ifdef DEBUG
+ Purpose purpose_;
+#endif
Handle<String> name_;
friend class HLoadNamedField;
« 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