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

Unified Diff: test/cctest/compiler/graph-builder-tester.h

Issue 1109853003: [test] Remove pesky MachineCallHelper from inheritance chain. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Cleanup. 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 | « test/cctest/cctest.gyp ('k') | test/cctest/compiler/graph-builder-tester.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/compiler/graph-builder-tester.h
diff --git a/test/cctest/compiler/graph-builder-tester.h b/test/cctest/compiler/graph-builder-tester.h
index ca50c9f4eb92d6a9bd4d9c68ae398f7662eabb24..9a5174c1d744067b017887a56f05ea6a5ba71d2d 100644
--- a/test/cctest/compiler/graph-builder-tester.h
+++ b/test/cctest/compiler/graph-builder-tester.h
@@ -10,7 +10,9 @@
#include "src/compiler/common-operator.h"
#include "src/compiler/graph-builder.h"
+#include "src/compiler/linkage.h"
#include "src/compiler/machine-operator.h"
+#include "src/compiler/pipeline.h"
#include "src/compiler/simplified-operator.h"
#include "test/cctest/compiler/call-tester.h"
#include "test/cctest/compiler/simplified-graph-builder.h"
@@ -19,30 +21,6 @@ namespace v8 {
namespace internal {
namespace compiler {
-class MachineCallHelper : public CallHelper {
- public:
- MachineCallHelper(Isolate* isolate, MachineSignature* machine_sig);
-
- Node* Parameter(size_t index);
-
- void GenerateCode() { Generate(); }
-
- protected:
- virtual byte* Generate();
- void InitParameters(GraphBuilder* builder, CommonOperatorBuilder* common);
-
- protected:
- size_t parameter_count() const { return machine_sig_->parameter_count(); }
-
- private:
- Node** parameters_;
- // TODO(dcarney): shouldn't need graph stored.
- Isolate* isolate_;
- Graph* graph_;
- MaybeHandle<Code> code_;
-};
-
-
class GraphAndBuilders {
public:
explicit GraphAndBuilders(Zone* zone)
@@ -52,7 +30,7 @@ class GraphAndBuilders {
main_simplified_(zone) {}
protected:
- // Prefixed with main_ to avoid naiming conflicts.
+ // Prefixed with main_ to avoid naming conflicts.
Graph* main_graph_;
CommonOperatorBuilder main_common_;
MachineOperatorBuilder main_machine_;
@@ -64,7 +42,7 @@ template <typename ReturnType>
class GraphBuilderTester
: public HandleAndZoneScope,
private GraphAndBuilders,
- public MachineCallHelper,
+ public CallHelper,
public SimplifiedGraphBuilder,
public CallHelper2<ReturnType, GraphBuilderTester<ReturnType> > {
public:
@@ -74,20 +52,53 @@ class GraphBuilderTester
MachineType p3 = kMachNone,
MachineType p4 = kMachNone)
: GraphAndBuilders(main_zone()),
- MachineCallHelper(
+ CallHelper(
main_isolate(),
MakeMachineSignature(
main_zone(), ReturnValueTraits<ReturnType>::Representation(),
p0, p1, p2, p3, p4)),
SimplifiedGraphBuilder(main_isolate(), main_graph_, &main_common_,
- &main_machine_, &main_simplified_) {
+ &main_machine_, &main_simplified_),
+ parameters_(main_zone()->template NewArray<Node*>(parameter_count())) {
Begin(static_cast<int>(parameter_count()));
- InitParameters(this, &main_common_);
+ InitParameters();
}
virtual ~GraphBuilderTester() {}
+ void GenerateCode() { Generate(); }
+ Node* Parameter(size_t index) {
+ DCHECK(index < parameter_count());
+ return parameters_[index];
+ }
+
Factory* factory() const { return isolate()->factory(); }
+
+ protected:
+ virtual byte* Generate() {
+ if (!Pipeline::SupportedBackend()) return NULL;
+ if (code_.is_null()) {
+ Zone* zone = graph()->zone();
+ CallDescriptor* desc =
+ Linkage::GetSimplifiedCDescriptor(zone, machine_sig_);
+ code_ = Pipeline::GenerateCodeForTesting(main_isolate(), desc, graph());
+ }
+ return code_.ToHandleChecked()->entry();
+ }
+
+ void InitParameters() {
+ int param_count = static_cast<int>(parameter_count());
+ for (int i = 0; i < param_count; ++i) {
+ parameters_[i] = this->NewNode(common()->Parameter(i), graph()->start());
+ }
+ }
+
+ size_t parameter_count() const { return machine_sig_->parameter_count(); }
+
+ private:
+ Node** parameters_;
+ MaybeHandle<Code> code_;
};
+
} // namespace compiler
} // namespace internal
} // namespace v8
« no previous file with comments | « test/cctest/cctest.gyp ('k') | test/cctest/compiler/graph-builder-tester.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698