Commit db13377f authored by jarin's avatar jarin Committed by Commit bot

[turbofan] Use graph assembler for memory optimizer.

Review-Url: https://codereview.chromium.org/2602413002
Cr-Commit-Position: refs/heads/master@{#42041}
parent efb329a8
......@@ -7,7 +7,6 @@
#include "src/code-factory.h"
#include "src/compiler/access-builder.h"
#include "src/compiler/compiler-source-position-table.h"
#include "src/compiler/graph-assembler.h"
#include "src/compiler/js-graph.h"
#include "src/compiler/linkage.h"
#include "src/compiler/node-matchers.h"
......
......@@ -18,14 +18,6 @@ GraphAssembler::GraphAssembler(JSGraph* jsgraph, Node* effect, Node* control,
current_effect_(effect),
current_control_(control) {}
Node* GraphAssembler::TrueConstant() { return jsgraph()->TrueConstant(); }
Node* GraphAssembler::FalseConstant() { return jsgraph()->FalseConstant(); }
Node* GraphAssembler::HeapNumberMapConstant() {
return jsgraph()->HeapNumberMapConstant();
}
Node* GraphAssembler::IntPtrConstant(intptr_t value) {
return jsgraph()->IntPtrConstant(value);
}
......@@ -34,6 +26,10 @@ Node* GraphAssembler::Int32Constant(int32_t value) {
return jsgraph()->Int32Constant(value);
}
Node* GraphAssembler::UniqueInt32Constant(int32_t value) {
return graph()->NewNode(common()->Int32Constant(value));
}
Node* GraphAssembler::SmiConstant(int32_t value) {
return jsgraph()->SmiConstant(value);
}
......@@ -50,9 +46,6 @@ Node* GraphAssembler::HeapConstant(Handle<HeapObject> object) {
return jsgraph()->HeapConstant(object);
}
Node* GraphAssembler::NoContextConstant() {
return jsgraph()->NoContextConstant();
}
Node* GraphAssembler::ExternalConstant(ExternalReference ref) {
return jsgraph()->ExternalConstant(ref);
......@@ -62,19 +55,10 @@ Node* GraphAssembler::CEntryStubConstant(int result_size) {
return jsgraph()->CEntryStubConstant(result_size);
}
Node* GraphAssembler::EmptyStringConstant() {
return jsgraph()->EmptyStringConstant();
}
Node* GraphAssembler::UndefinedConstant() {
return jsgraph()->UndefinedConstant();
}
Node* GraphAssembler::TheHoleConstant() { return jsgraph()->TheHoleConstant(); }
Node* GraphAssembler::FixedArrayMapConstant() {
return jsgraph()->FixedArrayMapConstant();
}
#define SINGLETON_CONST_DEF(Name) \
Node* GraphAssembler::Name() { return jsgraph()->Name(); }
JSGRAPH_SINGLETON_CONSTANT_LIST(SINGLETON_CONST_DEF)
#undef SINGLETON_CONST_DEF
#define PURE_UNOP_DEF(Name) \
Node* GraphAssembler::Name(Node* input) { \
......@@ -148,6 +132,12 @@ Node* GraphAssembler::Store(StoreRepresentation rep, Node* object, Node* offset,
current_effect_, current_control_);
}
Node* GraphAssembler::Load(MachineType rep, Node* object, Node* offset) {
return current_effect_ =
graph()->NewNode(machine()->Load(rep), object, offset,
current_effect_, current_control_);
}
Node* GraphAssembler::Retain(Node* buffer) {
return current_effect_ =
graph()->NewNode(common()->Retain(), buffer, current_effect_);
......@@ -160,9 +150,9 @@ Node* GraphAssembler::UnsafePointerAdd(Node* base, Node* external) {
}
Node* GraphAssembler::ToNumber(Node* value) {
return current_effect_ = graph()->NewNode(
ToNumberOperator(), jsgraph()->ToNumberBuiltinConstant(), value,
jsgraph()->NoContextConstant(), current_effect_);
return current_effect_ =
graph()->NewNode(ToNumberOperator(), ToNumberBuiltinConstant(),
value, NoContextConstant(), current_effect_);
}
Node* GraphAssembler::DeoptimizeIf(DeoptimizeReason reason, Node* condition,
......
......@@ -28,7 +28,8 @@ namespace compiler {
V(RoundFloat64ToInt32) \
V(TruncateFloat64ToWord32) \
V(Float64ExtractHighWord32) \
V(Float64Abs)
V(Float64Abs) \
V(BitcastWordToTagged)
#define PURE_ASSEMBLER_MACH_BINOP_LIST(V) \
V(WordShl) \
......@@ -38,6 +39,9 @@ namespace compiler {
V(Word32And) \
V(Word32Shr) \
V(Word32Shl) \
V(IntAdd) \
V(IntSub) \
V(UintLessThan) \
V(Int32Add) \
V(Int32Sub) \
V(Int32Mul) \
......@@ -63,6 +67,19 @@ namespace compiler {
V(Uint32Mod) \
V(Uint32Div)
#define JSGRAPH_SINGLETON_CONSTANT_LIST(V) \
V(TrueConstant) \
V(FalseConstant) \
V(HeapNumberMapConstant) \
V(NoContextConstant) \
V(EmptyStringConstant) \
V(UndefinedConstant) \
V(TheHoleConstant) \
V(FixedArrayMapConstant) \
V(ToNumberBuiltinConstant) \
V(AllocateInNewSpaceStubConstant) \
V(AllocateInOldSpaceStubConstant)
class GraphAssembler;
enum class GraphAssemblerLabelType { kDeferred, kNonDeferred };
......@@ -216,23 +233,20 @@ class GraphAssembler {
}
// Value creation.
Node* TrueConstant();
Node* FalseConstant();
Node* HeapNumberMapConstant();
Node* IntPtrConstant(intptr_t value);
Node* Uint32Constant(int32_t value);
Node* Int32Constant(int32_t value);
Node* UniqueInt32Constant(int32_t value);
Node* SmiConstant(int32_t value);
Node* Float64Constant(double value);
Node* Projection(int index, Node* value);
Node* HeapConstant(Handle<HeapObject> object);
Node* NoContextConstant();
Node* CEntryStubConstant(int result_size);
Node* ExternalConstant(ExternalReference ref);
Node* EmptyStringConstant();
Node* UndefinedConstant();
Node* TheHoleConstant();
Node* FixedArrayMapConstant();
#define SINGLETON_CONST_DECL(Name) Node* Name();
JSGRAPH_SINGLETON_CONSTANT_LIST(SINGLETON_CONST_DECL)
#undef SINGLETON_CONST_DECL
#define PURE_UNOP_DECL(Name) Node* Name(Node* input);
PURE_ASSEMBLER_MACH_UNOP_LIST(PURE_UNOP_DECL)
......@@ -254,6 +268,7 @@ class GraphAssembler {
Node* value);
Node* Store(StoreRepresentation rep, Node* object, Node* offset, Node* value);
Node* Load(MachineType rep, Node* object, Node* offset);
Node* Retain(Node* buffer);
Node* UnsafePointerAdd(Node* base, Node* external);
......@@ -264,6 +279,8 @@ class GraphAssembler {
Node* frame_state);
template <typename... Args>
Node* Call(const CallDescriptor* desc, Args... args);
template <typename... Args>
Node* Call(const Operator* op, Args... args);
// Basic control operations.
template <class LabelType>
......@@ -410,6 +427,12 @@ void GraphAssembler::GotoUnless(Node* condition, LabelType* label,
template <typename... Args>
Node* GraphAssembler::Call(const CallDescriptor* desc, Args... args) {
const Operator* op = common()->Call(desc);
return Call(op, args...);
}
template <typename... Args>
Node* GraphAssembler::Call(const Operator* op, Args... args) {
DCHECK_EQ(IrOpcode::kCall, op->opcode());
Node* args_array[] = {args..., current_effect_, current_control_};
int size = static_cast<int>(sizeof...(args)) + op->EffectInputCount() +
op->ControlInputCount();
......
This diff is collapsed.
......@@ -5,6 +5,7 @@
#ifndef V8_COMPILER_MEMORY_OPTIMIZER_H_
#define V8_COMPILER_MEMORY_OPTIMIZER_H_
#include "src/compiler/graph-assembler.h"
#include "src/zone/zone-containers.h"
namespace v8 {
......@@ -131,6 +132,7 @@ class MemoryOptimizer final {
CommonOperatorBuilder* common() const;
MachineOperatorBuilder* machine() const;
Zone* zone() const { return zone_; }
GraphAssembler* gasm() { return &graph_assembler_; }
SetOncePointer<const Operator> allocate_operator_;
JSGraph* const jsgraph_;
......@@ -138,6 +140,7 @@ class MemoryOptimizer final {
ZoneMap<NodeId, AllocationStates> pending_;
ZoneQueue<Token> tokens_;
Zone* const zone_;
GraphAssembler graph_assembler_;
DISALLOW_IMPLICIT_CONSTRUCTORS(MemoryOptimizer);
};
......
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