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 { ...@@ -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) \ #define DEFINE_CODE_STUB_BASE(NAME, SUPER) \
public: \ public: \
NAME(uint32_t key, Isolate* isolate) : SUPER(key, isolate) {} \ NAME(uint32_t key, Isolate* isolate) : SUPER(key, isolate) {} \
......
...@@ -63,21 +63,6 @@ CompilationInfo::CompilationInfo(Handle<Script> script, Zone* zone) ...@@ -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, CompilationInfo::CompilationInfo(Handle<SharedFunctionInfo> shared_info,
Zone* zone) Zone* zone)
: flags_(kLazy | kThisHasUses), : flags_(kLazy | kThisHasUses),
......
...@@ -97,7 +97,7 @@ class CompilationInfo { ...@@ -97,7 +97,7 @@ class CompilationInfo {
CompilationInfo(Handle<JSFunction> closure, Zone* zone); CompilationInfo(Handle<JSFunction> closure, Zone* zone);
CompilationInfo(Handle<Script> script, Zone* zone); CompilationInfo(Handle<Script> script, Zone* zone);
CompilationInfo(Isolate* isolate, Zone* zone); CompilationInfo(CodeStub* stub, Isolate* isolate, Zone* zone);
virtual ~CompilationInfo(); virtual ~CompilationInfo();
Isolate* isolate() const { Isolate* isolate() const {
...@@ -427,7 +427,6 @@ class CompilationInfo { ...@@ -427,7 +427,6 @@ class CompilationInfo {
protected: protected:
CompilationInfo(Handle<SharedFunctionInfo> shared_info, CompilationInfo(Handle<SharedFunctionInfo> shared_info,
Zone* zone); Zone* zone);
CompilationInfo(CodeStub* stub, Isolate* isolate, Zone* zone);
CompilationInfo(ScriptCompiler::ExternalSourceStream* source_stream, CompilationInfo(ScriptCompiler::ExternalSourceStream* source_stream,
ScriptCompiler::StreamedSource::Encoding encoding, ScriptCompiler::StreamedSource::Encoding encoding,
Isolate* isolate, Zone* zone); Isolate* isolate, Zone* zone);
......
...@@ -1003,7 +1003,8 @@ Handle<Code> Pipeline::GenerateCodeForTesting(Isolate* isolate, ...@@ -1003,7 +1003,8 @@ Handle<Code> Pipeline::GenerateCodeForTesting(Isolate* isolate,
CallDescriptor* call_descriptor, CallDescriptor* call_descriptor,
Graph* graph, Graph* graph,
Schedule* schedule) { Schedule* schedule) {
CompilationInfo info(isolate, graph->zone()); FakeStubForTesting stub(isolate);
CompilationInfo info(&stub, isolate, graph->zone());
return GenerateCodeForTesting(&info, call_descriptor, graph, schedule); return GenerateCodeForTesting(&info, call_descriptor, graph, schedule);
} }
...@@ -1044,7 +1045,8 @@ Handle<Code> Pipeline::GenerateCodeForTesting(CompilationInfo* info, ...@@ -1044,7 +1045,8 @@ Handle<Code> Pipeline::GenerateCodeForTesting(CompilationInfo* info,
bool Pipeline::AllocateRegistersForTesting(const RegisterConfiguration* config, bool Pipeline::AllocateRegistersForTesting(const RegisterConfiguration* config,
InstructionSequence* sequence, InstructionSequence* sequence,
bool run_verifier) { bool run_verifier) {
CompilationInfo info(sequence->isolate(), sequence->zone()); FakeStubForTesting stub(sequence->isolate());
CompilationInfo info(&stub, sequence->isolate(), sequence->zone());
ZonePool zone_pool; ZonePool zone_pool;
PipelineData data(&zone_pool, &info); PipelineData data(&zone_pool, &info);
data.InitializeTorTesting(sequence); data.InitializeTorTesting(sequence);
......
...@@ -30,8 +30,8 @@ class InstructionTester : public HandleAndZoneScope { ...@@ -30,8 +30,8 @@ class InstructionTester : public HandleAndZoneScope {
: isolate(main_isolate()), : isolate(main_isolate()),
graph(zone()), graph(zone()),
schedule(zone()), schedule(zone()),
info(static_cast<HydrogenCodeStub*>(NULL), main_isolate()), fake_stub(main_isolate()),
linkage(Linkage::ComputeIncoming(zone(), &info)), info(&fake_stub, main_isolate()),
common(zone()), common(zone()),
machine(zone()), machine(zone()),
code(NULL) {} code(NULL) {}
...@@ -39,8 +39,8 @@ class InstructionTester : public HandleAndZoneScope { ...@@ -39,8 +39,8 @@ class InstructionTester : public HandleAndZoneScope {
Isolate* isolate; Isolate* isolate;
Graph graph; Graph graph;
Schedule schedule; Schedule schedule;
FakeStubForTesting fake_stub;
CompilationInfoWithZone info; CompilationInfoWithZone info;
Linkage linkage;
CommonOperatorBuilder common; CommonOperatorBuilder common;
MachineOperatorBuilder machine; MachineOperatorBuilder machine;
TestInstrSeq* code; TestInstrSeq* code;
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "src/v8.h" #include "src/v8.h"
#include "src/code-stubs.h"
#include "src/compiler.h" #include "src/compiler.h"
#include "src/zone.h" #include "src/zone.h"
...@@ -73,11 +74,14 @@ TEST(TestLinkageJSFunctionIncoming) { ...@@ -73,11 +74,14 @@ TEST(TestLinkageJSFunctionIncoming) {
TEST(TestLinkageCodeStubIncoming) { TEST(TestLinkageCodeStubIncoming) {
Isolate* isolate = CcTest::InitIsolateOnce(); 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); CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info);
// TODO(titzer): test linkage creation with a bonafide code stub. CHECK(descriptor);
// this just checks current behavior. CHECK_EQ(1, static_cast<int>(descriptor->JSParameterCount()));
CHECK(!descriptor); 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