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.
|
|
|
|
|
|
|
|
#ifndef V8_COMPILER_PIPELINE_H_
|
|
|
|
#define V8_COMPILER_PIPELINE_H_
|
|
|
|
|
2015-02-06 09:00:40 +00:00
|
|
|
// Clients of this interface shouldn't depend on lots of compiler internals.
|
|
|
|
// Do not include anything from src/compiler here!
|
2014-07-30 13:54:45 +00:00
|
|
|
#include "src/compiler.h"
|
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
2015-10-02 16:55:12 +00:00
|
|
|
|
|
|
|
class RegisterConfiguration;
|
|
|
|
|
2014-07-30 13:54:45 +00:00
|
|
|
namespace compiler {
|
|
|
|
|
2014-11-17 14:46:41 +00:00
|
|
|
class CallDescriptor;
|
2014-07-30 13:54:45 +00:00
|
|
|
class Graph;
|
2014-11-17 12:36:58 +00:00
|
|
|
class InstructionSequence;
|
2014-10-14 08:43:33 +00:00
|
|
|
class Linkage;
|
2014-10-27 09:36:51 +00:00
|
|
|
class PipelineData;
|
2014-07-30 13:54:45 +00:00
|
|
|
class Schedule;
|
|
|
|
|
|
|
|
class Pipeline {
|
|
|
|
public:
|
2014-08-26 15:17:57 +00:00
|
|
|
explicit Pipeline(CompilationInfo* info) : info_(info) {}
|
2014-07-30 13:54:45 +00:00
|
|
|
|
|
|
|
// Run the entire pipeline and generate a handle to a code object.
|
|
|
|
Handle<Code> GenerateCode();
|
|
|
|
|
2015-12-09 14:09:22 +00:00
|
|
|
// Run the pipeline on a machine graph and generate code. The {schedule} must
|
|
|
|
// be valid, hence the given {graph} does not need to be schedulable.
|
2015-12-02 12:35:12 +00:00
|
|
|
static Handle<Code> GenerateCodeForCodeStub(Isolate* isolate,
|
|
|
|
CallDescriptor* call_descriptor,
|
|
|
|
Graph* graph, Schedule* schedule,
|
|
|
|
Code::Kind kind,
|
2015-12-14 13:45:54 +00:00
|
|
|
const char* debug_name);
|
2015-08-25 12:56:50 +00:00
|
|
|
|
2014-11-17 14:46:41 +00:00
|
|
|
// Run the pipeline on a machine graph and generate code. If {schedule} is
|
|
|
|
// {nullptr}, then compute a new schedule for code generation.
|
|
|
|
static Handle<Code> GenerateCodeForTesting(CompilationInfo* info,
|
|
|
|
Graph* graph,
|
|
|
|
Schedule* schedule = nullptr);
|
2014-07-30 13:54:45 +00:00
|
|
|
|
2014-11-17 14:46:41 +00:00
|
|
|
// Run just the register allocator phases.
|
|
|
|
static bool AllocateRegistersForTesting(const RegisterConfiguration* config,
|
|
|
|
InstructionSequence* sequence,
|
|
|
|
bool run_verifier);
|
2014-11-17 12:36:58 +00:00
|
|
|
|
2015-08-28 09:02:09 +00:00
|
|
|
// Run the pipeline on a machine graph and generate code. If {schedule} is
|
|
|
|
// {nullptr}, then compute a new schedule for code generation.
|
2014-11-17 14:46:41 +00:00
|
|
|
static Handle<Code> GenerateCodeForTesting(CompilationInfo* info,
|
|
|
|
CallDescriptor* call_descriptor,
|
2015-08-28 09:02:09 +00:00
|
|
|
Graph* graph,
|
|
|
|
Schedule* schedule = nullptr);
|
2014-11-17 14:46:41 +00:00
|
|
|
|
2015-08-28 09:02:09 +00:00
|
|
|
private:
|
2014-07-30 13:54:45 +00:00
|
|
|
CompilationInfo* info_;
|
2014-11-14 16:44:38 +00:00
|
|
|
PipelineData* data_;
|
|
|
|
|
|
|
|
// Helpers for executing pipeline phases.
|
|
|
|
template <typename Phase>
|
|
|
|
void Run();
|
|
|
|
template <typename Phase, typename Arg0>
|
|
|
|
void Run(Arg0 arg_0);
|
2014-07-30 13:54:45 +00:00
|
|
|
|
2014-08-13 14:05:37 +00:00
|
|
|
CompilationInfo* info() const { return info_; }
|
|
|
|
Isolate* isolate() { return info_->isolate(); }
|
|
|
|
|
2014-11-17 12:36:58 +00:00
|
|
|
void BeginPhaseKind(const char* phase_kind);
|
2014-11-14 16:44:38 +00:00
|
|
|
void RunPrintAndVerify(const char* phase, bool untyped = false);
|
2015-02-13 10:35:18 +00:00
|
|
|
Handle<Code> ScheduleAndGenerateCode(CallDescriptor* call_descriptor);
|
2014-11-17 12:36:58 +00:00
|
|
|
void AllocateRegisters(const RegisterConfiguration* config,
|
[turbofan] Unify referencing of stack slots
Previously, it was not possible to specify StackSlotOperands for all
slots in both the caller and callee stacks. Specifically, the region
of the callee's stack including the saved return address, frame
pointer, function pointer and context pointer could not be addressed
by the register allocator/gap resolver.
In preparation for better tail call support, which will use the gap
resolver to reconcile outgoing parameters, this change makes it
possible to address all slots on the stack, because slots in the
previously inaccessible dead zone may become parameter slots for
outgoing tail calls. All caller stack slots are accessible as they
were before, with slot -1 corresponding to the last stack
parameter. Stack slot indices >= 0 access the callee stack, with slot
0 corresponding to the callee's saved return address, 1 corresponding
to the saved frame pointer, 2 corresponding to the current function
context, 3 corresponding to the frame marker/JSFunction, and slots 4
and above corresponding to spill slots.
The following changes were specifically needed:
* Frame has been changed to explicitly manage three areas of the
callee frame, the fixed header, the spill slot area, and the
callee-saved register area.
* Conversions from stack slot indices to fp offsets all now go through
a common bottleneck: OptimizedFrame::StackSlotOffsetRelativeToFp
* The generation of deoptimization translation tables has been changed
to support the new stack slot indexing scheme. Crankshaft, which
doesn't support the new slot numbering in its register allocator,
must adapt the indexes when creating translation tables.
* Callee-saved parameters are now kept below spill slots, not above,
to support saving only the optimal set of used registers, which is
only known after register allocation is finished and spill slots
have been allocated.
Review URL: https://codereview.chromium.org/1261923007
Cr-Commit-Position: refs/heads/master@{#30224}
2015-08-18 14:47:56 +00:00
|
|
|
CallDescriptor* descriptor, bool run_verifier);
|
2014-07-30 13:54:45 +00:00
|
|
|
};
|
2014-11-14 16:44:38 +00:00
|
|
|
|
|
|
|
} // namespace compiler
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|
2014-07-30 13:54:45 +00:00
|
|
|
|
|
|
|
#endif // V8_COMPILER_PIPELINE_H_
|