Commit 256ae736 authored by titzer's avatar titzer Committed by Commit bot

[turbofan] Extract frame-states.h from common-operator.h

R=jarin@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1131853002

Cr-Commit-Position: refs/heads/master@{#28330}
parent 0baf6739
......@@ -623,6 +623,8 @@ source_set("v8_base") {
"src/compiler/frame.h",
"src/compiler/frame-elider.cc",
"src/compiler/frame-elider.h",
"src/compiler/frame-states.cc",
"src/compiler/frame-states.h",
"src/compiler/gap-resolver.cc",
"src/compiler/gap-resolver.h",
"src/compiler/graph-builder.h",
......
......@@ -62,47 +62,6 @@ SelectParameters const& SelectParametersOf(const Operator* const op) {
}
size_t hash_value(OutputFrameStateCombine const& sc) {
return base::hash_combine(sc.kind_, sc.parameter_);
}
std::ostream& operator<<(std::ostream& os, OutputFrameStateCombine const& sc) {
switch (sc.kind_) {
case OutputFrameStateCombine::kPushOutput:
if (sc.parameter_ == 0) return os << "Ignore";
return os << "Push(" << sc.parameter_ << ")";
case OutputFrameStateCombine::kPokeAt:
return os << "PokeAt(" << sc.parameter_ << ")";
}
UNREACHABLE();
return os;
}
bool operator==(FrameStateCallInfo const& lhs, FrameStateCallInfo const& rhs) {
return lhs.type() == rhs.type() && lhs.bailout_id() == rhs.bailout_id() &&
lhs.state_combine() == rhs.state_combine();
}
bool operator!=(FrameStateCallInfo const& lhs, FrameStateCallInfo const& rhs) {
return !(lhs == rhs);
}
size_t hash_value(FrameStateCallInfo const& info) {
return base::hash_combine(info.type(), info.bailout_id(),
info.state_combine());
}
std::ostream& operator<<(std::ostream& os, FrameStateCallInfo const& info) {
return os << info.type() << ", " << info.bailout_id() << ", "
<< info.state_combine();
}
size_t ProjectionIndexOf(const Operator* const op) {
DCHECK_EQ(IrOpcode::kProjection, op->opcode());
return OpParameter<size_t>(op);
......
// Copyright 2013 the V8 project authors. All rights reserved.
// 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_COMMON_OPERATOR_H_
#define V8_COMPILER_COMMON_OPERATOR_H_
#include "src/compiler/frame-states.h"
#include "src/compiler/machine-type.h"
#include "src/unique.h"
......@@ -57,102 +58,6 @@ std::ostream& operator<<(std::ostream&, SelectParameters const& p);
SelectParameters const& SelectParametersOf(const Operator* const);
// Flag that describes how to combine the current environment with
// the output of a node to obtain a framestate for lazy bailout.
class OutputFrameStateCombine {
public:
enum Kind {
kPushOutput, // Push the output on the expression stack.
kPokeAt // Poke at the given environment location,
// counting from the top of the stack.
};
static OutputFrameStateCombine Ignore() {
return OutputFrameStateCombine(kPushOutput, 0);
}
static OutputFrameStateCombine Push(size_t count = 1) {
return OutputFrameStateCombine(kPushOutput, count);
}
static OutputFrameStateCombine PokeAt(size_t index) {
return OutputFrameStateCombine(kPokeAt, index);
}
Kind kind() const { return kind_; }
size_t GetPushCount() const {
DCHECK_EQ(kPushOutput, kind());
return parameter_;
}
size_t GetOffsetToPokeAt() const {
DCHECK_EQ(kPokeAt, kind());
return parameter_;
}
bool IsOutputIgnored() const {
return kind_ == kPushOutput && parameter_ == 0;
}
size_t ConsumedOutputCount() const {
return kind_ == kPushOutput ? GetPushCount() : 1;
}
bool operator==(OutputFrameStateCombine const& other) const {
return kind_ == other.kind_ && parameter_ == other.parameter_;
}
bool operator!=(OutputFrameStateCombine const& other) const {
return !(*this == other);
}
friend size_t hash_value(OutputFrameStateCombine const&);
friend std::ostream& operator<<(std::ostream&,
OutputFrameStateCombine const&);
private:
OutputFrameStateCombine(Kind kind, size_t parameter)
: kind_(kind), parameter_(parameter) {}
Kind const kind_;
size_t const parameter_;
};
// The type of stack frame that a FrameState node represents.
enum FrameStateType {
JS_FRAME, // Represents an unoptimized JavaScriptFrame.
ARGUMENTS_ADAPTOR // Represents an ArgumentsAdaptorFrame.
};
class FrameStateCallInfo final {
public:
FrameStateCallInfo(
FrameStateType type, BailoutId bailout_id,
OutputFrameStateCombine state_combine,
MaybeHandle<JSFunction> jsfunction = MaybeHandle<JSFunction>())
: type_(type),
bailout_id_(bailout_id),
frame_state_combine_(state_combine),
jsfunction_(jsfunction) {}
FrameStateType type() const { return type_; }
BailoutId bailout_id() const { return bailout_id_; }
OutputFrameStateCombine state_combine() const { return frame_state_combine_; }
MaybeHandle<JSFunction> jsfunction() const { return jsfunction_; }
private:
FrameStateType type_;
BailoutId bailout_id_;
OutputFrameStateCombine frame_state_combine_;
MaybeHandle<JSFunction> jsfunction_;
};
bool operator==(FrameStateCallInfo const&, FrameStateCallInfo const&);
bool operator!=(FrameStateCallInfo const&, FrameStateCallInfo const&);
size_t hash_value(FrameStateCallInfo const&);
std::ostream& operator<<(std::ostream&, FrameStateCallInfo const&);
size_t ProjectionIndexOf(const Operator* const);
......
// Copyright 2015 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 "src/base/functional.h"
#include "src/compiler/frame-states.h"
namespace v8 {
namespace internal {
namespace compiler {
size_t hash_value(OutputFrameStateCombine const& sc) {
return base::hash_combine(sc.kind_, sc.parameter_);
}
std::ostream& operator<<(std::ostream& os, OutputFrameStateCombine const& sc) {
switch (sc.kind_) {
case OutputFrameStateCombine::kPushOutput:
if (sc.parameter_ == 0) return os << "Ignore";
return os << "Push(" << sc.parameter_ << ")";
case OutputFrameStateCombine::kPokeAt:
return os << "PokeAt(" << sc.parameter_ << ")";
}
UNREACHABLE();
return os;
}
bool operator==(FrameStateCallInfo const& lhs, FrameStateCallInfo const& rhs) {
return lhs.type() == rhs.type() && lhs.bailout_id() == rhs.bailout_id() &&
lhs.state_combine() == rhs.state_combine();
}
bool operator!=(FrameStateCallInfo const& lhs, FrameStateCallInfo const& rhs) {
return !(lhs == rhs);
}
size_t hash_value(FrameStateCallInfo const& info) {
return base::hash_combine(info.type(), info.bailout_id(),
info.state_combine());
}
std::ostream& operator<<(std::ostream& os, FrameStateCallInfo const& info) {
return os << info.type() << ", " << info.bailout_id() << ", "
<< info.state_combine();
}
}
}
}
// Copyright 2015 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_FRAME_STATES_H_
#define V8_COMPILER_FRAME_STATES_H_
#include "src/handles-inl.h" // TODO(everyone): Fix our inl.h crap
#include "src/objects-inl.h" // TODO(everyone): Fix our inl.h crap
#include "src/utils.h"
namespace v8 {
namespace internal {
namespace compiler {
// Flag that describes how to combine the current environment with
// the output of a node to obtain a framestate for lazy bailout.
class OutputFrameStateCombine {
public:
enum Kind {
kPushOutput, // Push the output on the expression stack.
kPokeAt // Poke at the given environment location,
// counting from the top of the stack.
};
static OutputFrameStateCombine Ignore() {
return OutputFrameStateCombine(kPushOutput, 0);
}
static OutputFrameStateCombine Push(size_t count = 1) {
return OutputFrameStateCombine(kPushOutput, count);
}
static OutputFrameStateCombine PokeAt(size_t index) {
return OutputFrameStateCombine(kPokeAt, index);
}
Kind kind() const { return kind_; }
size_t GetPushCount() const {
DCHECK_EQ(kPushOutput, kind());
return parameter_;
}
size_t GetOffsetToPokeAt() const {
DCHECK_EQ(kPokeAt, kind());
return parameter_;
}
bool IsOutputIgnored() const {
return kind_ == kPushOutput && parameter_ == 0;
}
size_t ConsumedOutputCount() const {
return kind_ == kPushOutput ? GetPushCount() : 1;
}
bool operator==(OutputFrameStateCombine const& other) const {
return kind_ == other.kind_ && parameter_ == other.parameter_;
}
bool operator!=(OutputFrameStateCombine const& other) const {
return !(*this == other);
}
friend size_t hash_value(OutputFrameStateCombine const&);
friend std::ostream& operator<<(std::ostream&,
OutputFrameStateCombine const&);
private:
OutputFrameStateCombine(Kind kind, size_t parameter)
: kind_(kind), parameter_(parameter) {}
Kind const kind_;
size_t const parameter_;
};
// The type of stack frame that a FrameState node represents.
enum FrameStateType {
JS_FRAME, // Represents an unoptimized JavaScriptFrame.
ARGUMENTS_ADAPTOR // Represents an ArgumentsAdaptorFrame.
};
class FrameStateCallInfo final {
public:
FrameStateCallInfo(
FrameStateType type, BailoutId bailout_id,
OutputFrameStateCombine state_combine,
MaybeHandle<JSFunction> jsfunction = MaybeHandle<JSFunction>())
: type_(type),
bailout_id_(bailout_id),
frame_state_combine_(state_combine),
jsfunction_(jsfunction) {}
FrameStateType type() const { return type_; }
BailoutId bailout_id() const { return bailout_id_; }
OutputFrameStateCombine state_combine() const { return frame_state_combine_; }
MaybeHandle<JSFunction> jsfunction() const { return jsfunction_; }
private:
FrameStateType type_;
BailoutId bailout_id_;
OutputFrameStateCombine frame_state_combine_;
MaybeHandle<JSFunction> jsfunction_;
};
bool operator==(FrameStateCallInfo const&, FrameStateCallInfo const&);
bool operator!=(FrameStateCallInfo const&, FrameStateCallInfo const&);
size_t hash_value(FrameStateCallInfo const&);
std::ostream& operator<<(std::ostream&, FrameStateCallInfo const&);
} // namespace compiler
} // namespace internal
} // namespace v8
#endif // V8_COMPILER_FRAME_STATES_H_
......@@ -462,6 +462,8 @@
'../../src/compiler/frame.h',
'../../src/compiler/frame-elider.cc',
'../../src/compiler/frame-elider.h',
"../../src/compiler/frame-states.cc",
"../../src/compiler/frame-states.h",
'../../src/compiler/gap-resolver.cc',
'../../src/compiler/gap-resolver.h',
'../../src/compiler/graph-builder.h',
......
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