[svn:parrot] r48917 - in branches/oplib_handling_cleanup: . compilers/imcc config/auto config/gen/config_h include/parrot lib/Parrot runtime/parrot/library src src/gc src/interp src/pmc src/runcore t/pmc t/src tools/dev
plobsing at svn.parrot.org
plobsing at svn.parrot.org
Fri Sep 10 20:06:28 UTC 2010
Author: plobsing
Date: Fri Sep 10 20:06:27 2010
New Revision: 48917
URL: https://trac.parrot.org/parrot/changeset/48917
Log:
sync with trunk
Modified:
branches/oplib_handling_cleanup/ (props changed)
branches/oplib_handling_cleanup/compilers/imcc/pbc.c
branches/oplib_handling_cleanup/config/auto/gcc.pm
branches/oplib_handling_cleanup/config/auto/msvc.pm
branches/oplib_handling_cleanup/config/gen/config_h/config_h.in
branches/oplib_handling_cleanup/include/parrot/packfile.h
branches/oplib_handling_cleanup/include/parrot/runcore_trace.h (props changed)
branches/oplib_handling_cleanup/lib/Parrot/Headerizer.pm
branches/oplib_handling_cleanup/runtime/parrot/library/P6object.pir
branches/oplib_handling_cleanup/src/gc/system.c
branches/oplib_handling_cleanup/src/interp/inter_create.c (props changed)
branches/oplib_handling_cleanup/src/oo.c
branches/oplib_handling_cleanup/src/packfile.c
branches/oplib_handling_cleanup/src/packout.c
branches/oplib_handling_cleanup/src/pmc/bytebuffer.pmc
branches/oplib_handling_cleanup/src/pmc/nativepccmethod.pmc
branches/oplib_handling_cleanup/src/pmc/packfileannotations.pmc
branches/oplib_handling_cleanup/src/pmc/stringbuilder.pmc
branches/oplib_handling_cleanup/src/runcore/cores.c (props changed)
branches/oplib_handling_cleanup/src/runcore/trace.c (props changed)
branches/oplib_handling_cleanup/t/pmc/hashiteratorkey.t
branches/oplib_handling_cleanup/t/pmc/lexinfo.t
branches/oplib_handling_cleanup/t/src/embed.t (props changed)
branches/oplib_handling_cleanup/tools/dev/fetch_languages.pl
branches/oplib_handling_cleanup/tools/dev/headerizer.pl
branches/oplib_handling_cleanup/tools/dev/mk_gitignore.pl (props changed)
branches/oplib_handling_cleanup/tools/dev/nci_thunk_gen.pir
Modified: branches/oplib_handling_cleanup/compilers/imcc/pbc.c
==============================================================================
--- branches/oplib_handling_cleanup/compilers/imcc/pbc.c Fri Sep 10 19:56:58 2010 (r48916)
+++ branches/oplib_handling_cleanup/compilers/imcc/pbc.c Fri Sep 10 20:06:27 2010 (r48917)
@@ -361,11 +361,11 @@
}
else {
/* initialize rlookup cache */
- interp->code->const_table->string_hash =
- Parrot_pmc_new_init_int(interp, enum_class_Hash, enum_type_INTVAL);
- ((Hash *)VTABLE_get_pointer(interp, interp->code->const_table->string_hash))->compare =
- (hash_comp_fn)hash_compare_string_distinct_enc;
-
+ interp->code->const_table->string_hash = parrot_create_hash(interp,
+ enum_type_INTVAL,
+ Hash_key_type_STRING,
+ hash_compare_string_distinct_enc,
+ (hash_hash_key_fn)key_hash_STRING);
interp->code->const_table->constants =
mem_gc_allocate_n_zeroed_typed(interp, newcount, PackFile_Constant);
}
@@ -1144,7 +1144,7 @@
constant->type = PFC_STRING;
constant->u.string = s;
- VTABLE_set_integer_keyed_str(interp, table->string_hash, s, k);
+ parrot_hash_put(interp, table->string_hash, s, (void *)k);
return k;
}
Modified: branches/oplib_handling_cleanup/config/auto/gcc.pm
==============================================================================
--- branches/oplib_handling_cleanup/config/auto/gcc.pm Fri Sep 10 19:56:58 2010 (r48916)
+++ branches/oplib_handling_cleanup/config/auto/gcc.pm Fri Sep 10 20:06:27 2010 (r48917)
@@ -86,6 +86,7 @@
$conf->data->set( sym_export => '__attribute__ ((visibility("default")))' )
if $gccversion >= 4.0 && !$conf->data->get('sym_export');
+ $conf->data->set( noinline => '__attribute__ ((noinline))' );
# sneaky check for g++
my $gpp = (index($conf->data->get('cc'), '++') > 0) ? 1 : 0;
Modified: branches/oplib_handling_cleanup/config/auto/msvc.pm
==============================================================================
--- branches/oplib_handling_cleanup/config/auto/msvc.pm Fri Sep 10 19:56:58 2010 (r48916)
+++ branches/oplib_handling_cleanup/config/auto/msvc.pm Fri Sep 10 20:06:27 2010 (r48917)
@@ -89,6 +89,9 @@
# for details.
$conf->data->add( " ", "ccflags", "-D_CRT_SECURE_NO_DEPRECATE" );
}
+
+ $conf->data->set( noinline => '__declspec(noinline)' );
+
return 1;
}
Modified: branches/oplib_handling_cleanup/config/gen/config_h/config_h.in
==============================================================================
--- branches/oplib_handling_cleanup/config/gen/config_h/config_h.in Fri Sep 10 19:56:58 2010 (r48916)
+++ branches/oplib_handling_cleanup/config/gen/config_h/config_h.in Fri Sep 10 20:06:27 2010 (r48917)
@@ -84,6 +84,8 @@
#endif
#endif
+#define PARROT_NOINLINE @noinline@
+
#if defined(PARROT_IN_CORE)
/* Put any other symbols here. */
Modified: branches/oplib_handling_cleanup/include/parrot/packfile.h
==============================================================================
--- branches/oplib_handling_cleanup/include/parrot/packfile.h Fri Sep 10 19:56:58 2010 (r48916)
+++ branches/oplib_handling_cleanup/include/parrot/packfile.h Fri Sep 10 20:06:27 2010 (r48917)
@@ -263,7 +263,7 @@
opcode_t const_count;
PackFile_Constant *constants;
PackFile_ByteCode *code; /* where this segment belongs to */
- PMC *string_hash; /* Hash for lookup strings and numbers */
+ Hash *string_hash; /* Hash for lookup strings and numbers */
} PackFile_ConstTable;
typedef struct PackFile_ByteCode_OpMappingEntry {
Modified: branches/oplib_handling_cleanup/lib/Parrot/Headerizer.pm
==============================================================================
--- branches/oplib_handling_cleanup/lib/Parrot/Headerizer.pm Fri Sep 10 19:56:58 2010 (r48916)
+++ branches/oplib_handling_cleanup/lib/Parrot/Headerizer.pm Fri Sep 10 20:06:27 2010 (r48917)
@@ -45,6 +45,7 @@
$self->{valid_macros} = { map { ( $_, 1 ) } qw(
PARROT_EXPORT
PARROT_INLINE
+ PARROT_NOINLINE
PARROT_CAN_RETURN_NULL
PARROT_CANNOT_RETURN_NULL
Modified: branches/oplib_handling_cleanup/runtime/parrot/library/P6object.pir
==============================================================================
--- branches/oplib_handling_cleanup/runtime/parrot/library/P6object.pir Fri Sep 10 19:56:58 2010 (r48916)
+++ branches/oplib_handling_cleanup/runtime/parrot/library/P6object.pir Fri Sep 10 20:06:27 2010 (r48917)
@@ -260,6 +260,9 @@
.local pmc methodpmc
methodname = shift methoditer
methodpmc = methods[methodname]
+ # don't add NativePCCMethods
+ $I0 = isa methodpmc, 'NativePCCMethod'
+ if $I0 goto method_loop
# don't add NCI methods (they don't work)
$I0 = isa methodpmc, 'NCI'
if $I0 goto method_loop
Modified: branches/oplib_handling_cleanup/src/gc/system.c
==============================================================================
--- branches/oplib_handling_cleanup/src/gc/system.c Fri Sep 10 19:56:58 2010 (r48916)
+++ branches/oplib_handling_cleanup/src/gc/system.c Fri Sep 10 20:06:27 2010 (r48917)
@@ -75,6 +75,7 @@
__attribute__nonnull__(1)
__attribute__nonnull__(2);
+PARROT_NOINLINE
static void trace_system_stack(PARROT_INTERP,
ARGIN(const Memory_Pools *mem_pools))
__attribute__nonnull__(1)
@@ -234,12 +235,14 @@
Traces the memory block starting at C<< interp->lo_var_ptr >>. This should be
the address of a local variable which has been created on the stack early in
the interpreter's lifecycle. We trace until the address of another local stack
-variable in this function, which should be at the "top" of the stack.
+variable in this function, which should be at the "top" of the stack. For this
+reason, this function must never be inlined.
=cut
*/
+PARROT_NOINLINE
static void
trace_system_stack(PARROT_INTERP, ARGIN(const Memory_Pools *mem_pools))
{
Modified: branches/oplib_handling_cleanup/src/oo.c
==============================================================================
--- branches/oplib_handling_cleanup/src/oo.c Fri Sep 10 19:56:58 2010 (r48916)
+++ branches/oplib_handling_cleanup/src/oo.c Fri Sep 10 20:06:27 2010 (r48917)
@@ -260,12 +260,8 @@
|| base_type == enum_class_ResizableStringArray
|| base_type == enum_class_String)
type = Parrot_pmc_get_type(interp, key);
- else if (VTABLE_does(interp, key, CONST_STRING(interp, "string")) ||
- base_type == enum_class_NameSpace)
- type = Parrot_pmc_get_type_str(interp, VTABLE_get_string(interp, key));
else
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
- "can't get class from an instance of class '%Ss'", VTABLE_name(interp, key));
+ type = Parrot_pmc_get_type_str(interp, VTABLE_get_string(interp, key));
classobj = get_pmc_proxy(interp, type);
}
Modified: branches/oplib_handling_cleanup/src/packfile.c
==============================================================================
--- branches/oplib_handling_cleanup/src/packfile.c Fri Sep 10 19:56:58 2010 (r48916)
+++ branches/oplib_handling_cleanup/src/packfile.c Fri Sep 10 20:06:27 2010 (r48917)
@@ -3912,6 +3912,11 @@
self->const_count = 0;
+ if (self->string_hash) {
+ parrot_hash_destroy(interp, self->string_hash);
+ self->string_hash = NULL;
+ }
+
return;
}
Modified: branches/oplib_handling_cleanup/src/packout.c
==============================================================================
--- branches/oplib_handling_cleanup/src/packout.c Fri Sep 10 19:56:58 2010 (r48916)
+++ branches/oplib_handling_cleanup/src/packout.c Fri Sep 10 20:06:27 2010 (r48917)
@@ -273,9 +273,11 @@
GETATTR_Key_str_key(interp, key, key_str);
GETATTR_Key_num_key(interp, key, key_num);
- if (type == PFC_STRING && !PMC_IS_NULL(ct->string_hash)) {
- if (VTABLE_exists_keyed_str(interp, ct->string_hash, key_str)) {
- i = VTABLE_get_integer_keyed_str(interp, ct->string_hash, key_str);
+ if (type == PFC_STRING && ct->string_hash) {
+ HashBucket *bucket = parrot_hash_get_bucket(interp, ct->string_hash,
+ key_str);
+ if (bucket) {
+ i = (int)bucket->value;
if (i < ct->const_count) /* only consider constants that have already occured */
return i;
}
Modified: branches/oplib_handling_cleanup/src/pmc/bytebuffer.pmc
==============================================================================
--- branches/oplib_handling_cleanup/src/pmc/bytebuffer.pmc Fri Sep 10 19:56:58 2010 (r48916)
+++ branches/oplib_handling_cleanup/src/pmc/bytebuffer.pmc Fri Sep 10 20:06:27 2010 (r48917)
@@ -393,16 +393,10 @@
ARGIN_NULLOK(const STR_VTABLE *encoding))
{
ASSERT_ARGS(build_string)
- STRING *result;
if (encoding == NULL)
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_ENCODING,
"Invalid encoding");
- result = Parrot_str_new_init(interp, (const char *)content, size, encoding, 0);
- if (!STRING_validate(interp, result))
- Parrot_ex_throw_from_c_args(interp, NULL,
- EXCEPTION_INVALID_STRING_REPRESENTATION,
- "Invalid buffer content");
- return result;
+ return Parrot_str_new_init(interp, (const char *)content, size, encoding, 0);
}
/*
Modified: branches/oplib_handling_cleanup/src/pmc/nativepccmethod.pmc
==============================================================================
--- branches/oplib_handling_cleanup/src/pmc/nativepccmethod.pmc Fri Sep 10 19:56:58 2010 (r48916)
+++ branches/oplib_handling_cleanup/src/pmc/nativepccmethod.pmc Fri Sep 10 20:06:27 2010 (r48917)
@@ -20,7 +20,7 @@
/* HEADERIZER HFILE: none */
-pmclass NativePCCMethod auto_attrs {
+pmclass NativePCCMethod auto_attrs provides invokable {
ATTR STRING *signature;
ATTR void *func;
Modified: branches/oplib_handling_cleanup/src/pmc/packfileannotations.pmc
==============================================================================
--- branches/oplib_handling_cleanup/src/pmc/packfileannotations.pmc Fri Sep 10 19:56:58 2010 (r48916)
+++ branches/oplib_handling_cleanup/src/pmc/packfileannotations.pmc Fri Sep 10 20:06:27 2010 (r48917)
@@ -80,6 +80,8 @@
PARROT_PACKFILEANNOTATIONS(SELF);
Parrot_gc_mark_PMC_alive(INTERP, attrs->const_table);
+ Parrot_gc_mark_PMC_alive(INTERP, attrs->gr_byte);
+ Parrot_gc_mark_PMC_alive(INTERP, attrs->gr_entries);
Parrot_gc_mark_PMC_alive(INTERP, attrs->annotations);
SUPER();
Modified: branches/oplib_handling_cleanup/src/pmc/stringbuilder.pmc
==============================================================================
--- branches/oplib_handling_cleanup/src/pmc/stringbuilder.pmc Fri Sep 10 19:56:58 2010 (r48916)
+++ branches/oplib_handling_cleanup/src/pmc/stringbuilder.pmc Fri Sep 10 20:06:27 2010 (r48917)
@@ -61,23 +61,17 @@
*/
VTABLE void init_int(INTVAL initial_size) {
- STRING * const buffer = mem_gc_allocate_zeroed_typed(INTERP, STRING);
+ STRING * const buffer = Parrot_gc_new_string_header(INTERP, 0);
if (initial_size < INITIAL_STRING_CAPACITY)
initial_size = INITIAL_STRING_CAPACITY;
- buffer->encoding = Parrot_default_encoding_ptr;
- buffer->_buflen = initial_size;
- buffer->_bufstart = buffer->strstart
- = mem_gc_allocate_n_typed(INTERP,
- initial_size, char);
-
- /* We need these string flags to use this buffer in substr_str */
- buffer->flags = PObj_is_string_FLAG | PObj_external_FLAG;
+ Parrot_gc_allocate_string_storage(INTERP, buffer, initial_size);
+ buffer->encoding = Parrot_default_encoding_ptr;
SET_ATTR_buffer(INTERP, SELF, buffer);
- PObj_custom_destroy_SET(SELF);
+ PObj_custom_mark_SET(SELF);
}
@@ -110,24 +104,21 @@
}
}
-
/*
-=item C<void destroy()>
+=item C<void mark()>
-Free the buffer on destruction.
+Mark the buffer.
=cut
*/
- VTABLE void destroy() {
+ VTABLE void mark() {
if (PMC_data(SELF)) {
STRING *buffer;
GET_ATTR_buffer(INTERP, SELF, buffer);
- if (buffer->_bufstart)
- mem_gc_free(INTERP, buffer->_bufstart);
- mem_gc_free(INTERP, buffer);
+ Parrot_gc_mark_STRING_alive(INTERP, buffer);
}
}
@@ -197,13 +188,9 @@
if (total_size > buffer->_buflen) {
/* Reallocate */
- mem_gc_free(INTERP, buffer->_bufstart);
total_size = calculate_capacity(INTERP, total_size);
- buffer->_bufstart = buffer->strstart
- = mem_gc_allocate_n_typed(INTERP, total_size, char);
- buffer->_buflen = total_size;
+ Parrot_gc_reallocate_string_storage(INTERP, buffer, total_size);
}
-
buffer->bufused = new_buffer->bufused;
buffer->encoding = new_buffer->encoding;
@@ -220,17 +207,17 @@
/* Calculate (possibly new) total size */
total_size = calculate_capacity(INTERP, total_size);
- buffer->_bufstart = buffer->strstart = mem_gc_realloc_n_typed(INTERP,
- buffer->_bufstart, total_size, char);
- buffer->_buflen = total_size;
+ Parrot_gc_reallocate_string_storage(INTERP, buffer, total_size);
+ buffer->_buflen = total_size;
}
/* Tack s on the end of buffer */
- mem_sys_memcopy((void *)((ptrcast_t)buffer->strstart + buffer->bufused),
+ mem_sys_memcopy((void *)((ptrcast_t)buffer->_bufstart + buffer->bufused),
s->strstart, s->bufused);
/* Update buffer */
buffer->bufused += s->bufused;
+ buffer->strstart = (char *)buffer->_bufstart;
buffer->strlen += Parrot_str_length(INTERP, s);
buffer->hashval = 0; /* hash is invalid */
@@ -282,13 +269,12 @@
/* Reallocate if necessary */
if (total_size > Buffer_buflen(buffer)) {
- buffer->_bufstart = buffer->strstart = mem_gc_realloc_n_typed(INTERP,
- buffer->_bufstart, total_size, char);
- buffer->_buflen = total_size;
+ Parrot_gc_reallocate_string_storage(INTERP, buffer, total_size);
+ buffer->strstart = (char*)buffer->_bufstart;
}
/* Tack s on the buffer */
- mem_sys_memcopy((void *)((ptrcast_t)buffer->strstart),
+ mem_sys_memcopy((void *)((char*)buffer->_bufstart),
s->strstart, s->bufused);
/* Update buffer */
Modified: branches/oplib_handling_cleanup/t/pmc/hashiteratorkey.t
==============================================================================
--- branches/oplib_handling_cleanup/t/pmc/hashiteratorkey.t Fri Sep 10 19:56:58 2010 (r48916)
+++ branches/oplib_handling_cleanup/t/pmc/hashiteratorkey.t Fri Sep 10 20:06:27 2010 (r48917)
@@ -20,11 +20,22 @@
.sub 'main'
.include 'test_more.pir'
- plan(3)
+ plan(6)
+ 'test_new'()
+ 'test_key_value'()
+ 'test_empty'()
+
+.end
+
+
+.sub 'test_new'
$P0 = new ['HashIteratorKey']
ok(1, "Can create HashIteratorKey directly")
+.end
+
+.sub 'test_key_value'
$P0 = new ['Hash']
$P0['foo'] = 'bar'
$P1 = iter $P0
@@ -36,6 +47,27 @@
.end
+.sub 'test_empty'
+ .local pmc hik, p
+ .local int i
+ .local string s
+ hik = new ['HashIteratorKey']
+
+ # De facto behavior tested for code coverage
+
+ p = hik.'key'()
+ i = isnull p
+ is(i, 1, 'HIK.key gives null when unitialized')
+
+ s = hik
+ is(s, '', 'HIK gives empty string when unitialized')
+
+ # Magic value?
+ i = hik
+ is(i, -1, 'HIK get_integer gives -1')
+.end
+
+
# Local Variables:
# mode: pir
# fill-column: 100
Modified: branches/oplib_handling_cleanup/t/pmc/lexinfo.t
==============================================================================
--- branches/oplib_handling_cleanup/t/pmc/lexinfo.t Fri Sep 10 19:56:58 2010 (r48916)
+++ branches/oplib_handling_cleanup/t/pmc/lexinfo.t Fri Sep 10 20:06:27 2010 (r48917)
@@ -17,11 +17,15 @@
=cut
+.include 'except_types.pasm'
+
.sub main :main
.include 'test_more.pir'
- plan(3)
+ plan(5)
inspect_test()
+ inspect_invalid_test()
+ declare_lex_preg_test()
.end
.sub inspect_test
@@ -58,6 +62,33 @@
is(have_b, 1, "$b symbol was in list")
.end
+.sub inspect_invalid_test
+ .local pmc li, in, ex
+ .local int r, type
+ li = new ['LexInfo']
+ r = 0
+ push_eh catch
+ in = inspect li, 'fubar'
+ goto done
+ catch:
+ .get_results(ex)
+ type = ex['type']
+ r = iseq type, .EXCEPTION_INVALID_OPERATION
+ done:
+ ok(r, 'invalid introspection key throws as expected')
+.end
+
+.sub declare_lex_preg_test
+ .const string preg_name = 'foo'
+ .const int preg_value = 42
+ .local pmc li
+ li = new ['LexInfo']
+ li.'declare_lex_preg'(preg_name, preg_value)
+ .local int r
+ r = li[preg_name]
+ is(r, preg_value, 'declare_lex_preg method')
+.end
+
# Local Variables:
# mode: pir
# fill-column: 100
Modified: branches/oplib_handling_cleanup/tools/dev/fetch_languages.pl
==============================================================================
--- branches/oplib_handling_cleanup/tools/dev/fetch_languages.pl Fri Sep 10 19:56:58 2010 (r48916)
+++ branches/oplib_handling_cleanup/tools/dev/fetch_languages.pl Fri Sep 10 20:06:27 2010 (r48917)
@@ -231,7 +231,7 @@
{
name => 'pir',
scm => 'GIT',
- repository => 'http://github.com/bacek/pir.git'
+ repository => 'http://github.com/parrot/pir.git'
},
{
Modified: branches/oplib_handling_cleanup/tools/dev/headerizer.pl
==============================================================================
--- branches/oplib_handling_cleanup/tools/dev/headerizer.pl Fri Sep 10 19:56:58 2010 (r48916)
+++ branches/oplib_handling_cleanup/tools/dev/headerizer.pl Fri Sep 10 20:06:27 2010 (r48917)
@@ -329,7 +329,11 @@
# Walk the object files and find corresponding source (either .c or .pmc)
for my $ofile (@ofiles) {
- next if $ofile =~ m/^\Qsrc$PConfig{slash}ops\E/;
+
+ # Skip files in the src/ops/ subdirectory.
+
+ next if $ofile =~ m/^\Qsrc$PConfig{slash}ops\E/ || # if run by hand...
+ $ofile =~ m{^src/ops}; # ... or by makefile
$ofile =~ s/\\/\//g;
Modified: branches/oplib_handling_cleanup/tools/dev/nci_thunk_gen.pir
==============================================================================
--- branches/oplib_handling_cleanup/tools/dev/nci_thunk_gen.pir Fri Sep 10 19:56:58 2010 (r48916)
+++ branches/oplib_handling_cleanup/tools/dev/nci_thunk_gen.pir Fri Sep 10 20:06:27 2010 (r48917)
@@ -313,7 +313,7 @@
str_file = concat str_file, '.str'
.local string head
- head = 'sprintf'(<<'HEAD', c_file, ext_defn, str_file)
+ head = 'sprintf'(<<'HEADSTART', c_file)
/* ex: set ro ft=c:
* !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
*
@@ -326,7 +326,13 @@
/* %s
* Copyright (C) 2010, Parrot Foundation.
* SVN Info
- * $Id$
+HEADSTART
+
+ # Avoid svn mangling here by hex encoding the dollar signs
+ head = concat head, " * \x{24}Id: \x{24}\n"
+
+ .local string headtail
+ headtail = 'sprintf'(<<'HEAD', ext_defn, str_file)
* Overview:
* Native Call Interface routines. The code needed to build a
* parrot to C call frame is in here
@@ -355,6 +361,7 @@
hackish, but that is just fine */
HEAD
+ head = concat head, headtail
.return (head)
.end
More information about the parrot-commits
mailing list