CompilationCache::~CompilationCache() {}
-static Handle<CompilationCacheTable> AllocateTable(Isolate* isolate, int size) {
- CALL_HEAP_FUNCTION(isolate,
- CompilationCacheTable::Allocate(isolate->heap(), size),
- CompilationCacheTable);
-}
-
-
Handle<CompilationCacheTable> CompilationSubCache::GetTable(int generation) {
ASSERT(generation < generations_);
Handle<CompilationCacheTable> result;
if (tables_[generation]->IsUndefined()) {
- result = AllocateTable(isolate(), kInitialCacheSize);
+ result = CompilationCacheTable::New(isolate(), kInitialCacheSize);
tables_[generation] = *result;
} else {
CompilationCacheTable* table =
}
-Handle<ObjectHashTable> Factory::NewObjectHashTable(
- int at_least_space_for,
- MinimumCapacity capacity_option) {
- ASSERT(0 <= at_least_space_for);
- CALL_HEAP_FUNCTION(isolate(),
- ObjectHashTable::Allocate(isolate()->heap(),
- at_least_space_for,
- capacity_option),
- ObjectHashTable);
-}
-
-
-Handle<WeakHashTable> Factory::NewWeakHashTable(int at_least_space_for) {
- ASSERT(0 <= at_least_space_for);
- CALL_HEAP_FUNCTION(
- isolate(),
- WeakHashTable::Allocate(isolate()->heap(),
- at_least_space_for,
- USE_DEFAULT_MINIMUM_CAPACITY,
- TENURED),
- WeakHashTable);
-}
-
-
Handle<DeoptimizationInputData> Factory::NewDeoptimizationInputData(
int deopt_entry_count,
PretenureFlag pretenure) {
}
-Handle<MapCache> Factory::NewMapCache(int at_least_space_for) {
- CALL_HEAP_FUNCTION(isolate(),
- MapCache::Allocate(isolate()->heap(),
- at_least_space_for),
- MapCache);
-}
-
-
Handle<MapCache> Factory::AddToMapCache(Handle<Context> context,
Handle<FixedArray> keys,
Handle<Map> map) {
Handle<FixedArray> keys) {
if (context->map_cache()->IsUndefined()) {
// Allocate the new map cache for the native context.
- Handle<MapCache> new_cache = NewMapCache(24);
+ Handle<MapCache> new_cache = MapCache::New(isolate(), 24);
context->set_map_cache(*new_cache);
}
// Check to see whether there is a matching element in the cache.
int number_of_heap_ptr_entries,
int number_of_int32_entries);
- Handle<ObjectHashTable> NewObjectHashTable(
- int at_least_space_for,
- MinimumCapacity capacity_option = USE_DEFAULT_MINIMUM_CAPACITY);
-
Handle<OrderedHashSet> NewOrderedHashSet();
Handle<OrderedHashMap> NewOrderedHashMap();
- Handle<WeakHashTable> NewWeakHashTable(int at_least_space_for);
-
Handle<DeoptimizationInputData> NewDeoptimizationInputData(
int deopt_entry_count,
PretenureFlag pretenure);
void Heap::EnsureWeakObjectToCodeTable() {
if (!weak_object_to_code_table()->IsHashTable()) {
- set_weak_object_to_code_table(*isolate()->factory()->NewWeakHashTable(16));
+ set_weak_object_to_code_table(*WeakHashTable::New(
+ isolate(), 16, USE_DEFAULT_MINIMUM_CAPACITY, TENURED));
}
}
return Handle<ObjectHashTable>::cast(inline_value);
}
- Handle<ObjectHashTable> hashtable = isolate->factory()->NewObjectHashTable(
- kInitialCapacity,
- USE_CUSTOM_MINIMUM_CAPACITY);
+ Handle<ObjectHashTable> hashtable = ObjectHashTable::New(
+ isolate, kInitialCapacity, USE_CUSTOM_MINIMUM_CAPACITY);
if (inline_value->IsSmi()) {
// We were storing the identity hash inline and now allocated an actual
template<typename Derived, typename Shape, typename Key>
-MaybeObject* HashTable<Derived, Shape, Key>::Allocate(
- Heap* heap,
+Handle<Derived> HashTable<Derived, Shape, Key>::New(
+ Isolate* isolate,
int at_least_space_for,
MinimumCapacity capacity_option,
PretenureFlag pretenure) {
+ ASSERT(0 <= at_least_space_for);
ASSERT(!capacity_option || IsPowerOf2(at_least_space_for));
int capacity = (capacity_option == USE_CUSTOM_MINIMUM_CAPACITY)
? at_least_space_for
v8::internal::Heap::FatalProcessOutOfMemory("invalid table size", true);
}
- Object* obj;
- { MaybeObject* maybe_obj =
- heap-> AllocateHashTable(EntryToIndex(capacity), pretenure);
- if (!maybe_obj->ToObject(&obj)) return maybe_obj;
- }
- HashTable::cast(obj)->SetNumberOfElements(0);
- HashTable::cast(obj)->SetNumberOfDeletedElements(0);
- HashTable::cast(obj)->SetCapacity(capacity);
- return obj;
-}
-
+ Factory* factory = isolate->factory();
+ int length = EntryToIndex(capacity);
+ Handle<FixedArray> array = factory->NewFixedArray(length, pretenure);
+ array->set_map_no_write_barrier(*factory->hash_table_map());
+ Handle<Derived> table = Handle<Derived>::cast(array);
-template<typename Derived, typename Shape, typename Key>
-Handle<Derived> HashTable<Derived, Shape, Key>::New(
- Isolate* isolate,
- int at_least_space_for,
- MinimumCapacity capacity_option,
- PretenureFlag pretenure) {
- CALL_HEAP_FUNCTION(
- isolate,
- Allocate(isolate->heap(), at_least_space_for, capacity_option, pretenure),
- Derived);
+ table->SetNumberOfElements(0);
+ table->SetNumberOfDeletedElements(0);
+ table->SetCapacity(capacity);
+ return table;
}
SetNumberOfDeletedElements(NumberOfDeletedElements() + n);
}
- // Returns a new HashTable object. Might return Failure.
- // TODO(ishell): this will be eventually replaced by New().
- MUST_USE_RESULT static MaybeObject* Allocate(
- Heap* heap,
- int at_least_space_for,
- MinimumCapacity capacity_option = USE_DEFAULT_MINIMUM_CAPACITY,
- PretenureFlag pretenure = NOT_TENURED);
-
// Returns a new HashTable object.
MUST_USE_RESULT static Handle<Derived> New(
Isolate* isolate,
Isolate* isolate,
Handle<JSWeakCollection> weak_collection) {
ASSERT(weak_collection->map()->inobject_properties() == 0);
- Handle<ObjectHashTable> table = isolate->factory()->NewObjectHashTable(0);
+ Handle<ObjectHashTable> table = ObjectHashTable::New(isolate, 0);
weak_collection->set_table(*table);
weak_collection->set_next(Smi::FromInt(0));
return weak_collection;
LocalContext context;
v8::HandleScope scope(context->GetIsolate());
Isolate* isolate = CcTest::i_isolate();
- TestHashMap(isolate->factory()->NewObjectHashTable(23));
+ TestHashMap(ObjectHashTable::New(isolate, 23));
TestHashMap(isolate->factory()->NewOrderedHashMap());
}
TEST(HashTableRehash) {
LocalContext context;
Isolate* isolate = CcTest::i_isolate();
- Factory* factory = isolate->factory();
v8::HandleScope scope(context->GetIsolate());
// Test almost filled table.
{
- Handle<ObjectHashTable> table = factory->NewObjectHashTable(100);
+ Handle<ObjectHashTable> table = ObjectHashTable::New(isolate, 100);
ObjectHashTableTest* t = reinterpret_cast<ObjectHashTableTest*>(*table);
int capacity = t->capacity();
for (int i = 0; i < capacity - 1; i++) {
}
// Test half-filled table.
{
- Handle<ObjectHashTable> table = factory->NewObjectHashTable(100);
+ Handle<ObjectHashTable> table = ObjectHashTable::New(isolate, 100);
ObjectHashTableTest* t = reinterpret_cast<ObjectHashTableTest*>(*table);
int capacity = t->capacity();
for (int i = 0; i < capacity / 2; i++) {
LocalContext context;
v8::HandleScope scope(context->GetIsolate());
Isolate* isolate = CcTest::i_isolate();
- TestHashMapCausesGC(isolate->factory()->NewObjectHashTable(1));
+ TestHashMapCausesGC(ObjectHashTable::New(isolate, 1));
TestHashMapCausesGC(isolate->factory()->NewOrderedHashMap());
}
#endif
static Handle<JSWeakMap> AllocateJSWeakMap(Isolate* isolate) {
Factory* factory = isolate->factory();
- Heap* heap = isolate->heap();
Handle<Map> map = factory->NewMap(JS_WEAK_MAP_TYPE, JSWeakMap::kSize);
Handle<JSObject> weakmap_obj = factory->NewJSObjectFromMap(map);
Handle<JSWeakMap> weakmap(JSWeakMap::cast(*weakmap_obj));
// Do not use handles for the hash table, it would make entries strong.
- Object* table_obj = ObjectHashTable::Allocate(heap, 1)->ToObjectChecked();
- ObjectHashTable* table = ObjectHashTable::cast(table_obj);
- weakmap->set_table(table);
+ Handle<ObjectHashTable> table = ObjectHashTable::New(isolate, 1);
+ weakmap->set_table(*table);
weakmap->set_next(Smi::FromInt(0));
return weakmap;
}
static Handle<JSWeakSet> AllocateJSWeakSet(Isolate* isolate) {
Factory* factory = isolate->factory();
- Heap* heap = isolate->heap();
Handle<Map> map = factory->NewMap(JS_WEAK_SET_TYPE, JSWeakSet::kSize);
Handle<JSObject> weakset_obj = factory->NewJSObjectFromMap(map);
Handle<JSWeakSet> weakset(JSWeakSet::cast(*weakset_obj));
// Do not use handles for the hash table, it would make entries strong.
- Object* table_obj = ObjectHashTable::Allocate(heap, 1)->ToObjectChecked();
- ObjectHashTable* table = ObjectHashTable::cast(table_obj);
- weakset->set_table(table);
+ Handle<ObjectHashTable> table = ObjectHashTable::New(isolate, 1);
+ weakset->set_table(*table);
weakset->set_next(Smi::FromInt(0));
return weakset;
}