[svn:parrot] r44047 - in trunk: . compilers/data_json compilers/imcc compilers/json compilers/nqp compilers/pct compilers/pge compilers/tge config/auto/sizes docs/book/draft docs/book/pct docs/dev docs/pdds examples/embed examples/languages/abc examples/languages/squaak examples/pge ext/nqp-rx include/parrot lib/Parrot lib/Parrot/Configure/Step ports/cpan ports/cygwin ports/debian ports/fedora ports/mandriva ports/suse runtime/parrot/languages runtime/parrot/library runtime/parrot/library/Math runtime/parrot/library/Math/Random src/call src/gc src/interp src/pmc src/runcore t/compilers/tge t/library t/oo t/pmc t/src t/steps/init/hints tools/build tools/dev tools/util
whiteknight at svn.parrot.org
whiteknight at svn.parrot.org
Tue Feb 16 21:09:04 UTC 2010
Author: whiteknight
Date: Tue Feb 16 21:09:03 2010
New Revision: 44047
URL: https://trac.parrot.org/parrot/changeset/44047
Log:
merge the op_pmcs branch. This bumps PBC_COMPAT, which is going to require a realclean after updating. Also, I haven't regenerated the test PBCs yet, so the packfile tests are failing
Added:
trunk/src/pmc/opcode.pmc
- copied unchanged from r44044, branches/op_pmcs/src/pmc/opcode.pmc
trunk/src/pmc/oplib.pmc
- copied unchanged from r44044, branches/op_pmcs/src/pmc/oplib.pmc
trunk/t/pmc/opcode.t
- copied unchanged from r44044, branches/op_pmcs/t/pmc/opcode.t
trunk/t/pmc/oplib.t
- copied unchanged from r44044, branches/op_pmcs/t/pmc/oplib.t
Modified:
trunk/ (props changed)
trunk/PBC_COMPAT
trunk/compilers/data_json/Rules.mak (props changed)
trunk/compilers/imcc/Rules.mak (props changed)
trunk/compilers/json/Rules.mak (props changed)
trunk/compilers/nqp/Rules.mak (props changed)
trunk/compilers/pct/Rules.mak (props changed)
trunk/compilers/pge/Rules.mak (props changed)
trunk/compilers/tge/Rules.mak (props changed)
trunk/config/auto/sizes/intval_maxmin_c.in (props changed)
trunk/docs/book/draft/README (props changed)
trunk/docs/book/draft/appa_glossary.pod (props changed)
trunk/docs/book/draft/appb_patch_submission.pod (props changed)
trunk/docs/book/draft/appc_command_line_options.pod (props changed)
trunk/docs/book/draft/appd_build_options.pod (props changed)
trunk/docs/book/draft/appe_source_code.pod (props changed)
trunk/docs/book/draft/ch01_introduction.pod (props changed)
trunk/docs/book/draft/ch02_getting_started.pod (props changed)
trunk/docs/book/draft/ch07_dynpmcs.pod (props changed)
trunk/docs/book/draft/ch08_dynops.pod (props changed)
trunk/docs/book/draft/ch10_opcode_reference.pod (props changed)
trunk/docs/book/draft/ch11_directive_reference.pod (props changed)
trunk/docs/book/draft/ch12_operator_reference.pod (props changed)
trunk/docs/book/draft/chXX_hlls.pod (props changed)
trunk/docs/book/draft/chXX_library.pod (props changed)
trunk/docs/book/draft/chXX_testing_and_debugging.pod (props changed)
trunk/docs/book/pct/ch01_introduction.pod (props changed)
trunk/docs/book/pct/ch02_getting_started.pod (props changed)
trunk/docs/book/pct/ch03_compiler_tools.pod (props changed)
trunk/docs/book/pct/ch04_pge.pod (props changed)
trunk/docs/book/pct/ch05_nqp.pod (props changed)
trunk/docs/dev/c_functions.pod (props changed)
trunk/docs/pdds/pdd30_install.pod (props changed)
trunk/examples/embed/cotorra.c (props changed)
trunk/examples/languages/abc/ (props changed)
trunk/examples/languages/squaak/ (props changed)
trunk/examples/pge/demo.pir (props changed)
trunk/ext/nqp-rx/Rules.mak (props changed)
trunk/include/parrot/call.h (props changed)
trunk/include/parrot/gc_api.h (props changed)
trunk/include/parrot/runcore_api.h (props changed)
trunk/include/parrot/runcore_profiling.h (props changed)
trunk/include/parrot/runcore_trace.h (props changed)
trunk/lib/Parrot/Configure/Step/Test.pm (props changed)
trunk/lib/Parrot/H2inc.pm (props changed)
trunk/ports/cpan/pause_guide.pod (props changed)
trunk/ports/cygwin/parrot-1.0.0-1.cygport (props changed)
trunk/ports/debian/libparrot-dev.install.in (props changed)
trunk/ports/debian/libparrot.install.in (props changed)
trunk/ports/debian/parrot-doc.install.in (props changed)
trunk/ports/debian/parrot.install.in (props changed)
trunk/ports/fedora/parrot.spec.fedora (props changed)
trunk/ports/mandriva/parrot.spec.mandriva (props changed)
trunk/ports/suse/parrot.spec.suse (props changed)
trunk/runtime/parrot/languages/ (props changed)
trunk/runtime/parrot/library/Math/Rand.pir (props changed)
trunk/runtime/parrot/library/Math/Random/mt19937ar.pir (props changed)
trunk/runtime/parrot/library/Rules.mak (props changed)
trunk/src/call/ops.c (props changed)
trunk/src/call/pcc.c (props changed)
trunk/src/gc/alloc_memory.c (props changed)
trunk/src/gc/alloc_resources.c (props changed)
trunk/src/gc/api.c (props changed)
trunk/src/gc/malloc.c (props changed)
trunk/src/gc/malloc_trace.c (props changed)
trunk/src/gc/mark_sweep.c (props changed)
trunk/src/gc/system.c (props changed)
trunk/src/interp/inter_cb.c (props changed)
trunk/src/interp/inter_create.c (props changed)
trunk/src/interp/inter_misc.c (props changed)
trunk/src/pmc/pmc.num
trunk/src/runcore/cores.c (props changed)
trunk/src/runcore/main.c (props changed)
trunk/src/runcore/profiling.c (props changed)
trunk/src/runcore/trace.c (props changed)
trunk/t/compilers/tge/NoneGrammar.tg (props changed)
trunk/t/library/mt19937ar.t (props changed)
trunk/t/library/mt19937ar.txt (props changed)
trunk/t/oo/root_new.t (props changed)
trunk/t/pmc/namespace-old.t (props changed)
trunk/t/pmc/pmc.t
trunk/t/src/embed.t (props changed)
trunk/t/steps/init/hints/linux-01.t (props changed)
trunk/tools/build/cc_flags.pl (props changed)
trunk/tools/build/h2inc.pl (props changed)
trunk/tools/dev/fetch_languages.pl (props changed)
trunk/tools/dev/mk_gitignore.pl (props changed)
trunk/tools/util/perlcritic-cage.conf (props changed)
Modified: trunk/PBC_COMPAT
==============================================================================
--- trunk/PBC_COMPAT Tue Feb 16 21:05:51 2010 (r44046)
+++ trunk/PBC_COMPAT Tue Feb 16 21:09:03 2010 (r44047)
@@ -27,6 +27,7 @@
# please insert tab separated entries at the top of the list
+6.3 2010.02.16 whiteknight Add OpLib and Opcode PMCs
6.2 2010.01.31 cotto serialization-related changes to ParrotInterpreter
6.1 2010.01.30 whiteknight remove Array PMC
6.0 2010.01.19 chromatic released 2.0.0
Copied: trunk/src/pmc/opcode.pmc (from r44044, branches/op_pmcs/src/pmc/opcode.pmc)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/src/pmc/opcode.pmc Tue Feb 16 21:09:03 2010 (r44047, copy of r44044, branches/op_pmcs/src/pmc/opcode.pmc)
@@ -0,0 +1,67 @@
+#include "parrot/parrot.h"
+
+pmclass Opcode auto_attrs {
+ ATTR op_info_t *info;
+ ATTR INTVAL op_number;
+ ATTR STRING *full_name_cache;
+
+ VTABLE void init() {
+ Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
+ "Opcode must be created from OpLib.");
+ }
+
+ VTABLE void mark() {
+ Parrot_Opcode_attributes * const attrs = PARROT_OPCODE(SELF);
+ if (attrs->full_name_cache)
+ Parrot_gc_mark_STRING_alive(INTERP, attrs->full_name_cache);
+ }
+
+ VTABLE void set_pointer(void *i) {
+ Parrot_Opcode_attributes * const attrs = PARROT_OPCODE(SELF);
+ if (attrs->info)
+ Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
+ "Opcode has already been initialized");
+ attrs->info = (op_info_t *)i;
+ }
+
+ VTABLE void set_string_native(STRING *name) {
+ const char * const cstr = Parrot_str_to_cstring(INTERP, name);
+ const INTVAL num = INTERP->op_lib->op_code(cstr, 1);
+ Parrot_str_free_cstring(cstr);
+ if (num == -1)
+ Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_OUT_OF_BOUNDS,
+ "Opcode: Opcode %S not found", name);
+ VTABLE_set_integer_native(INTERP, SELF, num);
+ }
+
+ VTABLE INTVAL get_integer() {
+ Parrot_Opcode_attributes * const attrs = PARROT_OPCODE(SELF);
+ if (!attrs->info)
+ return -1;
+ return attrs->op_number;
+ }
+
+ VTABLE void set_integer_native(INTVAL value) {
+ const INTVAL opcount = INTERP->op_lib->op_count;
+ Parrot_Opcode_attributes * const attrs = PARROT_OPCODE(SELF);
+ if (attrs->info)
+ Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
+ "Opcode has already been initialized");
+ if (value >= opcount || value < 0)
+ Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_OUT_OF_BOUNDS,
+ "Opcode: Opcode index %d out of bounds", value);
+ attrs->info = &(INTERP->op_info_table[value]);
+ attrs->op_number = value;
+ }
+
+ VTABLE STRING* get_string() {
+ Parrot_Opcode_attributes * const attrs = PARROT_OPCODE(SELF);
+ if (attrs->full_name_cache == NULL) {
+ const char * const name = attrs->info->full_name;
+ const INTVAL len = strlen(name);
+ STRING * const newstr = Parrot_str_new(INTERP, name, len);
+ attrs->full_name_cache = newstr;
+ }
+ return attrs->full_name_cache;
+ }
+}
Copied: trunk/src/pmc/oplib.pmc (from r44044, branches/op_pmcs/src/pmc/oplib.pmc)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/src/pmc/oplib.pmc Tue Feb 16 21:09:03 2010 (r44047, copy of r44044, branches/op_pmcs/src/pmc/oplib.pmc)
@@ -0,0 +1,54 @@
+#include "parrot/parrot.h"
+
+/* TODO: Since Opcode PMCs are essentially read-only after initialization
+ here, we should cache them. A FixedPMCArray would be okay, an
+ INTVAL->PMC HASH might be better, since it's unlike that we will
+ need to cache even a majority of the ~1300 ops. */
+static PMC *OPLIB_PMC_INSTANCE;
+pmclass OpLib {
+ void class_init() {
+ OPLIB_PMC_INSTANCE = NULL;
+ }
+
+ VTABLE void *get_pointer() {
+ return OPLIB_PMC_INSTANCE;
+ }
+
+ VTABLE void set_pointer(void *ptr) {
+ OPLIB_PMC_INSTANCE = (PMC *)ptr;
+ }
+
+ /* Look up an opnumber given the name of the op. First we look for the
+ specific name, then the more general short name. */
+ VTABLE INTVAL get_integer_keyed_str(STRING *name) {
+ const char * const cstr = Parrot_str_to_cstring(INTERP, name);
+ INTVAL num = INTERP->op_lib->op_code(cstr, 1);
+ if (num == -1)
+ num = INTERP->op_lib->op_code(cstr, 0);
+ Parrot_str_free_cstring(cstr);
+ return num;
+ }
+
+ VTABLE PMC* get_pmc_keyed_str(STRING *name) {
+ PMC * const op = pmc_new_noinit(INTERP, enum_class_Opcode);
+ VTABLE_set_string_native(INTERP, op, name);
+ PObj_custom_mark_SET(op);
+ return op;
+ }
+
+ VTABLE PMC* get_pmc_keyed(PMC *key) {
+ STRING * const strkey = VTABLE_get_string(INTERP, key);
+ return VTABLE_get_pmc_keyed_str(INTERP, SELF, strkey);
+ }
+
+ VTABLE PMC* get_pmc_keyed_int(INTVAL value) {
+ PMC * const op = pmc_new_noinit(INTERP, enum_class_Opcode);
+ VTABLE_set_integer_native(INTERP, op, value);
+ PObj_custom_mark_SET(op);
+ return op;
+ }
+
+ VTABLE INTVAL get_integer() {
+ return INTERP->op_lib->op_count;
+ }
+}
Modified: trunk/src/pmc/pmc.num
==============================================================================
--- trunk/src/pmc/pmc.num Tue Feb 16 21:05:51 2010 (r44046)
+++ trunk/src/pmc/pmc.num Tue Feb 16 21:09:03 2010 (r44047)
@@ -79,3 +79,6 @@
os.pmc 51
file.pmc 52
+
+oplib.pmc 53
+opcode.pmc 54
Copied: trunk/t/pmc/opcode.t (from r44044, branches/op_pmcs/t/pmc/opcode.t)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/t/pmc/opcode.t Tue Feb 16 21:09:03 2010 (r44047, copy of r44044, branches/op_pmcs/t/pmc/opcode.t)
@@ -0,0 +1,29 @@
+#! parrot
+# Copyright (C) 2001-2009, Parrot Foundation.
+# $Id: fixedpmcarray.t 42684 2009-11-21 13:40:19Z jkeenan $
+
+=head1 NAME
+
+t/pmc/opcode.t - Opcode PMC
+
+=head1 SYNOPSIS
+
+ % prove t/pmc/opcode.t
+
+=cut
+
+.sub main :main
+ .include 'test_more.pir'
+ plan(1)
+ cannot_create_directly()
+.end
+
+.sub cannot_create_directly
+ push_eh cannot_create
+ $P0 = new ['Opcode']
+ ok(0, "shouldn't be able to create new opcode")
+ goto create_end
+ cannot_create:
+ ok(1)
+ create_end:
+.end
Copied: trunk/t/pmc/oplib.t (from r44044, branches/op_pmcs/t/pmc/oplib.t)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/t/pmc/oplib.t Tue Feb 16 21:09:03 2010 (r44047, copy of r44044, branches/op_pmcs/t/pmc/oplib.t)
@@ -0,0 +1,30 @@
+#! parrot
+# Copyright (C) 2001-2009, Parrot Foundation.
+# $Id: fixedpmcarray.t 42684 2009-11-21 13:40:19Z jkeenan $
+
+=head1 NAME
+
+t/pmc/oplib.t - OpLib PMC
+
+=head1 SYNOPSIS
+
+ % prove t/pmc/oplib.t
+
+=cut
+
+.sub main :main
+ .include 'test_more.pir'
+ plan(1)
+ get_singleton()
+.end
+
+.sub get_singleton
+ $P0 = new ['OpLib']
+ $I0 = isnull $P0
+ is($I0, 0)
+
+ # TODO: How to test that this is actually a singleton?
+ #$P1 = new ['OpLib']
+ #is($P0, $P1)
+.end
+
Modified: trunk/t/pmc/pmc.t
==============================================================================
--- trunk/t/pmc/pmc.t Tue Feb 16 21:05:51 2010 (r44046)
+++ trunk/t/pmc/pmc.t Tue Feb 16 21:09:03 2010 (r44047)
@@ -51,7 +51,7 @@
my $checkTypes;
my %types_we_cant_test
= map { $_ => 1; } ( # These require initializers.
- qw(default Null Iterator ArrayIterator HashIterator StringIterator OrderedHashIterator Enumerate ParrotObject ParrotThread BigInt LexInfo LexPad Object Handle),
+ qw(default Null Iterator ArrayIterator HashIterator StringIterator OrderedHashIterator Enumerate ParrotObject ParrotThread BigInt LexInfo LexPad Object Handle Opcode),
# Instances of these appear to have other types.
qw(PMCProxy Class) );
More information about the parrot-commits
mailing list