Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(235)

Unified Diff: test/cctest/compiler/test-simplified-lowering.cc

Issue 1109773002: [turbofan] Add SimplifiedOperator::Allocate operator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/flag-definitions.h ('k') | test/unittests/compiler/js-typed-lowering-unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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:
« no previous file with comments | « src/flag-definitions.h ('k') | test/unittests/compiler/js-typed-lowering-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698