Commit 599511d0 authored by hpayer@chromium.org's avatar hpayer@chromium.org

Added pretenuring support for call new.

BUG=
R=mvstanton@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14935 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 8a02fd3b
...@@ -193,6 +193,9 @@ DEFINE_bool(clever_optimizations, ...@@ -193,6 +193,9 @@ DEFINE_bool(clever_optimizations,
true, true,
"Optimize object size, Array shift, DOM strings and string +") "Optimize object size, Array shift, DOM strings and string +")
DEFINE_bool(pretenuring, true, "allocate objects in old space") 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")
DEFINE_bool(track_fields, true, "track fields with only smi values") DEFINE_bool(track_fields, true, "track fields with only smi values")
DEFINE_bool(track_double_fields, true, "track fields with double values") DEFINE_bool(track_double_fields, true, "track fields with double values")
DEFINE_bool(track_heap_object_fields, true, "track fields with heap values") DEFINE_bool(track_heap_object_fields, true, "track fields with heap values")
......
...@@ -8780,11 +8780,19 @@ void HOptimizedGraphBuilder::VisitCallNew(CallNew* expr) { ...@@ -8780,11 +8780,19 @@ void HOptimizedGraphBuilder::VisitCallNew(CallNew* expr) {
HValue* size_in_bytes = HValue* size_in_bytes =
AddInstruction(new(zone()) HConstant(instance_size, AddInstruction(new(zone()) HConstant(instance_size,
Representation::Integer32())); Representation::Integer32()));
HAllocate::Flags flags = HAllocate::DefaultFlags();
if (FLAG_pretenuring_call_new &&
isolate()->heap()->ShouldGloballyPretenure()) {
flags = static_cast<HAllocate::Flags>(
flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE);
}
HInstruction* receiver = HInstruction* receiver =
AddInstruction(new(zone()) HAllocate(context, AddInstruction(new(zone()) HAllocate(context,
size_in_bytes, size_in_bytes,
HType::JSObject(), HType::JSObject(),
HAllocate::DefaultFlags())); flags));
HAllocate::cast(receiver)->set_known_initial_map(initial_map); HAllocate::cast(receiver)->set_known_initial_map(initial_map);
// Load the initial map from the constructor. // Load the initial map from the constructor.
......
...@@ -2183,6 +2183,30 @@ TEST(OptimizedAllocationArrayLiterals) { ...@@ -2183,6 +2183,30 @@ TEST(OptimizedAllocationArrayLiterals) {
} }
TEST(OptimizedPretenuringCallNew) {
i::FLAG_allow_natives_syntax = true;
i::FLAG_pretenuring_call_new = true;
CcTest::InitializeVM();
if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate());
HEAP->SetNewSpaceHighPromotionModeActive(true);
AlwaysAllocateScope always_allocate;
v8::Local<v8::Value> res = CompileRun(
"function g() { this.a = 0; }"
"function f() {"
" return new g();"
"};"
"f(); f(); f();"
"%OptimizeFunctionOnNextCall(f);"
"f();");
Handle<JSObject> o =
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
CHECK(HEAP->InOldPointerSpace(*o));
}
static int CountMapTransitions(Map* map) { static int CountMapTransitions(Map* map) {
return map->transitions()->number_of_transitions(); return map->transitions()->number_of_transitions();
} }
......
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