Dictionary::New() handlified.
R=yangguo@chromium.org Review URL: https://codereview.chromium.org/246743003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20957 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
28f5cf398e
commit
c8d36c711c
@ -131,35 +131,6 @@ Handle<ConstantPoolArray> Factory::NewConstantPoolArray(
|
||||
}
|
||||
|
||||
|
||||
Handle<NameDictionary> Factory::NewNameDictionary(int at_least_space_for) {
|
||||
ASSERT(0 <= at_least_space_for);
|
||||
CALL_HEAP_FUNCTION(isolate(),
|
||||
NameDictionary::Allocate(isolate()->heap(),
|
||||
at_least_space_for),
|
||||
NameDictionary);
|
||||
}
|
||||
|
||||
|
||||
Handle<SeededNumberDictionary> Factory::NewSeededNumberDictionary(
|
||||
int at_least_space_for) {
|
||||
ASSERT(0 <= at_least_space_for);
|
||||
CALL_HEAP_FUNCTION(isolate(),
|
||||
SeededNumberDictionary::Allocate(isolate()->heap(),
|
||||
at_least_space_for),
|
||||
SeededNumberDictionary);
|
||||
}
|
||||
|
||||
|
||||
Handle<UnseededNumberDictionary> Factory::NewUnseededNumberDictionary(
|
||||
int at_least_space_for) {
|
||||
ASSERT(0 <= at_least_space_for);
|
||||
CALL_HEAP_FUNCTION(isolate(),
|
||||
UnseededNumberDictionary::Allocate(isolate()->heap(),
|
||||
at_least_space_for),
|
||||
UnseededNumberDictionary);
|
||||
}
|
||||
|
||||
|
||||
Handle<OrderedHashSet> Factory::NewOrderedHashSet() {
|
||||
return OrderedHashSet::Allocate(isolate(), 4);
|
||||
}
|
||||
@ -1488,7 +1459,8 @@ Handle<GlobalObject> Factory::NewGlobalObject(Handle<JSFunction> constructor) {
|
||||
|
||||
// Allocate a dictionary object for backing storage.
|
||||
int at_least_space_for = map->NumberOfOwnDescriptors() * 2 + initial_size;
|
||||
Handle<NameDictionary> dictionary = NewNameDictionary(at_least_space_for);
|
||||
Handle<NameDictionary> dictionary =
|
||||
NameDictionary::New(isolate(), at_least_space_for);
|
||||
|
||||
// The global object might be created from an object template with accessors.
|
||||
// Fill these accessors into the dictionary.
|
||||
|
@ -50,14 +50,6 @@ class Factory V8_FINAL {
|
||||
int number_of_heap_ptr_entries,
|
||||
int number_of_int32_entries);
|
||||
|
||||
Handle<SeededNumberDictionary> NewSeededNumberDictionary(
|
||||
int at_least_space_for);
|
||||
|
||||
Handle<UnseededNumberDictionary> NewUnseededNumberDictionary(
|
||||
int at_least_space_for);
|
||||
|
||||
Handle<NameDictionary> NewNameDictionary(int at_least_space_for);
|
||||
|
||||
Handle<ObjectHashTable> NewObjectHashTable(
|
||||
int at_least_space_for,
|
||||
MinimumCapacity capacity_option = USE_DEFAULT_MINIMUM_CAPACITY);
|
||||
|
24
src/heap.cc
24
src/heap.cc
@ -2916,20 +2916,13 @@ bool Heap::CreateInitialObjects() {
|
||||
}
|
||||
hidden_string_ = String::cast(obj);
|
||||
|
||||
// Allocate the code_stubs dictionary. The initial size is set to avoid
|
||||
// Create the code_stubs dictionary. The initial size is set to avoid
|
||||
// expanding the dictionary during bootstrapping.
|
||||
{ MaybeObject* maybe_obj = UnseededNumberDictionary::Allocate(this, 128);
|
||||
if (!maybe_obj->ToObject(&obj)) return false;
|
||||
}
|
||||
set_code_stubs(UnseededNumberDictionary::cast(obj));
|
||||
set_code_stubs(*UnseededNumberDictionary::New(isolate(), 128));
|
||||
|
||||
|
||||
// Allocate the non_monomorphic_cache used in stub-cache.cc. The initial size
|
||||
// Create the non_monomorphic_cache used in stub-cache.cc. The initial size
|
||||
// is set to avoid expanding the dictionary during bootstrapping.
|
||||
{ MaybeObject* maybe_obj = UnseededNumberDictionary::Allocate(this, 64);
|
||||
if (!maybe_obj->ToObject(&obj)) return false;
|
||||
}
|
||||
set_non_monomorphic_cache(UnseededNumberDictionary::cast(obj));
|
||||
set_non_monomorphic_cache(*UnseededNumberDictionary::New(isolate(), 64));
|
||||
|
||||
{ MaybeObject* maybe_obj = AllocatePolymorphicCodeCache();
|
||||
if (!maybe_obj->ToObject(&obj)) return false;
|
||||
@ -3037,11 +3030,12 @@ bool Heap::CreateInitialObjects() {
|
||||
Symbol::cast(obj)->set_is_private(true);
|
||||
set_megamorphic_symbol(Symbol::cast(obj));
|
||||
|
||||
{ MaybeObject* maybe_obj = SeededNumberDictionary::Allocate(this, 0, TENURED);
|
||||
if (!maybe_obj->ToObject(&obj)) return false;
|
||||
{
|
||||
Handle<SeededNumberDictionary> dict =
|
||||
SeededNumberDictionary::New(isolate(), 0, TENURED);
|
||||
dict->set_requires_slow_elements();
|
||||
set_empty_slow_element_dictionary(*dict);
|
||||
}
|
||||
SeededNumberDictionary::cast(obj)->set_requires_slow_elements();
|
||||
set_empty_slow_element_dictionary(SeededNumberDictionary::cast(obj));
|
||||
|
||||
{ MaybeObject* maybe_obj = AllocateSymbol();
|
||||
if (!maybe_obj->ToObject(&obj)) return false;
|
||||
|
@ -4630,7 +4630,7 @@ void JSObject::NormalizeProperties(Handle<JSObject> object,
|
||||
property_count += 2; // Make space for two more properties.
|
||||
}
|
||||
Handle<NameDictionary> dictionary =
|
||||
isolate->factory()->NewNameDictionary(property_count);
|
||||
NameDictionary::New(isolate, property_count);
|
||||
|
||||
Handle<DescriptorArray> descs(map->instance_descriptors());
|
||||
for (int i = 0; i < real_size; i++) {
|
||||
@ -4853,9 +4853,10 @@ void JSObject::TransformToFastProperties(Handle<JSObject> object,
|
||||
void JSObject::ResetElements(Handle<JSObject> object) {
|
||||
if (object->map()->is_observed()) {
|
||||
// Maintain invariant that observed elements are always in dictionary mode.
|
||||
Factory* factory = object->GetIsolate()->factory();
|
||||
Isolate* isolate = object->GetIsolate();
|
||||
Factory* factory = isolate->factory();
|
||||
Handle<SeededNumberDictionary> dictionary =
|
||||
factory->NewSeededNumberDictionary(0);
|
||||
SeededNumberDictionary::New(isolate, 0);
|
||||
if (object->map() == *factory->sloppy_arguments_elements_map()) {
|
||||
FixedArray::cast(object->elements())->set(1, *dictionary);
|
||||
} else {
|
||||
@ -4910,7 +4911,6 @@ Handle<SeededNumberDictionary> JSObject::NormalizeElements(
|
||||
ASSERT(!object->HasExternalArrayElements() &&
|
||||
!object->HasFixedTypedArrayElements());
|
||||
Isolate* isolate = object->GetIsolate();
|
||||
Factory* factory = isolate->factory();
|
||||
|
||||
// Find the backing store.
|
||||
Handle<FixedArrayBase> array(FixedArrayBase::cast(object->elements()));
|
||||
@ -4933,7 +4933,7 @@ Handle<SeededNumberDictionary> JSObject::NormalizeElements(
|
||||
int used_elements = 0;
|
||||
object->GetElementsCapacityAndUsage(&old_capacity, &used_elements);
|
||||
Handle<SeededNumberDictionary> dictionary =
|
||||
factory->NewSeededNumberDictionary(used_elements);
|
||||
SeededNumberDictionary::New(isolate, used_elements);
|
||||
|
||||
dictionary = CopyFastElementsToDictionary(array, length, dictionary);
|
||||
|
||||
@ -5746,8 +5746,7 @@ MaybeHandle<Object> JSObject::Freeze(Handle<JSObject> object) {
|
||||
int capacity = 0;
|
||||
int used = 0;
|
||||
object->GetElementsCapacityAndUsage(&capacity, &used);
|
||||
new_element_dictionary =
|
||||
isolate->factory()->NewSeededNumberDictionary(used);
|
||||
new_element_dictionary = SeededNumberDictionary::New(isolate, used);
|
||||
|
||||
// Move elements to a dictionary; avoid calling NormalizeElements to avoid
|
||||
// unnecessary transitions.
|
||||
@ -14897,21 +14896,17 @@ template class Dictionary<UnseededNumberDictionary,
|
||||
UnseededNumberDictionaryShape,
|
||||
uint32_t>;
|
||||
|
||||
template MaybeObject*
|
||||
template Handle<SeededNumberDictionary>
|
||||
Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>::
|
||||
Allocate(Heap* heap, int at_least_space_for, PretenureFlag pretenure);
|
||||
New(Isolate*, int at_least_space_for, PretenureFlag pretenure);
|
||||
|
||||
template MaybeObject*
|
||||
template Handle<UnseededNumberDictionary>
|
||||
Dictionary<UnseededNumberDictionary, UnseededNumberDictionaryShape, uint32_t>::
|
||||
Allocate(Heap* heap, int at_least_space_for, PretenureFlag pretenure);
|
||||
|
||||
template MaybeObject*
|
||||
Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::
|
||||
Allocate(Heap* heap, int n, PretenureFlag pretenure);
|
||||
New(Isolate*, int at_least_space_for, PretenureFlag pretenure);
|
||||
|
||||
template Handle<NameDictionary>
|
||||
Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::
|
||||
New(Isolate* isolate, int n, PretenureFlag pretenure);
|
||||
New(Isolate*, int n, PretenureFlag pretenure);
|
||||
|
||||
template Handle<SeededNumberDictionary>
|
||||
Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>::
|
||||
@ -15061,7 +15056,7 @@ Handle<Object> JSObject::PrepareSlowElementsForSort(
|
||||
// elements.
|
||||
Handle<SeededNumberDictionary> dict(object->element_dictionary(), isolate);
|
||||
Handle<SeededNumberDictionary> new_dict =
|
||||
isolate->factory()->NewSeededNumberDictionary(dict->NumberOfElements());
|
||||
SeededNumberDictionary::New(isolate, dict->NumberOfElements());
|
||||
|
||||
uint32_t pos = 0;
|
||||
uint32_t undefs = 0;
|
||||
@ -15793,32 +15788,12 @@ Handle<MapCache> MapCache::Put(
|
||||
}
|
||||
|
||||
|
||||
template<typename Derived, typename Shape, typename Key>
|
||||
MaybeObject* Dictionary<Derived, Shape, Key>::Allocate(
|
||||
Heap* heap,
|
||||
int at_least_space_for,
|
||||
PretenureFlag pretenure) {
|
||||
Object* obj;
|
||||
{ MaybeObject* maybe_obj =
|
||||
DerivedHashTable::Allocate(
|
||||
heap,
|
||||
at_least_space_for,
|
||||
USE_DEFAULT_MINIMUM_CAPACITY,
|
||||
pretenure);
|
||||
if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
||||
}
|
||||
// Initialize the next enumeration index.
|
||||
Dictionary::cast(obj)->
|
||||
SetNextEnumerationIndex(PropertyDetails::kInitialIndex);
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
template<typename Derived, typename Shape, typename Key>
|
||||
Handle<Derived> Dictionary<Derived, Shape, Key>::New(
|
||||
Isolate* isolate,
|
||||
int at_least_space_for,
|
||||
PretenureFlag pretenure) {
|
||||
ASSERT(0 <= at_least_space_for);
|
||||
Handle<Derived> dict = DerivedHashTable::New(isolate,
|
||||
at_least_space_for,
|
||||
USE_DEFAULT_MINIMUM_CAPACITY,
|
||||
|
@ -4057,12 +4057,6 @@ class Dictionary: public HashTable<Derived, Shape, Key> {
|
||||
return Smi::cast(this->get(kNextEnumerationIndexIndex))->value();
|
||||
}
|
||||
|
||||
// Returns a new array for dictionary usage. Might return Failure.
|
||||
MUST_USE_RESULT static MaybeObject* Allocate(
|
||||
Heap* heap,
|
||||
int at_least_space_for,
|
||||
PretenureFlag pretenure = NOT_TENURED);
|
||||
|
||||
// Creates a new dictionary.
|
||||
MUST_USE_RESULT static Handle<Derived> New(
|
||||
Isolate* isolate,
|
||||
|
@ -10049,8 +10049,7 @@ class ArrayConcatVisitor {
|
||||
ASSERT(fast_elements_);
|
||||
Handle<FixedArray> current_storage(*storage_);
|
||||
Handle<SeededNumberDictionary> slow_storage(
|
||||
isolate_->factory()->NewSeededNumberDictionary(
|
||||
current_storage->length()));
|
||||
SeededNumberDictionary::New(isolate_, current_storage->length()));
|
||||
uint32_t current_length = static_cast<uint32_t>(current_storage->length());
|
||||
for (uint32_t i = 0; i < current_length; i++) {
|
||||
HandleScope loop_scope(isolate_);
|
||||
@ -10596,7 +10595,7 @@ RUNTIME_FUNCTION(Runtime_ArrayConcat) {
|
||||
uint32_t at_least_space_for = estimate_nof_elements +
|
||||
(estimate_nof_elements >> 2);
|
||||
storage = Handle<FixedArray>::cast(
|
||||
isolate->factory()->NewSeededNumberDictionary(at_least_space_for));
|
||||
SeededNumberDictionary::New(isolate, at_least_space_for));
|
||||
}
|
||||
|
||||
ArrayConcatVisitor visitor(isolate, storage, fast_case);
|
||||
|
@ -445,8 +445,7 @@ void TypeFeedbackOracle::CreateDictionary(Handle<Code> code,
|
||||
ZoneList<RelocInfo>* infos) {
|
||||
AllowHeapAllocation allocation_allowed;
|
||||
Code* old_code = *code;
|
||||
dictionary_ =
|
||||
isolate()->factory()->NewUnseededNumberDictionary(infos->length());
|
||||
dictionary_ = UnseededNumberDictionary::New(isolate(), infos->length());
|
||||
RelocateRelocInfos(infos, old_code, *code);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user