Revision: 20957
Author: [email protected]
Date: Fri Apr 25 07:56:13 2014 UTC
Log: Dictionary::New() handlified.
[email protected]
Review URL: https://codereview.chromium.org/246743003
http://code.google.com/p/v8/source/detail?r=20957
Modified:
/branches/bleeding_edge/src/factory.cc
/branches/bleeding_edge/src/factory.h
/branches/bleeding_edge/src/heap.cc
/branches/bleeding_edge/src/objects.cc
/branches/bleeding_edge/src/objects.h
/branches/bleeding_edge/src/runtime.cc
/branches/bleeding_edge/src/type-info.cc
=======================================
--- /branches/bleeding_edge/src/factory.cc Thu Apr 24 15:45:44 2014 UTC
+++ /branches/bleeding_edge/src/factory.cc Fri Apr 25 07:56:13 2014 UTC
@@ -129,35 +129,6 @@
number_of_int32_entries),
ConstantPoolArray);
}
-
-
-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() {
@@ -1488,7 +1459,8 @@
// 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.
=======================================
--- /branches/bleeding_edge/src/factory.h Thu Apr 24 10:39:50 2014 UTC
+++ /branches/bleeding_edge/src/factory.h Fri Apr 25 07:56:13 2014 UTC
@@ -50,14 +50,6 @@
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);
=======================================
--- /branches/bleeding_edge/src/heap.cc Thu Apr 24 12:07:40 2014 UTC
+++ /branches/bleeding_edge/src/heap.cc Fri Apr 25 07:56:13 2014 UTC
@@ -2916,20 +2916,13 @@
}
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 @@
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;
=======================================
--- /branches/bleeding_edge/src/objects.cc Thu Apr 24 15:33:40 2014 UTC
+++ /branches/bleeding_edge/src/objects.cc Fri Apr 25 07:56:13 2014 UTC
@@ -4630,7 +4630,7 @@
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::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 @@
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 @@
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 @@
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 @@
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 @@
// 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;
@@ -15791,27 +15786,6 @@
new_cache->ElementAdded();
return new_cache;
}
-
-
-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>
@@ -15819,6 +15793,7 @@
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,
=======================================
--- /branches/bleeding_edge/src/objects.h Thu Apr 24 15:33:40 2014 UTC
+++ /branches/bleeding_edge/src/objects.h Fri Apr 25 07:56:13 2014 UTC
@@ -4056,12 +4056,6 @@
int NextEnumerationIndex() {
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(
=======================================
--- /branches/bleeding_edge/src/runtime.cc Fri Apr 25 07:03:05 2014 UTC
+++ /branches/bleeding_edge/src/runtime.cc Fri Apr 25 07:56:13 2014 UTC
@@ -10049,8 +10049,7 @@
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 @@
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);
=======================================
--- /branches/bleeding_edge/src/type-info.cc Thu Apr 24 10:39:50 2014 UTC
+++ /branches/bleeding_edge/src/type-info.cc Fri Apr 25 07:56:13 2014 UTC
@@ -445,8 +445,7 @@
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);
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.