octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: JIT interrupt handler naming


From: Max Brister
Subject: Re: JIT interrupt handler naming
Date: Sun, 28 Jul 2013 19:01:28 -0700




On Wed, Jul 24, 2013 at 11:44 PM, lyh.kernel <address@hidden> wrote:
Hello Max,
 
If we want to support disabling interrupts I do not think the API should be JIT specific. If we add a function to disable interrupts in the interpreter, we should make JIT match that behavior.

--
Max Brister

Agree. Interrupts disable should be implement in the interpreter and JIT simultaneously.

On the other hand, I want to ask you the implementation of error handling either in JIT. Take a simple example:

-------------------- Compiling tree --------------------
while (i <= 10000)
  i++;
endwhile

-------------------- optimized llvm ir --------------------

define void @foobar(%octave_base_value**) {
prelude:
  %1 = getelementptr inbounds %octave_base_value** %0, i64 1
  %2 = load %octave_base_value** %0, align 8
  %3 = load %octave_base_value** %1, align 8
  %4 = call double @octave_jit_cast_scalar_any(%octave_base_value* %3)
  br label %while_cond_check

while_cond_check:                                 ; preds = %while_body, %prelude
  %5 = phi double [ %4, %prelude ], [ %8, %while_body ]
  %6 = phi %octave_base_value* [ %2, %prelude ], [ %11, %while_body ]
  %7 = fcmp ule double %5, 1.000000e+04
  br i1 %7, label %while_body, label %final

while_body:                                       ; preds = %while_cond_check
  %8 = fadd double 1.000000e+00, %5
  call void @octave_jit_release_any(%octave_base_value* %6)
  %9 = load volatile i32* @octave_interrupt_state, align 4
  %10 = icmp sgt i32 %9, 0
  %11 = call %octave_base_value* @octave_jit_cast_any_scalar(double %5)
  br i1 %10, label %final, label %while_cond_check

final:                                            ; preds = %while_body, %while_cond_check
  %12 = phi double [ %5, %while_cond_check ], [ %8, %while_body ]
  %13 = phi %octave_base_value* [ %6, %while_cond_check ], [ %11, %while_body ]
  store %octave_base_value* %13, %octave_base_value** %0, align 8
  %14 = call %octave_base_value* @octave_jit_cast_any_scalar(double %12)
  store %octave_base_value* %14, %octave_base_value** %1, align 8
  ret void
}

I guess you use "%9 = load volatile i32* @octave_interrupt_state, align 4" to load global variable octave_interrupt_state. This value is used to do interrupt handling. But which instruction is used to do error handling?

Thanks a lot 


The code is simply checking to see if octave has been interrupted. For example, try running the following code in Octave
 iter = 0
 while 1
   iter = iter + 1
 endwhile

Then hit cntrl-c during execution. After execution terminates, inspect the value of iter.

What happens, is octave intercepts the cntrl-c, and sets octave_interrupt_state to true, we then check that boolean in JIT. If it is true, then we need to stop execution of JIT and return the current values of all variables. This means the above while loop actually looks something like this:
 iter = 0
 while 1 and not octave_interrupt_state
   iter = iter + 1
 endwhile


--
Max Brister

reply via email to

[Prev in Thread] Current Thread [Next in Thread]