NameDictionary's key type is now Handle<Name> instead of Name*.

R=yangguo@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20947 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
ishell@chromium.org 2014-04-24 14:59:09 +00:00
parent 1bdc421adf
commit cb46971aa3
10 changed files with 71 additions and 57 deletions

View File

@ -893,7 +893,7 @@ Register StubCompiler::CheckPrototypes(Handle<HeapType> type,
name = factory()->InternalizeString(Handle<String>::cast(name)); name = factory()->InternalizeString(Handle<String>::cast(name));
} }
ASSERT(current.is_null() || ASSERT(current.is_null() ||
current->property_dictionary()->FindEntry(*name) == current->property_dictionary()->FindEntry(name) ==
NameDictionary::kNotFound); NameDictionary::kNotFound);
GenerateDictionaryNegativeLookup(masm(), miss, reg, name, GenerateDictionaryNegativeLookup(masm(), miss, reg, name,

View File

@ -844,7 +844,7 @@ Register StubCompiler::CheckPrototypes(Handle<HeapType> type,
name = factory()->InternalizeString(Handle<String>::cast(name)); name = factory()->InternalizeString(Handle<String>::cast(name));
} }
ASSERT(current.is_null() || ASSERT(current.is_null() ||
(current->property_dictionary()->FindEntry(*name) == (current->property_dictionary()->FindEntry(name) ==
NameDictionary::kNotFound)); NameDictionary::kNotFound));
GenerateDictionaryNegativeLookup(masm(), miss, reg, name, GenerateDictionaryNegativeLookup(masm(), miss, reg, name,

View File

@ -878,7 +878,7 @@ Register StubCompiler::CheckPrototypes(Handle<HeapType> type,
name = factory()->InternalizeString(Handle<String>::cast(name)); name = factory()->InternalizeString(Handle<String>::cast(name));
} }
ASSERT(current.is_null() || ASSERT(current.is_null() ||
current->property_dictionary()->FindEntry(*name) == current->property_dictionary()->FindEntry(name) ==
NameDictionary::kNotFound); NameDictionary::kNotFound);
GenerateDictionaryNegativeLookup(masm(), miss, reg, name, GenerateDictionaryNegativeLookup(masm(), miss, reg, name,

View File

@ -885,7 +885,7 @@ Register StubCompiler::CheckPrototypes(Handle<HeapType> type,
name = factory()->InternalizeString(Handle<String>::cast(name)); name = factory()->InternalizeString(Handle<String>::cast(name));
} }
ASSERT(current.is_null() || ASSERT(current.is_null() ||
current->property_dictionary()->FindEntry(*name) == current->property_dictionary()->FindEntry(name) ==
NameDictionary::kNotFound); NameDictionary::kNotFound);
GenerateDictionaryNegativeLookup(masm(), miss, reg, name, GenerateDictionaryNegativeLookup(masm(), miss, reg, name,

View File

@ -6648,7 +6648,7 @@ Handle<Object> NumberDictionaryShape::AsHandle(Isolate* isolate, uint32_t key) {
} }
bool NameDictionaryShape::IsMatch(Name* key, Object* other) { bool NameDictionaryShape::IsMatch(Handle<Name> key, Object* other) {
// We know that all entries in a hash table had their hash keys created. // We know that all entries in a hash table had their hash keys created.
// Use that knowledge to have fast failure. // Use that knowledge to have fast failure.
if (key->Hash() != Name::cast(other)->Hash()) return false; if (key->Hash() != Name::cast(other)->Hash()) return false;
@ -6656,26 +6656,26 @@ bool NameDictionaryShape::IsMatch(Name* key, Object* other) {
} }
uint32_t NameDictionaryShape::Hash(Name* key) { uint32_t NameDictionaryShape::Hash(Handle<Name> key) {
return key->Hash(); return key->Hash();
} }
uint32_t NameDictionaryShape::HashForObject(Name* key, Object* other) { uint32_t NameDictionaryShape::HashForObject(Handle<Name> key, Object* other) {
return Name::cast(other)->Hash(); return Name::cast(other)->Hash();
} }
MaybeObject* NameDictionaryShape::AsObject(Heap* heap, Name* key) { MaybeObject* NameDictionaryShape::AsObject(Heap* heap, Handle<Name> key) {
ASSERT(key->IsUniqueName()); ASSERT(key->IsUniqueName());
return key; return *key;
} }
Handle<Object> NameDictionaryShape::AsHandle(Isolate* isolate, Name* key) { Handle<Object> NameDictionaryShape::AsHandle(Isolate* isolate,
Handle<Name> key) {
ASSERT(key->IsUniqueName()); ASSERT(key->IsUniqueName());
// TODO(ishell): Convert Name* to Handle<Name> to avoid re-wrapping here. return key;
return handle(key, isolate);
} }

View File

@ -660,7 +660,7 @@ void JSObject::SetNormalizedProperty(Handle<JSObject> object,
Handle<String>::cast(name)); Handle<String>::cast(name));
} }
int entry = property_dictionary->FindEntry(*name); int entry = property_dictionary->FindEntry(name);
if (entry == NameDictionary::kNotFound) { if (entry == NameDictionary::kNotFound) {
Handle<Object> store_value = value; Handle<Object> store_value = value;
if (object->IsGlobalObject()) { if (object->IsGlobalObject()) {
@ -705,7 +705,7 @@ Handle<Object> JSObject::DeleteNormalizedProperty(Handle<JSObject> object,
ASSERT(!object->HasFastProperties()); ASSERT(!object->HasFastProperties());
Isolate* isolate = object->GetIsolate(); Isolate* isolate = object->GetIsolate();
Handle<NameDictionary> dictionary(object->property_dictionary()); Handle<NameDictionary> dictionary(object->property_dictionary());
int entry = dictionary->FindEntry(*name); int entry = dictionary->FindEntry(name);
if (entry != NameDictionary::kNotFound) { if (entry != NameDictionary::kNotFound) {
// If we have a global object set the cell to the hole. // If we have a global object set the cell to the hole.
if (object->IsGlobalObject()) { if (object->IsGlobalObject()) {
@ -728,7 +728,7 @@ Handle<Object> JSObject::DeleteNormalizedProperty(Handle<JSObject> object,
Handle<Object> deleted(dictionary->DeleteProperty(entry, mode), isolate); Handle<Object> deleted(dictionary->DeleteProperty(entry, mode), isolate);
if (*deleted == isolate->heap()->true_value()) { if (*deleted == isolate->heap()->true_value()) {
Handle<NameDictionary> new_properties = Handle<NameDictionary> new_properties =
NameDictionary::Shrink(dictionary, *name); NameDictionary::Shrink(dictionary, name);
object->set_properties(*new_properties); object->set_properties(*new_properties);
} }
return deleted; return deleted;
@ -1924,7 +1924,7 @@ void JSObject::AddSlowProperty(Handle<JSObject> object,
Handle<NameDictionary> dict(object->property_dictionary()); Handle<NameDictionary> dict(object->property_dictionary());
if (object->IsGlobalObject()) { if (object->IsGlobalObject()) {
// In case name is an orphaned property reuse the cell. // In case name is an orphaned property reuse the cell.
int entry = dict->FindEntry(*name); int entry = dict->FindEntry(name);
if (entry != NameDictionary::kNotFound) { if (entry != NameDictionary::kNotFound) {
Handle<PropertyCell> cell(PropertyCell::cast(dict->ValueAt(entry))); Handle<PropertyCell> cell(PropertyCell::cast(dict->ValueAt(entry)));
PropertyCell::SetValueInferType(cell, value); PropertyCell::SetValueInferType(cell, value);
@ -2054,7 +2054,7 @@ static void ReplaceSlowProperty(Handle<JSObject> object,
Handle<Object> value, Handle<Object> value,
PropertyAttributes attributes) { PropertyAttributes attributes) {
NameDictionary* dictionary = object->property_dictionary(); NameDictionary* dictionary = object->property_dictionary();
int old_index = dictionary->FindEntry(*name); int old_index = dictionary->FindEntry(name);
int new_enumeration_index = 0; // 0 means "Use the next available index." int new_enumeration_index = 0; // 0 means "Use the next available index."
if (old_index != -1) { if (old_index != -1) {
// All calls to ReplaceSlowProperty have had all transitions removed. // All calls to ReplaceSlowProperty have had all transitions removed.
@ -14627,8 +14627,17 @@ Handle<Derived> HashTable<Derived, Shape, Key>::New(
} }
// Find entry for key otherwise return kNotFound. // TODO(ishell): Remove this when all the callers are handlified.
int NameDictionary::FindEntry(Name* key) { int NameDictionary::FindEntry(Name* key) {
DisallowHeapAllocation no_allocation;
Isolate* isolate = key->GetIsolate();
HandleScope scope(isolate);
return FindEntry(handle(key, isolate));
}
// Find entry for key otherwise return kNotFound.
int NameDictionary::FindEntry(Handle<Name> key) {
if (!key->IsUniqueName()) { if (!key->IsUniqueName()) {
return DerivedHashTable::FindEntry(key); return DerivedHashTable::FindEntry(key);
} }
@ -14651,16 +14660,16 @@ int NameDictionary::FindEntry(Name* key) {
int index = EntryToIndex(entry); int index = EntryToIndex(entry);
Object* element = get(index); Object* element = get(index);
if (element->IsUndefined()) break; // Empty entry. if (element->IsUndefined()) break; // Empty entry.
if (key == element) return entry; if (*key == element) return entry;
if (!element->IsUniqueName() && if (!element->IsUniqueName() &&
!element->IsTheHole() && !element->IsTheHole() &&
Name::cast(element)->Equals(key)) { Name::cast(element)->Equals(*key)) {
// Replace a key that is a non-internalized string by the equivalent // Replace a key that is a non-internalized string by the equivalent
// internalized string for faster further lookups. // internalized string for faster further lookups.
set(index, key); set(index, *key);
return entry; return entry;
} }
ASSERT(element->IsTheHole() || !Name::cast(element)->Equals(key)); ASSERT(element->IsTheHole() || !Name::cast(element)->Equals(*key));
entry = NextProbe(entry, count++, capacity); entry = NextProbe(entry, count++, capacity);
} }
return kNotFound; return kNotFound;
@ -14877,7 +14886,7 @@ template class HashTable<ObjectHashTable, ObjectHashTableShape, Object*>;
template class HashTable<WeakHashTable, WeakHashTableShape<2>, Object*>; template class HashTable<WeakHashTable, WeakHashTableShape<2>, Object*>;
template class Dictionary<NameDictionary, NameDictionaryShape, Name*>; template class Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >;
template class Dictionary<SeededNumberDictionary, template class Dictionary<SeededNumberDictionary,
SeededNumberDictionaryShape, SeededNumberDictionaryShape,
@ -14895,11 +14904,12 @@ template MaybeObject*
Dictionary<UnseededNumberDictionary, UnseededNumberDictionaryShape, uint32_t>:: Dictionary<UnseededNumberDictionary, UnseededNumberDictionaryShape, uint32_t>::
Allocate(Heap* heap, int at_least_space_for, PretenureFlag pretenure); Allocate(Heap* heap, int at_least_space_for, PretenureFlag pretenure);
template MaybeObject* Dictionary<NameDictionary, NameDictionaryShape, Name*>:: template MaybeObject*
Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::
Allocate(Heap* heap, int n, PretenureFlag pretenure); Allocate(Heap* heap, int n, PretenureFlag pretenure);
template Handle<NameDictionary> template Handle<NameDictionary>
Dictionary<NameDictionary, NameDictionaryShape, Name*>:: Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::
New(Isolate* isolate, int n, PretenureFlag pretenure); New(Isolate* isolate, int n, PretenureFlag pretenure);
template Handle<SeededNumberDictionary> template Handle<SeededNumberDictionary>
@ -14919,8 +14929,8 @@ Dictionary<UnseededNumberDictionary, UnseededNumberDictionaryShape, uint32_t>::
SlowReverseLookup(Object* value); SlowReverseLookup(Object* value);
template Object* template Object*
Dictionary<NameDictionary, NameDictionaryShape, Name*>::SlowReverseLookup( Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::
Object*); SlowReverseLookup(Object* value);
template void template void
Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>:: Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>::
@ -14932,12 +14942,12 @@ Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>::
uint32_t>::SortMode); uint32_t>::SortMode);
template Object* template Object*
Dictionary<NameDictionary, NameDictionaryShape, Name*>::DeleteProperty( Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::DeleteProperty(
int, JSObject::DeleteMode); int, JSObject::DeleteMode);
template Handle<Object> template Handle<Object>
Dictionary<NameDictionary, NameDictionaryShape, Name*>::DeleteProperty( Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::DeleteProperty(
Handle<Dictionary<NameDictionary, NameDictionaryShape, Name*> >, Handle<Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> > >,
int, int,
JSObject::DeleteMode); JSObject::DeleteMode);
@ -14955,34 +14965,35 @@ Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>::
JSObject::DeleteMode); JSObject::DeleteMode);
template Handle<NameDictionary> template Handle<NameDictionary>
HashTable<NameDictionary, NameDictionaryShape, Name*>:: HashTable<NameDictionary, NameDictionaryShape, Handle<Name> >::
New(Isolate*, int, MinimumCapacity, PretenureFlag); New(Isolate*, int, MinimumCapacity, PretenureFlag);
template Handle<NameDictionary> template Handle<NameDictionary>
HashTable<NameDictionary, NameDictionaryShape, Name*>:: HashTable<NameDictionary, NameDictionaryShape, Handle<Name> >::
Shrink(Handle<NameDictionary>, Name* n); Shrink(Handle<NameDictionary>, Handle<Name>);
template Handle<SeededNumberDictionary> template Handle<SeededNumberDictionary>
HashTable<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>:: HashTable<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>::
Shrink(Handle<SeededNumberDictionary>, uint32_t); Shrink(Handle<SeededNumberDictionary>, uint32_t);
template void Dictionary<NameDictionary, NameDictionaryShape, Name*>:: template void Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::
CopyKeysTo( CopyKeysTo(
FixedArray*, FixedArray*,
int, int,
PropertyAttributes, PropertyAttributes,
Dictionary<NameDictionary, NameDictionaryShape, Name*>::SortMode); Dictionary<
NameDictionary, NameDictionaryShape, Handle<Name> >::SortMode);
template int template int
Dictionary<NameDictionary, NameDictionaryShape, Name*>:: Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::
NumberOfElementsFilterAttributes(PropertyAttributes); NumberOfElementsFilterAttributes(PropertyAttributes);
template MaybeObject* template MaybeObject*
Dictionary<NameDictionary, NameDictionaryShape, Name*>::Add( Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::Add(
Name*, Object*, PropertyDetails); Handle<Name>, Object*, PropertyDetails);
template MaybeObject* template MaybeObject*
Dictionary<NameDictionary, NameDictionaryShape, Name*>:: Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::
GenerateNewEnumerationIndices(); GenerateNewEnumerationIndices();
template int template int
@ -15006,8 +15017,8 @@ Dictionary<UnseededNumberDictionary, UnseededNumberDictionaryShape, uint32_t>::
EnsureCapacity(int, uint32_t); EnsureCapacity(int, uint32_t);
template MaybeObject* template MaybeObject*
Dictionary<NameDictionary, NameDictionaryShape, Name*>:: Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::
EnsureCapacity(int, Name*); EnsureCapacity(int, Handle<Name>);
template MaybeObject* template MaybeObject*
Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>:: Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>::
@ -15018,15 +15029,15 @@ Dictionary<UnseededNumberDictionary, UnseededNumberDictionaryShape, uint32_t>::
AddEntry(uint32_t, Object*, PropertyDetails, uint32_t); AddEntry(uint32_t, Object*, PropertyDetails, uint32_t);
template MaybeObject* template MaybeObject*
Dictionary<NameDictionary, NameDictionaryShape, Name*>::AddEntry( Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::AddEntry(
Name*, Object*, PropertyDetails, uint32_t); Handle<Name>, Object*, PropertyDetails, uint32_t);
template template
int Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>:: int Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>::
NumberOfEnumElements(); NumberOfEnumElements();
template template
int Dictionary<NameDictionary, NameDictionaryShape, Name*>:: int Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::
NumberOfEnumElements(); NumberOfEnumElements();
template template
@ -15039,7 +15050,7 @@ Handle<NameDictionary> NameDictionary::AddNameEntry(Handle<NameDictionary> dict,
Handle<Object> value, Handle<Object> value,
PropertyDetails details) { PropertyDetails details) {
CALL_HEAP_FUNCTION(dict->GetIsolate(), CALL_HEAP_FUNCTION(dict->GetIsolate(),
dict->Add(*name, *value, details), dict->Add(name, *value, details),
NameDictionary); NameDictionary);
} }
@ -15477,7 +15488,7 @@ Handle<PropertyCell> JSGlobalObject::EnsurePropertyCell(
Handle<JSGlobalObject> global, Handle<JSGlobalObject> global,
Handle<Name> name) { Handle<Name> name) {
ASSERT(!global->HasFastProperties()); ASSERT(!global->HasFastProperties());
int entry = global->property_dictionary()->FindEntry(*name); int entry = global->property_dictionary()->FindEntry(name);
if (entry == NameDictionary::kNotFound) { if (entry == NameDictionary::kNotFound) {
Isolate* isolate = global->GetIsolate(); Isolate* isolate = global->GetIsolate();
Handle<PropertyCell> cell = isolate->factory()->NewPropertyCell( Handle<PropertyCell> cell = isolate->factory()->NewPropertyCell(

View File

@ -4119,14 +4119,14 @@ class Dictionary: public HashTable<Derived, Shape, Key> {
}; };
class NameDictionaryShape : public BaseShape<Name*> { class NameDictionaryShape : public BaseShape<Handle<Name> > {
public: public:
static inline bool IsMatch(Name* key, Object* other); static inline bool IsMatch(Handle<Name> key, Object* other);
static inline uint32_t Hash(Name* key); static inline uint32_t Hash(Handle<Name> key);
static inline uint32_t HashForObject(Name* key, Object* object); static inline uint32_t HashForObject(Handle<Name> key, Object* object);
MUST_USE_RESULT static inline MaybeObject* AsObject(Heap* heap, MUST_USE_RESULT static inline MaybeObject* AsObject(Heap* heap,
Name* key); Handle<Name> key);
static inline Handle<Object> AsHandle(Isolate* isolate, Name* key); static inline Handle<Object> AsHandle(Isolate* isolate, Handle<Name> key);
static const int kPrefixSize = 2; static const int kPrefixSize = 2;
static const int kEntrySize = 3; static const int kEntrySize = 3;
static const bool kIsEnumerable = true; static const bool kIsEnumerable = true;
@ -4135,7 +4135,7 @@ class NameDictionaryShape : public BaseShape<Name*> {
class NameDictionary: public Dictionary<NameDictionary, class NameDictionary: public Dictionary<NameDictionary,
NameDictionaryShape, NameDictionaryShape,
Name*> { Handle<Name> > {
public: public:
static inline NameDictionary* cast(Object* obj) { static inline NameDictionary* cast(Object* obj) {
ASSERT(obj->IsDictionary()); ASSERT(obj->IsDictionary());
@ -4149,6 +4149,9 @@ class NameDictionary: public Dictionary<NameDictionary,
// Find entry for key, otherwise return kNotFound. Optimized version of // Find entry for key, otherwise return kNotFound. Optimized version of
// HashTable::FindEntry. // HashTable::FindEntry.
int FindEntry(Handle<Name> key);
// TODO(ishell): Remove this when all the callers are handlified.
int FindEntry(Name* key); int FindEntry(Name* key);
// TODO(mstarzinger): Temporary wrapper until handlified. // TODO(mstarzinger): Temporary wrapper until handlified.

View File

@ -3074,7 +3074,7 @@ RUNTIME_FUNCTION(Runtime_FunctionSetReadOnlyPrototype) {
} else { // Dictionary properties. } else { // Dictionary properties.
// Directly manipulate the property details. // Directly manipulate the property details.
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
int entry = function->property_dictionary()->FindEntry(*name); int entry = function->property_dictionary()->FindEntry(name);
ASSERT(entry != NameDictionary::kNotFound); ASSERT(entry != NameDictionary::kNotFound);
PropertyDetails details = function->property_dictionary()->DetailsAt(entry); PropertyDetails details = function->property_dictionary()->DetailsAt(entry);
PropertyDetails new_details( PropertyDetails new_details(
@ -15138,7 +15138,7 @@ void Runtime::InitializeIntrinsicFunctionNames(Isolate* isolate,
const Runtime::Function* Runtime::FunctionForName(Handle<String> name) { const Runtime::Function* Runtime::FunctionForName(Handle<String> name) {
Heap* heap = name->GetHeap(); Heap* heap = name->GetHeap();
int entry = heap->intrinsic_function_names()->FindEntry(*name); int entry = heap->intrinsic_function_names()->FindEntry(name);
if (entry != kNotFound) { if (entry != kNotFound) {
Object* smi_index = heap->intrinsic_function_names()->ValueAt(entry); Object* smi_index = heap->intrinsic_function_names()->ValueAt(entry);
int function_index = Smi::cast(smi_index)->value(); int function_index = Smi::cast(smi_index)->value();

View File

@ -891,7 +891,7 @@ void LoadStubCompiler::NonexistentHandlerFrontend(Handle<HeapType> type,
name = factory()->InternalizeString(Handle<String>::cast(name)); name = factory()->InternalizeString(Handle<String>::cast(name));
} }
ASSERT(last.is_null() || ASSERT(last.is_null() ||
last->property_dictionary()->FindEntry(*name) == last->property_dictionary()->FindEntry(name) ==
NameDictionary::kNotFound); NameDictionary::kNotFound);
GenerateDictionaryNegativeLookup(masm(), &miss, holder, name, GenerateDictionaryNegativeLookup(masm(), &miss, holder, name,
scratch2(), scratch3()); scratch2(), scratch3());

View File

@ -796,7 +796,7 @@ Register StubCompiler::CheckPrototypes(Handle<HeapType> type,
name = factory()->InternalizeString(Handle<String>::cast(name)); name = factory()->InternalizeString(Handle<String>::cast(name));
} }
ASSERT(current.is_null() || ASSERT(current.is_null() ||
current->property_dictionary()->FindEntry(*name) == current->property_dictionary()->FindEntry(name) ==
NameDictionary::kNotFound); NameDictionary::kNotFound);
GenerateDictionaryNegativeLookup(masm(), miss, reg, name, GenerateDictionaryNegativeLookup(masm(), miss, reg, name,