[svn:parrot] r40682 - in branches/context_pmc2: . compilers/pirc/src config/gen docs/project include/parrot lib/Parrot lib/Parrot/Pmc2c runtime/parrot/library/PGE src src/interp src/jit/i386 src/pmc t/op

bacek at svn.parrot.org bacek at svn.parrot.org
Thu Aug 20 23:03:04 UTC 2009


Author: bacek
Date: Thu Aug 20 23:03:02 2009
New Revision: 40682
URL: https://trac.parrot.org/parrot/changeset/40682

Log:
Bring branch up-to-date with trunk

Conflicts:
	docs/project/release_manager_guide.pod
	include/parrot/sub.h
	src/gc/alloc_register.c
	src/pmc/continuation.pmc
	src/pmc/exception.pmc
	src/pmc/lexpad.pmc
	src/pmc/sub.pmc
	src/sub.c

Added:
   branches/context_pmc2/t/op/exit.t
Modified:
   branches/context_pmc2/MANIFEST
   branches/context_pmc2/PLATFORMS
   branches/context_pmc2/README
   branches/context_pmc2/compilers/pirc/src/bcgen.c
   branches/context_pmc2/config/gen/core_pmcs.pm
   branches/context_pmc2/docs/project/release_manager_guide.pod
   branches/context_pmc2/include/parrot/global_setup.h
   branches/context_pmc2/include/parrot/sub.h
   branches/context_pmc2/include/parrot/vtables.h
   branches/context_pmc2/lib/Parrot/Pmc2c/PMCEmitter.pm
   branches/context_pmc2/lib/Parrot/Test.pm
   branches/context_pmc2/runtime/parrot/library/PGE/Text.pir
   branches/context_pmc2/src/global_setup.c
   branches/context_pmc2/src/interp/inter_create.c
   branches/context_pmc2/src/jit/i386/jit_defs.c
   branches/context_pmc2/src/jit/i386/jit_emit.h
   branches/context_pmc2/src/pmc/hashiterator.pmc
   branches/context_pmc2/src/pmc/sub.pmc
   branches/context_pmc2/src/vtables.c
   branches/context_pmc2/t/op/arithmetics.t

Modified: branches/context_pmc2/MANIFEST
==============================================================================
--- branches/context_pmc2/MANIFEST	Thu Aug 20 22:35:02 2009	(r40681)
+++ branches/context_pmc2/MANIFEST	Thu Aug 20 23:03:02 2009	(r40682)
@@ -1791,6 +1791,7 @@
 t/op/copy.t                                                 [test]
 t/op/debuginfo.t                                            [test]
 t/op/exceptions.t                                           [test]
+t/op/exit.t                                                 [test]
 t/op/gc.t                                                   [test]
 t/op/globals.t                                              [test]
 t/op/hacks.t                                                [test]

Modified: branches/context_pmc2/PLATFORMS
==============================================================================
--- branches/context_pmc2/PLATFORMS	Thu Aug 20 22:35:02 2009	(r40681)
+++ branches/context_pmc2/PLATFORMS	Thu Aug 20 23:03:02 2009	(r40682)
@@ -20,12 +20,12 @@
 linux-x86-gcc4.2.3                Y    Y    ?     Y   Y   Y    Y     ?  20080715
 linux-x86-gcc4.2.4                Y    Y    ?     Y   Y   Y    Y     ?  20081023
 linux-x86-gcc4.3.2                Y    Y    ?     Y   Y   Y    Y     ?  20081030
-linux-x86-llvm-gcc-4.2            Y    Y    ?     ?   ?   Y    Y     ?  20090514
+linux-x86-llvm-gcc-4.2            Y    Y    ?     ?   ?   Y    Y     ?  20090819
 sol10-sparc-cc_5.9           B4   Y    -    -     Y   Y   Y    Y     ?  20090720
 sol10-sparc-cc_5.9           B8   Y    -    -     Y   Y   Y    Y     ?  20090720
 sol10-sparc-gcc_4.0.2        B4   Y    -    -     Y   Y   Y    Y/1   ?  20080510
 sol10-sparc-gcc_4.0.2        B8   Y    -    -     Y   Y   Y    Y/2   ?  20080518
-win32-x86-mingw_gcc3.4.5          Y    Y    -     -   -   Y    Y     Y  20090421
+win32-x86-mingw_gcc3.4.5          Y    Y    -     -   -   Y    Y/1   Y  20090818
 win32-x86-msvc_9.0                -    Y    -     Y   -   Y    Y     ?  20090317
 
 

Modified: branches/context_pmc2/README
==============================================================================
--- branches/context_pmc2/README	Thu Aug 20 22:35:02 2009	(r40681)
+++ branches/context_pmc2/README	Thu Aug 20 23:03:02 2009	(r40682)
@@ -85,6 +85,13 @@
 But please note that dynamic libs will not be found for non-standard
 locations unless you set LD_LIBRARY_PATH or similar.
 
+If you want to build high level languages on top of Parrot, you should
+also run
+
+    make install-dev
+
+to install development files which compilers need in their build process.
+
 Look at docs/parrot.pod and docs/intro.pod for where to go from here.  If you
 have any problems, see the section "How To Submit A Bug Report" in
 docs/submissions.pod.  These documents are in POD format. You can view these

Modified: branches/context_pmc2/compilers/pirc/src/bcgen.c
==============================================================================
--- branches/context_pmc2/compilers/pirc/src/bcgen.c	Thu Aug 20 22:35:02 2009	(r40681)
+++ branches/context_pmc2/compilers/pirc/src/bcgen.c	Thu Aug 20 23:03:02 2009	(r40682)
@@ -910,7 +910,7 @@
 {
     ASSERT_ARGS(find_outer_sub)
     PMC          *current;
-    Parrot_sub   *sub;
+    Parrot_Sub_attributes *sub;
     STRING       *cur_name;
     size_t        len;
     global_label *outersub;
@@ -1131,7 +1131,7 @@
 {
     ASSERT_ARGS(add_sub_pmc)
     PMC                   *sub_pmc;        /* the "Sub" pmc, or a variant, such as "Coroutine" */
-    Parrot_sub            *sub;
+    Parrot_Sub_attributes *sub;
     int                    subconst_index; /* index in const table for the sub pmc */
     int                    subname_index;
     int                    i;              /* for loop iterator */

Modified: branches/context_pmc2/config/gen/core_pmcs.pm
==============================================================================
--- branches/context_pmc2/config/gen/core_pmcs.pm	Thu Aug 20 22:35:02 2009	(r40681)
+++ branches/context_pmc2/config/gen/core_pmcs.pm	Thu Aug 20 23:03:02 2009	(r40682)
@@ -116,26 +116,20 @@
     __attribute__nonnull__(1)
     __attribute__nonnull__(2);
 
-extern void Parrot_initialize_core_pmcs(PARROT_INTERP)
+extern void Parrot_initialize_core_pmcs(PARROT_INTERP, int pass)
     __attribute__nonnull__(1);
 
-void Parrot_initialize_core_pmcs(PARROT_INTERP)
+void Parrot_initialize_core_pmcs(PARROT_INTERP, int pass)
 {
-    int pass;
-    for (pass = 0; pass <= 1; ++pass) {
-        /* first the PMC with the highest enum
-         * this reduces MMD table resize action */
+    /* first the PMC with the highest enum
+     * this reduces MMD table resize action */
 END_C
 
-    print {$OUT} "        Parrot_${_}_class_init(interp, enum_class_${_}, pass);\n"
+    print {$OUT} "    Parrot_${_}_class_init(interp, enum_class_${_}, pass);\n"
         foreach ( @pmcs[ -1 .. -1 ] );
-    print {$OUT} "        Parrot_${_}_class_init(interp, enum_class_${_}, pass);\n"
+    print {$OUT} "    Parrot_${_}_class_init(interp, enum_class_${_}, pass);\n"
         foreach ( @pmcs[ 0 .. $#pmcs - 1 ] );
     print {$OUT} <<'END_C';
-        if (!pass) {
-            parrot_global_setup_2(interp);
-        }
-    }
 }
 
 static void register_pmc(PARROT_INTERP, NOTNULL(PMC *registry), int pmc_id)

Modified: branches/context_pmc2/docs/project/release_manager_guide.pod
==============================================================================
--- branches/context_pmc2/docs/project/release_manager_guide.pod	Thu Aug 20 22:35:02 2009	(r40681)
+++ branches/context_pmc2/docs/project/release_manager_guide.pod	Thu Aug 20 23:03:02 2009	(r40682)
@@ -366,8 +366,8 @@
 
  - Sept 15, 2009     - 1.6  - particle
  - Oct 20, 2009      - 1.7  - dukeleto
- - Nov 17, 2009      - 1.8  -
- - Dec 15, 2009      - 1.9  -
+ - Nov 17, 2009      - 1.8  - bernhard
+ - Dec 15, 2009      - 1.9  - gerd
  - Jan 19, 2010      - 2.0* -
 
 =cut

Modified: branches/context_pmc2/include/parrot/global_setup.h
==============================================================================
--- branches/context_pmc2/include/parrot/global_setup.h	Thu Aug 20 22:35:02 2009	(r40681)
+++ branches/context_pmc2/include/parrot/global_setup.h	Thu Aug 20 23:03:02 2009	(r40682)
@@ -32,9 +32,6 @@
 void init_world_once(PARROT_INTERP)
         __attribute__nonnull__(1);
 
-void parrot_global_setup_2(PARROT_INTERP)
-        __attribute__nonnull__(1);
-
 #define ASSERT_ARGS_Parrot_set_config_hash_internal \
      __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(parrot_config)
@@ -42,8 +39,6 @@
        PARROT_ASSERT_ARG(interp)
 #define ASSERT_ARGS_init_world_once __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_parrot_global_setup_2 __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp)
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 /* HEADERIZER END: src/global_setup.c */
 

Modified: branches/context_pmc2/include/parrot/sub.h
==============================================================================
--- branches/context_pmc2/include/parrot/sub.h	Thu Aug 20 22:35:02 2009	(r40681)
+++ branches/context_pmc2/include/parrot/sub.h	Thu Aug 20 23:03:02 2009	(r40682)
@@ -150,6 +150,9 @@
         } \
     } while (0)
 
+typedef struct Parrot_Sub_attributes Parrot_sub;
+typedef struct Parrot_Coroutine_attributes Parrot_coro;
+
 typedef struct Parrot_cont {
     /* continuation destination */
     PackFile_ByteCode *seg;          /* bytecode segment */

Modified: branches/context_pmc2/include/parrot/vtables.h
==============================================================================
--- branches/context_pmc2/include/parrot/vtables.h	Thu Aug 20 22:35:02 2009	(r40681)
+++ branches/context_pmc2/include/parrot/vtables.h	Thu Aug 20 23:03:02 2009	(r40682)
@@ -32,6 +32,10 @@
         FUNC_MODIFIES(*vtable);
 
 PARROT_EXPORT
+void Parrot_initialize_core_vtables(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+PARROT_EXPORT
 PARROT_MALLOC
 PARROT_CANNOT_RETURN_NULL
 VTABLE * Parrot_new_vtable(SHIM_INTERP);
@@ -54,6 +58,9 @@
 #define ASSERT_ARGS_Parrot_destroy_vtable __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp) \
     || PARROT_ASSERT_ARG(vtable)
+#define ASSERT_ARGS_Parrot_initialize_core_vtables \
+     __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
 #define ASSERT_ARGS_Parrot_new_vtable __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
 #define ASSERT_ARGS_mark_vtables __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp)

Modified: branches/context_pmc2/lib/Parrot/Pmc2c/PMCEmitter.pm
==============================================================================
--- branches/context_pmc2/lib/Parrot/Pmc2c/PMCEmitter.pm	Thu Aug 20 22:35:02 2009	(r40681)
+++ branches/context_pmc2/lib/Parrot/Pmc2c/PMCEmitter.pm	Thu Aug 20 23:03:02 2009	(r40682)
@@ -584,14 +584,6 @@
     $cout .= "\";\n";
 
     my $const = ( $self->{flags}{dynpmc} ) ? " " : " const ";
-    if ( @$multi_funcs ) {
-        $cout .= $multi_strings . <<"EOC";
-
-   $const multi_func_list _temp_multi_func_list[] = {
-        $multi_list
-    };
-EOC
-    }
 
     my $flags = $self->vtable_flags;
     $cout .= <<"EOC";
@@ -732,7 +724,11 @@
 
 
     if ( @$multi_funcs ) {
-        $cout .= <<"EOC";
+        $cout .= $multi_strings . <<"EOC";
+
+            $const multi_func_list _temp_multi_func_list[] = {
+                $multi_list
+            };
 #define N_MULTI_LIST (sizeof(_temp_multi_func_list)/sizeof(_temp_multi_func_list[0]))
             Parrot_mmd_add_multi_list_from_c_args(interp,
                 _temp_multi_func_list, N_MULTI_LIST);

Modified: branches/context_pmc2/lib/Parrot/Test.pm
==============================================================================
--- branches/context_pmc2/lib/Parrot/Test.pm	Thu Aug 20 22:35:02 2009	(r40681)
+++ branches/context_pmc2/lib/Parrot/Test.pm	Thu Aug 20 23:03:02 2009	(r40682)
@@ -100,6 +100,11 @@
 the output with the unexpected result is false I<and> if Parrot exits with a
 non-zero exit code.
 
+=item C<pasm_exit_code_is($code, $exit_code, $description)>
+
+Runs the PASM code and passes the test if the exit code equals $exit_code,
+fails the test otherwise.
+
 =item C<pir_output_is($code, $expected, $description)>
 
 Runs the PIR code and passes the test if a string comparison of output with the
@@ -130,6 +135,11 @@
 the unexpected result is false I<and> if Parrot exits with a non-zero exit
 code.
 
+=item C<pir_exit_code_is($code, $exit_code, $description)>
+
+Runs the PIR code and passes the test if the exit code equals $exit_code,
+fails the test otherwise.
+
 =item C<pbc_output_is($code, $expected, $description)>
 
 Runs the Parrot Bytecode and passes the test if a string comparison of output
@@ -161,6 +171,11 @@
 with the unexpected result is false I<and> if Parrot exits with a non-zero exit
 code.
 
+=item C<pbc_exit_code_is($code, $exit_code, $description)>
+
+Runs the Parrot Bytecode and passes the test if the exit code equals $exit_code,
+fails the test otherwise.
+
 =item C<pir_2_pasm_is($code, $expected, $description)>
 
 Compile the Parrot Intermediate Representation and generate Parrot Assembler Code.
@@ -579,13 +594,13 @@
     # Name of the file with test code.
     # This depends on which kind of code we are testing.
     my $code_f;
-    if ( $func =~ m/^pir_.*?output/ ) {
+    if ( $func =~ m/^pir_(exit_code|.*?output)/ ) {
         $code_f = per_test( '.pir', $test_no );
     }
-    elsif ( $func =~ m/^pasm_.*?output_/ ) {
+    elsif ( $func =~ m/^pasm_(exit_code|.*?output_)/ ) {
         $code_f = per_test( '.pasm', $test_no );
     }
-    elsif ( $func =~ m/^pbc_.*?output_/ ) {
+    elsif ( $func =~ m/^pbc_(exit_code|.*?output_)/ ) {
         $code_f = per_test( '.pbc', $test_no );
     }
     else {
@@ -684,6 +699,7 @@
     my %parrot_test_map = map {
         $_ . '_output_is'           => 'is_eq',
         $_ . '_error_output_is'     => 'is_eq',
+        $_ . '_exit_code_is'        => 'is_eq',
         $_ . '_output_isnt'         => 'isnt_eq',
         $_ . '_error_output_isnt'   => 'isnt_eq',
         $_ . '_output_like'         => 'like',
@@ -723,6 +739,18 @@
                 \$extra{todo}
                 if defined $extra{todo};
 
+            if ( $func =~ /_exit_code_is$/ ) {
+                $expected = int($expected);
+                if ($exit_code == $expected) {
+                    my $pass = $builder->$meth( $exit_code, $expected, $desc );
+                    return $pass;
+                }
+                else {
+                    $builder->ok(0);
+                    return 0;
+                }
+            }
+
             if ( $func =~ /_error_/ ) {
                 return _handle_error_output( $builder, $real_output, $expected, $desc )
                     unless $exit_code;

Modified: branches/context_pmc2/runtime/parrot/library/PGE/Text.pir
==============================================================================
--- branches/context_pmc2/runtime/parrot/library/PGE/Text.pir	Thu Aug 20 22:35:02 2009	(r40681)
+++ branches/context_pmc2/runtime/parrot/library/PGE/Text.pir	Thu Aug 20 23:03:02 2009	(r40682)
@@ -50,7 +50,6 @@
     .local int balanced                            # in balanced match
     .local pmc stack                               # lookket backtracking
 
-    stack = new 'ResizableStringArray'
     $P0 = get_hll_global ['PGE'], 'Match'
     (mob, pos, target) = $P0.'new'(tgt)
     from = pos
@@ -88,6 +87,7 @@
     if $I0 < 0 goto end                            # no leading delim fails
     lookket = ''
     balanced = 1
+    stack = new 'ResizableStringArray'
   next:
     $S0 = substr target, pos, 1                    # check current pos
     if $S0 == '' goto fail                         # end of string -> fail

Modified: branches/context_pmc2/src/global_setup.c
==============================================================================
--- branches/context_pmc2/src/global_setup.c	Thu Aug 20 22:35:02 2009	(r40681)
+++ branches/context_pmc2/src/global_setup.c	Thu Aug 20 23:03:02 2009	(r40682)
@@ -28,7 +28,7 @@
 
 /* These functions are defined in the auto-generated file core_pmcs.c */
 /* XXX Get it into some public place */
-extern void Parrot_initialize_core_pmcs(PARROT_INTERP);
+extern void Parrot_initialize_core_pmcs(PARROT_INTERP, int pass);
 void Parrot_register_core_pmcs(PARROT_INTERP, PMC* registry);
 
 static const unsigned char* parrot_config_stored = NULL;
@@ -39,9 +39,14 @@
 /* HEADERIZER BEGIN: static */
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 
+static void parrot_global_setup_2(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
 static void parrot_set_config_hash_interpreter(PARROT_INTERP)
         __attribute__nonnull__(1);
 
+#define ASSERT_ARGS_parrot_global_setup_2 __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
 #define ASSERT_ARGS_parrot_set_config_hash_interpreter \
      __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp)
@@ -160,10 +165,9 @@
     Parrot_platform_init_code();
 #endif
 
-    parrot_alloc_vtables(interp);
-
     /* Call base vtable class constructor methods */
-    Parrot_initialize_core_pmcs(interp);
+    parrot_global_setup_2(interp);
+    Parrot_initialize_core_pmcs(interp, 1);
 
     iglobals = interp->iglobals;
     VTABLE_set_pmc_keyed_int(interp, iglobals,
@@ -191,7 +195,7 @@
 
 /*
 
-=item C<void parrot_global_setup_2(PARROT_INTERP)>
+=item C<static void parrot_global_setup_2(PARROT_INTERP)>
 
 called from inmidst of PMC bootstrapping between pass 0 and 1
 
@@ -199,7 +203,7 @@
 
 */
 
-void
+static void
 parrot_global_setup_2(PARROT_INTERP)
 {
     ASSERT_ARGS(parrot_global_setup_2)

Modified: branches/context_pmc2/src/interp/inter_create.c
==============================================================================
--- branches/context_pmc2/src/interp/inter_create.c	Thu Aug 20 22:35:02 2009	(r40681)
+++ branches/context_pmc2/src/interp/inter_create.c	Thu Aug 20 23:03:02 2009	(r40682)
@@ -180,6 +180,8 @@
      */
     Parrot_str_init(interp);
 
+    Parrot_initialize_core_vtables(interp);
+
     /* Set up the MMD struct */
     interp->binop_mmd_funcs = NULL;
 

Modified: branches/context_pmc2/src/jit/i386/jit_defs.c
==============================================================================
--- branches/context_pmc2/src/jit/i386/jit_defs.c	Thu Aug 20 22:35:02 2009	(r40681)
+++ branches/context_pmc2/src/jit/i386/jit_defs.c	Thu Aug 20 23:03:02 2009	(r40682)
@@ -1216,55 +1216,6 @@
        jit_info->native_ptr, (f)); \
        emitm_calll(jit_info->native_ptr, EXEC_CALLDISP);
 
-/* new_p_ic */
-void
-Parrot_jit_vtable_newp_ic_op(Parrot_jit_info_t *jit_info,
-                     PARROT_INTERP)
-{
-    int p1, i2;
-    op_info_t *op_info = &interp->op_info_table[*jit_info->cur_op];
-    size_t offset = offsetof(VTABLE, init);
-
-    PARROT_ASSERT(op_info->types[0] == PARROT_ARG_P);
-    p1 = *(jit_info->cur_op + 1);
-    i2 = *(jit_info->cur_op + 2);
-
-    if (i2 <= 0 || i2 >= interp->n_vtable_max)
-        Parrot_ex_throw_from_c_args(interp, NULL, 1,
-            "Illegal PMC enum (%d) in new", i2);
-
-    /* get interpreter */
-    Parrot_jit_emit_get_INTERP(interp, jit_info->native_ptr, emit_ECX);
-
-    /* push pmc enum and interpreter */
-    emitm_pushl_i(jit_info->native_ptr, i2);
-    emitm_pushl_r(jit_info->native_ptr, emit_ECX);
-#if EXEC_CAPABLE
-    if (jit_info->objfile) {
-        CALL("pmc_new_noinit");
-    }
-    else
-#endif
-    {
-        call_func(jit_info, (void (*) (void))pmc_new_noinit);
-    }
-    /* result = eax push pmc */
-    emitm_pushl_r(jit_info->native_ptr, emit_EAX);
-    /* store in PMC too */
-    emitm_movl_r_m(interp, jit_info->native_ptr,
-            emit_EAX, emit_EBX, emit_None, 1, REG_OFFS_PMC(p1));
-    /* push interpreter */
-    Parrot_jit_emit_get_INTERP(interp, jit_info->native_ptr, emit_ECX);
-    emitm_pushl_r(jit_info->native_ptr, emit_ECX);
-    /* mov (offs)%eax, %eax i.e. $1->vtable */
-    emitm_movl_m_r(interp, jit_info->native_ptr, emit_EAX, emit_EAX, emit_None, 1,
-            offsetof(struct PMC, vtable));
-    /* call *(offset)eax */
-    emitm_callm(jit_info->native_ptr, emit_EAX, emit_None, emit_None, offset);
-    /* adjust 4 args pushed */
-    emitm_addb_i_r(jit_info->native_ptr, 16, emit_ESP);
-}
-
 #  undef IREG
 #  undef NREG
 #  undef SREG

Modified: branches/context_pmc2/src/jit/i386/jit_emit.h
==============================================================================
--- branches/context_pmc2/src/jit/i386/jit_emit.h	Thu Aug 20 22:35:02 2009	(r40681)
+++ branches/context_pmc2/src/jit/i386/jit_emit.h	Thu Aug 20 23:03:02 2009	(r40682)
@@ -1661,9 +1661,6 @@
 /* if_p_ic */
 void Parrot_jit_vtable_ifp_op(Parrot_jit_info_t *jit_info, PARROT_INTERP);
 
-/* new_p_ic */
-void Parrot_jit_vtable_newp_ic_op(Parrot_jit_info_t *jit_info, PARROT_INTERP);
-
 #endif /* JIT_VTABLE_OPS */
 
 #if EXEC_CAPABLE

Modified: branches/context_pmc2/src/pmc/hashiterator.pmc
==============================================================================
--- branches/context_pmc2/src/pmc/hashiterator.pmc	Thu Aug 20 22:35:02 2009	(r40681)
+++ branches/context_pmc2/src/pmc/hashiterator.pmc	Thu Aug 20 23:03:02 2009	(r40682)
@@ -246,8 +246,10 @@
 */
 
     VTABLE STRING* shift_string() {
-        PMC * const key = SELF.shift_pmc();
-        return VTABLE_get_string(INTERP, key);
+        PMC    * const key = SELF.shift_pmc();
+        STRING * const ret = VTABLE_get_string(INTERP, key);
+        temporary_pmc_free(INTERP, key);
+        return ret;
     }
 
 }

Modified: branches/context_pmc2/src/pmc/sub.pmc
==============================================================================
--- branches/context_pmc2/src/pmc/sub.pmc	Thu Aug 20 22:35:02 2009	(r40681)
+++ branches/context_pmc2/src/pmc/sub.pmc	Thu Aug 20 23:03:02 2009	(r40682)
@@ -140,7 +140,9 @@
 */
 
     VTABLE STRING *get_string() {
-        Parrot_Sub_attributes *sub = PARROT_SUB(SELF);
+        STRING *name;
+        Parrot_Sub_attributes *sub;
+        PMC_get_sub(INTERP, SELF, sub);
 
         if (sub->name)
             return Parrot_str_copy(INTERP, sub->name);
@@ -149,7 +151,8 @@
     }
 
     VTABLE void set_string_native(STRING *subname) {
-        Parrot_Sub_attributes *sub = PARROT_SUB(SELF);
+        Parrot_Sub_attributes *sub;
+        PMC_get_sub(INTERP, SELF, sub);
         sub->name = Parrot_str_copy(INTERP, subname);
     }
 
@@ -182,7 +185,8 @@
 */
 
     VTABLE void *get_pointer() {
-        Parrot_Sub_attributes *sub = PARROT_SUB(SELF);
+        Parrot_Sub_attributes *sub;
+        PMC_get_sub(INTERP, SELF, sub);
         return sub->seg->base.data + sub->start_offs;
     }
 
@@ -199,8 +203,9 @@
 */
 
     VTABLE INTVAL get_integer_keyed(PMC *key) {
-        Parrot_Sub_attributes *sub = PARROT_SUB(SELF);
+        Parrot_Sub_attributes *sub;
         UNUSED(key)
+        PMC_get_sub(INTERP, SELF, sub);
 
         return (INTVAL) (sub->seg->base.data);
     }
@@ -236,7 +241,7 @@
 */
 
     VTABLE opcode_t *invoke(void *next) {
-        Parrot_Sub_attributes *sub = PARROT_SUB(SELF);
+        Parrot_Sub_attributes *sub;
         PMC            *caller_ctx;
         PMC            *context;
         PMC            *ccont;
@@ -397,14 +402,15 @@
 
     VTABLE PMC *clone() {
         PMC        * const ret = pmc_new(INTERP, SELF->vtable->base_type);
-        Parrot_Sub_attributes *dest_sub = PARROT_SUB(SELF);
+        Parrot_Sub_attributes *dest_sub;
         Parrot_Sub_attributes *sub;
 
         /* XXX Why? */
         /* we have to mark it ourselves */
         PObj_custom_mark_destroy_SETALL(ret);
 
-        sub = PARROT_SUB(ret);
+        PMC_get_sub(INTERP, SELF, dest_sub);
+        PMC_get_sub(INTERP, ret, sub);
 
         /* first set the sub struct, Parrot_str_copy may cause GC */
         *sub = *dest_sub;
@@ -435,8 +441,11 @@
     VTABLE void assign_pmc(PMC *other) {
         /* only handle the case where the other PMC is the same type */
         if (other->vtable->base_type == SELF->vtable->base_type) {
-            Parrot_Sub_attributes *my_sub = PARROT_SUB(SELF);
-            Parrot_Sub_attributes *other_sub = PARROT_SUB(other);
+            Parrot_Sub_attributes *my_sub;
+            Parrot_Sub_attributes *other_sub;
+
+            PMC_get_sub(INTERP, SELF, my_sub);
+            PMC_get_sub(INTERP, other, other_sub);
 
             /* copy the sub struct */
             memmove(my_sub, other_sub, sizeof (Parrot_Sub_attributes));
@@ -504,8 +513,11 @@
 */
 
     MULTI INTVAL is_equal(PMC *value) {
-        Parrot_Sub_attributes *my_sub = PARROT_SUB(SELF);
-        Parrot_Sub_attributes *value_sub = PARROT_SUB(value);
+        Parrot_Sub_attributes *my_sub;
+        Parrot_Sub_attributes *value_sub;
+
+        PMC_get_sub(INTERP, SELF, my_sub);
+        PMC_get_sub(INTERP, value, value_sub);
 
         return SELF->vtable         == value->vtable
         &&     (my_sub)->start_offs == (value_sub)->start_offs
@@ -554,12 +566,13 @@
     }
 
     VTABLE void freeze(visit_info *info) {
-        IMAGE_IO   * const io  = info->image_io;
-        Parrot_Sub_attributes *sub = PARROT_SUB(SELF);
-        STRING            *hll_name;
+        IMAGE_IO       * const io  = info->image_io;
+        Parrot_Sub_attributes *sub;
+        STRING                *hll_name;
         int i;
 
         SUPER(info);
+        PMC_get_sub(INTERP, SELF, sub);
         /*
          * we currently need to write these items:
          * - start offset in byte-code segment
@@ -736,10 +749,12 @@
 
     VTABLE PMC *inspect_str(STRING *what)
     {
-        Parrot_Sub_attributes *sub = PARROT_SUB(SELF);
+        Parrot_Sub_attributes *sub;
         PMC                   *retval;
         INTVAL                 count_found = -1;
 
+        PMC_get_sub(INTERP, SELF, sub);
+
         /* If the argument info hasn't been generated yet, generate it. */
         if (!sub->arg_info) {
             /* Get pointer into the bytecode where this sub starts. */
@@ -860,8 +875,15 @@
 */
 
     METHOD get_namespace() {
-        Parrot_Sub_attributes *sub = PARROT_SUB(SELF);
-        PMC *_namespace = sub->namespace_stash;
+        PMC *_namespace;
+        Parrot_Sub_attributes *sub;
+        PMC_get_sub(INTERP, SELF, sub);
+        /*
+        XXX Rakudo's failing with with this code on ASSERT. Why???
+        GET_ATTR_namespace_stash(INTERP, SELF, _namespace);
+        PARROT_ASSERT(_namespace == sub->namespace_stash || !"consistency!!!");
+        */
+        _namespace = sub->namespace_stash;
         RETURN(PMC *_namespace);
     }
 
@@ -871,10 +893,11 @@
          * see also imcc/reg_alloc.c */
         static const char types[] = "INSP";
         char *p;
-        Parrot_Sub_attributes *sub = PARROT_SUB(SELF);
+        Parrot_Sub_attributes *sub;
         char          * const kind = Parrot_str_to_cstring(interp, reg);
         INTVAL                regs_used;
 
+        PMC_get_sub(INTERP, SELF, sub);
         PARROT_ASSERT(sub->n_regs_used);
 
         if (!*kind || kind[1]) {
@@ -895,33 +918,40 @@
     }
 
     METHOD get_lexinfo() {
-        Parrot_Sub_attributes *sub = PARROT_SUB(SELF);
         PMC        *lexinfo;
+        Parrot_Sub_attributes *sub;
+        PMC_get_sub(INTERP, SELF, sub);
+
+        lexinfo = sub->lex_info ? sub->lex_info: PMCNULL;
 
-        lexinfo = sub->lex_info ? sub->lex_info : PMCNULL;
         RETURN(PMC *lexinfo);
     }
 
     METHOD get_subid() {
-        Parrot_Sub_attributes *sub = PARROT_SUB(SELF);
         STRING     *subid;
+        Parrot_Sub_attributes *sub;
+        PMC_get_sub(INTERP, SELF, sub);
 
         subid = sub->subid ? sub->subid : CONST_STRING(interp, "");
+
         RETURN(STRING *subid);
     }
 
     METHOD get_outer() {
-        Parrot_Sub_attributes *sub = PARROT_SUB(SELF);
-        PMC        *outersub;
+        PMC                   *outersub;
+        Parrot_Sub_attributes *sub;
+        PMC_get_sub(INTERP, SELF, sub);
 
         outersub = sub->outer_sub ? sub->outer_sub : PMCNULL;
+
         RETURN(PMC *outersub);
     }
 
     METHOD set_outer(PMC *outer) {
         /* Set outer sub. */
-        Parrot_Sub_attributes     *sub = PARROT_SUB(SELF);
-        PMC                       *ctx;
+        PMC                   *ctx;
+        Parrot_Sub_attributes *sub;
+        PMC_get_sub(INTERP, SELF, sub);
 
         sub->outer_sub = outer;
 
@@ -945,10 +975,12 @@
     }
 
     METHOD get_multisig() {
-        Parrot_Sub_attributes *sub = PARROT_SUB(SELF);
-        PMC        *multisig;
+        PMC                 *multisig;
+        Parrot_Sub_attributes *sub;
+        PMC_get_sub(INTERP, SELF, sub);
 
         multisig = sub->multi_signature ? sub->multi_signature : PMCNULL;
+
         RETURN(PMC *multisig);
     }
 

Modified: branches/context_pmc2/src/vtables.c
==============================================================================
--- branches/context_pmc2/src/vtables.c	Thu Aug 20 22:35:02 2009	(r40681)
+++ branches/context_pmc2/src/vtables.c	Thu Aug 20 23:03:02 2009	(r40682)
@@ -19,6 +19,10 @@
 #include "parrot/parrot.h"
 #include "parrot/vtables.h"
 
+/* This function is defined in the auto-generated file core_pmcs.c */
+/* XXX Get it into some public place */
+extern void Parrot_initialize_core_pmcs(PARROT_INTERP, int pass);
+
 /* HEADERIZER HFILE: include/parrot/vtables.h */
 
 /*
@@ -222,6 +226,28 @@
 }
 
 /*
+
+=item C<void Parrot_initialize_core_vtables(PARROT_INTERP)>
+
+Initialize vtables for the core PMCs.
+
+=cut
+
+*/
+
+PARROT_EXPORT
+void
+Parrot_initialize_core_vtables(PARROT_INTERP)
+{
+    ASSERT_ARGS(Parrot_initialize_core_vtables)
+
+    if (! interp->vtables) {
+        parrot_alloc_vtables(interp);
+        Parrot_initialize_core_pmcs(interp, 0);
+    }
+}
+
+/*
  * Local variables:
  *   c-file-style: "parrot"
  * End:

Modified: branches/context_pmc2/t/op/arithmetics.t
==============================================================================
--- branches/context_pmc2/t/op/arithmetics.t	Thu Aug 20 22:35:02 2009	(r40681)
+++ branches/context_pmc2/t/op/arithmetics.t	Thu Aug 20 23:03:02 2009	(r40682)
@@ -7,7 +7,7 @@
 use lib qw( . lib ../lib ../../lib );
 
 use Test::More;
-use Parrot::Test tests => 26;
+use Parrot::Test tests => 27;
 
 # test for GMP
 use Parrot::Config;
@@ -697,6 +697,33 @@
 -Inf
 OUTPUT
 
+TODO: {
+
+local $TODO = 'rounding nan/inf gives something like -2147483648';
+pir_output_is(<<CODE,<<OUTPUT, "TT #370 Rounding inf/nan");
+.sub 'main'
+        \$N0 = 'Inf'
+        \$I0 = floor \$N0
+        say \$I0
+        \$N0 = 'NaN'
+        \$I0 = floor \$N0
+        say \$I0
+        \$N0 = 'Inf'
+        \$I0 = ceil \$N0
+        say \$I0
+        \$N0 = 'NaN'
+        \$I0 = ceil \$N0
+        say \$I0
+    .end
+CODE
+Inf
+NaN
+Inf
+NaN
+OUTPUT
+
+}
+
 # Local Variables:
 #   mode: cperl
 #   cperl-indent-level: 4

Added: branches/context_pmc2/t/op/exit.t
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ branches/context_pmc2/t/op/exit.t	Thu Aug 20 23:03:02 2009	(r40682)
@@ -0,0 +1,72 @@
+#!perl
+# Copyright (C) 2009, Parrot Foundation.
+# $Id$
+
+use strict;
+use warnings;
+use lib qw( . lib ../lib ../../lib );
+
+use Test::More;
+use Parrot::Test tests => 7;
+
+=head1 NAME
+
+t/op/exit.t - Testing the exit pseudo-opcode
+
+=head1 SYNOPSIS
+
+    % prove t/op/exit.t
+
+=head1 DESCRIPTION
+
+Test both success and failure exit status.
+
+=cut
+
+pir_exit_code_is( <<'CODE', 0, 'pir exit with success' );
+.sub main
+    exit 0
+.end
+CODE
+
+pir_exit_code_is( <<'CODE', 1, 'pir exit with failure' );
+.sub main
+    exit 1
+.end
+CODE
+
+pasm_exit_code_is( <<'CODE', 1, 'pasm exit with failure' );
+    exit 1
+CODE
+
+pasm_exit_code_is( <<'CODE', 0, 'pasm exit without failure' );
+    exit 0
+CODE
+
+# If you know of a better place to put these tests, please put them there
+
+pir_exit_code_is( <<'CODE', 0, 'pir exits with success by default' );
+.sub main
+    $S0 = "cheese"
+.end
+CODE
+
+TODO: {
+    local $TODO = 'pasm exits with 1 by default';
+    pasm_exit_code_is( <<'CODE', 0, 'exit with success by default' );
+        set I0, 0
+CODE
+
+}
+TODO: {
+    local $TODO = 'pbc exits with 1 by default';
+    # Should we be using this file?
+    my $pbc = File::Spec->catfile(qw/ t native_pbc integer_1.pbc /);
+    pbc_exit_code_is($pbc, 0, 'pbc exits with 0 by default');
+}
+
+#   mode: cperl
+#   cperl-indent-level: 4
+#   fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:


More information about the parrot-commits mailing list