Reviewers: Yang,
Message:
PTAL
Description:
Get rid of special property_encoding flag on the LookupIterator
BUG=
Please review this at https://codereview.chromium.org/539083002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+29, -51 lines):
M src/ic/ic.cc
M src/lookup.h
M src/lookup.cc
M src/lookup-inl.h
Index: src/ic/ic.cc
diff --git a/src/ic/ic.cc b/src/ic/ic.cc
index
cc20c7cd26647dcef47d54c391902aa0bf8606f3..a2d60143028bbb0c0fb72147111b4582a3c059aa
100644
--- a/src/ic/ic.cc
+++ b/src/ic/ic.cc
@@ -898,7 +898,7 @@ Handle<Code> IC::ComputeHandler(LookupIterator* lookup,
Handle<Object> value) {
Handle<Code> code = PropertyHandlerCompiler::Find(
lookup->name(), stub_holder_map, kind(), flag,
- lookup->holder_map()->is_dictionary_map() ? Code::NORMAL :
Code::FAST);
+ lookup->is_dictionary_holder() ? Code::NORMAL : Code::FAST);
// Use the cached value if it exists, and if it is different from the
// handler that just missed.
if (!code.is_null()) {
@@ -1033,7 +1033,7 @@ Handle<Code> LoadIC::CompileHandler(LookupIterator*
lookup,
// -------------- Dictionary properties --------------
DCHECK(lookup->state() == LookupIterator::DATA);
- if (lookup->property_encoding() == LookupIterator::DICTIONARY) {
+ if (lookup->is_dictionary_holder()) {
if (kind() != Code::LOAD_IC) return slow_stub();
if (holder->IsGlobalObject()) {
NamedLoadHandlerCompiler compiler(isolate(), receiver_type(), holder,
@@ -1057,7 +1057,6 @@ Handle<Code> LoadIC::CompileHandler(LookupIterator*
lookup,
}
// -------------- Fields --------------
- DCHECK(lookup->property_encoding() == LookupIterator::DESCRIPTOR);
if (lookup->property_details().type() == FIELD) {
FieldIndex field = lookup->GetFieldIndex();
if (receiver_is_holder) {
@@ -1455,7 +1454,7 @@ Handle<Code> StoreIC::CompileHandler(LookupIterator*
lookup,
// -------------- Dictionary properties --------------
DCHECK(lookup->state() == LookupIterator::DATA);
- if (lookup->property_encoding() == LookupIterator::DICTIONARY) {
+ if (lookup->is_dictionary_holder()) {
if (holder->IsGlobalObject()) {
Handle<PropertyCell> cell = lookup->GetPropertyCell();
Handle<HeapType> union_type = PropertyCell::UpdatedType(cell, value);
@@ -1472,7 +1471,6 @@ Handle<Code> StoreIC::CompileHandler(LookupIterator*
lookup,
}
// -------------- Fields --------------
- DCHECK(lookup->property_encoding() == LookupIterator::DESCRIPTOR);
if (lookup->property_details().type() == FIELD) {
bool use_stub = true;
if (lookup->representation().IsHeapObject()) {
Index: src/lookup-inl.h
diff --git a/src/lookup-inl.h b/src/lookup-inl.h
index
bb82f1e28315e4722df8d06c66e182e977548532..cc7378892562afda7bda425973d2ee699917cccc
100644
--- a/src/lookup-inl.h
+++ b/src/lookup-inl.h
@@ -47,7 +47,6 @@ LookupIterator::State LookupIterator::LookupInHolder(Map*
map,
// Fall through.
case INTERCEPTOR:
if (map->is_dictionary_map()) {
- property_encoding_ = DICTIONARY;
if (holder == NULL) return UNKNOWN;
NameDictionary* dict =
JSObject::cast(holder)->property_dictionary();
number_ = dict->FindEntry(name_);
@@ -62,7 +61,6 @@ LookupIterator::State LookupIterator::LookupInHolder(Map*
map,
DescriptorArray* descriptors = map->instance_descriptors();
number_ = descriptors->SearchWithCache(*name_, map);
if (number_ == DescriptorArray::kNotFound) return NOT_FOUND;
- property_encoding_ = DESCRIPTOR;
property_details_ = descriptors->GetDetails(number_);
}
has_property_ = true;
Index: src/lookup.cc
diff --git a/src/lookup.cc b/src/lookup.cc
index
60506e75aad6ece4e6c19835453937b65e305b38..752cd7063fe983dee9b88387bfeb8f87082805ba
100644
--- a/src/lookup.cc
+++ b/src/lookup.cc
@@ -94,7 +94,7 @@ void LookupIterator::ReloadPropertyInformation() {
void LookupIterator::PrepareForDataProperty(Handle<Object> value) {
DCHECK(state_ == DATA || state_ == ACCESSOR);
DCHECK(HolderIsReceiverOrHiddenPrototype());
- if (property_encoding_ == DICTIONARY) return;
+ if (holder_map_->is_dictionary_map()) return;
holder_map_ =
Map::PrepareForDataProperty(holder_map_, descriptor_number(), value);
JSObject::MigrateToMap(GetHolder<JSObject>(), holder_map_);
@@ -107,15 +107,13 @@ void
LookupIterator::ReconfigureDataProperty(Handle<Object> value,
DCHECK(state_ == DATA || state_ == ACCESSOR);
DCHECK(HolderIsReceiverOrHiddenPrototype());
Handle<JSObject> holder = GetHolder<JSObject>();
- if (property_encoding_ != DICTIONARY) {
- holder_map_ = Map::ReconfigureDataProperty(holder_map_,
descriptor_number(),
- attributes);
- JSObject::MigrateToMap(holder, holder_map_);
- }
-
if (holder_map_->is_dictionary_map()) {
PropertyDetails details(attributes, NORMAL, 0);
JSObject::SetNormalizedProperty(holder, name(), value, details);
+ } else {
+ holder_map_ = Map::ReconfigureDataProperty(holder_map_,
descriptor_number(),
+ attributes);
+ JSObject::MigrateToMap(holder, holder_map_);
}
ReloadPropertyInformation();
@@ -232,21 +230,17 @@ bool
LookupIterator::HolderIsReceiverOrHiddenPrototype() const {
Handle<Object> LookupIterator::FetchValue() const {
Object* result = NULL;
Handle<JSObject> holder = GetHolder<JSObject>();
- switch (property_encoding_) {
- case DICTIONARY:
- result = holder->property_dictionary()->ValueAt(number_);
- if (holder->IsGlobalObject()) {
- result = PropertyCell::cast(result)->value();
- }
- break;
- case DESCRIPTOR:
- if (property_details_.type() == v8::internal::FIELD) {
- FieldIndex field_index =
- FieldIndex::ForDescriptor(*holder_map_, number_);
- return JSObject::FastPropertyAt(
- holder, property_details_.representation(), field_index);
- }
- result = holder_map_->instance_descriptors()->GetValue(number_);
+ if (holder_map_->is_dictionary_map()) {
+ result = holder->property_dictionary()->ValueAt(number_);
+ if (holder_map_->IsGlobalObjectMap()) {
+ result = PropertyCell::cast(result)->value();
+ }
+ } else if (property_details_.type() == v8::internal::FIELD) {
+ FieldIndex field_index = FieldIndex::ForDescriptor(*holder_map_,
number_);
+ return JSObject::FastPropertyAt(holder,
property_details_.representation(),
+ field_index);
+ } else {
+ result = holder_map_->instance_descriptors()->GetValue(number_);
}
return handle(result, isolate_);
}
@@ -254,7 +248,7 @@ Handle<Object> LookupIterator::FetchValue() const {
int LookupIterator::GetConstantIndex() const {
DCHECK(has_property_);
- DCHECK_EQ(DESCRIPTOR, property_encoding_);
+ DCHECK(!holder_map_->is_dictionary_map());
DCHECK_EQ(v8::internal::CONSTANT, property_details_.type());
return descriptor_number();
}
@@ -262,21 +256,21 @@ int LookupIterator::GetConstantIndex() const {
FieldIndex LookupIterator::GetFieldIndex() const {
DCHECK(has_property_);
- DCHECK_EQ(DESCRIPTOR, property_encoding_);
+ DCHECK(!holder_map_->is_dictionary_map());
DCHECK_EQ(v8::internal::FIELD, property_details_.type());
int index =
-
holder_map()->instance_descriptors()->GetFieldIndex(descriptor_number());
+
holder_map_->instance_descriptors()->GetFieldIndex(descriptor_number());
bool is_double = representation().IsDouble();
- return FieldIndex::ForPropertyIndex(*holder_map(), index, is_double);
+ return FieldIndex::ForPropertyIndex(*holder_map_, index, is_double);
}
Handle<HeapType> LookupIterator::GetFieldType() const {
DCHECK(has_property_);
- DCHECK_EQ(DESCRIPTOR, property_encoding_);
+ DCHECK(!holder_map_->is_dictionary_map());
DCHECK_EQ(v8::internal::FIELD, property_details_.type());
return handle(
-
holder_map()->instance_descriptors()->GetFieldType(descriptor_number()),
+
holder_map_->instance_descriptors()->GetFieldType(descriptor_number()),
isolate_);
}
@@ -306,7 +300,7 @@ void LookupIterator::WriteDataValue(Handle<Object>
value) {
DCHECK(is_guaranteed_to_have_holder());
DCHECK_EQ(DATA, state_);
Handle<JSObject> holder = GetHolder<JSObject>();
- if (property_encoding_ == DICTIONARY) {
+ if (holder_map_->is_dictionary_map()) {
NameDictionary* property_dictionary = holder->property_dictionary();
if (holder->IsGlobalObject()) {
Handle<PropertyCell> cell(
Index: src/lookup.h
diff --git a/src/lookup.h b/src/lookup.h
index
594919d1cf52be737bc450de6d7df0da81abda90..ac5c27db5dd54832ef4053daccf1df9619a15e91
100644
--- a/src/lookup.h
+++ b/src/lookup.h
@@ -43,16 +43,10 @@ class LookupIterator FINAL BASE_EMBEDDED {
BEFORE_PROPERTY = INTERCEPTOR
};
- enum PropertyEncoding {
- DICTIONARY,
- DESCRIPTOR
- };
-
LookupIterator(Handle<Object> receiver, Handle<Name> name,
Configuration configuration = PROTOTYPE_CHAIN)
: configuration_(ComputeConfiguration(configuration, name)),
state_(NOT_FOUND),
- property_encoding_(DESCRIPTOR),
property_details_(NONE, NORMAL, Representation::None()),
isolate_(name->GetIsolate()),
name_(name),
@@ -69,7 +63,6 @@ class LookupIterator FINAL BASE_EMBEDDED {
Configuration configuration = PROTOTYPE_CHAIN)
: configuration_(ComputeConfiguration(configuration, name)),
state_(NOT_FOUND),
- property_encoding_(DESCRIPTOR),
property_details_(NONE, NORMAL, Representation::None()),
isolate_(name->GetIsolate()),
name_(name),
@@ -96,7 +89,7 @@ class LookupIterator FINAL BASE_EMBEDDED {
return maybe_receiver_.ToHandleChecked();
}
Handle<JSObject> GetStoreTarget() const;
- Handle<Map> holder_map() const { return holder_map_; }
+ bool is_dictionary_holder() const { return
holder_map_->is_dictionary_map(); }
Handle<Map> transition_map() const {
DCHECK_EQ(TRANSITION, state_);
return transition_map_;
@@ -132,10 +125,6 @@ class LookupIterator FINAL BASE_EMBEDDED {
void TransitionToAccessorProperty(AccessorComponent component,
Handle<Object> accessor,
PropertyAttributes attributes);
- PropertyEncoding property_encoding() const {
- DCHECK(has_property_);
- return property_encoding_;
- }
PropertyDetails property_details() const {
DCHECK(has_property_);
return property_details_;
@@ -181,12 +170,12 @@ class LookupIterator FINAL BASE_EMBEDDED {
}
int descriptor_number() const {
DCHECK(has_property_);
- DCHECK_EQ(DESCRIPTOR, property_encoding_);
+ DCHECK(!holder_map_->is_dictionary_map());
return number_;
}
int dictionary_entry() const {
DCHECK(has_property_);
- DCHECK_EQ(DICTIONARY, property_encoding_);
+ DCHECK(holder_map_->is_dictionary_map());
return number_;
}
@@ -204,7 +193,6 @@ class LookupIterator FINAL BASE_EMBEDDED {
Configuration configuration_;
State state_;
bool has_property_;
- PropertyEncoding property_encoding_;
PropertyDetails property_details_;
Isolate* isolate_;
Handle<Name> name_;
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.