static Handle<CompilationCacheTable> AllocateTable(Isolate* isolate, int size) {
CALL_HEAP_FUNCTION(isolate,
- CompilationCacheTable::Allocate(size),
+ CompilationCacheTable::Allocate(isolate->heap(), size),
CompilationCacheTable);
}
Handle<NameDictionary> Factory::NewNameDictionary(int at_least_space_for) {
ASSERT(0 <= at_least_space_for);
CALL_HEAP_FUNCTION(isolate(),
- NameDictionary::Allocate(at_least_space_for),
+ NameDictionary::Allocate(isolate()->heap(),
+ at_least_space_for),
NameDictionary);
}
int at_least_space_for) {
ASSERT(0 <= at_least_space_for);
CALL_HEAP_FUNCTION(isolate(),
- SeededNumberDictionary::Allocate(at_least_space_for),
+ SeededNumberDictionary::Allocate(isolate()->heap(),
+ at_least_space_for),
SeededNumberDictionary);
}
int at_least_space_for) {
ASSERT(0 <= at_least_space_for);
CALL_HEAP_FUNCTION(isolate(),
- UnseededNumberDictionary::Allocate(at_least_space_for),
+ UnseededNumberDictionary::Allocate(isolate()->heap(),
+ at_least_space_for),
UnseededNumberDictionary);
}
Handle<ObjectHashSet> Factory::NewObjectHashSet(int at_least_space_for) {
ASSERT(0 <= at_least_space_for);
CALL_HEAP_FUNCTION(isolate(),
- ObjectHashSet::Allocate(at_least_space_for),
+ ObjectHashSet::Allocate(isolate()->heap(),
+ at_least_space_for),
ObjectHashSet);
}
Handle<ObjectHashTable> Factory::NewObjectHashTable(int at_least_space_for) {
ASSERT(0 <= at_least_space_for);
CALL_HEAP_FUNCTION(isolate(),
- ObjectHashTable::Allocate(at_least_space_for),
+ ObjectHashTable::Allocate(isolate()->heap(),
+ at_least_space_for),
ObjectHashTable);
}
Handle<MapCache> Factory::NewMapCache(int at_least_space_for) {
CALL_HEAP_FUNCTION(isolate(),
- MapCache::Allocate(at_least_space_for), MapCache);
+ MapCache::Allocate(isolate()->heap(),
+ at_least_space_for),
+ MapCache);
}
set_the_hole_value(reinterpret_cast<Oddball*>(Smi::FromInt(0)));
// Allocate initial string table.
- { MaybeObject* maybe_obj = StringTable::Allocate(kInitialStringTableSize);
+ { MaybeObject* maybe_obj =
+ StringTable::Allocate(this, kInitialStringTableSize);
if (!maybe_obj->ToObject(&obj)) return false;
}
// Don't use set_string_table() due to asserts.
// Allocate the code_stubs dictionary. The initial size is set to avoid
// expanding the dictionary during bootstrapping.
- { MaybeObject* maybe_obj = UnseededNumberDictionary::Allocate(128);
+ { MaybeObject* maybe_obj = UnseededNumberDictionary::Allocate(this, 128);
if (!maybe_obj->ToObject(&obj)) return false;
}
set_code_stubs(UnseededNumberDictionary::cast(obj));
// Allocate 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(64);
+ { MaybeObject* maybe_obj = UnseededNumberDictionary::Allocate(this, 64);
if (!maybe_obj->ToObject(&obj)) return false;
}
set_non_monomorphic_cache(UnseededNumberDictionary::cast(obj));
CreateFixedStubs();
// Allocate the dictionary of intrinsic function names.
- { MaybeObject* maybe_obj = NameDictionary::Allocate(Runtime::kNumFunctions);
+ { MaybeObject* maybe_obj =
+ NameDictionary::Allocate(this, Runtime::kNumFunctions);
if (!maybe_obj->ToObject(&obj)) return false;
}
{ MaybeObject* maybe_obj = Runtime::InitializeIntrinsicFunctionNames(this,
NameDictionary* dictionary;
MaybeObject* maybe_dictionary =
NameDictionary::Allocate(
+ this,
map->NumberOfOwnDescriptors() * 2 + initial_size);
if (!maybe_dictionary->To(&dictionary)) return maybe_dictionary;
if (map()->is_observed()) {
// Maintain invariant that observed elements are always in dictionary mode.
SeededNumberDictionary* dictionary;
- MaybeObject* maybe = SeededNumberDictionary::Allocate(0);
+ MaybeObject* maybe = SeededNumberDictionary::Allocate(GetHeap(), 0);
if (!maybe->To(&dictionary)) return maybe;
if (map() == GetHeap()->non_strict_arguments_elements_map()) {
FixedArray::cast(elements())->set(1, dictionary);
return ComputeIntegerHash(static_cast<uint32_t>(other->Number()), seed);
}
-MaybeObject* NumberDictionaryShape::AsObject(uint32_t key) {
- return Isolate::Current()->heap()->NumberFromUint32(key);
+MaybeObject* NumberDictionaryShape::AsObject(Isolate* isolate, uint32_t key) {
+ return isolate->heap()->NumberFromUint32(key);
}
}
-MaybeObject* NameDictionaryShape::AsObject(Name* key) {
+MaybeObject* NameDictionaryShape::AsObject(Isolate* isolate, Name* key) {
return key;
}
template <int entrysize>
-MaybeObject* ObjectHashTableShape<entrysize>::AsObject(Object* key) {
+MaybeObject* ObjectHashTableShape<entrysize>::AsObject(Isolate* isolate,
+ Object* key) {
return key;
}
property_count += 2; // Make space for two more properties.
}
NameDictionary* dictionary;
- MaybeObject* maybe_dictionary = NameDictionary::Allocate(property_count);
+ MaybeObject* maybe_dictionary =
+ NameDictionary::Allocate(GetHeap(), property_count);
if (!maybe_dictionary->To(&dictionary)) return maybe_dictionary;
DescriptorArray* descs = map_of_this->instance_descriptors();
GetElementsCapacityAndUsage(&old_capacity, &used_elements);
SeededNumberDictionary* dictionary = NULL;
{ Object* object;
- MaybeObject* maybe = SeededNumberDictionary::Allocate(used_elements);
+ MaybeObject* maybe =
+ SeededNumberDictionary::Allocate(GetHeap(), used_elements);
if (!maybe->ToObject(&object)) return maybe;
dictionary = SeededNumberDictionary::cast(object);
}
ObjectHashTable* hashtable;
static const int kInitialCapacity = 4;
MaybeObject* maybe_obj =
- ObjectHashTable::Allocate(kInitialCapacity,
+ ObjectHashTable::Allocate(GetHeap(),
+ kInitialCapacity,
ObjectHashTable::USE_CUSTOM_MINIMUM_CAPACITY);
if (!maybe_obj->To<ObjectHashTable>(&hashtable)) return maybe_obj;
if (normal_type_cache()->IsUndefined()) {
Object* result;
{ MaybeObject* maybe_result =
- CodeCacheHashTable::Allocate(CodeCacheHashTable::kInitialSize);
+ CodeCacheHashTable::Allocate(GetHeap(),
+ CodeCacheHashTable::kInitialSize);
if (!maybe_result->ToObject(&result)) return maybe_result;
}
set_normal_type_cache(result);
Object* result;
{ MaybeObject* maybe_result =
PolymorphicCodeCacheHashTable::Allocate(
+ GetHeap(),
PolymorphicCodeCacheHashTable::kInitialSize);
if (!maybe_result->ToObject(&result)) return maybe_result;
}
template<typename Shape, typename Key>
-MaybeObject* HashTable<Shape, Key>::Allocate(int at_least_space_for,
+MaybeObject* HashTable<Shape, Key>::Allocate(Heap* heap,
+ int at_least_space_for,
MinimumCapacity capacity_option,
PretenureFlag pretenure) {
ASSERT(!capacity_option || IS_POWER_OF_TWO(at_least_space_for));
}
Object* obj;
- { MaybeObject* maybe_obj = Isolate::Current()->heap()->
- AllocateHashTable(EntryToIndex(capacity), pretenure);
+ { MaybeObject* maybe_obj =
+ heap-> AllocateHashTable(EntryToIndex(capacity), pretenure);
if (!maybe_obj->ToObject(&obj)) return maybe_obj;
}
HashTable::cast(obj)->SetNumberOfElements(0);
(capacity > kMinCapacityForPretenure) && !GetHeap()->InNewSpace(this);
Object* obj;
{ MaybeObject* maybe_obj =
- Allocate(nof * 2,
+ Allocate(GetHeap(),
+ nof * 2,
USE_DEFAULT_MINIMUM_CAPACITY,
pretenure ? TENURED : NOT_TENURED);
if (!maybe_obj->ToObject(&obj)) return maybe_obj;
!GetHeap()->InNewSpace(this);
Object* obj;
{ MaybeObject* maybe_obj =
- Allocate(at_least_room_for,
+ Allocate(GetHeap(),
+ at_least_room_for,
USE_DEFAULT_MINIMUM_CAPACITY,
pretenure ? TENURED : NOT_TENURED);
if (!maybe_obj->ToObject(&obj)) return maybe_obj;
template class Dictionary<UnseededNumberDictionaryShape, uint32_t>;
template MaybeObject* Dictionary<SeededNumberDictionaryShape, uint32_t>::
- Allocate(int at_least_space_for);
+ Allocate(Heap* heap, int at_least_space_for);
template MaybeObject* Dictionary<UnseededNumberDictionaryShape, uint32_t>::
- Allocate(int at_least_space_for);
+ Allocate(Heap* heap, int at_least_space_for);
-template MaybeObject* Dictionary<NameDictionaryShape, Name*>::Allocate(int n);
+template MaybeObject* Dictionary<NameDictionaryShape, Name*>::
+ Allocate(Heap* heap, int n);
template MaybeObject* Dictionary<SeededNumberDictionaryShape, uint32_t>::AtPut(
uint32_t, Object*);
Object* obj;
{ MaybeObject* maybe_obj =
- SeededNumberDictionary::Allocate(dict->NumberOfElements());
+ SeededNumberDictionary::Allocate(GetHeap(), dict->NumberOfElements());
if (!maybe_obj->ToObject(&obj)) return maybe_obj;
}
SeededNumberDictionary* new_dict = SeededNumberDictionary::cast(obj);
template<typename Shape, typename Key>
-MaybeObject* Dictionary<Shape, Key>::Allocate(int at_least_space_for) {
+MaybeObject* Dictionary<Shape, Key>::Allocate(Heap* heap,
+ int at_least_space_for) {
Object* obj;
{ MaybeObject* maybe_obj =
- HashTable<Shape, Key>::Allocate(at_least_space_for);
+ HashTable<Shape, Key>::Allocate(heap, at_least_space_for);
if (!maybe_obj->ToObject(&obj)) return maybe_obj;
}
// Initialize the next enumeration index.
}
Object* k;
- { MaybeObject* maybe_k = Shape::AsObject(key);
+ { MaybeObject* maybe_k = Shape::AsObject(this->GetIsolate(), key);
if (!maybe_k->ToObject(&k)) return maybe_k;
}
PropertyDetails details = PropertyDetails(NONE, NORMAL);
uint32_t hash) {
// Compute the key object.
Object* k;
- { MaybeObject* maybe_k = Shape::AsObject(key);
+ { MaybeObject* maybe_k = Shape::AsObject(this->GetIsolate(), key);
if (!maybe_k->ToObject(&k)) return maybe_k;
}
details = PropertyDetails(details.attributes(),
details.type(),
DetailsAt(entry).dictionary_index());
- MaybeObject* maybe_object_key = SeededNumberDictionaryShape::AsObject(key);
+ MaybeObject* maybe_object_key =
+ SeededNumberDictionaryShape::AsObject(GetIsolate(), key);
Object* object_key;
if (!maybe_object_key->ToObject(&object_key)) return maybe_object_key;
SetEntry(entry, object_key, value, details);
Object* value) {
int entry = FindEntry(key);
if (entry == kNotFound) return AddNumberEntry(key, value);
- MaybeObject* maybe_object_key = UnseededNumberDictionaryShape::AsObject(key);
+ MaybeObject* maybe_object_key =
+ UnseededNumberDictionaryShape::AsObject(GetIsolate(), key);
Object* object_key;
if (!maybe_object_key->ToObject(&object_key)) return maybe_object_key;
SetEntry(entry, object_key, value);
// // Returns the hash value for object.
// static uint32_t HashForObject(Key key, Object* object);
// // Convert key to an object.
-// static inline Object* AsObject(Key key);
+// static inline Object* AsObject(Isolate* isolate, Key key);
// // The prefix size indicates number of elements in the beginning
// // of the backing storage.
// static const int kPrefixSize = ..;
// Returns a new HashTable object. Might return Failure.
MUST_USE_RESULT static MaybeObject* Allocate(
+ Heap* heap,
int at_least_space_for,
MinimumCapacity capacity_option = USE_DEFAULT_MINIMUM_CAPACITY,
PretenureFlag pretenure = NOT_TENURED);
static inline uint32_t HashForObject(HashTableKey* key, Object* object) {
return key->HashForObject(object);
}
- MUST_USE_RESULT static inline MaybeObject* AsObject(HashTableKey* key) {
+ MUST_USE_RESULT static inline MaybeObject* AsObject(Isolate* isolate,
+ HashTableKey* key) {
return key->AsObject();
}
return key->HashForObject(object);
}
- MUST_USE_RESULT static inline MaybeObject* AsObject(HashTableKey* key) {
+ MUST_USE_RESULT static inline MaybeObject* AsObject(Isolate* isolate,
+ HashTableKey* key) {
return key->AsObject();
}
}
// Returns a new array for dictionary usage. Might return Failure.
- MUST_USE_RESULT static MaybeObject* Allocate(int at_least_space_for);
+ MUST_USE_RESULT static MaybeObject* Allocate(Heap* heap,
+ int at_least_space_for);
// Ensure enough space for n additional elements.
MUST_USE_RESULT MaybeObject* EnsureCapacity(int n, Key key);
static inline bool IsMatch(Name* key, Object* other);
static inline uint32_t Hash(Name* key);
static inline uint32_t HashForObject(Name* key, Object* object);
- MUST_USE_RESULT static inline MaybeObject* AsObject(Name* key);
+ MUST_USE_RESULT static inline MaybeObject* AsObject(Isolate* isolate,
+ Name* key);
static const int kPrefixSize = 2;
static const int kEntrySize = 3;
static const bool kIsEnumerable = true;
class NumberDictionaryShape : public BaseShape<uint32_t> {
public:
static inline bool IsMatch(uint32_t key, Object* other);
- MUST_USE_RESULT static inline MaybeObject* AsObject(uint32_t key);
+ MUST_USE_RESULT static inline MaybeObject* AsObject(Isolate* isolate,
+ uint32_t key);
static const int kEntrySize = 3;
static const bool kIsEnumerable = false;
};
static inline bool IsMatch(Object* key, Object* other);
static inline uint32_t Hash(Object* key);
static inline uint32_t HashForObject(Object* key, Object* object);
- MUST_USE_RESULT static inline MaybeObject* AsObject(Object* key);
+ MUST_USE_RESULT static inline MaybeObject* AsObject(Isolate* isolate,
+ Object* key);
static const int kPrefixSize = 0;
static const int kEntrySize = entrysize;
};
return key->HashForObject(object);
}
- MUST_USE_RESULT static MaybeObject* AsObject(HashTableKey* key) {
+ MUST_USE_RESULT static MaybeObject* AsObject(Isolate* isolate,
+ HashTableKey* key) {
return key->AsObject();
}
return key->HashForObject(object);
}
- MUST_USE_RESULT static MaybeObject* AsObject(HashTableKey* key) {
+ MUST_USE_RESULT static MaybeObject* AsObject(Isolate* isolate,
+ HashTableKey* key) {
return key->AsObject();
}
TypeFeedbackOracle::TypeFeedbackOracle(Handle<Code> code,
Handle<Context> native_context,
Isolate* isolate,
- Zone* zone) {
- native_context_ = native_context;
- isolate_ = isolate;
- zone_ = zone;
+ Zone* zone)
+ : native_context_(native_context),
+ isolate_(isolate),
+ zone_(zone) {
BuildDictionary(code);
ASSERT(reinterpret_cast<Address>(*dictionary_.location()) != kHandleZapValue);
}
if (info->IsSmi()) {
ASSERT(static_cast<ElementsKind>(Smi::cast(*info)->value()) <=
LAST_FAST_ELEMENTS_KIND);
- return Isolate::Current()->global_context()->array_function();
+ return isolate_->global_context()->array_function();
}
return info->IsJSFunction();
}
if (info->IsSmi()) {
ASSERT(static_cast<ElementsKind>(Smi::cast(*info)->value()) <=
LAST_FAST_ELEMENTS_KIND);
- return Handle<JSFunction>(Isolate::Current()->global_context()->
- array_function());
+ return Handle<JSFunction>(isolate_->global_context()->array_function());
} else {
return Handle<JSFunction>::cast(info);
}
void TypeFeedbackOracle::BuildDictionary(Handle<Code> code) {
AssertNoAllocation no_allocation;
ZoneList<RelocInfo> infos(16, zone());
- HandleScope scope(code->GetIsolate());
+ HandleScope scope(isolate_);
GetRelocInfos(code, &infos);
CreateDictionary(code, &infos);
ProcessRelocInfos(&infos);
private:
Handle<Context> native_context_;
Isolate* isolate_;
- Handle<UnseededNumberDictionary> dictionary_;
Zone* zone_;
+ Handle<UnseededNumberDictionary> dictionary_;
DISALLOW_COPY_AND_ASSIGN(TypeFeedbackOracle);
};
}
-static Handle<JSWeakMap> AllocateJSWeakMap() {
- Handle<Map> map = FACTORY->NewMap(JS_WEAK_MAP_TYPE, JSWeakMap::kSize);
- Handle<JSObject> weakmap_obj = FACTORY->NewJSObjectFromMap(map);
+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(1)->ToObjectChecked();
+ Object* table_obj = ObjectHashTable::Allocate(heap, 1)->ToObjectChecked();
ObjectHashTable* table = ObjectHashTable::cast(table_obj);
weakmap->set_table(table);
weakmap->set_next(Smi::FromInt(0));
TEST(Weakness) {
FLAG_incremental_marking = false;
LocalContext context;
+ Isolate* isolate = GetIsolateFrom(&context);
+ Factory* factory = isolate->factory();
+ Heap* heap = isolate->heap();
v8::HandleScope scope;
- Handle<JSWeakMap> weakmap = AllocateJSWeakMap();
- GlobalHandles* global_handles = GetIsolateFrom(&context)->global_handles();
+ Handle<JSWeakMap> weakmap = AllocateJSWeakMap(isolate);
+ GlobalHandles* global_handles = isolate->global_handles();
// Keep global reference to the key.
Handle<Object> key;
{
v8::HandleScope scope;
- Handle<Map> map = FACTORY->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
- Handle<JSObject> object = FACTORY->NewJSObjectFromMap(map);
+ Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
+ Handle<JSObject> object = factory->NewJSObjectFromMap(map);
key = global_handles->Create(*object);
}
CHECK(!global_handles->IsWeak(key.location()));
v8::HandleScope scope;
PutIntoWeakMap(weakmap,
Handle<JSObject>(JSObject::cast(*key)),
- Handle<Smi>(Smi::FromInt(23), GetIsolateFrom(&context)));
+ Handle<Smi>(Smi::FromInt(23), isolate));
}
CHECK_EQ(1, ObjectHashTable::cast(weakmap->table())->NumberOfElements());
// Force a full GC.
- HEAP->CollectAllGarbage(false);
+ heap->CollectAllGarbage(false);
CHECK_EQ(0, NumberOfWeakCalls);
CHECK_EQ(1, ObjectHashTable::cast(weakmap->table())->NumberOfElements());
CHECK_EQ(
// Force a full GC.
// Perform two consecutive GCs because the first one will only clear
// weak references whereas the second one will also clear weak maps.
- HEAP->CollectAllGarbage(false);
+ heap->CollectAllGarbage(false);
CHECK_EQ(1, NumberOfWeakCalls);
CHECK_EQ(1, ObjectHashTable::cast(weakmap->table())->NumberOfElements());
CHECK_EQ(
0, ObjectHashTable::cast(weakmap->table())->NumberOfDeletedElements());
- HEAP->CollectAllGarbage(false);
+ heap->CollectAllGarbage(false);
CHECK_EQ(1, NumberOfWeakCalls);
CHECK_EQ(0, ObjectHashTable::cast(weakmap->table())->NumberOfElements());
CHECK_EQ(
TEST(Shrinking) {
LocalContext context;
+ Isolate* isolate = GetIsolateFrom(&context);
+ Factory* factory = isolate->factory();
+ Heap* heap = isolate->heap();
v8::HandleScope scope;
- Handle<JSWeakMap> weakmap = AllocateJSWeakMap();
+ Handle<JSWeakMap> weakmap = AllocateJSWeakMap(isolate);
// Check initial capacity.
CHECK_EQ(32, ObjectHashTable::cast(weakmap->table())->Capacity());
// Fill up weak map to trigger capacity change.
{
v8::HandleScope scope;
- Handle<Map> map = FACTORY->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
+ Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
for (int i = 0; i < 32; i++) {
- Handle<JSObject> object = FACTORY->NewJSObjectFromMap(map);
- PutIntoWeakMap(weakmap, object,
- Handle<Smi>(Smi::FromInt(i), GetIsolateFrom(&context)));
+ Handle<JSObject> object = factory->NewJSObjectFromMap(map);
+ PutIntoWeakMap(weakmap, object, Handle<Smi>(Smi::FromInt(i), isolate));
}
}
CHECK_EQ(32, ObjectHashTable::cast(weakmap->table())->NumberOfElements());
CHECK_EQ(
0, ObjectHashTable::cast(weakmap->table())->NumberOfDeletedElements());
- HEAP->CollectAllGarbage(false);
+ heap->CollectAllGarbage(false);
CHECK_EQ(0, ObjectHashTable::cast(weakmap->table())->NumberOfElements());
CHECK_EQ(
32, ObjectHashTable::cast(weakmap->table())->NumberOfDeletedElements());
TEST(Regress2060a) {
FLAG_always_compact = true;
LocalContext context;
+ Isolate* isolate = GetIsolateFrom(&context);
+ Factory* factory = isolate->factory();
+ Heap* heap = isolate->heap();
v8::HandleScope scope;
Handle<JSFunction> function =
- FACTORY->NewFunction(FACTORY->function_string(), FACTORY->null_value());
- Handle<JSObject> key = FACTORY->NewJSObject(function);
- Handle<JSWeakMap> weakmap = AllocateJSWeakMap();
+ factory->NewFunction(factory->function_string(), factory->null_value());
+ Handle<JSObject> key = factory->NewJSObject(function);
+ Handle<JSWeakMap> weakmap = AllocateJSWeakMap(isolate);
// Start second old-space page so that values land on evacuation candidate.
- Page* first_page = HEAP->old_pointer_space()->anchor()->next_page();
- FACTORY->NewFixedArray(900 * KB / kPointerSize, TENURED);
+ Page* first_page = heap->old_pointer_space()->anchor()->next_page();
+ factory->NewFixedArray(900 * KB / kPointerSize, TENURED);
// Fill up weak map with values on an evacuation candidate.
{
v8::HandleScope scope;
for (int i = 0; i < 32; i++) {
- Handle<JSObject> object = FACTORY->NewJSObject(function, TENURED);
- CHECK(!HEAP->InNewSpace(object->address()));
+ Handle<JSObject> object = factory->NewJSObject(function, TENURED);
+ CHECK(!heap->InNewSpace(object->address()));
CHECK(!first_page->Contains(object->address()));
PutIntoWeakMap(weakmap, key, object);
}
// Force compacting garbage collection.
CHECK(FLAG_always_compact);
- HEAP->CollectAllGarbage(Heap::kNoGCFlags);
+ heap->CollectAllGarbage(Heap::kNoGCFlags);
}
#endif
LocalContext context;
+ Isolate* isolate = GetIsolateFrom(&context);
+ Factory* factory = isolate->factory();
+ Heap* heap = isolate->heap();
v8::HandleScope scope;
Handle<JSFunction> function =
- FACTORY->NewFunction(FACTORY->function_string(), FACTORY->null_value());
+ factory->NewFunction(factory->function_string(), factory->null_value());
// Start second old-space page so that keys land on evacuation candidate.
- Page* first_page = HEAP->old_pointer_space()->anchor()->next_page();
- FACTORY->NewFixedArray(900 * KB / kPointerSize, TENURED);
+ Page* first_page = heap->old_pointer_space()->anchor()->next_page();
+ factory->NewFixedArray(900 * KB / kPointerSize, TENURED);
// Fill up weak map with keys on an evacuation candidate.
Handle<JSObject> keys[32];
for (int i = 0; i < 32; i++) {
- keys[i] = FACTORY->NewJSObject(function, TENURED);
- CHECK(!HEAP->InNewSpace(keys[i]->address()));
+ keys[i] = factory->NewJSObject(function, TENURED);
+ CHECK(!heap->InNewSpace(keys[i]->address()));
CHECK(!first_page->Contains(keys[i]->address()));
}
- Handle<JSWeakMap> weakmap = AllocateJSWeakMap();
+ Handle<JSWeakMap> weakmap = AllocateJSWeakMap(isolate);
for (int i = 0; i < 32; i++) {
PutIntoWeakMap(weakmap,
keys[i],
- Handle<Smi>(Smi::FromInt(i), GetIsolateFrom(&context)));
+ Handle<Smi>(Smi::FromInt(i), isolate));
}
// Force compacting garbage collection. The subsequent collections are used
// to verify that key references were actually updated.
CHECK(FLAG_always_compact);
- HEAP->CollectAllGarbage(Heap::kNoGCFlags);
- HEAP->CollectAllGarbage(Heap::kNoGCFlags);
- HEAP->CollectAllGarbage(Heap::kNoGCFlags);
+ heap->CollectAllGarbage(Heap::kNoGCFlags);
+ heap->CollectAllGarbage(Heap::kNoGCFlags);
+ heap->CollectAllGarbage(Heap::kNoGCFlags);
}