[svn:parrot] r46826 - in branches/ucs4_encoding: . compilers/imcc include/parrot lib/Parrot lib/Parrot/Test src src/dynoplibs src/gc src/interp src/packfile src/runcore src/string t/dynoplibs t/native_pbc t/src tools/build tools/dev
darbelo at svn.parrot.org
darbelo at svn.parrot.org
Thu May 20 20:26:49 UTC 2010
Author: darbelo
Date: Thu May 20 20:26:49 2010
New Revision: 46826
URL: https://trac.parrot.org/parrot/changeset/46826
Log:
Pull changes from trunk.
Modified:
branches/ucs4_encoding/ (props changed)
branches/ucs4_encoding/PBC_COMPAT
branches/ucs4_encoding/compilers/imcc/pbc.c
branches/ucs4_encoding/include/parrot/exceptions.h
branches/ucs4_encoding/include/parrot/runcore_trace.h (props changed)
branches/ucs4_encoding/lib/Parrot/Headerizer.pm
branches/ucs4_encoding/lib/Parrot/Test/Pod.pm
branches/ucs4_encoding/src/dynoplibs/deprecated.ops (contents, props changed)
branches/ucs4_encoding/src/exceptions.c
branches/ucs4_encoding/src/gc/gc_private.h
branches/ucs4_encoding/src/gc/mark_sweep.c
branches/ucs4_encoding/src/interp/inter_create.c (props changed)
branches/ucs4_encoding/src/packfile/pf_items.c
branches/ucs4_encoding/src/runcore/cores.c (props changed)
branches/ucs4_encoding/src/runcore/trace.c (props changed)
branches/ucs4_encoding/src/string/api.c
branches/ucs4_encoding/src/utils.c
branches/ucs4_encoding/t/dynoplibs/deprecated.t (props changed)
branches/ucs4_encoding/t/native_pbc/annotations.pbc
branches/ucs4_encoding/t/native_pbc/integer_1.pbc
branches/ucs4_encoding/t/native_pbc/number_1.pbc
branches/ucs4_encoding/t/native_pbc/string_1.pbc
branches/ucs4_encoding/t/src/embed.t (props changed)
branches/ucs4_encoding/tools/build/headerizer.pl
branches/ucs4_encoding/tools/dev/mk_gitignore.pl (props changed)
Modified: branches/ucs4_encoding/PBC_COMPAT
==============================================================================
--- branches/ucs4_encoding/PBC_COMPAT Thu May 20 20:05:41 2010 (r46825)
+++ branches/ucs4_encoding/PBC_COMPAT Thu May 20 20:26:49 2010 (r46826)
@@ -27,6 +27,7 @@
# please insert tab separated entries at the top of the list
+6.17 2010.05.20 NotFound store encoding of string constants
6.16 2010.05.18 plobsing move freeze/thaw adjacent to visit
6.15 2010.05.06 bacek add StringBuilder PMC
6.14 2010.05.03 coke remove popaction, pushmark, pushaction ops.
Modified: branches/ucs4_encoding/compilers/imcc/pbc.c
==============================================================================
--- branches/ucs4_encoding/compilers/imcc/pbc.c Thu May 20 20:05:41 2010 (r46825)
+++ branches/ucs4_encoding/compilers/imcc/pbc.c Thu May 20 20:26:49 2010 (r46826)
@@ -888,7 +888,7 @@
IMCC_string_from_reg(PARROT_INTERP, ARGIN(const SymReg *r))
{
ASSERT_ARGS(IMCC_string_from_reg)
- const char *buf = r->name;
+ char *buf = r->name;
if (r->type & VT_ENCODED) {
/*
@@ -896,19 +896,63 @@
* get first part as charset, rest as string
*/
STRING *s;
+ const CHARSET *s_charset;
+ const ENCODING *s_encoding = NULL;
+ const ENCODING *src_encoding;
const char *charset;
- char * const p = strchr(r->name, '"');
+ #define MAX_NAME 31
+ char charset_name[MAX_NAME + 1];
+ char encoding_name[MAX_NAME + 1];
+ char * p = strchr(r->name, '"');
+ char * p2 = strchr(r->name, ':');
PARROT_ASSERT(p && p[-1] == ':');
-
- p[-1] = 0;
- charset = r->name;
+ if (p2 < p -1) {
+ strncpy(encoding_name, buf, p2 - buf);
+ encoding_name[p2-buf] = '\0';
+ strncpy(charset_name, p2 +1, p - p2 - 2);
+ charset_name[p- p2 - 2] = '\0';
+ /*fprintf(stderr, "%s:%s\n", charset_name, encoding_name);*/
+ s_charset = Parrot_find_charset(interp, charset_name);
+ s_encoding = Parrot_find_encoding(interp, encoding_name);
+ }
+ else {
+ strncpy(charset_name, buf, p - buf - 1);
+ charset_name[p - buf - 1] = '\0';
+ /*fprintf(stderr, "%s\n", charset_name);*/
+ s_charset = Parrot_find_charset(interp, charset_name);
+ }
+ if (strcmp(charset_name, "unicode") == 0)
+ src_encoding = Parrot_utf8_encoding_ptr;
+ else
+ src_encoding = Parrot_fixed_8_encoding_ptr;
+ if (s_encoding == NULL)
+ s_encoding = src_encoding;
/* past delim */
buf = p + 1;
- s = Parrot_str_unescape(interp, buf, '"', charset);
-
- /* restore colon, as we may reuse this string */
- p[-1] = ':';
+ if (strcmp(charset_name, "unicode") == 0 && strcmp(encoding_name, "utf8") == 0) {
+ /* Special case needed for backward compatibility with utf8 literals
+ * using \xHH\xHH byte sequences */
+ s = Parrot_str_unescape(interp, buf, '"', "utf8:unicode");
+ }
+ else {
+ p = buf;
+ p2 = strchr(buf, '"');
+ while (p2 != NULL) {
+ p = p2;
+ p2 = strchr(p + 1, '"');
+ }
+ {
+ STRING * aux = Parrot_str_new_init(interp, buf, p - buf,
+ src_encoding, s_charset, 0);
+ s = Parrot_str_unescape_string(interp, aux,
+ s_charset, s_encoding, PObj_constant_FLAG);
+ if (!CHARSET_VALIDATE(interp, s))
+ Parrot_ex_throw_from_c_args(interp, NULL,
+ EXCEPTION_INVALID_STRING_REPRESENTATION,
+ "Malformed string");
+ }
+ }
return s;
}
else if (*buf == '"') {
Modified: branches/ucs4_encoding/include/parrot/exceptions.h
==============================================================================
--- branches/ucs4_encoding/include/parrot/exceptions.h Thu May 20 20:05:41 2010 (r46825)
+++ branches/ucs4_encoding/include/parrot/exceptions.h Thu May 20 20:26:49 2010 (r46826)
@@ -115,9 +115,9 @@
/* HEADERIZER BEGIN: src/exceptions.c */
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
+PARROT_EXPORT
PARROT_DOES_NOT_RETURN
PARROT_COLD
-PARROT_EXPORT
void do_panic(
NULLOK_INTERP,
ARGIN_NULLOK(const char *message),
Modified: branches/ucs4_encoding/lib/Parrot/Headerizer.pm
==============================================================================
--- branches/ucs4_encoding/lib/Parrot/Headerizer.pm Thu May 20 20:05:41 2010 (r46825)
+++ branches/ucs4_encoding/lib/Parrot/Headerizer.pm Thu May 20 20:26:49 2010 (r46826)
@@ -247,8 +247,10 @@
}
if ( $return_type =~ /\*/ ) {
if ( !$macros{PARROT_CAN_RETURN_NULL} && !$macros{PARROT_CANNOT_RETURN_NULL} ) {
- $self->squawk( $file, $name,
- 'Returns a pointer, but no PARROT_CAN(NOT)_RETURN_NULL macro found.' );
+ if ( $name !~ /^yy/ ) { # Don't complain about lexer-created functions
+ $self->squawk( $file, $name,
+ 'Returns a pointer, but no PARROT_CAN(NOT)_RETURN_NULL macro found.' );
+ }
}
elsif ( $macros{PARROT_CAN_RETURN_NULL} && $macros{PARROT_CANNOT_RETURN_NULL} ) {
$self->squawk( $file, $name,
Modified: branches/ucs4_encoding/lib/Parrot/Test/Pod.pm
==============================================================================
--- branches/ucs4_encoding/lib/Parrot/Test/Pod.pm Thu May 20 20:05:41 2010 (r46825)
+++ branches/ucs4_encoding/lib/Parrot/Test/Pod.pm Thu May 20 20:26:49 2010 (r46826)
@@ -198,7 +198,7 @@
@files = @{ $self->{argv} };
}
else {
- print STDERR "\nFinding files with POD, this may take a minute.\n";
+ print STDERR "\n# Finding files with POD, this may take a minute.\n";
@files = (
keys(%{ $self->{manifest} }),
keys(%{ $self->{manifest_gen} })
Modified: branches/ucs4_encoding/src/dynoplibs/deprecated.ops
==============================================================================
--- branches/ucs4_encoding/src/dynoplibs/deprecated.ops Thu May 20 20:05:41 2010 (r46825)
+++ branches/ucs4_encoding/src/dynoplibs/deprecated.ops Thu May 20 20:26:49 2010 (r46826)
@@ -30,25 +30,25 @@
=cut
-op exchange(inout INT, inout INT) :base_core {
+op exchange(inout INT, inout INT) :deprecated {
const INTVAL temp = $1;
$1 = $2;
$2 = temp;
}
-op exchange(inout PMC, inout PMC) :base_core {
+op exchange(inout PMC, inout PMC) :deprecated {
PMC * const temp = $1;
$1 = $2;
$2 = temp;
}
-op exchange(inout NUM, inout NUM) :base_core {
+op exchange(inout NUM, inout NUM) :deprecated {
FLOATVAL temp = $1;
$1 = $2;
$2 = temp;
}
-op exchange(inout STR, inout STR) :base_core {
+op exchange(inout STR, inout STR) :deprecated {
STRING * const temp = $1;
$1 = $2;
$2 = temp;
@@ -62,7 +62,7 @@
=cut
-inline op setp_ind(in INT, invar PMC) :base_ref {
+inline op setp_ind(in INT, invar PMC) :deprecated {
if ($1 < 0 || $1 >= NUM_REGISTERS)
PANIC(interp, "Out of bound register access");
REG_PMC(interp, $1) = $2;
@@ -76,7 +76,7 @@
=cut
-inline op setn_ind(in INT, in NUM) :base_ref {
+inline op setn_ind(in INT, in NUM) :deprecated {
if ($1 < 0 || $1 >= NUM_REGISTERS)
PANIC(interp, "Out of bound register access");
REG_NUM(interp, $1) = $2;
@@ -90,7 +90,7 @@
=cut
-inline op sets_ind(in INT, in STR) :base_ref {
+inline op sets_ind(in INT, in STR) :deprecated {
if ($1 < 0 || $1 >= NUM_REGISTERS)
PANIC(interp, "Out of bound register access");
REG_STR(interp, $1) = $2;
@@ -104,7 +104,7 @@
=cut
-inline op seti_ind(in INT, in INT) :base_ref {
+inline op seti_ind(in INT, in INT) :deprecated {
if ($1 < 0 || $1 >= NUM_REGISTERS)
PANIC(interp, "Out of bound register access");
REG_INT(interp, $1) = $2;
@@ -128,19 +128,19 @@
=cut
-inline op cleari() :base_core {
+inline op cleari() :deprecated {
Parrot_clear_i(interp);
}
-inline op clearn() :base_core {
+inline op clearn() :deprecated {
Parrot_clear_n(interp);
}
-inline op clears() :base_core {
+inline op clears() :deprecated {
Parrot_clear_s(interp);
}
-inline op clearp() :base_core {
+inline op clearp() :deprecated {
Parrot_clear_p(interp);
}
Modified: branches/ucs4_encoding/src/exceptions.c
==============================================================================
--- branches/ucs4_encoding/src/exceptions.c Thu May 20 20:05:41 2010 (r46825)
+++ branches/ucs4_encoding/src/exceptions.c Thu May 20 20:26:49 2010 (r46826)
@@ -680,9 +680,9 @@
*/
+PARROT_EXPORT
PARROT_DOES_NOT_RETURN
PARROT_COLD
-PARROT_EXPORT
void
do_panic(NULLOK_INTERP, ARGIN_NULLOK(const char *message),
ARGIN_NULLOK(const char *file), unsigned int line)
Modified: branches/ucs4_encoding/src/gc/gc_private.h
==============================================================================
--- branches/ucs4_encoding/src/gc/gc_private.h Thu May 20 20:05:41 2010 (r46825)
+++ branches/ucs4_encoding/src/gc/gc_private.h Thu May 20 20:26:49 2010 (r46826)
@@ -352,7 +352,7 @@
ARGMOD(Memory_Pools *mem_pools),
int flag,
ARGIN_NULLOK(void *arg),
- ARGIN(pool_iter_fn func))
+ NOTNULL(pool_iter_fn func))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
__attribute__nonnull__(5)
Modified: branches/ucs4_encoding/src/gc/mark_sweep.c
==============================================================================
--- branches/ucs4_encoding/src/gc/mark_sweep.c Thu May 20 20:05:41 2010 (r46825)
+++ branches/ucs4_encoding/src/gc/mark_sweep.c Thu May 20 20:26:49 2010 (r46826)
@@ -840,7 +840,7 @@
header_pools_iterate_callback(PARROT_INTERP,
ARGMOD(Memory_Pools *mem_pools),
int flag, ARGIN_NULLOK(void *arg),
- ARGIN(pool_iter_fn func))
+ NOTNULL(pool_iter_fn func))
{
ASSERT_ARGS(header_pools_iterate_callback)
Modified: branches/ucs4_encoding/src/packfile/pf_items.c
==============================================================================
--- branches/ucs4_encoding/src/packfile/pf_items.c Thu May 20 20:05:41 2010 (r46825)
+++ branches/ucs4_encoding/src/packfile/pf_items.c Thu May 20 20:26:49 2010 (r46826)
@@ -1216,7 +1216,10 @@
ASSERT_ARGS(PF_fetch_string)
STRING *s;
UINTVAL flags;
+ UINTVAL encoding_nr;
UINTVAL charset_nr;
+ const ENCODING *encoding;
+ const CHARSET *charset;
size_t size;
const int wordsize = pf ? pf->header->wordsize : sizeof (opcode_t);
opcode_t flag_charset_word = PF_fetch_opcode(pf, cursor);
@@ -1224,20 +1227,31 @@
if (flag_charset_word == -1)
return STRINGNULL;
- /* decode flags and charset */
+ /* decode flags, charset and encoding */
flags = (flag_charset_word & 0x1 ? PObj_constant_FLAG : 0) |
(flag_charset_word & 0x2 ? PObj_private7_FLAG : 0) ;
- charset_nr = flag_charset_word >> 8;
+ encoding_nr = (flag_charset_word >> 16);
+ charset_nr = (flag_charset_word >> 8) & 0xFF;
size = (size_t)PF_fetch_opcode(pf, cursor);
TRACE_PRINTF(("PF_fetch_string(): flags=0x%04x, ", flags));
+ TRACE_PRINTF(("encoding_nr=%ld, ", encoding_nr));
TRACE_PRINTF(("charset_nr=%ld, ", charset_nr));
TRACE_PRINTF(("size=%ld.\n", size));
- s = string_make_from_charset(interp, (const char *)*cursor,
- size, charset_nr, flags);
+ encoding = Parrot_get_encoding(interp, encoding_nr);
+ charset = Parrot_get_charset(interp, charset_nr);
+ if (!encoding)
+ Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED,
+ "Invalid encoding number '%d' specified", encoding_nr);
+ if (!charset)
+ Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED,
+ "Invalid charset number '%d' specified", charset_nr);
+
+ s = Parrot_str_new_init(interp, (const char *)*cursor, size,
+ encoding, charset, flags);
/* print only printable characters */
TRACE_PRINTF_VAL(("PF_fetch_string(): string is '%s' at 0x%x\n",
@@ -1298,8 +1312,9 @@
* see also PF_fetch_string
*/
- /* encode charset_nr and flags into the same word for a 33% savings on constant overhead */
- *cursor++ = (Parrot_charset_number_of_str(NULL, s) << 8) |
+ /* encode charset_nr, encoding_nr and flags into the same word */
+ *cursor++ = (Parrot_encoding_number_of_str(NULL, s) << 16) |
+ (Parrot_charset_number_of_str(NULL, s) << 8) |
(PObj_get_FLAGS(s) & PObj_constant_FLAG ? 0x1 : 0x0) |
(PObj_get_FLAGS(s) & PObj_private7_FLAG ? 0x2 : 0x0) ;
*cursor++ = s->bufused;
Modified: branches/ucs4_encoding/src/string/api.c
==============================================================================
--- branches/ucs4_encoding/src/string/api.c Thu May 20 20:05:41 2010 (r46825)
+++ branches/ucs4_encoding/src/string/api.c Thu May 20 20:26:49 2010 (r46826)
@@ -2615,7 +2615,7 @@
else {
/* \xhh 1..2 hex digits */
pending = 1;
- for (digcount = 0; digcount < 2; ) {
+ for (digcount = 0; digcount < 2;) {
if (!isxdigit(c))
break;
digbuf[digcount] = c;
Modified: branches/ucs4_encoding/src/utils.c
==============================================================================
--- branches/ucs4_encoding/src/utils.c Thu May 20 20:05:41 2010 (r46825)
+++ branches/ucs4_encoding/src/utils.c Thu May 20 20:26:49 2010 (r46826)
@@ -62,12 +62,12 @@
static void next_rand(_rand_buf X);
static void process_cycle_without_exit(
int node_index,
- ARGIN(parrot_prm_context* c))
+ ARGIN(const parrot_prm_context *c))
__attribute__nonnull__(2);
static void rec_climb_back_and_mark(
int node_index,
- ARGIN(parrot_prm_context* c))
+ ARGIN(const parrot_prm_context *c))
__attribute__nonnull__(2);
#define ASSERT_ARGS__drand48 __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
@@ -664,8 +664,8 @@
/*
-=item C<static void rec_climb_back_and_mark(int node_index, parrot_prm_context*
-c)>
+=item C<static void rec_climb_back_and_mark(int node_index, const
+parrot_prm_context *c)>
Recursive function, used by Parrot_register_move to
climb back the graph of register moves operations.
@@ -689,7 +689,7 @@
*/
static void
-rec_climb_back_and_mark(int node_index, ARGIN(parrot_prm_context* c))
+rec_climb_back_and_mark(int node_index, ARGIN(const parrot_prm_context *c))
{
ASSERT_ARGS(rec_climb_back_and_mark)
const int node = c->dest_regs[node_index];
@@ -715,8 +715,8 @@
/*
-=item C<static void process_cycle_without_exit(int node_index,
-parrot_prm_context* c)>
+=item C<static void process_cycle_without_exit(int node_index, const
+parrot_prm_context *c)>
Recursive function, used by Parrot_register_move to handle the case
of cycles without exits, that are cycles of move ops between registers
@@ -732,7 +732,7 @@
*/
static void
-process_cycle_without_exit(int node_index, ARGIN(parrot_prm_context* c))
+process_cycle_without_exit(int node_index, ARGIN(const parrot_prm_context *c))
{
ASSERT_ARGS(process_cycle_without_exit)
const int pred = c->src_regs[node_index];
@@ -915,6 +915,7 @@
/* TODO: Macroize COMPARE */
/* This is an awfully expensive function to call, what with all the */
/* comparisons that never change. We ought to precompute everything. */
+/* XXX We should be able to guarantee that *a and *b never change via const parameters. */
static INTVAL
COMPARE(PARROT_INTERP, ARGIN(void *a), ARGIN(void *b), ARGIN(PMC *cmp))
{
Modified: branches/ucs4_encoding/t/native_pbc/annotations.pbc
==============================================================================
Binary file (source and/or target). No diff available.
Modified: branches/ucs4_encoding/t/native_pbc/integer_1.pbc
==============================================================================
Binary file (source and/or target). No diff available.
Modified: branches/ucs4_encoding/t/native_pbc/number_1.pbc
==============================================================================
Binary file (source and/or target). No diff available.
Modified: branches/ucs4_encoding/t/native_pbc/string_1.pbc
==============================================================================
Binary file (source and/or target). No diff available.
Modified: branches/ucs4_encoding/tools/build/headerizer.pl
==============================================================================
--- branches/ucs4_encoding/tools/build/headerizer.pl Thu May 20 20:05:41 2010 (r46825)
+++ branches/ucs4_encoding/tools/build/headerizer.pl Thu May 20 20:26:49 2010 (r46826)
@@ -89,8 +89,9 @@
my $heading = $headerizer->generate_documentation_signature($decl);
- $text =~ s/=item C<[^>]*\b$name\b[^>]*>\n+/$heading\n\n/sm or
- warn "$cfile_name: $name has no POD\n";
+ $text =~ s/=item C<[^>]*\b$name\b[^>]*>\n+/$heading\n\n/sm or do {
+ warn "$cfile_name: $name has no POD\n" unless $name =~ /^yy/; # lexer funcs don't have to have POD
+ }
}
open( my $fhout, '>', $cfile_name ) or die "Can't create $cfile_name: $!";
print {$fhout} $text;
@@ -126,7 +127,9 @@
push( @attrs, "__attribute__nonnull__($n)" );
}
if ( ( $arg =~ m{\*} ) && ( $arg !~ /\b(SHIM|((ARGIN|ARGOUT|ARGMOD)(_NULLOK)?)|ARGFREE(_NOTNULL)?)\b/ ) ) {
- $headerizer->squawk( $file, $name, qq{"$arg" isn't protected with an ARGIN, ARGOUT or ARGMOD (or a _NULLOK variant), or ARGFREE} );
+ if ( $name !~ /^yy/ ) { # Don't complain about the lexer auto-generated funcs
+ $headerizer->squawk( $file, $name, qq{"$arg" isn't protected with an ARGIN, ARGOUT or ARGMOD (or a _NULLOK variant), or ARGFREE} );
+ }
}
if ( ($arg =~ /\bconst\b/) && ($arg =~ /\*/) && ($arg !~ /\*\*/) && ($arg =~ /\b(ARG(MOD|OUT))\b/) ) {
$headerizer->squawk( $file, $name, qq{"$arg" is const, but that $1 conflicts with const} );
More information about the parrot-commits
mailing list