}
-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);
}
// 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.
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);
}
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;
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;
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++) {
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 {
ASSERT(!object->HasExternalArrayElements() &&
!object->HasFixedTypedArrayElements());
Isolate* isolate = object->GetIsolate();
- Factory* factory = isolate->factory();
// Find the backing store.
Handle<FixedArrayBase> array(FixedArrayBase::cast(object->elements()));
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);
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.
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>::
// 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;
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,
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,
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_);
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);
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);
}