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

Unified Diff: src/property.h

Issue 167303005: Track field types. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Support transitions in LookupResult. Created 6 years, 9 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
« src/objects.cc ('K') | « src/objects-inl.h ('k') | src/property.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/property.h
diff --git a/src/property.h b/src/property.h
index baa5a0f993c7e13be91b281e07d2d20659607eb2..53ce4539e566b35962aba6038f157fefe887a4bd 100644
--- a/src/property.h
+++ b/src/property.h
@@ -101,9 +101,12 @@ class FieldDescriptor: public Descriptor {
FieldDescriptor(Name* key,
int field_index,
PropertyAttributes attributes,
- Representation representation)
- : Descriptor(key, Smi::FromInt(0), attributes,
- FIELD, representation, field_index) {}
+ Representation representation);
+ FieldDescriptor(Name* key,
+ int field_index,
+ HeapType* field_type,
+ PropertyAttributes attributes,
+ Representation representation);
};
@@ -205,11 +208,7 @@ class LookupResult BASE_EMBEDDED {
number_ = number;
}
- bool CanHoldValue(Handle<Object> value) {
- if (IsNormal()) return true;
- ASSERT(!IsTransition());
- return value->FitsRepresentation(details_.representation());
- }
+ bool CanHoldValue(Handle<Object> value) const;
void TransitionResult(JSObject* holder, Map* target) {
lookup_type_ = TRANSITION_TYPE;
@@ -454,9 +453,13 @@ class LookupResult BASE_EMBEDDED {
}
Object* GetValueFromMap(Map* map) const {
- ASSERT(lookup_type_ == DESCRIPTOR_TYPE);
- ASSERT(number_ < map->NumberOfOwnDescriptors());
- return map->instance_descriptors()->GetValue(number_);
+ if (lookup_type_ == DESCRIPTOR_TYPE) {
+ ASSERT(number_ < map->NumberOfOwnDescriptors());
+ return map->instance_descriptors()->GetValue(number_);
+ }
+ ASSERT(lookup_type_ == TRANSITION_TYPE);
+ return transition_->instance_descriptors()->GetValue(
+ transition_->LastAdded());
}
int GetFieldIndexFromMap(Map* map) const {
@@ -465,6 +468,22 @@ class LookupResult BASE_EMBEDDED {
return map->instance_descriptors()->GetFieldIndex(number_);
}
+ HeapType* GetFieldType() const {
+ return GetFieldTypeFromMap(holder()->map());
Toon Verwaest 2014/03/21 14:33:37 Aarg, this is ugly. We really need to cache holder
Benedikt Meurer 2014/04/11 11:12:00 ACK.
+ }
+
+ HeapType* GetFieldTypeFromMap(Map* map) const;
+
+ Map* GetFieldOwner() const {
+ return GetFieldOwnerFromMap(holder()->map());
+ }
+
+ Map* GetFieldOwnerFromMap(Map* map) const {
+ ASSERT(lookup_type_ == DESCRIPTOR_TYPE);
+ ASSERT(number_ < map->NumberOfOwnDescriptors());
+ return map->FindFieldOwner(number_);
+ }
+
void Iterate(ObjectVisitor* visitor);
private:
« src/objects.cc ('K') | « src/objects-inl.h ('k') | src/property.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698