Author: allison Date: Sat Aug 2 15:45:13 2008 New Revision: 29952 Modified: trunk/docs/pdds/draft/pdd08_keys.pod trunk/docs/pdds/pdd17_pmc.pod trunk/docs/pdds/pdd23_exceptions.pod
Changes in other areas also in this revision: Added: trunk/src/pmc/exceptionhandler.pmc - copied unchanged from r29949, /branches/pdd25cx/src/pmc/exceptionhandler.pmc Removed: trunk/src/pmc/exception_handler.pmc Modified: trunk/MANIFEST trunk/compilers/bcg/src/pmc/bcg.pmc trunk/compilers/imcc/imcc.l trunk/compilers/imcc/imcc.y trunk/compilers/imcc/imclexer.c trunk/compilers/imcc/imcparser.c trunk/compilers/imcc/main.c trunk/compilers/imcc/optimizer.c trunk/compilers/imcc/parser_util.c trunk/compilers/imcc/pbc.c trunk/compilers/imcc/pcc.c trunk/compilers/imcc/reg_alloc.c trunk/compilers/imcc/symreg.c trunk/compilers/pct/src/PAST/Compiler.pir trunk/compilers/pge/PGE/Exp.pir trunk/compilers/pge/PGE/OPTable.pir trunk/compilers/pge/PGE/P5Regex.pir trunk/compilers/pge/PGE/Perl6Regex.pir trunk/config/gen/crypto/digest_pmc.in trunk/config/gen/makefiles/root.in trunk/config/gen/platform/ansi/exec.c trunk/config/gen/platform/generic/exec.c trunk/config/gen/platform/generic/signal.h trunk/config/gen/platform/generic/stat.c trunk/config/gen/platform/win32/exec.c trunk/config/gen/platform/win32/stat.c trunk/docs/art/pp002-pmc.pod trunk/docs/book/ch05_pasm.pod trunk/docs/compiler_faq.pod trunk/docs/stm/internals.pod trunk/editor/pir-mode.el trunk/examples/sdl/tetris/blockdata.pir trunk/include/parrot/exceptions.h trunk/include/parrot/interpreter.h trunk/include/parrot/scheduler.h trunk/include/parrot/stacks.h trunk/include/parrot/sub.h trunk/languages/BASIC/compiler/COMP_parsefuncs.pm trunk/languages/WMLScript/pmc/wmlsbytecode.pmc trunk/languages/dotnet/build/builtins.pl trunk/languages/dotnet/build/translator.pl trunk/languages/dotnet/pmc/dotnetassembly.pmc trunk/languages/dotnet/pmc/dotnetassemblyref.pmc trunk/languages/dotnet/pmc/dotnetbytecode.pmc trunk/languages/dotnet/pmc/dotnetclassmetadata.pmc trunk/languages/dotnet/pmc/dotneteh.pmc trunk/languages/dotnet/pmc/dotnetfieldmetadata.pmc trunk/languages/dotnet/pmc/dotnetmemberrefmetadata.pmc trunk/languages/dotnet/pmc/dotnetmethodmetadata.pmc trunk/languages/dotnet/pmc/dotnetparammetadata.pmc trunk/languages/dotnet/pmc/dotnetsignature.pmc trunk/languages/dotnet/pmc/dotnettyperefmetadata.pmc trunk/languages/dotnet/pmc/managedpointer.pmc trunk/languages/dotnet/src/exception.pir trunk/languages/dotnet/src/method.pir trunk/languages/dotnet/src/signature.pir trunk/languages/dotnet/src/translator.pir trunk/languages/jako/lib/Jako/Construct/Declaration/Constant.pm trunk/languages/jako/lib/Jako/Construct/Declaration/Sub.pm trunk/languages/jako/lib/Jako/Construct/Declaration/Variable.pm trunk/languages/jako/lib/Jako/Construct/Expression/Call.pm trunk/languages/jako/lib/Jako/Construct/Expression/Value/Literal.pm trunk/languages/jako/lib/Jako/Construct/Statement/Arithmetic.pm trunk/languages/jako/lib/Jako/Construct/Statement/Bitwise.pm trunk/languages/jako/lib/Jako/Construct/Statement/Call.pm trunk/languages/jako/lib/Jako/Construct/Statement/Concat.pm trunk/languages/jako/lib/Jako/Construct/Statement/LoopControl.pm trunk/languages/jako/lib/Jako/Construct/Statement/Return.pm trunk/languages/jako/lib/Jako/Parser.pm trunk/languages/jako/lib/Jako/Processor.pm trunk/languages/lisp/lisp.pir trunk/languages/lisp/read.pir trunk/languages/lua/src/lib/luaaux.pir trunk/languages/lua/src/pmc/lua.pmc trunk/languages/lua/src/pmc/luaany.pmc trunk/languages/lua/src/pmc/luabytecode.pmc trunk/languages/lua/src/pmc/luaclosure.pmc trunk/languages/lua/src/pmc/luanumber.pmc trunk/languages/lua/src/pmc/luastring.pmc trunk/languages/lua/src/pmc/luatable.pmc trunk/languages/lua/src/pmc/luathread.pmc trunk/languages/lua/src/pmc/luauserdata.pmc trunk/languages/m4/src/m4.pir trunk/languages/perl6/src/builtins/control.pir trunk/languages/perl6/src/builtins/enums.pir trunk/languages/perl6/src/classes/Signature.pir trunk/languages/perl6/src/ops/perl6.ops trunk/languages/perl6/src/pmc/mutable_pmc.template trunk/languages/perl6/src/pmc/mutablevar.pmc trunk/languages/perl6/t/pmc/mutable.t trunk/languages/pheme/pheme.pir trunk/languages/pipp/src/pmc/phpresource.pmc trunk/languages/pynie/src/builtins/funcs.pir trunk/languages/regex/pmc/match.pmc trunk/languages/regex/pmc/matchrange.pmc trunk/languages/tcl/docs/howto.pod trunk/languages/tcl/runtime/builtin/after.pir trunk/languages/tcl/runtime/builtin/append.pir trunk/languages/tcl/runtime/builtin/apply.pir trunk/languages/tcl/runtime/builtin/array.pir trunk/languages/tcl/runtime/builtin/binary.pir trunk/languages/tcl/runtime/builtin/break.pir trunk/languages/tcl/runtime/builtin/catch.pir trunk/languages/tcl/runtime/builtin/cd.pir trunk/languages/tcl/runtime/builtin/clock.pir trunk/languages/tcl/runtime/builtin/close.pir trunk/languages/tcl/runtime/builtin/continue.pir trunk/languages/tcl/runtime/builtin/dict.pir trunk/languages/tcl/runtime/builtin/encoding.pir trunk/languages/tcl/runtime/builtin/eof.pir trunk/languages/tcl/runtime/builtin/error.pir trunk/languages/tcl/runtime/builtin/eval.pir trunk/languages/tcl/runtime/builtin/exit.pir trunk/languages/tcl/runtime/builtin/expr.pir trunk/languages/tcl/runtime/builtin/file.pir trunk/languages/tcl/runtime/builtin/fileevent.pir trunk/languages/tcl/runtime/builtin/flush.pir trunk/languages/tcl/runtime/builtin/for.pir trunk/languages/tcl/runtime/builtin/foreach.pir trunk/languages/tcl/runtime/builtin/format.pir trunk/languages/tcl/runtime/builtin/gets.pir trunk/languages/tcl/runtime/builtin/global.pir trunk/languages/tcl/runtime/builtin/if.pir trunk/languages/tcl/runtime/builtin/incr.pir trunk/languages/tcl/runtime/builtin/info.pir trunk/languages/tcl/runtime/builtin/inline.pir trunk/languages/tcl/runtime/builtin/join.pir trunk/languages/tcl/runtime/builtin/lappend.pir trunk/languages/tcl/runtime/builtin/lassign.pir trunk/languages/tcl/runtime/builtin/lindex.pir trunk/languages/tcl/runtime/builtin/linsert.pir trunk/languages/tcl/runtime/builtin/llength.pir trunk/languages/tcl/runtime/builtin/lrange.pir trunk/languages/tcl/runtime/builtin/lrepeat.pir trunk/languages/tcl/runtime/builtin/lreplace.pir trunk/languages/tcl/runtime/builtin/lreverse.pir trunk/languages/tcl/runtime/builtin/lsearch.pir trunk/languages/tcl/runtime/builtin/lset.pir trunk/languages/tcl/runtime/builtin/lsort.pir trunk/languages/tcl/runtime/builtin/namespace.pir trunk/languages/tcl/runtime/builtin/open.pir trunk/languages/tcl/runtime/builtin/proc.pir trunk/languages/tcl/runtime/builtin/puts.pir trunk/languages/tcl/runtime/builtin/pwd.pir trunk/languages/tcl/runtime/builtin/regexp.pir trunk/languages/tcl/runtime/builtin/regsub.pir trunk/languages/tcl/runtime/builtin/rename.pir trunk/languages/tcl/runtime/builtin/return.pir trunk/languages/tcl/runtime/builtin/scan.pir trunk/languages/tcl/runtime/builtin/set.pir trunk/languages/tcl/runtime/builtin/socket.pir trunk/languages/tcl/runtime/builtin/source.pir trunk/languages/tcl/runtime/builtin/split.pir trunk/languages/tcl/runtime/builtin/string.pir trunk/languages/tcl/runtime/builtin/subst.pir trunk/languages/tcl/runtime/builtin/switch.pir trunk/languages/tcl/runtime/builtin/time.pir trunk/languages/tcl/runtime/builtin/unset.pir trunk/languages/tcl/runtime/builtin/uplevel.pir trunk/languages/tcl/runtime/builtin/upvar.pir trunk/languages/tcl/runtime/builtin/variable.pir trunk/languages/tcl/runtime/builtin/vwait.pir trunk/languages/tcl/runtime/builtin/while.pir trunk/languages/tcl/runtime/conversions.pir trunk/languages/tcl/runtime/options.pir trunk/languages/tcl/runtime/string_to_list.pir trunk/languages/tcl/runtime/variables.pir trunk/languages/tcl/src/grammar/expr/functions.pir trunk/languages/tcl/src/grammar/expr/operators.pir trunk/languages/tcl/src/grammar/expr/parse.pir trunk/languages/tcl/src/grammar/expr/past2pir.tg trunk/languages/tcl/src/grammar/expr/pge2past.tg trunk/languages/tcl/src/macros.pir trunk/languages/tcl/src/ops/tcl.ops trunk/languages/tcl/src/pmc/tclint.pmc trunk/languages/tcl/src/pmc/tcllist.pmc trunk/languages/tcl/src/pmc/tclstring.pmc trunk/languages/tcl/src/tclsh.pir trunk/lib/Parrot/OpTrans/CSwitch.pm trunk/lib/Parrot/Pmc2c/Attribute.pm trunk/lib/Parrot/Pmc2c/PCCMETHOD.pm trunk/lib/Parrot/Pmc2c/PMC/Null.pm trunk/lib/Parrot/Pmc2c/PMC/RO.pm trunk/runtime/parrot/library/Config/JSON.pir trunk/runtime/parrot/library/Crow.pir trunk/runtime/parrot/library/File/Spec/Unix.pir trunk/runtime/parrot/library/File/Spec/Win32.pir trunk/runtime/parrot/library/Getopt/Obj.pir trunk/runtime/parrot/library/PGE/Util.pir trunk/runtime/parrot/library/Parrot/Coroutine.pir trunk/runtime/parrot/library/Parrot/Exception.pir trunk/runtime/parrot/library/SDL.pir trunk/runtime/parrot/library/String/Utils.pir trunk/runtime/parrot/library/Test/Builder.pir trunk/runtime/parrot/library/Test/Builder/TestPlan.pir trunk/runtime/parrot/library/dumper.pir trunk/runtime/parrot/library/yaml_dumper.pir trunk/src/bignum.c trunk/src/bignum.h trunk/src/charset.c trunk/src/charset/ascii.c trunk/src/charset/binary.c trunk/src/charset/iso-8859-1.c trunk/src/charset/unicode.c trunk/src/debug.c trunk/src/dynext.c trunk/src/dynpmc/dynlexpad.pmc trunk/src/dynpmc/gdbmhash.pmc trunk/src/dynpmc/rational.pmc trunk/src/dynpmc/subproxy.pmc trunk/src/embed.c trunk/src/encoding.c trunk/src/encodings/fixed_8.c trunk/src/encodings/ucs2.c trunk/src/encodings/utf16.c trunk/src/encodings/utf8.c trunk/src/events.c trunk/src/exceptions.c trunk/src/exec_save.c trunk/src/gc/dod.c trunk/src/gc/gc_gms.c trunk/src/gc/register.c trunk/src/global.c trunk/src/hash.c trunk/src/headers.c trunk/src/hll.c trunk/src/inter_call.c trunk/src/inter_cb.c trunk/src/inter_create.c trunk/src/inter_misc.c trunk/src/inter_run.c trunk/src/interpreter.c trunk/src/io/io.c trunk/src/io/io_buf.c trunk/src/io/io_layers.c trunk/src/io/io_unix.c trunk/src/jit/alpha/jit_emit.h trunk/src/jit/amd64/jit_emit.h trunk/src/jit/arm/jit_emit.h trunk/src/jit/hppa/jit_emit.h trunk/src/jit/i386/jit_emit.h trunk/src/jit/ia64/jit_emit.h trunk/src/jit/mips/jit_emit.h trunk/src/jit/ppc/jit_emit.h trunk/src/jit/sun4/jit_emit.h trunk/src/key.c trunk/src/list.c trunk/src/mmd.c trunk/src/oo.c trunk/src/ops/core.ops trunk/src/ops/experimental.ops trunk/src/ops/io.ops trunk/src/ops/math.ops trunk/src/ops/object.ops trunk/src/ops/ops.num trunk/src/ops/ops.skip trunk/src/ops/pic.ops trunk/src/ops/pmc.ops trunk/src/ops/string.ops trunk/src/ops/sys.ops trunk/src/ops/var.ops trunk/src/packfile.c trunk/src/packfile/pf_items.c trunk/src/pic.c trunk/src/pmc.c trunk/src/pmc/array.pmc trunk/src/pmc/bigint.pmc trunk/src/pmc/bound_nci.pmc trunk/src/pmc/capture.pmc trunk/src/pmc/class.pmc trunk/src/pmc/complex.pmc trunk/src/pmc/continuation.pmc trunk/src/pmc/coroutine.pmc trunk/src/pmc/default.pmc trunk/src/pmc/delegate.pmc trunk/src/pmc/enumerate.pmc trunk/src/pmc/eval.pmc trunk/src/pmc/eventhandler.pmc trunk/src/pmc/exception.pmc trunk/src/pmc/exporter.pmc trunk/src/pmc/file.pmc trunk/src/pmc/fixedbooleanarray.pmc trunk/src/pmc/fixedfloatarray.pmc trunk/src/pmc/fixedintegerarray.pmc trunk/src/pmc/fixedpmcarray.pmc trunk/src/pmc/fixedstringarray.pmc trunk/src/pmc/hash.pmc trunk/src/pmc/integer.pmc trunk/src/pmc/intlist.pmc trunk/src/pmc/iterator.pmc trunk/src/pmc/key.pmc trunk/src/pmc/lexinfo.pmc trunk/src/pmc/lexpad.pmc trunk/src/pmc/multisub.pmc trunk/src/pmc/namespace.pmc trunk/src/pmc/nci.pmc trunk/src/pmc/object.pmc trunk/src/pmc/orderedhash.pmc trunk/src/pmc/os.pmc trunk/src/pmc/pair.pmc trunk/src/pmc/parrotinterpreter.pmc trunk/src/pmc/parrotio.pmc trunk/src/pmc/pmcproxy.pmc trunk/src/pmc/resizablebooleanarray.pmc trunk/src/pmc/resizablefloatarray.pmc trunk/src/pmc/resizableintegerarray.pmc trunk/src/pmc/resizablepmcarray.pmc trunk/src/pmc/resizablestringarray.pmc trunk/src/pmc/role.pmc trunk/src/pmc/sarray.pmc trunk/src/pmc/scalar.pmc trunk/src/pmc/scheduler.pmc trunk/src/pmc/schedulermessage.pmc trunk/src/pmc/sharedref.pmc trunk/src/pmc/slice.pmc trunk/src/pmc/string.pmc trunk/src/pmc/sub.pmc trunk/src/pmc/task.pmc trunk/src/pmc/timer.pmc trunk/src/pmc/unmanagedstruct.pmc trunk/src/pmc_freeze.c trunk/src/runops_cores.c trunk/src/scheduler.c trunk/src/spf_render.c trunk/src/spf_vtable.c trunk/src/stacks.c trunk/src/stm/backend.c trunk/src/string.c trunk/src/string_primitives.c trunk/src/sub.c trunk/src/thread.c trunk/src/trace.c trunk/src/tsq.c trunk/t/compilers/imcc/imcpasm/opt0.t trunk/t/compilers/imcc/imcpasm/optc.t trunk/t/compilers/pge/perl6regex/01-regex.t trunk/t/op/basic.t trunk/t/op/calling.t trunk/t/op/exceptions.t trunk/t/op/hacks.t trunk/t/op/pushaction.t trunk/t/pmc/continuation.t trunk/t/pmc/exception.t trunk/t/pmc/exception_handler.t trunk/t/pmc/signal.t trunk/t/pmc/sub.t trunk/t/src/basic.t trunk/t/src/extend.t trunk/t/steps/auto_pmc-01.t trunk/tools/build/nativecall.pl trunk/tools/util/crow.pir Log: [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949. Modified: trunk/docs/pdds/draft/pdd08_keys.pod ============================================================================== --- trunk/docs/pdds/draft/pdd08_keys.pod (original) +++ trunk/docs/pdds/draft/pdd08_keys.pod Sat Aug 2 15:45:13 2008 @@ -100,7 +100,7 @@ =item Todo -Need discussion on whether C<OUT_OF_BOUNDS> is a good exception for this, or +Need discussion on whether C<EXCEPTION_OUT_OF_BOUNDS> is a good exception for this, or whether something else should be used. It's really a compiler screw-up, since code which indexes a non-aggregate shouldn't be generated. Modified: trunk/docs/pdds/pdd17_pmc.pod ============================================================================== --- trunk/docs/pdds/pdd17_pmc.pod (original) +++ trunk/docs/pdds/pdd17_pmc.pod Sat Aug 2 15:45:13 2008 @@ -1867,7 +1867,7 @@ An extension of C<Sub> that provides dynamic code evaluation and execution. -=item Exception_Handler +=item ExceptionHandler A code object for handling exceptions. Modified: trunk/docs/pdds/pdd23_exceptions.pod ============================================================================== --- trunk/docs/pdds/pdd23_exceptions.pod (original) +++ trunk/docs/pdds/pdd23_exceptions.pod Sat Aug 2 15:45:13 2008 @@ -1,9 +1,6 @@ # Copyright (C) 2001-2007, The Perl Foundation. # $Id$ -{{ NOTE: "rethrow", and "pushaction" are removed, and "die" is different }} -{{ TODO: enable backtrace }} - =head1 NAME docs/pdds/pdd23_exceptions.pod - Parrot Exceptions @@ -72,35 +69,35 @@ Throw an exception consisting of the given I<EXCEPTION> PMC. Active exception handlers (if any) will be invoked with I<EXCEPTION> as the only parameter. -Throwing an exception with C<throw> is a one-way trip (unless you have made -other arrangements) because Parrot does not take a continuation after this -opcode. (But see B<throwcc> below.) - -Any type of PMC can be thrown as an exception. However, if there's any chance -of cross-language calls -- and in a Parrot environment, cross-language -operations are kind of the point -- then you should be prepared to catch -exception classes you would never have thrown yourself. -That said, it is I<VERY STRONGLY RECOMMENDED> that any thrown PMC that can -possibly escape your private sandbox should meet the minimal interface -requirements of the C<parrot;exception> class, described below. - -=item B<throwcc I<EXCEPTION> [ , I<CONTINUATION> ]> +=item B<throw I<EXCEPTION> [ , I<CONTINUATION> ]> Throw an exception consisting of the given I<EXCEPTION> PMC after taking a continuation at the next opcode. When a I<CONTINUATION> is passed in, it will use that instead. Active exception handlers (if any) will be invoked with I<EXCEPTION> and the given continuation as parameters. -Except for the continuation which is passed to exception handlers, -C<throwcc> is just like C<throw>. This opcode is useful for exceptions -that are more like warnings or notices than errors. - -Exception handlers can resume execution immediately after the C<throwcc> -opcode by executing the C<handled> opcode, and then invoking the given -continuation which they receive as a parameter. That continuation must be -invoked with no parameters; in other words, C<throwcc> never returns a -value. +Any type of PMC can be thrown as an exception. However, if there's any chance +of cross-language calls -- and in a Parrot environment, cross-language +operations are kind of the point -- then you should be prepared to catch +exception classes you would never have thrown yourself. + +That said, it is recommended that any thrown PMC that can possibly escape your +private sandbox should meet the minimal interface requirements of the +C<parrot;exception> class, described below. + +Exception handlers can resume execution immediately after the C<throw> opcode +by invoking the resume continuation which is stored in the exception object. +That continuation must be invoked with no parameters; in other words, C<throw> +never returns a value. + +=item B<rethrow I<EXCEPTION>> + +While handling an exception, rethrow the exception to the next handler. Aside +from selecting a different handler, the behaviour of C<rethrow> is the same as +C<throw>. Each successive call to C<rethrow> will select a different handler, +until it exhausts the list of possible handlers. A rethrown exception that +is not handled behaves the same as an unhandled C<throw>n exception. =item B<die [ I<MESSAGE> ]> @@ -115,7 +112,8 @@ If this exception is not handled, it results in Parrot returning an error indication and the stringification of I<MESSAGE> to its embedding environment. When running standalone, this means writing the stringification of I<MESSAGE> -to standard error and executing the standard C function C<exit(EXIT_FAILURE)>. +to standard error and executing the standard Parrot function C<Parrot_exit>, to +shut down the interpreter cleanly. =item B<exit [ I<EXITCODE> ]> @@ -126,12 +124,6 @@ as a status to its embedded environment, or when running standalone, to execute the C function C<exit(I<EXITCODE>)>. -=item B<handled I<EXCEPTION>> - -While handling an exception, tell Parrot that the exception has been handled -and should be removed from the stack of active exceptions. This opcode is an -exception handler's way of telling Parrot that it has handled the exception. - =back =head2 Exception Introspection Opcodes @@ -145,22 +137,12 @@ Return the quantity of currently active exception handlers. -=item B<get_eh I<index>> - -Return the exception handler at I<index>. The index is an offset from the top -of the stack, with '0' being the top. - -=item B<get_all_eh> - -Return a resizable pmc array of all current exception handlers. - =back =head2 Order of Operations in Exception Handling -When B<throw> or B<throwcc> is called, for all active exception -handlers, in LIFO order: +When B<throw> is called, for all active exception handlers, in LIFO order: =over @@ -169,38 +151,26 @@ =item 2 Push an exception record somewhere, presumably on the exception handler -stack. The exception record contains a pointer to an exception handler +stack. The exception record contains a pointer to an exception handler block, an exception PMC, and (optionally) a continuation. =item 3 Invoke the handler (note: this is still in the thrower's dynamic context). -=back - -If the handler returns without calling C<handled>: - -=over - -=item 1 -Find the "exception handling in progress" record. - -=item 2 -Find the next exception handler. - -=item 3 -If the handler is found, invoke it. - - =item 4 +If the handler is C<rethrow>n, repeat steps 1-3 above, finding the next +exception handler. + +=item 5 If no handler is found, and the exception is non-fatal (such as a warning), and there is a continuation in the exception record (because -the throwing opcode was C<throwcc>), invoke the continuation (resume +the throwing opcode was C<throw>), invoke the continuation (resume execution). Whether to resume or die when an exception isn't handled is determined by the severity of the exception. -=item 5 -Otherwise terminate program a la C<die>. +=item 6 +Otherwise terminate the program like C<die>. =back @@ -211,21 +181,6 @@ may choose to handle the exception and continue execution by invoking the exception's continuation. - -When the C<handled> opcode is called: - -=over - -=item 1 -Pop and destroy the exception record. - -=item 2 -If there was a continuation in the exception record, invoke the -continuation. - -=back - - =head1 IMPLEMENTATION =head2 Exception Object Interface