2015-05-11 08:03:03 +00:00
|
|
|
// 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_
|
|
|
|
|
2017-06-07 13:23:33 +00:00
|
|
|
#include "src/builtins/builtins.h"
|
2015-08-12 07:32:36 +00:00
|
|
|
#include "src/handles.h"
|
2017-05-29 13:24:32 +00:00
|
|
|
#include "src/objects/shared-function-info.h"
|
2015-08-12 07:32:36 +00:00
|
|
|
#include "src/utils.h"
|
2015-05-11 08:03:03 +00:00
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
2015-08-12 07:32:36 +00:00
|
|
|
|
2015-05-11 08:03:03 +00:00
|
|
|
namespace compiler {
|
|
|
|
|
2017-06-07 13:23:33 +00:00
|
|
|
class JSGraph;
|
|
|
|
class Node;
|
2018-11-02 12:52:24 +00:00
|
|
|
class SharedFunctionInfoRef;
|
2017-06-07 13:23:33 +00:00
|
|
|
|
2015-05-11 08:03:03 +00:00
|
|
|
// 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:
|
2017-06-30 12:11:44 +00:00
|
|
|
static const size_t kInvalidIndex = SIZE_MAX;
|
2015-05-11 08:03:03 +00:00
|
|
|
|
|
|
|
static OutputFrameStateCombine Ignore() {
|
2017-06-30 12:11:44 +00:00
|
|
|
return OutputFrameStateCombine(kInvalidIndex);
|
2015-05-11 08:03:03 +00:00
|
|
|
}
|
|
|
|
static OutputFrameStateCombine PokeAt(size_t index) {
|
2017-06-30 12:11:44 +00:00
|
|
|
return OutputFrameStateCombine(index);
|
2015-05-11 08:03:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t GetOffsetToPokeAt() const {
|
2017-06-30 12:11:44 +00:00
|
|
|
DCHECK_NE(parameter_, kInvalidIndex);
|
2015-05-11 08:03:03 +00:00
|
|
|
return parameter_;
|
|
|
|
}
|
|
|
|
|
2017-06-30 12:11:44 +00:00
|
|
|
bool IsOutputIgnored() const { return parameter_ == kInvalidIndex; }
|
2015-05-11 08:03:03 +00:00
|
|
|
|
2017-06-30 12:11:44 +00:00
|
|
|
size_t ConsumedOutputCount() const { return IsOutputIgnored() ? 0 : 1; }
|
2015-05-11 08:03:03 +00:00
|
|
|
|
|
|
|
bool operator==(OutputFrameStateCombine const& other) const {
|
2017-06-30 12:11:44 +00:00
|
|
|
return parameter_ == other.parameter_;
|
2015-05-11 08:03:03 +00:00
|
|
|
}
|
|
|
|
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:
|
2017-06-30 12:11:44 +00:00
|
|
|
explicit OutputFrameStateCombine(size_t parameter) : parameter_(parameter) {}
|
2015-05-11 08:03:03 +00:00
|
|
|
|
|
|
|
size_t const parameter_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// The type of stack frame that a FrameState node represents.
|
2015-06-23 07:17:07 +00:00
|
|
|
enum class FrameStateType {
|
2018-04-04 06:31:33 +00:00
|
|
|
kInterpretedFunction, // Represents an InterpretedFrame.
|
|
|
|
kArgumentsAdaptor, // Represents an ArgumentsAdaptorFrame.
|
|
|
|
kConstructStub, // Represents a ConstructStubFrame.
|
|
|
|
kBuiltinContinuation, // Represents a continuation to a stub.
|
|
|
|
kJavaScriptBuiltinContinuation, // Represents a continuation to a JavaScipt
|
|
|
|
// builtin.
|
|
|
|
kJavaScriptBuiltinContinuationWithCatch // Represents a continuation to a
|
|
|
|
// JavaScipt builtin with a catch
|
|
|
|
// handler.
|
2015-05-11 08:03:03 +00:00
|
|
|
};
|
|
|
|
|
2015-06-23 07:17:07 +00:00
|
|
|
class FrameStateFunctionInfo {
|
2015-05-11 08:03:03 +00:00
|
|
|
public:
|
2015-06-23 07:17:07 +00:00
|
|
|
FrameStateFunctionInfo(FrameStateType type, int parameter_count,
|
|
|
|
int local_count,
|
[turbofan] Remove the JSContextRelaxation reducer.
This reducer doesn't really add value, because:
(a) it is only concerned with JSCallFunction and JSToNumber, but when
we get to it, all JSCallFunction nodes will have been replaced by
Call nodes, and in the not so far future, we will also have
replaced almost all JSToNumber nodes with better code,
(b) and the reducer tries to be smart and use one of the outermost
contexts, but that might not be beneficial always; actually it
might even create longer live ranges and lead to more spilling
in some cases.
But most importantly, the JSContextRelaxation currently blocks inlining
based on SharedFunctionInfo, because it requires the inliner to check
the native context, which in turn requires JSFunction knowledge. So I'm
removing this reducer for now to unblock the more important inliner
changes.
R=jarin@chromium.org
Review URL: https://codereview.chromium.org/1715633002
Cr-Commit-Position: refs/heads/master@{#34139}
2016-02-19 07:55:26 +00:00
|
|
|
Handle<SharedFunctionInfo> shared_info)
|
2015-05-11 08:03:03 +00:00
|
|
|
: type_(type),
|
2015-06-23 07:17:07 +00:00
|
|
|
parameter_count_(parameter_count),
|
|
|
|
local_count_(local_count),
|
[turbofan] Remove the JSContextRelaxation reducer.
This reducer doesn't really add value, because:
(a) it is only concerned with JSCallFunction and JSToNumber, but when
we get to it, all JSCallFunction nodes will have been replaced by
Call nodes, and in the not so far future, we will also have
replaced almost all JSToNumber nodes with better code,
(b) and the reducer tries to be smart and use one of the outermost
contexts, but that might not be beneficial always; actually it
might even create longer live ranges and lead to more spilling
in some cases.
But most importantly, the JSContextRelaxation currently blocks inlining
based on SharedFunctionInfo, because it requires the inliner to check
the native context, which in turn requires JSFunction knowledge. So I'm
removing this reducer for now to unblock the more important inliner
changes.
R=jarin@chromium.org
Review URL: https://codereview.chromium.org/1715633002
Cr-Commit-Position: refs/heads/master@{#34139}
2016-02-19 07:55:26 +00:00
|
|
|
shared_info_(shared_info) {}
|
2015-05-11 08:03:03 +00:00
|
|
|
|
2015-06-23 07:17:07 +00:00
|
|
|
int local_count() const { return local_count_; }
|
|
|
|
int parameter_count() const { return parameter_count_; }
|
|
|
|
Handle<SharedFunctionInfo> shared_info() const { return shared_info_; }
|
2015-05-11 08:03:03 +00:00
|
|
|
FrameStateType type() const { return type_; }
|
2015-06-23 07:17:07 +00:00
|
|
|
|
2015-12-18 08:41:10 +00:00
|
|
|
static bool IsJSFunctionType(FrameStateType type) {
|
2017-06-14 11:21:43 +00:00
|
|
|
return type == FrameStateType::kInterpretedFunction ||
|
2018-04-04 06:31:33 +00:00
|
|
|
type == FrameStateType::kJavaScriptBuiltinContinuation ||
|
|
|
|
type == FrameStateType::kJavaScriptBuiltinContinuationWithCatch;
|
2015-12-18 08:41:10 +00:00
|
|
|
}
|
|
|
|
|
2015-06-23 07:17:07 +00:00
|
|
|
private:
|
|
|
|
FrameStateType const type_;
|
|
|
|
int const parameter_count_;
|
|
|
|
int const local_count_;
|
|
|
|
Handle<SharedFunctionInfo> const shared_info_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class FrameStateInfo final {
|
|
|
|
public:
|
|
|
|
FrameStateInfo(BailoutId bailout_id, OutputFrameStateCombine state_combine,
|
|
|
|
const FrameStateFunctionInfo* info)
|
|
|
|
: bailout_id_(bailout_id),
|
|
|
|
frame_state_combine_(state_combine),
|
|
|
|
info_(info) {}
|
|
|
|
|
|
|
|
FrameStateType type() const {
|
2017-06-14 11:21:43 +00:00
|
|
|
return info_ == nullptr ? FrameStateType::kInterpretedFunction
|
2015-06-23 07:17:07 +00:00
|
|
|
: info_->type();
|
|
|
|
}
|
2015-05-11 08:03:03 +00:00
|
|
|
BailoutId bailout_id() const { return bailout_id_; }
|
|
|
|
OutputFrameStateCombine state_combine() const { return frame_state_combine_; }
|
2015-06-23 07:17:07 +00:00
|
|
|
MaybeHandle<SharedFunctionInfo> shared_info() const {
|
|
|
|
return info_ == nullptr ? MaybeHandle<SharedFunctionInfo>()
|
|
|
|
: info_->shared_info();
|
|
|
|
}
|
|
|
|
int parameter_count() const {
|
|
|
|
return info_ == nullptr ? 0 : info_->parameter_count();
|
|
|
|
}
|
|
|
|
int local_count() const {
|
|
|
|
return info_ == nullptr ? 0 : info_->local_count();
|
|
|
|
}
|
|
|
|
const FrameStateFunctionInfo* function_info() const { return info_; }
|
2015-05-11 08:03:03 +00:00
|
|
|
|
|
|
|
private:
|
2015-05-15 12:17:15 +00:00
|
|
|
BailoutId const bailout_id_;
|
|
|
|
OutputFrameStateCombine const frame_state_combine_;
|
2015-06-23 07:17:07 +00:00
|
|
|
const FrameStateFunctionInfo* const info_;
|
2015-05-11 08:03:03 +00:00
|
|
|
};
|
|
|
|
|
2015-06-23 07:17:07 +00:00
|
|
|
bool operator==(FrameStateInfo const&, FrameStateInfo const&);
|
|
|
|
bool operator!=(FrameStateInfo const&, FrameStateInfo const&);
|
2015-05-11 08:03:03 +00:00
|
|
|
|
2015-06-23 07:17:07 +00:00
|
|
|
size_t hash_value(FrameStateInfo const&);
|
2015-05-11 08:03:03 +00:00
|
|
|
|
2015-06-23 07:17:07 +00:00
|
|
|
std::ostream& operator<<(std::ostream&, FrameStateInfo const&);
|
2015-05-11 08:03:03 +00:00
|
|
|
|
2015-05-20 13:42:08 +00:00
|
|
|
static const int kFrameStateParametersInput = 0;
|
|
|
|
static const int kFrameStateLocalsInput = 1;
|
|
|
|
static const int kFrameStateStackInput = 2;
|
|
|
|
static const int kFrameStateContextInput = 3;
|
|
|
|
static const int kFrameStateFunctionInput = 4;
|
|
|
|
static const int kFrameStateOuterStateInput = 5;
|
|
|
|
static const int kFrameStateInputCount = kFrameStateOuterStateInput + 1;
|
2015-05-11 08:03:03 +00:00
|
|
|
|
2018-04-04 06:31:33 +00:00
|
|
|
enum class ContinuationFrameStateMode { EAGER, LAZY, LAZY_WITH_CATCH };
|
2017-06-07 13:23:33 +00:00
|
|
|
|
2018-01-22 12:24:41 +00:00
|
|
|
Node* CreateStubBuiltinContinuationFrameState(
|
|
|
|
JSGraph* graph, Builtins::Name name, Node* context, Node* const* parameters,
|
|
|
|
int parameter_count, Node* outer_frame_state,
|
|
|
|
ContinuationFrameStateMode mode);
|
2017-06-07 13:23:33 +00:00
|
|
|
|
|
|
|
Node* CreateJavaScriptBuiltinContinuationFrameState(
|
2018-11-02 12:52:24 +00:00
|
|
|
JSGraph* graph, const SharedFunctionInfoRef& shared, Builtins::Name name,
|
2018-01-22 12:24:41 +00:00
|
|
|
Node* target, Node* context, Node* const* stack_parameters,
|
2017-06-07 13:23:33 +00:00
|
|
|
int stack_parameter_count, Node* outer_frame_state,
|
|
|
|
ContinuationFrameStateMode mode);
|
|
|
|
|
2019-05-21 07:23:02 +00:00
|
|
|
Node* CreateGenericLazyDeoptContinuationFrameState(
|
|
|
|
JSGraph* graph, const SharedFunctionInfoRef& shared, Node* target,
|
|
|
|
Node* context, Node* receiver, Node* outer_frame_state);
|
|
|
|
|
2015-05-11 08:03:03 +00:00
|
|
|
} // namespace compiler
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|
|
|
|
|
|
|
|
#endif // V8_COMPILER_FRAME_STATES_H_
|