Index: test/cctest/test-heap.cc |
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc |
index f97bf17219a903143d00a13faef5d1b3eedd5998..9a5f24ec8227701a0af962da4a907ee3477f1eb4 100644 |
--- a/test/cctest/test-heap.cc |
+++ b/test/cctest/test-heap.cc |
@@ -1264,9 +1264,9 @@ static void FillUpNewSpace(NewSpace* new_space) { |
v8::HandleScope scope; |
AlwaysAllocateScope always_allocate; |
intptr_t available = new_space->EffectiveCapacity() - new_space->Size(); |
- intptr_t number_of_fillers = (available / FixedArray::SizeFor(1000)) - 10; |
+ intptr_t number_of_fillers = (available / FixedArray::SizeFor(32)) - 1; |
for (intptr_t i = 0; i < number_of_fillers; i++) { |
- CHECK(HEAP->InNewSpace(*FACTORY->NewFixedArray(1000, NOT_TENURED))); |
+ CHECK(HEAP->InNewSpace(*FACTORY->NewFixedArray(32, NOT_TENURED))); |
} |
} |
@@ -1680,3 +1680,33 @@ TEST(ResetSharedFunctionInfoCountersDuringMarkSweep) { |
CHECK_EQ(0, f->shared()->opt_count()); |
CHECK_EQ(0, f->shared()->code()->profiler_ticks()); |
} |
+ |
+ |
+// Test that HAllocateObject will always return an object in new-space. |
+TEST(OptimizedAllocationAlwaysInNewSpace) { |
+ i::FLAG_allow_natives_syntax = true; |
+ InitializeVM(); |
+ if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; |
+ v8::HandleScope scope; |
+ |
+ FillUpNewSpace(HEAP->new_space()); |
+ AlwaysAllocateScope always_allocate; |
+ v8::Local<v8::Value> res = CompileRun( |
+ "function c(x) {" |
+ " this.x = x;" |
+ " for (var i = 0; i < 32; i++) {" |
+ " this['x' + i] = x;" |
+ " }" |
+ "}" |
+ "function f(x) { return new c(x); };" |
+ "f(1); f(2); f(3);" |
+ "%OptimizeFunctionOnNextCall(f);" |
+ "f(4);"); |
+ CHECK(res->IsObject()); |
+ CHECK(res->ToObject()->GetRealNamedProperty(v8_str("x"))->Int32Value() == 4); |
+ |
+ Handle<JSObject> o = |
+ v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
+ |
+ CHECK(HEAP->InNewSpace(*o)); |
+} |