mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 06:02:44 +00:00 
			
		
		
		
	LibJS: Store the bytecode accumulator in a dedicated physical register
We now use a dedicated physical register to store the bytecode accumulator, instead of loading and storing it to the memory everytime.
This commit is contained in:
		
							parent
							
								
									f9cab320e6
								
							
						
					
					
						commit
						38f3b78a1d
					
				
					 5 changed files with 163 additions and 129 deletions
				
			
		|  | @ -399,16 +399,13 @@ Value new_regexp(VM& vm, ParsedRegex const& parsed_regex, DeprecatedString const | |||
| } | ||||
| 
 | ||||
| // 13.3.8.1 https://tc39.es/ecma262/#sec-runtime-semantics-argumentlistevaluation
 | ||||
| MarkedVector<Value> argument_list_evaluation(Bytecode::Interpreter& interpreter) | ||||
| MarkedVector<Value> argument_list_evaluation(VM& vm, Value arguments) | ||||
| { | ||||
|     // Note: Any spreading and actual evaluation is handled in preceding opcodes
 | ||||
|     // Note: The spec uses the concept of a list, while we create a temporary array
 | ||||
|     //       in the preceding opcodes, so we have to convert in a manner that is not
 | ||||
|     //       visible to the user
 | ||||
|     auto& vm = interpreter.vm(); | ||||
| 
 | ||||
|     MarkedVector<Value> argument_values { vm.heap() }; | ||||
|     auto arguments = interpreter.accumulator(); | ||||
| 
 | ||||
|     auto& argument_array = arguments.as_array(); | ||||
|     auto array_length = argument_array.indexed_properties().array_like_size(); | ||||
|  | @ -451,11 +448,10 @@ ThrowCompletionOr<void> create_variable(VM& vm, DeprecatedFlyString const& name, | |||
|     return verify_cast<GlobalEnvironment>(vm.variable_environment())->create_global_var_binding(name, false); | ||||
| } | ||||
| 
 | ||||
| ThrowCompletionOr<ECMAScriptFunctionObject*> new_class(VM& vm, ClassExpression const& class_expression, Optional<IdentifierTableIndex> const& lhs_name) | ||||
| ThrowCompletionOr<ECMAScriptFunctionObject*> new_class(VM& vm, Value super_class, ClassExpression const& class_expression, Optional<IdentifierTableIndex> const& lhs_name) | ||||
| { | ||||
|     auto& interpreter = vm.bytecode_interpreter(); | ||||
|     auto name = class_expression.name(); | ||||
|     auto super_class = interpreter.accumulator(); | ||||
| 
 | ||||
|     // NOTE: NewClass expects classEnv to be active lexical environment
 | ||||
|     auto* class_environment = vm.lexical_environment(); | ||||
|  | @ -476,7 +472,6 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> new_class(VM& vm, ClassExpression c | |||
| // 13.3.7.1 Runtime Semantics: Evaluation, https://tc39.es/ecma262/#sec-super-keyword-runtime-semantics-evaluation
 | ||||
| ThrowCompletionOr<NonnullGCPtr<Object>> super_call_with_argument_array(VM& vm, Value argument_array, bool is_synthetic) | ||||
| { | ||||
|     auto& interpreter = vm.bytecode_interpreter(); | ||||
|     // 1. Let newTarget be GetNewTarget().
 | ||||
|     auto new_target = vm.get_new_target(); | ||||
| 
 | ||||
|  | @ -495,7 +490,7 @@ ThrowCompletionOr<NonnullGCPtr<Object>> super_call_with_argument_array(VM& vm, V | |||
|         for (size_t i = 0; i < length; ++i) | ||||
|             arg_list.append(array_value.get_without_side_effects(PropertyKey { i })); | ||||
|     } else { | ||||
|         arg_list = argument_list_evaluation(interpreter); | ||||
|         arg_list = argument_list_evaluation(vm, argument_array); | ||||
|     } | ||||
| 
 | ||||
|     // 5. If IsConstructor(func) is false, throw a TypeError exception.
 | ||||
|  |  | |||
|  | @ -31,9 +31,9 @@ struct CalleeAndThis { | |||
| }; | ||||
| ThrowCompletionOr<CalleeAndThis> get_callee_and_this_from_environment(Bytecode::Interpreter&, DeprecatedFlyString const& name, u32 cache_index); | ||||
| Value new_regexp(VM&, ParsedRegex const&, DeprecatedString const& pattern, DeprecatedString const& flags); | ||||
| MarkedVector<Value> argument_list_evaluation(Bytecode::Interpreter&); | ||||
| MarkedVector<Value> argument_list_evaluation(VM&, Value arguments); | ||||
| ThrowCompletionOr<void> create_variable(VM&, DeprecatedFlyString const& name, Op::EnvironmentMode, bool is_global, bool is_immutable, bool is_strict); | ||||
| ThrowCompletionOr<ECMAScriptFunctionObject*> new_class(VM&, ClassExpression const&, Optional<IdentifierTableIndex> const& lhs_name); | ||||
| ThrowCompletionOr<ECMAScriptFunctionObject*> new_class(VM&, Value super_class, ClassExpression const&, Optional<IdentifierTableIndex> const& lhs_name); | ||||
| ThrowCompletionOr<NonnullGCPtr<Object>> super_call_with_argument_array(VM&, Value argument_array, bool is_synthetic); | ||||
| Object* iterator_to_object(VM&, IteratorRecord); | ||||
| IteratorRecord object_to_iterator(VM&, Object&); | ||||
|  |  | |||
|  | @ -934,7 +934,7 @@ ThrowCompletionOr<void> CallWithArgumentArray::execute_impl(Bytecode::Interprete | |||
| { | ||||
|     auto callee = interpreter.reg(m_callee); | ||||
|     TRY(throw_if_needed_for_call(interpreter, callee, call_type(), expression_string())); | ||||
|     auto argument_values = argument_list_evaluation(interpreter); | ||||
|     auto argument_values = argument_list_evaluation(interpreter.vm(), interpreter.accumulator()); | ||||
|     interpreter.accumulator() = TRY(perform_call(interpreter, interpreter.reg(m_this_value), call_type(), callee, move(argument_values))); | ||||
|     return {}; | ||||
| } | ||||
|  | @ -1217,7 +1217,7 @@ ThrowCompletionOr<void> IteratorResultValue::execute_impl(Bytecode::Interpreter& | |||
| 
 | ||||
| ThrowCompletionOr<void> NewClass::execute_impl(Bytecode::Interpreter& interpreter) const | ||||
| { | ||||
|     interpreter.accumulator() = TRY(new_class(interpreter.vm(), m_class_expression, m_lhs_name)); | ||||
|     interpreter.accumulator() = TRY(new_class(interpreter.vm(), interpreter.accumulator(), m_class_expression, m_lhs_name)); | ||||
|     return {}; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Idan Horowitz
						Idan Horowitz