Commit d91e8d8f authored by Jakob Gruber's avatar Jakob Gruber Committed by Commit Bot

[compiler] Hook in unary op builtins with feedback in generic lowering

If --turbo-nci is enabled, use unary op builtins with feedback
collection during generic lowering.

Bug: v8:8888
Change-Id: Ie32cfe1558a7fbada2ac69a99ef969097558bc89
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2209067
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67962}
parent c8e3cbbe
......@@ -2810,19 +2810,27 @@ SpeculationMode BytecodeGraphBuilder::GetSpeculationMode(int slot_id) const {
}
void BytecodeGraphBuilder::VisitBitwiseNot() {
BuildUnaryOp(javascript()->BitwiseNot());
FeedbackSource feedback = CreateFeedbackSource(
bytecode_iterator().GetSlotOperand(kUnaryOperationHintIndex).ToInt());
BuildUnaryOp(javascript()->BitwiseNot(feedback));
}
void BytecodeGraphBuilder::VisitDec() {
BuildUnaryOp(javascript()->Decrement());
FeedbackSource feedback = CreateFeedbackSource(
bytecode_iterator().GetSlotOperand(kUnaryOperationHintIndex).ToInt());
BuildUnaryOp(javascript()->Decrement(feedback));
}
void BytecodeGraphBuilder::VisitInc() {
BuildUnaryOp(javascript()->Increment());
FeedbackSource feedback = CreateFeedbackSource(
bytecode_iterator().GetSlotOperand(kUnaryOperationHintIndex).ToInt());
BuildUnaryOp(javascript()->Increment(feedback));
}
void BytecodeGraphBuilder::VisitNegate() {
BuildUnaryOp(javascript()->Negate());
FeedbackSource feedback = CreateFeedbackSource(
bytecode_iterator().GetSlotOperand(kUnaryOperationHintIndex).ToInt());
BuildUnaryOp(javascript()->Negate(feedback));
}
void BytecodeGraphBuilder::VisitAdd() {
......
......@@ -6,11 +6,22 @@
#define V8_COMPILER_GLOBALS_H_
#include "src/common/globals.h"
#include "src/flags/flags.h"
namespace v8 {
namespace internal {
namespace compiler {
// The nci flag is currently used to experiment with feedback collection in
// optimized code produced by generic lowering.
// Considerations:
// - Should we increment the call count? https://crbug.com/v8/10524
// - Is feedback already megamorphic in all these cases?
//
// TODO(jgruber): Remove once we've made a decision whether to collect feedback
// unconditionally.
inline bool CollectFeedbackInGenericLowering() { return FLAG_turbo_nci; }
enum class StackCheckKind {
kJSFunctionEntry = 0,
kJSIterationBody,
......
This diff is collapsed.
......@@ -42,6 +42,10 @@ class JSGenericLowering final : public AdvancedReducer {
Operator::Properties properties);
void ReplaceWithRuntimeCall(Node* node, Runtime::FunctionId f, int args = -1);
void ReplaceUnaryOpWithBuiltinCall(Node* node,
Builtins::Name builtin_without_feedback,
Builtins::Name builtin_with_feedback);
Zone* zone() const;
Isolate* isolate() const;
JSGraph* jsgraph() const { return jsgraph_; }
......
......@@ -226,8 +226,12 @@ std::ostream& operator<<(std::ostream& os, FeedbackParameter const& p) {
}
FeedbackParameter const& FeedbackParameterOf(const Operator* op) {
DCHECK(op->opcode() == IrOpcode::kJSCreateEmptyLiteralArray ||
DCHECK(op->opcode() == IrOpcode::kJSDecrement ||
op->opcode() == IrOpcode::kJSBitwiseNot ||
op->opcode() == IrOpcode::kJSCreateEmptyLiteralArray ||
op->opcode() == IrOpcode::kJSIncrement ||
op->opcode() == IrOpcode::kJSInstanceOf ||
op->opcode() == IrOpcode::kJSNegate ||
op->opcode() == IrOpcode::kJSStoreDataPropertyInLiteral ||
op->opcode() == IrOpcode::kJSStoreInArrayLiteral);
return OpParameter<FeedbackParameter>(op);
......@@ -659,10 +663,6 @@ CompareOperationHint CompareOperationHintOf(const Operator* op) {
V(Divide, Operator::kNoProperties, 2, 1) \
V(Modulus, Operator::kNoProperties, 2, 1) \
V(Exponentiate, Operator::kNoProperties, 2, 1) \
V(BitwiseNot, Operator::kNoProperties, 1, 1) \
V(Decrement, Operator::kNoProperties, 1, 1) \
V(Increment, Operator::kNoProperties, 1, 1) \
V(Negate, Operator::kNoProperties, 1, 1) \
V(ToLength, Operator::kNoProperties, 1, 1) \
V(ToName, Operator::kNoProperties, 1, 1) \
V(ToNumber, Operator::kNoProperties, 1, 1) \
......@@ -699,6 +699,12 @@ CompareOperationHint CompareOperationHintOf(const Operator* op) {
V(ParseInt, Operator::kNoProperties, 2, 1) \
V(RegExpTest, Operator::kNoProperties, 2, 1)
#define UNARY_OP_LIST(V) \
V(BitwiseNot) \
V(Decrement) \
V(Increment) \
V(Negate)
#define BINARY_OP_LIST(V) V(Add)
#define COMPARE_OP_LIST(V) \
......@@ -815,6 +821,16 @@ CACHED_OP_LIST(CACHED_OP)
BINARY_OP_LIST(BINARY_OP)
#undef BINARY_OP
#define UNARY_OP(Name) \
const Operator* JSOperatorBuilder::Name(FeedbackSource const& feedback) { \
FeedbackParameter parameters(feedback); \
return new (zone()) Operator1<FeedbackParameter>( \
IrOpcode::kJS##Name, Operator::kNoProperties, "JS" #Name, 1, 1, 1, 1, \
1, 2, parameters); \
}
UNARY_OP_LIST(UNARY_OP)
#undef UNARY_OP
#define COMPARE_OP(Name, ...) \
const Operator* JSOperatorBuilder::Name(CompareOperationHint hint) { \
switch (hint) { \
......@@ -1418,6 +1434,7 @@ Handle<ScopeInfo> ScopeInfoOf(const Operator* op) {
return OpParameter<Handle<ScopeInfo>>(op);
}
#undef UNARY_OP_LIST
#undef BINARY_OP_LIST
#undef CACHED_OP_LIST
#undef COMPARE_OP_LIST
......
......@@ -771,10 +771,10 @@ class V8_EXPORT_PRIVATE JSOperatorBuilder final
const Operator* Modulus();
const Operator* Exponentiate();
const Operator* BitwiseNot();
const Operator* Decrement();
const Operator* Increment();
const Operator* Negate();
const Operator* BitwiseNot(FeedbackSource const& feedback);
const Operator* Decrement(FeedbackSource const& feedback);
const Operator* Increment(FeedbackSource const& feedback);
const Operator* Negate(FeedbackSource const& feedback);
const Operator* ToLength();
const Operator* ToName();
......
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