Commit 9f57d626 authored by verwaest@chromium.org's avatar verwaest@chromium.org

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
parent a13d748e
...@@ -898,7 +898,7 @@ Handle<Code> IC::ComputeHandler(LookupIterator* lookup, Handle<Object> value) { ...@@ -898,7 +898,7 @@ Handle<Code> IC::ComputeHandler(LookupIterator* lookup, Handle<Object> value) {
Handle<Code> code = PropertyHandlerCompiler::Find( Handle<Code> code = PropertyHandlerCompiler::Find(
lookup->name(), stub_holder_map, kind(), flag, 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 // Use the cached value if it exists, and if it is different from the
// handler that just missed. // handler that just missed.
if (!code.is_null()) { if (!code.is_null()) {
...@@ -1033,7 +1033,7 @@ Handle<Code> LoadIC::CompileHandler(LookupIterator* lookup, ...@@ -1033,7 +1033,7 @@ Handle<Code> LoadIC::CompileHandler(LookupIterator* lookup,
// -------------- Dictionary properties -------------- // -------------- Dictionary properties --------------
DCHECK(lookup->state() == LookupIterator::DATA); 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 (kind() != Code::LOAD_IC) return slow_stub();
if (holder->IsGlobalObject()) { if (holder->IsGlobalObject()) {
NamedLoadHandlerCompiler compiler(isolate(), receiver_type(), holder, NamedLoadHandlerCompiler compiler(isolate(), receiver_type(), holder,
...@@ -1057,7 +1057,6 @@ Handle<Code> LoadIC::CompileHandler(LookupIterator* lookup, ...@@ -1057,7 +1057,6 @@ Handle<Code> LoadIC::CompileHandler(LookupIterator* lookup,
} }
// -------------- Fields -------------- // -------------- Fields --------------
DCHECK(lookup->property_encoding() == LookupIterator::DESCRIPTOR);
if (lookup->property_details().type() == FIELD) { if (lookup->property_details().type() == FIELD) {
FieldIndex field = lookup->GetFieldIndex(); FieldIndex field = lookup->GetFieldIndex();
if (receiver_is_holder) { if (receiver_is_holder) {
...@@ -1455,7 +1454,7 @@ Handle<Code> StoreIC::CompileHandler(LookupIterator* lookup, ...@@ -1455,7 +1454,7 @@ Handle<Code> StoreIC::CompileHandler(LookupIterator* lookup,
// -------------- Dictionary properties -------------- // -------------- Dictionary properties --------------
DCHECK(lookup->state() == LookupIterator::DATA); DCHECK(lookup->state() == LookupIterator::DATA);
if (lookup->property_encoding() == LookupIterator::DICTIONARY) { if (lookup->is_dictionary_holder()) {
if (holder->IsGlobalObject()) { if (holder->IsGlobalObject()) {
Handle<PropertyCell> cell = lookup->GetPropertyCell(); Handle<PropertyCell> cell = lookup->GetPropertyCell();
Handle<HeapType> union_type = PropertyCell::UpdatedType(cell, value); Handle<HeapType> union_type = PropertyCell::UpdatedType(cell, value);
...@@ -1472,7 +1471,6 @@ Handle<Code> StoreIC::CompileHandler(LookupIterator* lookup, ...@@ -1472,7 +1471,6 @@ Handle<Code> StoreIC::CompileHandler(LookupIterator* lookup,
} }
// -------------- Fields -------------- // -------------- Fields --------------
DCHECK(lookup->property_encoding() == LookupIterator::DESCRIPTOR);
if (lookup->property_details().type() == FIELD) { if (lookup->property_details().type() == FIELD) {
bool use_stub = true; bool use_stub = true;
if (lookup->representation().IsHeapObject()) { if (lookup->representation().IsHeapObject()) {
......
...@@ -47,7 +47,6 @@ LookupIterator::State LookupIterator::LookupInHolder(Map* map, ...@@ -47,7 +47,6 @@ LookupIterator::State LookupIterator::LookupInHolder(Map* map,
// Fall through. // Fall through.
case INTERCEPTOR: case INTERCEPTOR:
if (map->is_dictionary_map()) { if (map->is_dictionary_map()) {
property_encoding_ = DICTIONARY;
if (holder == NULL) return UNKNOWN; if (holder == NULL) return UNKNOWN;
NameDictionary* dict = JSObject::cast(holder)->property_dictionary(); NameDictionary* dict = JSObject::cast(holder)->property_dictionary();
number_ = dict->FindEntry(name_); number_ = dict->FindEntry(name_);
...@@ -62,7 +61,6 @@ LookupIterator::State LookupIterator::LookupInHolder(Map* map, ...@@ -62,7 +61,6 @@ LookupIterator::State LookupIterator::LookupInHolder(Map* map,
DescriptorArray* descriptors = map->instance_descriptors(); DescriptorArray* descriptors = map->instance_descriptors();
number_ = descriptors->SearchWithCache(*name_, map); number_ = descriptors->SearchWithCache(*name_, map);
if (number_ == DescriptorArray::kNotFound) return NOT_FOUND; if (number_ == DescriptorArray::kNotFound) return NOT_FOUND;
property_encoding_ = DESCRIPTOR;
property_details_ = descriptors->GetDetails(number_); property_details_ = descriptors->GetDetails(number_);
} }
has_property_ = true; has_property_ = true;
......
...@@ -94,7 +94,7 @@ void LookupIterator::ReloadPropertyInformation() { ...@@ -94,7 +94,7 @@ void LookupIterator::ReloadPropertyInformation() {
void LookupIterator::PrepareForDataProperty(Handle<Object> value) { void LookupIterator::PrepareForDataProperty(Handle<Object> value) {
DCHECK(state_ == DATA || state_ == ACCESSOR); DCHECK(state_ == DATA || state_ == ACCESSOR);
DCHECK(HolderIsReceiverOrHiddenPrototype()); DCHECK(HolderIsReceiverOrHiddenPrototype());
if (property_encoding_ == DICTIONARY) return; if (holder_map_->is_dictionary_map()) return;
holder_map_ = holder_map_ =
Map::PrepareForDataProperty(holder_map_, descriptor_number(), value); Map::PrepareForDataProperty(holder_map_, descriptor_number(), value);
JSObject::MigrateToMap(GetHolder<JSObject>(), holder_map_); JSObject::MigrateToMap(GetHolder<JSObject>(), holder_map_);
...@@ -107,15 +107,13 @@ void LookupIterator::ReconfigureDataProperty(Handle<Object> value, ...@@ -107,15 +107,13 @@ void LookupIterator::ReconfigureDataProperty(Handle<Object> value,
DCHECK(state_ == DATA || state_ == ACCESSOR); DCHECK(state_ == DATA || state_ == ACCESSOR);
DCHECK(HolderIsReceiverOrHiddenPrototype()); DCHECK(HolderIsReceiverOrHiddenPrototype());
Handle<JSObject> holder = GetHolder<JSObject>(); 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()) { if (holder_map_->is_dictionary_map()) {
PropertyDetails details(attributes, NORMAL, 0); PropertyDetails details(attributes, NORMAL, 0);
JSObject::SetNormalizedProperty(holder, name(), value, details); JSObject::SetNormalizedProperty(holder, name(), value, details);
} else {
holder_map_ = Map::ReconfigureDataProperty(holder_map_, descriptor_number(),
attributes);
JSObject::MigrateToMap(holder, holder_map_);
} }
ReloadPropertyInformation(); ReloadPropertyInformation();
...@@ -232,21 +230,17 @@ bool LookupIterator::HolderIsReceiverOrHiddenPrototype() const { ...@@ -232,21 +230,17 @@ bool LookupIterator::HolderIsReceiverOrHiddenPrototype() const {
Handle<Object> LookupIterator::FetchValue() const { Handle<Object> LookupIterator::FetchValue() const {
Object* result = NULL; Object* result = NULL;
Handle<JSObject> holder = GetHolder<JSObject>(); Handle<JSObject> holder = GetHolder<JSObject>();
switch (property_encoding_) { if (holder_map_->is_dictionary_map()) {
case DICTIONARY: result = holder->property_dictionary()->ValueAt(number_);
result = holder->property_dictionary()->ValueAt(number_); if (holder_map_->IsGlobalObjectMap()) {
if (holder->IsGlobalObject()) { result = PropertyCell::cast(result)->value();
result = PropertyCell::cast(result)->value(); }
} } else if (property_details_.type() == v8::internal::FIELD) {
break; FieldIndex field_index = FieldIndex::ForDescriptor(*holder_map_, number_);
case DESCRIPTOR: return JSObject::FastPropertyAt(holder, property_details_.representation(),
if (property_details_.type() == v8::internal::FIELD) { field_index);
FieldIndex field_index = } else {
FieldIndex::ForDescriptor(*holder_map_, number_); result = holder_map_->instance_descriptors()->GetValue(number_);
return JSObject::FastPropertyAt(
holder, property_details_.representation(), field_index);
}
result = holder_map_->instance_descriptors()->GetValue(number_);
} }
return handle(result, isolate_); return handle(result, isolate_);
} }
...@@ -254,7 +248,7 @@ Handle<Object> LookupIterator::FetchValue() const { ...@@ -254,7 +248,7 @@ Handle<Object> LookupIterator::FetchValue() const {
int LookupIterator::GetConstantIndex() const { int LookupIterator::GetConstantIndex() const {
DCHECK(has_property_); DCHECK(has_property_);
DCHECK_EQ(DESCRIPTOR, property_encoding_); DCHECK(!holder_map_->is_dictionary_map());
DCHECK_EQ(v8::internal::CONSTANT, property_details_.type()); DCHECK_EQ(v8::internal::CONSTANT, property_details_.type());
return descriptor_number(); return descriptor_number();
} }
...@@ -262,21 +256,21 @@ int LookupIterator::GetConstantIndex() const { ...@@ -262,21 +256,21 @@ int LookupIterator::GetConstantIndex() const {
FieldIndex LookupIterator::GetFieldIndex() const { FieldIndex LookupIterator::GetFieldIndex() const {
DCHECK(has_property_); DCHECK(has_property_);
DCHECK_EQ(DESCRIPTOR, property_encoding_); DCHECK(!holder_map_->is_dictionary_map());
DCHECK_EQ(v8::internal::FIELD, property_details_.type()); DCHECK_EQ(v8::internal::FIELD, property_details_.type());
int index = int index =
holder_map()->instance_descriptors()->GetFieldIndex(descriptor_number()); holder_map_->instance_descriptors()->GetFieldIndex(descriptor_number());
bool is_double = representation().IsDouble(); 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 { Handle<HeapType> LookupIterator::GetFieldType() const {
DCHECK(has_property_); DCHECK(has_property_);
DCHECK_EQ(DESCRIPTOR, property_encoding_); DCHECK(!holder_map_->is_dictionary_map());
DCHECK_EQ(v8::internal::FIELD, property_details_.type()); DCHECK_EQ(v8::internal::FIELD, property_details_.type());
return handle( return handle(
holder_map()->instance_descriptors()->GetFieldType(descriptor_number()), holder_map_->instance_descriptors()->GetFieldType(descriptor_number()),
isolate_); isolate_);
} }
...@@ -306,7 +300,7 @@ void LookupIterator::WriteDataValue(Handle<Object> value) { ...@@ -306,7 +300,7 @@ void LookupIterator::WriteDataValue(Handle<Object> value) {
DCHECK(is_guaranteed_to_have_holder()); DCHECK(is_guaranteed_to_have_holder());
DCHECK_EQ(DATA, state_); DCHECK_EQ(DATA, state_);
Handle<JSObject> holder = GetHolder<JSObject>(); Handle<JSObject> holder = GetHolder<JSObject>();
if (property_encoding_ == DICTIONARY) { if (holder_map_->is_dictionary_map()) {
NameDictionary* property_dictionary = holder->property_dictionary(); NameDictionary* property_dictionary = holder->property_dictionary();
if (holder->IsGlobalObject()) { if (holder->IsGlobalObject()) {
Handle<PropertyCell> cell( Handle<PropertyCell> cell(
......
...@@ -43,16 +43,10 @@ class LookupIterator FINAL BASE_EMBEDDED { ...@@ -43,16 +43,10 @@ class LookupIterator FINAL BASE_EMBEDDED {
BEFORE_PROPERTY = INTERCEPTOR BEFORE_PROPERTY = INTERCEPTOR
}; };
enum PropertyEncoding {
DICTIONARY,
DESCRIPTOR
};
LookupIterator(Handle<Object> receiver, Handle<Name> name, LookupIterator(Handle<Object> receiver, Handle<Name> name,
Configuration configuration = PROTOTYPE_CHAIN) Configuration configuration = PROTOTYPE_CHAIN)
: configuration_(ComputeConfiguration(configuration, name)), : configuration_(ComputeConfiguration(configuration, name)),
state_(NOT_FOUND), state_(NOT_FOUND),
property_encoding_(DESCRIPTOR),
property_details_(NONE, NORMAL, Representation::None()), property_details_(NONE, NORMAL, Representation::None()),
isolate_(name->GetIsolate()), isolate_(name->GetIsolate()),
name_(name), name_(name),
...@@ -69,7 +63,6 @@ class LookupIterator FINAL BASE_EMBEDDED { ...@@ -69,7 +63,6 @@ class LookupIterator FINAL BASE_EMBEDDED {
Configuration configuration = PROTOTYPE_CHAIN) Configuration configuration = PROTOTYPE_CHAIN)
: configuration_(ComputeConfiguration(configuration, name)), : configuration_(ComputeConfiguration(configuration, name)),
state_(NOT_FOUND), state_(NOT_FOUND),
property_encoding_(DESCRIPTOR),
property_details_(NONE, NORMAL, Representation::None()), property_details_(NONE, NORMAL, Representation::None()),
isolate_(name->GetIsolate()), isolate_(name->GetIsolate()),
name_(name), name_(name),
...@@ -96,7 +89,7 @@ class LookupIterator FINAL BASE_EMBEDDED { ...@@ -96,7 +89,7 @@ class LookupIterator FINAL BASE_EMBEDDED {
return maybe_receiver_.ToHandleChecked(); return maybe_receiver_.ToHandleChecked();
} }
Handle<JSObject> GetStoreTarget() const; 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 { Handle<Map> transition_map() const {
DCHECK_EQ(TRANSITION, state_); DCHECK_EQ(TRANSITION, state_);
return transition_map_; return transition_map_;
...@@ -132,10 +125,6 @@ class LookupIterator FINAL BASE_EMBEDDED { ...@@ -132,10 +125,6 @@ class LookupIterator FINAL BASE_EMBEDDED {
void TransitionToAccessorProperty(AccessorComponent component, void TransitionToAccessorProperty(AccessorComponent component,
Handle<Object> accessor, Handle<Object> accessor,
PropertyAttributes attributes); PropertyAttributes attributes);
PropertyEncoding property_encoding() const {
DCHECK(has_property_);
return property_encoding_;
}
PropertyDetails property_details() const { PropertyDetails property_details() const {
DCHECK(has_property_); DCHECK(has_property_);
return property_details_; return property_details_;
...@@ -181,12 +170,12 @@ class LookupIterator FINAL BASE_EMBEDDED { ...@@ -181,12 +170,12 @@ class LookupIterator FINAL BASE_EMBEDDED {
} }
int descriptor_number() const { int descriptor_number() const {
DCHECK(has_property_); DCHECK(has_property_);
DCHECK_EQ(DESCRIPTOR, property_encoding_); DCHECK(!holder_map_->is_dictionary_map());
return number_; return number_;
} }
int dictionary_entry() const { int dictionary_entry() const {
DCHECK(has_property_); DCHECK(has_property_);
DCHECK_EQ(DICTIONARY, property_encoding_); DCHECK(holder_map_->is_dictionary_map());
return number_; return number_;
} }
...@@ -204,7 +193,6 @@ class LookupIterator FINAL BASE_EMBEDDED { ...@@ -204,7 +193,6 @@ class LookupIterator FINAL BASE_EMBEDDED {
Configuration configuration_; Configuration configuration_;
State state_; State state_;
bool has_property_; bool has_property_;
PropertyEncoding property_encoding_;
PropertyDetails property_details_; PropertyDetails property_details_;
Isolate* isolate_; Isolate* isolate_;
Handle<Name> name_; Handle<Name> name_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment