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

Unified Diff: test/cctest/test-heap.cc

Issue 16337005: Deprecate FACTORY helper macro. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 7 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 | « test/cctest/test-func-name-inference.cc ('k') | test/cctest/test-mark-compact.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-heap.cc
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc
index 8bd3ab3fe39d47b6da7d47916887ebe45452f881..c9f70dcc96ec95f4f5375a12fec26ad0b5bdb689 100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -146,6 +146,7 @@ static void CheckFindCodeObject(Isolate* isolate) {
TEST(HeapObjects) {
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
Heap* heap = isolate->heap();
HandleScope sc(isolate);
@@ -201,7 +202,7 @@ TEST(HeapObjects) {
CHECK(heap->nan_value()->IsNumber());
CHECK(std::isnan(heap->nan_value()->Number()));
- Handle<String> s = FACTORY->NewStringFromAscii(CStrVector("fisk hest "));
+ Handle<String> s = factory->NewStringFromAscii(CStrVector("fisk hest "));
CHECK(s->IsString());
CHECK_EQ(10, s->length());
@@ -339,10 +340,12 @@ TEST(String) {
TEST(LocalHandles) {
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(CcTest::isolate());
const char* name = "Kasper the spunky";
- Handle<String> string = FACTORY->NewStringFromAscii(CStrVector(name));
+ Handle<String> string = factory->NewStringFromAscii(CStrVector(name));
CHECK_EQ(StrLength(name), string->length());
}
@@ -609,17 +612,19 @@ TEST(StringTable) {
TEST(FunctionAllocation) {
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope sc(CcTest::isolate());
- Handle<String> name = FACTORY->InternalizeUtf8String("theFunction");
+ Handle<String> name = factory->InternalizeUtf8String("theFunction");
Handle<JSFunction> function =
- FACTORY->NewFunction(name, FACTORY->undefined_value());
+ factory->NewFunction(name, factory->undefined_value());
Handle<Map> initial_map =
- FACTORY->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
+ factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
function->set_initial_map(*initial_map);
- Handle<String> prop_name = FACTORY->InternalizeUtf8String("theSlot");
- Handle<JSObject> obj = FACTORY->NewJSObject(function);
+ Handle<String> prop_name = factory->InternalizeUtf8String("theSlot");
+ Handle<JSObject> obj = factory->NewJSObject(function);
obj->SetProperty(
*prop_name, Smi::FromInt(23), NONE, kNonStrictMode)->ToObjectChecked();
CHECK_EQ(Smi::FromInt(23), obj->GetProperty(*prop_name));
@@ -632,6 +637,8 @@ TEST(FunctionAllocation) {
TEST(ObjectProperties) {
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope sc(CcTest::isolate());
String* object_string = String::cast(HEAP->Object_string());
@@ -639,9 +646,9 @@ TEST(ObjectProperties) {
GetProperty(object_string)->ToObjectChecked();
JSFunction* object_function = JSFunction::cast(raw_object);
Handle<JSFunction> constructor(object_function);
- Handle<JSObject> obj = FACTORY->NewJSObject(constructor);
- Handle<String> first = FACTORY->InternalizeUtf8String("first");
- Handle<String> second = FACTORY->InternalizeUtf8String("second");
+ Handle<JSObject> obj = factory->NewJSObject(constructor);
+ Handle<String> first = factory->InternalizeUtf8String("first");
+ Handle<String> second = factory->InternalizeUtf8String("second");
// check for empty
CHECK(!obj->HasLocalProperty(*first));
@@ -687,35 +694,37 @@ TEST(ObjectProperties) {
// check string and internalized string match
const char* string1 = "fisk";
- Handle<String> s1 = FACTORY->NewStringFromAscii(CStrVector(string1));
+ Handle<String> s1 = factory->NewStringFromAscii(CStrVector(string1));
obj->SetProperty(
*s1, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
- Handle<String> s1_string = FACTORY->InternalizeUtf8String(string1);
+ Handle<String> s1_string = factory->InternalizeUtf8String(string1);
CHECK(obj->HasLocalProperty(*s1_string));
// check internalized string and string match
const char* string2 = "fugl";
- Handle<String> s2_string = FACTORY->InternalizeUtf8String(string2);
+ Handle<String> s2_string = factory->InternalizeUtf8String(string2);
obj->SetProperty(
*s2_string, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
- Handle<String> s2 = FACTORY->NewStringFromAscii(CStrVector(string2));
+ Handle<String> s2 = factory->NewStringFromAscii(CStrVector(string2));
CHECK(obj->HasLocalProperty(*s2));
}
TEST(JSObjectMaps) {
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope sc(CcTest::isolate());
- Handle<String> name = FACTORY->InternalizeUtf8String("theFunction");
+ Handle<String> name = factory->InternalizeUtf8String("theFunction");
Handle<JSFunction> function =
- FACTORY->NewFunction(name, FACTORY->undefined_value());
+ factory->NewFunction(name, factory->undefined_value());
Handle<Map> initial_map =
- FACTORY->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
+ factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
function->set_initial_map(*initial_map);
- Handle<String> prop_name = FACTORY->InternalizeUtf8String("theSlot");
- Handle<JSObject> obj = FACTORY->NewJSObject(function);
+ Handle<String> prop_name = factory->InternalizeUtf8String("theSlot");
+ Handle<JSObject> obj = factory->NewJSObject(function);
// Set a propery
obj->SetProperty(
@@ -729,16 +738,18 @@ TEST(JSObjectMaps) {
TEST(JSArray) {
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope sc(CcTest::isolate());
- Handle<String> name = FACTORY->InternalizeUtf8String("Array");
+ Handle<String> name = factory->InternalizeUtf8String("Array");
Object* raw_object = Isolate::Current()->context()->global_object()->
GetProperty(*name)->ToObjectChecked();
Handle<JSFunction> function = Handle<JSFunction>(
JSFunction::cast(raw_object));
// Allocate the object.
- Handle<JSObject> object = FACTORY->NewJSObject(function);
+ Handle<JSObject> object = factory->NewJSObject(function);
Handle<JSArray> array = Handle<JSArray>::cast(object);
// We just initialized the VM, no heap allocation failure yet.
array->Initialize(0)->ToObjectChecked();
@@ -756,7 +767,7 @@ TEST(JSArray) {
// Set array length with larger than smi value.
Handle<Object> length =
- FACTORY->NewNumberFromUint(static_cast<uint32_t>(Smi::kMaxValue) + 1);
+ factory->NewNumberFromUint(static_cast<uint32_t>(Smi::kMaxValue) + 1);
array->SetElementsLength(*length)->ToObjectChecked();
uint32_t int_length = 0;
@@ -776,6 +787,8 @@ TEST(JSArray) {
TEST(JSObjectCopy) {
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope sc(CcTest::isolate());
String* object_string = String::cast(HEAP->Object_string());
@@ -783,9 +796,9 @@ TEST(JSObjectCopy) {
GetProperty(object_string)->ToObjectChecked();
JSFunction* object_function = JSFunction::cast(raw_object);
Handle<JSFunction> constructor(object_function);
- Handle<JSObject> obj = FACTORY->NewJSObject(constructor);
- Handle<String> first = FACTORY->InternalizeUtf8String("first");
- Handle<String> second = FACTORY->InternalizeUtf8String("second");
+ Handle<JSObject> obj = factory->NewJSObject(constructor);
+ Handle<String> first = factory->InternalizeUtf8String("first");
+ Handle<String> second = factory->InternalizeUtf8String("second");
obj->SetProperty(
*first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
@@ -824,6 +837,8 @@ TEST(JSObjectCopy) {
TEST(StringAllocation) {
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
const unsigned char chars[] = { 0xe5, 0xa4, 0xa7 };
for (int length = 0; length < 100; length++) {
@@ -839,18 +854,18 @@ TEST(StringAllocation) {
non_ascii[3 * i + 2] = chars[2];
}
Handle<String> non_ascii_sym =
- FACTORY->InternalizeUtf8String(
+ factory->InternalizeUtf8String(
Vector<const char>(non_ascii, 3 * length));
CHECK_EQ(length, non_ascii_sym->length());
Handle<String> ascii_sym =
- FACTORY->InternalizeOneByteString(OneByteVector(ascii, length));
+ factory->InternalizeOneByteString(OneByteVector(ascii, length));
CHECK_EQ(length, ascii_sym->length());
Handle<String> non_ascii_str =
- FACTORY->NewStringFromUtf8(Vector<const char>(non_ascii, 3 * length));
+ factory->NewStringFromUtf8(Vector<const char>(non_ascii, 3 * length));
non_ascii_str->Hash();
CHECK_EQ(length, non_ascii_str->length());
Handle<String> ascii_str =
- FACTORY->NewStringFromUtf8(Vector<const char>(ascii, length));
+ factory->NewStringFromUtf8(Vector<const char>(ascii, length));
ascii_str->Hash();
CHECK_EQ(length, ascii_str->length());
DeleteArray(non_ascii);
@@ -876,6 +891,8 @@ static int ObjectsFoundInHeap(Heap* heap, Handle<Object> objs[], int size) {
TEST(Iteration) {
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(CcTest::isolate());
// Array of objects to scan haep for.
@@ -884,16 +901,16 @@ TEST(Iteration) {
int next_objs_index = 0;
// Allocate a JS array to OLD_POINTER_SPACE and NEW_SPACE
- objs[next_objs_index++] = FACTORY->NewJSArray(10);
- objs[next_objs_index++] = FACTORY->NewJSArray(10,
+ objs[next_objs_index++] = factory->NewJSArray(10);
+ objs[next_objs_index++] = factory->NewJSArray(10,
FAST_HOLEY_ELEMENTS,
TENURED);
// Allocate a small string to OLD_DATA_SPACE and NEW_SPACE
objs[next_objs_index++] =
- FACTORY->NewStringFromAscii(CStrVector("abcdefghij"));
+ factory->NewStringFromAscii(CStrVector("abcdefghij"));
objs[next_objs_index++] =
- FACTORY->NewStringFromAscii(CStrVector("abcdefghij"), TENURED);
+ factory->NewStringFromAscii(CStrVector("abcdefghij"), TENURED);
// Allocate a large string (for large object space).
int large_size = Page::kMaxNonCodeHeapObjectSize + 1;
@@ -901,7 +918,7 @@ TEST(Iteration) {
for (int i = 0; i < large_size - 1; ++i) str[i] = 'a';
str[large_size - 1] = '\0';
objs[next_objs_index++] =
- FACTORY->NewStringFromAscii(CStrVector(str), TENURED);
+ factory->NewStringFromAscii(CStrVector(str), TENURED);
delete[] str;
// Add a Map object to look for.
@@ -936,6 +953,8 @@ static int LenFromSize(int size) {
TEST(Regression39128) {
// Test case for crbug.com/39128.
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
// Increase the chance of 'bump-the-pointer' allocation in old space.
HEAP->CollectAllGarbage(Heap::kNoGCFlags);
@@ -952,7 +971,7 @@ TEST(Regression39128) {
CHECK(object_ctor->has_initial_map());
Handle<Map> object_map(object_ctor->initial_map());
// Create a map with single inobject property.
- Handle<Map> my_map = FACTORY->CopyMap(object_map, 1);
+ Handle<Map> my_map = factory->CopyMap(object_map, 1);
int n_properties = my_map->inobject_properties();
CHECK_GT(n_properties, 0);
@@ -1013,6 +1032,8 @@ TEST(TestCodeFlushing) {
if (!FLAG_flush_code) return;
i::FLAG_allow_natives_syntax = true;
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(CcTest::isolate());
const char* source = "function foo() {"
" var x = 42;"
@@ -1020,7 +1041,7 @@ TEST(TestCodeFlushing) {
" var z = x + y;"
"};"
"foo()";
- Handle<String> foo_name = FACTORY->InternalizeUtf8String("foo");
+ Handle<String> foo_name = factory->InternalizeUtf8String("foo");
// This compile will add the code to the compilation cache.
{ v8::HandleScope scope(CcTest::isolate());
@@ -1060,6 +1081,8 @@ TEST(TestCodeFlushingIncremental) {
if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return;
i::FLAG_allow_natives_syntax = true;
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(CcTest::isolate());
const char* source = "function foo() {"
" var x = 42;"
@@ -1067,7 +1090,7 @@ TEST(TestCodeFlushingIncremental) {
" var z = x + y;"
"};"
"foo()";
- Handle<String> foo_name = FACTORY->InternalizeUtf8String("foo");
+ Handle<String> foo_name = factory->InternalizeUtf8String("foo");
// This compile will add the code to the compilation cache.
{ v8::HandleScope scope(CcTest::isolate());
@@ -1126,6 +1149,8 @@ TEST(TestCodeFlushingIncrementalScavenge) {
if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return;
i::FLAG_allow_natives_syntax = true;
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(CcTest::isolate());
const char* source = "var foo = function() {"
" var x = 42;"
@@ -1137,8 +1162,8 @@ TEST(TestCodeFlushingIncrementalScavenge) {
" var x = 23;"
"};"
"bar();";
- Handle<String> foo_name = FACTORY->InternalizeUtf8String("foo");
- Handle<String> bar_name = FACTORY->InternalizeUtf8String("bar");
+ Handle<String> foo_name = factory->InternalizeUtf8String("foo");
+ Handle<String> bar_name = factory->InternalizeUtf8String("bar");
// Perfrom one initial GC to enable code flushing.
HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
@@ -1193,6 +1218,7 @@ TEST(TestCodeFlushingIncrementalAbort) {
i::FLAG_allow_natives_syntax = true;
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
Heap* heap = isolate->heap();
v8::HandleScope scope(CcTest::isolate());
const char* source = "function foo() {"
@@ -1201,7 +1227,7 @@ TEST(TestCodeFlushingIncrementalAbort) {
" var z = x + y;"
"};"
"foo()";
- Handle<String> foo_name = FACTORY->InternalizeUtf8String("foo");
+ Handle<String> foo_name = factory->InternalizeUtf8String("foo");
// This compile will add the code to the compilation cache.
{ v8::HandleScope scope(CcTest::isolate());
@@ -1892,6 +1918,8 @@ TEST(InstanceOfStubWriteBarrier) {
TEST(PrototypeTransitionClearing) {
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(CcTest::isolate());
CompileRun(
@@ -1931,7 +1959,7 @@ TEST(PrototypeTransitionClearing) {
{
AlwaysAllocateScope always_allocate;
SimulateFullSpace(space);
- prototype = FACTORY->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED);
+ prototype = factory->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED);
}
// Add a prototype on an evacuation candidate and verify that transition
@@ -2290,6 +2318,8 @@ TEST(ReleaseOverReservedPages) {
i::FLAG_crankshaft = false;
i::FLAG_always_opt = false;
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(CcTest::isolate());
static const int number_of_test_pages = 20;
@@ -2299,7 +2329,7 @@ TEST(ReleaseOverReservedPages) {
for (int i = 0; i < number_of_test_pages; i++) {
AlwaysAllocateScope always_allocate;
SimulateFullSpace(old_pointer_space);
- FACTORY->NewFixedArray(1, TENURED);
+ factory->NewFixedArray(1, TENURED);
}
CHECK_EQ(number_of_test_pages + 1, old_pointer_space->CountTotalPages());
@@ -2329,6 +2359,8 @@ TEST(ReleaseOverReservedPages) {
TEST(Regress2237) {
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(CcTest::isolate());
Handle<String> slice(HEAP->empty_string());
@@ -2336,7 +2368,7 @@ TEST(Regress2237) {
// Generate a parent that lives in new-space.
v8::HandleScope inner_scope(CcTest::isolate());
const char* c = "This text is long enough to trigger sliced strings.";
- Handle<String> s = FACTORY->NewStringFromAscii(CStrVector(c));
+ Handle<String> s = factory->NewStringFromAscii(CStrVector(c));
CHECK(s->IsSeqOneByteString());
CHECK(HEAP->InNewSpace(*s));
@@ -2344,7 +2376,7 @@ TEST(Regress2237) {
// lives in old-space.
SimulateFullSpace(HEAP->new_space());
AlwaysAllocateScope always_allocate;
- Handle<String> t = FACTORY->NewProperSubString(s, 5, 35);
+ Handle<String> t = factory->NewProperSubString(s, 5, 35);
CHECK(t->IsSlicedString());
CHECK(!HEAP->InNewSpace(*t));
*slice.location() = *t.location();
@@ -2900,6 +2932,8 @@ TEST(Regress169928) {
i::FLAG_allow_natives_syntax = true;
i::FLAG_crankshaft = false;
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(CcTest::isolate());
// Some flags turn Scavenge collections into Mark-sweep collections
@@ -2930,7 +2964,7 @@ TEST(Regress169928) {
HEAP->CollectGarbage(NEW_SPACE);
// Allocate the object.
- Handle<FixedArray> array_data = FACTORY->NewFixedArray(2, NOT_TENURED);
+ Handle<FixedArray> array_data = factory->NewFixedArray(2, NOT_TENURED);
array_data->set(0, Smi::FromInt(1));
array_data->set(1, Smi::FromInt(2));
@@ -2938,7 +2972,7 @@ TEST(Regress169928) {
JSArray::kSize + AllocationSiteInfo::kSize +
kPointerSize);
- Handle<JSArray> array = FACTORY->NewJSArrayWithElements(array_data,
+ Handle<JSArray> array = factory->NewJSArrayWithElements(array_data,
FAST_SMI_ELEMENTS,
NOT_TENURED);
« no previous file with comments | « test/cctest/test-func-name-inference.cc ('k') | test/cctest/test-mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698