mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 15:32:46 +00:00 
			
		
		
		
	LibJS/JIT: Resolve the GetById property name at JIT time
We can resolve the IdentifierTableIndex to a DeprecatedFlyString& once when jitting the code, instead of every time GetById executes.
This commit is contained in:
		
							parent
							
								
									673e3ec57d
								
							
						
					
					
						commit
						c92954db36
					
				
					 4 changed files with 10 additions and 11 deletions
				
			
		|  | @ -35,14 +35,13 @@ ThrowCompletionOr<NonnullGCPtr<Object>> base_object_for_get(Bytecode::Interprete | ||||||
|     return base_value.to_object(vm); |     return base_value.to_object(vm); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| ThrowCompletionOr<Value> get_by_id(Bytecode::Interpreter& interpreter, IdentifierTableIndex property, Value base_value, Value this_value, u32 cache_index) | ThrowCompletionOr<Value> get_by_id(Bytecode::Interpreter& interpreter, DeprecatedFlyString const& property, Value base_value, Value this_value, u32 cache_index) | ||||||
| { | { | ||||||
|     auto& vm = interpreter.vm(); |     auto& vm = interpreter.vm(); | ||||||
|     auto const& name = interpreter.current_executable().get_identifier(property); |  | ||||||
|     auto& cache = interpreter.current_executable().property_lookup_caches[cache_index]; |     auto& cache = interpreter.current_executable().property_lookup_caches[cache_index]; | ||||||
| 
 | 
 | ||||||
|     if (base_value.is_string()) { |     if (base_value.is_string()) { | ||||||
|         auto string_value = TRY(base_value.as_string().get(vm, name)); |         auto string_value = TRY(base_value.as_string().get(vm, property)); | ||||||
|         if (string_value.has_value()) |         if (string_value.has_value()) | ||||||
|             return *string_value; |             return *string_value; | ||||||
|     } |     } | ||||||
|  | @ -58,7 +57,7 @@ ThrowCompletionOr<Value> get_by_id(Bytecode::Interpreter& interpreter, Identifie | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     CacheablePropertyMetadata cacheable_metadata; |     CacheablePropertyMetadata cacheable_metadata; | ||||||
|     auto value = TRY(base_obj->internal_get(name, this_value, &cacheable_metadata)); |     auto value = TRY(base_obj->internal_get(property, this_value, &cacheable_metadata)); | ||||||
| 
 | 
 | ||||||
|     if (cacheable_metadata.type == CacheablePropertyMetadata::Type::OwnProperty) { |     if (cacheable_metadata.type == CacheablePropertyMetadata::Type::OwnProperty) { | ||||||
|         cache.shape = shape; |         cache.shape = shape; | ||||||
|  |  | ||||||
|  | @ -13,7 +13,7 @@ | ||||||
| namespace JS::Bytecode { | namespace JS::Bytecode { | ||||||
| 
 | 
 | ||||||
| ThrowCompletionOr<NonnullGCPtr<Object>> base_object_for_get(Bytecode::Interpreter&, Value base_value); | ThrowCompletionOr<NonnullGCPtr<Object>> base_object_for_get(Bytecode::Interpreter&, Value base_value); | ||||||
| ThrowCompletionOr<Value> get_by_id(Bytecode::Interpreter&, IdentifierTableIndex, Value base_value, Value this_value, u32 cache_index); | ThrowCompletionOr<Value> get_by_id(Bytecode::Interpreter&, DeprecatedFlyString const& property, Value base_value, Value this_value, u32 cache_index); | ||||||
| ThrowCompletionOr<Value> get_by_value(Bytecode::Interpreter&, Value base_value, Value property_key_value); | ThrowCompletionOr<Value> get_by_value(Bytecode::Interpreter&, Value base_value, Value property_key_value); | ||||||
| ThrowCompletionOr<Value> get_global(Bytecode::Interpreter&, IdentifierTableIndex, u32 cache_index); | ThrowCompletionOr<Value> get_global(Bytecode::Interpreter&, IdentifierTableIndex, u32 cache_index); | ||||||
| ThrowCompletionOr<void> put_by_property_key(VM&, Value base, Value this_value, Value value, PropertyKey name, Op::PropertyKind kind); | ThrowCompletionOr<void> put_by_property_key(VM&, Value base, Value this_value, Value value, PropertyKey name, Op::PropertyKind kind); | ||||||
|  |  | ||||||
|  | @ -760,7 +760,7 @@ ThrowCompletionOr<void> SetLocal::execute_impl(Bytecode::Interpreter&) const | ||||||
| ThrowCompletionOr<void> GetById::execute_impl(Bytecode::Interpreter& interpreter) const | ThrowCompletionOr<void> GetById::execute_impl(Bytecode::Interpreter& interpreter) const | ||||||
| { | { | ||||||
|     auto base_value = interpreter.accumulator(); |     auto base_value = interpreter.accumulator(); | ||||||
|     interpreter.accumulator() = TRY(get_by_id(interpreter, m_property, base_value, base_value, m_cache_index)); |     interpreter.accumulator() = TRY(get_by_id(interpreter, interpreter.current_executable().get_identifier(m_property), base_value, base_value, m_cache_index)); | ||||||
|     return {}; |     return {}; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -768,7 +768,7 @@ ThrowCompletionOr<void> GetByIdWithThis::execute_impl(Bytecode::Interpreter& int | ||||||
| { | { | ||||||
|     auto base_value = interpreter.accumulator(); |     auto base_value = interpreter.accumulator(); | ||||||
|     auto this_value = interpreter.reg(m_this_value); |     auto this_value = interpreter.reg(m_this_value); | ||||||
|     interpreter.accumulator() = TRY(get_by_id(interpreter, m_property, base_value, this_value, m_cache_index)); |     interpreter.accumulator() = TRY(get_by_id(interpreter, interpreter.current_executable().get_identifier(m_property), base_value, this_value, m_cache_index)); | ||||||
|     return {}; |     return {}; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -919,7 +919,7 @@ void Compiler::compile_new_class(Bytecode::Op::NewClass const& op) | ||||||
|     store_accumulator(RET); |     store_accumulator(RET); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static Value cxx_get_by_id(VM& vm, Value base, Bytecode::IdentifierTableIndex property, u32 cache_index) | static Value cxx_get_by_id(VM& vm, Value base, DeprecatedFlyString const& property, u32 cache_index) | ||||||
| { | { | ||||||
|     return TRY_OR_SET_EXCEPTION(Bytecode::get_by_id(vm.bytecode_interpreter(), property, base, base, cache_index)); |     return TRY_OR_SET_EXCEPTION(Bytecode::get_by_id(vm.bytecode_interpreter(), property, base, base, cache_index)); | ||||||
| } | } | ||||||
|  | @ -929,7 +929,7 @@ void Compiler::compile_get_by_id(Bytecode::Op::GetById const& op) | ||||||
|     load_accumulator(ARG1); |     load_accumulator(ARG1); | ||||||
|     m_assembler.mov( |     m_assembler.mov( | ||||||
|         Assembler::Operand::Register(ARG2), |         Assembler::Operand::Register(ARG2), | ||||||
|         Assembler::Operand::Imm(op.property().value())); |         Assembler::Operand::Imm(bit_cast<u64>(&m_bytecode_executable.get_identifier(op.property())))); | ||||||
|     m_assembler.mov( |     m_assembler.mov( | ||||||
|         Assembler::Operand::Register(ARG3), |         Assembler::Operand::Register(ARG3), | ||||||
|         Assembler::Operand::Imm(op.cache_index())); |         Assembler::Operand::Imm(op.cache_index())); | ||||||
|  | @ -1575,7 +1575,7 @@ void Compiler::compile_resolve_super_base(Bytecode::Op::ResolveSuperBase const&) | ||||||
|     check_exception(); |     check_exception(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static Value cxx_get_by_id_with_this(VM& vm, Bytecode::IdentifierTableIndex property, Value base_value, Value this_value, u32 cache_index) | static Value cxx_get_by_id_with_this(VM& vm, DeprecatedFlyString const& property, Value base_value, Value this_value, u32 cache_index) | ||||||
| { | { | ||||||
|     return TRY_OR_SET_EXCEPTION(get_by_id(vm.bytecode_interpreter(), property, base_value, this_value, cache_index)); |     return TRY_OR_SET_EXCEPTION(get_by_id(vm.bytecode_interpreter(), property, base_value, this_value, cache_index)); | ||||||
| } | } | ||||||
|  | @ -1584,7 +1584,7 @@ void Compiler::compile_get_by_id_with_this(Bytecode::Op::GetByIdWithThis const& | ||||||
| { | { | ||||||
|     m_assembler.mov( |     m_assembler.mov( | ||||||
|         Assembler::Operand::Register(ARG1), |         Assembler::Operand::Register(ARG1), | ||||||
|         Assembler::Operand::Imm(op.property().value())); |         Assembler::Operand::Imm(bit_cast<u64>(&m_bytecode_executable.get_identifier(op.property())))); | ||||||
|     load_accumulator(ARG2); |     load_accumulator(ARG2); | ||||||
|     load_vm_register(ARG3, op.this_value()); |     load_vm_register(ARG3, op.this_value()); | ||||||
|     m_assembler.mov( |     m_assembler.mov( | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling