2014-07-30 13:54:45 +00:00
|
|
|
// Copyright 2014 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "test/cctest/compiler/graph-builder-tester.h"
|
2014-09-12 11:59:26 +00:00
|
|
|
|
|
|
|
#include "src/compiler/linkage.h"
|
2014-07-30 13:54:45 +00:00
|
|
|
#include "src/compiler/pipeline.h"
|
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
namespace compiler {
|
|
|
|
|
2015-01-23 15:19:34 +00:00
|
|
|
MachineCallHelper::MachineCallHelper(Isolate* isolate,
|
|
|
|
MachineSignature* machine_sig)
|
|
|
|
: CallHelper(isolate, machine_sig),
|
2014-07-30 13:54:45 +00:00
|
|
|
parameters_(NULL),
|
2015-01-23 15:19:34 +00:00
|
|
|
isolate_(isolate),
|
2014-07-30 13:54:45 +00:00
|
|
|
graph_(NULL) {}
|
|
|
|
|
|
|
|
|
|
|
|
void MachineCallHelper::InitParameters(GraphBuilder* builder,
|
|
|
|
CommonOperatorBuilder* common) {
|
2015-01-30 09:29:25 +00:00
|
|
|
DCHECK(!parameters_);
|
2014-07-30 13:54:45 +00:00
|
|
|
graph_ = builder->graph();
|
2014-09-03 10:13:21 +00:00
|
|
|
int param_count = static_cast<int>(parameter_count());
|
|
|
|
if (param_count == 0) return;
|
|
|
|
parameters_ = graph_->zone()->NewArray<Node*>(param_count);
|
|
|
|
for (int i = 0; i < param_count; ++i) {
|
2014-08-05 08:47:39 +00:00
|
|
|
parameters_[i] = builder->NewNode(common->Parameter(i), graph_->start());
|
2014-07-30 13:54:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
byte* MachineCallHelper::Generate() {
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK(parameter_count() == 0 || parameters_ != NULL);
|
2014-08-12 08:06:02 +00:00
|
|
|
if (!Pipeline::SupportedBackend()) return NULL;
|
2014-07-30 13:54:45 +00:00
|
|
|
if (code_.is_null()) {
|
|
|
|
Zone* zone = graph_->zone();
|
2014-11-17 14:46:41 +00:00
|
|
|
CallDescriptor* desc =
|
|
|
|
Linkage::GetSimplifiedCDescriptor(zone, machine_sig_);
|
2015-01-23 15:19:34 +00:00
|
|
|
code_ = Pipeline::GenerateCodeForTesting(isolate_, desc, graph_);
|
2014-07-30 13:54:45 +00:00
|
|
|
}
|
|
|
|
return code_.ToHandleChecked()->entry();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-03 10:13:21 +00:00
|
|
|
Node* MachineCallHelper::Parameter(size_t index) {
|
2015-01-30 09:29:25 +00:00
|
|
|
DCHECK(parameters_);
|
2014-09-03 10:13:21 +00:00
|
|
|
DCHECK(index < parameter_count());
|
|
|
|
return parameters_[index];
|
2014-07-30 13:54:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace compiler
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|