Commit b3c067ff authored by hpayer@chromium.org's avatar hpayer@chromium.org

Remove global pretenuring mode.

BUG=
R=bmeurer@chromium.org, mvstanton@chromium.org

Review URL: https://codereview.chromium.org/304493002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21511 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent c03b9848
......@@ -190,7 +190,6 @@ DEFINE_bool(compiled_keyed_dictionary_loads, true,
"use optimizing compiler to generate keyed dictionary load stubs")
DEFINE_bool(clever_optimizations, true,
"Optimize object size, Array shift, DOM strings and string +")
DEFINE_bool(pretenuring, true, "allocate objects in old space")
// TODO(hpayer): We will remove this flag as soon as we have pretenuring
// support for specific allocation sites.
DEFINE_bool(pretenuring_call_new, false, "pretenure call new")
......
......@@ -1034,12 +1034,6 @@ class Heap {
inline int64_t AdjustAmountOfExternalAllocatedMemory(
int64_t change_in_bytes);
// Returns the allocation mode (pre-tenuring) based on observed promotion
// rates of previous collections.
inline PretenureFlag GetPretenureMode() {
return FLAG_pretenuring ? TENURED : NOT_TENURED;
}
inline intptr_t PromotedTotalSize() {
int64_t total = PromotedSpaceSizeOfObjects() + PromotedExternalMemorySize();
if (total > kMaxInt) return static_cast<intptr_t>(kMaxInt);
......
......@@ -2293,11 +2293,8 @@ HValue* HGraphBuilder::BuildAllocateElements(ElementsKind kind,
HValue* total_size = AddUncasted<HAdd>(mul, header_size);
total_size->ClearFlag(HValue::kCanOverflow);
PretenureFlag pretenure_flag = !FLAG_allocation_site_pretenuring ?
isolate()->heap()->GetPretenureMode() : NOT_TENURED;
return Add<HAllocate>(total_size, HType::NonPrimitive(),
pretenure_flag, instance_type);
return Add<HAllocate>(total_size, HType::NonPrimitive(), NOT_TENURED,
instance_type);
}
......@@ -5482,12 +5479,10 @@ HInstruction* HOptimizedGraphBuilder::BuildStoreNamedField(
NoObservableSideEffectsScope no_side_effects(this);
HInstruction* heap_number_size = Add<HConstant>(HeapNumber::kSize);
PretenureFlag pretenure_flag = !FLAG_allocation_site_pretenuring ?
isolate()->heap()->GetPretenureMode() : NOT_TENURED;
// TODO(hpayer): Allocation site pretenuring support.
HInstruction* heap_number = Add<HAllocate>(heap_number_size,
HType::HeapNumber(),
pretenure_flag,
NOT_TENURED,
HEAP_NUMBER_TYPE);
AddStoreMapConstant(heap_number, isolate()->factory()->heap_number_map());
Add<HStoreNamedField>(heap_number, HObjectAccess::ForHeapNumberValue(),
......@@ -8605,9 +8600,6 @@ void HOptimizedGraphBuilder::VisitCallNew(CallNew* expr) {
AllocationSite::AddDependentCompilationInfo(allocation_site,
AllocationSite::TENURING,
top_info());
} else {
allocation_mode = HAllocationMode(
isolate()->heap()->GetPretenureMode());
}
}
......@@ -9536,15 +9528,10 @@ HValue* HOptimizedGraphBuilder::BuildBinaryOperation(
Maybe<int> fixed_right_arg = expr->fixed_right_arg();
Handle<AllocationSite> allocation_site = expr->allocation_site();
PretenureFlag pretenure_flag = !FLAG_allocation_site_pretenuring ?
isolate()->heap()->GetPretenureMode() : NOT_TENURED;
HAllocationMode allocation_mode =
FLAG_allocation_site_pretenuring
? (allocation_site.is_null()
? HAllocationMode(NOT_TENURED)
: HAllocationMode(allocation_site))
: HAllocationMode(pretenure_flag);
HAllocationMode allocation_mode;
if (FLAG_allocation_site_pretenuring && !allocation_site.is_null()) {
allocation_mode = HAllocationMode(allocation_site);
}
HValue* result = HGraphBuilder::BuildBinaryOperation(
expr->op(), left, right, left_type, right_type, result_type,
......@@ -10251,7 +10238,7 @@ HInstruction* HOptimizedGraphBuilder::BuildFastLiteral(
HValue* object_size_constant = Add<HConstant>(
boilerplate_object->map()->instance_size());
PretenureFlag pretenure_flag = isolate()->heap()->GetPretenureMode();
PretenureFlag pretenure_flag = NOT_TENURED;
if (FLAG_allocation_site_pretenuring) {
pretenure_flag = site_context->current()->GetPretenureMode();
Handle<AllocationSite> site(site_context->current());
......
......@@ -1566,7 +1566,7 @@ inline bool AllocationSite::IncrementMementoFoundCount() {
int value = memento_found_count();
set_memento_found_count(value + 1);
return value == kPretenureMinimumCreated;
return memento_found_count() == kPretenureMinimumCreated;
}
......
......@@ -2194,98 +2194,60 @@ TEST(OptimizedAllocationAlwaysInNewSpace) {
TEST(OptimizedPretenuringAllocationFolding) {
i::FLAG_allow_natives_syntax = true;
i::FLAG_max_semi_space_size = 1;
i::FLAG_allocation_site_pretenuring = false;
i::FLAG_expose_gc = true;
CcTest::InitializeVM();
if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Value> res = CompileRun(
"function DataObject() {"
" this.a = 1.1;"
" this.b = [{}];"
" this.c = 1.2;"
" this.d = [{}];"
" this.e = 1.3;"
" this.f = [{}];"
"}"
"var number_elements = 20000;"
i::ScopedVector<char> source(1024);
i::OS::SNPrintF(
source,
"var number_elements = %d;"
"var elements = new Array();"
"function f() {"
" for (var i = 0; i < number_elements; i++) {"
" elements[i] = new DataObject();"
" elements[i] = [[{}], [1.1]];"
" }"
" return elements[number_elements-1]"
"};"
"f(); f(); f();"
"f(); gc();"
"f(); f();"
"%OptimizeFunctionOnNextCall(f);"
"f();");
Handle<JSObject> o =
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
"f();",
AllocationSite::kPretenureMinimumCreated);
CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(0)));
CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(1)));
CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(2)));
CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(3)));
CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(4)));
CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(5)));
}
TEST(OptimizedPretenuringAllocationFoldingBlocks) {
i::FLAG_allow_natives_syntax = true;
i::FLAG_max_semi_space_size = 1;
i::FLAG_allocation_site_pretenuring = false;
CcTest::InitializeVM();
if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Value> res = CompileRun(source.start());
v8::Local<v8::Value> res = CompileRun(
"var number_elements = 30000;"
"var elements = new Array(number_elements);"
"function DataObject() {"
" this.a = [{}];"
" this.b = [{}];"
" this.c = 1.1;"
" this.d = 1.2;"
" this.e = [{}];"
" this.f = 1.3;"
"}"
"function f() {"
" for (var i = 0; i < number_elements; i++) {"
" elements[i] = new DataObject();"
" }"
" return elements[number_elements - 1];"
"};"
"f(); f(); f();"
"%OptimizeFunctionOnNextCall(f);"
"f();");
v8::Local<v8::Value> int_array = v8::Object::Cast(*res)->Get(v8_str("0"));
Handle<JSObject> int_array_handle =
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array));
v8::Local<v8::Value> double_array = v8::Object::Cast(*res)->Get(v8_str("1"));
Handle<JSObject> double_array_handle =
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array));
Handle<JSObject> o =
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(0)));
CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(1)));
CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(2)));
CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(3)));
CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(4)));
CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(5)));
CHECK(CcTest::heap()->InOldPointerSpace(*o));
CHECK(CcTest::heap()->InOldPointerSpace(*int_array_handle));
CHECK(CcTest::heap()->InOldPointerSpace(int_array_handle->elements()));
CHECK(CcTest::heap()->InOldPointerSpace(*double_array_handle));
CHECK(CcTest::heap()->InOldDataSpace(double_array_handle->elements()));
}
TEST(OptimizedPretenuringObjectArrayLiterals) {
i::FLAG_allow_natives_syntax = true;
i::FLAG_max_semi_space_size = 1;
i::FLAG_expose_gc = true;
CcTest::InitializeVM();
if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Value> res = CompileRun(
"var number_elements = 20000;"
i::ScopedVector<char> source(1024);
i::OS::SNPrintF(
source,
"var number_elements = %d;"
"var elements = new Array(number_elements);"
"function f() {"
" for (var i = 0; i < number_elements; i++) {"
......@@ -2293,9 +2255,13 @@ TEST(OptimizedPretenuringObjectArrayLiterals) {
" }"
" return elements[number_elements - 1];"
"};"
"f(); f(); f();"
"f(); gc();"
"f(); f();"
"%OptimizeFunctionOnNextCall(f);"
"f();");
"f();",
AllocationSite::kPretenureMinimumCreated);
v8::Local<v8::Value> res = CompileRun(source.start());
Handle<JSObject> o =
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
......@@ -2307,14 +2273,16 @@ TEST(OptimizedPretenuringObjectArrayLiterals) {
TEST(OptimizedPretenuringMixedInObjectProperties) {
i::FLAG_allow_natives_syntax = true;
i::FLAG_max_semi_space_size = 1;
i::FLAG_expose_gc = true;
CcTest::InitializeVM();
if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Value> res = CompileRun(
"var number_elements = 20000;"
i::ScopedVector<char> source(1024);
i::OS::SNPrintF(
source,
"var number_elements = %d;"
"var elements = new Array(number_elements);"
"function f() {"
" for (var i = 0; i < number_elements; i++) {"
......@@ -2322,9 +2290,13 @@ TEST(OptimizedPretenuringMixedInObjectProperties) {
" }"
" return elements[number_elements - 1];"
"};"
"f(); f(); f();"
"f(); gc();"
"f(); f();"
"%OptimizeFunctionOnNextCall(f);"
"f();");
"f();",
AllocationSite::kPretenureMinimumCreated);
v8::Local<v8::Value> res = CompileRun(source.start());
Handle<JSObject> o =
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
......@@ -2342,14 +2314,16 @@ TEST(OptimizedPretenuringMixedInObjectProperties) {
TEST(OptimizedPretenuringDoubleArrayProperties) {
i::FLAG_allow_natives_syntax = true;
i::FLAG_max_semi_space_size = 1;
i::FLAG_expose_gc = true;
CcTest::InitializeVM();
if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Value> res = CompileRun(
"var number_elements = 30000;"
i::ScopedVector<char> source(1024);
i::OS::SNPrintF(
source,
"var number_elements = %d;"
"var elements = new Array(number_elements);"
"function f() {"
" for (var i = 0; i < number_elements; i++) {"
......@@ -2357,9 +2331,13 @@ TEST(OptimizedPretenuringDoubleArrayProperties) {
" }"
" return elements[i - 1];"
"};"
"f(); f(); f();"
"f(); gc();"
"f(); f();"
"%OptimizeFunctionOnNextCall(f);"
"f();");
"f();",
AllocationSite::kPretenureMinimumCreated);
v8::Local<v8::Value> res = CompileRun(source.start());
Handle<JSObject> o =
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
......@@ -2371,14 +2349,16 @@ TEST(OptimizedPretenuringDoubleArrayProperties) {
TEST(OptimizedPretenuringdoubleArrayLiterals) {
i::FLAG_allow_natives_syntax = true;
i::FLAG_max_semi_space_size = 1;
i::FLAG_expose_gc = true;
CcTest::InitializeVM();
if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Value> res = CompileRun(
"var number_elements = 30000;"
i::ScopedVector<char> source(1024);
i::OS::SNPrintF(
source,
"var number_elements = %d;"
"var elements = new Array(number_elements);"
"function f() {"
" for (var i = 0; i < number_elements; i++) {"
......@@ -2386,9 +2366,13 @@ TEST(OptimizedPretenuringdoubleArrayLiterals) {
" }"
" return elements[number_elements - 1];"
"};"
"f(); f(); f();"
"f(); gc();"
"f(); f();"
"%OptimizeFunctionOnNextCall(f);"
"f();");
"f();",
AllocationSite::kPretenureMinimumCreated);
v8::Local<v8::Value> res = CompileRun(source.start());
Handle<JSObject> o =
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
......@@ -2400,14 +2384,16 @@ TEST(OptimizedPretenuringdoubleArrayLiterals) {
TEST(OptimizedPretenuringNestedMixedArrayLiterals) {
i::FLAG_allow_natives_syntax = true;
i::FLAG_max_semi_space_size = 1;
i::FLAG_expose_gc = true;
CcTest::InitializeVM();
if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Value> res = CompileRun(
"var number_elements = 20000;"
i::ScopedVector<char> source(1024);
i::OS::SNPrintF(
source,
"var number_elements = 100;"
"var elements = new Array(number_elements);"
"function f() {"
" for (var i = 0; i < number_elements; i++) {"
......@@ -2415,9 +2401,13 @@ TEST(OptimizedPretenuringNestedMixedArrayLiterals) {
" }"
" return elements[number_elements - 1];"
"};"
"f(); f(); f();"
"f(); gc();"
"f(); f();"
"%OptimizeFunctionOnNextCall(f);"
"f();");
"f();",
AllocationSite::kPretenureMinimumCreated);
v8::Local<v8::Value> res = CompileRun(source.start());
v8::Local<v8::Value> int_array = v8::Object::Cast(*res)->Get(v8_str("0"));
Handle<JSObject> int_array_handle =
......@@ -2438,14 +2428,16 @@ TEST(OptimizedPretenuringNestedMixedArrayLiterals) {
TEST(OptimizedPretenuringNestedObjectLiterals) {
i::FLAG_allow_natives_syntax = true;
i::FLAG_max_semi_space_size = 1;
i::FLAG_expose_gc = true;
CcTest::InitializeVM();
if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Value> res = CompileRun(
"var number_elements = 20000;"
i::ScopedVector<char> source(1024);
i::OS::SNPrintF(
source,
"var number_elements = %d;"
"var elements = new Array(number_elements);"
"function f() {"
" for (var i = 0; i < number_elements; i++) {"
......@@ -2453,9 +2445,13 @@ TEST(OptimizedPretenuringNestedObjectLiterals) {
" }"
" return elements[number_elements - 1];"
"};"
"f(); f(); f();"
"f(); gc();"
"f(); f();"
"%OptimizeFunctionOnNextCall(f);"
"f();");
"f();",
AllocationSite::kPretenureMinimumCreated);
v8::Local<v8::Value> res = CompileRun(source.start());
v8::Local<v8::Value> int_array_1 = v8::Object::Cast(*res)->Get(v8_str("0"));
Handle<JSObject> int_array_handle_1 =
......@@ -2476,14 +2472,16 @@ TEST(OptimizedPretenuringNestedObjectLiterals) {
TEST(OptimizedPretenuringNestedDoubleLiterals) {
i::FLAG_allow_natives_syntax = true;
i::FLAG_max_semi_space_size = 1;
i::FLAG_expose_gc = true;
CcTest::InitializeVM();
if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Value> res = CompileRun(
"var number_elements = 20000;"
i::ScopedVector<char> source(1024);
i::OS::SNPrintF(
source,
"var number_elements = %d;"
"var elements = new Array(number_elements);"
"function f() {"
" for (var i = 0; i < number_elements; i++) {"
......@@ -2491,9 +2489,13 @@ TEST(OptimizedPretenuringNestedDoubleLiterals) {
" }"
" return elements[number_elements - 1];"
"};"
"f(); f(); f();"
"f(); gc();"
"f(); f();"
"%OptimizeFunctionOnNextCall(f);"
"f();");
"f();",
AllocationSite::kPretenureMinimumCreated);
v8::Local<v8::Value> res = CompileRun(source.start());
v8::Local<v8::Value> double_array_1 =
v8::Object::Cast(*res)->Get(v8_str("0"));
......@@ -2517,19 +2519,21 @@ TEST(OptimizedPretenuringNestedDoubleLiterals) {
// Make sure pretenuring feedback is gathered for constructed objects as well
// as for literals.
TEST(OptimizedPretenuringConstructorCalls) {
if (!FLAG_allocation_site_pretenuring || !i::FLAG_pretenuring_call_new) {
if (!i::FLAG_pretenuring_call_new) {
// FLAG_pretenuring_call_new needs to be synced with the snapshot.
return;
}
i::FLAG_allow_natives_syntax = true;
i::FLAG_max_semi_space_size = 1;
i::FLAG_expose_gc = true;
CcTest::InitializeVM();
if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Value> res = CompileRun(
"var number_elements = 20000;"
i::ScopedVector<char> source(1024);
i::OS::SNPrintF(
source,
"var number_elements = %d;"
"var elements = new Array(number_elements);"
"function foo() {"
" this.a = 3;"
......@@ -2541,9 +2545,13 @@ TEST(OptimizedPretenuringConstructorCalls) {
" }"
" return elements[number_elements - 1];"
"};"
"f(); f(); f();"
"f(); gc();"
"f(); f();"
"%OptimizeFunctionOnNextCall(f);"
"f();");
"f();",
AllocationSite::kPretenureMinimumCreated);
v8::Local<v8::Value> res = CompileRun(source.start());
Handle<JSObject> o =
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
......@@ -2552,56 +2560,68 @@ TEST(OptimizedPretenuringConstructorCalls) {
}
// Test regular array literals allocation.
TEST(OptimizedAllocationArrayLiterals) {
TEST(OptimizedPretenuringCallNew) {
if (!i::FLAG_pretenuring_call_new) {
// FLAG_pretenuring_call_new needs to be synced with the snapshot.
return;
}
i::FLAG_allow_natives_syntax = true;
i::FLAG_expose_gc = true;
CcTest::InitializeVM();
if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Value> res = CompileRun(
i::ScopedVector<char> source(1024);
i::OS::SNPrintF(
source,
"var number_elements = 100;"
"var elements = new Array(number_elements);"
"function g() { this.a = 0; }"
"function f() {"
" var numbers = new Array(1, 2, 3);"
" numbers[0] = 3.14;"
" return numbers;"
" for (var i = 0; i < number_elements; i++) {"
" elements[i] = new g();"
" }"
" return elements[number_elements - 1];"
"};"
"f(); f(); f();"
"f(); gc();"
"f(); f();"
"%OptimizeFunctionOnNextCall(f);"
"f();");
CHECK_EQ(static_cast<int>(3.14),
v8::Object::Cast(*res)->Get(v8_str("0"))->Int32Value());
"f();",
AllocationSite::kPretenureMinimumCreated);
v8::Local<v8::Value> res = CompileRun(source.start());
Handle<JSObject> o =
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
CHECK(CcTest::heap()->InNewSpace(o->elements()));
CHECK(CcTest::heap()->InOldPointerSpace(*o));
}
// Test global pretenuring call new.
TEST(OptimizedPretenuringCallNew) {
// Test regular array literals allocation.
TEST(OptimizedAllocationArrayLiterals) {
i::FLAG_allow_natives_syntax = true;
i::FLAG_allocation_site_pretenuring = false;
i::FLAG_pretenuring_call_new = true;
CcTest::InitializeVM();
if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate());
AlwaysAllocateScope always_allocate(CcTest::i_isolate());
v8::Local<v8::Value> res = CompileRun(
"function g() { this.a = 0; }"
"function f() {"
" return new g();"
" var numbers = new Array(1, 2, 3);"
" numbers[0] = 3.14;"
" return numbers;"
"};"
"f(); f(); f();"
"%OptimizeFunctionOnNextCall(f);"
"f();");
CHECK_EQ(static_cast<int>(3.14),
v8::Object::Cast(*res)->Get(v8_str("0"))->Int32Value());
Handle<JSObject> o =
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
CHECK(CcTest::heap()->InOldPointerSpace(*o));
CHECK(CcTest::heap()->InNewSpace(o->elements()));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment