| Index: test/cctest/compiler/test-simplified-lowering.cc
|
| diff --git a/test/cctest/compiler/test-simplified-lowering.cc b/test/cctest/compiler/test-simplified-lowering.cc
|
| index d1c877561f11f48a38c2940dca6389dcdda1dcb3..eb730cf3f271b4519ea01c45e2e1c1cde38059b2 100644
|
| --- a/test/cctest/compiler/test-simplified-lowering.cc
|
| +++ b/test/cctest/compiler/test-simplified-lowering.cc
|
| @@ -22,6 +22,7 @@
|
| #include "src/scopes.h"
|
| #include "test/cctest/cctest.h"
|
| #include "test/cctest/compiler/codegen-tester.h"
|
| +#include "test/cctest/compiler/function-tester.h"
|
| #include "test/cctest/compiler/graph-builder-tester.h"
|
| #include "test/cctest/compiler/value-helper.h"
|
|
|
| @@ -77,6 +78,17 @@ class SimplifiedLoweringTester : public GraphBuilderTester<ReturnType> {
|
| CHECK(factory()->NewNumber(expected)->SameValue(result));
|
| }
|
|
|
| + template <typename T>
|
| + T* CallWithPotentialGC() {
|
| + // TODO(titzer): we wrap the code in a JSFunction here to reuse the
|
| + // JSEntryStub; that could be done with a special prologue or other stub.
|
| + Handle<JSFunction> fun = FunctionTester::ForMachineGraph(this->graph());
|
| + Handle<Object>* args = NULL;
|
| + MaybeHandle<Object> result = Execution::Call(
|
| + this->isolate(), fun, factory()->undefined_value(), 0, args, false);
|
| + return T::cast(*result.ToHandleChecked());
|
| + }
|
| +
|
| Factory* factory() { return this->isolate()->factory(); }
|
| Heap* heap() { return this->isolate()->heap(); }
|
| };
|
| @@ -650,6 +662,31 @@ TEST(RunAccessTests_Smi) {
|
| }
|
|
|
|
|
| +TEST(RunAllocate) {
|
| + PretenureFlag flag[] = {NOT_TENURED, TENURED};
|
| +
|
| + for (size_t i = 0; i < arraysize(flag); i++) {
|
| + SimplifiedLoweringTester<HeapObject*> t;
|
| + FieldAccess access = AccessBuilder::ForMap();
|
| + Node* size = t.jsgraph.Constant(HeapNumber::kSize);
|
| + Node* alloc = t.NewNode(t.simplified()->Allocate(flag[i]), size);
|
| + Node* map = t.jsgraph.Constant(t.factory()->heap_number_map());
|
| + t.StoreField(access, alloc, map);
|
| + t.Return(alloc);
|
| +
|
| + t.LowerAllNodes();
|
| + t.GenerateCode();
|
| +
|
| + if (Pipeline::SupportedTarget()) {
|
| + HeapObject* result = t.CallWithPotentialGC<HeapObject>();
|
| + CHECK(t.heap()->new_space()->Contains(result) || flag[i] == TENURED);
|
| + CHECK(t.heap()->old_space()->Contains(result) || flag[i] == NOT_TENURED);
|
| + CHECK(result->IsHeapNumber());
|
| + }
|
| + }
|
| +}
|
| +
|
| +
|
| // Fills in most of the nodes of the graph in order to make tests shorter.
|
| class TestingGraph : public HandleAndZoneScope, public GraphAndBuilders {
|
| public:
|
|
|