mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 09:02:43 +00:00 
			
		
		
		
	LibJS: Move Instruction::length() to the Op.h header
Make sure this gets inlined as well, as it's used by the bytecode stream iterator and thus extremely hot.
This commit is contained in:
		
							parent
							
								
									48a8022cf6
								
							
						
					
					
						commit
						a8ccc9580d
					
				
					 2 changed files with 19 additions and 18 deletions
				
			
		|  | @ -25,22 +25,4 @@ void Instruction::destroy(Instruction& instruction) | ||||||
| #undef __BYTECODE_OP | #undef __BYTECODE_OP | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| size_t Instruction::length() const |  | ||||||
| { |  | ||||||
|     if (type() == Type::Call) |  | ||||||
|         return static_cast<Op::Call const&>(*this).length(); |  | ||||||
|     else if (type() == Type::NewArray) |  | ||||||
|         return static_cast<Op::NewArray const&>(*this).length(); |  | ||||||
| 
 |  | ||||||
| #define __BYTECODE_OP(op) \ |  | ||||||
|     case Type::op:        \ |  | ||||||
|         return sizeof(Op::op); |  | ||||||
| 
 |  | ||||||
|     switch (type()) { |  | ||||||
|         ENUMERATE_BYTECODE_OPS(__BYTECODE_OP) |  | ||||||
|     default: |  | ||||||
|         VERIFY_NOT_REACHED(); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -392,4 +392,23 @@ ALWAYS_INLINE void Instruction::execute(Bytecode::Interpreter& interpreter) cons | ||||||
| #undef __BYTECODE_OP | #undef __BYTECODE_OP | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | ALWAYS_INLINE size_t Instruction::length() const | ||||||
|  | { | ||||||
|  |     if (type() == Type::Call) | ||||||
|  |         return static_cast<Op::Call const&>(*this).length(); | ||||||
|  |     else if (type() == Type::NewArray) | ||||||
|  |         return static_cast<Op::NewArray const&>(*this).length(); | ||||||
|  | 
 | ||||||
|  | #define __BYTECODE_OP(op) \ | ||||||
|  |     case Type::op:        \ | ||||||
|  |         return sizeof(Op::op); | ||||||
|  | 
 | ||||||
|  |     switch (type()) { | ||||||
|  |         ENUMERATE_BYTECODE_OPS(__BYTECODE_OP) | ||||||
|  |     default: | ||||||
|  |         VERIFY_NOT_REACHED(); | ||||||
|  |     } | ||||||
|  | #undef __BYTECODE_OP | ||||||
|  | } | ||||||
|  | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling