Reviewers: Michael Starzinger, mvstanton,
Message:
We will enable this code as soon as we have pretenuring support for specific
allocation sites.
Description:
Added pretenuring support for call new.
BUG=
Please review this at https://codereview.chromium.org/16226012/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/flag-definitions.h
M src/hydrogen.cc
M test/cctest/test-heap.cc
Index: src/flag-definitions.h
diff --git a/src/flag-definitions.h b/src/flag-definitions.h
index
8fe6778e67cc26093d8079594351d2c040fa0529..d0068769976f6db6b5f3165771c316a9b217a552
100644
--- a/src/flag-definitions.h
+++ b/src/flag-definitions.h
@@ -193,6 +193,9 @@ 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")
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_heap_object_fields, true, "track fields with heap
values")
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index
1cf6d836fb11ae9f8dc78d93e92f4e61ce4e01d3..df04a052e51cf055193c10782bcd252b0b98f3ec
100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -8782,11 +8782,19 @@ void HOptimizedGraphBuilder::VisitCallNew(CallNew*
expr) {
HValue* size_in_bytes =
AddInstruction(new(zone()) HConstant(instance_size,
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 =
AddInstruction(new(zone()) HAllocate(context,
size_in_bytes,
HType::JSObject(),
- HAllocate::DefaultFlags()));
+ flags));
HAllocate::cast(receiver)->set_known_initial_map(initial_map);
// Load the initial map from the constructor.
Index: test/cctest/test-heap.cc
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc
index
0c66c8f524ecbb6afeb7eab764dba696a30c59ec..c11355c3cb609ebcc1e841093a583510970f187c
100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -2155,6 +2155,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) {
return map->transitions()->number_of_transitions();
}
--
--
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/groups/opt_out.