Commit bb9cf1cb authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[turbofan] Put some tests under a canonical handle scope.

The heap broker expects that handles get canonicalized.

R=jarin@chromium.org

Bug: v8:7790
Change-Id: If6162316bb2a256e783a8175ac7d4172d040b28b
Reviewed-on: https://chromium-review.googlesource.com/1155123
Commit-Queue: Georg Neis <neis@chromium.org>
Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54823}
parent c26c3338
...@@ -193,9 +193,7 @@ double MutableHeapNumberRef::value() const { ...@@ -193,9 +193,7 @@ double MutableHeapNumberRef::value() const {
} }
bool ObjectRef::equals(const ObjectRef& other) const { bool ObjectRef::equals(const ObjectRef& other) const {
// TODO(neis): Change this to "data_ == other.data_" once the canonical handle return data_ == other.data_;
// scopes are fixed in tests.
return data_->object.equals(other.data_->object);
} }
StringRef ObjectRef::TypeOf() const { StringRef ObjectRef::TypeOf() const {
...@@ -309,16 +307,7 @@ void JSHeapBroker::AddData(Handle<Object> object, ObjectData* data) { ...@@ -309,16 +307,7 @@ void JSHeapBroker::AddData(Handle<Object> object, ObjectData* data) {
object->ShortPrint(); object->ShortPrint();
PrintF(")\n"); PrintF(")\n");
} }
if (isolate()->handle_scope_data()->canonical_scope == nullptr) { CHECK_NOT_NULL(isolate()->handle_scope_data()->canonical_scope);
// TODO(neis): Change the tests to always have canonical handle scopes.
CHECK_EQ(mode(), kDisabled);
if (FLAG_trace_heap_broker) {
PrintF(
"... but not remembering it because there's no canonical handle "
"scope\n");
}
return;
}
CHECK(refs_.insert({object.address(), data}).second); CHECK(refs_.insert({object.address(), data}).second);
} }
......
...@@ -21,6 +21,7 @@ namespace compiler { ...@@ -21,6 +21,7 @@ namespace compiler {
FunctionTester::FunctionTester(const char* source, uint32_t flags) FunctionTester::FunctionTester(const char* source, uint32_t flags)
: isolate(main_isolate()), : isolate(main_isolate()),
canonical(isolate),
function((FLAG_allow_natives_syntax = true, NewFunction(source))), function((FLAG_allow_natives_syntax = true, NewFunction(source))),
flags_(flags) { flags_(flags) {
Compile(function); Compile(function);
...@@ -30,6 +31,7 @@ FunctionTester::FunctionTester(const char* source, uint32_t flags) ...@@ -30,6 +31,7 @@ FunctionTester::FunctionTester(const char* source, uint32_t flags)
FunctionTester::FunctionTester(Graph* graph, int param_count) FunctionTester::FunctionTester(Graph* graph, int param_count)
: isolate(main_isolate()), : isolate(main_isolate()),
canonical(isolate),
function(NewFunction(BuildFunction(param_count).c_str())), function(NewFunction(BuildFunction(param_count).c_str())),
flags_(0) { flags_(0) {
CompileGraph(graph); CompileGraph(graph);
...@@ -37,6 +39,7 @@ FunctionTester::FunctionTester(Graph* graph, int param_count) ...@@ -37,6 +39,7 @@ FunctionTester::FunctionTester(Graph* graph, int param_count)
FunctionTester::FunctionTester(Handle<Code> code, int param_count) FunctionTester::FunctionTester(Handle<Code> code, int param_count)
: isolate(main_isolate()), : isolate(main_isolate()),
canonical(isolate),
function((FLAG_allow_natives_syntax = true, function((FLAG_allow_natives_syntax = true,
NewFunction(BuildFunction(param_count).c_str()))), NewFunction(BuildFunction(param_count).c_str()))),
flags_(0) { flags_(0) {
......
...@@ -31,6 +31,7 @@ class FunctionTester : public InitializedHandleScope { ...@@ -31,6 +31,7 @@ class FunctionTester : public InitializedHandleScope {
explicit FunctionTester(Handle<Code> code); explicit FunctionTester(Handle<Code> code);
Isolate* isolate; Isolate* isolate;
CanonicalHandleScope canonical;
Handle<JSFunction> function; Handle<JSFunction> function;
MaybeHandle<Object> Call() { MaybeHandle<Object> Call() {
......
...@@ -22,7 +22,8 @@ namespace compiler { ...@@ -22,7 +22,8 @@ namespace compiler {
class ContextSpecializationTester : public HandleAndZoneScope { class ContextSpecializationTester : public HandleAndZoneScope {
public: public:
explicit ContextSpecializationTester(Maybe<OuterContext> context) explicit ContextSpecializationTester(Maybe<OuterContext> context)
: graph_(new (main_zone()) Graph(main_zone())), : canonical_(main_isolate()),
graph_(new (main_zone()) Graph(main_zone())),
common_(main_zone()), common_(main_zone()),
javascript_(main_zone()), javascript_(main_zone()),
machine_(main_zone()), machine_(main_zone()),
...@@ -50,6 +51,7 @@ class ContextSpecializationTester : public HandleAndZoneScope { ...@@ -50,6 +51,7 @@ class ContextSpecializationTester : public HandleAndZoneScope {
size_t expected_new_depth); size_t expected_new_depth);
private: private:
CanonicalHandleScope canonical_;
Graph* graph_; Graph* graph_;
CommonOperatorBuilder common_; CommonOperatorBuilder common_;
JSOperatorBuilder javascript_; JSOperatorBuilder javascript_;
......
...@@ -23,6 +23,7 @@ class JSTypedLoweringTester : public HandleAndZoneScope { ...@@ -23,6 +23,7 @@ class JSTypedLoweringTester : public HandleAndZoneScope {
public: public:
explicit JSTypedLoweringTester(int num_parameters = 0) explicit JSTypedLoweringTester(int num_parameters = 0)
: isolate(main_isolate()), : isolate(main_isolate()),
canonical(isolate),
js_heap_broker(isolate, main_zone()), js_heap_broker(isolate, main_zone()),
binop(nullptr), binop(nullptr),
unop(nullptr), unop(nullptr),
...@@ -39,6 +40,7 @@ class JSTypedLoweringTester : public HandleAndZoneScope { ...@@ -39,6 +40,7 @@ class JSTypedLoweringTester : public HandleAndZoneScope {
} }
Isolate* isolate; Isolate* isolate;
CanonicalHandleScope canonical;
JSHeapBroker js_heap_broker; JSHeapBroker js_heap_broker;
const Operator* binop; const Operator* binop;
const Operator* unop; const Operator* unop;
......
...@@ -128,6 +128,7 @@ CallDescriptor* CreateDescriptorForStackArguments(Zone* zone, ...@@ -128,6 +128,7 @@ CallDescriptor* CreateDescriptorForStackArguments(Zone* zone,
void TestHelper(int n, int m, bool tail) { void TestHelper(int n, int m, bool tail) {
HandleAndZoneScope scope; HandleAndZoneScope scope;
Isolate* isolate = scope.main_isolate(); Isolate* isolate = scope.main_isolate();
CanonicalHandleScope canonical(isolate);
Zone* zone = scope.main_zone(); Zone* zone = scope.main_zone();
CallDescriptor* caller_descriptor = CallDescriptor* caller_descriptor =
CreateDescriptorForStackArguments(zone, n); CreateDescriptorForStackArguments(zone, n);
......
...@@ -108,6 +108,7 @@ CallDescriptor* CreateDescriptorForStackArguments(Zone* zone, ...@@ -108,6 +108,7 @@ CallDescriptor* CreateDescriptorForStackArguments(Zone* zone,
void TestHelper(int n, int m) { void TestHelper(int n, int m) {
HandleAndZoneScope scope; HandleAndZoneScope scope;
Isolate* isolate = scope.main_isolate(); Isolate* isolate = scope.main_isolate();
CanonicalHandleScope canonical(isolate);
Zone* zone = scope.main_zone(); Zone* zone = scope.main_zone();
CallDescriptor* caller_descriptor = CallDescriptor* caller_descriptor =
CreateDescriptorForStackArguments(zone, n); CreateDescriptorForStackArguments(zone, n);
......
...@@ -33,12 +33,14 @@ struct Tests { ...@@ -33,12 +33,14 @@ struct Tests {
Isolate* isolate; Isolate* isolate;
HandleScope scope; HandleScope scope;
CanonicalHandleScope canonical;
Zone zone; Zone zone;
Types T; Types T;
Tests() Tests()
: isolate(CcTest::InitIsolateOnce()), : isolate(CcTest::InitIsolateOnce()),
scope(isolate), scope(isolate),
canonical(isolate),
zone(isolate->allocator(), ZONE_NAME), zone(isolate->allocator(), ZONE_NAME),
T(&zone, isolate, isolate->random_number_generator()) {} T(&zone, isolate, isolate->random_number_generator()) {}
......
...@@ -16,6 +16,7 @@ namespace compiler { ...@@ -16,6 +16,7 @@ namespace compiler {
GraphTest::GraphTest(int num_parameters) GraphTest::GraphTest(int num_parameters)
: TestWithNativeContext(), : TestWithNativeContext(),
TestWithIsolateAndZone(), TestWithIsolateAndZone(),
canonical_(isolate()),
common_(zone()), common_(zone()),
graph_(zone()), graph_(zone()),
js_heap_broker_(isolate(), zone()), js_heap_broker_(isolate(), zone()),
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "src/compiler/graph.h" #include "src/compiler/graph.h"
#include "src/compiler/node-origin-table.h" #include "src/compiler/node-origin-table.h"
#include "src/compiler/typer.h" #include "src/compiler/typer.h"
#include "src/handles.h"
#include "test/unittests/test-utils.h" #include "test/unittests/test-utils.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
...@@ -17,8 +18,6 @@ namespace v8 { ...@@ -17,8 +18,6 @@ namespace v8 {
namespace internal { namespace internal {
// Forward declarations. // Forward declarations.
template <class T>
class Handle;
class HeapObject; class HeapObject;
namespace compiler { namespace compiler {
...@@ -65,6 +64,7 @@ class GraphTest : public virtual TestWithNativeContext, ...@@ -65,6 +64,7 @@ class GraphTest : public virtual TestWithNativeContext,
JSHeapBroker* js_heap_broker() { return &js_heap_broker_; } JSHeapBroker* js_heap_broker() { return &js_heap_broker_; }
private: private:
CanonicalHandleScope canonical_;
CommonOperatorBuilder common_; CommonOperatorBuilder common_;
Graph graph_; Graph graph_;
JSHeapBroker js_heap_broker_; JSHeapBroker js_heap_broker_;
......
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