Commit 1818a2f2 authored by oth's avatar oth Committed by Commit bot

[interpreter] Remove BytecodeArrayBuilder::Illegal().

BUG=v8:4280
LOG=N

Review-Url: https://codereview.chromium.org/1979523002
Cr-Commit-Position: refs/heads/master@{#36249}
parent 407d9fce
......@@ -113,6 +113,7 @@ namespace internal {
"Invalid frame for FastNewStrictArgumentsStub") \
V(kInvalidFullCodegenState, "invalid full-codegen state") \
V(kInvalidHandleScopeLevel, "Invalid HandleScope level") \
V(kInvalidJumpTableIndex, "Invalid jump table index") \
V(kInvalidLeftHandSideInAssignment, "Invalid left-hand side in assignment") \
V(kInvalidLhsInCompoundAssignment, "Invalid lhs in compound assignment") \
V(kInvalidLhsInCountOperation, "Invalid lhs in count operation") \
......
......@@ -1419,8 +1419,8 @@ void BytecodeGraphBuilder::VisitExtraWide() {
}
void BytecodeGraphBuilder::VisitIllegal() {
NewNode(javascript()->CallRuntime(Runtime::kAbort),
jsgraph()->Constant(kIllegalBytecode));
// Not emitted in valid bytecode.
UNREACHABLE();
}
void BytecodeGraphBuilder::VisitNop() {}
......
......@@ -766,11 +766,6 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::Return() {
return *this;
}
BytecodeArrayBuilder& BytecodeArrayBuilder::Illegal() {
Output(Bytecode::kIllegal);
return *this;
}
BytecodeArrayBuilder& BytecodeArrayBuilder::Debugger() {
Output(Bytecode::kDebugger);
return *this;
......
......@@ -232,8 +232,6 @@ class BytecodeArrayBuilder final : public ZoneObject {
BytecodeArrayBuilder& ReThrow();
BytecodeArrayBuilder& Return();
BytecodeArrayBuilder& Illegal();
// Debugger.
BytecodeArrayBuilder& Debugger();
......@@ -334,6 +332,11 @@ class BytecodeArrayBuilder final : public ZoneObject {
// Gets a constant pool entry for the |object|.
size_t GetConstantPoolEntry(Handle<Object> object);
// Not implemented as the illegal bytecode is used inside internally
// to indicate a bytecode field is not valid or an error has occured
// during bytecode generation.
BytecodeArrayBuilder& Illegal();
Isolate* isolate() const { return isolate_; }
BytecodeArrayWriter* bytecode_array_writer() {
return &bytecode_array_writer_;
......
......@@ -41,6 +41,8 @@ void BytecodeArrayWriter::UpdateSourcePositionTable(
}
void BytecodeArrayWriter::EmitBytecode(const BytecodeNode* const node) {
DCHECK_NE(node->bytecode(), Bytecode::kIllegal);
OperandScale operand_scale = node->operand_scale();
if (operand_scale != OperandScale::kSingle) {
Bytecode prefix = Bytecodes::OperandScaleToPrefixBytecode(operand_scale);
......
......@@ -655,10 +655,14 @@ void BytecodeGenerator::BuildIndexedJump(Register index, size_t start_index,
.CompareOperation(Token::Value::EQ_STRICT, index)
.JumpIfTrue(&(targets[i]));
}
// TODO(oth): This should be an abort via the runtime with a
// corresponding message., An illegal bytecode should never be
// emitted in valid bytecode.
builder()->Illegal(); // Should never get here.
RegisterAllocationScope register_scope(this);
Register reason = register_allocator()->NewRegister();
BailoutReason bailout_reason = BailoutReason::kInvalidJumpTableIndex;
builder()
->LoadLiteral(Smi::FromInt(static_cast<int>(bailout_reason)))
.StoreAccumulatorInRegister(reason)
.CallRuntime(Runtime::kAbort, reason, 1);
}
void BytecodeGenerator::VisitIterationHeader(IterationStatement* stmt,
......
......@@ -17,21 +17,20 @@ BytecodePeepholeOptimizer::BytecodePeepholeOptimizer(
BytecodePipelineStage* next_stage)
: constant_array_builder_(constant_array_builder),
next_stage_(next_stage),
last_(Bytecode::kNop),
last_is_valid_(false),
last_is_discardable_(false) {
// TODO(oth): Remove last_is_valid_ and use kIllegal for last_ when
// not invalid. Currently blocked on bytecode generator emitting
// kIllegal for entry not found in jump table.
InvalidateLast();
}
void BytecodePeepholeOptimizer::InvalidateLast() { last_is_valid_ = false; }
void BytecodePeepholeOptimizer::InvalidateLast() {
last_.set_bytecode(Bytecode::kIllegal);
}
bool BytecodePeepholeOptimizer::LastIsValid() const { return last_is_valid_; }
bool BytecodePeepholeOptimizer::LastIsValid() const {
return last_.bytecode() != Bytecode::kIllegal;
}
void BytecodePeepholeOptimizer::SetLast(const BytecodeNode* const node) {
last_.Clone(node);
last_is_valid_ = true;
last_is_discardable_ = true;
}
......
......@@ -45,7 +45,6 @@ class BytecodePeepholeOptimizer final : public BytecodePipelineStage,
ConstantArrayBuilder* constant_array_builder_;
BytecodePipelineStage* next_stage_;
BytecodeNode last_;
bool last_is_valid_;
bool last_is_discardable_;
DISALLOW_COPY_AND_ASSIGN(BytecodePeepholeOptimizer);
......
......@@ -15,16 +15,18 @@ snippet: "
"
frame size: 11
parameter count: 1
bytecode array length: 195
bytecode array length: 203
bytecodes: [
B(Ldar), R(new_target),
B(JumpIfUndefined), U8(12),
B(JumpIfUndefined), U8(20),
B(ResumeGenerator), R(new_target),
B(Star), R(1),
B(LdaZero),
B(TestEqualStrict), R(1),
B(JumpIfTrue), U8(49),
B(Illegal),
B(JumpIfTrue), U8(57),
B(LdaSmi), U8(80),
B(Star), R(2),
B(CallRuntime), U16(Runtime::kAbort), R(2), U8(1),
B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1),
B(PushContext), R(0),
B(Ldar), R(this),
......@@ -110,7 +112,7 @@ bytecodes: [
constant pool: [
]
handlers: [
[30, 131, 137],
[38, 139, 145],
]
---
......@@ -119,19 +121,21 @@ snippet: "
"
frame size: 11
parameter count: 1
bytecode array length: 289
bytecode array length: 297
bytecodes: [
B(Ldar), R(new_target),
B(JumpIfUndefined), U8(18),
B(JumpIfUndefined), U8(26),
B(ResumeGenerator), R(new_target),
B(Star), R(1),
B(LdaZero),
B(TestEqualStrict), R(1),
B(JumpIfTrue), U8(55),
B(JumpIfTrue), U8(63),
B(LdaSmi), U8(1),
B(TestEqualStrict), R(1),
B(JumpIfTrue), U8(127),
B(Illegal),
B(JumpIfTrueConstant), U8(0),
B(LdaSmi), U8(80),
B(Star), R(2),
B(CallRuntime), U16(Runtime::kAbort), R(2), U8(1),
B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1),
B(PushContext), R(0),
B(Ldar), R(this),
......@@ -255,9 +259,10 @@ bytecodes: [
/* 25 S> */ B(Return),
]
constant pool: [
kInstanceTypeDontCare,
]
handlers: [
[36, 216, 222],
[44, 224, 230],
]
---
......@@ -266,19 +271,21 @@ snippet: "
"
frame size: 17
parameter count: 1
bytecode array length: 792
bytecode array length: 808
bytecodes: [
B(Ldar), R(new_target),
B(JumpIfUndefined), U8(18),
B(JumpIfUndefined), U8(26),
B(ResumeGenerator), R(new_target),
B(Star), R(3),
B(LdaZero),
B(TestEqualStrict), R(3),
B(JumpIfTrue), U8(55),
B(JumpIfTrue), U8(63),
B(LdaSmi), U8(1),
B(TestEqualStrict), R(3),
B(JumpIfTrueConstant), U8(3),
B(Illegal),
B(LdaSmi), U8(80),
B(Star), R(4),
B(CallRuntime), U16(Runtime::kAbort), R(4), U8(1),
B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1),
B(PushContext), R(0),
B(Ldar), R(this),
......@@ -344,11 +351,13 @@ bytecodes: [
/* 30 E> */ B(StaContextSlot), R(1), U8(7),
B(LdaSmi), U8(-2),
B(TestEqual), R(3),
B(JumpIfTrue), U8(9),
B(JumpIfTrue), U8(17),
B(LdaSmi), U8(1),
B(TestEqualStrict), R(3),
B(JumpIfTrueConstant), U8(9),
B(Illegal),
B(LdaSmi), U8(80),
B(Star), R(11),
B(CallRuntime), U16(Runtime::kAbort), R(11), U8(1),
/* 27 S> */ B(LdaContextSlot), R(1), U8(7),
B(Star), R(13),
B(LoadIC), R(13), U8(4), U8(7),
......@@ -434,7 +443,7 @@ bytecodes: [
B(PopContext), R(2),
B(LdaZero),
B(StaContextSlot), R(1), U8(9),
B(Wide), B(Jump), U16(-222),
B(Wide), B(Jump), U16(-230),
B(Jump), U8(49),
B(Star), R(12),
B(LdaConstant), U8(11),
......@@ -629,9 +638,9 @@ constant pool: [
kInstanceTypeDontCare,
]
handlers: [
[36, 710, 716],
[148, 446, 452],
[151, 397, 399],
[554, 569, 571],
[44, 726, 732],
[156, 462, 468],
[159, 413, 415],
[570, 585, 587],
]
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