[bigint] Output ToNumber bytecode for unary plus
As part of that change, make ToNumber return in the accumulator. Bug: v8:6791 Change-Id: I8ce0f4fbc7ad8ee7fb4a32a8a499394395010750 Reviewed-on: https://chromium-review.googlesource.com/658082 Reviewed-by: Ross McIlroy <rmcilroy@chromium.org> Reviewed-by: Georg Neis <neis@chromium.org> Commit-Queue: Adam Klein <adamk@chromium.org> Cr-Commit-Position: refs/heads/master@{#47976}
This commit is contained in:
parent
53add533de
commit
bf55951cdd
@ -2438,7 +2438,7 @@ void BytecodeGraphBuilder::VisitToNumber() {
|
||||
Node* object = environment()->LookupAccumulator();
|
||||
|
||||
FeedbackSlot slot =
|
||||
feedback_vector()->ToSlot(bytecode_iterator().GetIndexOperand(1));
|
||||
feedback_vector()->ToSlot(bytecode_iterator().GetIndexOperand(0));
|
||||
JSTypeHintLowering::LoweringResult lowering =
|
||||
TryBuildSimplifiedToNumber(object, slot);
|
||||
|
||||
@ -2450,8 +2450,7 @@ void BytecodeGraphBuilder::VisitToNumber() {
|
||||
node = NewNode(javascript()->ToNumber(), object);
|
||||
}
|
||||
|
||||
environment()->BindRegister(bytecode_iterator().GetRegisterOperand(0), node,
|
||||
Environment::kAttachFrameState);
|
||||
environment()->BindAccumulator(node, Environment::kAttachFrameState);
|
||||
}
|
||||
|
||||
void BytecodeGraphBuilder::VisitJump() { BuildJump(); }
|
||||
|
@ -994,9 +994,8 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::ToName(Register out) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
BytecodeArrayBuilder& BytecodeArrayBuilder::ToNumber(Register out,
|
||||
int feedback_slot) {
|
||||
OutputToNumber(out, feedback_slot);
|
||||
BytecodeArrayBuilder& BytecodeArrayBuilder::ToNumber(int feedback_slot) {
|
||||
OutputToNumber(feedback_slot);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -353,7 +353,9 @@ class V8_EXPORT_PRIVATE BytecodeArrayBuilder final
|
||||
// Converts accumulator and stores result in register |out|.
|
||||
BytecodeArrayBuilder& ToObject(Register out);
|
||||
BytecodeArrayBuilder& ToName(Register out);
|
||||
BytecodeArrayBuilder& ToNumber(Register out, int feedback_slot);
|
||||
|
||||
// Converts accumulator and stores result back in accumulator.
|
||||
BytecodeArrayBuilder& ToNumber(int feedback_slot);
|
||||
|
||||
// Flow Control.
|
||||
BytecodeArrayBuilder& Bind(BytecodeLabel* label);
|
||||
|
@ -3429,6 +3429,12 @@ void BytecodeGenerator::VisitNot(UnaryOperation* expr) {
|
||||
}
|
||||
}
|
||||
|
||||
void BytecodeGenerator::VisitPlus(UnaryOperation* expr) {
|
||||
VisitForAccumulatorValue(expr->expression());
|
||||
builder()->SetExpressionPosition(expr);
|
||||
builder()->ToNumber(feedback_index(expr->UnaryOperationFeedbackSlot()));
|
||||
}
|
||||
|
||||
void BytecodeGenerator::BuildBinaryOperationForUnaryOperation(
|
||||
UnaryOperation* expr, Token::Value binop, int rhs) {
|
||||
VisitForAccumulatorValue(expr->expression());
|
||||
@ -3452,11 +3458,11 @@ void BytecodeGenerator::VisitUnaryOperation(UnaryOperation* expr) {
|
||||
case Token::Value::DELETE:
|
||||
VisitDelete(expr);
|
||||
break;
|
||||
// TODO(adamk): Output specific bytecodes for ADD, SUB, and BIT_NOT
|
||||
// instead of transforming them to binary operations.
|
||||
case Token::Value::ADD:
|
||||
BuildBinaryOperationForUnaryOperation(expr, Token::Value::MUL, 1);
|
||||
VisitPlus(expr);
|
||||
break;
|
||||
// TODO(adamk): Output specific bytecodes for SUB and BIT_NOT
|
||||
// instead of transforming them to binary operations.
|
||||
case Token::Value::SUB:
|
||||
BuildBinaryOperationForUnaryOperation(expr, Token::Value::MUL, -1);
|
||||
break;
|
||||
@ -3588,13 +3594,13 @@ void BytecodeGenerator::VisitCountOperation(CountOperation* expr) {
|
||||
// Save result for postfix expressions.
|
||||
FeedbackSlot count_slot = expr->CountBinaryOpFeedbackSlot();
|
||||
if (is_postfix) {
|
||||
// Convert old value into a number before saving it.
|
||||
old_value = register_allocator()->NewRegister();
|
||||
// Convert old value into a number before saving it.
|
||||
// TODO(ignition): Think about adding proper PostInc/PostDec bytecodes
|
||||
// instead of this ToNumber + Inc/Dec dance.
|
||||
builder()
|
||||
->ToNumber(old_value, feedback_index(count_slot))
|
||||
.LoadAccumulatorWithRegister(old_value);
|
||||
->ToNumber(feedback_index(count_slot))
|
||||
.StoreAccumulatorInRegister(old_value);
|
||||
}
|
||||
|
||||
// Perform +1/-1 operation.
|
||||
|
@ -78,6 +78,7 @@ class BytecodeGenerator final : public AstVisitor<BytecodeGenerator> {
|
||||
void VisitTypeOf(UnaryOperation* expr);
|
||||
void VisitNot(UnaryOperation* expr);
|
||||
void VisitDelete(UnaryOperation* expr);
|
||||
void VisitPlus(UnaryOperation* expr);
|
||||
|
||||
// Visits a typeof expression for the value on which to perform the typeof.
|
||||
void VisitForTypeOfValue(Expression* expr);
|
||||
|
@ -215,7 +215,7 @@ namespace interpreter {
|
||||
\
|
||||
/* Cast operators */ \
|
||||
V(ToName, AccumulatorUse::kRead, OperandType::kRegOut) \
|
||||
V(ToNumber, AccumulatorUse::kRead, OperandType::kRegOut, OperandType::kIdx) \
|
||||
V(ToNumber, AccumulatorUse::kReadWrite, OperandType::kIdx) \
|
||||
V(ToObject, AccumulatorUse::kRead, OperandType::kRegOut) \
|
||||
\
|
||||
/* Literals */ \
|
||||
|
@ -1225,7 +1225,7 @@ IGNITION_HANDLER(ToName, InterpreterAssembler) {
|
||||
Dispatch();
|
||||
}
|
||||
|
||||
// ToNumber <dst> <slot>
|
||||
// ToNumber <slot>
|
||||
//
|
||||
// Convert the object referenced by the accumulator to a number.
|
||||
IGNITION_HANDLER(ToNumber, InterpreterAssembler) {
|
||||
@ -1264,13 +1264,13 @@ IGNITION_HANDLER(ToNumber, InterpreterAssembler) {
|
||||
}
|
||||
|
||||
BIND(&if_done);
|
||||
StoreRegister(var_result.value(), BytecodeOperandReg(0));
|
||||
|
||||
// Record the type feedback collected for {object}.
|
||||
Node* slot_index = BytecodeOperandIdx(1);
|
||||
Node* slot_index = BytecodeOperandIdx(0);
|
||||
Node* feedback_vector = LoadFeedbackVector();
|
||||
UpdateFeedback(var_type_feedback.value(), feedback_vector, slot_index);
|
||||
|
||||
SetAccumulator(var_result.value());
|
||||
Dispatch();
|
||||
}
|
||||
|
||||
|
@ -238,7 +238,7 @@ snippet: "
|
||||
"
|
||||
frame size: 3
|
||||
parameter count: 1
|
||||
bytecode array length: 44
|
||||
bytecode array length: 43
|
||||
bytecodes: [
|
||||
/* 30 E> */ B(StackCheck),
|
||||
/* 42 S> */ B(LdaSmi), I8(17),
|
||||
@ -249,8 +249,8 @@ bytecodes: [
|
||||
/* 55 E> */ B(Add), R(1), U8(0),
|
||||
B(Star), R(1),
|
||||
B(Ldar), R(0),
|
||||
B(ToNumber), R(2), U8(1),
|
||||
B(Ldar), R(2),
|
||||
B(ToNumber), U8(1),
|
||||
B(Star), R(2),
|
||||
B(Inc), U8(1),
|
||||
B(Star), R(0),
|
||||
B(Ldar), R(2),
|
||||
|
@ -31,13 +31,13 @@ snippet: "
|
||||
"
|
||||
frame size: 2
|
||||
parameter count: 1
|
||||
bytecode array length: 17
|
||||
bytecode array length: 16
|
||||
bytecodes: [
|
||||
/* 30 E> */ B(StackCheck),
|
||||
/* 42 S> */ B(LdaSmi), I8(1),
|
||||
B(Star), R(0),
|
||||
/* 45 S> */ B(ToNumber), R(1), U8(0),
|
||||
B(Ldar), R(1),
|
||||
/* 45 S> */ B(ToNumber), U8(0),
|
||||
B(Star), R(1),
|
||||
B(Inc), U8(0),
|
||||
B(Star), R(0),
|
||||
B(Ldar), R(1),
|
||||
@ -74,13 +74,13 @@ snippet: "
|
||||
"
|
||||
frame size: 2
|
||||
parameter count: 1
|
||||
bytecode array length: 17
|
||||
bytecode array length: 16
|
||||
bytecodes: [
|
||||
/* 30 E> */ B(StackCheck),
|
||||
/* 42 S> */ B(LdaSmi), I8(1),
|
||||
B(Star), R(0),
|
||||
/* 45 S> */ B(ToNumber), R(1), U8(0),
|
||||
B(Ldar), R(1),
|
||||
/* 45 S> */ B(ToNumber), U8(0),
|
||||
B(Star), R(1),
|
||||
B(Dec), U8(0),
|
||||
B(Star), R(0),
|
||||
B(Ldar), R(1),
|
||||
@ -97,14 +97,14 @@ snippet: "
|
||||
"
|
||||
frame size: 3
|
||||
parameter count: 1
|
||||
bytecode array length: 27
|
||||
bytecode array length: 26
|
||||
bytecodes: [
|
||||
/* 30 E> */ B(StackCheck),
|
||||
/* 42 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(41), R(1),
|
||||
B(Mov), R(1), R(0),
|
||||
/* 54 S> */ B(LdaNamedProperty), R(1), U8(1), U8(1),
|
||||
B(ToNumber), R(2), U8(5),
|
||||
B(Ldar), R(2),
|
||||
B(ToNumber), U8(5),
|
||||
B(Star), R(2),
|
||||
B(Inc), U8(5),
|
||||
/* 66 E> */ B(StaNamedProperty), R(1), U8(1), U8(3),
|
||||
B(Ldar), R(2),
|
||||
@ -146,7 +146,7 @@ snippet: "
|
||||
"
|
||||
frame size: 5
|
||||
parameter count: 1
|
||||
bytecode array length: 32
|
||||
bytecode array length: 31
|
||||
bytecodes: [
|
||||
/* 30 E> */ B(StackCheck),
|
||||
/* 45 S> */ B(LdaConstant), U8(0),
|
||||
@ -155,8 +155,8 @@ bytecodes: [
|
||||
B(Mov), R(2), R(1),
|
||||
/* 72 S> */ B(Ldar), R(0),
|
||||
/* 81 E> */ B(LdaKeyedProperty), R(2), U8(1),
|
||||
B(ToNumber), R(4), U8(5),
|
||||
B(Ldar), R(4),
|
||||
B(ToNumber), U8(5),
|
||||
B(Star), R(4),
|
||||
B(Dec), U8(5),
|
||||
/* 86 E> */ B(StaKeyedProperty), R(2), R(0), U8(3),
|
||||
B(Ldar), R(4),
|
||||
@ -227,7 +227,7 @@ snippet: "
|
||||
"
|
||||
frame size: 3
|
||||
parameter count: 1
|
||||
bytecode array length: 29
|
||||
bytecode array length: 28
|
||||
bytecodes: [
|
||||
B(CreateFunctionContext), U8(1),
|
||||
B(PushContext), R(1),
|
||||
@ -237,8 +237,8 @@ bytecodes: [
|
||||
/* 53 S> */ B(CreateClosure), U8(0), U8(0), U8(2),
|
||||
B(Star), R(0),
|
||||
/* 78 S> */ B(LdaCurrentContextSlot), U8(4),
|
||||
B(ToNumber), R(2), U8(1),
|
||||
B(Ldar), R(2),
|
||||
B(ToNumber), U8(1),
|
||||
B(Star), R(2),
|
||||
B(Dec), U8(1),
|
||||
/* 86 E> */ B(StaCurrentContextSlot), U8(4),
|
||||
B(Ldar), R(2),
|
||||
@ -256,7 +256,7 @@ snippet: "
|
||||
"
|
||||
frame size: 4
|
||||
parameter count: 1
|
||||
bytecode array length: 29
|
||||
bytecode array length: 28
|
||||
bytecodes: [
|
||||
/* 30 E> */ B(StackCheck),
|
||||
/* 44 S> */ B(LdaSmi), I8(1),
|
||||
@ -264,8 +264,8 @@ bytecodes: [
|
||||
/* 55 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(37),
|
||||
B(Star), R(1),
|
||||
/* 63 S> */ B(Ldar), R(0),
|
||||
B(ToNumber), R(3), U8(1),
|
||||
B(Ldar), R(3),
|
||||
B(ToNumber), U8(1),
|
||||
B(Star), R(3),
|
||||
B(Inc), U8(1),
|
||||
B(Star), R(0),
|
||||
B(LdaSmi), I8(2),
|
||||
|
@ -36,12 +36,12 @@ snippet: "
|
||||
"
|
||||
frame size: 1
|
||||
parameter count: 1
|
||||
bytecode array length: 17
|
||||
bytecode array length: 16
|
||||
bytecodes: [
|
||||
/* 26 E> */ B(StackCheck),
|
||||
/* 31 S> */ B(LdaGlobal), U8(0), U8(0),
|
||||
B(ToNumber), R(0), U8(4),
|
||||
B(Ldar), R(0),
|
||||
B(ToNumber), U8(4),
|
||||
B(Star), R(0),
|
||||
B(Dec), U8(4),
|
||||
/* 44 E> */ B(StaGlobalSloppy), U8(0), U8(2),
|
||||
B(Ldar), R(0),
|
||||
@ -83,12 +83,12 @@ snippet: "
|
||||
"
|
||||
frame size: 1
|
||||
parameter count: 1
|
||||
bytecode array length: 17
|
||||
bytecode array length: 16
|
||||
bytecodes: [
|
||||
/* 27 E> */ B(StackCheck),
|
||||
/* 32 S> */ B(LdaGlobal), U8(0), U8(0),
|
||||
B(ToNumber), R(0), U8(4),
|
||||
B(Ldar), R(0),
|
||||
B(ToNumber), U8(4),
|
||||
B(Star), R(0),
|
||||
B(Inc), U8(4),
|
||||
/* 50 E> */ B(StaGlobalSloppy), U8(0), U8(2),
|
||||
B(Ldar), R(0),
|
||||
|
@ -209,7 +209,7 @@ snippet: "
|
||||
"
|
||||
frame size: 5
|
||||
parameter count: 2
|
||||
bytecode array length: 138
|
||||
bytecode array length: 137
|
||||
bytecodes: [
|
||||
B(Ldar), R(1),
|
||||
B(JumpIfUndefined), U8(18),
|
||||
@ -259,8 +259,8 @@ bytecodes: [
|
||||
/* 34 S> */ B(LdaUndefined),
|
||||
/* 34 E> */ B(StaCurrentContextSlot), U8(4),
|
||||
/* 39 S> */ B(LdaModuleVariable), I8(1), U8(1),
|
||||
B(ToNumber), R(4), U8(1),
|
||||
B(Ldar), R(4),
|
||||
B(ToNumber), U8(1),
|
||||
B(Star), R(4),
|
||||
B(Inc), U8(1),
|
||||
/* 42 E> */ B(StaModuleVariable), I8(1), U8(1),
|
||||
B(Ldar), R(4),
|
||||
@ -287,7 +287,7 @@ snippet: "
|
||||
"
|
||||
frame size: 5
|
||||
parameter count: 2
|
||||
bytecode array length: 142
|
||||
bytecode array length: 141
|
||||
bytecodes: [
|
||||
B(Ldar), R(1),
|
||||
B(JumpIfUndefined), U8(18),
|
||||
@ -339,8 +339,8 @@ bytecodes: [
|
||||
/* 34 S> */ B(LdaUndefined),
|
||||
/* 34 E> */ B(StaCurrentContextSlot), U8(4),
|
||||
/* 39 S> */ B(LdaModuleVariable), I8(1), U8(1),
|
||||
B(ToNumber), R(4), U8(1),
|
||||
B(Ldar), R(4),
|
||||
B(ToNumber), U8(1),
|
||||
B(Star), R(4),
|
||||
B(Inc), U8(1),
|
||||
/* 42 E> */ B(StaModuleVariable), I8(1), U8(1),
|
||||
B(Ldar), R(4),
|
||||
@ -367,7 +367,7 @@ snippet: "
|
||||
"
|
||||
frame size: 5
|
||||
parameter count: 2
|
||||
bytecode array length: 146
|
||||
bytecode array length: 145
|
||||
bytecodes: [
|
||||
B(Ldar), R(1),
|
||||
B(JumpIfUndefined), U8(18),
|
||||
@ -419,8 +419,8 @@ bytecodes: [
|
||||
/* 36 S> */ B(LdaUndefined),
|
||||
/* 36 E> */ B(StaCurrentContextSlot), U8(4),
|
||||
/* 41 S> */ B(LdaModuleVariable), I8(1), U8(1),
|
||||
B(ToNumber), R(4), U8(1),
|
||||
B(Ldar), R(4),
|
||||
B(ToNumber), U8(1),
|
||||
B(Star), R(4),
|
||||
B(Inc), U8(1),
|
||||
/* 44 E> */ B(CallRuntime), U16(Runtime::kThrowConstAssignError), R(0), U8(0),
|
||||
B(Ldar), R(4),
|
||||
|
@ -139,12 +139,12 @@ snippet: "
|
||||
"
|
||||
frame size: 1
|
||||
parameter count: 1
|
||||
bytecode array length: 9
|
||||
bytecode array length: 8
|
||||
bytecodes: [
|
||||
/* 30 E> */ B(StackCheck),
|
||||
/* 42 S> */ B(LdaSmi), I8(13),
|
||||
B(Star), R(0),
|
||||
/* 53 S> */ B(MulSmi), I8(1), U8(0),
|
||||
/* 53 S> */ B(ToNumber), U8(0),
|
||||
/* 56 S> */ B(Return),
|
||||
]
|
||||
constant pool: [
|
||||
|
@ -221,7 +221,7 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
|
||||
.CompareNull();
|
||||
|
||||
// Emit conversion operator invocations.
|
||||
builder.ToNumber(reg, 1).ToObject(reg).ToName(reg);
|
||||
builder.ToNumber(1).ToObject(reg).ToName(reg);
|
||||
|
||||
// Emit GetSuperConstructor.
|
||||
builder.GetSuperConstructor(reg);
|
||||
|
Loading…
Reference in New Issue
Block a user