Skip to content

Commit 7414a6a

Browse files
committed
Refactor.
1 parent 854d17e commit 7414a6a

File tree

2 files changed

+6
-22
lines changed

2 files changed

+6
-22
lines changed

monoruby/src/compiler/runtime.rs

+2-16
Original file line numberDiff line numberDiff line change
@@ -304,14 +304,7 @@ pub(super) extern "C" fn vm_handle_arguments(
304304
callid: CallSiteId,
305305
) -> Option<Value> {
306306
let caller_lfp = vm.cfp().lfp();
307-
match set_frame_arguments(
308-
globals,
309-
callee_lfp,
310-
caller_lfp,
311-
callid,
312-
src,
313-
globals.store[callid].pos_num,
314-
) {
307+
match set_frame_arguments(globals, callee_lfp, caller_lfp, callid) {
315308
Ok(_) => {
316309
set_frame_block(&globals.store[callid], callee_lfp, caller_lfp);
317310
Some(Value::nil())
@@ -331,14 +324,7 @@ pub(super) extern "C" fn jit_handle_arguments_no_block(
331324
callid: CallSiteId,
332325
) -> Option<Value> {
333326
let caller_lfp = vm.cfp().lfp();
334-
match set_frame_arguments(
335-
globals,
336-
callee_lfp,
337-
caller_lfp,
338-
callid,
339-
src,
340-
globals.store[callid].pos_num,
341-
) {
327+
match set_frame_arguments(globals, callee_lfp, caller_lfp, callid) {
342328
Ok(_) => Some(Value::nil()),
343329
Err(err) => {
344330
vm.set_error(err);

monoruby/src/compiler/runtime/args.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,12 @@ pub(crate) fn set_frame_arguments(
7676
callee_lfp: Lfp,
7777
caller_lfp: Lfp,
7878
callid: CallSiteId,
79-
src: *const Value,
80-
pos_num: usize,
8179
) -> Result<()> {
8280
let callee_fid = callee_lfp.meta().func_id();
8381
let callee = &globals.store[callee_fid];
8482
let caller = &globals.store[callid];
8583

86-
positional(caller, callee, src, pos_num, callee_lfp, caller_lfp)?;
84+
positional(caller, callee, callee_lfp, caller_lfp)?;
8785
if !callee.no_keyword() || !caller.kw_may_exists() {
8886
handle_keyword(callee, caller, callee_lfp, caller_lfp)?;
8987
}
@@ -158,7 +156,7 @@ pub(crate) extern "C" fn jit_generic_set_arguments(
158156
let caller = &globals.store[caller];
159157
let callee_fid = meta.func_id();
160158
let callee = &globals.store[callee_fid];
161-
match positional(caller, callee, src, caller.pos_num, callee_lfp, caller_lfp) {
159+
match positional(caller, callee, callee_lfp, caller_lfp) {
162160
Ok(_) => Some(Value::nil()),
163161
Err(err) => {
164162
vm.set_error(err);
@@ -173,15 +171,15 @@ pub(crate) extern "C" fn jit_generic_set_arguments(
173171
fn positional(
174172
caller: &CallSiteInfo,
175173
callee: &FuncInfo,
176-
src: *const Value,
177-
pos_num: usize,
178174
mut callee_lfp: Lfp,
179175
caller_lfp: Lfp,
180176
) -> Result<()> {
181177
let max_pos = callee.max_positional_args();
182178
let no_push = callee.discard_excess_positional_args();
183179
let splat_pos = &caller.splat_pos;
180+
let src = caller_lfp.register_ptr(caller.args.0 as usize) as _;
184181
let dst = callee_lfp.register_ptr(1) as *mut Value;
182+
let pos_num = caller.pos_num;
185183

186184
let ex = if callee.no_keyword() && caller.kw_may_exists() {
187185
// handle excessive keyword arguments

0 commit comments

Comments
 (0)