perl.cvs.parrot
[Top] [All Lists]

[svn:parrot] r28863 - in trunk: . include/parrot src

Subject: [svn:parrot] r28863 - in trunk: . include/parrot src
From:
Date: Mon, 30 Jun 2008 08:01:17 -0700 PDT
Newsgroups: perl.cvs.parrot

Author: Whiteknight
Date: Mon Jun 30 08:01:17 2008
New Revision: 28863

Removed:
   trunk/src/stack_common.c
Modified:
   trunk/MANIFEST
   trunk/include/parrot/stacks.h
   trunk/src/stacks.c

Log:
[core] merged src/stacks.c and src/stack_common.c into src/stacks.c. 
* Deleted src/stack_common.c from repo, removed from MANIFEST
* merged function register_new_stack into new_stack. Deleted former.
* Simplified Stack_Chunk_t structure definition to remove unneeded nonsense
* Cache Stack_Chunk_t pool pointer instead of structure size. Saves on pool 
lookups.

Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST      (original)
+++ trunk/MANIFEST      Mon Jun 30 08:01:17 2008
@@ -3145,7 +3145,6 @@
 src/scheduler.c                                             []
 src/spf_render.c                                            []
 src/spf_vtable.c                                            []
-src/stack_common.c                                          []
 src/stacks.c                                                []
 src/stm/backend.c                                           []
 src/stm/stm_internal.h                                      []

Modified: trunk/include/parrot/stacks.h
==============================================================================
--- trunk/include/parrot/stacks.h       (original)
+++ trunk/include/parrot/stacks.h       Mon Jun 30 08:01:17 2008
@@ -24,23 +24,19 @@
     void (*cleanup)(PARROT_INTERP, struct Stack_Entry *);
 } Stack_Entry_t;
 
+struct Small_Object_Pool; /* forward decl */
+
 typedef struct Stack_Chunk {
     UnionVal            cache;
     Parrot_UInt         flags;
-    int                 size;
+    struct Small_Object_Pool  *pool;
     const char         *name;
     struct Stack_Chunk *prev;
     Parrot_UInt         refcount;
-    union { /* force appropriate alignment of 'data'.  If alignment
-               is necessary, assume double is good enough.  27-04-2007. */
-        Stack_Entry_t data;
-#if PARROT_PTR_ALIGNMENT > 1
-        double d_dummy;
-#endif
-    } u;
+    Stack_Entry_t       data;
 } Stack_Chunk_t;
 
-#define STACK_DATAP(chunk)    &((chunk)->u.data)
+#define STACK_DATAP(chunk)    &((chunk)->data)
 /* #define STACK_ITEMSIZE(chunk) PObj_buflen(chunk) */
 
 
@@ -52,6 +48,14 @@
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will 
be lost. */
 
 PARROT_API
+PARROT_WARN_UNUSED_RESULT
+PARROT_CANNOT_RETURN_NULL
+Stack_Chunk_t * cst_new_stack_chunk(PARROT_INTERP,
+    ARGIN(const Stack_Chunk_t *chunk))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2);
+
+PARROT_API
 void mark_stack(PARROT_INTERP, ARGMOD(Stack_Chunk_t *chunk))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
@@ -121,44 +125,6 @@
         FUNC_MODIFIES(*stack_p);
 
 PARROT_API
-void stack_push(PARROT_INTERP,
-    ARGMOD(Stack_Chunk_t **stack_p),
-    ARGIN(void *thing),
-    Stack_entry_type type,
-    NULLOK(Stack_cleanup_method cleanup))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        __attribute__nonnull__(3)
-        FUNC_MODIFIES(*stack_p);
-
-PARROT_WARN_UNUSED_RESULT
-PARROT_PURE_FUNCTION
-Stack_entry_type get_entry_type(ARGIN(const Stack_Entry_t *entry))
-        __attribute__nonnull__(1);
-
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will 
be lost. */
-/* HEADERIZER END: src/stacks.c */
-/* HEADERIZER BEGIN: src/stack_common.c */
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will 
be lost. */
-
-PARROT_API
-PARROT_WARN_UNUSED_RESULT
-PARROT_CANNOT_RETURN_NULL
-Stack_Chunk_t * cst_new_stack_chunk(PARROT_INTERP,
-    ARGIN(const Stack_Chunk_t *chunk))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2);
-
-PARROT_API
-PARROT_WARN_UNUSED_RESULT
-PARROT_CANNOT_RETURN_NULL
-Stack_Chunk_t * register_new_stack(PARROT_INTERP,
-    ARGIN(const char *name),
-    size_t item_size)
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2);
-
-PARROT_API
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
 Stack_Entry_t* stack_prepare_pop(PARROT_INTERP,
@@ -177,11 +143,26 @@
         FUNC_MODIFIES(*stack_p);
 
 PARROT_API
+void stack_push(PARROT_INTERP,
+    ARGMOD(Stack_Chunk_t **stack_p),
+    ARGIN(void *thing),
+    Stack_entry_type type,
+    NULLOK(Stack_cleanup_method cleanup))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        __attribute__nonnull__(3)
+        FUNC_MODIFIES(*stack_p);
+
+PARROT_API
 void stack_system_init(SHIM_INTERP);
 
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will 
be lost. */
-/* HEADERIZER END: src/stack_common.c */
+PARROT_WARN_UNUSED_RESULT
+PARROT_PURE_FUNCTION
+Stack_entry_type get_entry_type(ARGIN(const Stack_Entry_t *entry))
+        __attribute__nonnull__(1);
 
+/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will 
be lost. */
+/* HEADERIZER END: src/stacks.c */
 
 #define ERROR_STACK_EMPTY 1
 #define ERROR_STACK_SHALLOW 1

Modified: trunk/src/stacks.c
==============================================================================
--- trunk/src/stacks.c  (original)
+++ trunk/src/stacks.c  Mon Jun 30 08:01:17 2008
@@ -26,6 +26,51 @@
 
 /*
 
+=item C<void stack_system_init>
+
+Called from C<make_interpreter()> to initialize the interpreter's
+register stacks.
+
+=cut
+
+*/
+
+PARROT_API
+void
+stack_system_init(SHIM_INTERP)
+{
+}
+
+/*
+
+=item C<Stack_Chunk_t * cst_new_stack_chunk>
+
+Get a new chunk either from the freelist or allocate one.
+
+=cut
+
+*/
+
+PARROT_API
+PARROT_WARN_UNUSED_RESULT
+PARROT_CANNOT_RETURN_NULL
+Stack_Chunk_t *
+cst_new_stack_chunk(PARROT_INTERP, ARGIN(const Stack_Chunk_t *chunk))
+{
+    Small_Object_Pool * const pool = chunk->pool;
+    Stack_Chunk_t * const new_chunk = (Stack_Chunk_t 
*)pool->get_free_object(interp, pool);
+
+    PObj_bufstart(new_chunk) = NULL;
+    PObj_buflen(new_chunk)   = 0;
+
+    new_chunk->pool          = chunk->pool;
+    new_chunk->name          = chunk->name;
+
+    return new_chunk;
+}
+
+/*
+
 =item C<Stack_Chunk_t * new_stack>
 
 Create a new stack and name it. C<< stack->name >> is used for
@@ -41,7 +86,14 @@
 Stack_Chunk_t *
 new_stack(PARROT_INTERP, ARGIN(const char *name))
 {
-    return register_new_stack(interp, name, sizeof (Stack_Entry_t));
+    Small_Object_Pool * const pool = make_bufferlike_pool(interp, sizeof 
(Stack_Chunk_t));
+    Stack_Chunk_t     * const chunk = (Stack_Chunk_t 
*)(pool->get_free_object)(interp, pool);
+
+    chunk->prev = chunk;        /* mark the top of the stack */
+    chunk->name = name;
+    chunk->pool = pool;         /* cache the pool pointer, for ease */
+
+    return chunk;
 }
 
 
@@ -222,6 +274,31 @@
 
 /*
 
+=item C<Stack_Entry_t* stack_prepare_push>
+
+Return a pointer, where new entries go for push.
+
+=cut
+
+*/
+
+PARROT_API
+PARROT_WARN_UNUSED_RESULT
+PARROT_CANNOT_RETURN_NULL
+Stack_Entry_t*
+stack_prepare_push(PARROT_INTERP, ARGMOD(Stack_Chunk_t **stack_p))
+{
+    Stack_Chunk_t * const chunk     = *stack_p;
+    Stack_Chunk_t * const new_chunk = cst_new_stack_chunk(interp, chunk);
+
+    new_chunk->prev = chunk;
+    *stack_p        = new_chunk;
+
+    return STACK_DATAP(new_chunk);
+}
+
+/*
+
 =item C<void stack_push>
 
 Push something on the generic stack.
@@ -268,6 +345,34 @@
 
 /*
 
+=item C<Stack_Entry_t* stack_prepare_pop>
+
+Return a pointer, where new entries are popped off.
+
+=cut
+
+*/
+
+PARROT_API
+PARROT_WARN_UNUSED_RESULT
+PARROT_CANNOT_RETURN_NULL
+Stack_Entry_t*
+stack_prepare_pop(PARROT_INTERP, ARGMOD(Stack_Chunk_t **stack_p))
+{
+    Stack_Chunk_t * const chunk = *stack_p;
+
+    /* the first entry (initial top) refers to itself */
+    if (chunk == chunk->prev)
+        real_exception(interp, NULL, ERROR_STACK_EMPTY,
+            "No entries on %s Stack!", chunk->name);
+
+    *stack_p = chunk->prev;
+
+    return STACK_DATAP(chunk);
+}
+
+/*
+
 =item C<void * stack_pop>
 
 Pop off an entry and return a pointer to the contents.
@@ -316,8 +421,7 @@
 
     /* recycle this chunk to the free list if it's otherwise unreferenced */
     if (cur_chunk->refcount <= 0) {
-        Small_Object_Pool * const pool =
-            get_bufferlike_pool(interp, cur_chunk->size);
+        Small_Object_Pool * const pool = cur_chunk->pool;
 
         pool->dod_object(interp, pool, (PObj *)cur_chunk);
         pool->add_free_object(interp, pool, (PObj *)cur_chunk);

<Prev in Thread] Current Thread [Next in Thread>
  • [svn:parrot] r28863 - in trunk: . include/parrot src, Whiteknight <=