Skip to content

Commit 1883cff

Browse files
committed
Remove op_end
https://bugs.webkit.org/show_bug.cgi?id=306661 rdar://169310061 Reviewed by Yusuke Suzuki. op_end is semantically the same as op_ret (but has worse codegen in Baseline). Let's remove it and use op_ret everywhere instead. Had to fix a few other places that were using op_end as a sentinel opcode in peephole optimizing bytecode. I replaced it with op_debug since that opcode shouldn't exist outside bytecode generated for debugging. No new tests, no new behavior. Covered by existing tests. Canonical link: https://commits.webkit.org/306567@main
1 parent c5a53c2 commit 1883cff

14 files changed

Lines changed: 11 additions & 60 deletions

‎Source/JavaScriptCore/bytecode/BytecodeList.rb‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2018-2023 Apple Inc. All rights reserved.
1+
# Copyright (C) 2018-2026 Apple Inc. All rights reserved.
22
#
33
# Redistribution and use in source and binary forms, with or without
44
# modification, are permitted provided that the following conditions
@@ -21,6 +21,8 @@
2121
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2222
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2323

24+
# This file us consumed by generator/main.rb in order to generate Bytecodes.h/BytecodeStructs.h
25+
2426
types [
2527
:VirtualRegister,
2628

@@ -1132,11 +1134,6 @@
11321134
data: VirtualRegister,
11331135
}
11341136

1135-
op :end,
1136-
args: {
1137-
value: VirtualRegister,
1138-
}
1139-
11401137
op :get_property_enumerator,
11411138
args: {
11421139
dst: VirtualRegister,
@@ -1417,6 +1414,8 @@
14171414
profileIndex: unsigned,
14181415
}
14191416

1417+
# If you add any bytecodes after bitnot make sure to update isOpcode
1418+
14201419
end_section :Bytecode
14211420

14221421
begin_section :CLoopHelpers,

‎Source/JavaScriptCore/bytecode/BytecodeUseDef.cpp‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ void computeUsesForBytecodeIndexImpl(const JSInstruction* instruction, Checkpoin
110110
USES(OpThrow, value)
111111
USES(OpThrowStaticError, message)
112112
USES(OpDebug, data)
113-
USES(OpEnd, value)
114113
USES(OpRet, value)
115114
USES(OpJtrue, condition)
116115
USES(OpJfalse, condition)
@@ -384,7 +383,6 @@ void computeDefsForBytecodeIndexImpl(unsigned numVars, const JSInstruction* inst
384383

385384
// These don't define anything.
386385
case op_put_to_scope:
387-
case op_end:
388386
case op_throw:
389387
case op_throw_static_error:
390388
case op_check_tdz:

‎Source/JavaScriptCore/bytecode/Opcode.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ inline bool isTerminal(OpcodeID opcodeID)
256256
{
257257
switch (opcodeID) {
258258
case op_ret:
259-
case op_end:
260259
case op_unreachable:
261260
return true;
262261
default:

‎Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3969,12 +3969,6 @@ RegisterID* BytecodeGenerator::emitReturn(RegisterID* src)
39693969
return src;
39703970
}
39713971

3972-
RegisterID* BytecodeGenerator::emitEnd(RegisterID* src)
3973-
{
3974-
OpEnd::emit(this, src);
3975-
return src;
3976-
}
3977-
39783972
template<typename ConstructOp>
39793973
RegisterID* BytecodeGenerator::emitConstructImpl(RegisterID* dst, RegisterID* func, RegisterID* lazyThis, ExpectedFunction expectedFunction, CallArguments& callArguments, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
39803974
{

‎Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ namespace JSC {
334334
using OpNop = ::JSC::OpNop;
335335
using CodeBlock = std::unique_ptr<UnlinkedCodeBlockGenerator>;
336336
using InstructionType = JSInstruction;
337-
static constexpr OpcodeID opcodeForDisablingOptimizations = op_end;
337+
static constexpr OpcodeID opcodeForDisablingOptimizations = op_debug;
338338
};
339339

340340
class BytecodeGenerator : public BytecodeGeneratorBase<JSGeneratorTraits> {
@@ -878,7 +878,6 @@ namespace JSC {
878878
RegisterID* emitGetGlobalPrivate(RegisterID* dst, const Identifier& property);
879879

880880
RegisterID* emitReturn(RegisterID* src);
881-
RegisterID* emitEnd(RegisterID* src);
882881

883882
RegisterID* emitConstruct(RegisterID* dst, RegisterID* func, RegisterID* lazyThis, ExpectedFunction, CallArguments&, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd);
884883
RegisterID* emitSuperConstruct(RegisterID* dst, RegisterID* func, RegisterID* lazyThis, ExpectedFunction, CallArguments&, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd);
@@ -1119,9 +1118,9 @@ namespace JSC {
11191118
RegisterID* emitMove(RegisterID* dst, RegisterID* src);
11201119

11211120
public:
1122-
void disablePeepholeOptimization() { m_lastOpcodeID = op_end; }
1121+
void disablePeepholeOptimization() { m_lastOpcodeID = op_debug; }
11231122
private:
1124-
bool canDoPeepholeOptimization() const { return m_lastOpcodeID != op_end; }
1123+
bool canDoPeepholeOptimization() const { return m_lastOpcodeID != op_debug; }
11251124

11261125
public:
11271126
bool isSuperUsedInInnerArrowFunction();

‎Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5358,7 +5358,7 @@ static void emitProgramNodeBytecode(BytecodeGenerator& generator, ScopeNode& sco
53585358
scopeNode.emitStatementsBytecode(generator, dstRegister.get());
53595359

53605360
generator.emitDebugHook(DidExecuteProgram, JSTextPosition(scopeNode.lastLine(), scopeNode.startOffset(), scopeNode.lineStartOffset()));
5361-
generator.emitEnd(dstRegister.get());
5361+
generator.emitReturn(dstRegister.get());
53625362
}
53635363

53645364
// ------------------------------ ProgramNode -----------------------------
@@ -5386,7 +5386,7 @@ void EvalNode::emitBytecode(BytecodeGenerator& generator, RegisterID*)
53865386
emitStatementsBytecode(generator, dstRegister.get());
53875387

53885388
generator.emitDebugHook(DidExecuteProgram, JSTextPosition(lastLine(), startOffset(), lineStartOffset()));
5389-
generator.emitEnd(dstRegister.get());
5389+
generator.emitReturn(dstRegister.get());
53905390
}
53915391

53925392
// ------------------------------ FunctionNode -----------------------------

‎Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8902,11 +8902,6 @@ void ByteCodeParser::parseBlock(unsigned limit)
89028902
}
89038903
LAST_OPCODE_LINKED(op_ret);
89048904
}
8905-
case op_end:
8906-
ASSERT(!inlineCallFrame());
8907-
addToGraph(Return, get(currentInstruction->as<OpEnd>().m_value));
8908-
flushForReturn();
8909-
LAST_OPCODE(op_end);
89108905

89118906
case op_throw:
89128907
addToGraph(Throw, get(currentInstruction->as<OpThrow>().m_value));

‎Source/JavaScriptCore/interpreter/Interpreter.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ bool Interpreter::isOpcode(Opcode opcode)
449449
&& !HashTraits<Opcode>::isDeletedValue(opcode)
450450
&& opcodeIDTable().contains(opcode);
451451
#else
452-
return opcode >= 0 && opcode <= op_end;
452+
return opcode >= 0 && opcode <= op_bitnot;
453453
#endif
454454
}
455455
#endif // ASSERT_ENABLED

‎Source/JavaScriptCore/jit/JIT.cpp‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,6 @@ void JIT::privateCompileMainPass()
299299
DEFINE_OP(op_del_by_id)
300300
DEFINE_OP(op_del_by_val)
301301
DEFINE_OP(op_div)
302-
DEFINE_OP(op_end)
303302
DEFINE_OP(op_enter)
304303
DEFINE_OP(op_get_scope)
305304
DEFINE_OP(op_eq)

‎Source/JavaScriptCore/jit/JIT.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,6 @@ namespace JSC {
404404
void emit_op_del_by_val(const JSInstruction*);
405405
void emitSlow_op_del_by_val(const JSInstruction*, Vector<SlowCaseEntry>::iterator&);
406406
void emit_op_div(const JSInstruction*);
407-
void emit_op_end(const JSInstruction*);
408407
void emit_op_enter(const JSInstruction*);
409408
void emit_op_get_scope(const JSInstruction*);
410409
void emit_op_eq(const JSInstruction*);

0 commit comments

Comments
 (0)