Re: [PATCH] Exceptions

2007-10-24 Thread Allison Randal

Kevin Tew wrote:

exceptions_ops.diff adds some simple ops needed for PDD compliance.
exceptions.diff attempts to change all instances of clear_eh to pop_eh.


Looks good.

The exception handler stack introspection interface you added to the PDD 
is solid. The stack will be replaced by the concurrency scheduler in a 
few months, but we can preserve this same introspection interface. Let's 
go with 'eh_count' rather than 'eh_stack_depth', since it won't be a stack.


Go ahead and apply.

Thanks!
Allison


Re: [PATCH] Exceptions

2007-10-24 Thread jerry gay
On 10/24/07, Allison Randal [EMAIL PROTECTED] wrote:
 Kevin Tew wrote:
  exceptions_ops.diff adds some simple ops needed for PDD compliance.
  exceptions.diff attempts to change all instances of clear_eh to pop_eh.

 Looks good.

 The exception handler stack introspection interface you added to the PDD
 is solid. The stack will be replaced by the concurrency scheduler in a
 few months, but we can preserve this same introspection interface. Let's
 go with 'eh_count' rather than 'eh_stack_depth', since it won't be a stack.

 Go ahead and apply.

there are a few typos and pod nits that can be easily fixed before or
after this is applied.

i'd prefer 'count_eh', to match every other exception handler related
op that has an '_eh' suffix. seems silly to have just one with a 'eh_'
prefix.

also, i'd suggest 'get_all_eh' rather than 'get_ehs', both to make it
more visually distinct from 'get_eh' and also to make it match the
'_eh' suffix of the other ops.
~jerry


Re: [PATCH] Exceptions

2007-10-24 Thread Allison Randal

jerry gay wrote:


i'd prefer 'count_eh', to match every other exception handler related
op that has an '_eh' suffix. seems silly to have just one with a 'eh_'
prefix.


'count_eh' isn't distinctive enough.

Another possibility is not to provide an opcode for the number of 
exception handlers, since it's a relatively uncommon operation, and 
leave that as an 'inspect' option on the concurrency scheduler.


Probably the most common use of 'eh_count' would be to find the number 
of elements in the array of exception handlers returned by 'get_all_eh' 
before performing some operation on it, in which case calling the 
elements vtable function on the array is good enough.



also, i'd suggest 'get_all_eh' rather than 'get_ehs', both to make it
more visually distinct from 'get_eh' and also to make it match the
'_eh' suffix of the other ops.


+1

Allison


[PATCH] Exceptions as promised...

2001-10-25 Thread jgoff

The included patch requires a new file t/op/exceptions.t, which tests basic exception 
handling, in this case divide-by-zero.
Patch was generated against latest CVS, but it shouldn't matter -that- much.

-Jeff
[EMAIL PROTECTED]




diff --recursive -C 2 parrot_cvs/MANIFEST parrot/MANIFEST
*** parrot_cvs/MANIFEST Wed Oct 24 07:36:57 2001
--- parrot/MANIFEST Wed Oct 24 07:37:22 2001
***
*** 108,111 
--- 108,112 
  t/op/basic.t
  t/op/bitwise.t
+ t/op/exception.t
  t/op/integer.t
  t/op/number.t
Only in parrot/: Makefile
diff --recursive -C 2 parrot_cvs/Parrot/Assembler.pm parrot/Parrot/Assembler.pm
*** parrot_cvs/Parrot/Assembler.pm  Wed Oct 24 07:36:57 2001
--- parrot/Parrot/Assembler.pm  Wed Oct 24 07:54:22 2001
***
*** 110,114 
  =cut
  
! my(%type_to_suffix)=('I'='i',  'N'='n',
   'S'='s',  'P'='p',
   'i'='ic', 'n'='nc',
--- 110,115 
  =cut
  
! my(%type_to_suffix)=('E'='e',
!'I'='i',  'N'='n',
   'S'='s',  'P'='p',
   'i'='ic', 'n'='nc',
***
*** 923,927 
  #
  
! if  (m/^([INPS])\d+$/) {   # a register.
push @arg_t,lc($1);
  } elsif (m/^\[([a-z]+):(\d+)\s*\]$/) { # string constant
--- 924,928 
  #
  
! if  (m/^([EINPS])\d+$/) {  # a register.
push @arg_t,lc($1);
  } elsif (m/^\[([a-z]+):(\d+)\s*\]$/) { # string constant
***
*** 945,949 
#
  
!   my @grep_ops = grep($_ =~ /^$opcode(?:_(?:(?:[ins]c?)|p))+$/, keys(%opcodes));
  
foreach my $op (@grep_ops) {
--- 946,950 
#
  
!   my @grep_ops = grep($_ =~ /^$opcode(?:_(?:(?:[eins]c?)|p))+$/, keys(%opcodes));
  
foreach my $op (@grep_ops) {
***
*** 1056,1059 
--- 1057,1061 
  
  my %rtype_map = (
+   e = E,
i = I,
n = N,
***
*** 1092,1100 
  #
  
! if($rtype eq I || $rtype eq N || $rtype eq P || $rtype eq S) {
# its a register argument
  
!   $args[$_] =~ s/^[INPS](\d+)$/$1/i
! or error(Expected m/[INPS]\\d+/, but got '$args[$_]'!, $file, $line);
  
error(Register $1 out of range (should be 0-31) in '$opcode',$file,$line) if 
$1  0 or $1  31;
--- 1094,1102 
  #
  
! if($rtype eq E || $rtype eq I || $rtype eq N || $rtype eq P || $rtype eq 
S) {
# its a register argument
  
!   $args[$_] =~ s/^[EINPS](\d+)$/$1/i
! or error(Expected m/[EINPS]\\d+/, but got '$args[$_]'!, $file, $line);
  
error(Register $1 out of range (should be 0-31) in '$opcode',$file,$line) if 
$1  0 or $1  31;
Only in parrot/Parrot: Config.pm
Only in parrot/Parrot: Types.pm
diff --recursive -C 2 parrot_cvs/Types_pm.in parrot/Types_pm.in
*** parrot_cvs/Types_pm.in  Wed Oct 24 07:36:57 2001
--- parrot/Types_pm.in  Wed Oct 24 07:39:58 2001
***
*** 35,38 
--- 35,39 
  
  my %how_to_pack = (
+ E  = $pack_type{op},
  I  = $pack_type{op},
  i  = $pack_type{op},
Only in parrot/classes: intclass.o
diff --recursive -C 2 parrot_cvs/config_h.in parrot/config_h.in
*** parrot_cvs/config_h.in  Wed Oct 24 07:36:57 2001
--- parrot/config_h.in  Wed Oct 24 07:53:11 2001
***
*** 24,31 
--- 24,33 
  #define FRAMES_PER_PMC_REG_CHUNK FRAMES_PER_CHUNK
  #define FRAMES_PER_NUM_REG_CHUNK FRAMES_PER_CHUNK
+ #define FRAMES_PER_EXC_REG_CHUNK FRAMES_PER_CHUNK
  #define FRAMES_PER_INT_REG_CHUNK FRAMES_PER_CHUNK
  #define FRAMES_PER_STR_REG_CHUNK FRAMES_PER_CHUNK
  
  #define MASK_STACK_CHUNK_LOW_BITS ${stacklow}
+ #define MASK_EXC_CHUNK_LOW_BITS ${intlow}
  #define MASK_INT_CHUNK_LOW_BITS ${intlow}
  #define MASK_NUM_CHUNK_LOW_BITS ${numlow}
diff --recursive -C 2 parrot_cvs/core.ops parrot/core.ops
*** parrot_cvs/core.ops Wed Oct 24 07:36:57 2001
--- parrot/core.ops Wed Oct 24 07:56:30 2001
***
*** 120,123 
--- 120,127 
  
  
+ =item Bset(e, i)
+ 
+ =item Bset(i, e)
+ 
  =item Bset(i, i)
  
***
*** 136,141 
  =cut
  
  
! AUTO_OP set(i, i|ic) {
$1 = $2;
  }
--- 140,148 
  =cut
  
+ AUTO_OP set(e, i) {
+   $1 = $2;
+ }
  
! AUTO_OP set(i, e|i|ic) {
$1 = $2;
  }
***
*** 684,688 
  
  AUTO_OP div(i, i|ic, i|ic) {
!   $1 = $2 / $3;
  }
  
--- 691,701 
  
  AUTO_OP div(i, i|ic, i|ic) {
!   INTVAL z = $3;
! 
!   if(z == 0) {
! interpreter-exc_reg-registers[0] = 1;
!   } else {
! $1 = $2 / $3;
!   }
  }
  
***
*** 1504,1507 
--- 1517,1522 
  
  
+ =item Bpope()
+ 
  =item Bpopi()
  
***
*** 1517,1520 
--- 1532,1539 
  =cut
  
+ AUTO_OP pope() {
+   Parrot_pop_e(interpreter);
+ }
+ 
  AUTO_OP popi() {
Parrot_pop_i(interpreter);
***
*** 1536,1539 
--- 1555,1560 
  
  
+ =item