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