Skip to content

Commit

Permalink
[pmc] Optimize dynpmc WB and testlib/nci_pmc.in
Browse files Browse the repository at this point in the history
mark non-writers as :no_wb
  • Loading branch information
Reini Urban committed Jun 13, 2014
1 parent 58b5777 commit 00cd232
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 35 deletions.
14 changes: 8 additions & 6 deletions src/dynpmc/dynlexpad.pmc
@@ -1,5 +1,5 @@
/*
Copyright (C) 2005-2011, Parrot Foundation.
Copyright (C) 2005-2014, Parrot Foundation.

=head1 NAME

Expand Down Expand Up @@ -66,10 +66,12 @@ Initialize the LexPad PMC and remember the associate context.

*/

VTABLE void set_pointer(void* ctx) {
VTABLE void set_pointer(void* ctx) :manual_wb {
PMC * const std_pad = PARROT_DYNLEXPAD(SELF)->init;
if (std_pad)
if (std_pad) {
VTABLE_set_pointer(INTERP, std_pad, ctx);
PARROT_GC_WRITE_BARRIER(INTERP, SELF);
}
}

/*
Expand Down Expand Up @@ -191,7 +193,7 @@ doesn't exist, it is created.

*/

VTABLE void set_pmc_keyed(PMC* name, PMC* value) {
VTABLE void set_pmc_keyed(PMC* name, PMC* value) :manual_wb {
STRING * const s = VTABLE_get_string(INTERP, name);
SELF.set_pmc_keyed_str(s, value);
}
Expand Down Expand Up @@ -226,7 +228,7 @@ Destroy DynLexPad.

*/

VTABLE void destroy() {
VTABLE void destroy() :no_wb {
if (PARROT_DYNLEXPAD(SELF)->hash) {
Parrot_hash_destroy(INTERP, PARROT_DYNLEXPAD(SELF)->hash);
PARROT_DYNLEXPAD(SELF)->hash = NULL;
Expand All @@ -242,7 +244,7 @@ Marks the lexpad hash as live.

*/

VTABLE void mark() {
VTABLE void mark() :no_wb {
PMC * const std_pad = PARROT_DYNLEXPAD(SELF)->init;
Parrot_gc_mark_PMC_alive(INTERP, std_pad);
if (PARROT_DYNLEXPAD(SELF)->hash)
Expand Down
22 changes: 11 additions & 11 deletions src/dynpmc/file.pmc
@@ -1,9 +1,9 @@
/*
Copyright (C) 2001-2011, Parrot Foundation.
Copyright (C) 2001-2014, Parrot Foundation.

=head1 NAME

src/pmc/file.pmc - File PMC
src/dynpmc/file.pmc - File PMC

=head1 DESCRIPTION

Expand Down Expand Up @@ -40,21 +40,21 @@ information see F<src/pmc.c>.
=cut

*/
void class_init() {
void class_init() :no_wb {
UNUSED(INTERP);
UNUSED(entry);

File_PMC = NULL;
}

VTABLE void *get_pointer() {
VTABLE void *get_pointer() :no_wb {
UNUSED(INTERP);
UNUSED(SELF);

return File_PMC;
}

VTABLE void set_pointer(void *ptr) {
VTABLE void set_pointer(void *ptr) :no_wb {
UNUSED(INTERP);
UNUSED(SELF);

Expand All @@ -71,7 +71,7 @@ Returns a true value (1) if the supplied file or directory exists.

*/

METHOD exists(STRING *path) {
METHOD exists(STRING *path) :no_wb {
const INTVAL res = Parrot_file_lstat_intval(interp, path, STAT_EXISTS);

RETURN(INTVAL res);
Expand All @@ -87,7 +87,7 @@ Returns a true value (1) if the supplied path is a directory.

*/

METHOD is_dir(STRING *path) {
METHOD is_dir(STRING *path) :no_wb {
const INTVAL res = Parrot_file_lstat_intval(interp, path, STAT_ISDIR);

RETURN(INTVAL res);
Expand All @@ -103,7 +103,7 @@ Returns a true value (1) if the supplied path is a plain file.

*/

METHOD is_file(STRING *path) {
METHOD is_file(STRING *path) :no_wb {
const INTVAL res = Parrot_file_lstat_intval(interp, path, STAT_ISREG);

RETURN(INTVAL res);
Expand All @@ -119,7 +119,7 @@ Returns a true value (1) if the supplied path is a link.

*/

METHOD is_link(STRING *path) {
METHOD is_link(STRING *path) :no_wb {
const INTVAL res = Parrot_file_lstat_intval(interp, path, STAT_ISLNK);

RETURN(INTVAL res);
Expand All @@ -141,7 +141,7 @@ free to change or give me hints on how to change it. -- ambs

*/

METHOD copy(STRING *from, STRING *to) {
METHOD copy(STRING *from, STRING *to) :no_wb {
#define CHUNK_SIZE 1024

char * const cfrom = Parrot_str_to_cstring(INTERP, from);
Expand Down Expand Up @@ -196,7 +196,7 @@ Rename a file C<from> to the path C<to>.

*/

METHOD rename(STRING *from, STRING *to) {
METHOD rename(STRING *from, STRING *to) :no_wb {
Parrot_file_rename(INTERP, from, to);
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/dynpmc/select.pmc
@@ -1,9 +1,9 @@
/*
Copyright (C) 2011, Parrot Foundation.
Copyright (C) 2011-2014 Parrot Foundation.

=head1 NAME

src/pmc/select.pmc - IO Select PMC
src/dynpmc/select.pmc - IO Select PMC

=head1 DESCRIPTION

Expand Down Expand Up @@ -104,7 +104,7 @@ Mark fd_map hash as live.
=cut

*/
VTABLE void mark() {
VTABLE void mark() :no_wb {
PMC *fd_map;
GET_ATTR_fd_map(INTERP, SELF, fd_map);
Parrot_gc_mark_PMC_alive(interp, fd_map);
Expand All @@ -127,7 +127,7 @@ the Select PMC

*/

METHOD max_fd() {
METHOD max_fd() :no_wb {
INTVAL v;
GET_ATTR_max_fd(INTERP, SELF, v);
RETURN(INTVAL v);
Expand All @@ -146,7 +146,7 @@ Used mainly for testing purposes.

*/

METHOD fd_map() {
METHOD fd_map() :no_wb {
PMC *fd_map;
GET_ATTR_fd_map(INTERP, SELF, fd_map);
RETURN(PMC *fd_map);
Expand Down Expand Up @@ -225,7 +225,7 @@ read before returning.

*/

METHOD can_read(FLOATVAL timeout) {
METHOD can_read(FLOATVAL timeout) :no_wb {
fd_set rdset;
struct timeval timeouts;
PMC *results;
Expand Down Expand Up @@ -265,7 +265,7 @@ write to before returning.

*/

METHOD can_write(FLOATVAL timeout) {
METHOD can_write(FLOATVAL timeout) :no_wb {
fd_set wbset;
struct timeval timeouts;
PMC *results, *fd_map;
Expand Down Expand Up @@ -304,7 +304,7 @@ exception state before returning.

*/

METHOD has_exception(FLOATVAL timeout) {
METHOD has_exception(FLOATVAL timeout) :no_wb {
fd_set ebset;
struct timeval timeouts;
PMC *results, *fd_map;
Expand Down Expand Up @@ -345,7 +345,7 @@ handled.

*/

METHOD select(FLOATVAL timeout) {
METHOD select(FLOATVAL timeout) :no_wb {
fd_set rdset, wrset, erset;
struct timeval timeouts;

Expand Down
18 changes: 9 additions & 9 deletions t/tools/dev/headerizer/testlib/nci_pmc.in
@@ -1,5 +1,5 @@
/*
Copyright (C) 2001-2011, Parrot Foundation.
Copyright (C) 2001-2014, Parrot Foundation.


=head1 NAME
Expand Down Expand Up @@ -213,7 +213,7 @@ Return the MMD signature PMC, if any or a Null PMC.

*/

METHOD get_multisig() {
METHOD get_multisig() :no_wb {
PMC *sig;
GET_ATTR_multi_sig(INTERP, SELF, sig);
if (PMC_IS_NULL(sig))
Expand All @@ -235,7 +235,7 @@ Initializes the NCI with a C<NULL> function pointer.
PObj_custom_mark_SET(SELF);
}

VTABLE void *get_pointer() {
VTABLE void *get_pointer() :no_wb {
return PARROT_NCI(SELF)->orig_func;
}

Expand Down Expand Up @@ -276,7 +276,7 @@ Mark any referenced strings and PMCs.
=cut

*/
VTABLE void mark() {
VTABLE void mark() :no_wb {
if (PARROT_NCI(SELF)) {
Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);

Expand All @@ -300,7 +300,7 @@ Creates and returns a clone of the NCI.

*/

VTABLE PMC *clone() {
VTABLE PMC *clone() :no_wb {
Parrot_NCI_attributes * const nci_info_self = PARROT_NCI(SELF);
Parrot_NCI_attributes *nci_info_ret;
void *orig_func;
Expand Down Expand Up @@ -334,7 +334,7 @@ Returns whether the NCI is defined.

*/

VTABLE INTVAL defined() {
VTABLE INTVAL defined() :no_wb {
Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
return nci_info->orig_func != NULL;
}
Expand Down Expand Up @@ -402,7 +402,7 @@ Returns the function pointer as an integer.

*/

VTABLE INTVAL get_integer() {
VTABLE INTVAL get_integer() :no_wb {
Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
if (!nci_info->func)
build_func(INTERP, nci_info);
Expand All @@ -419,7 +419,7 @@ Returns the boolean value of the pointer.

*/

VTABLE INTVAL get_bool() {
VTABLE INTVAL get_bool() :no_wb {
Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
return (0 != (INTVAL)nci_info->orig_func);
}
Expand All @@ -433,7 +433,7 @@ Return the arity of the NCI (the number of arguments).
=cut

*/
METHOD arity() {
METHOD arity() :no_wb {
Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
INTVAL arity = 0;

Expand Down

0 comments on commit 00cd232

Please sign in to comment.