[Ignition] Rename New and NewWithSpread bytecodes.

Rename to Construct and ConstructWithSpread, to match the names of
the JSOperators used.

Unfortunately, I can't find a way for auto-formatting to stay happy unless we
change the indentation for the whole BYTECODE_LIST macro.

Review-Url: https://codereview.chromium.org/2663963003
Cr-Commit-Position: refs/heads/master@{#42840}
This commit is contained in:
petermarshall 2017-02-01 01:04:04 -08:00 committed by Commit bot
parent 44cac16f48
commit a7ba61fdb5
16 changed files with 343 additions and 341 deletions

View File

@ -1352,7 +1352,7 @@ void BytecodeGraphBuilder::VisitCallRuntimeForPair() {
Environment::kAttachFrameState);
}
Node* BytecodeGraphBuilder::ProcessCallNewWithSpreadArguments(
Node* BytecodeGraphBuilder::ProcessConstructWithSpreadArguments(
const Operator* op, Node* callee, Node* new_target,
interpreter::Register first_arg, size_t arity) {
Node** all = local_zone()->NewArray<Node*>(arity);
@ -1367,7 +1367,7 @@ Node* BytecodeGraphBuilder::ProcessCallNewWithSpreadArguments(
return value;
}
void BytecodeGraphBuilder::VisitNewWithSpread() {
void BytecodeGraphBuilder::VisitConstructWithSpread() {
PrepareEagerCheckpoint();
interpreter::Register callee_reg = bytecode_iterator().GetRegisterOperand(0);
interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1);
@ -1378,7 +1378,7 @@ void BytecodeGraphBuilder::VisitNewWithSpread() {
const Operator* op =
javascript()->ConstructWithSpread(static_cast<int>(arg_count) + 2);
Node* value = ProcessCallNewWithSpreadArguments(op, callee, new_target,
Node* value = ProcessConstructWithSpreadArguments(op, callee, new_target,
first_arg, arg_count + 2);
environment()->BindAccumulator(value, Environment::kAttachFrameState);
}
@ -1396,7 +1396,7 @@ void BytecodeGraphBuilder::VisitInvokeIntrinsic() {
environment()->BindAccumulator(value, Environment::kAttachFrameState);
}
Node* BytecodeGraphBuilder::ProcessCallNewArguments(
Node* BytecodeGraphBuilder::ProcessConstructArguments(
const Operator* call_new_op, Node* callee, Node* new_target,
interpreter::Register first_arg, size_t arity) {
Node** all = local_zone()->NewArray<Node*>(arity);
@ -1411,7 +1411,7 @@ Node* BytecodeGraphBuilder::ProcessCallNewArguments(
return value;
}
void BytecodeGraphBuilder::VisitNew() {
void BytecodeGraphBuilder::VisitConstruct() {
PrepareEagerCheckpoint();
interpreter::Register callee_reg = bytecode_iterator().GetRegisterOperand(0);
interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1);
@ -1428,7 +1428,7 @@ void BytecodeGraphBuilder::VisitNew() {
float const frequency = ComputeCallFrequency(slot_id);
const Operator* call = javascript()->Construct(
static_cast<int>(arg_count) + 2, frequency, feedback);
Node* value = ProcessCallNewArguments(call, callee, new_target, first_arg,
Node* value = ProcessConstructArguments(call, callee, new_target, first_arg,
arg_count + 2);
environment()->BindAccumulator(value, Environment::kAttachFrameState);
}

View File

@ -111,10 +111,11 @@ class BytecodeGraphBuilder {
Node* ProcessCallArguments(const Operator* call_op, Node* callee,
interpreter::Register receiver, size_t arity);
Node* ProcessCallNewArguments(const Operator* call_new_op, Node* callee,
Node* ProcessConstructArguments(const Operator* call_new_op, Node* callee,
Node* new_target,
interpreter::Register first_arg, size_t arity);
Node* ProcessCallNewWithSpreadArguments(const Operator* op, Node* callee,
interpreter::Register first_arg,
size_t arity);
Node* ProcessConstructWithSpreadArguments(const Operator* op, Node* callee,
Node* new_target,
interpreter::Register first_arg,
size_t arity);

View File

@ -306,7 +306,7 @@ bool BytecodeHasNoSideEffect(interpreter::Bytecode bytecode) {
typedef interpreter::Bytecode Bytecode;
typedef interpreter::Bytecodes Bytecodes;
if (Bytecodes::IsWithoutExternalSideEffects(bytecode)) return true;
if (Bytecodes::IsCallOrNew(bytecode)) return true;
if (Bytecodes::IsCallOrConstruct(bytecode)) return true;
if (Bytecodes::WritesBooleanToAccumulator(bytecode)) return true;
if (Bytecodes::IsJumpIfToBoolean(bytecode)) return true;
if (Bytecodes::IsPrefixScalingBytecode(bytecode)) return true;

View File

@ -328,7 +328,7 @@ DebugBreakType BytecodeArrayBreakIterator::GetDebugBreakType() {
return isolate()->is_tail_call_elimination_enabled()
? DEBUG_BREAK_SLOT_AT_TAIL_CALL
: DEBUG_BREAK_SLOT_AT_CALL;
} else if (interpreter::Bytecodes::IsCallOrNew(bytecode)) {
} else if (interpreter::Bytecodes::IsCallOrConstruct(bytecode)) {
return DEBUG_BREAK_SLOT_AT_CALL;
} else if (source_position_iterator_.is_statement()) {
return DEBUG_BREAK_SLOT;

View File

@ -905,10 +905,16 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::CallWithSpread(Register callable,
return *this;
}
BytecodeArrayBuilder& BytecodeArrayBuilder::New(Register constructor,
BytecodeArrayBuilder& BytecodeArrayBuilder::Construct(Register constructor,
RegisterList args,
int feedback_slot_id) {
OutputNew(constructor, args, args.register_count(), feedback_slot_id);
OutputConstruct(constructor, args, args.register_count(), feedback_slot_id);
return *this;
}
BytecodeArrayBuilder& BytecodeArrayBuilder::ConstructWithSpread(
Register constructor, RegisterList args) {
OutputConstructWithSpread(constructor, args, args.register_count());
return *this;
}
@ -961,12 +967,6 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::CallJSRuntime(int context_index,
return *this;
}
BytecodeArrayBuilder& BytecodeArrayBuilder::NewWithSpread(Register constructor,
RegisterList args) {
OutputNewWithSpread(constructor, args, args.register_count());
return *this;
}
BytecodeArrayBuilder& BytecodeArrayBuilder::Delete(Register object,
LanguageMode language_mode) {
if (language_mode == SLOPPY) {

View File

@ -218,15 +218,16 @@ class V8_EXPORT_PRIVATE BytecodeArrayBuilder final
// onwards. The final argument must be a spread.
BytecodeArrayBuilder& CallWithSpread(Register callable, RegisterList args);
// Call the new operator. The accumulator holds the |new_target|.
// Call the Construct operator. The accumulator holds the |new_target|.
// The |constructor| is in a register and arguments are in |args|.
BytecodeArrayBuilder& New(Register constructor, RegisterList args,
BytecodeArrayBuilder& Construct(Register constructor, RegisterList args,
int feedback_slot);
// Call the new operator for use with a spread. The accumulator holds the
// |new_target|. The |constructor| is in a register and arguments are in
// Call the Construct operator for use with a spread. The accumulator holds
// the |new_target|. The |constructor| is in a register and arguments are in
// |args|. The final argument must be a spread.
BytecodeArrayBuilder& NewWithSpread(Register constructor, RegisterList args);
BytecodeArrayBuilder& ConstructWithSpread(Register constructor,
RegisterList args);
// Call the runtime function with |function_id| and arguments |args|.
BytecodeArrayBuilder& CallRuntime(Runtime::FunctionId function_id,

View File

@ -2606,7 +2606,7 @@ void BytecodeGenerator::VisitCallSuper(Call* expr) {
// if there is exactly one spread, and it is the last argument.
if (expr->only_last_arg_is_spread()) {
// TODO(petermarshall): Collect type on the feedback slot.
builder()->NewWithSpread(constructor, args_regs);
builder()->ConstructWithSpread(constructor, args_regs);
} else {
// Call construct.
// TODO(turbofan): For now we do gather feedback on super constructor
@ -2616,7 +2616,7 @@ void BytecodeGenerator::VisitCallSuper(Call* expr) {
// the job done for now. In the long run we might want to revisit this
// and come up with a better way.
int const feedback_slot_index = feedback_index(expr->CallFeedbackICSlot());
builder()->New(constructor, args_regs, feedback_slot_index);
builder()->Construct(constructor, args_regs, feedback_slot_index);
}
}
@ -2632,9 +2632,9 @@ void BytecodeGenerator::VisitCallNew(CallNew* expr) {
if (expr->only_last_arg_is_spread()) {
// TODO(petermarshall): Collect type on the feedback slot.
builder()->NewWithSpread(constructor, args);
builder()->ConstructWithSpread(constructor, args);
} else {
builder()->New(constructor, args,
builder()->Construct(constructor, args,
feedback_index(expr->CallNewFeedbackSlot()));
}
}

View File

@ -227,7 +227,8 @@ bool Bytecodes::IsStarLookahead(Bytecode bytecode, OperandScale operand_scale) {
case Bytecode::kTypeOf:
case Bytecode::kCall:
case Bytecode::kCallProperty:
case Bytecode::kNew:
case Bytecode::kConstruct:
case Bytecode::kConstructWithSpread:
return true;
default:
return false;

View File

@ -166,10 +166,10 @@ namespace interpreter {
V(InvokeIntrinsic, AccumulatorUse::kWrite, OperandType::kIntrinsicId, \
OperandType::kRegList, OperandType::kRegCount) \
\
/* New operators */ \
V(New, AccumulatorUse::kReadWrite, OperandType::kReg, OperandType::kRegList, \
OperandType::kRegCount, OperandType::kIdx) \
V(NewWithSpread, AccumulatorUse::kReadWrite, OperandType::kReg, \
/* Construct operators */ \
V(Construct, AccumulatorUse::kReadWrite, OperandType::kReg, \
OperandType::kRegList, OperandType::kRegCount, OperandType::kIdx) \
V(ConstructWithSpread, AccumulatorUse::kReadWrite, OperandType::kReg, \
OperandType::kRegList, OperandType::kRegCount) \
\
/* Test Operators */ \
@ -612,9 +612,9 @@ class V8_EXPORT_PRIVATE Bytecodes final {
}
// Returns true if the bytecode is a call or a constructor call.
static constexpr bool IsCallOrNew(Bytecode bytecode) {
static constexpr bool IsCallOrConstruct(Bytecode bytecode) {
return bytecode == Bytecode::kCall || bytecode == Bytecode::kCallProperty ||
bytecode == Bytecode::kTailCall || bytecode == Bytecode::kNew;
bytecode == Bytecode::kTailCall || bytecode == Bytecode::kConstruct;
}
// Returns true if the bytecode is a call to the runtime.

View File

@ -2199,13 +2199,13 @@ void Interpreter::DoCallWithSpread(InterpreterAssembler* assembler) {
__ Dispatch();
}
// NewWithSpread <first_arg> <arg_count>
// ConstructWithSpread <first_arg> <arg_count>
//
// Call the constructor in |constructor| with the first argument in register
// |first_arg| and |arg_count| arguments in subsequent registers. The final
// argument is always a spread. The new.target is in the accumulator.
//
void Interpreter::DoNewWithSpread(InterpreterAssembler* assembler) {
void Interpreter::DoConstructWithSpread(InterpreterAssembler* assembler) {
Node* new_target = __ GetAccumulator();
Node* constructor_reg = __ BytecodeOperandReg(0);
Node* constructor = __ LoadRegister(constructor_reg);
@ -2219,13 +2219,13 @@ void Interpreter::DoNewWithSpread(InterpreterAssembler* assembler) {
__ Dispatch();
}
// New <constructor> <first_arg> <arg_count>
// Construct <constructor> <first_arg> <arg_count>
//
// Call operator new with |constructor| and the first argument in
// Call operator construct with |constructor| and the first argument in
// register |first_arg| and |arg_count| arguments in subsequent
// registers. The new.target is in the accumulator.
//
void Interpreter::DoNew(InterpreterAssembler* assembler) {
void Interpreter::DoConstruct(InterpreterAssembler* assembler) {
Node* new_target = __ GetAccumulator();
Node* constructor_reg = __ BytecodeOperandReg(0);
Node* constructor = __ LoadRegister(constructor_reg);

View File

@ -19,7 +19,7 @@ bytecodes: [
/* 45 E> */ B(StackCheck),
/* 50 S> */ B(LdaGlobal), U8(0), U8(4),
B(Star), R(0),
/* 57 E> */ B(New), R(0), R(0), U8(0), U8(2),
/* 57 E> */ B(Construct), R(0), R(0), U8(0), U8(2),
/* 68 S> */ B(Return),
]
constant pool: [
@ -44,7 +44,7 @@ bytecodes: [
B(LdaSmi), I8(3),
B(Star), R(1),
B(Ldar), R(0),
/* 70 E> */ B(New), R(0), R(1), U8(1), U8(2),
/* 70 E> */ B(Construct), R(0), R(1), U8(1), U8(2),
/* 82 S> */ B(Return),
]
constant pool: [
@ -78,7 +78,7 @@ bytecodes: [
B(LdaSmi), I8(5),
B(Star), R(3),
B(Ldar), R(0),
/* 112 E> */ B(New), R(0), R(1), U8(3), U8(2),
/* 112 E> */ B(Construct), R(0), R(1), U8(3), U8(2),
/* 130 S> */ B(Return),
]
constant pool: [

View File

@ -118,7 +118,7 @@ bytecodes: [
B(LdaSmi), I8(1),
B(Star), R(3),
B(Ldar), R(0),
/* 118 E> */ B(New), R(2), R(3), U8(1), U8(2),
/* 118 E> */ B(Construct), R(2), R(3), U8(1), U8(2),
B(Star), R(2),
B(Ldar), R(this),
B(JumpIfNotHole), U8(4),
@ -171,7 +171,7 @@ bytecodes: [
/* 117 S> */ B(Ldar), R(1),
B(GetSuperConstructor), R(2),
B(Ldar), R(0),
/* 117 E> */ B(New), R(2), R(0), U8(0), U8(2),
/* 117 E> */ B(Construct), R(2), R(0), U8(0), U8(2),
B(Star), R(2),
B(Ldar), R(this),
B(JumpIfNotHole), U8(4),

View File

@ -215,7 +215,7 @@ bytecodes: [
B(Star), R(1),
B(Star), R(2),
/* 87 S> */ B(Nop),
/* 94 E> */ B(New), R(2), R(0), U8(0), U8(3),
/* 94 E> */ B(Construct), R(2), R(0), U8(0), U8(3),
/* 103 S> */ B(Return),
]
constant pool: [

View File

@ -38,7 +38,7 @@ bytecodes: [
/* 89 S> */ B(CreateArrayLiteral), U8(1), U8(5), U8(9),
B(Star), R(4),
B(Ldar), R(2),
/* 89 E> */ B(NewWithSpread), R(2), R(4), U8(1),
/* 89 E> */ B(ConstructWithSpread), R(2), R(4), U8(1),
B(LdaUndefined),
/* 110 S> */ B(Return),
]
@ -84,7 +84,7 @@ bytecodes: [
B(CreateArrayLiteral), U8(1), U8(5), U8(9),
B(Star), R(5),
B(Ldar), R(2),
/* 89 E> */ B(NewWithSpread), R(2), R(4), U8(2),
/* 89 E> */ B(ConstructWithSpread), R(2), R(4), U8(2),
B(LdaUndefined),
/* 113 S> */ B(Return),
]

View File

@ -30,7 +30,7 @@ bytecodes: [
/* 93 S> */ B(Ldar), R(1),
B(GetSuperConstructor), R(3),
B(Ldar), R(0),
/* 93 E> */ B(NewWithSpread), R(3), R(2), U8(1),
/* 93 E> */ B(ConstructWithSpread), R(3), R(2), U8(1),
/* 93 S> */ B(Return),
]
constant pool: [
@ -67,7 +67,7 @@ bytecodes: [
B(Star), R(4),
B(Ldar), R(0),
B(Mov), R(2), R(5),
/* 140 E> */ B(NewWithSpread), R(3), R(4), U8(2),
/* 140 E> */ B(ConstructWithSpread), R(3), R(4), U8(2),
B(Star), R(3),
B(Ldar), R(this),
B(JumpIfNotHole), U8(4),

View File

@ -138,7 +138,6 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
.CallRuntime(Runtime::kIsArray, reg)
.CallRuntimeForPair(Runtime::kLoadLookupSlotForCall, reg_list, pair)
.CallJSRuntime(Context::SPREAD_ITERABLE_INDEX, reg_list)
.NewWithSpread(reg, reg_list)
.CallWithSpread(reg, reg_list);
// Emit binary operator invocations.
@ -185,8 +184,8 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
// Emit delete
builder.Delete(reg, LanguageMode::SLOPPY).Delete(reg, LanguageMode::STRICT);
// Emit new.
builder.New(reg, reg_list, 1);
// Emit construct.
builder.Construct(reg, reg_list, 1).ConstructWithSpread(reg, reg_list);
// Emit test operator invocations.
builder.CompareOperation(Token::Value::EQ, reg, 1)