cvsuser     03/12/21 02:15:20

  Modified:    build_tools build_nativecall.pl
               classes  parrotinterpreter.pmc parrotthread.pmc
               jit/i386 jit_emit.h
               src      embed.c global_setup.c interpreter.c jit.c memory.c
                        smallobject.c string.c
  Log:
  parrot-threads-11
  * disable JITed NCI stubs for now
  * create Parrot_base_vtables only once
  * fix thread creation and interpreter destruction
  * PANIC on memory allocation failures
  * always use allocation functions in memory.c
  * fix off by one allocation error in JIT
  
  Revision  Changes    Path
  1.30      +2 -2      parrot/build_tools/build_nativecall.pl
  
  Index: build_nativecall.pl
  ===================================================================
  RCS file: /cvs/public/parrot/build_tools/build_nativecall.pl,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -w -r1.29 -r1.30
  --- build_nativecall.pl       29 Oct 2003 09:18:19 -0000      1.29
  +++ build_nativecall.pl       21 Dec 2003 10:15:03 -0000      1.30
  @@ -125,7 +125,7 @@
   /* nci.c
    *  Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
    *  CVS Info
  - *     $Id: build_nativecall.pl,v 1.29 2003/10/29 09:18:19 leo Exp $
  + *     $Id: build_nativecall.pl,v 1.30 2003/12/21 10:15:03 leo Exp $
    *  Overview:
    *     Native Call Interface routines. The code needed to build a
    *     parrot to C call frame is in here
  @@ -137,7 +137,7 @@
   
   #include "parrot/parrot.h"
   
  -#if defined(HAS_JIT) && defined(I386)
  +#if defined(HAS_JIT) && defined(I386) && defined(threaded_NCI_is_ok)
   #  include "parrot/exec.h"
   #  include "parrot/jit.h"
   #  define CAN_BUILD_CALL_FRAMES
  
  
  
  1.18      +7 -3      parrot/classes/parrotinterpreter.pmc
  
  Index: parrotinterpreter.pmc
  ===================================================================
  RCS file: /cvs/public/parrot/classes/parrotinterpreter.pmc,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -w -r1.17 -r1.18
  --- parrotinterpreter.pmc     19 Dec 2003 14:07:40 -0000      1.17
  +++ parrotinterpreter.pmc     21 Dec 2003 10:15:08 -0000      1.18
  @@ -1,7 +1,7 @@
   /* parrotinterpreter.pmc
    *  Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
    *  CVS Info
  - *     $Id: parrotinterpreter.pmc,v 1.17 2003/12/19 14:07:40 leo Exp $
  + *     $Id: parrotinterpreter.pmc,v 1.18 2003/12/21 10:15:08 leo Exp $
    *  Overview:
    *     These are the vtable functions for the ParrotInterpreter base class
    *  Data Structure and Algorithms:
  @@ -143,6 +143,8 @@
           if (!PMC_data(SELF)) {
               Parrot_Interp new_interp = make_interpreter(INTERP, 0);
               PMC_data(SELF) = new_interp;
  +            VTABLE_set_pmc_keyed_int(new_interp, new_interp->iglobals,
  +                    (INTVAL) IGLOBALS_INTERPRETER, SELF);
           }
        SELF->cache.struct_val = NULL;
       }
  @@ -153,6 +155,8 @@
           if (!PMC_data(SELF)) {
               Parrot_Interp new_interp = make_interpreter(p, 0);
               PMC_data(SELF) = new_interp;
  +            VTABLE_set_pmc_keyed_int(new_interp, new_interp->iglobals,
  +                    (INTVAL) IGLOBALS_INTERPRETER, SELF);
           }
        SELF->cache.struct_val = NULL;
       }
  
  
  
  1.5       +1 -3      parrot/classes/parrotthread.pmc
  
  Index: parrotthread.pmc
  ===================================================================
  RCS file: /cvs/public/parrot/classes/parrotthread.pmc,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -w -r1.4 -r1.5
  --- parrotthread.pmc  19 Dec 2003 16:42:37 -0000      1.4
  +++ parrotthread.pmc  21 Dec 2003 10:15:08 -0000      1.5
  @@ -1,7 +1,7 @@
   /* parrotthread.pmc
    *  Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
    *  CVS Info
  - *     $Id: parrotthread.pmc,v 1.4 2003/12/19 16:42:37 leo Exp $
  + *     $Id: parrotthread.pmc,v 1.5 2003/12/21 10:15:08 leo Exp $
    *  Overview:
    *     ParrotThread is a threaded ParrotInterpreter subclass
    *  Data Structure and Algorithms:
  @@ -48,8 +48,6 @@
           SUPER();
           pt_add_to_interpreters(interpreter, PMC_data(SELF));
           UNLOCK(interpreter_array_mutex);
  -        parent = VTABLE_get_pmc_keyed_int(interpreter, interpreter->iglobals,
  -                IGLOBALS_INTERPRETER);
       }
   
       /*
  
  
  
  1.96      +2 -2      parrot/jit/i386/jit_emit.h
  
  Index: jit_emit.h
  ===================================================================
  RCS file: /cvs/public/parrot/jit/i386/jit_emit.h,v
  retrieving revision 1.95
  retrieving revision 1.96
  diff -u -w -r1.95 -r1.96
  --- jit_emit.h        1 Dec 2003 16:30:11 -0000       1.95
  +++ jit_emit.h        21 Dec 2003 10:15:10 -0000      1.96
  @@ -3,7 +3,7 @@
    *
    * i386
    *
  - * $Id: jit_emit.h,v 1.95 2003/12/01 16:30:11 leo Exp $
  + * $Id: jit_emit.h,v 1.96 2003/12/21 10:15:10 leo Exp $
    */
   
   #include <assert.h>
  @@ -2959,7 +2959,7 @@
                           &PMC_REG(count_regs(sig, signature->strstart)));
   #if PARROT_CATCH_NULL
                   jit_emit_cmp_rm_i(pc, emit_EAX, &PMCNULL);
  -                emitm_jxs(pc, emitm_jnz, 2); /* skip the xor */
  +                emitm_jxs(pc, emitm_jne, 2); /* skip the xor */
                   jit_emit_bxor_rr_i(pc, emit_EAX, emit_EAX);
   #endif
                   emitm_pushl_r(pc, emit_EAX);
  
  
  
  1.98      +4 -4      parrot/src/embed.c
  
  Index: embed.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/embed.c,v
  retrieving revision 1.97
  retrieving revision 1.98
  diff -u -w -r1.97 -r1.98
  --- embed.c   13 Dec 2003 15:01:17 -0000      1.97
  +++ embed.c   21 Dec 2003 10:15:19 -0000      1.98
  @@ -1,7 +1,7 @@
   /* embed.c
    *  Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
    *  CVS Info
  - *     $Id: embed.c,v 1.97 2003/12/13 15:01:17 leo Exp $
  + *     $Id: embed.c,v 1.98 2003/12/21 10:15:19 leo Exp $
    *  Overview:
    *     The Parrot embedding interface.
    *  Data Structure and Algorithms:
  @@ -170,7 +170,7 @@
           INTVAL read_result;
   
           chunk_size = program_size > 0 ? program_size : 1024;
  -        program_code = (char *)malloc(chunk_size);
  +        program_code = (char *)mem_sys_allocate(chunk_size);
           wanted = program_size;
           program_size = 0;
   
  @@ -192,7 +192,7 @@
                   break;
               chunk_size = 1024;
               program_code =
  -                realloc(program_code, program_size + chunk_size);
  +                mem_sys_realloc(program_code, program_size + chunk_size);
   
               if (NULL == program_code) {
                   PIO_eprintf(interpreter,
  @@ -526,7 +526,7 @@
       for (i = 0; argv[i]; i++)
           space += strlen(argv[i]) + 1;
   
  -    command = (char*) malloc(space == 0 ? 1 : space);
  +    command = (char*) mem_sys_allocate(space == 0 ? 1 : space);
       p = command;
       for (i = 0; argv[i]; i++) {
           strcpy(p, argv[i]);
  
  
  
  1.50      +10 -4     parrot/src/global_setup.c
  
  Index: global_setup.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/global_setup.c,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -w -r1.49 -r1.50
  --- global_setup.c    2 Dec 2003 17:45:16 -0000       1.49
  +++ global_setup.c    21 Dec 2003 10:15:19 -0000      1.50
  @@ -1,7 +1,7 @@
   /* global_setup.c
    *  Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
    *  CVS Info
  - *     $Id: global_setup.c,v 1.49 2003/12/02 17:45:16 dan Exp $
  + *     $Id: global_setup.c,v 1.50 2003/12/21 10:15:19 leo Exp $
    *  Overview:
    *      Performs all the global setting up of things. This includes the
    *      (very few) global variables that Parrot totes around
  @@ -33,7 +33,13 @@
   
       string_init();              /* Set up the string subsystem */
   
  -    /* allocate core vtable table */
  +    /* TODO allocate core vtable table only once - or per interpreter
  +     *
  +     * this interfers with JITted NCI on i386, where the method stubs
  +     * are stored inside vtable->method_table - different threads get
  +     * the same code
  +     */
  +    if (!Parrot_base_vtables)
       Parrot_base_vtables =
           mem_sys_allocate_zeroed(sizeof(VTABLE *) * PARROT_MAX_CLASSES);
       enum_class_max = enum_class_core_max;
  
  
  
  1.245     +8 -2      parrot/src/interpreter.c
  
  Index: interpreter.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/interpreter.c,v
  retrieving revision 1.244
  retrieving revision 1.245
  diff -u -w -r1.244 -r1.245
  --- interpreter.c     20 Dec 2003 11:56:35 -0000      1.244
  +++ interpreter.c     21 Dec 2003 10:15:19 -0000      1.245
  @@ -1,7 +1,7 @@
   /* interpreter.c
    *  Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
    *  CVS Info
  - *     $Id: interpreter.c,v 1.244 2003/12/20 11:56:35 leo Exp $
  + *     $Id: interpreter.c,v 1.245 2003/12/21 10:15:19 leo Exp $
    *  Overview:
    *     The interpreter api handles running the operations
    *  Data Structure and Algorithms:
  @@ -1133,7 +1133,13 @@
           encoding_destroy();
       }
   
  +    else {
  +        /* don't free a thread interpreter, if it isn't joined yet */
  +        if (!interpreter->thread_data || (
  +                    interpreter->thread_data &&
  +                    interpreter->thread_data->state == THREAD_STATE_JOINED))
       mem_sys_free(interpreter);
  +    }
   }
   
   #ifdef GC_IS_MALLOC
  
  
  
  1.78      +3 -3      parrot/src/jit.c
  
  Index: jit.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/jit.c,v
  retrieving revision 1.77
  retrieving revision 1.78
  diff -u -w -r1.77 -r1.78
  --- jit.c     23 Oct 2003 17:48:59 -0000      1.77
  +++ jit.c     21 Dec 2003 10:15:19 -0000      1.78
  @@ -1,7 +1,7 @@
   /*
    * jit.c
    *
  - * $Id: jit.c,v 1.77 2003/10/23 17:48:59 robert Exp $
  + * $Id: jit.c,v 1.78 2003/12/21 10:15:19 leo Exp $
    */
   
   #include <parrot/parrot.h>
  @@ -107,7 +107,7 @@
   
       /* Allocate space for the branch information and register map */
       optimizer->map_branch = branch =
  -        (char *)mem_sys_allocate_zeroed((size_t)(code_end - code_start));
  +        (char *)mem_sys_allocate_zeroed((size_t)(code_end - code_start + 1));
   
       /* Allocate space for the branch list */
       optimizer->branch_list = (opcode_t **)
  @@ -990,7 +990,7 @@
           op_func = op_jit;
   
   
  -    name = malloc(strlen(interpreter->code->cur_cs->base.name) + 5);
  +    name = mem_sys_allocate(strlen(interpreter->code->cur_cs->base.name) + 5);
       sprintf(name, "%s_JIT", interpreter->code->cur_cs->base.name);
       jit_seg = PackFile_find_segment(interpreter->code->cur_cs->base.dir,
               name, 0);
  
  
  
  1.41      +18 -4     parrot/src/memory.c
  
  Index: memory.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/memory.c,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -w -r1.40 -r1.41
  --- memory.c  23 Oct 2003 17:48:59 -0000      1.40
  +++ memory.c  21 Dec 2003 10:15:19 -0000      1.41
  @@ -1,7 +1,7 @@
   /* memory.c
    *  Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
    *  CVS Info
  - *     $Id: memory.c,v 1.40 2003/10/23 17:48:59 robert Exp $
  + *     $Id: memory.c,v 1.41 2003/12/21 10:15:19 leo Exp $
    *  Overview:
    *     The memory (mem) API handles memory allocation
    *  Data Structure and Algorithms:
  @@ -15,10 +15,17 @@
   /*=for api mem mem_sys_allocate
      uses malloc to allocate system memory
   */
  +
  +/* for PANIC */
  +#define interpreter NULL
  +
   void *
   mem_sys_allocate(size_t size)
   {
  -    return malloc((size_t)size);
  +    void *ptr = malloc((size_t)size);
  +    if (!ptr)
  +        PANIC("Out of mem");
  +    return ptr;
   }
   
   /*=for api mem mem_sys_allocate_zeroed
  @@ -27,7 +34,10 @@
   void *
   mem_sys_allocate_zeroed(size_t size)
   {
  -    return calloc(1, (size_t)size);
  +    void *ptr = calloc(1, (size_t)size);
  +    if (!ptr)
  +        PANIC("Out of mem");
  +    return ptr;
   }
   
   /*=for api mem mem_sys_realloc
  @@ -36,8 +46,12 @@
   void *
   mem_sys_realloc(void *from, size_t size)
   {
  -    return realloc(from, size);
  +    void *ptr = realloc(from, size);
  +    if (!ptr)
  +        PANIC("Out of mem");
  +    return ptr;
   }
  +#undef interpreter
   
   /*=for api mem mem_sys_free
      free a chunk of memory back to the system
  
  
  
  1.31      +4 -2      parrot/src/smallobject.c
  
  Index: smallobject.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/smallobject.c,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -w -r1.30 -r1.31
  --- smallobject.c     20 Dec 2003 11:56:35 -0000      1.30
  +++ smallobject.c     21 Dec 2003 10:15:19 -0000      1.31
  @@ -1,7 +1,7 @@
   /* resources.c
    *  Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
    *  CVS Info
  - *     $Id: smallobject.c,v 1.30 2003/12/20 11:56:35 leo Exp $
  + *     $Id: smallobject.c,v 1.31 2003/12/21 10:15:19 leo Exp $
    *  Overview:
    *     Handles the accessing of small object pools (header pools)
    *  Data Structure and Algorithms:
  @@ -261,7 +261,7 @@
        */
       new_arena = Parrot_memalign(ARENA_ALIGN, size);
       if (!new_arena)
  -        internal_exception(ALLOCATION_ERROR, "Out of arena memory");
  +        PANIC("Out of arena memory");
       /* offset in bytes of whole Objects */
       offset = ( 1 + sizeof(struct Small_Object_Arena) / pool->object_size) *
           pool->object_size;
  @@ -280,6 +280,8 @@
       new_arena->free_list = NULL;
   #else
       new_arena = mem_sys_allocate(sizeof(struct Small_Object_Arena));
  +    if (!new_arena)
  +        PANIC("Out of arena memory");
       size = pool->object_size * pool->objects_per_alloc;
       /* could be mem_sys_allocate too, but calloc is fast */
       new_arena->start_objects = mem_sys_allocate_zeroed(size);
  
  
  
  1.163     +2 -2      parrot/src/string.c
  
  Index: string.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/string.c,v
  retrieving revision 1.162
  retrieving revision 1.163
  diff -u -w -r1.162 -r1.163
  --- string.c  11 Dec 2003 15:22:59 -0000      1.162
  +++ string.c  21 Dec 2003 10:15:19 -0000      1.163
  @@ -1,7 +1,7 @@
   /* string.c
    *  Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
    *  CVS Info
  - *     $Id: string.c,v 1.162 2003/12/11 15:22:59 leo Exp $
  + *     $Id: string.c,v 1.163 2003/12/21 10:15:19 leo Exp $
    *  Overview:
    *     This is the api definitions for the string subsystem
    *  Data Structure and Algorithms:
  @@ -1560,7 +1560,7 @@
       if (s == NULL) {
           return NULL;
       }
  -    p = malloc(s->bufused + 1);
  +    p = mem_sys_allocate(s->bufused + 1);
       memcpy(p, s->strstart, s->bufused);
       p[s->bufused] = 0;
       return p;
  
  
  

Reply via email to