mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 07:02:44 +00:00 
			
		
		
		
	LibJS: Work-in-progress JIT compiler :^)
This commit is contained in:
		
							parent
							
								
									f52e4fa5c2
								
							
						
					
					
						commit
						babdc0a25b
					
				
					 11 changed files with 634 additions and 4 deletions
				
			
		
							
								
								
									
										33
									
								
								Userland/Libraries/LibJS/JIT/NativeExecutable.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								Userland/Libraries/LibJS/JIT/NativeExecutable.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,33 @@ | |||
| /*
 | ||||
|  * Copyright (c) 2023, Andreas Kling <kling@serenityos.org> | ||||
|  * | ||||
|  * SPDX-License-Identifier: BSD-2-Clause | ||||
|  */ | ||||
| 
 | ||||
| #include <LibJS/Bytecode/Interpreter.h> | ||||
| #include <LibJS/JIT/NativeExecutable.h> | ||||
| #include <LibJS/Runtime/VM.h> | ||||
| #include <sys/mman.h> | ||||
| 
 | ||||
| namespace JS::JIT { | ||||
| 
 | ||||
| NativeExecutable::NativeExecutable(void* code, size_t size) | ||||
|     : m_code(code) | ||||
|     , m_size(size) | ||||
| { | ||||
| } | ||||
| 
 | ||||
| NativeExecutable::~NativeExecutable() | ||||
| { | ||||
|     munmap(m_code, m_size); | ||||
| } | ||||
| 
 | ||||
| void NativeExecutable::run(VM& vm) | ||||
| { | ||||
|     typedef void (*JITCode)(VM&, Value* registers, Value* locals); | ||||
|     ((JITCode)m_code)(vm, | ||||
|         vm.bytecode_interpreter().registers().data(), | ||||
|         vm.running_execution_context().local_variables.data()); | ||||
| } | ||||
| 
 | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling