Commit 0a5bffe2 authored by leszeks's avatar leszeks Committed by Commit bot

[turbofan] Do not set node's mark to min on get

This simplifies the mark getter enough to generate a branch-free check
on many architectures (e.g. using cmov on x64 or csel on ARM).

As a drive-by, we can now make the mark access const.

Review-Url: https://codereview.chromium.org/2583043004
Cr-Commit-Position: refs/heads/master@{#41833}
parent a1418981
......@@ -20,11 +20,10 @@ class NodeMarkerBase {
public:
NodeMarkerBase(Graph* graph, uint32_t num_states);
V8_INLINE Mark Get(Node* node) {
V8_INLINE Mark Get(const Node* node) {
Mark mark = node->mark();
if (mark < mark_min_) {
mark = mark_min_;
node->set_mark(mark_min_);
return 0;
}
DCHECK_LT(mark, mark_max_);
return mark - mark_min_;
......@@ -52,9 +51,9 @@ class NodeMarkerBase {
// set to State(0) in constant time.
//
// In its current implementation, in debug mode NodeMarker will try to
// (efficiently) detect invalid use of an older NodeMarker. Namely, if you get
// or set a node with a NodeMarker, and then get or set that node
// with an older NodeMarker you will get a crash.
// (efficiently) detect invalid use of an older NodeMarker. Namely, if you set a
// node with a NodeMarker, and then get or set that node with an older
// NodeMarker you will get a crash.
//
// GraphReducer uses a NodeMarker, so individual Reducers cannot use a
// NodeMarker.
......@@ -64,7 +63,7 @@ class NodeMarker : public NodeMarkerBase {
V8_INLINE NodeMarker(Graph* graph, uint32_t num_states)
: NodeMarkerBase(graph, num_states) {}
V8_INLINE State Get(Node* node) {
V8_INLINE State Get(const Node* node) {
return static_cast<State>(NodeMarkerBase::Get(node));
}
......
......@@ -294,7 +294,7 @@ class V8_EXPORT_PRIVATE Node final {
void set_type(Type* type) { type_ = type; }
// Only NodeMarkers should manipulate the marks on nodes.
Mark mark() { return mark_; }
Mark mark() const { return mark_; }
void set_mark(Mark mark) { mark_ = mark; }
inline bool has_inline_inputs() const {
......
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