Commit 222001ac authored by svenpanne's avatar svenpanne Committed by Commit bot

Removed one bogus CompilationInfo constructor.

Use a fake code stub instead, basically following the null object pattern.

Review URL: https://codereview.chromium.org/918973002

Cr-Commit-Position: refs/heads/master@{#26610}
parent 4465836c
......@@ -294,6 +294,30 @@ class CodeStub BASE_EMBEDDED {
};
// TODO(svenpanne) This class is only used to construct a more or less sensible
// CompilationInfo for testing purposes, basically pretending that we are
// currently compiling some kind of code stub. Remove this when the pipeline and
// testing machinery is restructured in such a way that we don't have to come up
// with a CompilationInfo out of thin air, although we only need a few parts of
// it.
struct FakeStubForTesting : public CodeStub {
explicit FakeStubForTesting(Isolate* isolate) : CodeStub(isolate) {}
// Only used by pipeline.cc's GetDebugName in DEBUG mode.
Major MajorKey() const OVERRIDE { return CodeStub::NoCache; }
CallInterfaceDescriptor GetCallInterfaceDescriptor() OVERRIDE {
UNREACHABLE();
return CallInterfaceDescriptor();
}
Handle<Code> GenerateCode() OVERRIDE {
UNREACHABLE();
return Handle<Code>();
}
};
#define DEFINE_CODE_STUB_BASE(NAME, SUPER) \
public: \
NAME(uint32_t key, Isolate* isolate) : SUPER(key, isolate) {} \
......
......@@ -63,21 +63,6 @@ CompilationInfo::CompilationInfo(Handle<Script> script, Zone* zone)
}
CompilationInfo::CompilationInfo(Isolate* isolate, Zone* zone)
: flags_(kThisHasUses),
script_(Handle<Script>::null()),
source_stream_(NULL),
osr_ast_id_(BailoutId::None()),
parameter_count_(0),
optimization_id_(-1),
ast_value_factory_(NULL),
ast_value_factory_owned_(false),
aborted_due_to_dependency_change_(false),
osr_expr_stack_height_(0) {
Initialize(isolate, STUB, zone);
}
CompilationInfo::CompilationInfo(Handle<SharedFunctionInfo> shared_info,
Zone* zone)
: flags_(kLazy | kThisHasUses),
......
......@@ -97,7 +97,7 @@ class CompilationInfo {
CompilationInfo(Handle<JSFunction> closure, Zone* zone);
CompilationInfo(Handle<Script> script, Zone* zone);
CompilationInfo(Isolate* isolate, Zone* zone);
CompilationInfo(CodeStub* stub, Isolate* isolate, Zone* zone);
virtual ~CompilationInfo();
Isolate* isolate() const {
......@@ -427,7 +427,6 @@ class CompilationInfo {
protected:
CompilationInfo(Handle<SharedFunctionInfo> shared_info,
Zone* zone);
CompilationInfo(CodeStub* stub, Isolate* isolate, Zone* zone);
CompilationInfo(ScriptCompiler::ExternalSourceStream* source_stream,
ScriptCompiler::StreamedSource::Encoding encoding,
Isolate* isolate, Zone* zone);
......
......@@ -1003,7 +1003,8 @@ Handle<Code> Pipeline::GenerateCodeForTesting(Isolate* isolate,
CallDescriptor* call_descriptor,
Graph* graph,
Schedule* schedule) {
CompilationInfo info(isolate, graph->zone());
FakeStubForTesting stub(isolate);
CompilationInfo info(&stub, isolate, graph->zone());
return GenerateCodeForTesting(&info, call_descriptor, graph, schedule);
}
......@@ -1044,7 +1045,8 @@ Handle<Code> Pipeline::GenerateCodeForTesting(CompilationInfo* info,
bool Pipeline::AllocateRegistersForTesting(const RegisterConfiguration* config,
InstructionSequence* sequence,
bool run_verifier) {
CompilationInfo info(sequence->isolate(), sequence->zone());
FakeStubForTesting stub(sequence->isolate());
CompilationInfo info(&stub, sequence->isolate(), sequence->zone());
ZonePool zone_pool;
PipelineData data(&zone_pool, &info);
data.InitializeTorTesting(sequence);
......
......@@ -30,8 +30,8 @@ class InstructionTester : public HandleAndZoneScope {
: isolate(main_isolate()),
graph(zone()),
schedule(zone()),
info(static_cast<HydrogenCodeStub*>(NULL), main_isolate()),
linkage(Linkage::ComputeIncoming(zone(), &info)),
fake_stub(main_isolate()),
info(&fake_stub, main_isolate()),
common(zone()),
machine(zone()),
code(NULL) {}
......@@ -39,8 +39,8 @@ class InstructionTester : public HandleAndZoneScope {
Isolate* isolate;
Graph graph;
Schedule schedule;
FakeStubForTesting fake_stub;
CompilationInfoWithZone info;
Linkage linkage;
CommonOperatorBuilder common;
MachineOperatorBuilder machine;
TestInstrSeq* code;
......
......@@ -4,6 +4,7 @@
#include "src/v8.h"
#include "src/code-stubs.h"
#include "src/compiler.h"
#include "src/zone.h"
......@@ -73,11 +74,14 @@ TEST(TestLinkageJSFunctionIncoming) {
TEST(TestLinkageCodeStubIncoming) {
Isolate* isolate = CcTest::InitIsolateOnce();
CompilationInfoWithZone info(static_cast<CodeStub*>(NULL), isolate);
ToNumberStub stub(isolate);
CompilationInfoWithZone info(&stub, isolate);
CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info);
// TODO(titzer): test linkage creation with a bonafide code stub.
// this just checks current behavior.
CHECK(!descriptor);
CHECK(descriptor);
CHECK_EQ(1, static_cast<int>(descriptor->JSParameterCount()));
CHECK_EQ(1, static_cast<int>(descriptor->ReturnCount()));
CHECK_EQ(Operator::kNoProperties, descriptor->properties());
CHECK_EQ(false, descriptor->IsJSFunctionCall());
}
......
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