mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 03:32:45 +00:00 
			
		
		
		
	LibJS: Make Executable ref-counted and let instruction iterator co-own it
This ensures that the instruction stream pointed at by the instruction iterator remains valid as long as the iterator exists.
This commit is contained in:
		
							parent
							
								
									b1ee5c8738
								
							
						
					
					
						commit
						c14db6ab12
					
				
					 9 changed files with 61 additions and 26 deletions
				
			
		|  | @ -5,9 +5,34 @@ | |||
|  */ | ||||
| 
 | ||||
| #include <LibJS/Bytecode/Executable.h> | ||||
| #include <LibJS/SourceCode.h> | ||||
| 
 | ||||
| namespace JS::Bytecode { | ||||
| 
 | ||||
| Executable::Executable( | ||||
|     NonnullOwnPtr<IdentifierTable> identifier_table, | ||||
|     NonnullOwnPtr<StringTable> string_table, | ||||
|     NonnullOwnPtr<RegexTable> regex_table, | ||||
|     NonnullRefPtr<SourceCode const> source_code, | ||||
|     size_t number_of_property_lookup_caches, | ||||
|     size_t number_of_global_variable_caches, | ||||
|     size_t number_of_registers, | ||||
|     Vector<NonnullOwnPtr<BasicBlock>> basic_blocks, | ||||
|     bool is_strict_mode) | ||||
|     : basic_blocks(move(basic_blocks)) | ||||
|     , string_table(move(string_table)) | ||||
|     , identifier_table(move(identifier_table)) | ||||
|     , regex_table(move(regex_table)) | ||||
|     , source_code(move(source_code)) | ||||
|     , number_of_registers(number_of_registers) | ||||
|     , is_strict_mode(is_strict_mode) | ||||
| { | ||||
|     property_lookup_caches.resize(number_of_property_lookup_caches); | ||||
|     global_variable_caches.resize(number_of_global_variable_caches); | ||||
| } | ||||
| 
 | ||||
| Executable::~Executable() = default; | ||||
| 
 | ||||
| void Executable::dump() const | ||||
| { | ||||
|     dbgln("\033[33;1mJS::Bytecode::Executable\033[0m ({})", name); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling