diff --git a/boa/src/builtins/function/mod.rs b/boa/src/builtins/function/mod.rs index 1564e99c868..3e5e5f43347 100644 --- a/boa/src/builtins/function/mod.rs +++ b/boa/src/builtins/function/mod.rs @@ -84,6 +84,7 @@ impl Function { context: &mut Context, local_env: &Environment, ) { + use crate::builtins::Array; // Create array of values let array = Array::new_array(context); Array::add_to_array_object(&array, &args_list.get(index..).unwrap_or_default(), context) diff --git a/boa/src/bytecompiler.rs b/boa/src/bytecompiler.rs index b2ba46f9229..e8f5c348f92 100644 --- a/boa/src/bytecompiler.rs +++ b/boa/src/bytecompiler.rs @@ -598,6 +598,7 @@ impl ByteCompiler { self.compile_expr(field.obj(), true); self.emit(Opcode::Dup, &[]); self.compile_expr(field.field(), true); + self.emit(Opcode::Swap, &[]); self.emit(Opcode::GetPropertyByValue, &[]); } expr => { diff --git a/boa/src/context.rs b/boa/src/context.rs index 7f8b9eb460b..561510cccf0 100644 --- a/boa/src/context.rs +++ b/boa/src/context.rs @@ -721,16 +721,19 @@ impl Context { compiler.compile_statement_list(&statement_list, true); let code_block = compiler.finish(); - let prev = self.vm.frame.take(); - self.vm.frame = Some(Box::new(CallFrame { - prev, + let environment = self.get_current_environment().clone(); + let fp = self.vm.stack.len(); + let global_object = self.global_object().into(); + + self.vm.push_frame(CallFrame { + prev: None, code: Gc::new(code_block), - this: self.global_object().into(), + this: global_object, pc: 0, - fp: self.vm.stack.len(), + fp, exit_on_return: true, - environment: self.get_current_environment().clone(), - })); + environment, + }); let result = self.run(); // The main_timer needs to be dropped before the BoaProfiler is. diff --git a/boa/src/object/gcobject.rs b/boa/src/object/gcobject.rs index e19817d059e..70c1fe505d7 100644 --- a/boa/src/object/gcobject.rs +++ b/boa/src/object/gcobject.rs @@ -246,7 +246,7 @@ impl GcObject { for (i, param) in params.iter().enumerate() { // Rest Parameters if param.is_rest_param() { - function.add_rest_param(param, i, args, context, &local_env); + Function::add_rest_param(param, i, args, context, &local_env); break; } @@ -259,8 +259,9 @@ impl GcObject { Some(value) => value, }; - function - .add_arguments_to_environment(param, value, &local_env, context); + Function::add_arguments_to_environment( + param, value, &local_env, context, + ); } if has_parameter_expressions {