[turbofan] make GraphAssembler isolate independent

This enables using the GraphAssembler for Wasm.

Change-Id: Id1f46db6cc05c9de6e878fb062434211a9c390ff
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1977160
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Reviewed-by: Michael Stanton <mvstanton@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65552}
This commit is contained in:
Tobias Tebbi 2019-12-19 23:05:11 +01:00 committed by Commit Bot
parent d873128a67
commit c679efc440
11 changed files with 178 additions and 156 deletions

View File

@ -274,7 +274,7 @@ class EffectControlLinearizer {
return js_graph_->simplified();
}
MachineOperatorBuilder* machine() const { return js_graph_->machine(); }
GraphAssembler* gasm() { return &graph_assembler_; }
JSGraphAssembler* gasm() { return &graph_assembler_; }
JSGraph* js_graph_;
Schedule* schedule_;
@ -284,7 +284,7 @@ class EffectControlLinearizer {
RegionObservability region_observability_ = RegionObservability::kObservable;
SourcePositionTable* source_positions_;
NodeOriginTable* node_origins_;
GraphAssembler graph_assembler_;
JSGraphAssembler graph_assembler_;
Node* frame_state_zapper_; // For tracking down compiler::Node::New crashes.
};

View File

@ -335,27 +335,28 @@ BasicBlock* GraphAssembler::BasicBlockUpdater::Finalize(BasicBlock* original) {
return block;
}
GraphAssembler::GraphAssembler(JSGraph* jsgraph, Zone* zone, Schedule* schedule)
GraphAssembler::GraphAssembler(MachineGraph* mcgraph, Zone* zone,
Schedule* schedule)
: temp_zone_(zone),
jsgraph_(jsgraph),
mcgraph_(mcgraph),
effect_(nullptr),
control_(nullptr),
block_updater_(schedule != nullptr ? new BasicBlockUpdater(
schedule, jsgraph->graph(), zone)
schedule, mcgraph->graph(), zone)
: nullptr) {}
GraphAssembler::~GraphAssembler() = default;
Node* GraphAssembler::IntPtrConstant(intptr_t value) {
return AddClonedNode(jsgraph()->IntPtrConstant(value));
return AddClonedNode(mcgraph()->IntPtrConstant(value));
}
Node* GraphAssembler::Int32Constant(int32_t value) {
return AddClonedNode(jsgraph()->Int32Constant(value));
return AddClonedNode(mcgraph()->Int32Constant(value));
}
Node* GraphAssembler::Int64Constant(int64_t value) {
return AddClonedNode(jsgraph()->Int64Constant(value));
return AddClonedNode(mcgraph()->Int64Constant(value));
}
Node* GraphAssembler::UniqueIntPtrConstant(intptr_t value) {
@ -365,37 +366,37 @@ Node* GraphAssembler::UniqueIntPtrConstant(intptr_t value) {
: common()->Int32Constant(static_cast<int32_t>(value))));
}
Node* GraphAssembler::SmiConstant(int32_t value) {
Node* JSGraphAssembler::SmiConstant(int32_t value) {
return AddClonedNode(jsgraph()->SmiConstant(value));
}
Node* GraphAssembler::Uint32Constant(uint32_t value) {
return AddClonedNode(jsgraph()->Uint32Constant(value));
return AddClonedNode(mcgraph()->Uint32Constant(value));
}
Node* GraphAssembler::Float64Constant(double value) {
return AddClonedNode(jsgraph()->Float64Constant(value));
return AddClonedNode(mcgraph()->Float64Constant(value));
}
TNode<HeapObject> GraphAssembler::HeapConstant(Handle<HeapObject> object) {
TNode<HeapObject> JSGraphAssembler::HeapConstant(Handle<HeapObject> object) {
return TNode<HeapObject>::UncheckedCast(
AddClonedNode(jsgraph()->HeapConstant(object)));
}
TNode<Object> GraphAssembler::Constant(const ObjectRef& ref) {
TNode<Object> JSGraphAssembler::Constant(const ObjectRef& ref) {
return TNode<Object>::UncheckedCast(AddClonedNode(jsgraph()->Constant(ref)));
}
TNode<Number> GraphAssembler::NumberConstant(double value) {
TNode<Number> JSGraphAssembler::NumberConstant(double value) {
return TNode<Number>::UncheckedCast(
AddClonedNode(jsgraph()->Constant(value)));
}
Node* GraphAssembler::ExternalConstant(ExternalReference ref) {
return AddClonedNode(jsgraph()->ExternalConstant(ref));
return AddClonedNode(mcgraph()->ExternalConstant(ref));
}
Node* GraphAssembler::CEntryStubConstant(int result_size) {
Node* JSGraphAssembler::CEntryStubConstant(int result_size) {
return AddClonedNode(jsgraph()->CEntryStubConstant(result_size));
}
@ -404,17 +405,17 @@ Node* GraphAssembler::LoadFramePointer() {
}
#define SINGLETON_CONST_DEF(Name, Type) \
TNode<Type> GraphAssembler::Name##Constant() { \
TNode<Type> JSGraphAssembler::Name##Constant() { \
return TNode<Type>::UncheckedCast( \
AddClonedNode(jsgraph()->Name##Constant())); \
}
JSGRAPH_SINGLETON_CONSTANT_LIST(SINGLETON_CONST_DEF)
#undef SINGLETON_CONST_DEF
#define SINGLETON_CONST_TEST_DEF(Name, ...) \
TNode<Boolean> GraphAssembler::Is##Name(TNode<Object> value) { \
return TNode<Boolean>::UncheckedCast( \
ReferenceEqual(value, Name##Constant())); \
#define SINGLETON_CONST_TEST_DEF(Name, ...) \
TNode<Boolean> JSGraphAssembler::Is##Name(TNode<Object> value) { \
return TNode<Boolean>::UncheckedCast( \
ReferenceEqual(value, Name##Constant())); \
}
JSGRAPH_SINGLETON_CONSTANT_LIST(SINGLETON_CONST_TEST_DEF)
#undef SINGLETON_CONST_TEST_DEF
@ -485,115 +486,118 @@ Node* GraphAssembler::Projection(int index, Node* value) {
graph()->NewNode(common()->Projection(index), value, control()));
}
Node* GraphAssembler::Allocate(AllocationType allocation, Node* size) {
Node* JSGraphAssembler::Allocate(AllocationType allocation, Node* size) {
return AddNode(
graph()->NewNode(simplified()->AllocateRaw(Type::Any(), allocation), size,
effect(), control()));
}
Node* GraphAssembler::LoadField(FieldAccess const& access, Node* object) {
Node* JSGraphAssembler::LoadField(FieldAccess const& access, Node* object) {
Node* value = AddNode(graph()->NewNode(simplified()->LoadField(access),
object, effect(), control()));
return value;
}
Node* GraphAssembler::LoadElement(ElementAccess const& access, Node* object,
Node* index) {
Node* JSGraphAssembler::LoadElement(ElementAccess const& access, Node* object,
Node* index) {
Node* value = AddNode(graph()->NewNode(simplified()->LoadElement(access),
object, index, effect(), control()));
return value;
}
Node* GraphAssembler::StoreField(FieldAccess const& access, Node* object,
Node* value) {
Node* JSGraphAssembler::StoreField(FieldAccess const& access, Node* object,
Node* value) {
return AddNode(graph()->NewNode(simplified()->StoreField(access), object,
value, effect(), control()));
}
Node* GraphAssembler::StoreElement(ElementAccess const& access, Node* object,
Node* index, Node* value) {
Node* JSGraphAssembler::StoreElement(ElementAccess const& access, Node* object,
Node* index, Node* value) {
return AddNode(graph()->NewNode(simplified()->StoreElement(access), object,
index, value, effect(), control()));
}
void GraphAssembler::TransitionAndStoreElement(MapRef double_map,
MapRef fast_map,
TNode<HeapObject> object,
TNode<Number> index,
TNode<Object> value) {
void JSGraphAssembler::TransitionAndStoreElement(MapRef double_map,
MapRef fast_map,
TNode<HeapObject> object,
TNode<Number> index,
TNode<Object> value) {
AddNode(graph()->NewNode(simplified()->TransitionAndStoreElement(
double_map.object(), fast_map.object()),
object, index, value, effect(), control()));
}
TNode<Number> GraphAssembler::StringLength(TNode<String> string) {
TNode<Number> JSGraphAssembler::StringLength(TNode<String> string) {
return AddNode<Number>(
graph()->NewNode(simplified()->StringLength(), string));
}
TNode<Boolean> GraphAssembler::ReferenceEqual(TNode<Object> lhs,
TNode<Object> rhs) {
TNode<Boolean> JSGraphAssembler::ReferenceEqual(TNode<Object> lhs,
TNode<Object> rhs) {
return AddNode<Boolean>(
graph()->NewNode(simplified()->ReferenceEqual(), lhs, rhs));
}
TNode<Number> GraphAssembler::NumberMin(TNode<Number> lhs, TNode<Number> rhs) {
TNode<Number> JSGraphAssembler::NumberMin(TNode<Number> lhs,
TNode<Number> rhs) {
return AddNode<Number>(graph()->NewNode(simplified()->NumberMin(), lhs, rhs));
}
TNode<Number> GraphAssembler::NumberMax(TNode<Number> lhs, TNode<Number> rhs) {
TNode<Number> JSGraphAssembler::NumberMax(TNode<Number> lhs,
TNode<Number> rhs) {
return AddNode<Number>(graph()->NewNode(simplified()->NumberMax(), lhs, rhs));
}
TNode<Number> GraphAssembler::NumberAdd(TNode<Number> lhs, TNode<Number> rhs) {
TNode<Number> JSGraphAssembler::NumberAdd(TNode<Number> lhs,
TNode<Number> rhs) {
return AddNode<Number>(graph()->NewNode(simplified()->NumberAdd(), lhs, rhs));
}
TNode<Number> GraphAssembler::NumberSubtract(TNode<Number> lhs,
TNode<Number> rhs) {
TNode<Number> JSGraphAssembler::NumberSubtract(TNode<Number> lhs,
TNode<Number> rhs) {
return AddNode<Number>(
graph()->NewNode(simplified()->NumberSubtract(), lhs, rhs));
}
TNode<Boolean> GraphAssembler::NumberLessThan(TNode<Number> lhs,
TNode<Number> rhs) {
TNode<Boolean> JSGraphAssembler::NumberLessThan(TNode<Number> lhs,
TNode<Number> rhs) {
return AddNode<Boolean>(
graph()->NewNode(simplified()->NumberLessThan(), lhs, rhs));
}
TNode<Boolean> GraphAssembler::NumberLessThanOrEqual(TNode<Number> lhs,
TNode<Number> rhs) {
TNode<Boolean> JSGraphAssembler::NumberLessThanOrEqual(TNode<Number> lhs,
TNode<Number> rhs) {
return AddNode<Boolean>(
graph()->NewNode(simplified()->NumberLessThanOrEqual(), lhs, rhs));
}
TNode<String> GraphAssembler::StringSubstring(TNode<String> string,
TNode<Number> from,
TNode<Number> to) {
TNode<String> JSGraphAssembler::StringSubstring(TNode<String> string,
TNode<Number> from,
TNode<Number> to) {
return AddNode<String>(graph()->NewNode(
simplified()->StringSubstring(), string, from, to, effect(), control()));
}
TNode<Boolean> GraphAssembler::ObjectIsCallable(TNode<Object> value) {
TNode<Boolean> JSGraphAssembler::ObjectIsCallable(TNode<Object> value) {
return AddNode<Boolean>(
graph()->NewNode(simplified()->ObjectIsCallable(), value));
}
Node* GraphAssembler::CheckIf(Node* cond, DeoptimizeReason reason) {
Node* JSGraphAssembler::CheckIf(Node* cond, DeoptimizeReason reason) {
return AddNode(graph()->NewNode(simplified()->CheckIf(reason), cond, effect(),
control()));
}
TNode<Boolean> GraphAssembler::NumberIsFloat64Hole(TNode<Number> value) {
TNode<Boolean> JSGraphAssembler::NumberIsFloat64Hole(TNode<Number> value) {
return AddNode<Boolean>(
graph()->NewNode(simplified()->NumberIsFloat64Hole(), value));
}
TNode<Boolean> GraphAssembler::ToBoolean(TNode<Object> value) {
TNode<Boolean> JSGraphAssembler::ToBoolean(TNode<Object> value) {
return AddNode<Boolean>(graph()->NewNode(simplified()->ToBoolean(), value));
}
TNode<FixedArrayBase> GraphAssembler::MaybeGrowFastElements(
TNode<FixedArrayBase> JSGraphAssembler::MaybeGrowFastElements(
ElementsKind kind, const FeedbackSource& feedback, TNode<JSArray> array,
TNode<FixedArrayBase> elements, TNode<Number> new_length,
TNode<Number> old_length) {
@ -677,7 +681,7 @@ Node* GraphAssembler::UnsafePointerAdd(Node* base, Node* external) {
effect(), control()));
}
TNode<Number> GraphAssembler::ToNumber(TNode<Object> value) {
TNode<Number> JSGraphAssembler::ToNumber(TNode<Object> value) {
return AddNode<Number>(graph()->NewNode(ToNumberOperator(),
ToNumberBuiltinConstant(), value,
NoContextConstant(), effect()));
@ -798,7 +802,7 @@ void GraphAssembler::GotoIfBasicBlock(BasicBlock* block, Node* branch,
BasicBlock* GraphAssembler::FinalizeCurrentBlock(BasicBlock* block) {
if (block_updater_) {
block = block_updater_->Finalize(block);
if (control() == jsgraph()->Dead()) {
if (control() == mcgraph()->Dead()) {
// If the block's end is unreachable, then reset current effect and
// control to that of the block's throw control node.
DCHECK(block->control() == BasicBlock::kThrow);
@ -814,7 +818,7 @@ void GraphAssembler::ConnectUnreachableToEnd() {
DCHECK_EQ(effect()->opcode(), IrOpcode::kUnreachable);
Node* throw_node = graph()->NewNode(common()->Throw(), effect(), control());
NodeProperties::MergeControlToEnd(graph(), common(), throw_node);
effect_ = control_ = jsgraph()->Dead();
effect_ = control_ = mcgraph()->Dead();
if (block_updater_) {
block_updater_->AddThrow(throw_node);
}
@ -856,10 +860,9 @@ void GraphAssembler::InitializeEffectControl(Node* effect, Node* control) {
control_ = control;
}
Operator const* GraphAssembler::ToNumberOperator() {
Operator const* JSGraphAssembler::ToNumberOperator() {
if (!to_number_operator_.is_set()) {
Callable callable =
Builtins::CallableFor(jsgraph()->isolate(), Builtins::kToNumber);
Callable callable = Builtins::CallableFor(isolate(), Builtins::kToNumber);
CallDescriptor::Flags flags = CallDescriptor::kNoFlags;
auto call_descriptor = Linkage::GetStubCallDescriptor(
graph()->zone(), callable.descriptor(),

View File

@ -232,7 +232,8 @@ class V8_EXPORT_PRIVATE GraphAssembler {
public:
// Constructs a GraphAssembler. If {schedule} is not null, the graph assembler
// will maintain the schedule as it updates blocks.
GraphAssembler(JSGraph* jsgraph, Zone* zone, Schedule* schedule = nullptr);
GraphAssembler(MachineGraph* jsgraph, Zone* zone,
Schedule* schedule = nullptr);
virtual ~GraphAssembler();
void Reset(BasicBlock* block);
@ -271,26 +272,12 @@ class V8_EXPORT_PRIVATE GraphAssembler {
Node* Int32Constant(int32_t value);
Node* Int64Constant(int64_t value);
Node* UniqueIntPtrConstant(intptr_t value);
Node* SmiConstant(int32_t value);
Node* Float64Constant(double value);
Node* Projection(int index, Node* value);
TNode<HeapObject> HeapConstant(Handle<HeapObject> object);
TNode<Object> Constant(const ObjectRef& ref);
TNode<Number> NumberConstant(double value);
Node* CEntryStubConstant(int result_size);
Node* ExternalConstant(ExternalReference ref);
Node* LoadFramePointer();
#define SINGLETON_CONST_DECL(Name, Type) TNode<Type> Name##Constant();
JSGRAPH_SINGLETON_CONSTANT_LIST(SINGLETON_CONST_DECL)
#undef SINGLETON_CONST_DECL
#define SINGLETON_CONST_TEST_DECL(Name, ...) \
TNode<Boolean> Is##Name(TNode<Object> value);
JSGRAPH_SINGLETON_CONSTANT_LIST(SINGLETON_CONST_TEST_DECL)
#undef SINGLETON_CONST_TEST_DECL
#define PURE_UNOP_DECL(Name) Node* Name(Node* input);
PURE_ASSEMBLER_MACH_UNOP_LIST(PURE_UNOP_DECL)
#undef PURE_UNOP_DECL
@ -314,54 +301,9 @@ class V8_EXPORT_PRIVATE GraphAssembler {
Node* Float64RoundDown(Node* value);
Node* Float64RoundTruncate(Node* value);
TNode<Number> ToNumber(TNode<Object> value);
Node* BitcastWordToTagged(Node* value);
Node* BitcastTaggedToWord(Node* value);
Node* BitcastTaggedToWordForTagAndSmiBits(Node* value);
Node* Allocate(AllocationType allocation, Node* size);
Node* LoadField(FieldAccess const&, Node* object);
template <typename T>
TNode<T> LoadField(FieldAccess const& access, TNode<HeapObject> object) {
// TODO(jgruber): Investigate issues on ptr compression bots and enable.
// DCHECK(IsMachineRepresentationOf<T>(
// access.machine_type.representation()));
return TNode<T>::UncheckedCast(LoadField(access, object));
}
Node* LoadElement(ElementAccess const&, Node* object, Node* index);
template <typename T>
TNode<T> LoadElement(ElementAccess const& access, TNode<HeapObject> object,
TNode<Number> index) {
// TODO(jgruber): Investigate issues on ptr compression bots and enable.
// DCHECK(IsMachineRepresentationOf<T>(
// access.machine_type.representation()));
return TNode<T>::UncheckedCast(LoadElement(access, object, index));
}
Node* StoreField(FieldAccess const&, Node* object, Node* value);
Node* StoreElement(ElementAccess const&, Node* object, Node* index,
Node* value);
void TransitionAndStoreElement(MapRef double_map, MapRef fast_map,
TNode<HeapObject> object, TNode<Number> index,
TNode<Object> value);
TNode<Number> StringLength(TNode<String> string);
TNode<Boolean> ReferenceEqual(TNode<Object> lhs, TNode<Object> rhs);
TNode<Number> NumberMin(TNode<Number> lhs, TNode<Number> rhs);
TNode<Number> NumberMax(TNode<Number> lhs, TNode<Number> rhs);
TNode<Boolean> NumberLessThan(TNode<Number> lhs, TNode<Number> rhs);
TNode<Boolean> NumberLessThanOrEqual(TNode<Number> lhs, TNode<Number> rhs);
TNode<Number> NumberAdd(TNode<Number> lhs, TNode<Number> rhs);
TNode<Number> NumberSubtract(TNode<Number> lhs, TNode<Number> rhs);
TNode<String> StringSubstring(TNode<String> string, TNode<Number> from,
TNode<Number> to);
TNode<Boolean> ObjectIsCallable(TNode<Object> value);
Node* CheckIf(Node* cond, DeoptimizeReason reason);
TNode<Boolean> NumberIsFloat64Hole(TNode<Number> value);
TNode<Boolean> ToBoolean(TNode<Object> value);
TNode<FixedArrayBase> MaybeGrowFastElements(ElementsKind kind,
const FeedbackSource& feedback,
TNode<JSArray> array,
TNode<FixedArrayBase> elements,
TNode<Number> new_length,
TNode<Number> old_length);
Node* TypeGuard(Type type, Node* value);
Node* Checkpoint(FrameState frame_state);
@ -468,17 +410,11 @@ class V8_EXPORT_PRIVATE GraphAssembler {
V8_INLINE Node* AddClonedNode(Node* node);
Operator const* ToNumberOperator();
JSGraph* jsgraph() const { return jsgraph_; }
Isolate* isolate() const { return jsgraph_->isolate(); }
Graph* graph() const { return jsgraph_->graph(); }
MachineGraph* mcgraph() const { return mcgraph_; }
Graph* graph() const { return mcgraph_->graph(); }
Zone* temp_zone() const { return temp_zone_; }
CommonOperatorBuilder* common() const { return jsgraph()->common(); }
MachineOperatorBuilder* machine() const { return jsgraph()->machine(); }
SimplifiedOperatorBuilder* simplified() const {
return jsgraph()->simplified();
}
CommonOperatorBuilder* common() const { return mcgraph()->common(); }
MachineOperatorBuilder* machine() const { return mcgraph()->machine(); }
private:
template <typename... Vars>
@ -491,9 +427,8 @@ class V8_EXPORT_PRIVATE GraphAssembler {
BasicBlock* if_true_block,
BasicBlock* if_false_block);
SetOncePointer<Operator const> to_number_operator_;
Zone* temp_zone_;
JSGraph* jsgraph_;
MachineGraph* mcgraph_;
Node* effect_;
Node* control_;
std::unique_ptr<BasicBlockUpdater> block_updater_;
@ -718,6 +653,88 @@ Node* GraphAssembler::Call(const Operator* op, Args... args) {
return AddNode(call);
}
class V8_EXPORT_PRIVATE JSGraphAssembler : public GraphAssembler {
public:
// Constructs a JSGraphAssembler. If {schedule} is not null, the graph
// assembler will maintain the schedule as it updates blocks.
JSGraphAssembler(JSGraph* jsgraph, Zone* zone, Schedule* schedule = nullptr)
: GraphAssembler(jsgraph, zone, schedule), jsgraph_(jsgraph) {}
Node* SmiConstant(int32_t value);
TNode<HeapObject> HeapConstant(Handle<HeapObject> object);
TNode<Object> Constant(const ObjectRef& ref);
TNode<Number> NumberConstant(double value);
Node* CEntryStubConstant(int result_size);
#define SINGLETON_CONST_DECL(Name, Type) TNode<Type> Name##Constant();
JSGRAPH_SINGLETON_CONSTANT_LIST(SINGLETON_CONST_DECL)
#undef SINGLETON_CONST_DECL
#define SINGLETON_CONST_TEST_DECL(Name, ...) \
TNode<Boolean> Is##Name(TNode<Object> value);
JSGRAPH_SINGLETON_CONSTANT_LIST(SINGLETON_CONST_TEST_DECL)
#undef SINGLETON_CONST_TEST_DECL
Node* Allocate(AllocationType allocation, Node* size);
Node* LoadField(FieldAccess const&, Node* object);
template <typename T>
TNode<T> LoadField(FieldAccess const& access, TNode<HeapObject> object) {
// TODO(jgruber): Investigate issues on ptr compression bots and enable.
// DCHECK(IsMachineRepresentationOf<T>(
// access.machine_type.representation()));
return TNode<T>::UncheckedCast(LoadField(access, object));
}
Node* LoadElement(ElementAccess const&, Node* object, Node* index);
template <typename T>
TNode<T> LoadElement(ElementAccess const& access, TNode<HeapObject> object,
TNode<Number> index) {
// TODO(jgruber): Investigate issues on ptr compression bots and enable.
// DCHECK(IsMachineRepresentationOf<T>(
// access.machine_type.representation()));
return TNode<T>::UncheckedCast(LoadElement(access, object, index));
}
Node* StoreField(FieldAccess const&, Node* object, Node* value);
Node* StoreElement(ElementAccess const&, Node* object, Node* index,
Node* value);
void TransitionAndStoreElement(MapRef double_map, MapRef fast_map,
TNode<HeapObject> object, TNode<Number> index,
TNode<Object> value);
TNode<Number> StringLength(TNode<String> string);
TNode<Boolean> ReferenceEqual(TNode<Object> lhs, TNode<Object> rhs);
TNode<Number> ToNumber(TNode<Object> value);
TNode<Number> NumberMin(TNode<Number> lhs, TNode<Number> rhs);
TNode<Number> NumberMax(TNode<Number> lhs, TNode<Number> rhs);
TNode<Boolean> NumberLessThan(TNode<Number> lhs, TNode<Number> rhs);
TNode<Boolean> NumberLessThanOrEqual(TNode<Number> lhs, TNode<Number> rhs);
TNode<Number> NumberAdd(TNode<Number> lhs, TNode<Number> rhs);
TNode<Number> NumberSubtract(TNode<Number> lhs, TNode<Number> rhs);
TNode<String> StringSubstring(TNode<String> string, TNode<Number> from,
TNode<Number> to);
TNode<Boolean> ObjectIsCallable(TNode<Object> value);
Node* CheckIf(Node* cond, DeoptimizeReason reason);
TNode<Boolean> NumberIsFloat64Hole(TNode<Number> value);
TNode<Boolean> ToBoolean(TNode<Object> value);
TNode<FixedArrayBase> MaybeGrowFastElements(ElementsKind kind,
const FeedbackSource& feedback,
TNode<JSArray> array,
TNode<FixedArrayBase> elements,
TNode<Number> new_length,
TNode<Number> old_length);
JSGraph* jsgraph() const { return jsgraph_; }
Isolate* isolate() const { return jsgraph()->isolate(); }
SimplifiedOperatorBuilder* simplified() const {
return jsgraph()->simplified();
}
protected:
Operator const* ToNumberOperator();
private:
JSGraph* jsgraph_;
SetOncePointer<Operator const> to_number_operator_;
};
} // namespace compiler
} // namespace internal
} // namespace v8

View File

@ -41,10 +41,12 @@ namespace compiler {
// Shorter lambda declarations with less visual clutter.
#define _ [&]() // NOLINT(whitespace/braces)
class JSCallReducerAssembler : public GraphAssembler {
class JSCallReducerAssembler : public JSGraphAssembler {
public:
JSCallReducerAssembler(JSGraph* jsgraph, Zone* zone, Node* node)
: GraphAssembler(jsgraph, zone), node_(node), if_exception_nodes_(zone) {
: JSGraphAssembler(jsgraph, zone),
node_(node),
if_exception_nodes_(zone) {
InitializeEffectControl(NodeProperties::GetEffectInput(node),
NodeProperties::GetControlInput(node));
@ -84,7 +86,7 @@ class JSCallReducerAssembler : public GraphAssembler {
// implementation.
class IfBuilder0 {
public:
IfBuilder0(GraphAssembler* gasm, TNode<Boolean> cond, bool negate_cond)
IfBuilder0(JSGraphAssembler* gasm, TNode<Boolean> cond, bool negate_cond)
: gasm_(gasm), cond_(cond), negate_cond_(negate_cond) {}
V8_WARN_UNUSED_RESULT IfBuilder0& ExpectTrue() {
@ -134,7 +136,7 @@ class JSCallReducerAssembler : public GraphAssembler {
}
private:
GraphAssembler* const gasm_;
JSGraphAssembler* const gasm_;
const TNode<Boolean> cond_;
const bool negate_cond_;
BranchHint hint_ = BranchHint::kNone;
@ -150,7 +152,7 @@ class JSCallReducerAssembler : public GraphAssembler {
using If1BodyFunction = std::function<TNode<T>()>;
public:
IfBuilder1(GraphAssembler* gasm, TNode<Boolean> cond)
IfBuilder1(JSGraphAssembler* gasm, TNode<Boolean> cond)
: gasm_(gasm), cond_(cond) {}
V8_WARN_UNUSED_RESULT IfBuilder1& ExpectTrue() {
@ -200,7 +202,7 @@ class JSCallReducerAssembler : public GraphAssembler {
static constexpr MachineRepresentation kPhiRepresentation =
MachineRepresentation::kTagged;
GraphAssembler* const gasm_;
JSGraphAssembler* const gasm_;
const TNode<Boolean> cond_;
BranchHint hint_ = BranchHint::kNone;
If1BodyFunction then_body_;
@ -288,7 +290,7 @@ class JSCallReducerAssembler : public GraphAssembler {
using For0BodyFunction = std::function<void(TNode<Number>)>;
public:
ForBuilder0(GraphAssembler* gasm, TNode<Number> initial_value,
ForBuilder0(JSGraphAssembler* gasm, TNode<Number> initial_value,
const ConditionFunction1& cond, const StepFunction1& step)
: gasm_(gasm),
initial_value_(initial_value),
@ -324,7 +326,7 @@ class JSCallReducerAssembler : public GraphAssembler {
static constexpr MachineRepresentation kPhiRepresentation =
MachineRepresentation::kTagged;
GraphAssembler* const gasm_;
JSGraphAssembler* const gasm_;
const TNode<Number> initial_value_;
const ConditionFunction1 cond_;
const StepFunction1 step_;
@ -347,7 +349,7 @@ class JSCallReducerAssembler : public GraphAssembler {
using For1BodyFunction = std::function<void(TNode<Number>, TNode<Object>*)>;
class ForBuilder1 {
public:
ForBuilder1(GraphAssembler* gasm, TNode<Number> initial_value,
ForBuilder1(JSGraphAssembler* gasm, TNode<Number> initial_value,
const ConditionFunction1& cond, const StepFunction1& step,
TNode<Object> initial_arg0)
: gasm_(gasm),
@ -399,7 +401,7 @@ class JSCallReducerAssembler : public GraphAssembler {
static constexpr MachineRepresentation kPhiRepresentation =
MachineRepresentation::kTagged;
GraphAssembler* const gasm_;
JSGraphAssembler* const gasm_;
const TNode<Number> initial_value_;
const ConditionFunction1 cond_;
const StepFunction1 step_;
@ -670,7 +672,7 @@ TNode<JSArray> JSCallReducerAssembler::CreateArrayNoThrow(TNode<Object> ctor,
TNode<JSArray> JSCallReducerAssembler::AllocateEmptyJSArray(
ElementsKind kind, const NativeContextRef& native_context) {
// TODO(jgruber): Port AllocationBuilder to GraphAssembler.
// TODO(jgruber): Port AllocationBuilder to JSGraphAssembler.
MapRef map = native_context.GetInitialJSArrayMap(kind);
AllocationBuilder ab(jsgraph(), effect(), control());

View File

@ -44,7 +44,7 @@ class MemoryLowering::AllocationGroup final : public ZoneObject {
};
MemoryLowering::MemoryLowering(JSGraph* jsgraph, Zone* zone,
GraphAssembler* graph_assembler,
JSGraphAssembler* graph_assembler,
PoisoningMitigationLevel poisoning_level,
AllocationFolding allocation_folding,
WriteBarrierAssertFailedCallback callback,

View File

@ -71,7 +71,7 @@ class MemoryLowering final : public Reducer {
Node* node, Node* object, const char* name, Zone* temp_zone)>;
MemoryLowering(
JSGraph* jsgraph, Zone* zone, GraphAssembler* graph_assembler,
JSGraph* jsgraph, Zone* zone, JSGraphAssembler* graph_assembler,
PoisoningMitigationLevel poisoning_level,
AllocationFolding allocation_folding =
AllocationFolding::kDontAllocationFolding,
@ -116,7 +116,7 @@ class MemoryLowering final : public Reducer {
Zone* graph_zone() const { return graph_zone_; }
CommonOperatorBuilder* common() const { return common_; }
MachineOperatorBuilder* machine() const { return machine_; }
GraphAssembler* gasm() const { return graph_assembler_; }
JSGraphAssembler* gasm() const { return graph_assembler_; }
SetOncePointer<const Operator> allocate_operator_;
Isolate* isolate_;
@ -124,7 +124,7 @@ class MemoryLowering final : public Reducer {
Zone* graph_zone_;
CommonOperatorBuilder* common_;
MachineOperatorBuilder* machine_;
GraphAssembler* graph_assembler_;
JSGraphAssembler* graph_assembler_;
AllocationFolding allocation_folding_;
PoisoningMitigationLevel poisoning_level_;
WriteBarrierAssertFailedCallback write_barrier_assert_failed_;

View File

@ -79,7 +79,7 @@ class MemoryOptimizer final {
JSGraph* jsgraph() const { return jsgraph_; }
Zone* zone() const { return zone_; }
GraphAssembler graph_assembler_;
JSGraphAssembler graph_assembler_;
MemoryLowering memory_lowering_;
JSGraph* jsgraph_;
AllocationState const* const empty_state_;

View File

@ -1801,7 +1801,7 @@ struct LateOptimizationPhase {
CommonOperatorReducer common_reducer(&graph_reducer, data->graph(),
data->broker(), data->common(),
data->machine(), temp_zone);
GraphAssembler graph_assembler(data->jsgraph(), temp_zone);
JSGraphAssembler graph_assembler(data->jsgraph(), temp_zone);
SelectLowering select_lowering(&graph_assembler, data->graph());
AddReducer(data, &graph_reducer, &branch_condition_elimination);
AddReducer(data, &graph_reducer, &dead_code_elimination);

View File

@ -32,11 +32,11 @@ class ScheduledMachineLowering final {
private:
bool LowerNode(Node* node);
GraphAssembler* gasm() { return &graph_assembler_; }
JSGraphAssembler* gasm() { return &graph_assembler_; }
Schedule* schedule() { return schedule_; }
Schedule* schedule_;
GraphAssembler graph_assembler_;
JSGraphAssembler graph_assembler_;
SelectLowering select_lowering_;
MemoryLowering memory_lowering_;
ZoneVector<Reducer*> reducers_;

View File

@ -15,7 +15,7 @@ namespace v8 {
namespace internal {
namespace compiler {
SelectLowering::SelectLowering(GraphAssembler* graph_assembler, Graph* graph)
SelectLowering::SelectLowering(JSGraphAssembler* graph_assembler, Graph* graph)
: graph_assembler_(graph_assembler), start_(graph->start()) {}
SelectLowering::~SelectLowering() = default;

View File

@ -12,12 +12,12 @@ namespace internal {
namespace compiler {
// Forward declarations.
class GraphAssembler;
class JSGraphAssembler;
// Lowers Select nodes to diamonds.
class SelectLowering final : public Reducer {
public:
SelectLowering(GraphAssembler* graph_assembler, Graph* graph);
SelectLowering(JSGraphAssembler* graph_assembler, Graph* graph);
~SelectLowering() override;
const char* reducer_name() const override { return "SelectLowering"; }
@ -27,10 +27,10 @@ class SelectLowering final : public Reducer {
private:
Reduction LowerSelect(Node* node);
GraphAssembler* gasm() const { return graph_assembler_; }
JSGraphAssembler* gasm() const { return graph_assembler_; }
Node* start() const { return start_; }
GraphAssembler* graph_assembler_;
JSGraphAssembler* graph_assembler_;
Node* start_;
};