Get rid of special property_encoding flag on the LookupIterator

BUG=
R=yangguo@chromium.org

Review URL: https://codereview.chromium.org/539083002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23695 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
verwaest@chromium.org 2014-09-04 13:17:04 +00:00
parent a13d748e4d
commit 9f57d62618
4 changed files with 29 additions and 51 deletions

View File

@ -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()) {

View File

@ -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;

View File

@ -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(

View File

@ -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_;