Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Unified Diff: src/compiler/frame-states.h

Issue 1485183002: [turbofan] Deopt support for escape analysis (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@ea-local
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/compiler/frame-states.h
diff --git a/src/compiler/frame-states.h b/src/compiler/frame-states.h
index 8ab4d138d7d3fd76eedc6efbeb023254c46beb79..5f70aa76fa9a71f5e0dde085918e7db2574292b6 100644
--- a/src/compiler/frame-states.h
+++ b/src/compiler/frame-states.h
@@ -5,17 +5,28 @@
#ifndef V8_COMPILER_FRAME_STATES_H_
#define V8_COMPILER_FRAME_STATES_H_
+#include "src/compiler/machine-type.h"
#include "src/handles.h"
#include "src/utils.h"
+#include "src/zone-containers.h"
namespace v8 {
namespace internal {
// Forward declarations.
class SharedFunctionInfo;
+class Translation;
namespace compiler {
+// Forward declarations.
+class OperandGenerator;
+class CodeGenerator;
+class Node;
+class Instruction;
+class InstructionOperand;
+typedef ZoneVector<InstructionOperand> InstructionOperandVector;
+
// Flag that describes how to combine the current environment with
// the output of a node to obtain a framestate for lazy bailout.
class OutputFrameStateCombine {
@@ -164,6 +175,126 @@ static const int kFrameStateFunctionInput = 4;
static const int kFrameStateOuterStateInput = 5;
static const int kFrameStateInputCount = kFrameStateOuterStateInput + 1;
+
+enum class FrameStateInputKind { kAny, kStackSlot };
+
+
+class StateObjectCache {
+ public:
+ explicit StateObjectCache(Zone* zone) : objects_(zone) {}
+ static const size_t kNotCached = std::numeric_limits<std::size_t>::max();
+
+ size_t GetObjectId(Node* node) {
+ for (size_t i = 0; i < objects_.size(); ++i) {
+ if (objects_[i] == node) {
+ return i;
+ }
+ }
+ return kNotCached;
+ }
+
+ size_t InsertObject(Node* node) {
+ size_t id = objects_.size();
+ objects_.push_back(node);
+ return id;
+ }
+
+ private:
+ ZoneVector<Node*> objects_;
+};
+
+
+// Forward Declaration.
+class FrameStateDescriptor;
+
+
+class StateValueDescriptor {
+ public:
+ static const size_t kNoId = std::numeric_limits<std::size_t>::max();
+
+ StateValueDescriptor(Zone* zone, MachineType type, size_t id = kNoId)
+ : type_(type), id_(id), fields_(zone) {}
+
+ size_t AddOperand(InstructionOperandVector* inputs, OperandGenerator* g,
Jarin 2015/12/02 12:24:34 It is unfortunate that frame state needs to know a
sigurds 2015/12/02 16:35:13 Done.
+ StateObjectCache* cache, Node* input, MachineType type,
+ FrameStateInputKind kind, Zone* zone);
+
+ size_t Translate(CodeGenerator* gen, Translation* translation,
+ Instruction* instr, size_t frame_state_offset);
+ size_t TranslateOperand(size_t index, CodeGenerator* gen,
+ Translation* translation, Instruction* instr,
+ size_t frame_state_offset);
+
+ size_t size() { return fields_.size(); }
+
+ int IsRecursive() { return fields_.size() > 0; }
+ int IsDuplicate() { return fields_.size() == 0 && id_ != kNoId; }
Jarin 2015/12/02 12:24:34 I am wondering whether it would not be more readab
sigurds 2015/12/02 16:35:13 Great idea, thanks.
+
+ MachineType GetOperandType(size_t index) const {
+ return fields_[index].type_;
+ }
+
+
+ private:
+ MachineType type_;
+ size_t id_;
+ ZoneVector<StateValueDescriptor> fields_;
+};
+
+
+class FrameStateDescriptor : public ZoneObject {
+ public:
+ FrameStateDescriptor(Zone* zone, FrameStateType type, BailoutId bailout_id,
+ OutputFrameStateCombine state_combine,
+ size_t parameters_count, size_t locals_count,
+ size_t stack_count,
+ MaybeHandle<SharedFunctionInfo> shared_info,
+ FrameStateDescriptor* outer_state = nullptr);
+
+ FrameStateType type() const { return type_; }
+ BailoutId bailout_id() const { return bailout_id_; }
+ OutputFrameStateCombine state_combine() const { return frame_state_combine_; }
+ size_t parameters_count() const { return parameters_count_; }
+ size_t locals_count() const { return locals_count_; }
+ size_t stack_count() const { return stack_count_; }
+ MaybeHandle<SharedFunctionInfo> shared_info() const { return shared_info_; }
+ FrameStateDescriptor* outer_state() const { return outer_state_; }
+ bool HasContext() const {
+ return type_ == FrameStateType::kJavaScriptFunction;
+ }
+
+ size_t AddInputs(Node* state, OperandGenerator* g, StateObjectCache* cache,
+ InstructionOperandVector* inputs, FrameStateInputKind kind,
+ Zone* zone);
+ void TranslateOperands(CodeGenerator* gen, Instruction* instr,
+ size_t frame_state_offset,
+ OutputFrameStateCombine combine,
+ Translation* translation);
+
+ size_t GetSize(OutputFrameStateCombine combine =
+ OutputFrameStateCombine::Ignore()) const;
+ size_t GetTotalSize() const;
+ size_t GetFrameCount() const;
+ size_t GetJSFrameCount() const;
+
+ MachineType GetType(size_t index) const {
+ return values_.GetOperandType(index);
+ }
+ StateValueDescriptor* GetStateValueDescriptor() { return &values_; }
+
+ private:
+ FrameStateType type_;
+ BailoutId bailout_id_;
+ OutputFrameStateCombine frame_state_combine_;
+ size_t parameters_count_;
+ size_t locals_count_;
+ size_t stack_count_;
+ StateValueDescriptor values_;
+ MaybeHandle<SharedFunctionInfo> const shared_info_;
+ FrameStateDescriptor* outer_state_;
+};
+
+
} // namespace compiler
} // namespace internal
} // namespace v8

Powered by Google App Engine
This is Rietveld 408576698