[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: Jaroslav Sevcik <jarin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54823}
This commit is contained in:
Georg Neis 2018-07-31 13:12:53 +02:00 committed by Commit Bot
parent c26c333819
commit bb9cf1cb03
10 changed files with 18 additions and 16 deletions

View File

@ -193,9 +193,7 @@ double MutableHeapNumberRef::value() const {
}
bool ObjectRef::equals(const ObjectRef& other) const {
// TODO(neis): Change this to "data_ == other.data_" once the canonical handle
// scopes are fixed in tests.
return data_->object.equals(other.data_->object);
return data_ == other.data_;
}
StringRef ObjectRef::TypeOf() const {
@ -309,16 +307,7 @@ void JSHeapBroker::AddData(Handle<Object> object, ObjectData* data) {
object->ShortPrint();
PrintF(")\n");
}
if (isolate()->handle_scope_data()->canonical_scope == nullptr) {
// 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_NOT_NULL(isolate()->handle_scope_data()->canonical_scope);
CHECK(refs_.insert({object.address(), data}).second);
}

View File

@ -21,6 +21,7 @@ namespace compiler {
FunctionTester::FunctionTester(const char* source, uint32_t flags)
: isolate(main_isolate()),
canonical(isolate),
function((FLAG_allow_natives_syntax = true, NewFunction(source))),
flags_(flags) {
Compile(function);
@ -30,6 +31,7 @@ FunctionTester::FunctionTester(const char* source, uint32_t flags)
FunctionTester::FunctionTester(Graph* graph, int param_count)
: isolate(main_isolate()),
canonical(isolate),
function(NewFunction(BuildFunction(param_count).c_str())),
flags_(0) {
CompileGraph(graph);
@ -37,6 +39,7 @@ FunctionTester::FunctionTester(Graph* graph, int param_count)
FunctionTester::FunctionTester(Handle<Code> code, int param_count)
: isolate(main_isolate()),
canonical(isolate),
function((FLAG_allow_natives_syntax = true,
NewFunction(BuildFunction(param_count).c_str()))),
flags_(0) {

View File

@ -31,6 +31,7 @@ class FunctionTester : public InitializedHandleScope {
explicit FunctionTester(Handle<Code> code);
Isolate* isolate;
CanonicalHandleScope canonical;
Handle<JSFunction> function;
MaybeHandle<Object> Call() {

View File

@ -22,7 +22,8 @@ namespace compiler {
class ContextSpecializationTester : public HandleAndZoneScope {
public:
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()),
javascript_(main_zone()),
machine_(main_zone()),
@ -50,6 +51,7 @@ class ContextSpecializationTester : public HandleAndZoneScope {
size_t expected_new_depth);
private:
CanonicalHandleScope canonical_;
Graph* graph_;
CommonOperatorBuilder common_;
JSOperatorBuilder javascript_;

View File

@ -23,6 +23,7 @@ class JSTypedLoweringTester : public HandleAndZoneScope {
public:
explicit JSTypedLoweringTester(int num_parameters = 0)
: isolate(main_isolate()),
canonical(isolate),
js_heap_broker(isolate, main_zone()),
binop(nullptr),
unop(nullptr),
@ -39,6 +40,7 @@ class JSTypedLoweringTester : public HandleAndZoneScope {
}
Isolate* isolate;
CanonicalHandleScope canonical;
JSHeapBroker js_heap_broker;
const Operator* binop;
const Operator* unop;

View File

@ -128,6 +128,7 @@ CallDescriptor* CreateDescriptorForStackArguments(Zone* zone,
void TestHelper(int n, int m, bool tail) {
HandleAndZoneScope scope;
Isolate* isolate = scope.main_isolate();
CanonicalHandleScope canonical(isolate);
Zone* zone = scope.main_zone();
CallDescriptor* caller_descriptor =
CreateDescriptorForStackArguments(zone, n);

View File

@ -108,6 +108,7 @@ CallDescriptor* CreateDescriptorForStackArguments(Zone* zone,
void TestHelper(int n, int m) {
HandleAndZoneScope scope;
Isolate* isolate = scope.main_isolate();
CanonicalHandleScope canonical(isolate);
Zone* zone = scope.main_zone();
CallDescriptor* caller_descriptor =
CreateDescriptorForStackArguments(zone, n);

View File

@ -33,12 +33,14 @@ struct Tests {
Isolate* isolate;
HandleScope scope;
CanonicalHandleScope canonical;
Zone zone;
Types T;
Tests()
: isolate(CcTest::InitIsolateOnce()),
scope(isolate),
canonical(isolate),
zone(isolate->allocator(), ZONE_NAME),
T(&zone, isolate, isolate->random_number_generator()) {}

View File

@ -16,6 +16,7 @@ namespace compiler {
GraphTest::GraphTest(int num_parameters)
: TestWithNativeContext(),
TestWithIsolateAndZone(),
canonical_(isolate()),
common_(zone()),
graph_(zone()),
js_heap_broker_(isolate(), zone()),

View File

@ -10,6 +10,7 @@
#include "src/compiler/graph.h"
#include "src/compiler/node-origin-table.h"
#include "src/compiler/typer.h"
#include "src/handles.h"
#include "test/unittests/test-utils.h"
#include "testing/gmock/include/gmock/gmock.h"
@ -17,8 +18,6 @@ namespace v8 {
namespace internal {
// Forward declarations.
template <class T>
class Handle;
class HeapObject;
namespace compiler {
@ -65,6 +64,7 @@ class GraphTest : public virtual TestWithNativeContext,
JSHeapBroker* js_heap_broker() { return &js_heap_broker_; }
private:
CanonicalHandleScope canonical_;
CommonOperatorBuilder common_;
Graph graph_;
JSHeapBroker js_heap_broker_;