Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(849)

Unified Diff: src/objects.cc

Issue 257633002: HashTable::New() handlified. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.h ('k') | src/runtime.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 6900029665ac476b0523b4d767c0490a540dadf9..82ba2b4a092b07a3b1fcb57d9364495b0be67e47 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -5180,9 +5180,8 @@ Handle<ObjectHashTable> JSObject::GetOrCreateHiddenPropertiesHashtable(
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
@@ -14589,11 +14588,12 @@ void HashTable<Derived, Shape, Key>::IterateElements(ObjectVisitor* v) {
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
@@ -14602,28 +14602,16 @@ MaybeObject* HashTable<Derived, Shape, Key>::Allocate(
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;
}
« no previous file with comments | « src/objects.h ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698