Update V8 to version 4.1.0.21
This is a cherry-pick of all commits up to and including the
4.1.0.21 cherry-pick in Chromium.
Original commit message:
Version 4.1.0.21 (cherry-pick)
Merged 206e9136bde0f2b5ae8cb77afbb1e7833e5bd412
Unlink pages from the space page list after evacuation.
BUG=430201
LOG=N
R=jkummerow@chromium.org
Review URL: https://codereview.chromium.org/953813002
Cr-Commit-Position: refs/branch-heads/4.1@{#22}
Cr-Branched-From: 2e08d2a7aa9d65d269d8c57aba82eb38a8cb0a18-refs/heads/candidates@{#25353}
---
FPIIM-449
Change-Id: I8c23c7bbb70772b4858fe8a47b64fa97ee0d1f8c
diff --git a/src/compiler/operator.h b/src/compiler/operator.h
index 5137806..fb144ce 100644
--- a/src/compiler/operator.h
+++ b/src/compiler/operator.h
@@ -5,9 +5,11 @@
#ifndef V8_COMPILER_OPERATOR_H_
#define V8_COMPILER_OPERATOR_H_
+#include <ostream> // NOLINT(readability/streams)
+
#include "src/base/flags.h"
-#include "src/ostreams.h"
-#include "src/unique.h"
+#include "src/base/functional.h"
+#include "src/zone.h"
namespace v8 {
namespace internal {
@@ -47,9 +49,12 @@
};
typedef base::Flags<Property, uint8_t> Properties;
- Operator(Opcode opcode, Properties properties, const char* mnemonic)
- : opcode_(opcode), properties_(properties), mnemonic_(mnemonic) {}
- virtual ~Operator();
+ // Constructor.
+ Operator(Opcode opcode, Properties properties, const char* mnemonic,
+ size_t value_in, size_t effect_in, size_t control_in,
+ size_t value_out, size_t effect_out, size_t control_out);
+
+ virtual ~Operator() {}
// A small integer unique to all instances of a particular kind of operator,
// useful for quick matching for specific kinds of operators. For fast access
@@ -63,196 +68,122 @@
// Check if this operator equals another operator. Equivalent operators can
// be merged, and nodes with equivalent operators and equivalent inputs
// can be merged.
- virtual bool Equals(const Operator* other) const = 0;
+ virtual bool Equals(const Operator* that) const {
+ return this->opcode() == that->opcode();
+ }
// Compute a hashcode to speed up equivalence-set checking.
// Equal operators should always have equal hashcodes, and unequal operators
// should have unequal hashcodes with high probability.
- virtual int HashCode() const = 0;
+ virtual size_t HashCode() const { return base::hash<Opcode>()(opcode()); }
// Check whether this operator has the given property.
bool HasProperty(Property property) const {
return (properties() & property) == property;
}
- // Number of data inputs to the operator, for verifying graph structure.
- virtual int InputCount() const = 0;
-
- // Number of data outputs from the operator, for verifying graph structure.
- virtual int OutputCount() const = 0;
-
Properties properties() const { return properties_; }
+ // TODO(titzer): convert return values here to size_t.
+ int ValueInputCount() const { return value_in_; }
+ int EffectInputCount() const { return effect_in_; }
+ int ControlInputCount() const { return control_in_; }
+
+ int ValueOutputCount() const { return value_out_; }
+ int EffectOutputCount() const { return effect_out_; }
+ int ControlOutputCount() const { return control_out_; }
+
+ static inline size_t ZeroIfPure(Properties properties) {
+ return (properties & kPure) == kPure ? 0 : 1;
+ }
+
// TODO(titzer): API for input and output types, for typechecking graph.
protected:
// Print the full operator into the given stream, including any
// static parameters. Useful for debugging and visualizing the IR.
- virtual OStream& PrintTo(OStream& os) const = 0; // NOLINT
- friend OStream& operator<<(OStream& os, const Operator& op);
+ virtual void PrintTo(std::ostream& os) const;
+ friend std::ostream& operator<<(std::ostream& os, const Operator& op);
private:
Opcode opcode_;
Properties properties_;
const char* mnemonic_;
+ uint32_t value_in_;
+ uint16_t effect_in_;
+ uint16_t control_in_;
+ uint16_t value_out_;
+ uint8_t effect_out_;
+ uint8_t control_out_;
DISALLOW_COPY_AND_ASSIGN(Operator);
};
DEFINE_OPERATORS_FOR_FLAGS(Operator::Properties)
-OStream& operator<<(OStream& os, const Operator& op);
+std::ostream& operator<<(std::ostream& os, const Operator& op);
-// An implementation of Operator that has no static parameters. Such operators
-// have just a name, an opcode, and a fixed number of inputs and outputs.
-// They can represented by singletons and shared globally.
-class SimpleOperator : public Operator {
- public:
- SimpleOperator(Opcode opcode, Properties properties, int input_count,
- int output_count, const char* mnemonic);
- ~SimpleOperator();
-
- virtual bool Equals(const Operator* that) const FINAL {
- return opcode() == that->opcode();
- }
- virtual int HashCode() const FINAL { return opcode(); }
- virtual int InputCount() const FINAL { return input_count_; }
- virtual int OutputCount() const FINAL { return output_count_; }
-
- private:
- virtual OStream& PrintTo(OStream& os) const FINAL { // NOLINT
- return os << mnemonic();
- }
-
- int input_count_;
- int output_count_;
-
- DISALLOW_COPY_AND_ASSIGN(SimpleOperator);
-};
-
-// Template specialization implements a kind of type class for dealing with the
-// static parameters of Operator1 automatically.
-template <typename T>
-struct StaticParameterTraits {
- static OStream& PrintTo(OStream& os, T val) { // NOLINT
- return os << "??";
- }
- static int HashCode(T a) { return 0; }
- static bool Equals(T a, T b) {
- return false; // Not every T has a ==. By default, be conservative.
- }
-};
-
-// Specialization for static parameters of type {int}.
-template <>
-struct StaticParameterTraits<int> {
- static OStream& PrintTo(OStream& os, int val) { // NOLINT
- return os << val;
- }
- static int HashCode(int a) { return a; }
- static bool Equals(int a, int b) { return a == b; }
-};
-
-// Specialization for static parameters of type {double}.
-template <>
-struct StaticParameterTraits<double> {
- static OStream& PrintTo(OStream& os, double val) { // NOLINT
- return os << val;
- }
- static int HashCode(double a) {
- return static_cast<int>(bit_cast<int64_t>(a));
- }
- static bool Equals(double a, double b) {
- return bit_cast<int64_t>(a) == bit_cast<int64_t>(b);
- }
-};
-
-// Specialization for static parameters of type {Unique<Object>}.
-template <>
-struct StaticParameterTraits<Unique<Object> > {
- static OStream& PrintTo(OStream& os, Unique<Object> val) { // NOLINT
- return os << Brief(*val.handle());
- }
- static int HashCode(Unique<Object> a) {
- return static_cast<int>(a.Hashcode());
- }
- static bool Equals(Unique<Object> a, Unique<Object> b) { return a == b; }
-};
-
-// Specialization for static parameters of type {Unique<Name>}.
-template <>
-struct StaticParameterTraits<Unique<Name> > {
- static OStream& PrintTo(OStream& os, Unique<Name> val) { // NOLINT
- return os << Brief(*val.handle());
- }
- static int HashCode(Unique<Name> a) { return static_cast<int>(a.Hashcode()); }
- static bool Equals(Unique<Name> a, Unique<Name> b) { return a == b; }
-};
-
-#if DEBUG
-// Specialization for static parameters of type {Handle<Object>} to prevent any
-// direct usage of Handles in constants.
-template <>
-struct StaticParameterTraits<Handle<Object> > {
- static OStream& PrintTo(OStream& os, Handle<Object> val) { // NOLINT
- UNREACHABLE(); // Should use Unique<Object> instead
- return os;
- }
- static int HashCode(Handle<Object> a) {
- UNREACHABLE(); // Should use Unique<Object> instead
- return 0;
- }
- static bool Equals(Handle<Object> a, Handle<Object> b) {
- UNREACHABLE(); // Should use Unique<Object> instead
- return false;
- }
-};
-#endif
// A templatized implementation of Operator that has one static parameter of
-// type {T}. If a specialization of StaticParameterTraits<{T}> exists, then
-// operators of this kind can automatically be hashed, compared, and printed.
-template <typename T>
+// type {T}.
+template <typename T, typename Pred = std::equal_to<T>,
+ typename Hash = base::hash<T>>
class Operator1 : public Operator {
public:
- Operator1(Opcode opcode, Properties properties, int input_count,
- int output_count, const char* mnemonic, T parameter)
- : Operator(opcode, properties, mnemonic),
- input_count_(input_count),
- output_count_(output_count),
- parameter_(parameter) {}
+ Operator1(Opcode opcode, Properties properties, const char* mnemonic,
+ size_t value_in, size_t effect_in, size_t control_in,
+ size_t value_out, size_t effect_out, size_t control_out,
+ T parameter, Pred const& pred = Pred(), Hash const& hash = Hash())
+ : Operator(opcode, properties, mnemonic, value_in, effect_in, control_in,
+ value_out, effect_out, control_out),
+ parameter_(parameter),
+ pred_(pred),
+ hash_(hash) {}
- const T& parameter() const { return parameter_; }
+ T const& parameter() const { return parameter_; }
- virtual bool Equals(const Operator* other) const OVERRIDE {
+ bool Equals(const Operator* other) const FINAL {
if (opcode() != other->opcode()) return false;
const Operator1<T>* that = static_cast<const Operator1<T>*>(other);
- return StaticParameterTraits<T>::Equals(this->parameter_, that->parameter_);
+ return this->pred_(this->parameter(), that->parameter());
}
- virtual int HashCode() const OVERRIDE {
- return opcode() + 33 * StaticParameterTraits<T>::HashCode(this->parameter_);
+ size_t HashCode() const FINAL {
+ return base::hash_combine(this->opcode(), this->hash_(this->parameter()));
}
- virtual int InputCount() const OVERRIDE { return input_count_; }
- virtual int OutputCount() const OVERRIDE { return output_count_; }
- virtual OStream& PrintParameter(OStream& os) const { // NOLINT
- return StaticParameterTraits<T>::PrintTo(os << "[", parameter_) << "]";
+ virtual void PrintParameter(std::ostream& os) const {
+ os << "[" << this->parameter() << "]";
}
protected:
- virtual OStream& PrintTo(OStream& os) const FINAL { // NOLINT
- return PrintParameter(os << mnemonic());
+ void PrintTo(std::ostream& os) const FINAL {
+ os << mnemonic();
+ PrintParameter(os);
}
private:
- int input_count_;
- int output_count_;
- T parameter_;
+ T const parameter_;
+ Pred const pred_;
+ Hash const hash_;
};
// Helper to extract parameters from Operator1<*> operator.
template <typename T>
-static inline const T& OpParameter(const Operator* op) {
- return reinterpret_cast<const Operator1<T>*>(op)->parameter();
+inline T const& OpParameter(const Operator* op) {
+ return static_cast<const Operator1<T>*>(op)->parameter();
+}
+
+// NOTE: We have to be careful to use the right equal/hash functions below, for
+// float/double we always use the ones operating on the bit level.
+template <>
+inline float const& OpParameter(const Operator* op) {
+ return static_cast<const Operator1<float, base::bit_equal_to<float>,
+ base::bit_hash<float>>*>(op)->parameter();
+}
+
+template <>
+inline double const& OpParameter(const Operator* op) {
+ return static_cast<const Operator1<double, base::bit_equal_to<double>,
+ base::bit_hash<double>>*>(op)->parameter();
}
} // namespace compiler