[svn:parrot] r41302 - in branches/gc-refactor: . compilers/imcc compilers/pirc/src config/auto config/auto/sizes config/gen/makefiles docs docs/book/draft docs/book/pct docs/dev docs/pdds docs/project examples/benchmarks examples/embed examples/languages/abc examples/languages/squaak examples/nci examples/pge include/parrot lib/Parrot/Harness lib/Parrot/Pmc2c ports/cpan ports/cygwin ports/debian ports/fedora ports/mandriva ports/suse runtime/parrot/languages runtime/parrot/library runtime/parrot/library/Math src src/call src/dynpmc src/gc src/interp src/jit/i386 src/ops src/pmc src/runcore src/string t t/codingstd t/compilers/tge t/oo t/op t/pmc t/src t/tools tools/build tools/dev tools/util
jrtayloriv at svn.parrot.org
jrtayloriv at svn.parrot.org
Wed Sep 16 18:24:40 UTC 2009
Author: jrtayloriv
Date: Wed Sep 16 18:24:30 2009
New Revision: 41302
URL: https://trac.parrot.org/parrot/changeset/41302
Log:
Syncing branch with trunk prior to merge
Added:
branches/gc-refactor/include/parrot/runcore_profiling.h
- copied unchanged from r41301, trunk/include/parrot/runcore_profiling.h
branches/gc-refactor/runtime/parrot/library/SQLite3.pir
- copied unchanged from r41301, trunk/runtime/parrot/library/SQLite3.pir
branches/gc-refactor/src/runcore/profiling.c
- copied unchanged from r41301, trunk/src/runcore/profiling.c
branches/gc-refactor/tools/dev/vgp_darwin
- copied unchanged from r41301, trunk/tools/dev/vgp_darwin
Deleted:
branches/gc-refactor/include/parrot/pic.h
branches/gc-refactor/src/ops/pic.ops
branches/gc-refactor/src/pic.c
branches/gc-refactor/src/pic_jit.c
Modified:
branches/gc-refactor/ (props changed)
branches/gc-refactor/CREDITS
branches/gc-refactor/ChangeLog
branches/gc-refactor/DEPRECATED.pod
branches/gc-refactor/MANIFEST
branches/gc-refactor/MANIFEST.SKIP
branches/gc-refactor/MANIFEST.generated
branches/gc-refactor/META.yml
branches/gc-refactor/NEWS
branches/gc-refactor/PBC_COMPAT
branches/gc-refactor/PLATFORMS
branches/gc-refactor/README
branches/gc-refactor/VERSION
branches/gc-refactor/compilers/imcc/imc.h
branches/gc-refactor/compilers/imcc/imcc.l
branches/gc-refactor/compilers/imcc/imcc.y
branches/gc-refactor/compilers/imcc/imclexer.c
branches/gc-refactor/compilers/imcc/imcparser.c
branches/gc-refactor/compilers/imcc/main.c
branches/gc-refactor/compilers/imcc/parser_util.c
branches/gc-refactor/compilers/imcc/pbc.c
branches/gc-refactor/compilers/pirc/src/bcgen.c
branches/gc-refactor/config/auto/headers.pm
branches/gc-refactor/config/auto/msvc.pm
branches/gc-refactor/config/auto/sizes/intval_maxmin_c.in (props changed)
branches/gc-refactor/config/gen/makefiles/root.in
branches/gc-refactor/docs/book/draft/README (props changed)
branches/gc-refactor/docs/book/draft/appa_glossary.pod (props changed)
branches/gc-refactor/docs/book/draft/appb_patch_submission.pod (props changed)
branches/gc-refactor/docs/book/draft/appc_command_line_options.pod (props changed)
branches/gc-refactor/docs/book/draft/appd_build_options.pod (props changed)
branches/gc-refactor/docs/book/draft/appe_source_code.pod (props changed)
branches/gc-refactor/docs/book/draft/ch01_introduction.pod (props changed)
branches/gc-refactor/docs/book/draft/ch02_getting_started.pod (props changed)
branches/gc-refactor/docs/book/draft/ch07_dynpmcs.pod (props changed)
branches/gc-refactor/docs/book/draft/ch08_dynops.pod (props changed)
branches/gc-refactor/docs/book/draft/ch10_opcode_reference.pod (props changed)
branches/gc-refactor/docs/book/draft/ch11_directive_reference.pod (props changed)
branches/gc-refactor/docs/book/draft/ch12_operator_reference.pod (props changed)
branches/gc-refactor/docs/book/draft/chXX_hlls.pod (props changed)
branches/gc-refactor/docs/book/draft/chXX_library.pod (props changed)
branches/gc-refactor/docs/book/draft/chXX_testing_and_debugging.pod (props changed)
branches/gc-refactor/docs/book/pct/ch01_introduction.pod (props changed)
branches/gc-refactor/docs/book/pct/ch02_getting_started.pod (props changed)
branches/gc-refactor/docs/book/pct/ch03_compiler_tools.pod (props changed)
branches/gc-refactor/docs/book/pct/ch04_pge.pod (props changed)
branches/gc-refactor/docs/book/pct/ch05_nqp.pod (props changed)
branches/gc-refactor/docs/dev/c_functions.pod (props changed)
branches/gc-refactor/docs/embed.pod
branches/gc-refactor/docs/parrothist.pod
branches/gc-refactor/docs/pdds/pdd15_objects.pod
branches/gc-refactor/docs/pdds/pdd30_install.pod (props changed)
branches/gc-refactor/docs/project/release_manager_guide.pod
branches/gc-refactor/docs/running.pod
branches/gc-refactor/examples/benchmarks/oofib.pir
branches/gc-refactor/examples/embed/cotorra.c (contents, props changed)
branches/gc-refactor/examples/languages/abc/ (props changed)
branches/gc-refactor/examples/languages/squaak/ (props changed)
branches/gc-refactor/examples/nci/Mysql.pir
branches/gc-refactor/examples/nci/mysqltest.p6
branches/gc-refactor/examples/nci/mysqltest.pir
branches/gc-refactor/examples/nci/xlibtest.p6
branches/gc-refactor/examples/pge/demo.pir (props changed)
branches/gc-refactor/include/parrot/call.h (contents, props changed)
branches/gc-refactor/include/parrot/compiler.h
branches/gc-refactor/include/parrot/context.h
branches/gc-refactor/include/parrot/gc_api.h (props changed)
branches/gc-refactor/include/parrot/interpreter.h
branches/gc-refactor/include/parrot/packfile.h
branches/gc-refactor/include/parrot/parrot.h
branches/gc-refactor/include/parrot/pmc_freeze.h
branches/gc-refactor/include/parrot/runcore_api.h (contents, props changed)
branches/gc-refactor/include/parrot/runcore_trace.h (props changed)
branches/gc-refactor/include/parrot/string_funcs.h
branches/gc-refactor/include/parrot/sub.h
branches/gc-refactor/lib/Parrot/Harness/Options.pm
branches/gc-refactor/lib/Parrot/Pmc2c/PCCMETHOD.pm
branches/gc-refactor/ports/cpan/pause_guide.pod (props changed)
branches/gc-refactor/ports/cygwin/parrot-1.0.0-1.cygport (props changed)
branches/gc-refactor/ports/debian/libparrot-dev.install.in (props changed)
branches/gc-refactor/ports/debian/libparrot.install.in (props changed)
branches/gc-refactor/ports/debian/parrot-doc.install.in (props changed)
branches/gc-refactor/ports/debian/parrot.install.in (props changed)
branches/gc-refactor/ports/fedora/parrot.spec.fedora (props changed)
branches/gc-refactor/ports/mandriva/parrot.spec.mandriva (props changed)
branches/gc-refactor/ports/suse/parrot.spec.suse (props changed)
branches/gc-refactor/runtime/parrot/languages/ (props changed)
branches/gc-refactor/runtime/parrot/library/Math/Rand.pir (props changed)
branches/gc-refactor/src/call/ (props changed)
branches/gc-refactor/src/call/context.c
branches/gc-refactor/src/call/ops.c (contents, props changed)
branches/gc-refactor/src/call/pcc.c (contents, props changed)
branches/gc-refactor/src/dynext.c
branches/gc-refactor/src/dynpmc/dynlexpad.pmc
branches/gc-refactor/src/dynpmc/gdbmhash.pmc
branches/gc-refactor/src/embed.c
branches/gc-refactor/src/gc/alloc_memory.c (props changed)
branches/gc-refactor/src/gc/alloc_resources.c (props changed)
branches/gc-refactor/src/gc/api.c (props changed)
branches/gc-refactor/src/gc/gc_private.h
branches/gc-refactor/src/gc/malloc.c (props changed)
branches/gc-refactor/src/gc/malloc_trace.c (props changed)
branches/gc-refactor/src/gc/mark_sweep.c (contents, props changed)
branches/gc-refactor/src/gc/system.c (props changed)
branches/gc-refactor/src/interp/ (props changed)
branches/gc-refactor/src/interp/inter_cb.c (props changed)
branches/gc-refactor/src/interp/inter_create.c (contents, props changed)
branches/gc-refactor/src/interp/inter_misc.c (contents, props changed)
branches/gc-refactor/src/jit.c
branches/gc-refactor/src/jit/i386/exec_dep.c
branches/gc-refactor/src/jit/i386/exec_dep.h
branches/gc-refactor/src/jit/i386/jit_defs.c
branches/gc-refactor/src/ops/core.ops
branches/gc-refactor/src/ops/io.ops
branches/gc-refactor/src/ops/ops.num
branches/gc-refactor/src/packfile.c
branches/gc-refactor/src/parrot_debugger.c
branches/gc-refactor/src/pbc_merge.c
branches/gc-refactor/src/pmc/bigint.pmc
branches/gc-refactor/src/pmc/bignum.pmc
branches/gc-refactor/src/pmc/boolean.pmc
branches/gc-refactor/src/pmc/complex.pmc
branches/gc-refactor/src/pmc/continuation.pmc
branches/gc-refactor/src/pmc/coroutine.pmc
branches/gc-refactor/src/pmc/cpointer.pmc
branches/gc-refactor/src/pmc/eval.pmc
branches/gc-refactor/src/pmc/exception.pmc
branches/gc-refactor/src/pmc/exceptionhandler.pmc
branches/gc-refactor/src/pmc/fixedbooleanarray.pmc
branches/gc-refactor/src/pmc/fixedpmcarray.pmc
branches/gc-refactor/src/pmc/float.pmc
branches/gc-refactor/src/pmc/hash.pmc
branches/gc-refactor/src/pmc/integer.pmc
branches/gc-refactor/src/pmc/lexinfo.pmc
branches/gc-refactor/src/pmc/nci.pmc
branches/gc-refactor/src/pmc/packfile.pmc
branches/gc-refactor/src/pmc/packfileannotation.pmc
branches/gc-refactor/src/pmc/packfileannotations.pmc
branches/gc-refactor/src/pmc/packfileconstanttable.pmc
branches/gc-refactor/src/pmc/packfiledirectory.pmc
branches/gc-refactor/src/pmc/packfilefixupentry.pmc
branches/gc-refactor/src/pmc/packfilefixuptable.pmc
branches/gc-refactor/src/pmc/packfilerawsegment.pmc
branches/gc-refactor/src/pmc/packfilesegment.pmc
branches/gc-refactor/src/pmc/parrotlibrary.pmc
branches/gc-refactor/src/pmc/parrotthread.pmc
branches/gc-refactor/src/pmc/resizablepmcarray.pmc
branches/gc-refactor/src/pmc/resizablestringarray.pmc
branches/gc-refactor/src/pmc/scalar.pmc
branches/gc-refactor/src/pmc/string.pmc
branches/gc-refactor/src/pmc/sub.pmc
branches/gc-refactor/src/pmc/undef.pmc
branches/gc-refactor/src/pmc/unmanagedstruct.pmc
branches/gc-refactor/src/pmc_freeze.c
branches/gc-refactor/src/runcore/ (props changed)
branches/gc-refactor/src/runcore/cores.c (contents, props changed)
branches/gc-refactor/src/runcore/main.c (contents, props changed)
branches/gc-refactor/src/runcore/trace.c (props changed)
branches/gc-refactor/src/string/api.c
branches/gc-refactor/src/sub.c
branches/gc-refactor/src/vtable.tbl
branches/gc-refactor/t/codingstd/c_function_docs.t
branches/gc-refactor/t/compilers/tge/NoneGrammar.tg (props changed)
branches/gc-refactor/t/compilers/tge/grammar.t
branches/gc-refactor/t/harness
branches/gc-refactor/t/oo/root_new.t (props changed)
branches/gc-refactor/t/op/calling.t
branches/gc-refactor/t/op/interp.t
branches/gc-refactor/t/pmc/boolean.t
branches/gc-refactor/t/pmc/coroutine.t
branches/gc-refactor/t/pmc/fixedbooleanarray.t
branches/gc-refactor/t/pmc/fixedpmcarray.t
branches/gc-refactor/t/pmc/hash.t
branches/gc-refactor/t/pmc/integer.t
branches/gc-refactor/t/pmc/namespace-old.t (props changed)
branches/gc-refactor/t/pmc/resizablefloatarray.t
branches/gc-refactor/t/pmc/resizablepmcarray.t
branches/gc-refactor/t/pmc/sub.t
branches/gc-refactor/t/pmc/threads.t
branches/gc-refactor/t/pmc/undef.t
branches/gc-refactor/t/src/embed.t (props changed)
branches/gc-refactor/t/tools/pbc_dump.t
branches/gc-refactor/tools/build/nativecall.pl
branches/gc-refactor/tools/build/pmc2c.pl
branches/gc-refactor/tools/dev/fetch_languages.pl (props changed)
branches/gc-refactor/tools/dev/mk_gitignore.pl (props changed)
branches/gc-refactor/tools/dev/pprof2cg.pl (props changed)
branches/gc-refactor/tools/util/perlcritic-cage.conf (props changed)
branches/gc-refactor/tools/util/release.json
Modified: branches/gc-refactor/CREDITS
==============================================================================
--- branches/gc-refactor/CREDITS Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/CREDITS Wed Sep 16 18:24:30 2009 (r41302)
@@ -305,7 +305,7 @@
U: darbelo
A: arbelo
D: OpenBSD fixes and testing, gsoc2009-decnum-dynpmcs
-E: dany.arbelo at gmail.com
+E: arbelo at gmail.com
N: Dave Woldrich
D: Win32 build fixes
Modified: branches/gc-refactor/ChangeLog
==============================================================================
--- branches/gc-refactor/ChangeLog Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/ChangeLog Wed Sep 16 18:24:30 2009 (r41302)
@@ -1,5 +1,9 @@
#1 $Id$
+2009.9.15 particle
+ * Released 1.6.0
+ See NEWS for more.
+
2009.8.18 Whiteknight
* Released 1.5.0
See NEWS for more.
Modified: branches/gc-refactor/DEPRECATED.pod
==============================================================================
--- branches/gc-refactor/DEPRECATED.pod Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/DEPRECATED.pod Wed Sep 16 18:24:30 2009 (r41302)
@@ -153,14 +153,6 @@
L<http://rt.perl.org/rt3/Ticket/Display.html?id=60626>
-=item src/pic.c and src/pic_jit.c [eligible in 1.1]
-
-These two files were a thin prototype implementation of Polymorphic Inline
-Caching that only ever applied to 4 opcodes, one of which has now been removed.
-The files (and all functions in them) are deprecated, and will be removed.
-
-L<http://rt.perl.org/rt3/Ticket/Display.html?id=60048>
-
=item Subs marked with C<:vtable>/C<:method> aren't in namespace [eligible in 1.1]
Subs marked with C<:vtable> or C<:method> flags are no longer given a
Modified: branches/gc-refactor/MANIFEST
==============================================================================
--- branches/gc-refactor/MANIFEST Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/MANIFEST Wed Sep 16 18:24:30 2009 (r41302)
@@ -1,7 +1,7 @@
# ex: set ro:
# $Id$
#
-# generated by tools/dev/mk_manifest_and_skip.pl Tue Sep 8 22:16:59 2009 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Wed Sep 16 06:03:11 2009 UT
#
# See below for documentation on the format of this file.
#
@@ -996,11 +996,11 @@
include/parrot/oplib.h [main]include
include/parrot/packfile.h [main]include
include/parrot/parrot.h [main]include
-include/parrot/pic.h [main]include
include/parrot/pmc.h [main]include
include/parrot/pmc_freeze.h [main]include
include/parrot/pobj.h [main]include
include/parrot/runcore_api.h [main]include
+include/parrot/runcore_profiling.h [main]include
include/parrot/runcore_trace.h [main]include
include/parrot/scheduler.h [main]include
include/parrot/scheduler_private.h [main]include
@@ -1209,6 +1209,7 @@
runtime/parrot/library/SDL/Sprite.pir [library]
runtime/parrot/library/SDL/StopWatch.pir [library]
runtime/parrot/library/SDL/Surface.pir [library]
+runtime/parrot/library/SQLite3.pir [library]
runtime/parrot/library/Stream/Base.pir [library]
runtime/parrot/library/Stream/Combiner.pir [library]
runtime/parrot/library/Stream/Coroutine.pir [library]
@@ -1369,7 +1370,6 @@
src/ops/object.ops []
src/ops/ops.num [devel]src
src/ops/ops.skip []
-src/ops/pic.ops []
src/ops/pmc.ops []
src/ops/set.ops []
src/ops/string.ops []
@@ -1383,8 +1383,6 @@
src/pbc_disassemble.c []
src/pbc_dump.c []
src/pbc_merge.c []
-src/pic.c []
-src/pic_jit.c []
src/pmc.c []
src/pmc/addrregistry.pmc [devel]src
src/pmc/array.pmc [devel]src
@@ -1474,6 +1472,7 @@
src/pmc_freeze.c []
src/runcore/cores.c []
src/runcore/main.c []
+src/runcore/profiling.c []
src/runcore/trace.c []
src/scheduler.c []
src/spf_render.c []
@@ -2169,6 +2168,7 @@
tools/dev/svnclobber.pl []
tools/dev/symlink.pl []
tools/dev/vgp []
+tools/dev/vgp_darwin []
tools/dev/vms-patch []
tools/dev/vtablize.pl []
tools/docs/mk_chm.pl []
Modified: branches/gc-refactor/MANIFEST.SKIP
==============================================================================
--- branches/gc-refactor/MANIFEST.SKIP Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/MANIFEST.SKIP Wed Sep 16 18:24:30 2009 (r41302)
@@ -1,6 +1,6 @@
# ex: set ro:
# $Id$
-# generated by tools/dev/mk_manifest_and_skip.pl Mon Sep 7 21:02:37 2009 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Thu Sep 10 22:53:44 2009 UT
#
# This file should contain a transcript of the svn:ignore properties
# of the directories in the Parrot subversion repository. (Needed for
@@ -677,6 +677,8 @@
^src/atomic/.*\.o$
^src/atomic/.*\.o/
# generated from svn:ignore of 'src/call/'
+^src/call/.*\.o$
+^src/call/.*\.o/
^src/call/.*\.obj$
^src/call/.*\.obj/
^src/call/.*\.str$
@@ -795,6 +797,8 @@
^src/gc/Makefile$
^src/gc/Makefile/
# generated from svn:ignore of 'src/interp/'
+^src/interp/.*\.o$
+^src/interp/.*\.o/
^src/interp/.*\.str$
^src/interp/.*\.str/
# generated from svn:ignore of 'src/io/'
@@ -833,6 +837,13 @@
^src/pmc/.*\.tmp/
^src/pmc/Makefile$
^src/pmc/Makefile/
+# generated from svn:ignore of 'src/runcore/'
+^src/runcore/.*\.o$
+^src/runcore/.*\.o/
+^src/runcore/.*\.obj$
+^src/runcore/.*\.obj/
+^src/runcore/.*\.str$
+^src/runcore/.*\.str/
# generated from svn:ignore of 'src/string/'
^src/string/.*\.o$
^src/string/.*\.o/
Modified: branches/gc-refactor/MANIFEST.generated
==============================================================================
--- branches/gc-refactor/MANIFEST.generated Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/MANIFEST.generated Wed Sep 16 18:24:30 2009 (r41302)
@@ -2,10 +2,10 @@
# See tools/dev/install_files.pl for documentation on the
# format of this file.
# Please re-sort this file after *EVERY* modification
-blib/lib/libparrot.1.5.0.dylib [main]lib
+blib/lib/libparrot.1.6.0.dylib [main]lib
blib/lib/libparrot.a [main]lib
blib/lib/libparrot.dylib [main]lib
-blib/lib/libparrot.so.1.5.0 [main]lib
+blib/lib/libparrot.so.1.6.0 [main]lib
blib/lib/libparrot.so [main]lib
compilers/data_json/data_json.pbc [data_json]
compilers/json/JSON.pbc [json]
Modified: branches/gc-refactor/META.yml
==============================================================================
--- branches/gc-refactor/META.yml Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/META.yml Wed Sep 16 18:24:30 2009 (r41302)
@@ -4,7 +4,7 @@
# See http://module-build.sourceforge.net/META-spec-current.html for details.
---
name: parrot
-version: 1.5.0
+version: 1.6.0
author: parrot-dev at lists.parrot.org
abstract: a virtual machine designed for dynamic languages
license: artistic2
Modified: branches/gc-refactor/NEWS
==============================================================================
--- branches/gc-refactor/NEWS Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/NEWS Wed Sep 16 18:24:30 2009 (r41302)
@@ -1,30 +1,33 @@
# $Id$
New in 1.6.0
-- Core
- + Profiling runcore can now be used to generate Callgrind-compatible output
- + PMC allocator now automatically allocates ATTR structures
- + Added fixed-size structure allocator to GC
- + Contexts are now garbage-collectable
+- Functionality
+ + Added a fixed-size structure allocator to the Garbage Collector
+ + Added a "lazy" mode to the PObj and Fixed-Size memory allocators
+ + Added a profiling runcore, which generates Callgrind-compatible output
+ + Added lexical subsystem opcodes: find_dynamic_lex, store_dynamic_lex
+ + Converted Contexts to garbage-collectable PMC structures
+ Created a new Context API
- + Op definitions cache the current Context for subsequent lookups
+ + Enhanced the PMC allocator to automatically allocate ATTR structures
+- Performance
+ + Optimized opcodes to cache the current Context for subsequent lookups
+ + Reduced string comparisons in VTABLE_isa
+- Maintenance and cleanup
+ + Began proper encapsulation of STRING API
+ + Unified all PMC destruction functions
+ Unified Continuation PMC and Parrot_cont structure
+ Unified Sub PMC and Parrot_sub structure
- + Began proper encapsulation of STRING API
- + Modify PMC structure to remove UnionVal
+ Removed PMC_EXT structure
+ Removed PMC_Sync from PMC
- + Added a "Lazy" mode to the PObj and Fixed-Size allocators
- + Reduce string comparisons in VTABLE_isa
- + Unified all PMC destruction functions
- + Added several fixes for stack-walking GC code
- + Copying a NULL string now returns an empty STRING structure
- + Add find_dynamic_lex and store_dynamic_lex opcodes
+ + Removed UnionVal from PMC structure
+- Bugfix
+ + Fixed several stack-walking bugs in Garbage Collector code
+ + Fixed bug when copying a NULL STRING, now returns empty STRING struct
- Tests
- + Convert several Perl5 tests to PIR
- + Expand test coverage of NameSpace PMC
+ + Converted several Perl5 tests to PIR
+ + Expanded test coverage of NameSpace PMC
- Compilers
- + PCT is now included in "make install"
+ + Made Parrot Compiler Toolkit available in the base install
New in 1.5.0
- Core
Modified: branches/gc-refactor/PBC_COMPAT
==============================================================================
--- branches/gc-refactor/PBC_COMPAT Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/PBC_COMPAT Wed Sep 16 18:24:30 2009 (r41302)
@@ -27,6 +27,7 @@
# please insert tab separated entries at the top of the list
+5.2 2009.09.16 darbelo remove pic.ops
5.2 2009.08.06 dukeleto remove Random PMC
5.1 2009.08.06 cotto remove branch_cs opcode
5.0 2009.07.21 cotto released 1.4.0
Modified: branches/gc-refactor/PLATFORMS
==============================================================================
--- branches/gc-refactor/PLATFORMS Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/PLATFORMS Wed Sep 16 18:24:30 2009 (r41302)
@@ -40,7 +40,7 @@
freebsd-x86-gcc-4.2.1 4 Y Y Y ? ? Y Y Y 20090415
freebsd-amd64-gcc-4.2.1 8 Y - - ? ? Y Y Y 20090720
linux-amd64-clang-r73854 8 ? ? = Y Y Y/4 Y/1 ? 20090622
-linux-amd64-clang-r75433 8 Y N ? ? ? Y Y ? 20090712
+linux-amd64-clang-r75433 8 Y N ? ? ? Y Y*4 ? 20090913
linux-ppc-gcc3.4.5 Y Y Y ? ? Y Y ? 20080519
linux-s390x-gcc4.1.2 B4 ? - - Y Y Y Y/2 ? 20080908
linux-amd64-gcc4.1.2 8 Y - - Y Y Y Y ? 20080220
@@ -97,6 +97,7 @@
*2 http://rt.perl.org/rt3/Ticket/Display.html?id=60926
*3 64-bit MSVC uses 32-bit int and long values. For 64-bit use
--ccflags="-GS- -MD" --intval="long long" --opcode="long long"
+*4 only builds when configured --without-gmp. See TT #1006
The following configurations are also working on x86/linux (and possibly
other platforms):
Modified: branches/gc-refactor/README
==============================================================================
--- branches/gc-refactor/README Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/README Wed Sep 16 18:24:30 2009 (r41302)
@@ -1,4 +1,4 @@
-This is Parrot, version 1.5.0
+This is Parrot, version 1.6.0
------------------------------
Parrot is Copyright (C) 2001-2009, Parrot Foundation.
Modified: branches/gc-refactor/VERSION
==============================================================================
--- branches/gc-refactor/VERSION Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/VERSION Wed Sep 16 18:24:30 2009 (r41302)
@@ -1 +1 @@
-1.5.0
+1.6.0
Modified: branches/gc-refactor/compilers/imcc/imc.h
==============================================================================
--- branches/gc-refactor/compilers/imcc/imc.h Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/compilers/imcc/imc.h Wed Sep 16 18:24:30 2009 (r41302)
@@ -573,7 +573,6 @@
struct code_segment_t *prev; /* previous code segment */
struct code_segment_t *next; /* next code segment */
SymHash key_consts; /* this seg's cached key constants */
- int pic_idx; /* next index of PIC */
} code_segment_t;
typedef struct _imcc_globals_t {
Modified: branches/gc-refactor/compilers/imcc/imcc.l
==============================================================================
--- branches/gc-refactor/compilers/imcc/imcc.l Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/compilers/imcc/imcc.l Wed Sep 16 18:24:30 2009 (r41302)
@@ -519,9 +519,10 @@
}
<emit,INITIAL>{DOT}{LETTER}{LETTERDIGIT}* {
- char * const macro_name = yytext + 1;
-
- if (!expand_macro(interp, macro_name, yyscanner)) {
+ char * const macro_name = mem_sys_strdup(yytext + 1);
+ int failed = expand_macro(interp, macro_name, yyscanner);
+ mem_sys_free(macro_name);
+ if (! failed) {
yyless(1);
return DOT;
}
Modified: branches/gc-refactor/compilers/imcc/imcc.y
==============================================================================
--- branches/gc-refactor/compilers/imcc/imcc.y Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/compilers/imcc/imcc.y Wed Sep 16 18:24:30 2009 (r41302)
@@ -2003,7 +2003,7 @@
| target '=' un_op var
{ $$ = MK_I(interp, IMCC_INFO(interp)->cur_unit, $3, 2, $1, $4); }
| target '=' var bin_op var
- { $$ = MK_I(interp, IMCC_INFO(interp)->cur_unit, $4, 3, $1, $3, $5); }
+ { IMCC_INFO(interp)->line++; $$ = MK_I(interp, IMCC_INFO(interp)->cur_unit, $4, 3, $1, $3, $5); IMCC_INFO(interp)->line--; }
| target '=' var '[' keylist ']'
{ $$ = iINDEXFETCH(interp, IMCC_INFO(interp)->cur_unit, $1, $3, $5); }
| target '[' keylist ']' '=' var
@@ -2087,7 +2087,7 @@
op_assign:
target assign_op var
{
- $$ = MK_I(interp, IMCC_INFO(interp)->cur_unit, $2, 2, $1, $3);
+ IMCC_INFO(interp)->line++; $$ = MK_I(interp, IMCC_INFO(interp)->cur_unit, $2, 2, $1, $3); IMCC_INFO(interp)->line--;
}
;
Modified: branches/gc-refactor/compilers/imcc/imclexer.c
==============================================================================
--- branches/gc-refactor/compilers/imcc/imclexer.c Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/compilers/imcc/imclexer.c Wed Sep 16 18:24:30 2009 (r41302)
@@ -3618,9 +3618,10 @@
YY_RULE_SETUP
#line 521 "compilers/imcc/imcc.l"
{
- char * const macro_name = yytext + 1;
-
- if (!expand_macro(interp, macro_name, yyscanner)) {
+ char * const macro_name = mem_sys_strdup(yytext + 1);
+ int failed = expand_macro(interp, macro_name, yyscanner);
+ mem_sys_free(macro_name);
+ if (! failed) {
yyless(1);
return DOT;
}
@@ -3628,32 +3629,32 @@
YY_BREAK
case 117:
YY_RULE_SETUP
-#line 532 "compilers/imcc/imcc.l"
+#line 533 "compilers/imcc/imcc.l"
DUP_AND_RET(valp, FLOATC);
YY_BREAK
case 118:
YY_RULE_SETUP
-#line 533 "compilers/imcc/imcc.l"
+#line 534 "compilers/imcc/imcc.l"
DUP_AND_RET(valp, INTC);
YY_BREAK
case 119:
YY_RULE_SETUP
-#line 534 "compilers/imcc/imcc.l"
+#line 535 "compilers/imcc/imcc.l"
DUP_AND_RET(valp, INTC);
YY_BREAK
case 120:
YY_RULE_SETUP
-#line 535 "compilers/imcc/imcc.l"
+#line 536 "compilers/imcc/imcc.l"
DUP_AND_RET(valp, INTC);
YY_BREAK
case 121:
YY_RULE_SETUP
-#line 536 "compilers/imcc/imcc.l"
+#line 537 "compilers/imcc/imcc.l"
DUP_AND_RET(valp, INTC);
YY_BREAK
case 122:
YY_RULE_SETUP
-#line 538 "compilers/imcc/imcc.l"
+#line 539 "compilers/imcc/imcc.l"
{
valp->s = mem_sys_strdup(yytext);
@@ -3666,7 +3667,7 @@
YY_BREAK
case 123:
YY_RULE_SETUP
-#line 548 "compilers/imcc/imcc.l"
+#line 549 "compilers/imcc/imcc.l"
{
valp->s = mem_sys_strdup(yytext);
@@ -3676,7 +3677,7 @@
YY_BREAK
case 124:
YY_RULE_SETUP
-#line 555 "compilers/imcc/imcc.l"
+#line 556 "compilers/imcc/imcc.l"
{
macro_frame_t *frame;
@@ -3707,7 +3708,7 @@
YY_BREAK
case 125:
YY_RULE_SETUP
-#line 583 "compilers/imcc/imcc.l"
+#line 584 "compilers/imcc/imcc.l"
{
/* charset:"..." */
valp->s = mem_sys_strdup(yytext);
@@ -3718,7 +3719,7 @@
YY_BREAK
case 126:
YY_RULE_SETUP
-#line 591 "compilers/imcc/imcc.l"
+#line 592 "compilers/imcc/imcc.l"
{
if (valp) (valp)->s = yytext;
if (IMCC_INFO(interp)->state->pasm_file)
@@ -3729,7 +3730,7 @@
YY_BREAK
case 127:
YY_RULE_SETUP
-#line 599 "compilers/imcc/imcc.l"
+#line 600 "compilers/imcc/imcc.l"
{
if (valp) (valp)->s = yytext;
if (IMCC_INFO(interp)->state->pasm_file)
@@ -3740,7 +3741,7 @@
YY_BREAK
case 128:
YY_RULE_SETUP
-#line 607 "compilers/imcc/imcc.l"
+#line 608 "compilers/imcc/imcc.l"
{
if (valp) (valp)->s = yytext;
if (IMCC_INFO(interp)->state->pasm_file)
@@ -3751,7 +3752,7 @@
YY_BREAK
case 129:
YY_RULE_SETUP
-#line 615 "compilers/imcc/imcc.l"
+#line 616 "compilers/imcc/imcc.l"
{
if (valp) (valp)->s = yytext;
if (IMCC_INFO(interp)->state->pasm_file)
@@ -3762,7 +3763,7 @@
YY_BREAK
case 130:
YY_RULE_SETUP
-#line 623 "compilers/imcc/imcc.l"
+#line 624 "compilers/imcc/imcc.l"
{
IMCC_fataly(interp, EXCEPTION_SYNTAX_ERROR,
"'%s' is not a valid register name", yytext);
@@ -3770,7 +3771,7 @@
YY_BREAK
case 131:
YY_RULE_SETUP
-#line 628 "compilers/imcc/imcc.l"
+#line 629 "compilers/imcc/imcc.l"
{
if (IMCC_INFO(interp)->state->pasm_file == 0)
IMCC_fataly(interp, EXCEPTION_SYNTAX_ERROR,
@@ -3784,7 +3785,7 @@
YY_BREAK
case 132:
YY_RULE_SETUP
-#line 639 "compilers/imcc/imcc.l"
+#line 640 "compilers/imcc/imcc.l"
{
if (!IMCC_INFO(interp)->is_def) {
SymReg *r = find_sym(interp, yytext);
@@ -3815,19 +3816,19 @@
YY_BREAK
case 133:
YY_RULE_SETUP
-#line 668 "compilers/imcc/imcc.l"
+#line 669 "compilers/imcc/imcc.l"
/* skip */;
YY_BREAK
case 134:
YY_RULE_SETUP
-#line 670 "compilers/imcc/imcc.l"
+#line 671 "compilers/imcc/imcc.l"
{
/* catch all except for state macro */
return yytext[0];
}
YY_BREAK
case YY_STATE_EOF(emit):
-#line 675 "compilers/imcc/imcc.l"
+#line 676 "compilers/imcc/imcc.l"
{
BEGIN(INITIAL);
@@ -3840,18 +3841,18 @@
}
YY_BREAK
case YY_STATE_EOF(INITIAL):
-#line 686 "compilers/imcc/imcc.l"
+#line 687 "compilers/imcc/imcc.l"
yyterminate();
YY_BREAK
case 135:
YY_RULE_SETUP
-#line 688 "compilers/imcc/imcc.l"
+#line 689 "compilers/imcc/imcc.l"
DUP_AND_RET(valp, ENDM);
YY_BREAK
case 136:
/* rule 136 can match eol */
YY_RULE_SETUP
-#line 690 "compilers/imcc/imcc.l"
+#line 691 "compilers/imcc/imcc.l"
{
IMCC_INFO(interp)->line++;
DUP_AND_RET(valp, '\n');
@@ -3859,12 +3860,12 @@
YY_BREAK
case 137:
YY_RULE_SETUP
-#line 695 "compilers/imcc/imcc.l"
+#line 696 "compilers/imcc/imcc.l"
return LABEL;
YY_BREAK
case 138:
YY_RULE_SETUP
-#line 697 "compilers/imcc/imcc.l"
+#line 698 "compilers/imcc/imcc.l"
{
if (yylex(valp,yyscanner,interp) != LABEL)
@@ -3891,7 +3892,7 @@
YY_BREAK
case 139:
YY_RULE_SETUP
-#line 721 "compilers/imcc/imcc.l"
+#line 722 "compilers/imcc/imcc.l"
{
if (valp) {
const size_t len = strlen(IMCC_INFO(interp)->cur_macro_name) + yyleng + 12;
@@ -3910,49 +3911,49 @@
YY_BREAK
case 140:
YY_RULE_SETUP
-#line 737 "compilers/imcc/imcc.l"
+#line 738 "compilers/imcc/imcc.l"
/* skip leading ws */;
YY_BREAK
case 141:
YY_RULE_SETUP
-#line 738 "compilers/imcc/imcc.l"
+#line 739 "compilers/imcc/imcc.l"
DUP_AND_RET(valp, ' ');
YY_BREAK
case 142:
YY_RULE_SETUP
-#line 739 "compilers/imcc/imcc.l"
+#line 740 "compilers/imcc/imcc.l"
DUP_AND_RET(valp, REG);
YY_BREAK
case 143:
YY_RULE_SETUP
-#line 740 "compilers/imcc/imcc.l"
+#line 741 "compilers/imcc/imcc.l"
DUP_AND_RET(valp, REG);
YY_BREAK
case 144:
YY_RULE_SETUP
-#line 741 "compilers/imcc/imcc.l"
+#line 742 "compilers/imcc/imcc.l"
DUP_AND_RET(valp, IDENTIFIER);
YY_BREAK
case 145:
YY_RULE_SETUP
-#line 742 "compilers/imcc/imcc.l"
+#line 743 "compilers/imcc/imcc.l"
DUP_AND_RET(valp, MACRO);
YY_BREAK
case 146:
YY_RULE_SETUP
-#line 743 "compilers/imcc/imcc.l"
+#line 744 "compilers/imcc/imcc.l"
DUP_AND_RET(valp, yytext[0]);
YY_BREAK
case YY_STATE_EOF(macro):
-#line 744 "compilers/imcc/imcc.l"
+#line 745 "compilers/imcc/imcc.l"
yyterminate();
YY_BREAK
case 147:
YY_RULE_SETUP
-#line 746 "compilers/imcc/imcc.l"
+#line 747 "compilers/imcc/imcc.l"
ECHO;
YY_BREAK
-#line 3956 "compilers/imcc/imclexer.c"
+#line 3957 "compilers/imcc/imclexer.c"
case YY_STATE_EOF(pod):
case YY_STATE_EOF(cmt1):
case YY_STATE_EOF(cmt2):
@@ -5154,7 +5155,7 @@
#define YYTABLES_NAME "yytables"
-#line 746 "compilers/imcc/imcc.l"
+#line 747 "compilers/imcc/imcc.l"
Modified: branches/gc-refactor/compilers/imcc/imcparser.c
==============================================================================
--- branches/gc-refactor/compilers/imcc/imcparser.c Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/compilers/imcc/imcparser.c Wed Sep 16 18:24:30 2009 (r41302)
@@ -4433,7 +4433,7 @@
case 203:
#line 2006 "compilers/imcc/imcc.y"
- { (yyval.i) = MK_I(interp, IMCC_INFO(interp)->cur_unit, (yyvsp[(4) - (5)].s), 3, (yyvsp[(1) - (5)].sr), (yyvsp[(3) - (5)].sr), (yyvsp[(5) - (5)].sr)); }
+ { IMCC_INFO(interp)->line++; (yyval.i) = MK_I(interp, IMCC_INFO(interp)->cur_unit, (yyvsp[(4) - (5)].s), 3, (yyvsp[(1) - (5)].sr), (yyvsp[(3) - (5)].sr), (yyvsp[(5) - (5)].sr)); IMCC_INFO(interp)->line--; }
break;
case 204:
@@ -4629,7 +4629,7 @@
case 242:
#line 2089 "compilers/imcc/imcc.y"
{
- (yyval.i) = MK_I(interp, IMCC_INFO(interp)->cur_unit, (yyvsp[(2) - (3)].s), 2, (yyvsp[(1) - (3)].sr), (yyvsp[(3) - (3)].sr));
+ IMCC_INFO(interp)->line++; (yyval.i) = MK_I(interp, IMCC_INFO(interp)->cur_unit, (yyvsp[(2) - (3)].s), 2, (yyvsp[(1) - (3)].sr), (yyvsp[(3) - (3)].sr)); IMCC_INFO(interp)->line--;
}
break;
Modified: branches/gc-refactor/compilers/imcc/main.c
==============================================================================
--- branches/gc-refactor/compilers/imcc/main.c Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/compilers/imcc/main.c Wed Sep 16 18:24:30 2009 (r41302)
@@ -220,8 +220,8 @@
" -L --library add path to library search\n"
" -X --dynext add path to dynamic extension search\n"
" <Run core options>\n"
- " -R --runcore slow|bounds|fast|jit|cgoto|cgp|cgp-jit\n"
- " -R --runcore switch|switch-jit|trace|profiling|gcdebug\n"
+ " -R --runcore slow|bounds|fast|cgoto|cgp\n"
+ " -R --runcore switch|trace|profiling|gcdebug\n"
" -t --trace [flags]\n"
" <VM options>\n"
" -D --parrot-debug[=HEXFLAGS]\n"
@@ -380,11 +380,11 @@
else if (STREQ(opt.opt_arg, "cgoto"))
core |= PARROT_CGOTO_CORE;
else if (STREQ(opt.opt_arg, "jit"))
- core |= PARROT_JIT_CORE;
+ core |= PARROT_FAST_CORE;
else if (STREQ(opt.opt_arg, "cgp-jit"))
- core |= PARROT_CGP_JIT_CORE;
+ core |= PARROT_CGP_CORE;
else if (STREQ(opt.opt_arg, "switch-jit"))
- core |= PARROT_SWITCH_JIT_CORE;
+ core |= PARROT_SWITCH_CORE;
else if (STREQ(opt.opt_arg, "exec"))
core |= PARROT_EXEC_CORE;
else if (STREQ(opt.opt_arg, "trace"))
@@ -489,9 +489,6 @@
IMCC_INFO(interp)->allocator = IMCC_GRAPH_ALLOCATOR;
/* currently not ok due to different register allocation */
- if (strchr(opt.opt_arg, 'j')) {
- core |= PARROT_JIT_CORE;
- }
if (strchr(opt.opt_arg, '1')) {
IMCC_INFO(interp)->optimizer_level |= OPT_PRE;
}
@@ -503,9 +500,6 @@
#ifdef HAVE_COMPUTED_GOTO
core |= PARROT_CGP_CORE;
#endif
-#if JIT_CAPABLE
- core |= PARROT_JIT_CORE;
-#endif
}
break;
Modified: branches/gc-refactor/compilers/imcc/parser_util.c
==============================================================================
--- branches/gc-refactor/compilers/imcc/parser_util.c Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/compilers/imcc/parser_util.c Wed Sep 16 18:24:30 2009 (r41302)
@@ -714,13 +714,14 @@
}
if (imc_info) {
+ SymReg *ns = IMCC_INFO(interp)->cur_namespace;
IMCC_INFO(interp) = imc_info->prev;
mem_sys_free(imc_info);
imc_info = IMCC_INFO(interp);
IMCC_INFO(interp)->cur_unit = imc_info->last_unit;
- if (IMCC_INFO(interp)->cur_namespace)
- free_sym(IMCC_INFO(interp)->cur_namespace);
+ if (ns && ns != imc_info->cur_namespace)
+ free_sym(ns);
IMCC_INFO(interp)->cur_namespace = imc_info->cur_namespace;
}
Modified: branches/gc-refactor/compilers/imcc/pbc.c
==============================================================================
--- branches/gc-refactor/compilers/imcc/pbc.c Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/compilers/imcc/pbc.c Wed Sep 16 18:24:30 2009 (r41302)
@@ -1213,8 +1213,8 @@
PMC_get_sub(interp, sub_pmc, sub);
IMCC_debug(interp, DEBUG_PBC_CONST,
- "add lexical '%s' to sub name '%s'\n",
- n->name, (char*)sub->name->strstart);
+ "add lexical '%s' to sub name '%Ss'\n",
+ n->name, sub->name);
Parrot_PCCINVOKE(interp, lex_info,
string_from_literal(interp, "declare_lex_preg"),
@@ -1255,6 +1255,7 @@
subs_t *s;
PMC *current;
STRING *cur_name;
+ char *cur_name_str;
Parrot_Sub_attributes *sub;
size_t len;
@@ -1289,10 +1290,13 @@
PMC_get_sub(interp, current, sub);
cur_name = sub->name;
- if (cur_name->strlen == len
- && (memcmp((char*)cur_name->strstart, unit->outer->name, len) == 0))
+ cur_name_str = Parrot_str_to_cstring(interp, sub->name);
+ if (strlen(cur_name_str) == len
+ && (memcmp(cur_name_str, unit->outer->name, len) == 0)) {
+ Parrot_str_free_cstring(cur_name_str);
return current;
-
+ }
+ Parrot_str_free_cstring(cur_name_str);
return NULL;
}
@@ -1511,14 +1515,13 @@
PMC_get_sub(interp, sub->outer_sub, outer_sub);
IMCC_debug(interp, DEBUG_PBC_CONST,
- "add_const_pmc_sub '%s' flags %x color %d (%s) "
- "lex_info %s :outer(%s)\n",
+ "add_const_pmc_sub '%s' flags %x color %d (%Ss) "
+ "lex_info %s :outer(%Ss)\n",
r->name, r->pcc_sub->pragma, k,
- (char *) sub_pmc->vtable->whoami->strstart,
+ sub_pmc->vtable->whoami,
sub->lex_info ? "yes" : "no",
- sub->outer_sub ?
- (char *)outer_sub->name->strstart :
- "*none*");
+ sub->outer_sub? outer_sub->name :
+ Parrot_str_new(interp, "*none*", 0));
/*
* create entry in our fixup (=symbol) table
@@ -2107,24 +2110,14 @@
constant_folding(interp, unit);
store_sub_size(interp, code_size, ins_size);
- /*
- * allocate code and pic_index
- *
- * pic_index is half the size of the code, as one PIC-cacheable opcode
- * is at least two opcodes wide - see below how to further decrease
- * this storage
- */
+ /* allocate code */
interp->code->base.data = (opcode_t *)
mem_sys_realloc(interp->code->base.data, bytes);
/* reallocating this removes its mmaped-ness; needs encapsulation */
interp->code->base.pf->is_mmap_ped = 0;
- interp->code->pic_index->data = (opcode_t *)
- mem_sys_realloc(interp->code->pic_index->data, bytes / 2);
-
interp->code->base.size = oldsize + code_size;
- interp->code->pic_index->size = (oldsize + code_size) / 2;
IMCC_INFO(interp)->pc = (opcode_t *)interp->code->base.data + oldsize;
IMCC_INFO(interp)->npc = 0;
@@ -2249,21 +2242,6 @@
op = (opcode_t)ins->opnum;
- /* add PIC idx */
- if (parrot_PIC_op_is_cached(op)) {
- const size_t offs = IMCC_INFO(interp)->pc - interp->code->base.data;
- /*
- * for pic_idx fitting into a short, we could
- * further reduce the size by storing shorts
- * the relation code_size / pic_index_size could
- * indicate the used storage
- *
- * drawback: if we reach 0xffff, we'd have to resize again
- */
- interp->code->pic_index->data[offs / 2] =
- ++IMCC_INFO(interp)->globals->cs->pic_idx;
- }
-
/* Start generating the bytecode */
*(IMCC_INFO(interp)->pc)++ = op;
Modified: branches/gc-refactor/compilers/pirc/src/bcgen.c
==============================================================================
--- branches/gc-refactor/compilers/pirc/src/bcgen.c Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/compilers/pirc/src/bcgen.c Wed Sep 16 18:24:30 2009 (r41302)
@@ -912,6 +912,7 @@
PMC *current;
Parrot_Sub_attributes *sub;
STRING *cur_name;
+ STRING *out_name;
size_t len;
global_label *outersub;
@@ -959,8 +960,8 @@
PMC_get_sub(interp, current, sub);
cur_name = sub->name;
- /* XXX can't this be a call to Parrot_str_compare() ? */
- if (cur_name->strlen == len && (memcmp((char *)cur_name->strstart, outername, len) == 0))
+ out_name = Parrot_str_new(interp, outername, len);
+ if (Parrot_str_compare(interp, cur_name, out_name) == 0)
return current;
return NULL;
Modified: branches/gc-refactor/config/auto/headers.pm
==============================================================================
--- branches/gc-refactor/config/auto/headers.pm Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/config/auto/headers.pm Wed Sep 16 18:24:30 2009 (r41302)
@@ -104,6 +104,16 @@
if ( $conf->data->get_p5('OSNAME') eq "msys" ) {
push @extra_headers, qw(sysmman.h netdb.h);
}
+
+ if ( $conf->data->get_p5('OSNAME') eq "MSWin32" ) {
+ # Microsoft provides two annotations mechanisms. __declspec, which has been
+ # around for a while, and Microsoft's standard source code annotation
+ # language (SAL), introduced with Visual C++ 8.0.
+ # See <http://msdn2.microsoft.com/en-us/library/ms235402(VS.80).aspx>,
+ # <http://msdn2.microsoft.com/en-us/library/dabb5z75(VS.80).aspx>.
+ push @extra_headers, qw(sal.h);
+ }
+
return @extra_headers;
}
Modified: branches/gc-refactor/config/auto/msvc.pm
==============================================================================
--- branches/gc-refactor/config/auto/msvc.pm Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/config/auto/msvc.pm Wed Sep 16 18:24:30 2009 (r41302)
@@ -90,13 +90,6 @@
# To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help
# for details.
$conf->data->add( " ", "ccflags", "-D_CRT_SECURE_NO_DEPRECATE" );
-
- # Microsoft provides two annotations mechanisms. __declspec, which has been
- # around for a while, and Microsoft's standard source code annotation
- # language (SAL), introduced with Visual C++ 8.0.
- # See <http://msdn2.microsoft.com/en-us/library/ms235402(VS.80).aspx>,
- # <http://msdn2.microsoft.com/en-us/library/dabb5z75(VS.80).aspx>.
- $conf->data->set( HAS_MSVC_SAL => 1 );
}
return 1;
}
Modified: branches/gc-refactor/config/gen/makefiles/root.in
==============================================================================
--- branches/gc-refactor/config/gen/makefiles/root.in Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/config/gen/makefiles/root.in Wed Sep 16 18:24:30 2009 (r41302)
@@ -450,13 +450,12 @@
$(SRC_DIR)/oo$(O) \
$(SRC_DIR)/packfile$(O) \
$(SRC_DIR)/packout$(O) \
- $(SRC_DIR)/pic_jit$(O) \
- $(SRC_DIR)/pic$(O) \
$(SRC_DIR)/platform$(O) \
$(SRC_DIR)/pmc_freeze$(O) \
$(SRC_DIR)/pmc$(O) \
$(SRC_DIR)/runcore/main$(O) \
$(SRC_DIR)/runcore/cores$(O) \
+ $(SRC_DIR)/runcore/profiling$(O) \
$(SRC_DIR)/scheduler$(O) \
$(SRC_DIR)/spf_render$(O) \
$(SRC_DIR)/spf_vtable$(O) \
@@ -634,6 +633,8 @@
$(SRC_DIR)/pmc_freeze.str \
$(SRC_DIR)/oo.str \
$(SRC_DIR)/runcore/cores.str \
+ $(SRC_DIR)/runcore/main.str \
+ $(SRC_DIR)/runcore/profiling.str \
$(SRC_DIR)/scheduler.str \
$(SRC_DIR)/spf_render.str \
$(SRC_DIR)/spf_vtable.str \
@@ -914,7 +915,7 @@
$(PARROT) -o parrot_config.pbc tools/util/parrot-config.pir
$(PBC_TO_EXE) parrot_config.pbc --install
-$(INSTALLABLEPBCTOEXE) : $(PBC_TO_EXE)
+$(INSTALLABLEPBCTOEXE) : $(PBC_TO_EXE) $(SRC_DIR)/install_config$(O)
$(PBC_TO_EXE) pbc_to_exe.pbc --install
#
@@ -949,7 +950,8 @@
@rpath_blib@ $(ALL_PARROT_LIBS) $(LINKFLAGS)
#IF(win32): if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;1
-$(INSTALLABLEDIS) : $(SRC_DIR)/pbc_disassemble$(O) $(LIBPARROT)
+$(INSTALLABLEDIS) : $(SRC_DIR)/pbc_disassemble$(O) \
+ $(SRC_DIR)/install_config$(O) $(LIBPARROT)
$(LINK) @ld_out@$@ \
$(SRC_DIR)/pbc_disassemble$(O) \
@rpath_lib@ $(ALL_PARROT_LIBS) $(LINKFLAGS)
@@ -968,7 +970,8 @@
$(SRC_DIR)/pbc_dump$(O) : $(INC_DIR)/parrot.h $(GEN_HEADERS)
-$(INSTALLABLEPDUMP) : $(SRC_DIR)/pbc_dump$(O) $(SRC_DIR)/packdump$(O) $(LIBPARROT)
+$(INSTALLABLEPDUMP) : $(SRC_DIR)/pbc_dump$(O) $(SRC_DIR)/packdump$(O) \
+ $(SRC_DIR)/install_config$(O) $(LIBPARROT)
$(LINK) @ld_out@$@ \
$(SRC_DIR)/pbc_dump$(O) \
$(SRC_DIR)/packdump$(O) \
@@ -1138,9 +1141,13 @@
$(SRC_DIR)/extend$(O) : $(GENERAL_H_FILES) $(INC_DIR)/extend.h \
$(SRC_DIR)/pmc/pmc_sub.h
-$(SRC_DIR)/runcore/main$(O) : $(SRC_DIR)/runcore/main.c $(GENERAL_H_FILES) \
+$(SRC_DIR)/runcore/main$(O) : $(SRC_DIR)/runcore/main.c \
+ $(SRC_DIR)/runcore/main.str $(GENERAL_H_FILES) \
$(SRC_DIR)/pmc/pmc_parrotlibrary.h
+$(SRC_DIR)/runcore/profiling$(O) : $(SRC_DIR)/runcore/profiling.str $(GENERAL_H_FILES) \
+ $(SRC_DIR)/pmc/pmc_sub.h
+
$(SRC_DIR)/call/pcc$(O) : $(SRC_DIR)/call/pcc.c $(GENERAL_H_FILES) \
$(SRC_DIR)/call/pcc.str $(SRC_DIR)/pmc/pmc_fixedintegerarray.h \
$(SRC_DIR)/pmc/pmc_key.h $(SRC_DIR)/pmc/pmc_continuation.h
@@ -1176,11 +1183,6 @@
$(SRC_DIR)/main$(O) : $(SRC_DIR)/main.c $(GENERAL_H_FILES)
-$(SRC_DIR)/pic$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/pmc/pmc_fixedintegerarray.h \
- $(SRC_DIR)/pmc/pmc_continuation.h
-
-$(SRC_DIR)/pic_jit$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/pmc/pmc_sub.h
-
$(SRC_DIR)/multidispatch$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/multidispatch.str \
$(SRC_DIR)/pmc/pmc_nci.h $(SRC_DIR)/pmc/pmc_sub.h
@@ -1241,8 +1243,6 @@
$(OPS_DIR)/core_ops$(O) : $(GENERAL_H_FILES) $(OPS_DIR)/core_ops.c \
$(SRC_DIR)/pmc/pmc_continuation.h $(SRC_DIR)/pmc/pmc_parrotlibrary.h
-$(OPS_DIR)/pic.ops : $(SRC_DIR)/pmc/pmc_fixedintegerarray.h
-
# core_ops depends upon config.h so that it gets updated along with
# updates to config.h's version numbers
@@ -1523,7 +1523,6 @@
#IF(cg_flag): testC \
testf \
#IF(cg_flag): testg \
-#IF(jitcapable): testj \
testr \
testS \
src_tests \
@@ -1551,9 +1550,9 @@
testg : test_prep
$(PERL) t/harness $(EXTRA_TEST_ARGS) -g $(RUNCORE_TEST_FILES)
-# JIT core
+# JIT core - target retained, but falls back to standard core
testj : test_prep
- $(PERL) t/harness $(EXTRA_TEST_ARGS) -j $(RUNCORE_TEST_FILES)
+ $(PERL) t/harness $(EXTRA_TEST_ARGS) $(RUNCORE_TEST_FILES)
# normal core, write and run Parrot Byte Code
testr : test_prep
@@ -1563,13 +1562,13 @@
testS : test_prep
$(PERL) t/harness $(EXTRA_TEST_ARGS) -S $(RUNCORE_TEST_FILES)
-# Computed goto jitted core
+# Computed goto jitted core - target retained, but falls back to standard core
testCj : test_prep
- $(PERL) t/harness $(EXTRA_TEST_ARGS) -Cj $(RUNCORE_TEST_FILES)
+ $(PERL) t/harness $(EXTRA_TEST_ARGS) $(RUNCORE_TEST_FILES)
-# switched jitted core
+# switched jitted core - target retained, but falls back to standard core
testSj : test_prep
- $(PERL) t/harness $(EXTRA_TEST_ARGS) -Sj $(RUNCORE_TEST_FILES)
+ $(PERL) t/harness $(EXTRA_TEST_ARGS) $(RUNCORE_TEST_FILES)
# test the EXEC stuff
testexec: test_prep
Modified: branches/gc-refactor/docs/embed.pod
==============================================================================
--- branches/gc-refactor/docs/embed.pod Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/docs/embed.pod Wed Sep 16 18:24:30 2009 (r41302)
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2008, Parrot Foundation.
+# Copyright (C) 2001-2009, Parrot Foundation.
# $Id$
=head1 NAME
@@ -165,12 +165,6 @@
=item PARROT_CGOTO_CORE
-=item PARROT_JIT_CORE
-
-=item PARROT_CGP_JIT_CORE
-
-=item PARROT_SWITCH_JIT_CORE
-
=item PARROT_EXEC_CORE
=item PARROT_GC_DEBUG_CORE
Modified: branches/gc-refactor/docs/parrothist.pod
==============================================================================
--- branches/gc-refactor/docs/parrothist.pod Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/docs/parrothist.pod Wed Sep 16 18:24:30 2009 (r41302)
@@ -81,7 +81,7 @@
Bob 0.7.0 2008-Aug-19 "Severe Macaw"
Patrick 0.7.1 2008-Sep-16 "Manu Aloha"
- particle 0.8.0 2008-Oct-21 "Pareto Principle"
+ Jerry 0.8.0 2008-Oct-21 "Pareto Principle"
chromatic 0.8.1 2008-Nov-18 "Tio Richie"
Whiteknight 0.8.2 2008-Dec-16 "Feliz Loro"
@@ -92,9 +92,8 @@
Francois 1.1.0 2009-Apr-21 "Half-moon Conure"
Infinoid 1.2.0 2009-May-19 "Bird Brain"
Whiteknight 1.3.0 2009-Jun-16 "Andean Swift"
-
cotto 1.4.0 2009-Jul-21 "Mundo Cani"
Whiteknight 1.5.0 2009-Aug-18 "TEH PARROTZ!"
-
+ Jerry 1.6.0 2009-Sep-15 "half-pie"
=cut
Modified: branches/gc-refactor/docs/pdds/pdd15_objects.pod
==============================================================================
--- branches/gc-refactor/docs/pdds/pdd15_objects.pod Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/docs/pdds/pdd15_objects.pod Wed Sep 16 18:24:30 2009 (r41302)
@@ -31,9 +31,8 @@
Attributes are set on a class-wide basis, and all the objects of a class
will have the same set of attributes. Most OO languages don't allow
attribute changes to existing classes, but Parrot's base attribute
-system does allow it. In order to safely support advanced dynamic
-features in HLLs, attributes are not accessible via fixed attribute
-offsets, but only via named lookup.
+system does allow it (only before the first object is instantiated from
+the class).
=head3 Method
@@ -103,8 +102,12 @@
=item - Classes are instances of a meta-class and have their own sets of
class methods and class attributes
-=item - Objects may have an array of attributes. Attribute values may be
-PMCs or a low-level type.
+=item - Classes can be subclassed
+
+=item - High-level classes can subclass low-level PMCs
+
+=item - Objects have a collection (0 or more) of attributes. Attribute
+values may be PMCs or a low-level type.
=item - Objects have an associated class.
@@ -121,20 +124,15 @@
=item - Objects can set an attribute by name
-=item - Objects can be subclassed (note that objects may not necessarily
-be able to have their classes changed arbitrarily, but making a subclass
-and moving the object to it is allowable)
-
-=item - High-level objects can subclass low-level PMCs
-
=back
=head2 Implementation
There are four pieces to the object implementation. There are the PMCs for the
classes, roles, and objects, the opcodes the engine uses to do objecty things,
-the specific vtable functions used to perform those objecty things, and the
-supporting code provided by the interpreter engine to do the heavy lifting.
+specific vtable functions used to perform some of those objecty things, and
+the supporting code provided by the interpreter engine to do the heavy
+lifting.
Parrot, in general, doesn't restrict operations on objects and classes. If a
language has restrictions on what can be done with them, the language is
@@ -149,58 +147,60 @@
=head3 Class PMC API
There are two PMC classes, C<Class> and C<Object>. Class PMCs hold all
-the class-specific information. Instantiating a new OO class creates a
-new Class PMC, and enters the new OO class into Parrot's PMC class
-table, at which point it is indistinguishable from any other PMC class.
+the class-specific information. Instantiating a new high-level class
+creates a new Class PMC, and enters the new high-level class into
+Parrot's PMC class table, at which point it is indistinguishable from
+any other PMC class.
It's important to note that 'standard' classes are Class PMC instances,
or instances of a subclass of the Class PMC, and 'standard' objects are
Object PMCs. It isn't necessary to create a brand new low-level PMC
-class for each OO class, and they all share the Class or Object vtable,
-respectively.
+class for each high-level class, and they all share the Class PMC
+vtable functions.
-An instance of the Class PMC has eleven internal attributes, which are:
+An instance of the Class PMC has eleven core internal attributes, which
+are:
=over 4
-=item 0
+=item 1
The class name
-=item 1
+=item 2
A link to the class's associated namespace
-=item 2
+=item 3
A "have I been instantiated since I was last modified" flag
-=item 3
+=item 4
An array PMC of the immediate parent classes
-=item 4
+=item 5
A cached array of all parent PMCs, in search order (this is an optional
optimization, and can be calculated from the class's rules of inheritance,
the list of immediate parent classes, and the parent classes' rules of
inheritance)
-=item 5
+=item 6
An array PMC of the composed roles (these are Role PMCs, not string names of
roles).
-=item 6
+=item 7
A hash PMC of the methods defined in the class or composed into the
class
-=item 7
+=item 8
A hash PMC of the overloaded PMC vtable entries for the class.
-=item 8
+=item 9
The class attribute metadata hash. Keys are the attribute names and the
values are a hash of attribute characteristics, including name, type, the
@@ -208,7 +208,7 @@
that this only stores metadata for the attributes defined in this class,
and not for attributes inherited from its parents.
-=item 9
+=item 10
The full attribute lookup table. This associates attribute names with an
index into the object's attribute storage (an array). It includes all
@@ -218,7 +218,7 @@
attribute name. The value is an index into the per-object attribute
store.
-=item 10
+=item 11
The attribute cache. While the attribute lookup table defines every
attribute, whether it is visible or not with the current method
@@ -243,46 +243,23 @@
child class attributes override which parent class attributes. The
cache is only set on individual accesses to a particular attribute.
-(If a parent class changes its set of attributes, should that change
-appear in later instantiations of objects from child classes? If so, all
-of these classes would need to be re-constructed as a result of the
-change; note that any already instantiated objects would refer to the
-old class. NOTE: flag old classes with an "updated" status, to notify
-objects of the old class that they should rebless themselves into the
-new class next time they access the old class?)
-
Class PMCs also have the "I am a class" flag set on them.
=head4 Classes, Namespaces, and the Class Registry
-Extending an existing class that has been instantiated creates a new
-class object that replaces the old class object in the Namespace.
-However, the old class object must be kept, as the old objects still
-point to it and do their method resolution and attribute lookup through
-that class object.
-
-If a class hasn't been instantiated, adding a method or attribute only
-modifies the existing class object instead of creating a new class
-object. Extending a class that has been instantiated only causes the
-creation of a new class object the first time it's extended. After
-that, methods and attributes added to it will only modify the existing
-class object until it is instantiated again.
-
-The Namespace always points to the most current incarnation of the
-class. All the class objects that belong to a particular namespace store
-a pointer to that Namespace object. They keep that pointer even if the
-Namespace object no longer stores a pointer to them.
-
-Since any given class name may have multiple corresponding class
-objects, the class registry has a much diminished role in this
-implementation. Its only responsibility is maintaining a mapping of
-unique IDs to class objects throughout the system. It can't be used for
-looking up classes by name, because it's possible to have multiple
-classes with the same name in the same namespace. The class registry may
-need to have names removed (since it doesn't care about names anymore).
-Low-level PMC types will also need entries in the namespace hierarchy.
-We may eventually be able to eliminate the registry of class IDs
-altogether.
+If a class hasn't been instantiated, adding a method or attribute
+modifies the existing class object. Extending a class that has been
+instantiated is not allowed.
+
+The class registry has a much diminished role in this implementation.
+Its only responsibility is maintaining a mapping of unique IDs to class
+objects throughout the system. It should not be used for looking up
+classes by name.
+
+The class registry may need to have names removed (since it doesn't care
+about names anymore). We plan to eventually eliminate the registry of
+class IDs altogether. Low-level PMC types also have entries in the
+namespace hierarchy via PMCProxy objects.
A class can be garbage collected when it has no instantiated objects
and no Namespace object referencing it (to mark it as live). When a
@@ -334,15 +311,7 @@
Returns the PMC for the named method. If no method of this name exists, nor
can be constructed, returns a Null PMC.
-Note that for languages which support default fallback methods, such as Perl
-5's AUTOLOAD, this would be the place to return it if a normal lookup fails.
-
-Since the method list and vtable override list are stored in the class
-PMC, method finding is a lookup on the class object and not a lookup in
-the namespace. (This could be handled automatically whenever a class is
-associated with a namespace.) Just adding a sub to a namespace will not
-automatically make it a method of the class, you have to call add_method
-too.
+A class object reports on class methods, not on instance methods.
=item isa(pmc *)
@@ -358,19 +327,19 @@
=item can(string *)
Returns true or false if the class can perform the requested method.
-(Including with an AUTOLOAD)
+(Class systems that implement default fallback methods should report
+that they 'can' perform any method.)
-A class object only reports on class methods, it does not report on instance
-methods.
+A class object reports on class methods, not on instance methods.
=item does(class *)
Returns true or false to note whether the class in question implements the
interface passed in.
-A class object only reports on interfaces of the class (i.e. roles composed
-into the metaclass), while an instance object only reports on interfaces of
-the instance (i.e. roles composed into the class).
+A class object only reports on interfaces of the class (i.e. roles
+composed into the metaclass), it doesn't report on which interfaces will
+be added to an instance of that class.
=item inspect()
@@ -399,20 +368,14 @@
Remove a parent from the class.
-=item remove_role(string *)
-
-Remove a role from the class.
-
=back
-Currently Parrot only supports mutating a class' metainformation for
-Class classes. This is a restriction which will be lifted at some point
-soon.
+Parrot only supports mutating class metainformation for Class classes.
+This restriction may be lifted at some point.
=head4 Class Methods
-These methods are just syntactic sugar for the vtable functions. They are
-not included in the Class PMC by default, but added to Class as a role.
+These methods are just syntactic sugar for the vtable functions.
=over 4
@@ -429,11 +392,11 @@
the class, and also sets the association with a namespace. With no
argument it only returns the current value of the name attribute.
-=item namespace
+=item get_namespace
=begin PIR_FRAGMENT
- $P1 = $P2.'namespace'()
+ $P1 = $P2.'get_namespace'()
=end PIR_FRAGMENT
@@ -462,13 +425,12 @@
=end PIR_FRAGMENT
Adds a single attribute to the class. It takes a simple string name and,
-optionally, a simple string value or key specifying a type name. (A type
-name just checks C<does>, and doesn't necessarily correspond to a class or
-role namespace.)
+optionally, a simple string value or key specifying a type name. (Types
+are not currently checked by Parrot, and only provided for
+introspection.)
-If the class has already been instantiated, adding a new attribute triggers
-the creation of a new class, replacing the old class. See L<Classes,
-Namespaces, and the Class Registry>.
+If the class has already been instantiated, adding a new attribute
+throws an exception.
=item attributes
@@ -487,17 +449,11 @@
=begin PIR_FRAGMENT
$P1.'add_method'($S2, $P3)
- $P1.'add_method'($S2, $P3, 'vtable' => 1)
=end PIR_FRAGMENT
Adds a method to the class. It takes a simple string name and a method
-PMC. If the method already exists (and isn't a Multi) it will replace
-the method with the new method and throw a warning.
-
-It also takes named parameters to flag whether the method is a vtable
-override, and whether it is anonymous (no named entry as a method, only
-as a vtable).
+PMC. If the method already exists it will throw an exception.
=item methods
@@ -512,6 +468,19 @@
Note that the methods list includes any methods that were composed into
the class from roles.
+=item add_vtable_override
+
+=begin PIR_FRAGMENT
+
+ $P1.'add_vtable_override'($S2, $P3)
+
+=end PIR_FRAGMENT
+
+Adds a vtable override to the class. It takes a simple string name and a
+sub/method PMC. If the vtable override already exists it will throw an
+exception (attempting to add the same sub/method object a second time
+will be silently ignored).
+
=item add_parent
=begin PIR_FRAGMENT
@@ -520,7 +489,8 @@
=end PIR_FRAGMENT
-Adds a single parent to the class. It takes an instance of the Class PMC.
+Adds a single parent to the class. It takes a Class PMC argument (the
+parent to add).
=item parents
@@ -530,7 +500,7 @@
=end PIR_FRAGMENT
-An accessor for the parents of the class. It returns an Array of all
+An accessor for the parents of the class. It returns an array of all
parents. The accessor is read-only.
=item roles
@@ -541,7 +511,7 @@
=end PIR_FRAGMENT
-An accessor for the roles of the class. It returns an Array of all
+An accessor for the roles of the class. It returns an array of all
roles. The accessor is read-only.
=item add_role
@@ -575,8 +545,7 @@
=end PIR_FRAGMENT
Returns true if the class name passed in as a parameter is in the inheritance
-hierarchy of the class (this is not the same as the inheritance hierarchy of
-objects instantiated from the class), false otherwise.
+hierarchy of the class, false otherwise.
=item can
@@ -589,8 +558,6 @@
Returns true if the class object can perform the requested method, false
otherwise.
-A class object only reports on class methods, not on instance methods.
-
=item does
=begin PIR_FRAGMENT
@@ -624,22 +591,23 @@
C<Object> PMCs are the actual objects, and hold all the per-object
instance data.
-The Object PMC is an array of meta-information and attributes. The
-elements of this array are:
+An instance of the Object PMC has two core internal attributes, which
+are:
=over 4
-=item 0
+=item 1
The class PMC
-=item 1
+=item 2
-The object attribute store. This is simply an array of PMCs that
-provide the values for the attributes. It may be a resizable PMC array
-to provide lazy growth rather than allocating all needed memory for
-all attributes. We find the indexes into this array from the attribute
-cache or lookup table in the class.
+The object attribute store. This is simply an array of PMCs that provide
+the values for the attributes. It may be a resizable PMC array to
+provide lazy growth rather than allocating all needed memory for all
+attributes. The attribute cache and lookup table in the class store the
+indexes into this array, linking the attribute name and meta-information
+with the storage position.
=back
@@ -656,24 +624,6 @@
information about the object, method call functionality, etc. See the
sections below on L<Objects> and L<Vtables>.
-In addition to a value type, objects can have a container type. The
-container type can't be stored in the object itself, because a single
-object may live within multiple containers. So, the container type (when
-it exists) is stored in the LexPad or Namespace entry for a particular
-variable.
-
-In a static language like C#.Net:
-
- B isa A
- A o1 = new B();
- B o2 = new B();
-
- o1.x; # retrieves A's attribute
- o2.x; # retrieves B's attribute
-
- o1.foo(); # calls B's method
- o2.foo(); # calls B's method
-
=head4 Object Vtable Entries
All Objects need the following vtable entries.
@@ -683,8 +633,18 @@
=item find_method(string *)
Returns the PMC for the named method. If no method of this name exists,
-nor can be constructed, returns a Null PMC. This only passes the method
-search on to the object's class.
+nor can be constructed, returns a Null PMC.
+
+Note that for languages which support default fallback methods (such as
+Perl 5's AUTOLOAD) this would be the place to return it if a normal
+lookup fails.
+
+Since the method list and vtable override list are stored in the class
+PMC, method finding is a lookup on the class object and not a lookup in
+the namespace. Just adding a sub to a namespace will not automatically
+make it a method of the class, you have to call add_method too.
+
+An instance object reports on instance methods, not on class methods.
=item isa(class *)
@@ -694,7 +654,8 @@
=item can(string *)
Returns true or false if the object can perform the requested method.
-(Including with an AUTOLOAD)
+(Class systems that implement default fallback methods should report
+that they 'can' perform any method.)
An instance object only reports on instance methods, not on class methods.
@@ -753,32 +714,32 @@
=head3 Role PMC API
-An instance of the Role PMC has five attributes, which are:
+An instance of the Role PMC has five core attributes, which are:
=over 4
-=item 0
+=item 1
The role name
-=item 1
+=item 2
A link to the role's associated namespace
-=item 2
+=item 3
An array PMC of composed roles
-=item 3
+=item 4
An array PMC of the methods defined in the role or composed into the
role
-=item 4
+=item 5
-The role attribute hash. Keys are the attribute names and the values
-are a hash of attribute characteristics, including name, type, and the
-role they're associated with.
+The role attribute hash, where each key is an attribute name and the
+corresponding value is a hash of attribute characteristics, including
+name, type, and the role they're associated with.
=back
@@ -809,10 +770,17 @@
Returns the PMC for the named method. If no method of this name exists,
nor can be constructed, returns a Null PMC.
+A role object reports on class methods (methods of the metarole), not on
+instance methods.
+
=item can(string *)
Returns true or false if the role can perform the requested method.
-(Including with an AUTOLOAD)
+(Class systems that implement default fallback methods should report
+that they 'can' perform any method.)
+
+A role object reports on class methods (methods of the metarole), not on
+instance methods.
=item does(class *)
@@ -821,7 +789,7 @@
A role object only reports on interfaces of the role (i.e. roles composed into
the metarole), it doesn't report on which interfaces will be added to an
-object that composes the role.
+object instantiated from a class that composes the role.
=item clone
@@ -846,17 +814,11 @@
Remove a method from the role.
-
-=item remove_role(string *)
-
-Remove a role from the role.
-
=back
=head4 Role Methods
-These methods are just syntactic sugar for the vtable functions. They are
-not included in the Role PMC by default, but added to Role as a role.
+These methods are just syntactic sugar for the vtable functions.
=over 4
@@ -872,11 +834,11 @@
the current value for name. When passed an argument, it sets the name of
the role, and also sets the association with a namespace.
-=item namespace
+=item get_namespace
=begin PIR_FRAGMENT
- $P1 = $P2.'namespace'()
+ $P1 = $P2.'get_namespace'()
=end PIR_FRAGMENT
@@ -940,17 +902,23 @@
=begin PIR_FRAGMENT
$P1.'add_method'($S2, $P3)
- $P1.'add_method'($S2, $P3, 'vtable' => 1)
=end PIR_FRAGMENT
Adds a method to the role. It takes a simple string name and a method
-PMC. If the method already exists (and isn't a Multi) it will replace
-the method with the new method and throw a warning.
+PMC. If the method already exists it will throw an exception.
-It also takes slurpy named parameters to flag whether the method is a
-vtable override, and whether its anonymous (no named entry as a method,
-only as a vtable).
+=item add_vtable_override
+
+=begin PIR_FRAGMENT
+
+ $P1.'add_vtable_override'($S2, $P3)
+
+=end PIR_FRAGMENT
+
+Adds a vtable override to the role. It takes a simple string name and a
+sub/method PMC. If the vtable override already exists it will throw an
+exception.
=item methods
@@ -989,9 +957,8 @@
When declaring a composed class, you can optionally supply an array of
method names that will be defined by the class to resolve a conflict in
-its roles. This is done using the named parameter C<resolve>. This
-feature supports composition conflict resolution in languages such as
-Perl 6.
+its roles. This is done using the named parameter C<resolve>. This
+feature supports composition conflict resolution.
When adding a role to a class, you can optionally supply an array of
method names from the role to exclude from the composition process. This
@@ -1016,13 +983,6 @@
resolving method to be able to call either of the conflicting methods
from two composed roles.)
-If a method in a role is a MultiSub PMC and there is either no method of
-that name yet OR what is in the method slot with that name is also a
-MultiSub PMC, there will be no error. Instead, the multi-methods from
-the role will be added to the multi-methods of the MultiSub PMC already
-in the class. Any attempt to combine a multi with a non-multi will
-result in an error.
-
=head3 Opcodes
The following ops are provided to deal with objects. Please note that
@@ -1074,7 +1034,7 @@
=end PIR_FRAGMENT
-Call the method specified in the attribute $S1 using $P1 as the invocant and
+Call the method specified in the string name $S1 using $P1 as the invocant and
using the continuation passed in $P2. If you need to create a new continuation
use C<callmethodcc>.
@@ -1098,11 +1058,11 @@
=end PIR_FRAGMENT
-Call the method specified in the attribute $S1, or in the Sub object $P2,
+Call the method specified in the string name $S1, or in the Sub object $P2,
using $P1 as the invocant for method lookup and generate a new return
continuation.
-Throws a Method_Not_Found_Exception for a non-existent method.
+Throws an exception for a non-existent method.
=item callmethodsupercc [hypothetical, 2.0 or later]
@@ -1113,11 +1073,11 @@
=end PIR_FRAGMENT_TODO
-Call the method specified in the attribute $S1, or in the Sub object $P2,
+Call the method specified in the string name $S1, or in the Sub object $P2,
using $P1 as the invocant for method lookup and generate a new return
continuation. This is a variant of C<callmethodcc> that skips over the
current class when searching for the method, and only looks in the parent
-classes. PIR may provide some syntactical sugar for this.
+classes. PIR may provide some syntactic sugar for this.
=item callmethodnextcc [hypothetical, 2.0 or later]
@@ -1128,7 +1088,7 @@
=end PIR_FRAGMENT_TODO
-Call the method specified in the attribute $S1, or in the Sub object $P2,
+Call the method specified in the string name $S1, or in the Sub object $P2,
using $P1 as the invocant for method lookup and generate a new return
continuation. A variant of C<callmethodcc> that picks up an existing
C<find_method> search where it left off for the current call. {{ Note: this
@@ -1335,29 +1295,17 @@
=head3 Vtable Overriding
-Classes may override the vtable functions, allowing objects of a class to
-behave like a primitive PMC. To use these properly at a low-level
-requires a good working knowledge of the way Parrot works--generally for
-higher-level languages the language compiler or runtime will provide
-easier-to-use wrappers. These methods are all prototyped, and take a
-single fixed argument list, and return at most a single value.
+Classes can override vtable functions from PIR, allowing control over
+the low-level behavior of objects similar to PMCs defined in C. The
+vtable functions all take a single fixed argument list, and return at
+most a single value. Calling the overrides directly requires some
+knowledge of the way Parrot works, so higher-level languages will
+generally provide easier-to-use wrappers.
To override a vtable function, either add the :vtable pragma to the
declaration of the method, or pass a named parameter "vtable" into the
C<add_method> method on a class or role.
-=head3 What The Bytecode Sees
-
-The bytecode is isolated from most of the internal details of the
-implementation. This allows both for flexibility in the implementation and
-forward compatibility, generally good things. It also allows for multiple
-concurrent interoperable object systems. The major thrust is for transparent
-use of objects, though most class activity (including creation of subclasses
-and modifications of existing classes) should be transparent as well.
-
-
-
-
=head2 Examples
The following examples all assume we're working with basic Object objects
@@ -1369,7 +1317,7 @@
=begin PIR_FRAGMENT
- newclass $P0, "Foo"
+ $P0 = newclass "Foo"
=end PIR_FRAGMENT
@@ -1379,9 +1327,9 @@
=begin PIR_FRAGMENT
- get_class $P0, "A"
- get_class $P1, "B"
- subclass $P2, $P0, "Foo"
+ $P0 = get_class "A"
+ $P1 = get_class "B"
+ $P2 = subclass $P0, "Foo"
addparent $P2, $P1
=end PIR_FRAGMENT
@@ -1416,25 +1364,34 @@
Calling the method C<Xyzzy> on an object, assuming the PDD03 calling
conventions are respected:
-=begin PIR_FRAGMENT_INVALID
+=begin PASM_FRAGMENT_INVALID
callmethod "Xyzzy"
set S0, "Xyzzy"
callmethod
-=end PIR_FRAGMENT_INVALID
+=end PASM_FRAGMENT_INVALID
Or, if a return continuation needs constructing:
-=begin PIR_FRAGMENT_INVALID
+=begin PASM_FRAGMENT_INVALID
callmethodcc "Xyzzy"
set S0, "Xyzzy"
callmethodcc
-=end PIR_FRAGMENT_INVALID
+=end PASM_FRAGMENT_INVALID
+
+Or, calling a method in PIR, where the calling conventions are handled
+automatically.
+
+=begin PIR_FRAGMENT
+
+ $P0.'Xyzzy'($P1)
+
+=end PIR_FRAGMENT
=head3 Accessing attributes from within a class
@@ -1442,7 +1399,7 @@
=begin PIR_FRAGMENT
- getattribute $P1, $P0, "Foo\x0b"
+ $P1 = getattribute $P0, "b"
=end PIR_FRAGMENT
@@ -1474,9 +1431,9 @@
=head3 PMCs
-Ruby: Just like Smalltalk, everything is an object. I'm hoping to be able to
-implement core Ruby classes (String, Array, Hash, Module, etc) something like
-this.
+Ruby: Just like Smalltalk, everything is an object. Core Ruby classes
+(String, Array, Hash, Module, etc) might be implemented something like
+this:
ParrotClass
|
Modified: branches/gc-refactor/docs/project/release_manager_guide.pod
==============================================================================
--- branches/gc-refactor/docs/project/release_manager_guide.pod Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/docs/project/release_manager_guide.pod Wed Sep 16 18:24:30 2009 (r41302)
@@ -364,7 +364,10 @@
The starred releases are Parrot's twice-yearly supported releases, see
F<docs/project/support_policy.pod>.
- - Sept 15, 2009 - 1.6 - particle
+The calendar of releases is available at the comp.lang.parrot google calendar,
+visible at
+L<http://www.google.com/calendar/render?cid=ldhctdamsgfg5a1cord52po9h8@group.calendar.google.com>.
+
- Oct 20, 2009 - 1.7 - dukeleto
- Nov 17, 2009 - 1.8 - bernhard
- Dec 15, 2009 - 1.9 - gerd
Modified: branches/gc-refactor/docs/running.pod
==============================================================================
--- branches/gc-refactor/docs/running.pod Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/docs/running.pod Wed Sep 16 18:24:30 2009 (r41302)
@@ -137,16 +137,18 @@
slow, bounds bounds checking core (default)
cgoto computed goto core
cgp computed goto-predereferenced core
- cgp-jit computed goto-predereferenced core with JIT
exec exec core (uses JIT at compile time to generate native code)
fast fast core (no bounds checking, profiling, or tracing)
gcdebug performs a full GC run before every op dispatch (good for
debugging GC problems)
- jit JIT core
switch switch core
- switch-jit switch core with JIT
trace bounds checking core w/ trace info (see 'parrot --help-debug')
+The C<jit>, C<switch-jit>, and C<cgp-jit> options are currently aliases for the
+C<fast>, C<switch>, and C<cgp> options, respectively. We do not recommend
+their use in new code; they will continue working for existing code per our
+deprecation policy.
+
=item -p, --profile
Run with the slow core and print an execution profile.
Modified: branches/gc-refactor/examples/benchmarks/oofib.pir
==============================================================================
--- branches/gc-refactor/examples/benchmarks/oofib.pir Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/examples/benchmarks/oofib.pir Wed Sep 16 18:24:30 2009 (r41302)
@@ -6,12 +6,14 @@
.local int argc
argc = argv
.local pmc N
- N = new 'Integer'
- N = 24
if argc <= 1 goto noarg
$S0 = argv[1]
N = $S0
noarg:
+ N = new 'Integer'
+ N = 24
+ goto begin
+begin:
.local num start
time start
@@ -51,13 +53,10 @@
.local pmc n2
.local pmc r1
.local pmc r2
- n1 = new 'Integer'
- n2 = new 'Integer'
n1 = n - 1
n2 = n - 2
r1 = self."fibA"(n1)
r2 = self."fibB"(n2)
- n = new 'Integer'
n = r1 + r2
.return (n)
.end
@@ -71,13 +70,10 @@
.local pmc n2
.local pmc r1
.local pmc r2
- n1 = new 'Integer'
- n2 = new 'Integer'
n1 = n - 1
n2 = n - 2
r1 = self."fib"(n1)
r2 = self."fibB"(n2)
- n = new 'Integer'
n = r1 + r2
.return (n)
.end
@@ -93,13 +89,10 @@
.local pmc n2
.local pmc r1
.local pmc r2
- n1 = new 'Integer'
- n2 = new 'Integer'
n1 = n - 1
n2 = n - 2
r1 = self."fib"(n1)
r2 = self."fibA"(n2)
- n = new 'Integer'
n = r1 + r2
.return (n)
.end
Modified: branches/gc-refactor/examples/embed/cotorra.c
==============================================================================
--- branches/gc-refactor/examples/embed/cotorra.c Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/examples/embed/cotorra.c Wed Sep 16 18:24:30 2009 (r41302)
@@ -110,7 +110,6 @@
{ PARROT_SLOW_CORE, "slow" },
{ PARROT_FAST_CORE, "fast" },
{ PARROT_CGOTO_CORE, "cgoto" },
- { PARROT_JIT_CORE, "jit" },
{ PARROT_GC_DEBUG_CORE, "gcdebug" },
{ PARROT_SWITCH_CORE, "switch" }
};
Modified: branches/gc-refactor/examples/nci/Mysql.pir
==============================================================================
--- branches/gc-refactor/examples/nci/Mysql.pir Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/examples/nci/Mysql.pir Wed Sep 16 18:24:30 2009 (r41302)
@@ -1,4 +1,4 @@
-# Copyright (C) 2008, Parrot Foundation.
+# Copyright (C) 2008-2009, Parrot Foundation.
# $Id$
=head1 TITLE
@@ -81,6 +81,9 @@
clientlib = loadlib 'libmysqlclient'
$I0 = defined clientlib
if $I0 goto libloaded
+ clientlib = loadlib 'libmysqlclient.so.15'
+ $I0 = defined clientlib
+ if $I0 goto libloaded
fail('Cannot load mysql client lib')
libloaded:
set_global 'clientlib', clientlib
@@ -124,7 +127,7 @@
.end
#-----------------------------------------------------------------------
-.sub init :vtable
+.sub 'init' :vtable
.local pmc mysql_init
mysql_init = get_mysql_function('mysql_init', 'pp')
@@ -402,7 +405,7 @@
.namespace ['Mysql';'Result']
#-----------------------------------------------------------------------
-.sub init_pmc :vtable
+.sub 'init_pmc' :vtable
.param pmc mysql :named
.param pmc r :named
@@ -435,7 +438,7 @@
.end
#-----------------------------------------------------------------------
-.sub destroy :vtable
+.sub 'destroy' :vtable
self.'free'()
.end
@@ -454,7 +457,7 @@
.end
#-----------------------------------------------------------------------
-.sub field_count :method
+.sub 'elements' :vtable
.local pmc field_count
field_count = get_mysql_function('mysql_field_count', 'ip')
.local pmc mysql
@@ -465,6 +468,13 @@
.end
#-----------------------------------------------------------------------
+.sub field_count :method
+ .local int fields
+ fields = elements self
+ .return(fields)
+.end
+
+#-----------------------------------------------------------------------
.sub fetch_row :method
.local pmc rowres
@@ -516,14 +526,21 @@
.namespace ['Mysql';'Row']
#-----------------------------------------------------------------------
-.sub get_integer :vtable
+.sub 'get_integer' :vtable
+ .local pmc data
+ data = getattribute self, 'data'
+ $I0 = data
+ .return($I0)
+.end
+
+.sub 'elements' :vtable
.local pmc data
data = getattribute self, 'data'
$I0 = data
.return($I0)
.end
-.sub get_number :vtable
+.sub 'get_number' :vtable
.local pmc data
data = getattribute self, 'data'
$I0 = data
@@ -531,7 +548,7 @@
.return($N0)
.end
-.sub get_string_keyed :vtable
+.sub 'get_string_keyed' :vtable
.param int n
.local pmc data
@@ -540,7 +557,7 @@
.return($S0)
.end
-.sub get_pmc_keyed :vtable
+.sub 'get_pmc_keyed' :vtable
.param int n
.local pmc data
Modified: branches/gc-refactor/examples/nci/mysqltest.p6
==============================================================================
--- branches/gc-refactor/examples/nci/mysqltest.p6 Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/examples/nci/mysqltest.p6 Wed Sep 16 18:24:30 2009 (r41302)
@@ -21,7 +21,7 @@
########################################################################
use v6;
-use Mysql;
+use Mysql:from<parrot>;
say 'mysql client version: ', Mysql::get_client_info();
@@ -43,6 +43,7 @@
my @row_copy;
my $i = 0;
while ($i < $elems) {
+ print $i, ': ';
print "'", $row[$i], "'";
@row_copy.push($row[$i]);
++$i;
Modified: branches/gc-refactor/examples/nci/mysqltest.pir
==============================================================================
--- branches/gc-refactor/examples/nci/mysqltest.pir Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/examples/nci/mysqltest.pir Wed Sep 16 18:24:30 2009 (r41302)
@@ -1,4 +1,4 @@
-# Copyright (C) 2008, Parrot Foundation.
+# Copyright (C) 2008-2009, Parrot Foundation.
# $Id$
=head1 TITLE
@@ -38,9 +38,11 @@
say $S0
exit 1
good:
+ say 'connect...'
m.'connect'('localhost', 'parrot', 'baDworD', 'parrot')
+ say 'query...'
m.'query'('select * from hello;')
.local pmc r
@@ -72,12 +74,16 @@
# Testing prepared statement
+# Skipping, still not working
+ .return()
+
.local pmc stmt
stmt = m.'prepare'('select * from hello where foo = ?')
$I0 = stmt.'param_count'()
print 'Param count: '
say $I0
+ say 'Closing...'
$I0 = stmt.'close'()
print 'Close result: '
say $I0
Modified: branches/gc-refactor/examples/nci/xlibtest.p6
==============================================================================
--- branches/gc-refactor/examples/nci/xlibtest.p6 Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/examples/nci/xlibtest.p6 Wed Sep 16 18:24:30 2009 (r41302)
@@ -1,4 +1,4 @@
-# Copyright (C) 2008, Parrot Foundation.
+# Copyright (C) 2008-2009, Parrot Foundation.
# $Id$
use v6;
@@ -22,7 +22,7 @@
=end pod
-use Xlib;
+use Xlib:from<parrot>;
# Event types
constant KeyPress = 2;
Modified: branches/gc-refactor/include/parrot/call.h
==============================================================================
--- branches/gc-refactor/include/parrot/call.h Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/include/parrot/call.h Wed Sep 16 18:24:30 2009 (r41302)
@@ -215,7 +215,7 @@
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
PMC* Parrot_pcc_build_sig_object_from_varargs(PARROT_INTERP,
- ARGIN_NULLOK(PMC* obj),
+ ARGIN_NULLOK(PMC *obj),
ARGIN(const char *sig),
va_list args)
__attribute__nonnull__(1)
Modified: branches/gc-refactor/include/parrot/compiler.h
==============================================================================
--- branches/gc-refactor/include/parrot/compiler.h Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/include/parrot/compiler.h Wed Sep 16 18:24:30 2009 (r41302)
@@ -40,7 +40,11 @@
# ifdef _MSC_VER
# define __attribute__noreturn__ __declspec(noreturn)
# else
-# define __attribute__noreturn__ __attribute__((__noreturn__))
+# ifdef __clang__
+# define __attribute__noreturn__ __attribute__((analyzer_noreturn))
+# else
+# define __attribute__noreturn__ __attribute__((__noreturn__))
+# endif
# endif
#endif
#ifdef HASATTRIBUTE_PURE
@@ -99,25 +103,21 @@
*/
#define UNUSED(a) /*@-noeffect*/if (0) (void)(a)/*@=noeffect*/;
-/* 64-bit CL has some problems, so this section here is going to try to fix them */
-#ifdef PARROT_HAS_MSVC_SAL
-# ifdef _WIN64
- /* CL64 can't seem to find sal.h, so take that out of the equation */
-# undef PARROT_HAS_MSVC_SAL
- /* CL64 complains about not finding _iob, so this might fix it */
-
-
-# endif
-#endif
-
-#ifdef PARROT_HAS_MSVC_SAL
+#ifdef PARROT_HAS_HEADER_SAL
+/*
+ * Microsoft provides two annotations mechanisms. __declspec, which has been
+ * around for a while, and Microsoft's standard source code annotation
+ * language (SAL), introduced with Visual C++ 8.0.
+ * See <http://msdn2.microsoft.com/en-us/library/ms235402(VS.80).aspx>,
+ * <http://msdn2.microsoft.com/en-us/library/dabb5z75(VS.80).aspx>.
+ */
# include <sal.h>
# define PARROT_CAN_RETURN_NULL /*@null@*/ __maybenull
# define PARROT_CANNOT_RETURN_NULL /*@notnull@*/ __notnull
#else
# define PARROT_CAN_RETURN_NULL /*@null@*/
# define PARROT_CANNOT_RETURN_NULL /*@notnull@*/
-#endif
+#endif /* PARROT_HAS_HEADER_SAL */
#define PARROT_DEPRECATED __attribute__deprecated__
@@ -142,7 +142,7 @@
/* Function argument instrumentation */
/* For explanations of the annotations, see http://www.splint.org/manual/manual.html */
-#ifdef PARROT_HAS_MSVC_SAL
+#ifdef PARROT_HAS_HEADER_SAL
# define NOTNULL(x) /*@notnull@*/ __notnull x
/* The pointer passed may not be NULL */
Modified: branches/gc-refactor/include/parrot/context.h
==============================================================================
--- branches/gc-refactor/include/parrot/context.h Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/include/parrot/context.h Wed Sep 16 18:24:30 2009 (r41302)
@@ -32,7 +32,7 @@
/* Manually inlined macros. Used in optimised builds */
-# define __C(c) (PMC_data_typed(c, Parrot_Context*))
+# define __C(c) (PMC_data_typed((c), Parrot_Context*))
# define CTX_REG_NUM(p, x) (__C(p)->bp.regs_n[-1L - (x)])
# define CTX_REG_INT(p, x) (__C(p)->bp.regs_i[(x)])
Modified: branches/gc-refactor/include/parrot/interpreter.h
==============================================================================
--- branches/gc-refactor/include/parrot/interpreter.h Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/include/parrot/interpreter.h Wed Sep 16 18:24:30 2009 (r41302)
@@ -67,9 +67,6 @@
PARROT_SWITCH_CORE = 0x02, /* P = prederef */
PARROT_CGP_CORE = 0x06, /* CP */
PARROT_CGOTO_CORE = 0x04, /* C = cgoto */
- PARROT_JIT_CORE = 0x10, /* J = JIT */
- PARROT_CGP_JIT_CORE = 0x16, /* JCP */
- PARROT_SWITCH_JIT_CORE = 0x12, /* J P */
PARROT_EXEC_CORE = 0x20, /* TODO Parrot_exec_run variants */
PARROT_GC_DEBUG_CORE = 0x40, /* run GC before each op */
PARROT_DEBUGGER_CORE = 0x80, /* used by parrot debugger */
Modified: branches/gc-refactor/include/parrot/packfile.h
==============================================================================
--- branches/gc-refactor/include/parrot/packfile.h Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/include/parrot/packfile.h Wed Sep 16 18:24:30 2009 (r41302)
@@ -266,8 +266,6 @@
PackFile_Segment base;
Prederef prederef; /* The predereferenced code and info */
struct Parrot_jit_info_t *jit_info; /* JITs data */
- Parrot_PIC_store *pic_store; /* PIC storage */
- PackFile_Segment *pic_index; /* segment of indices into store */
struct PackFile_Debug *debugs;
PackFile_ConstTable *const_table;
PackFile_FixupTable *fixups;
Modified: branches/gc-refactor/include/parrot/parrot.h
==============================================================================
--- branches/gc-refactor/include/parrot/parrot.h Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/include/parrot/parrot.h Wed Sep 16 18:24:30 2009 (r41302)
@@ -271,7 +271,6 @@
#include "parrot/exceptions.h"
#include "parrot/warnings.h"
#include "parrot/memory.h"
-#include "parrot/pic.h"
#include "parrot/packfile.h"
#include "parrot/io.h"
#include "parrot/op.h"
Deleted: branches/gc-refactor/include/parrot/pic.h
==============================================================================
--- branches/gc-refactor/include/parrot/pic.h Wed Sep 16 18:24:30 2009 (r41301)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,204 +0,0 @@
-/* pic.h
- * Copyright (C) 2005, Parrot Foundation.
- * SVN Info
- * $Id$
- * Overview:
- * This is the api header for the pic subsystem
- * Data Structure and Algorithms:
- * History:
- * Notes:
- * References:
- */
-
-#ifndef PARROT_PIC_H_GUARD
-#define PARROT_PIC_H_GUARD
-
-#include "parrot/runcore_api.h"
-
-/*
- * one cache slot
- *
- * if types exceed 16 bits or for general MMD function calls an
- * extended cache slot is needed with more type entries
- */
-typedef struct Parrot_pic_lru_t {
- union {
- INTVAL type; /* for MMD left << 16 | right type */
- PMC *signature; /* arg passing signature */
- } u;
- union {
- funcptr_t real_function; /* the actual C code */
- PMC *sub; /* or a Sub PMC */
- PMC **pattr; /* attribute location */
- } f;
-} Parrot_PIC_lru;
-
-/*
- * PIC 3 more cache slots
- */
-typedef struct Parrot_pic_t {
- Parrot_PIC_lru lru[3]; /* PIC - three more cache entries */
- INTVAL miss_count; /* how many misses */
-} Parrot_PIC;
-
-/*
- * the main used MIC one cache slot - 4 words size
- */
-typedef struct Parrot_mic_t {
- Parrot_PIC_lru lru; /* MIC - one cache */
- union {
- STRING *method; /* for callmethod */
- INTVAL func_nr; /* MMD function number */
- STRING *attribute; /* obj.attribute */
- PMC *sig; /* arg passing */
- } m;
- Parrot_PIC *pic; /* more cache entries */
-} Parrot_MIC;
-
-/*
- * memory is managed by this structure hanging off a
- * PackFile_ByteCode segment
- */
-typedef struct Parrot_pic_store_t {
- struct Parrot_pic_store_t *prev; /* prev pic_store */
- size_t usable; /* size of usable memory: */
- Parrot_PIC *pic; /* from rear */
- Parrot_MIC *mic; /* idx access to allocated MICs */
- size_t n_mics; /* range check, debugging mainly */
-} Parrot_PIC_store;
-
-typedef int (*arg_pass_f)(PARROT_INTERP, PMC *sig,
- char *src_base, void **src_pc, char *dest_base, void **dest_pc);
-
-/* more or less private interfaces */
-
-/* HEADERIZER BEGIN: src/pic.c */
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-
-PARROT_WARN_UNUSED_RESULT
-PARROT_CANNOT_RETURN_NULL
-Parrot_MIC* parrot_PIC_alloc_mic(const PARROT_INTERP, size_t n);
-
-PARROT_WARN_UNUSED_RESULT
-PARROT_CANNOT_RETURN_NULL
-Parrot_PIC* parrot_PIC_alloc_pic(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-void parrot_PIC_alloc_store(ARGOUT(PackFile_ByteCode *cs), size_t n)
- __attribute__nonnull__(1)
- FUNC_MODIFIES(*cs);
-
-PARROT_WARN_UNUSED_RESULT
-int parrot_pic_check_sig(PARROT_INTERP,
- ARGIN(PMC *sig1),
- ARGIN(PMC *sig2),
- ARGOUT(int *type))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- __attribute__nonnull__(4)
- FUNC_MODIFIES(*type);
-
-void parrot_PIC_destroy(ARGMOD(PackFile_ByteCode *cs))
- __attribute__nonnull__(1)
- FUNC_MODIFIES(*cs);
-
-void parrot_pic_find_infix_v_pp(PARROT_INTERP,
- ARGIN(PMC *left),
- ARGIN(PMC *right),
- ARGOUT(Parrot_MIC *mic),
- ARGOUT(opcode_t *cur_opcode))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- __attribute__nonnull__(4)
- __attribute__nonnull__(5)
- FUNC_MODIFIES(*mic)
- FUNC_MODIFIES(*cur_opcode);
-
-PARROT_CONST_FUNCTION
-int parrot_PIC_op_is_cached(int op_code);
-
-PARROT_WARN_UNUSED_RESULT
-PARROT_CAN_RETURN_NULL
-void * parrot_pic_opcode(PARROT_INTERP, INTVAL op)
- __attribute__nonnull__(1);
-
-void parrot_PIC_prederef(PARROT_INTERP,
- opcode_t op,
- ARGOUT(void **pc_pred),
- ARGIN(Parrot_runcore_t *core))
- __attribute__nonnull__(1)
- __attribute__nonnull__(3)
- __attribute__nonnull__(4)
- FUNC_MODIFIES(*pc_pred);
-
-#define ASSERT_ARGS_parrot_PIC_alloc_mic __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
-#define ASSERT_ARGS_parrot_PIC_alloc_pic __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_parrot_PIC_alloc_store __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(cs)
-#define ASSERT_ARGS_parrot_pic_check_sig __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(sig1) \
- || PARROT_ASSERT_ARG(sig2) \
- || PARROT_ASSERT_ARG(type)
-#define ASSERT_ARGS_parrot_PIC_destroy __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(cs)
-#define ASSERT_ARGS_parrot_pic_find_infix_v_pp __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(left) \
- || PARROT_ASSERT_ARG(right) \
- || PARROT_ASSERT_ARG(mic) \
- || PARROT_ASSERT_ARG(cur_opcode)
-#define ASSERT_ARGS_parrot_PIC_op_is_cached __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
-#define ASSERT_ARGS_parrot_pic_opcode __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_parrot_PIC_prederef __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(pc_pred) \
- || PARROT_ASSERT_ARG(core)
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-/* HEADERIZER END: src/pic.c */
-
-
-/* HEADERIZER BEGIN: src/pic_jit.c */
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-
-PARROT_WARN_UNUSED_RESULT
-int parrot_pic_is_safe_to_jit(PARROT_INTERP,
- ARGIN(PMC *sub_pmc),
- ARGIN(PMC *sig_args),
- ARGIN(PMC *sig_results),
- ARGOUT(int *flags))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- __attribute__nonnull__(4)
- __attribute__nonnull__(5)
- FUNC_MODIFIES(*flags);
-
-funcptr_t parrot_pic_JIT_sub(PARROT_INTERP, ARGIN(PMC *sub_pmc), int flags)
- __attribute__nonnull__(1)
- __attribute__nonnull__(2);
-
-#define ASSERT_ARGS_parrot_pic_is_safe_to_jit __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(sub_pmc) \
- || PARROT_ASSERT_ARG(sig_args) \
- || PARROT_ASSERT_ARG(sig_results) \
- || PARROT_ASSERT_ARG(flags)
-#define ASSERT_ARGS_parrot_pic_JIT_sub __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(sub_pmc)
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-/* HEADERIZER END: src/pic_jit.c */
-
-#endif /* PARROT_PIC_H_GUARD */
-
-/*
- * Local variables:
- * c-file-style: "parrot"
- * End:
- * vim: expandtab shiftwidth=4:
- */
Modified: branches/gc-refactor/include/parrot/pmc_freeze.h
==============================================================================
--- branches/gc-refactor/include/parrot/pmc_freeze.h Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/include/parrot/pmc_freeze.h Wed Sep 16 18:24:30 2009 (r41302)
@@ -105,13 +105,6 @@
PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
PARROT_CAN_RETURN_NULL
-STRING* Parrot_freeze_at_destruct(PARROT_INTERP, ARGIN(PMC* pmc))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2);
-
-PARROT_EXPORT
-PARROT_WARN_UNUSED_RESULT
-PARROT_CAN_RETURN_NULL
PMC* Parrot_thaw(PARROT_INTERP, ARGIN(STRING *image))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
@@ -129,9 +122,6 @@
#define ASSERT_ARGS_Parrot_freeze __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(pmc)
-#define ASSERT_ARGS_Parrot_freeze_at_destruct __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(pmc)
#define ASSERT_ARGS_Parrot_thaw __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(image)
Modified: branches/gc-refactor/include/parrot/runcore_api.h
==============================================================================
--- branches/gc-refactor/include/parrot/runcore_api.h Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/include/parrot/runcore_api.h Wed Sep 16 18:24:30 2009 (r41302)
@@ -12,9 +12,6 @@
struct runcore_t;
typedef struct runcore_t Parrot_runcore_t;
-struct profiling_runcore_t;
-typedef struct profiling_runcore_t Parrot_profiling_runcore_t;
-
#include "parrot/parrot.h"
#include "parrot/op.h"
@@ -38,39 +35,6 @@
INTVAL flags;
};
-
-typedef enum Parrot_profiling_flags {
- PROFILING_EXIT_CHECK_FLAG = 1 << 0,
- PROFILING_FIRST_LOOP_FLAG = 1 << 1,
- PROFILING_HAVE_PRINTED_CLI_FLAG = 1 << 2
-} Parrot_profiling_flags;
-
-struct profiling_runcore_t {
- STRING *name;
- int id;
- oplib_init_f opinit;
- Parrot_runcore_runops_fn_t runops;
- Parrot_runcore_destroy_fn_t destroy;
- Parrot_runcore_prepare_fn_t prepare_run;
- INTVAL flags;
-
- /* end of common members */
- UHUGEINTVAL runcore_start;
- UHUGEINTVAL op_start;
- UHUGEINTVAL op_finish;
- UHUGEINTVAL runcore_finish;
- INTVAL profiling_flags;
- INTVAL runloop_count;
- FILE *profile_fd;
- STRING *profile_filename;
- PMC *prev_sub;
- Parrot_Context *prev_ctx;
- UINTVAL level; /* how many nested runloops */
- UINTVAL time_size; /* how big is the following array */
- UHUGEINTVAL *time; /* time spent between DO_OP and start/end of a runcore */
-};
-
-
typedef enum Parrot_runcore_flags {
RUNCORE_REENTRANT_FLAG = 1 << 0,
RUNCORE_FUNC_TABLE_FLAG = 1 << 1,
@@ -81,34 +45,6 @@
} Parrot_runcore_flags;
-#define Profiling_flag_SET(runcore, flag) \
- ((runcore)->profiling_flags |= flag)
-#define Profiling_flag_TEST(runcore, flag) \
- ((runcore)->profiling_flags & flag)
-#define Profiling_flag_CLEAR(runcore, flag) \
- ((runcore)->profiling_flags &= ~(flag))
-
-#define Profiling_exit_check_TEST(o) \
- Profiling_flag_TEST(o, PROFILING_EXIT_CHECK_FLAG)
-#define Profiling_exit_check_SET(o) \
- Profiling_flag_SET(o, PROFILING_EXIT_CHECK_FLAG)
-#define Profiling_exit_check_CLEAR(o) \
- Profiling_flag_CLEAR(o, PROFILING_EXIT_CHECK_FLAG)
-
-#define Profiling_first_loop_TEST(o) \
- Profiling_flag_TEST(o, PROFILING_FIRST_LOOP_FLAG)
-#define Profiling_first_loop_SET(o) \
- Profiling_flag_SET(o, PROFILING_FIRST_LOOP_FLAG)
-#define Profiling_first_loop_CLEAR(o) \
- Profiling_flag_CLEAR(o, PROFILING_FIRST_LOOP_FLAG)
-
-#define Profiling_have_printed_cli_TEST(o) \
- Profiling_flag_TEST(o, PROFILING_HAVE_PRINTED_CLI_FLAG)
-#define Profiling_have_printed_cli_SET(o) \
- Profiling_flag_SET(o, PROFILING_HAVE_PRINTED_CLI_FLAG)
-#define Profiling_have_printed_cli_CLEAR(o) \
- Profiling_flag_CLEAR(o, PROFILING_HAVE_PRINTED_CLI_FLAG)
-
#define Runcore_flag_SET(runcore, flag) \
((runcore)->flags |= flag)
#define Runcore_flag_TEST(runcore, flag) \
@@ -235,12 +171,6 @@
/* HEADERIZER BEGIN: src/runcore/cores.c */
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-PARROT_CAN_RETURN_NULL
-void * destroy_profiling_core(PARROT_INTERP,
- ARGIN(Parrot_profiling_runcore_t *runcore))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2);
-
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
oplib_init_f get_core_op_lib_init(PARROT_INTERP,
@@ -248,12 +178,6 @@
__attribute__nonnull__(1)
__attribute__nonnull__(2);
-PARROT_WARN_UNUSED_RESULT
-PARROT_CANNOT_RETURN_NULL
-void * init_jit_run(PARROT_INTERP, ARGIN(Parrot_runcore_t *runcore))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2);
-
PARROT_CAN_RETURN_NULL
void * init_prederef(PARROT_INTERP, ARGIN(Parrot_runcore_t *runcore))
__attribute__nonnull__(1)
@@ -269,9 +193,6 @@
void Parrot_runcore_cgp_init(PARROT_INTERP)
__attribute__nonnull__(1);
-void Parrot_runcore_cgp_jit_init(PARROT_INTERP)
- __attribute__nonnull__(1);
-
void Parrot_runcore_debugger_init(PARROT_INTERP)
__attribute__nonnull__(1);
@@ -284,30 +205,15 @@
void Parrot_runcore_gc_debug_init(PARROT_INTERP)
__attribute__nonnull__(1);
-void Parrot_runcore_jit_init(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-void Parrot_runcore_profiling_init(PARROT_INTERP)
- __attribute__nonnull__(1);
-
void Parrot_runcore_slow_init(PARROT_INTERP)
__attribute__nonnull__(1);
void Parrot_runcore_switch_init(PARROT_INTERP)
__attribute__nonnull__(1);
-void Parrot_runcore_switch_jit_init(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-#define ASSERT_ARGS_destroy_profiling_core __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(runcore)
#define ASSERT_ARGS_get_core_op_lib_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(runcore)
-#define ASSERT_ARGS_init_jit_run __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(runcore)
#define ASSERT_ARGS_init_prederef __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(runcore)
@@ -318,8 +224,6 @@
PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_Parrot_runcore_cgp_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_Parrot_runcore_cgp_jit_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_Parrot_runcore_debugger_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_Parrot_runcore_exec_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
@@ -328,17 +232,10 @@
PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_Parrot_runcore_gc_debug_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_Parrot_runcore_jit_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_Parrot_runcore_profiling_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_Parrot_runcore_slow_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_Parrot_runcore_switch_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_Parrot_runcore_switch_jit_init \
- __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: src/runcore/cores.c */
Copied: branches/gc-refactor/include/parrot/runcore_profiling.h (from r41301, trunk/include/parrot/runcore_profiling.h)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/gc-refactor/include/parrot/runcore_profiling.h Wed Sep 16 18:24:30 2009 (r41302, copy of r41301, trunk/include/parrot/runcore_profiling.h)
@@ -0,0 +1,106 @@
+/* runcore_api.h
+ * Copyright (C) 2001-2009, Parrot Foundation.
+ * SVN Info
+ * $Id$
+ * Overview:
+ * Functions and macros to dispatch opcodes.
+ */
+
+#ifndef PARROT_RUNCORE_PROFILING_H_GUARD
+#define PARROT_RUNCORE_PROFILING_H_GUARD
+
+struct profiling_runcore_t;
+typedef struct profiling_runcore_t Parrot_profiling_runcore_t;
+
+#include "parrot/parrot.h"
+#include "parrot/op.h"
+#include "parrot/runcore_api.h"
+
+typedef enum Parrot_profiling_flags {
+ PROFILING_EXIT_CHECK_FLAG = 1 << 0,
+ PROFILING_FIRST_LOOP_FLAG = 1 << 1,
+ PROFILING_HAVE_PRINTED_CLI_FLAG = 1 << 2
+} Parrot_profiling_flags;
+
+struct profiling_runcore_t {
+ STRING *name;
+ int id;
+ oplib_init_f opinit;
+ Parrot_runcore_runops_fn_t runops;
+ Parrot_runcore_destroy_fn_t destroy;
+ Parrot_runcore_prepare_fn_t prepare_run;
+ INTVAL flags;
+
+ /* end of common members */
+ UHUGEINTVAL runcore_start;
+ UHUGEINTVAL op_start;
+ UHUGEINTVAL op_finish;
+ UHUGEINTVAL runcore_finish;
+ INTVAL profiling_flags;
+ INTVAL runloop_count;
+ FILE *profile_fd;
+ STRING *profile_filename;
+ PMC *prev_sub;
+ Parrot_Context *prev_ctx;
+ UINTVAL level; /* how many nested runloops */
+ UINTVAL time_size; /* how big is the following array */
+ UHUGEINTVAL *time; /* time spent between DO_OP and start/end of a runcore */
+};
+
+
+#define Profiling_flag_SET(runcore, flag) \
+ ((runcore)->profiling_flags |= flag)
+#define Profiling_flag_TEST(runcore, flag) \
+ ((runcore)->profiling_flags & flag)
+#define Profiling_flag_CLEAR(runcore, flag) \
+ ((runcore)->profiling_flags &= ~(flag))
+
+#define Profiling_exit_check_TEST(o) \
+ Profiling_flag_TEST(o, PROFILING_EXIT_CHECK_FLAG)
+#define Profiling_exit_check_SET(o) \
+ Profiling_flag_SET(o, PROFILING_EXIT_CHECK_FLAG)
+#define Profiling_exit_check_CLEAR(o) \
+ Profiling_flag_CLEAR(o, PROFILING_EXIT_CHECK_FLAG)
+
+#define Profiling_first_loop_TEST(o) \
+ Profiling_flag_TEST(o, PROFILING_FIRST_LOOP_FLAG)
+#define Profiling_first_loop_SET(o) \
+ Profiling_flag_SET(o, PROFILING_FIRST_LOOP_FLAG)
+#define Profiling_first_loop_CLEAR(o) \
+ Profiling_flag_CLEAR(o, PROFILING_FIRST_LOOP_FLAG)
+
+#define Profiling_have_printed_cli_TEST(o) \
+ Profiling_flag_TEST(o, PROFILING_HAVE_PRINTED_CLI_FLAG)
+#define Profiling_have_printed_cli_SET(o) \
+ Profiling_flag_SET(o, PROFILING_HAVE_PRINTED_CLI_FLAG)
+#define Profiling_have_printed_cli_CLEAR(o) \
+ Profiling_flag_CLEAR(o, PROFILING_HAVE_PRINTED_CLI_FLAG)
+
+/* HEADERIZER BEGIN: src/runcore/profiling.c */
+/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
+
+PARROT_CAN_RETURN_NULL
+void * destroy_profiling_core(PARROT_INTERP,
+ ARGIN(Parrot_profiling_runcore_t *runcore))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
+void Parrot_runcore_profiling_init(PARROT_INTERP)
+ __attribute__nonnull__(1);
+
+#define ASSERT_ARGS_destroy_profiling_core __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(interp) \
+ || PARROT_ASSERT_ARG(runcore)
+#define ASSERT_ARGS_Parrot_runcore_profiling_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(interp)
+/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
+/* HEADERIZER END: src/runcore/profiling.c */
+
+#endif /* PARROT_RUNCORE_PROFILING_H_GUARD */
+
+/*
+ * Local variables:
+ * c-file-style: "parrot"
+ * End:
+ * vim: expandtab shiftwidth=4:
+ */
Modified: branches/gc-refactor/include/parrot/string_funcs.h
==============================================================================
--- branches/gc-refactor/include/parrot/string_funcs.h Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/include/parrot/string_funcs.h Wed Sep 16 18:24:30 2009 (r41302)
@@ -523,18 +523,6 @@
__attribute__nonnull__(1);
PARROT_EXPORT
-PARROT_WARN_UNUSED_RESULT
-PARROT_CAN_RETURN_NULL
-const CHARSET * string_rep_compatible(SHIM_INTERP,
- ARGIN(const STRING *a),
- ARGIN(const STRING *b),
- ARGOUT(const ENCODING **e))
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- __attribute__nonnull__(4)
- FUNC_MODIFIES(*e);
-
-PARROT_EXPORT
PARROT_MALLOC
PARROT_CAN_RETURN_NULL
char * string_to_cstring_nullable(SHIM_INTERP,
@@ -725,10 +713,6 @@
#define ASSERT_ARGS_string_primary_encoding_for_representation \
__attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_string_rep_compatible __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(a) \
- || PARROT_ASSERT_ARG(b) \
- || PARROT_ASSERT_ARG(e)
#define ASSERT_ARGS_string_to_cstring_nullable __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
#define ASSERT_ARGS_Parrot_str_from_int_base __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
Modified: branches/gc-refactor/include/parrot/sub.h
==============================================================================
--- branches/gc-refactor/include/parrot/sub.h Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/include/parrot/sub.h Wed Sep 16 18:24:30 2009 (r41302)
@@ -248,6 +248,17 @@
__attribute__nonnull__(2)
__attribute__nonnull__(3);
+PARROT_CANNOT_RETURN_NULL
+STRING * Parrot_Sub_get_filename_from_pc(PARROT_INTERP,
+ ARGIN_NULLOK(PMC *subpmc),
+ ARGIN_NULLOK(opcode_t *pc))
+ __attribute__nonnull__(1);
+
+INTVAL Parrot_Sub_get_line_from_pc(PARROT_INTERP,
+ ARGIN_NULLOK(PMC *subpmc),
+ ARGIN_NULLOK(opcode_t *pc))
+ __attribute__nonnull__(1);
+
#define ASSERT_ARGS_new_ret_continuation_pmc __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_Parrot_Context_get_info __attribute__unused__ int _ASSERT_ARGS_CHECK = \
@@ -288,6 +299,11 @@
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(lex_name) \
|| PARROT_ASSERT_ARG(ctx)
+#define ASSERT_ARGS_Parrot_Sub_get_filename_from_pc \
+ __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_Parrot_Sub_get_line_from_pc __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(interp)
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: src/sub.c */
Modified: branches/gc-refactor/lib/Parrot/Harness/Options.pm
==============================================================================
--- branches/gc-refactor/lib/Parrot/Harness/Options.pm Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/lib/Parrot/Harness/Options.pm Wed Sep 16 18:24:30 2009 (r41302)
@@ -1,4 +1,4 @@
-# Copyright (C) 2006-2008, Parrot Foundation.
+# Copyright (C) 2006-2009, Parrot Foundation.
# $Id$
=head1 NAME
@@ -88,7 +88,7 @@
my ($opts_ref) = @_;
my %remap = (
- 'j' => '-runcore=jit',
+ 'j' => '-runcore=fast',
'g' => '-runcore=cgoto',
'C' => '-runcore=cgp',
'S' => '-runcore=switch',
Modified: branches/gc-refactor/lib/Parrot/Pmc2c/PCCMETHOD.pm
==============================================================================
--- branches/gc-refactor/lib/Parrot/Pmc2c/PCCMETHOD.pm Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/lib/Parrot/Pmc2c/PCCMETHOD.pm Wed Sep 16 18:24:30 2009 (r41302)
@@ -238,7 +238,7 @@
$returns_accessors
END
- my $returns_sig = make_arg_pmc($returns_flags, '_return_sig');
+ my $returns_sig = make_arg_pmc($returns_flags, '_return_sig');
$e->emit( <<"END", __FILE__, __LINE__ + 1 );
/*END GENERATED ACCESSORS */
Copied: branches/gc-refactor/runtime/parrot/library/SQLite3.pir (from r41301, trunk/runtime/parrot/library/SQLite3.pir)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/gc-refactor/runtime/parrot/library/SQLite3.pir Wed Sep 16 18:24:30 2009 (r41302, copy of r41301, trunk/runtime/parrot/library/SQLite3.pir)
@@ -0,0 +1,135 @@
+# Copyright (C) 2008-2009, Parrot Foundation.
+# $Id$
+
+.namespace ['SQLite3']
+
+.const int SQLITE_OK = 0 # Successful result
+# beginning-of-error-codes
+.const int SQLITE_ERROR = 1 # SQL error or missing database
+.const int SQLITE_INTERNAL = 2 # Internal logic error in SQLite
+.const int SQLITE_PERM = 3 # Access permission denied
+.const int SQLITE_ABORT = 4 # Callback routine requested an abort
+.const int SQLITE_BUSY = 5 # The database file is locked
+.const int SQLITE_LOCKED = 6 # A table in the database is locked
+.const int SQLITE_NOMEM = 7 # A malloc() failed
+.const int SQLITE_READONLY = 8 # Attempt to write a readonly database
+.const int SQLITE_INTERRUPT = 9 # Operation terminated by sqlite3_interrupt()
+.const int SQLITE_IOERR = 10 # Some kind of disk I/O error occurred
+.const int SQLITE_CORRUPT = 11 # The database disk image is malformed
+.const int SQLITE_NOTFOUND = 12 # NOT USED. Table or record not found
+.const int SQLITE_FULL = 13 # Insertion failed because database is full
+.const int SQLITE_CANTOPEN = 14 # Unable to open the database file
+.const int SQLITE_PROTOCOL = 15 # NOT USED. Database lock protocol error
+.const int SQLITE_EMPTY = 16 # Database is empty
+.const int SQLITE_SCHEMA = 17 # The database schema changed
+.const int SQLITE_TOOBIG = 18 # String or BLOB exceeds size limit
+.const int SQLITE_CONSTRAINT = 19 # Abort due to constraint violation
+.const int SQLITE_MISMATCH = 20 # Data type mismatch
+.const int SQLITE_MISUSE = 21 # Library used incorrectly
+.const int SQLITE_NOLFS = 22 # Uses OS features not supported on host
+.const int SQLITE_AUTH = 23 # Authorization denied
+.const int SQLITE_FORMAT = 24 # Auxiliary database format error
+.const int SQLITE_RANGE = 25 # 2nd parameter to sqlite3_bind out of range
+.const int SQLITE_NOTADB = 26 # File opened that is not a database file
+.const int SQLITE_ROW = 100 # sqlite3_step() has another row ready
+.const int SQLITE_DONE = 101 # sqlite3_step() has finished executing
+
+.sub '_sqlite_init' :load
+ .local pmc libname
+ .local pmc function
+ .local pmc sqlite_funcs
+
+ libname = loadlib 'libsqlite3'
+ set_global '_sqlite3', libname
+
+ sqlite_funcs = new 'ResizableStringArray'
+ push sqlite_funcs, 'step'
+ push sqlite_funcs, 'ip'
+ push sqlite_funcs, 'finalize'
+ push sqlite_funcs, 'ip'
+ push sqlite_funcs, 'close'
+ push sqlite_funcs, 'ip'
+ push sqlite_funcs, 'errmsg'
+ push sqlite_funcs, 'tp'
+ push sqlite_funcs, 'errcode'
+ push sqlite_funcs, 'ip'
+ push sqlite_funcs, 'bind_int'
+ push sqlite_funcs, 'ipii'
+ push sqlite_funcs, 'bind_double'
+ push sqlite_funcs, 'ipid'
+ push sqlite_funcs, 'bind_text'
+ push sqlite_funcs, 'ipitii'
+ push sqlite_funcs, 'column_name'
+ push sqlite_funcs, 'tpi'
+ push sqlite_funcs, 'column_count'
+ push sqlite_funcs, 'ip'
+ push sqlite_funcs, 'column_type'
+ push sqlite_funcs, 'ipi'
+ push sqlite_funcs, 'column_int'
+ push sqlite_funcs, 'ipi'
+ push sqlite_funcs, 'column_double'
+ push sqlite_funcs, 'lpi'
+ push sqlite_funcs, 'column_text'
+ push sqlite_funcs, 'tpi'
+
+ function = dlfunc libname, 'sqlite3_open', 'itV'
+ set_global 'open_raw', function
+
+ function = dlfunc libname, 'sqlite3_prepare_v2', 'iptiVp'
+ set_global 'prepare_raw', function
+
+ .local pmc list_iter
+ list_iter = iter sqlite_funcs
+ .local string func_name, signature
+ .local pmc function
+
+ list_loop:
+ unless list_iter goto done
+ func_name = shift list_iter
+ signature = shift list_iter
+ $S0 = concat 'sqlite3_', func_name
+ function = dlfunc libname, $S0, signature
+ set_global func_name, function
+ goto list_loop
+
+ done:
+
+.end
+
+.sub 'open'
+ .param string connectstr
+ .local pmc dbhandle
+ .local pmc open_raw
+ .local int rc
+
+ open_raw = get_global 'open_raw'
+ dbhandle = new 'Pointer'
+ rc = open_raw(connectstr, dbhandle)
+
+ .return(dbhandle)
+.end
+
+.sub 'prepare'
+ .param pmc dbhandle
+ .param string psstr
+ .local int psstrlen
+ .local pmc pshandle
+ .local pmc dummy
+ .local pmc prepare_raw
+ .local int rc
+
+ prepare_raw = get_global 'prepare_raw'
+
+ pshandle = new 'Pointer'
+ dummy = new 'Pointer'
+ psstrlen = length psstr
+ rc = prepare_raw(dbhandle, psstr, psstrlen, pshandle, dummy)
+
+ .return(pshandle)
+.end
+
+# Local Variables:
+# mode: pir
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:
Modified: branches/gc-refactor/src/call/context.c
==============================================================================
--- branches/gc-refactor/src/call/context.c Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/call/context.c Wed Sep 16 18:24:30 2009 (r41302)
@@ -16,14 +16,6 @@
#include "parrot/call.h"
#include "../pmc/pmc_sub.h"
-/* set CTX_LEAK_DEBUG_FULL to 1 for enhanced context debugging.
- * When set (1) freed contexts are "poisoned" so that any dangling
- * references produce segfaults, and (2) contexts are not recycled
- * so that later allocations don't suddenly restore a dangling
- * reference to a "working" condition.
- */
-#define CTX_LEAK_DEBUG_FULL 0
-
/*
=head2 Context and register frame layout
@@ -78,6 +70,13 @@
__attribute__nonnull__(2)
FUNC_MODIFIES(*pmcctx);
+PARROT_INLINE
+PARROT_CANNOT_RETURN_NULL
+static Parrot_Context * get_context_struct_fast(PARROT_INTERP,
+ ARGIN(PMC *ctx))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
static void init_context(PARROT_INTERP,
ARGMOD(PMC *pmcctx),
ARGIN_NULLOK(PMC *pmcold))
@@ -88,6 +87,9 @@
#define ASSERT_ARGS_clear_regs __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(pmcctx)
+#define ASSERT_ARGS_get_context_struct_fast __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(interp) \
+ || PARROT_ASSERT_ARG(ctx)
#define ASSERT_ARGS_init_context __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(pmcctx)
@@ -116,7 +118,7 @@
ARGIN_NULLOK(struct PackFile_Constant **constants))
{
ASSERT_ARGS(Parrot_pcc_set_constants)
- Parrot_Context * c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context * c = get_context_struct_fast(interp, ctx);
c->constants = constants;
}
@@ -136,7 +138,7 @@
Parrot_pcc_get_int_constant(PARROT_INTERP, ARGIN(PMC *ctx), INTVAL idx)
{
ASSERT_ARGS(Parrot_pcc_get_int_constant)
- Parrot_Context const * c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context const * c = get_context_struct_fast(interp, ctx);
return c->constants[idx]->u.integer;
}
@@ -157,7 +159,7 @@
Parrot_pcc_get_num_constant(PARROT_INTERP, ARGIN(PMC *ctx), INTVAL idx)
{
ASSERT_ARGS(Parrot_pcc_get_num_constant)
- Parrot_Context const * c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context const * c = get_context_struct_fast(interp, ctx);
return c->constants[idx]->u.number;
}
@@ -178,7 +180,7 @@
Parrot_pcc_get_string_constant(PARROT_INTERP, ARGIN(PMC *ctx), INTVAL idx)
{
ASSERT_ARGS(Parrot_pcc_get_string_constant)
- Parrot_Context const * c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context const * c = get_context_struct_fast(interp, ctx);
return c->constants[idx]->u.string;
}
@@ -199,7 +201,7 @@
Parrot_pcc_get_pmc_constant(PARROT_INTERP, ARGIN(PMC *ctx), INTVAL idx)
{
ASSERT_ARGS(Parrot_pcc_get_pmc_constant)
- Parrot_Context const * c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context const * c = get_context_struct_fast(interp, ctx);
return c->constants[idx]->u.key;
}
@@ -214,13 +216,14 @@
=cut
*/
+
PARROT_EXPORT
PARROT_CANNOT_RETURN_NULL
struct PackFile_Constant **
Parrot_pcc_constants(PARROT_INTERP, ARGIN(PMC *ctx))
{
ASSERT_ARGS(Parrot_pcc_constants)
- return ((Parrot_Context*)(VTABLE_get_pointer(interp, ctx)))->constants;
+ return get_context_struct_fast(interp, ctx)->constants;
}
@@ -234,6 +237,7 @@
=cut
*/
+
PARROT_EXPORT
PARROT_CAN_RETURN_NULL
Parrot_Context*
@@ -263,7 +267,7 @@
Parrot_pcc_get_recursion_depth(PARROT_INTERP, ARGIN(PMC *ctx))
{
ASSERT_ARGS(Parrot_pcc_get_recursion_depth)
- Parrot_Context const *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context const *c = get_context_struct_fast(interp, ctx);
return c->recursion_depth;
}
@@ -282,7 +286,7 @@
Parrot_pcc_inc_recursion_depth(PARROT_INTERP, ARGIN(PMC *ctx))
{
ASSERT_ARGS(Parrot_pcc_inc_recursion_depth)
- Parrot_Context *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context *c = get_context_struct_fast(interp, ctx);
return c->recursion_depth++;
}
@@ -301,7 +305,7 @@
Parrot_pcc_dec_recursion_depth(PARROT_INTERP, ARGIN(PMC *ctx))
{
ASSERT_ARGS(Parrot_pcc_dec_recursion_depth)
- Parrot_Context *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context *c = get_context_struct_fast(interp, ctx);
return --c->recursion_depth;
}
@@ -321,7 +325,7 @@
Parrot_pcc_get_caller_ctx(PARROT_INTERP, ARGIN(PMC *ctx))
{
ASSERT_ARGS(Parrot_pcc_get_caller_ctx)
- Parrot_Context const *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context const *c = get_context_struct_fast(interp, ctx);
return c->caller_ctx;
}
@@ -342,7 +346,7 @@
Parrot_pcc_set_caller_ctx(PARROT_INTERP, ARGIN(PMC *ctx), ARGIN(PMC *caller_ctx))
{
ASSERT_ARGS(Parrot_pcc_set_caller_ctx)
- Parrot_Context *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context *c = get_context_struct_fast(interp, ctx);
c->caller_ctx = caller_ctx;
}
@@ -362,7 +366,7 @@
Parrot_pcc_get_outer_ctx(PARROT_INTERP, ARGIN(PMC *ctx))
{
ASSERT_ARGS(Parrot_pcc_get_outer_ctx)
- Parrot_Context const *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context const *c = get_context_struct_fast(interp, ctx);
return c->outer_ctx;
}
@@ -382,7 +386,7 @@
Parrot_pcc_set_outer_ctx(PARROT_INTERP, ARGIN(PMC *ctx), ARGIN(PMC *outer_ctx))
{
ASSERT_ARGS(Parrot_pcc_set_outer_ctx)
- Parrot_Context *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context *c = get_context_struct_fast(interp, ctx);
c->outer_ctx = outer_ctx;
}
@@ -402,7 +406,7 @@
Parrot_pcc_get_lex_pad(PARROT_INTERP, ARGIN(PMC *ctx))
{
ASSERT_ARGS(Parrot_pcc_get_lex_pad)
- Parrot_Context const *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context const *c = get_context_struct_fast(interp, ctx);
return c->lex_pad;
}
@@ -422,7 +426,7 @@
Parrot_pcc_set_lex_pad(PARROT_INTERP, ARGIN(PMC *ctx), ARGIN(PMC *lex_pad))
{
ASSERT_ARGS(Parrot_pcc_set_lex_pad)
- Parrot_Context *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context *c = get_context_struct_fast(interp, ctx);
c->lex_pad = lex_pad;
}
@@ -442,7 +446,7 @@
Parrot_pcc_get_namespace(PARROT_INTERP, ARGIN(PMC *ctx))
{
ASSERT_ARGS(Parrot_pcc_get_namespace)
- Parrot_Context const *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context const *c = get_context_struct_fast(interp, ctx);
return c->current_namespace;
}
@@ -462,7 +466,7 @@
Parrot_pcc_set_namespace(PARROT_INTERP, ARGIN(PMC *ctx), ARGIN_NULLOK(PMC *_namespace))
{
ASSERT_ARGS(Parrot_pcc_set_namespace)
- Parrot_Context *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context *c = get_context_struct_fast(interp, ctx);
c->current_namespace = _namespace;
}
@@ -481,7 +485,7 @@
Parrot_pcc_get_HLL(PARROT_INTERP, ARGIN(PMC *ctx))
{
ASSERT_ARGS(Parrot_pcc_get_HLL)
- Parrot_Context const *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context const *c = get_context_struct_fast(interp, ctx);
return c->current_HLL;
}
@@ -501,7 +505,7 @@
Parrot_pcc_set_HLL(PARROT_INTERP, ARGIN(PMC *ctx), INTVAL hll)
{
ASSERT_ARGS(Parrot_pcc_set_HLL)
- Parrot_Context *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context *c = get_context_struct_fast(interp, ctx);
c->current_HLL = hll;
}
@@ -521,7 +525,7 @@
Parrot_pcc_get_handlers(PARROT_INTERP, ARGIN(PMC *ctx))
{
ASSERT_ARGS(Parrot_pcc_get_handlers)
- Parrot_Context const *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context const *c = get_context_struct_fast(interp, ctx);
return c->handlers;
}
@@ -541,7 +545,7 @@
Parrot_pcc_set_handers(PARROT_INTERP, ARGIN(PMC *ctx), ARGIN(PMC *handlers))
{
ASSERT_ARGS(Parrot_pcc_set_handers)
- Parrot_Context *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context *c = get_context_struct_fast(interp, ctx);
c->handlers = handlers;
}
@@ -561,7 +565,7 @@
Parrot_pcc_get_continuation(PARROT_INTERP, ARGIN(PMC *ctx))
{
ASSERT_ARGS(Parrot_pcc_get_continuation)
- Parrot_Context const *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context const *c = get_context_struct_fast(interp, ctx);
return c->current_cont;
}
@@ -582,7 +586,7 @@
Parrot_pcc_set_continuation(PARROT_INTERP, ARGIN(PMC *ctx), ARGIN_NULLOK(PMC *_continuation))
{
ASSERT_ARGS(Parrot_pcc_set_continuation)
- Parrot_Context *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context *c = get_context_struct_fast(interp, ctx);
c->current_cont = _continuation;
}
@@ -602,7 +606,7 @@
Parrot_pcc_get_object(PARROT_INTERP, ARGIN(PMC *ctx))
{
ASSERT_ARGS(Parrot_pcc_get_object)
- Parrot_Context const *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context const *c = get_context_struct_fast(interp, ctx);
return c->current_object;
}
@@ -622,7 +626,7 @@
Parrot_pcc_set_object(PARROT_INTERP, ARGIN(PMC *ctx), ARGIN_NULLOK(PMC *object))
{
ASSERT_ARGS(Parrot_pcc_set_object)
- Parrot_Context *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context *c = get_context_struct_fast(interp, ctx);
c->current_object = object;
}
@@ -642,7 +646,7 @@
Parrot_pcc_get_sub(PARROT_INTERP, ARGIN(PMC *ctx))
{
ASSERT_ARGS(Parrot_pcc_get_sub)
- Parrot_Context const *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context const *c = get_context_struct_fast(interp, ctx);
return c->current_sub;
}
@@ -662,8 +666,18 @@
Parrot_pcc_set_sub(PARROT_INTERP, ARGIN(PMC *ctx), ARGIN_NULLOK(PMC *sub))
{
ASSERT_ARGS(Parrot_pcc_set_sub)
- Parrot_Context *c = Parrot_pcc_get_context_struct(interp, ctx);
- c->current_sub = sub;
+ Parrot_Context *c = get_context_struct_fast(interp, ctx);
+ c->current_sub = sub;
+
+ if (sub && !PMC_IS_NULL(sub)) {
+ Parrot_Sub_attributes *subattr;
+
+ PMC_get_sub(interp, sub, subattr);
+
+ c->current_pc = subattr->seg->base.data + subattr->start_offs;
+ c->current_HLL = subattr->HLL_id;
+ c->current_namespace = subattr->namespace_stash;
+ }
}
/*
@@ -682,7 +696,7 @@
Parrot_pcc_get_pc(PARROT_INTERP, ARGIN(PMC *ctx))
{
ASSERT_ARGS(Parrot_pcc_get_pc)
- Parrot_Context const *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context const *c = get_context_struct_fast(interp, ctx);
return c->current_pc;
}
@@ -702,7 +716,7 @@
Parrot_pcc_set_pc(PARROT_INTERP, ARGIN(PMC *ctx), ARGIN_NULLOK(opcode_t *pc))
{
ASSERT_ARGS(Parrot_pcc_set_pc)
- Parrot_Context *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context *c = get_context_struct_fast(interp, ctx);
c->current_pc = pc;
}
@@ -722,7 +736,7 @@
Parrot_pcc_get_results(PARROT_INTERP, ARGIN(PMC *ctx))
{
ASSERT_ARGS(Parrot_pcc_get_results)
- Parrot_Context const *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context const *c = get_context_struct_fast(interp, ctx);
return c->current_results;
}
@@ -742,7 +756,7 @@
Parrot_pcc_set_results(PARROT_INTERP, ARGIN(PMC *ctx), ARGIN_NULLOK(opcode_t *pc))
{
ASSERT_ARGS(Parrot_pcc_set_results)
- Parrot_Context *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context *c = get_context_struct_fast(interp, ctx);
c->current_results = pc;
}
@@ -762,7 +776,7 @@
Parrot_pcc_get_results_signature(PARROT_INTERP, ARGIN(PMC *ctx))
{
ASSERT_ARGS(Parrot_pcc_get_results_signature)
- Parrot_Context const *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context const *c = get_context_struct_fast(interp, ctx);
return c->results_signature;
}
@@ -783,7 +797,7 @@
Parrot_pcc_set_results_signature(PARROT_INTERP, ARGIN(PMC *ctx), ARGIN_NULLOK(PMC *sig))
{
ASSERT_ARGS(Parrot_pcc_set_results_signature)
- Parrot_Context *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context *c = get_context_struct_fast(interp, ctx);
c->results_signature = sig;
}
@@ -803,7 +817,7 @@
Parrot_pcc_get_pred_offset(PARROT_INTERP, ARGIN(PMC *ctx))
{
ASSERT_ARGS(Parrot_pcc_get_pred_offset)
- Parrot_Context const *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context const *c = get_context_struct_fast(interp, ctx);
return c->pred_offset;
}
@@ -824,7 +838,7 @@
Parrot_pcc_set_pred_offset(PARROT_INTERP, ARGIN(PMC *ctx), size_t pred_offset)
{
ASSERT_ARGS(Parrot_pcc_set_pred_offset)
- Parrot_Context *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context *c = get_context_struct_fast(interp, ctx);
c->pred_offset = pred_offset;
}
@@ -844,7 +858,7 @@
Parrot_pcc_warnings_on(PARROT_INTERP, ARGIN(PMC *ctx), UINTVAL flags)
{
ASSERT_ARGS(Parrot_pcc_warnings_on)
- Parrot_Context *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context *c = get_context_struct_fast(interp, ctx);
c->warns |= flags;
return c->warns;
}
@@ -865,7 +879,7 @@
Parrot_pcc_warnings_off(PARROT_INTERP, ARGIN(PMC *ctx), UINTVAL flags)
{
ASSERT_ARGS(Parrot_pcc_warnings_off)
- Parrot_Context *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context *c = get_context_struct_fast(interp, ctx);
c->warns &= ~flags;
}
@@ -886,7 +900,7 @@
Parrot_pcc_warnings_test(PARROT_INTERP, ARGIN(PMC *ctx), UINTVAL flags)
{
ASSERT_ARGS(Parrot_pcc_warnings_test)
- Parrot_Context *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context *c = get_context_struct_fast(interp, ctx);
return c->warns & flags;
}
@@ -905,7 +919,7 @@
Parrot_pcc_errors_on(PARROT_INTERP, ARGIN(PMC *ctx), UINTVAL flags)
{
ASSERT_ARGS(Parrot_pcc_errors_on)
- Parrot_Context *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context *c = get_context_struct_fast(interp, ctx);
c->errors |= flags;
}
@@ -925,7 +939,7 @@
Parrot_pcc_errors_off(PARROT_INTERP, ARGIN(PMC *ctx), UINTVAL flags)
{
ASSERT_ARGS(Parrot_pcc_errors_off)
- Parrot_Context *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context *c = get_context_struct_fast(interp, ctx);
c->errors &= ~flags;
}
@@ -945,7 +959,7 @@
Parrot_pcc_errors_test(PARROT_INTERP, ARGIN(PMC *ctx), UINTVAL flags)
{
ASSERT_ARGS(Parrot_pcc_errors_test)
- Parrot_Context *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context *c = get_context_struct_fast(interp, ctx);
return c->errors & flags;
}
@@ -964,7 +978,7 @@
Parrot_pcc_trace_flags_on(PARROT_INTERP, ARGIN(PMC *ctx), UINTVAL flags)
{
ASSERT_ARGS(Parrot_pcc_trace_flags_on)
- Parrot_Context *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context *c = get_context_struct_fast(interp, ctx);
c->trace_flags |= flags;
}
@@ -984,7 +998,7 @@
Parrot_pcc_trace_flags_off(PARROT_INTERP, ARGIN(PMC *ctx), UINTVAL flags)
{
ASSERT_ARGS(Parrot_pcc_trace_flags_off)
- Parrot_Context *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context *c = get_context_struct_fast(interp, ctx);
c->trace_flags &= ~flags;
}
@@ -1005,7 +1019,7 @@
Parrot_pcc_trace_flags_test(PARROT_INTERP, ARGIN(PMC *ctx), UINTVAL flags)
{
ASSERT_ARGS(Parrot_pcc_trace_flags_test)
- Parrot_Context *c = Parrot_pcc_get_context_struct(interp, ctx);
+ Parrot_Context *c = get_context_struct_fast(interp, ctx);
return c->trace_flags & flags;
}
@@ -1041,6 +1055,32 @@
UNUSED(ignored);
}
+/*
+
+=item C<static Parrot_Context * get_context_struct_fast(PARROT_INTERP, PMC
+*ctx)>
+
+Fetches Parrot_Context from Context PMC. This is a static, inlineable function
+so it only works within this file. It also only works if you *know* that ctx
+is a valid PMC, so be careful. This is an encapsulation-breaking optimization
+that improves performance measurably. Use responsibly. Never export this
+function.
+
+=cut
+
+*/
+
+
+PARROT_INLINE
+PARROT_CANNOT_RETURN_NULL
+static Parrot_Context *
+get_context_struct_fast(PARROT_INTERP, ARGIN(PMC *ctx))
+{
+ ASSERT_ARGS(get_context_struct_fast)
+
+ /* temporarily violate encapsulation; big speedup here */
+ return PMC_data_typed(ctx, Parrot_Context *);
+}
/*
@@ -1059,7 +1099,7 @@
{
ASSERT_ARGS(clear_regs)
UINTVAL i;
- Parrot_Context *ctx = Parrot_pcc_get_context_struct(interp, pmcctx);
+ Parrot_Context *ctx = get_context_struct_fast(interp, pmcctx);
/* NULL out registers - P/S have to be NULL for GC
*
@@ -1101,8 +1141,12 @@
init_context(PARROT_INTERP, ARGMOD(PMC *pmcctx), ARGIN_NULLOK(PMC *pmcold))
{
ASSERT_ARGS(init_context)
- Parrot_Context *ctx = Parrot_pcc_get_context_struct(interp, pmcctx);
- Parrot_Context *old = Parrot_pcc_get_context_struct(interp, pmcold);
+ Parrot_Context *ctx = get_context_struct_fast(interp, pmcctx);
+
+ /* pmcold may be null */
+ Parrot_Context *old = PMC_IS_NULL(pmcold)
+ ? NULL
+ : get_context_struct_fast(interp, pmcold);
ctx->current_results = NULL;
ctx->results_signature = NULL;
@@ -1125,6 +1169,7 @@
ctx->current_namespace = old->current_namespace;
/* end COW */
ctx->recursion_depth = old->recursion_depth;
+ ctx->caller_ctx = pmcold;
}
else {
ctx->constants = NULL;
@@ -1163,8 +1208,6 @@
PMC * const old = CURRENT_CONTEXT(interp);
PMC * const ctx = Parrot_set_new_context(interp, n_regs_used);
- Parrot_pcc_set_caller_ctx(interp, ctx, old);
-
/* doesn't change */
Parrot_pcc_set_sub(interp, ctx, Parrot_pcc_get_sub(interp, old));
@@ -1419,7 +1462,7 @@
{
ASSERT_ARGS(Parrot_pcc_get_INTVAL_reg)
PARROT_ASSERT(Parrot_pcc_get_regs_used(interp, ctx, REGNO_INT) > idx);
- return &(Parrot_pcc_get_context_struct(interp, ctx)->bp.regs_i[idx]);
+ return &(get_context_struct_fast(interp, ctx)->bp.regs_i[idx]);
}
/*
@@ -1440,7 +1483,7 @@
{
ASSERT_ARGS(Parrot_pcc_get_FLOATVAL_reg)
PARROT_ASSERT(Parrot_pcc_get_regs_used(interp, ctx, REGNO_NUM) > idx);
- return &(Parrot_pcc_get_context_struct(interp, ctx)->bp.regs_n[-1L - idx]);
+ return &(get_context_struct_fast(interp, ctx)->bp.regs_n[-1L - idx]);
}
/*
@@ -1461,7 +1504,7 @@
{
ASSERT_ARGS(Parrot_pcc_get_STRING_reg)
PARROT_ASSERT(Parrot_pcc_get_regs_used(interp, ctx, REGNO_STR) > idx);
- return &(Parrot_pcc_get_context_struct(interp, ctx)->bp_ps.regs_s[idx]);
+ return &(get_context_struct_fast(interp, ctx)->bp_ps.regs_s[idx]);
}
/*
@@ -1481,7 +1524,7 @@
{
ASSERT_ARGS(Parrot_pcc_get_PMC_reg)
PARROT_ASSERT(Parrot_pcc_get_regs_used(interp, ctx, REGNO_PMC) > idx);
- return &(Parrot_pcc_get_context_struct(interp, ctx)->bp_ps.regs_p[-1L - idx]);
+ return &(get_context_struct_fast(interp, ctx)->bp_ps.regs_p[-1L - idx]);
}
/*
@@ -1498,7 +1541,7 @@
Parrot_pcc_get_regs_used(PARROT_INTERP, ARGIN(PMC *ctx), int type)
{
ASSERT_ARGS(Parrot_pcc_get_regs_used)
- return Parrot_pcc_get_context_struct(interp, ctx)->n_regs_used[type];
+ return get_context_struct_fast(interp, ctx)->n_regs_used[type];
}
/*
@@ -1516,7 +1559,7 @@
Parrot_pcc_set_regs_used(PARROT_INTERP, ARGIN(PMC *ctx), int type, INTVAL num)
{
ASSERT_ARGS(Parrot_pcc_set_regs_used)
- Parrot_pcc_get_context_struct(interp, ctx)->n_regs_used[type] = num;
+ get_context_struct_fast(interp, ctx)->n_regs_used[type] = num;
}
/*
@@ -1534,7 +1577,7 @@
Parrot_pcc_get_regs_ni(PARROT_INTERP, ARGIN(PMC *ctx))
{
ASSERT_ARGS(Parrot_pcc_get_regs_ni)
- return &(Parrot_pcc_get_context_struct(interp, ctx)->bp);
+ return &(get_context_struct_fast(interp, ctx)->bp);
}
/*
@@ -1552,7 +1595,7 @@
Parrot_pcc_set_regs_ni(PARROT_INTERP, ARGIN(PMC *ctx), ARGIN(Regs_ni *bp))
{
ASSERT_ARGS(Parrot_pcc_set_regs_ni)
- Parrot_pcc_get_context_struct(interp, ctx)->bp = *bp;
+ get_context_struct_fast(interp, ctx)->bp = *bp;
}
/*
@@ -1570,7 +1613,7 @@
Parrot_pcc_get_regs_ps(PARROT_INTERP, ARGIN(PMC *ctx))
{
ASSERT_ARGS(Parrot_pcc_get_regs_ps)
- return &(Parrot_pcc_get_context_struct(interp, ctx)->bp_ps);
+ return &(get_context_struct_fast(interp, ctx)->bp_ps);
}
/*
@@ -1588,7 +1631,7 @@
Parrot_pcc_set_regs_ps(PARROT_INTERP, ARGIN(PMC *ctx), ARGIN(Regs_ps *bp_ps))
{
ASSERT_ARGS(Parrot_pcc_set_regs_ps)
- Parrot_pcc_get_context_struct(interp, ctx)->bp_ps = *bp_ps;
+ get_context_struct_fast(interp, ctx)->bp_ps = *bp_ps;
}
Modified: branches/gc-refactor/src/call/ops.c
==============================================================================
--- branches/gc-refactor/src/call/ops.c Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/call/ops.c Wed Sep 16 18:24:30 2009 (r41302)
@@ -338,7 +338,7 @@
ctx = runops_args(interp, sub, PMCNULL, NULL, sig, args);
va_end(args);
retval = (PMC *)set_retval(interp, *sig, ctx);
- return retval;
+ return retval ? retval : PMCNULL;
}
/*
Modified: branches/gc-refactor/src/call/pcc.c
==============================================================================
--- branches/gc-refactor/src/call/pcc.c Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/call/pcc.c Wed Sep 16 18:24:30 2009 (r41302)
@@ -342,12 +342,12 @@
/*
-=item C<PMC* Parrot_pcc_build_sig_object_from_varargs(PARROT_INTERP, PMC* obj,
+=item C<PMC* Parrot_pcc_build_sig_object_from_varargs(PARROT_INTERP, PMC *obj,
const char *sig, va_list args)>
-Take a varargs list, and convert it into a CallSignature PMC. The CallSignature
-stores the original short signature string, and an array of integer types to
-pass on to the multiple dispatch search.
+Converts a varargs list into a CallSignature PMC. The CallSignature stores the
+original short signature string and an array of integer types to pass on to the
+multiple dispatch search.
=cut
@@ -357,7 +357,7 @@
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
PMC*
-Parrot_pcc_build_sig_object_from_varargs(PARROT_INTERP, ARGIN_NULLOK(PMC* obj),
+Parrot_pcc_build_sig_object_from_varargs(PARROT_INTERP, ARGIN_NULLOK(PMC *obj),
ARGIN(const char *sig), va_list args)
{
ASSERT_ARGS(Parrot_pcc_build_sig_object_from_varargs)
@@ -366,7 +366,7 @@
PMC * const call_object = pmc_new(interp, enum_class_CallSignature);
STRING *string_sig = Parrot_str_new_constant(interp, sig);
const INTVAL sig_len = Parrot_str_byte_length(interp, string_sig);
- INTVAL in_return_sig = 0;
+ INTVAL in_return_sig = 0;
INTVAL i;
if (!sig_len)
@@ -386,7 +386,7 @@
if (in_return_sig) {
STRING * const signature = CONST_STRING(interp, "signature");
- /* Returns store the original passed-in pointer, so they can pass
+ /* Returns store the original passed-in pointer so they can pass
* the result back to the caller. */
PMC * const val_pointer = pmc_new(interp, enum_class_CPointer);
VTABLE_push_pmc(interp, returns, val_pointer);
@@ -427,11 +427,8 @@
VTABLE_push_string(interp, call_object, va_arg(args, STRING *));
break;
case 'P':
- {
- PMC * const pmc_arg = va_arg(args, PMC *);
- VTABLE_push_pmc(interp, call_object, pmc_arg);
+ VTABLE_push_pmc(interp, call_object, va_arg(args, PMC *));
break;
- }
case '-':
i++; /* skip '>' */
in_return_sig = 1;
@@ -458,6 +455,7 @@
return call_object;
}
+
/*
=item C<void Parrot_init_arg_nci(PARROT_INTERP, call_state *st, const char
@@ -479,8 +477,8 @@
init_call_stats(st);
if (PMC_IS_NULL(interp->args_signature))
- Parrot_init_arg_op(interp, CURRENT_CONTEXT(interp), interp->current_args,
- &st->src);
+ Parrot_init_arg_op(interp, CURRENT_CONTEXT(interp),
+ interp->current_args, &st->src);
else
Parrot_init_arg_indexes_and_sig_pmc(interp, CURRENT_CONTEXT(interp),
interp->current_args, interp->args_signature, &st->src);
@@ -509,7 +507,7 @@
PMC *ctx = CURRENT_CONTEXT(interp);
PMC * const current_cont = Parrot_pcc_get_continuation(interp, ctx);
- /* if this NCI call was a taicall, return results to caller's get_results
+ /* if this NCI call was a tailcall, return results to caller's get_results
* this also means that we pass the caller's register base pointer */
if (SUB_FLAG_TAILCALL_ISSET(current_cont))
ctx = PARROT_CONTINUATION(current_cont)->to_ctx;
@@ -604,6 +602,8 @@
PMC *sig_pmc = PMCNULL;
if (pc) {
+ if (*pc == 0)
+ return 0;
++pc;
sig_pmc = Parrot_pcc_get_pmc_constant(interp, ctx, *pc);
ASSERT_SIG_PMC(sig_pmc);
@@ -673,8 +673,8 @@
/* src ought to be an hash */
if (!VTABLE_does(interp, p_arg, CONST_STRING(interp, "hash")))
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
- "argument doesn't hash");
+ Parrot_ex_throw_from_c_args(interp, NULL,
+ EXCEPTION_INVALID_OPERATION, "argument doesn't hash");
/* create key needed to iterate the hash */
st->key = pmc_new(interp, enum_class_Key);
@@ -684,8 +684,8 @@
else {
/* src ought to be an array */
if (!VTABLE_does(interp, p_arg, CONST_STRING(interp, "array")))
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
- "argument doesn't array");
+ Parrot_ex_throw_from_c_args(interp, NULL,
+ EXCEPTION_INVALID_OPERATION, "argument doesn't array");
}
st->src.mode |= CALL_STATE_FLATTEN;
@@ -772,9 +772,8 @@
case PARROT_ARG_PMC:
if (st->src.u.sig.sig[st->src.i] == 'O')
UVal_pmc(st->val) = Parrot_pcc_get_object(interp, CURRENT_CONTEXT(interp));
- else {
+ else
UVal_pmc(st->val) = va_arg(*ap, PMC *);
- }
if (st->src.sig & PARROT_ARG_FLATTEN) {
int retval;
@@ -827,19 +826,21 @@
/* ensure that callees don't modify constant caller strings */
if (constant)
UVal_str(st->val) = Parrot_str_new_COW(interp,
- Parrot_pcc_get_string_constant(interp, st->src.ctx, idx));
+ Parrot_pcc_get_string_constant(interp, st->src.ctx, idx));
else
UVal_str(st->val) = CTX_REG_STR(st->src.ctx, idx);
break;
}
case PARROT_ARG_FLOATVAL:
- UVal_num(st->val) = constant ? Parrot_pcc_get_num_constant(interp, st->src.ctx, idx)
- : CTX_REG_NUM(st->src.ctx, idx);
+ UVal_num(st->val) = constant
+ ? Parrot_pcc_get_num_constant(interp, st->src.ctx, idx)
+ : CTX_REG_NUM(st->src.ctx, idx);
break;
case PARROT_ARG_PMC:
- UVal_pmc(st->val) = constant ? Parrot_pcc_get_pmc_constant(interp, st->src.ctx, idx)
- : CTX_REG_PMC(st->src.ctx, idx);
+ UVal_pmc(st->val) = constant
+ ? Parrot_pcc_get_pmc_constant(interp, st->src.ctx, idx)
+ : CTX_REG_PMC(st->src.ctx, idx);
if (st->src.sig & PARROT_ARG_FLATTEN) {
int retval;
@@ -939,7 +940,8 @@
case CALL_STATE_SIG:
return fetch_arg_sig(interp, st);
default:
- Parrot_ex_throw_from_c_args(interp, NULL, 1, "invalid call state mode");
+ Parrot_ex_throw_from_c_args(interp, NULL, 1,
+ "invalid call state mode");
}
}
@@ -988,6 +990,7 @@
return 1;
}
+
/*
=item C<static void convert_arg_from_int(PARROT_INTERP, call_state *st)>
@@ -1023,6 +1026,7 @@
}
}
+
/*
=item C<static void convert_arg_from_num(PARROT_INTERP, call_state *st)>
@@ -1094,6 +1098,7 @@
}
}
+
/*
=item C<static void convert_arg_from_pmc(PARROT_INTERP, call_state *st)>
@@ -1265,8 +1270,7 @@
else if (sig & PARROT_ARG_SLURPY_ARRAY) {
int idx;
- /* Create PMC for slurpy mode and register it; we must do this
- * otherwise it may get collected. */
+ /* Create PMC for slurpy mode */
st->dest.slurp = pmc_new(interp,
Parrot_get_ctx_HLL_type(interp, enum_class_Hash));
@@ -1321,8 +1325,8 @@
n_named++;
idx = st->dest.u.op.pc[i];
param = PARROT_ARG_CONSTANT_ISSET(st->dest.sig)
- ? Parrot_pcc_get_string_constant(interp, st->dest.ctx, idx)
- : CTX_REG_STR(st->dest.ctx, idx);
+ ? Parrot_pcc_get_string_constant(interp, st->dest.ctx, idx)
+ : CTX_REG_STR(st->dest.ctx, idx);
if (st->name == param || Parrot_str_equal(interp, st->name, param)) {
++i;
@@ -1500,11 +1504,11 @@
A named arg takes the form of
- STRING* name, [INPS] actual_arg,
+ STRING *name, [INPS] actual_arg,
or
- STRING* name, [INPS] actual_arg, int opt_arg_flag
+ STRING *name, [INPS] actual_arg, int opt_arg_flag
=cut
@@ -1521,30 +1525,31 @@
/* verify that a name exists */
const INTVAL sig = st->dest.sig =
VTABLE_get_integer_keyed_int(interp, st->dest.u.op.signature, i);
+
if (sig & PARROT_ARG_NAME) {
+ int last_name_pos = i;
INTVAL arg_sig;
- int last_name_pos;
/* if slurpy then no errors, return */
if (sig & PARROT_ARG_SLURPY_ARRAY)
return;
n_named++;
- last_name_pos = i;
/* move on to the actual arg */
i++;
/* verify that an actual arg exists */
arg_sig = st->dest.sig = VTABLE_get_integer_keyed_int(interp,
- st->dest.u.op.signature, i);
+ st->dest.u.op.signature, i);
PARROT_ASSERT(!(arg_sig & PARROT_ARG_NAME));
/* if this named arg is already filled, continue */
if (st->named_done & (1 << n_named)) {
if (i + 1 < st->dest.n) {
- arg_sig = st->dest.sig = VTABLE_get_integer_keyed_int(interp,
- st->dest.u.op.signature, i + 1);
+ arg_sig = st->dest.sig
+ = VTABLE_get_integer_keyed_int(interp,
+ st->dest.u.op.signature, i + 1);
/* skip associated opt flag arg as well */
if (arg_sig & PARROT_ARG_OPT_FLAG)
@@ -1562,8 +1567,10 @@
/* Don't walk off the end of the array */
if (i+1 >= st->dest.n)
continue;
+
arg_sig = st->dest.sig = VTABLE_get_integer_keyed_int(interp,
- st->dest.u.op.signature, i+1);
+ st->dest.u.op.signature, i + 1);
+
if (arg_sig & PARROT_ARG_OPT_FLAG) {
i++;
idx = st->dest.u.op.pc[i];
@@ -1584,7 +1591,8 @@
}
}
else
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
+ Parrot_ex_throw_from_c_args(interp, NULL,
+ EXCEPTION_INVALID_OPERATION,
"invalid arg type in named portion of args");
}
}
@@ -1604,6 +1612,7 @@
init_call_stats(ARGMOD(call_state *st))
{
ASSERT_ARGS(init_call_stats)
+
/* initial guess, adjusted for :flat args */
st->n_actual_args = st->src.n;
@@ -1789,7 +1798,8 @@
st->src.i - n_named);
if (!locate_named_named(interp, st))
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
+ Parrot_ex_throw_from_c_args(interp, NULL,
+ EXCEPTION_INVALID_OPERATION,
"too many named arguments - '%Ss' not expected", st->name);
n_named++;
@@ -1799,7 +1809,8 @@
/* Convert to a PMC to store in the hash */
dest->sig |= PARROT_ARG_PMC;
Parrot_convert_arg(interp, st);
- VTABLE_set_pmc_keyed_str(interp, dest->slurp, st->name, UVal_pmc(st->val));
+ VTABLE_set_pmc_keyed_str(interp, dest->slurp, st->name,
+ UVal_pmc(st->val));
}
else {
Parrot_convert_arg(interp, st);
@@ -1834,6 +1845,7 @@
Parrot_convert_arg(PARROT_INTERP, ARGMOD(call_state *st))
{
ASSERT_ARGS(Parrot_convert_arg)
+
/* register key args have to be cloned */
if ((st->src.sig & PARROT_ARG_TYPE_MASK) == PARROT_ARG_PMC)
clone_key_arg(interp, st);
@@ -1863,7 +1875,7 @@
Prelims: code segments aren't yet switched, so the current constants are still
that of the caller. The destination context is already created and set,
-C<src_ctx> point to the caller's context. C<dst_seg> has the constants of the
+C<src_ctx> points to the caller's context. C<dst_seg> has the constants of the
destination.
C<what> is either C<PARROT_OP_get_params_pc> or C<PARROT_OP_get_results_pc>.
@@ -1878,12 +1890,13 @@
void
parrot_pass_args(PARROT_INTERP,
ARGMOD(PMC *src_ctx), ARGMOD(PMC *dest_ctx),
- ARGMOD_NULLOK(opcode_t *src_indexes), ARGMOD_NULLOK(opcode_t *dest_indexes),
+ ARGMOD_NULLOK(opcode_t *src_indexes),
+ ARGMOD_NULLOK(opcode_t *dest_indexes),
arg_pass_t param_or_result)
{
ASSERT_ARGS(parrot_pass_args)
- call_state st;
PMC *src_signature, *dest_signature;
+ call_state st;
if (param_or_result == PARROT_PASS_PARAMS) {
src_signature = interp->args_signature;
@@ -1907,9 +1920,6 @@
dest_signature, &st.dest);
Parrot_process_args(interp, &st, param_or_result);
-
- /* If we created a slurpy, we had to GC register it so it did not get
- * collected during arg processing; we'll now unregister it. */
}
@@ -2167,7 +2177,8 @@
case PARROT_ARG_PMC :
reg_offset = n_regs_used[seen_arrow * 4 + REGNO_PMC]++; break;
default:
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
+ Parrot_ex_throw_from_c_args(interp, NULL,
+ EXCEPTION_INVALID_OPERATION,
"Parrot_PCCINVOKE: invalid reg type");
}
@@ -2197,6 +2208,7 @@
}
}
+
/*
=item C<static PMC * count_signature_elements(PARROT_INTERP, const char
@@ -2218,7 +2230,6 @@
{
ASSERT_ARGS(count_signature_elements)
const char *x;
- unsigned int seen_arrow = 0;
/*Count of number of each type of arg and result, INSP->INSP */
int max_regs[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
@@ -2230,8 +2241,9 @@
/* # of args, # of results */
int arg_ret_cnt[2] = { 0, 0 };
- /* Increment these values if we are not calling from a CallSignature
- PMC */
+ unsigned int seen_arrow = 0;
+
+ /* Increment these values if we are not calling from a CallSignature PMC */
if (flag) {
arg_ret_cnt[seen_arrow]++;
max_regs[REGNO_PMC]++;
@@ -2308,6 +2320,7 @@
return Parrot_push_context(interp, n_regs_used);
}
+
/*
=item C<static void commit_last_arg_sig_object(PARROT_INTERP, int index, int
@@ -2347,17 +2360,17 @@
}
else {
Parrot_ex_throw_from_c_args(interp, NULL,
- EXCEPTION_INVALID_OPERATION,
- "Parrot_pcc_invoke: Only the first parameter can be an invocant %d, %d",
- seen_arrow, index);
+ EXCEPTION_INVALID_OPERATION,
+ "Parrot_pcc_invoke: Only the first parameter can be "
+ "an invocant %d, %d", seen_arrow, index);
}
}
- else {
+ else
reg_offset = n_regs_used[seen_arrow * 4 + REGNO_PMC]++;
- }
break;
default:
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
+ Parrot_ex_throw_from_c_args(interp, NULL,
+ EXCEPTION_INVALID_OPERATION,
"Parrot_PCCINVOKE: invalid reg type");
}
@@ -2372,19 +2385,23 @@
if (!seen_arrow) {
switch (cur & PARROT_ARG_TYPE_MASK) {
case PARROT_ARG_INTVAL:
- CTX_REG_INT(ctx, reg_offset) = VTABLE_get_integer_keyed_int(interp, sig_obj, index);
+ CTX_REG_INT(ctx, reg_offset) =
+ VTABLE_get_integer_keyed_int(interp, sig_obj, index);
break;
case PARROT_ARG_FLOATVAL:
- CTX_REG_NUM(ctx, reg_offset) = VTABLE_get_number_keyed_int(interp, sig_obj, index);
+ CTX_REG_NUM(ctx, reg_offset) =
+ VTABLE_get_number_keyed_int(interp, sig_obj, index);
break;
case PARROT_ARG_STRING:
- CTX_REG_STR(ctx, reg_offset) = VTABLE_get_string_keyed_int(interp, sig_obj, index);
+ CTX_REG_STR(ctx, reg_offset) =
+ VTABLE_get_string_keyed_int(interp, sig_obj, index);
break;
case PARROT_ARG_PMC:
- CTX_REG_PMC(ctx, reg_offset) = VTABLE_get_pmc_keyed_int(interp, sig_obj, index);
- if (cur & PARROT_ARG_INVOCANT) {
+ CTX_REG_PMC(ctx, reg_offset) =
+ VTABLE_get_pmc_keyed_int(interp, sig_obj, index);
+
+ if (cur & PARROT_ARG_INVOCANT)
interp->current_object = CTX_REG_PMC(ctx, reg_offset);
- }
break;
default:
Parrot_ex_throw_from_c_args(interp, NULL,
@@ -2394,13 +2411,15 @@
}
}
+
/*
=item C<static void set_context_sig_returns(PARROT_INTERP, PMC *ctx, opcode_t
**indexes, const char *ret_x, PMC *result_list)>
Sets the subroutine return arguments in the context C<ctx>. Takes a C string
-for the return signature C<ret_x> and a list of return parameters C<result_list>.
+for the return signature C<ret_x> and a list of return parameters
+C<result_list>.
=cut
@@ -2420,41 +2439,36 @@
/* result_accessors perform the arg accessor function,
* assigning the corresponding registers to the result variables */
for (x = ret_x; x && *x; x++) {
- PMC * const result_item = VTABLE_get_pmc_keyed_int(interp, result_list, index);
+ PMC * const result_item =
+ VTABLE_get_pmc_keyed_int(interp, result_list, index);
+
if (isupper((unsigned char)*x)) {
switch (*x) {
case 'I':
- {
VTABLE_set_integer_native(interp, result_item,
CTX_REG_INT(ctx, indexes[seen_arrow][index]));
- }
break;
case 'N':
- {
VTABLE_set_number_native(interp, result_item,
CTX_REG_NUM(ctx, indexes[seen_arrow][index]));
- }
break;
case 'S':
- {
VTABLE_set_string_native(interp, result_item,
CTX_REG_STR(ctx, indexes[seen_arrow][index]));
- }
break;
case 'P':
- {
VTABLE_set_pmc(interp, result_item,
CTX_REG_PMC(ctx, indexes[seen_arrow][index]));
- }
break;
default:
Parrot_ex_throw_from_c_args(interp, NULL,
EXCEPTION_INVALID_OPERATION,
- "Parrot_pcc_invoke_from_sig_object: invalid reg type %c!", *x);
+ "Parrot_pcc_invoke_from_sig_object: "
+ "invalid reg type %c!", *x);
}
/* invalidate the CPointer's pointers so that GC doesn't try to
- * mark stack values -- RT #59880*/
+ * mark stack values -- RT #59880 */
VTABLE_set_string_keyed_str(interp, result_item,
empty_string, empty_string);
}
@@ -2463,13 +2477,15 @@
Parrot_pop_context(interp);
}
+
/*
=item C<static void set_context_sig_returns_varargs(PARROT_INTERP, PMC *ctx,
opcode_t **indexes, const char *ret_x, va_list returns)>
Sets the subroutine return arguments in the context C<ctx>. Takes a C string
-for the return signature C<ret_x> and a varargs list of return parameters C<returns>.
+for the return signature C<ret_x> and a varargs list of return parameters
+C<returns>.
To unify this function with C<set_context_sig_returns>, C<Parrot_PCCINVOKE>
needs to be changed to convert the va_list of input arguments into a signature
@@ -2485,9 +2501,9 @@
ARGMOD(opcode_t **indexes), ARGIN(const char *ret_x), va_list returns)
{
ASSERT_ARGS(set_context_sig_returns_varargs)
- unsigned int index = 0;
+ const char *x;
+ unsigned int index = 0;
unsigned int seen_arrow = 1;
- const char *x;
/* result_accessors perform the arg accessor function,
* assigning the corresponding registers to the result variables */
@@ -2496,25 +2512,25 @@
switch (*x) {
case 'I':
{
- INTVAL * const tmpINTVAL = va_arg(returns, INTVAL*);
+ INTVAL * const tmpINTVAL = va_arg(returns, INTVAL *);
*tmpINTVAL = CTX_REG_INT(ctx, indexes[seen_arrow][index]);
}
break;
case 'N':
{
- FLOATVAL * const tmpFLOATVAL = va_arg(returns, FLOATVAL*);
+ FLOATVAL * const tmpFLOATVAL = va_arg(returns, FLOATVAL *);
*tmpFLOATVAL = CTX_REG_NUM(ctx, indexes[seen_arrow][index]);
}
break;
case 'S':
{
- STRING ** const tmpSTRING = va_arg(returns, STRING**);
+ STRING ** const tmpSTRING = va_arg(returns, STRING **);
*tmpSTRING = CTX_REG_STR(ctx, indexes[seen_arrow][index]);
}
break;
case 'P':
{
- PMC ** const tmpPMC = va_arg(returns, PMC**);
+ PMC ** const tmpPMC = va_arg(returns, PMC **);
*tmpPMC = CTX_REG_PMC(ctx, indexes[seen_arrow][index]);
}
break;
@@ -2525,21 +2541,23 @@
}
}
}
+
Parrot_pop_context(interp);
}
+
/*
=item C<static const char * set_context_sig_params(PARROT_INTERP, const char
*signature, INTVAL *n_regs_used, PMC **sigs, opcode_t **indexes, PMC *ctx, PMC
*sig_obj)>
-Sets the subroutine arguments in the C<ctx> context, according to the
-signature string C<signature>. Currently this function is only called
-from C<Parrot_pcc_invoke_from_sig_object>, but eventually when
-things are unified enough it should be called from C<Parrot_PCCINVOKE>
-as well. The only difference currently between the two implementations
-are the calls to C<commit_last_arg_sig_object> and C<commit_last_arg>.
+Sets the subroutine arguments in the C<ctx> context, according to the signature
+string C<signature>. Currently this function is only called from
+C<Parrot_pcc_invoke_from_sig_object>, but eventually when things are unified
+enough it should be called from C<Parrot_PCCINVOKE> as well. The only
+difference currently between the two implementations are the calls to
+C<commit_last_arg_sig_object> and C<commit_last_arg>.
=cut
@@ -2553,14 +2571,15 @@
ARGMOD(PMC *sig_obj))
{
ASSERT_ARGS(set_context_sig_params)
- /* second loop through signature to build all index and arg_flag
- * loop also assigns args(up to the ->) to registers */
- int index = -1;
- int seen_arrow = 0;
- int cur = 0;
- const char *ret_x = 0;
+
const char *x;
+ const char *ret_x = 0;
+ int index = -1;
+ int seen_arrow = 0;
+ int cur = 0;
+ /* second loop through signature to build all index and arg_flag
+ * loop also assigns args(up to the ->) to registers */
for (x = signature; *x != '\0'; x++) {
/* detect -> separator */
if (*x == '-') {
@@ -2592,8 +2611,8 @@
/* parse arg type */
else if (isupper((unsigned char)*x)) {
if (index >= 0)
- commit_last_arg_sig_object(interp, index, cur, n_regs_used, seen_arrow,
- sigs, indexes, ctx, sig_obj);
+ commit_last_arg_sig_object(interp, index, cur, n_regs_used,
+ seen_arrow, sigs, indexes, ctx, sig_obj);
index++;
@@ -2603,11 +2622,11 @@
case 'S': cur = PARROT_ARG_STRING; break;
case 'P': cur = PARROT_ARG_PMC; break;
default:
- Parrot_ex_throw_from_c_args(interp, NULL,
- EXCEPTION_INVALID_OPERATION,
- "Parrot_pcc_invoke_from_sig_object: invalid reg type %c!", *x);
+ Parrot_ex_throw_from_c_args(interp, NULL,
+ EXCEPTION_INVALID_OPERATION,
+ "Parrot_pcc_invoke_from_sig_object: "
+ "invalid reg type %c!", *x);
}
-
}
/* parse arg adverbs */
else if (islower((unsigned char)*x)) {
@@ -2622,22 +2641,26 @@
default:
Parrot_ex_throw_from_c_args(interp, NULL,
EXCEPTION_INVALID_OPERATION,
- "Parrot_pcc_invoke_from_sig_object: invalid adverb type %c!", *x);
+ "Parrot_pcc_invoke_from_sig_object: "
+ "invalid adverb type %c!", *x);
}
}
}
if (index >= 0)
- commit_last_arg_sig_object(interp, index, cur, n_regs_used, seen_arrow, sigs,
- indexes, ctx, sig_obj);
+ commit_last_arg_sig_object(interp, index, cur, n_regs_used,
+ seen_arrow, sigs, indexes, ctx, sig_obj);
interp->current_args = indexes[0];
interp->args_signature = sigs[0];
+
Parrot_pcc_set_results(interp, ctx, indexes[1]);
Parrot_pcc_set_results_signature(interp, ctx, sigs[1]);
+
return ret_x;
}
+
/*
=item C<void Parrot_pcc_invoke_sub_from_c_args(PARROT_INTERP, PMC *sub_obj,
@@ -2657,15 +2680,18 @@
ARGIN(const char *sig), ...)
{
ASSERT_ARGS(Parrot_pcc_invoke_sub_from_c_args)
- PMC *sig_obj;
+ PMC *sig_obj;
va_list args;
+
va_start(args, sig);
- sig_obj = Parrot_pcc_build_sig_object_from_varargs(interp, PMCNULL, sig, args);
+ sig_obj = Parrot_pcc_build_sig_object_from_varargs(interp, PMCNULL,
+ sig, args);
va_end(args);
Parrot_pcc_invoke_from_sig_object(interp, sub_obj, sig_obj);
}
+
/*
=item C<void Parrot_PCCINVOKE(PARROT_INTERP, PMC* pmc, STRING *method_name,
@@ -2886,8 +2912,6 @@
VTABLE_invoke(interp, pccinvoke_meth, NULL);
set_context_sig_returns_varargs(interp, ctx, indexes, ret_x, list);
- PObj_live_CLEAR(args_sig);
- PObj_live_CLEAR(results_sig);
interp->current_args = save_current_args;
interp->args_signature = save_args_signature;
interp->current_object = save_current_object;
@@ -2899,13 +2923,12 @@
=item C<void Parrot_pcc_invoke_method_from_c_args(PARROT_INTERP, PMC* pmc,
STRING *method_name, const char *signature, ...)>
-Makes a method call given the name of the method and the arguments as a
-C variadic argument list. C<pmc> is the invocant, C<method_name> is the
-string name of the method, C<signature> is a C string describing the
-signature of the invocation, according to the Parrot calling
-conventions. The variadic argument list contains the input arguments
-followed by the output results in the same order that they appear in the
-function signature.
+Makes a method call given the name of the method and the arguments as a C
+variadic argument list. C<pmc> is the invocant, C<method_name> is the string
+name of the method, C<signature> is a C string describing the signature of the
+invocation, according to the Parrot calling conventions. The variadic argument
+list contains the input arguments followed by the output results in the same
+order that they appear in the function signature.
=cut
@@ -2918,15 +2941,18 @@
ARGIN(const char *signature), ...)
{
ASSERT_ARGS(Parrot_pcc_invoke_method_from_c_args)
- PMC *sig_obj;
- PMC *sub_obj;
+ PMC *sig_obj;
+ PMC *sub_obj;
va_list args;
+
va_start(args, signature);
- sig_obj = Parrot_pcc_build_sig_object_from_varargs(interp, pmc, signature, args);
+ sig_obj = Parrot_pcc_build_sig_object_from_varargs(interp, pmc,
+ signature, args);
va_end(args);
/* Find the subroutine object as a named method on pmc */
sub_obj = VTABLE_find_method(interp, pmc, method_name);
+
if (PMC_IS_NULL(sub_obj))
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_METHOD_NOT_FOUND,
"Method '%Ss' not found", method_name);
@@ -2937,6 +2963,7 @@
}
+
/*
=item C<void Parrot_pcc_invoke_from_sig_object(PARROT_INTERP, PMC *sub_obj, PMC
@@ -2967,9 +2994,12 @@
/* create the signature string, and the various PMCs that are needed to
store all the parameters and parameter counts. */
- char * const signature = Parrot_str_to_cstring(interp, VTABLE_get_string(interp, sig_obj));
- PMC * const args_sig = temporary_pmc_new(interp, enum_class_FixedIntegerArray);
- PMC * const results_sig = temporary_pmc_new(interp, enum_class_FixedIntegerArray);
+ char * const signature = Parrot_str_to_cstring(interp,
+ VTABLE_get_string(interp, sig_obj));
+ PMC * const args_sig = temporary_pmc_new(interp,
+ enum_class_FixedIntegerArray);
+ PMC * const results_sig = temporary_pmc_new(interp,
+ enum_class_FixedIntegerArray);
PMC * const ret_cont = new_ret_continuation_pmc(interp, NULL);
PMC * const result_list = VTABLE_get_attr_str(interp, sig_obj, CONST_STRING(interp, "returns"));
@@ -3011,12 +3041,11 @@
sigs, indexes, ctx, sig_obj);
/* Set up the context object for the function invokation */
- if (strncmp(signature, "Pi", 2) == 0) {
+ if (strncmp(signature, "Pi", 2) == 0)
interp->current_object = VTABLE_get_pmc_keyed_int(interp, sig_obj, 0);
- }
- else {
+ else
interp->current_object = PMCNULL;
- }
+
interp->current_cont = NEED_CONTINUATION;
Parrot_pcc_set_continuation(interp, ctx, ret_cont);
PMC_cont(ret_cont)->from_ctx = ctx;
Modified: branches/gc-refactor/src/dynext.c
==============================================================================
--- branches/gc-refactor/src/dynext.c Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/dynext.c Wed Sep 16 18:24:30 2009 (r41302)
@@ -564,7 +564,7 @@
VTABLE_getprop(s, lib_pmc, filename));
STRING * const lib_name = clone_string_into(d, s,
VTABLE_getprop(s, lib_pmc, libname));
- void * const handle = PMC_data(lib_pmc);
+ void * const handle = VTABLE_get_pointer(s, lib_pmc);
STRING * const type =
VTABLE_get_string(s, VTABLE_getprop(s, lib_pmc, type_str));
Modified: branches/gc-refactor/src/dynpmc/dynlexpad.pmc
==============================================================================
--- branches/gc-refactor/src/dynpmc/dynlexpad.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/dynpmc/dynlexpad.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -174,9 +174,9 @@
/*
-=item C<METHOD PMC* get_lexinfo()>
+=item C<void destroy()>
-Return the LexInfo PMC, if any or a Null PMC.
+Destroy DynLexPad.
=cut
Modified: branches/gc-refactor/src/dynpmc/gdbmhash.pmc
==============================================================================
--- branches/gc-refactor/src/dynpmc/gdbmhash.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/dynpmc/gdbmhash.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -349,15 +349,19 @@
STRING* keystr;
GDBM_FILE dbf = PMC_dbfh(SELF);
datum key_gdbm;
+ INTVAL ret;
if (!key) return 0;
if (!dbf) return 0;
keystr = make_hash_key(interp, key);
- key_gdbm.dsize = keystr->strlen;
- key_gdbm.dptr = keystr->strstart;
+ key_gdbm.dptr = Parrot_str_to_cstring(interp, keystr);
+ key_gdbm.dsize = strlen(key_gdbm.dptr);
+
+ ret = gdbm_exists(dbf, key_gdbm);
+ Parrot_str_free_cstring(key_gdbm.dptr);
- return gdbm_exists(dbf, key_gdbm);
+ return ret;
}
/*
Modified: branches/gc-refactor/src/embed.c
==============================================================================
--- branches/gc-refactor/src/embed.c Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/embed.c Wed Sep 16 18:24:30 2009 (r41302)
@@ -356,15 +356,6 @@
case PARROT_CGOTO_CORE:
Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "cgoto"));
break;
- case PARROT_JIT_CORE:
- Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "jit"));
- break;
- case PARROT_CGP_JIT_CORE:
- Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "cgp_jit"));
- break;
- case PARROT_SWITCH_JIT_CORE:
- Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "switch_jit"));
- break;
case PARROT_EXEC_CORE:
Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "exec"));
break;
Modified: branches/gc-refactor/src/gc/gc_private.h
==============================================================================
--- branches/gc-refactor/src/gc/gc_private.h Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/gc/gc_private.h Wed Sep 16 18:24:30 2009 (r41302)
@@ -72,12 +72,7 @@
/* Set to 1 if we want to use the fixed-size allocator. Set to 0 if we want
to allocate these things using mem_sys_allocate instead */
-/* Had seen errors on Windows. Appears to be fixed now. TT #940 */
-#if defined(_WIN32) || defined(_WIN64)
-# define GC_USE_FIXED_SIZE_ALLOCATOR 1
-#else
-# define GC_USE_FIXED_SIZE_ALLOCATOR 1
-#endif
+#define GC_USE_FIXED_SIZE_ALLOCATOR 1
/* We're using this here to add an additional pointer to a PObj without
having to actually add an entire pointer to every PObj-alike structure
Modified: branches/gc-refactor/src/gc/mark_sweep.c
==============================================================================
--- branches/gc-refactor/src/gc/mark_sweep.c Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/gc/mark_sweep.c Wed Sep 16 18:24:30 2009 (r41302)
@@ -535,6 +535,7 @@
return 0;
}
+ PARROT_ASSERT(current);
mem_pools->gc_trace_ptr = current;
/* short-term hack to color objects black */
Modified: branches/gc-refactor/src/interp/inter_create.c
==============================================================================
--- branches/gc-refactor/src/interp/inter_create.c Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/interp/inter_create.c Wed Sep 16 18:24:30 2009 (r41302)
@@ -400,6 +400,12 @@
/* copies of constant tables */
Parrot_destroy_constants(interp);
+ destroy_runloop_jump_points(interp);
+
+ /* packfile */
+ if (interp->initial_pf)
+ PackFile_destroy(interp, interp->initial_pf);
+
/* buffer headers, PMCs */
Parrot_gc_destroy_header_pools(interp);
@@ -413,12 +419,6 @@
/* cache structure */
destroy_object_cache(interp);
- /* packfile */
- if (interp->initial_pf)
- PackFile_destroy(interp, interp->initial_pf);
-
- destroy_runloop_jump_points(interp);
-
if (interp->evc_func_table) {
mem_sys_free(interp->evc_func_table);
interp->evc_func_table = NULL;
Modified: branches/gc-refactor/src/interp/inter_misc.c
==============================================================================
--- branches/gc-refactor/src/interp/inter_misc.c Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/interp/inter_misc.c Wed Sep 16 18:24:30 2009 (r41302)
@@ -22,6 +22,7 @@
#include "parrot/parrot.h"
#include "inter_misc.str"
#include "../compilers/imcc/imc.h"
+#include "parrot/runcore_api.h"
#include "parrot/has_header.h"
@@ -195,8 +196,7 @@
=item C<INTVAL interpinfo(PARROT_INTERP, INTVAL what)>
-C<what> specifies the type of information you want about the
-interpreter.
+C<what> specifies the type of information you want about the interpreter.
=cut
@@ -266,12 +266,6 @@
ret = PARROT_CGP_CORE;
else if (Parrot_str_equal(interp, name, CONST_STRING(interp, "cgoto")))
ret = PARROT_CGOTO_CORE;
- else if (Parrot_str_equal(interp, name, CONST_STRING(interp, "jit")))
- ret = PARROT_JIT_CORE;
- else if (Parrot_str_equal(interp, name, CONST_STRING(interp, "cgp_jit")))
- ret = PARROT_CGP_JIT_CORE;
- else if (Parrot_str_equal(interp, name, CONST_STRING(interp, "switch_jit")))
- ret = PARROT_SWITCH_JIT_CORE;
else if (Parrot_str_equal(interp, name, CONST_STRING(interp, "exec")))
ret = PARROT_EXEC_CORE;
else if (Parrot_str_equal(interp, name, CONST_STRING(interp, "gc_debug")))
@@ -283,6 +277,7 @@
break;
}
default: /* or a warning only? */
+ ret = -1;
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED,
"illegal argument in interpinfo");
}
Modified: branches/gc-refactor/src/jit.c
==============================================================================
--- branches/gc-refactor/src/jit.c Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/jit.c Wed Sep 16 18:24:30 2009 (r41302)
@@ -1456,6 +1456,9 @@
jit_info->arena.size = jit_info->arena.map_size * 20;
jit_info->native_ptr = jit_info->arena.start =
(char *)mem_alloc_executable((size_t)jit_info->arena.size);
+ if (! jit_info->native_ptr)
+ Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_JIT_ERROR,
+ "Cannot allocate executable memory");
# if EXEC_CAPABLE
if (obj)
@@ -1625,7 +1628,9 @@
PARROT_ASSERT(*cur_op == PARROT_OP_get_results_pc);
/* now emit the call - use special op for this */
- (op_func[PARROT_OP_pic_callr___pc].fn)(jit_info, interp);
+ /* Don't want to fix it. JIT on chopping block.
+ * (op_func[PARROT_OP_pic_callr___pc].fn)(jit_info, interp);
+ */
/* and the get_results */
(op_func[*cur_op].fn)(jit_info, interp);
@@ -1831,6 +1836,9 @@
struct jit_buffer_private_data *jit = (struct jit_buffer_private_data*)priv;
void *ptr = PARROT_MANAGEDSTRUCT(pmc)->ptr;
void *newptr = mem_alloc_executable(jit->size);
+ if (!newptr)
+ Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_JIT_ERROR,
+ "Cannot allocate executable memory");
memcpy(newptr, ptr, jit->size);
PARROT_MANAGEDSTRUCT(rv)->ptr = newptr;
}
Modified: branches/gc-refactor/src/jit/i386/exec_dep.c
==============================================================================
--- branches/gc-refactor/src/jit/i386/exec_dep.c Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/jit/i386/exec_dep.c Wed Sep 16 18:24:30 2009 (r41302)
@@ -26,7 +26,7 @@
#ifdef JIT_CGP
void
-Parrot_exec_normal_op(Parrot_jit_info_t *jit_info, PARROT_INTERP)
+Parrot_exec_normal_op(ARGIN(Parrot_jit_info_t *jit_info), PARROT_INTERP)
{
ASSERT_ARGS(Parrot_exec_normal_op)
Parrot_jit_optimizer_section_ptr cur_section =
@@ -111,7 +111,7 @@
#else /* JIT_CGP */
void
-Parrot_exec_normal_op(Parrot_jit_info_t *jit_info,
+Parrot_exec_normal_op(ARGIN(Parrot_jit_info_t *jit_info),
PARROT_INTERP)
{
ASSERT_ARGS(Parrot_exec_normal_op)
@@ -131,7 +131,7 @@
#endif /* JIT_CGP */
void
-Parrot_exec_cpcf_op(Parrot_jit_info_t *jit_info,
+Parrot_exec_cpcf_op(ARGIN(Parrot_jit_info_t *jit_info),
PARROT_INTERP)
{
ASSERT_ARGS(Parrot_exec_cpcf_op)
@@ -140,7 +140,7 @@
}
void
-Parrot_exec_restart_op(Parrot_jit_info_t *jit_info,
+Parrot_exec_restart_op(ARGIN(Parrot_jit_info_t *jit_info),
PARROT_INTERP)
{
ASSERT_ARGS(Parrot_exec_restart_op)
@@ -171,7 +171,7 @@
/* Assign the offset of the program_code */
void
-offset_fixup(Parrot_exec_objfile_t *obj)
+offset_fixup(ARGIN(Parrot_exec_objfile_t *obj))
{
ASSERT_ARGS(offset_fixup)
int i;
Modified: branches/gc-refactor/src/jit/i386/exec_dep.h
==============================================================================
--- branches/gc-refactor/src/jit/i386/exec_dep.h Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/jit/i386/exec_dep.h Wed Sep 16 18:24:30 2009 (r41302)
@@ -20,28 +20,45 @@
/* HEADERIZER BEGIN: src/exec_dep.c */
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-void offset_fixup(Parrot_exec_objfile_t *obj);
-void Parrot_exec_cpcf_op(Parrot_jit_info_t *jit_info, PARROT_INTERP)
+void offset_fixup(ARGIN(Parrot_exec_objfile_t *obj))
+ __attribute__nonnull__(1);
+
+void Parrot_exec_cpcf_op(ARGIN(Parrot_jit_info_t *jit_info), PARROT_INTERP)
+ __attribute__nonnull__(1)
__attribute__nonnull__(2);
-void Parrot_exec_normal_op(Parrot_jit_info_t *jit_info, PARROT_INTERP)
+void Parrot_exec_normal_op(
+ ARGIN(Parrot_jit_info_t *jit_info),
+ PARROT_INTERP)
+ __attribute__nonnull__(1)
__attribute__nonnull__(2);
-void Parrot_exec_normal_op(Parrot_jit_info_t *jit_info, PARROT_INTERP)
+void Parrot_exec_normal_op(
+ ARGIN(Parrot_jit_info_t *jit_info),
+ PARROT_INTERP)
+ __attribute__nonnull__(1)
__attribute__nonnull__(2);
-void Parrot_exec_restart_op(Parrot_jit_info_t *jit_info, PARROT_INTERP)
+void Parrot_exec_restart_op(
+ ARGIN(Parrot_jit_info_t *jit_info),
+ PARROT_INTERP)
+ __attribute__nonnull__(1)
__attribute__nonnull__(2);
-#define ASSERT_ARGS_offset_fixup __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
+#define ASSERT_ARGS_offset_fixup __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(obj)
#define ASSERT_ARGS_Parrot_exec_cpcf_op __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
+ PARROT_ASSERT_ARG(jit_info) \
+ || PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_Parrot_exec_normal_op __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
+ PARROT_ASSERT_ARG(jit_info) \
+ || PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_Parrot_exec_normal_op __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
+ PARROT_ASSERT_ARG(jit_info) \
+ || PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_Parrot_exec_restart_op __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
+ PARROT_ASSERT_ARG(jit_info) \
+ || PARROT_ASSERT_ARG(interp)
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: src/exec_dep.c */
Modified: branches/gc-refactor/src/jit/i386/jit_defs.c
==============================================================================
--- branches/gc-refactor/src/jit/i386/jit_defs.c Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/jit/i386/jit_defs.c Wed Sep 16 18:24:30 2009 (r41302)
@@ -2110,6 +2110,9 @@
* should free the function pointer returned here
*/
pc = jit_info.native_ptr = jit_info.arena.start = (char *)mem_alloc_executable(JIT_ALLOC_SIZE);
+ if (! pc)
+ Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_JIT_ERROR,
+ "Cannot allocate executable memory");
/* this generated jit function will be called as (INTERP (EBP 8), func_ptr
@@ -2413,8 +2416,9 @@
jit_emit_stack_frame_leave(pc);
emitm_ret(pc);
PARROT_ASSERT(pc - jit_info.arena.start <= JIT_ALLOC_SIZE);
+
/* could shrink arena.start here to used size */
- PObj_custom_destroy_SET(pmc_nci);
+
if (sizeptr)
*sizeptr = JIT_ALLOC_SIZE;
Parrot_str_free_cstring(signature_str);
Modified: branches/gc-refactor/src/ops/core.ops
==============================================================================
--- branches/gc-refactor/src/ops/core.ops Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/ops/core.ops Wed Sep 16 18:24:30 2009 (r41302)
@@ -430,42 +430,46 @@
interp->current_object = NULL;
interp->current_cont = NEED_CONTINUATION;
- dest = (opcode_t *)p->vtable->invoke(interp, p, dest);
+ dest = VTABLE_invoke(interp, p, dest);
goto ADDRESS(dest);
}
inline op invoke(invar PMC, invar PMC) :flow {
- opcode_t *dest;
- PMC * const p = $1;
+ opcode_t *dest = expr NEXT();
+ PMC * const p = $1;
interp->current_object = NULL;
- interp->current_cont = $2;
- dest = (opcode_t *)p->vtable->invoke(interp, p, expr NEXT());
+ interp->current_cont = $2;
+
+ dest = VTABLE_invoke(interp, p, dest);
goto ADDRESS(dest);
}
inline op yield() :flow {
- opcode_t *dest = expr NEXT();
- PMC * const p = Parrot_pcc_get_sub(interp, CURRENT_CONTEXT(interp));
- dest = (opcode_t *)p->vtable->invoke(interp, p, dest);
+ opcode_t *dest = expr NEXT();
+ PMC * const p = Parrot_pcc_get_sub(interp, CURRENT_CONTEXT(interp));
+
+ VTABLE_increment(interp, p);
+ dest = VTABLE_invoke(interp, p, dest);
+
goto ADDRESS(dest);
}
inline op tailcall(invar PMC) :flow {
- opcode_t *dest;
- PMC * const p = $1;
- dest = expr NEXT();
- interp->current_cont = Parrot_pcc_get_continuation(interp, CURRENT_CONTEXT(interp));
- PObj_get_FLAGS(interp->current_cont) |= SUB_FLAG_TAILCALL;
- dest = (opcode_t *)p->vtable->invoke(interp, p, dest);
+ PMC * const p = $1;
+ opcode_t *dest = expr NEXT();
+ interp->current_cont = Parrot_pcc_get_continuation(interp,
+ CURRENT_CONTEXT(interp));
+
+ SUB_FLAG_TAILCALL_SET(interp->current_cont);
+ dest = VTABLE_invoke(interp, p, dest);
goto ADDRESS(dest);
}
inline op returncc() :flow {
PMC * const p = Parrot_pcc_get_continuation(interp, CURRENT_CONTEXT(interp));
- opcode_t * const dest = (opcode_t *)p->vtable->invoke(interp,
- p, expr NEXT());
+ opcode_t * const dest = VTABLE_invoke(interp, p, expr NEXT());
goto ADDRESS(dest);
}
Modified: branches/gc-refactor/src/ops/io.ops
==============================================================================
--- branches/gc-refactor/src/ops/io.ops Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/ops/io.ops Wed Sep 16 18:24:30 2009 (r41302)
@@ -445,7 +445,15 @@
seek:
Set file position to offset $2 on IO stream $1. 'whence' is
-indicated by the value in $3.
+indicated by the value in $3. The valid values for 'whence' are:
+
+ Value Meaning
+ 0 Seek from the beginning of the file
+ 1 Seek from the current position
+ 2 Seek from the end of the file
+
+[ Note: the above values for 'whence' is just an educated guess
+at this point ]
=item B<seek>(invar PMC, in INT, in INT, in INT)
Modified: branches/gc-refactor/src/ops/ops.num
==============================================================================
--- branches/gc-refactor/src/ops/ops.num Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/ops/ops.num Wed Sep 16 18:24:30 2009 (r41302)
@@ -803,479 +803,474 @@
inspect_p_pc_s 779
inspect_p_p_sc 780
inspect_p_pc_sc 781
-pic_infix___ic_p_p 782
-pic_inline_sub___ic_p_p 783
-pic_get_params___pc 784
-pic_set_returns___pc 785
-pic_callr___pc 786
-new_p_s 787
-new_p_sc 788
-new_p_s_p 789
-new_p_sc_p 790
-new_p_s_pc 791
-new_p_sc_pc 792
-new_p_p 793
-new_p_pc 794
-new_p_p_p 795
-new_p_pc_p 796
-new_p_p_pc 797
-new_p_pc_pc 798
-root_new_p_p 799
-root_new_p_pc 800
-root_new_p_p_p 801
-root_new_p_pc_p 802
-root_new_p_p_pc 803
-root_new_p_pc_pc 804
-typeof_s_p 805
-typeof_p_p 806
-get_repr_s_p 807
-find_method_p_p_s 808
-find_method_p_p_sc 809
-defined_i_p 810
-defined_i_p_ki 811
-defined_i_p_kic 812
-defined_i_p_k 813
-defined_i_p_kc 814
-exists_i_p_ki 815
-exists_i_p_kic 816
-exists_i_p_k 817
-exists_i_p_kc 818
-delete_p_k 819
-delete_p_kc 820
-delete_p_ki 821
-delete_p_kic 822
-elements_i_p 823
-push_p_i 824
-push_p_ic 825
-push_p_n 826
-push_p_nc 827
-push_p_s 828
-push_p_sc 829
-push_p_p 830
-pop_i_p 831
-pop_n_p 832
-pop_s_p 833
-pop_p_p 834
-unshift_p_i 835
-unshift_p_ic 836
-unshift_p_n 837
-unshift_p_nc 838
-unshift_p_s 839
-unshift_p_sc 840
-unshift_p_p 841
-shift_i_p 842
-shift_n_p 843
-shift_s_p 844
-shift_p_p 845
-splice_p_p_i_i 846
-splice_p_p_ic_i 847
-splice_p_p_i_ic 848
-splice_p_p_ic_ic 849
-setprop_p_s_p 850
-setprop_p_sc_p 851
-getprop_p_s_p 852
-getprop_p_sc_p 853
-delprop_p_s 854
-delprop_p_sc 855
-prophash_p_p 856
-freeze_s_p 857
-thaw_p_s 858
-thaw_p_sc 859
-add_multi_s_s_p 860
-add_multi_sc_s_p 861
-add_multi_s_sc_p 862
-add_multi_sc_sc_p 863
-find_multi_p_s_s 864
-find_multi_p_sc_s 865
-find_multi_p_s_sc 866
-find_multi_p_sc_sc 867
-register_p 868
-unregister_p 869
-box_p_i 870
-box_p_ic 871
-box_p_n 872
-box_p_nc 873
-box_p_s 874
-box_p_sc 875
-iter_p_p 876
-morph_p_p 877
-morph_p_pc 878
-clone_s_s 879
-clone_s_sc 880
-exchange_i_i 881
-exchange_p_p 882
-exchange_n_n 883
-exchange_s_s 884
-set_i_i 885
-set_i_ic 886
-set_i_n 887
-set_i_nc 888
-set_i_s 889
-set_i_sc 890
-set_n_n 891
-set_n_nc 892
-set_n_i 893
-set_n_ic 894
-set_n_s 895
-set_n_sc 896
-set_n_p 897
-set_s_p 898
-set_s_s 899
-set_s_sc 900
-set_s_i 901
-set_s_ic 902
-set_s_n 903
-set_s_nc 904
-set_p_pc 905
-set_p_p 906
-set_p_i 907
-set_p_ic 908
-set_p_n 909
-set_p_nc 910
-set_p_s 911
-set_p_sc 912
-set_i_p 913
-assign_p_p 914
-assign_p_i 915
-assign_p_ic 916
-assign_p_n 917
-assign_p_nc 918
-assign_p_s 919
-assign_p_sc 920
-assign_s_s 921
-assign_s_sc 922
-setref_p_p 923
-deref_p_p 924
-setp_ind_i_p 925
-setp_ind_ic_p 926
-setn_ind_i_n 927
-setn_ind_ic_n 928
-setn_ind_i_nc 929
-setn_ind_ic_nc 930
-sets_ind_i_s 931
-sets_ind_ic_s 932
-sets_ind_i_sc 933
-sets_ind_ic_sc 934
-seti_ind_i_i 935
-seti_ind_ic_i 936
-seti_ind_i_ic 937
-seti_ind_ic_ic 938
-set_p_ki_i 939
-set_p_kic_i 940
-set_p_ki_ic 941
-set_p_kic_ic 942
-set_p_ki_n 943
-set_p_kic_n 944
-set_p_ki_nc 945
-set_p_kic_nc 946
-set_p_ki_s 947
-set_p_kic_s 948
-set_p_ki_sc 949
-set_p_kic_sc 950
-set_p_ki_p 951
-set_p_kic_p 952
-set_i_p_ki 953
-set_i_p_kic 954
-set_n_p_ki 955
-set_n_p_kic 956
-set_s_p_ki 957
-set_s_p_kic 958
-set_p_p_ki 959
-set_p_p_kic 960
-set_p_k_i 961
-set_p_kc_i 962
-set_p_k_ic 963
-set_p_kc_ic 964
-set_p_k_n 965
-set_p_kc_n 966
-set_p_k_nc 967
-set_p_kc_nc 968
-set_p_k_s 969
-set_p_kc_s 970
-set_p_k_sc 971
-set_p_kc_sc 972
-set_p_k_p 973
-set_p_kc_p 974
-set_i_p_k 975
-set_i_p_kc 976
-set_n_p_k 977
-set_n_p_kc 978
-set_s_p_k 979
-set_s_p_kc 980
-set_p_p_k 981
-set_p_p_kc 982
-clone_p_p 983
-clone_p_p_p 984
-clone_p_p_pc 985
-copy_p_p 986
-null_s 987
-null_i 988
-null_p 989
-null_n 990
-cleari 991
-clearn 992
-clears 993
-clearp 994
-ord_i_s 995
-ord_i_sc 996
-ord_i_s_i 997
-ord_i_sc_i 998
-ord_i_s_ic 999
-ord_i_sc_ic 1000
-chr_s_i 1001
-chr_s_ic 1002
-chopn_s_i 1003
-chopn_s_ic 1004
-chopn_s_s_i 1005
-chopn_s_sc_i 1006
-chopn_s_s_ic 1007
-chopn_s_sc_ic 1008
-concat_s_s 1009
-concat_s_sc 1010
-concat_p_p 1011
-concat_p_s 1012
-concat_p_sc 1013
-concat_s_s_s 1014
-concat_s_sc_s 1015
-concat_s_s_sc 1016
-concat_p_p_s 1017
-concat_p_p_sc 1018
-concat_p_p_p 1019
-repeat_s_s_i 1020
-repeat_s_sc_i 1021
-repeat_s_s_ic 1022
-repeat_s_sc_ic 1023
-repeat_p_p_i 1024
-repeat_p_p_ic 1025
-repeat_p_p_p 1026
-repeat_p_i 1027
-repeat_p_ic 1028
-repeat_p_p 1029
-length_i_s 1030
-length_i_sc 1031
-bytelength_i_s 1032
-bytelength_i_sc 1033
-pin_s 1034
-unpin_s 1035
-substr_s_s_i 1036
-substr_s_sc_i 1037
-substr_s_s_ic 1038
-substr_s_sc_ic 1039
-substr_s_s_i_i 1040
-substr_s_sc_i_i 1041
-substr_s_s_ic_i 1042
-substr_s_sc_ic_i 1043
-substr_s_s_i_ic 1044
-substr_s_sc_i_ic 1045
-substr_s_s_ic_ic 1046
-substr_s_sc_ic_ic 1047
-substr_s_s_i_i_s 1048
-substr_s_s_ic_i_s 1049
-substr_s_s_i_ic_s 1050
-substr_s_s_ic_ic_s 1051
-substr_s_s_i_i_sc 1052
-substr_s_s_ic_i_sc 1053
-substr_s_s_i_ic_sc 1054
-substr_s_s_ic_ic_sc 1055
-substr_s_i_i_s 1056
-substr_s_ic_i_s 1057
-substr_s_i_ic_s 1058
-substr_s_ic_ic_s 1059
-substr_s_i_i_sc 1060
-substr_s_ic_i_sc 1061
-substr_s_i_ic_sc 1062
-substr_s_ic_ic_sc 1063
-substr_s_p_i_i 1064
-substr_s_p_ic_i 1065
-substr_s_p_i_ic 1066
-substr_s_p_ic_ic 1067
-index_i_s_s 1068
-index_i_sc_s 1069
-index_i_s_sc 1070
-index_i_sc_sc 1071
-index_i_s_s_i 1072
-index_i_sc_s_i 1073
-index_i_s_sc_i 1074
-index_i_sc_sc_i 1075
-index_i_s_s_ic 1076
-index_i_sc_s_ic 1077
-index_i_s_sc_ic 1078
-index_i_sc_sc_ic 1079
-sprintf_s_s_p 1080
-sprintf_s_sc_p 1081
-sprintf_p_p_p 1082
-new_s 1083
-new_s_i 1084
-new_s_ic 1085
-stringinfo_i_s_i 1086
-stringinfo_i_sc_i 1087
-stringinfo_i_s_ic 1088
-stringinfo_i_sc_ic 1089
-upcase_s_s 1090
-upcase_s_sc 1091
-upcase_s 1092
-downcase_s_s 1093
-downcase_s_sc 1094
-downcase_s 1095
-titlecase_s_s 1096
-titlecase_s_sc 1097
-titlecase_s 1098
-join_s_s_p 1099
-join_s_sc_p 1100
-split_p_s_s 1101
-split_p_sc_s 1102
-split_p_s_sc 1103
-split_p_sc_sc 1104
-charset_i_s 1105
-charset_i_sc 1106
-charsetname_s_i 1107
-charsetname_s_ic 1108
-find_charset_i_s 1109
-find_charset_i_sc 1110
-trans_charset_s_i 1111
-trans_charset_s_ic 1112
-trans_charset_s_s_i 1113
-trans_charset_s_sc_i 1114
-trans_charset_s_s_ic 1115
-trans_charset_s_sc_ic 1116
-encoding_i_s 1117
-encoding_i_sc 1118
-encodingname_s_i 1119
-encodingname_s_ic 1120
-find_encoding_i_s 1121
-find_encoding_i_sc 1122
-trans_encoding_s_i 1123
-trans_encoding_s_ic 1124
-trans_encoding_s_s_i 1125
-trans_encoding_s_sc_i 1126
-trans_encoding_s_s_ic 1127
-trans_encoding_s_sc_ic 1128
-is_cclass_i_i_s_i 1129
-is_cclass_i_ic_s_i 1130
-is_cclass_i_i_sc_i 1131
-is_cclass_i_ic_sc_i 1132
-is_cclass_i_i_s_ic 1133
-is_cclass_i_ic_s_ic 1134
-is_cclass_i_i_sc_ic 1135
-is_cclass_i_ic_sc_ic 1136
-find_cclass_i_i_s_i_i 1137
-find_cclass_i_ic_s_i_i 1138
-find_cclass_i_i_sc_i_i 1139
-find_cclass_i_ic_sc_i_i 1140
-find_cclass_i_i_s_ic_i 1141
-find_cclass_i_ic_s_ic_i 1142
-find_cclass_i_i_sc_ic_i 1143
-find_cclass_i_ic_sc_ic_i 1144
-find_cclass_i_i_s_i_ic 1145
-find_cclass_i_ic_s_i_ic 1146
-find_cclass_i_i_sc_i_ic 1147
-find_cclass_i_ic_sc_i_ic 1148
-find_cclass_i_i_s_ic_ic 1149
-find_cclass_i_ic_s_ic_ic 1150
-find_cclass_i_i_sc_ic_ic 1151
-find_cclass_i_ic_sc_ic_ic 1152
-find_not_cclass_i_i_s_i_i 1153
-find_not_cclass_i_ic_s_i_i 1154
-find_not_cclass_i_i_sc_i_i 1155
-find_not_cclass_i_ic_sc_i_i 1156
-find_not_cclass_i_i_s_ic_i 1157
-find_not_cclass_i_ic_s_ic_i 1158
-find_not_cclass_i_i_sc_ic_i 1159
-find_not_cclass_i_ic_sc_ic_i 1160
-find_not_cclass_i_i_s_i_ic 1161
-find_not_cclass_i_ic_s_i_ic 1162
-find_not_cclass_i_i_sc_i_ic 1163
-find_not_cclass_i_ic_sc_i_ic 1164
-find_not_cclass_i_i_s_ic_ic 1165
-find_not_cclass_i_ic_s_ic_ic 1166
-find_not_cclass_i_i_sc_ic_ic 1167
-find_not_cclass_i_ic_sc_ic_ic 1168
-escape_s_s 1169
-compose_s_s 1170
-compose_s_sc 1171
-spawnw_i_s 1172
-spawnw_i_sc 1173
-spawnw_i_p 1174
-err_i 1175
-err_s 1176
-err_s_i 1177
-err_s_ic 1178
-time_i 1179
-time_n 1180
-gmtime_s_i 1181
-gmtime_s_ic 1182
-localtime_s_i 1183
-localtime_s_ic 1184
-decodetime_p_i 1185
-decodetime_p_ic 1186
-decodelocaltime_p_i 1187
-decodelocaltime_p_ic 1188
-sysinfo_s_i 1189
-sysinfo_s_ic 1190
-sysinfo_i_i 1191
-sysinfo_i_ic 1192
-sleep_i 1193
-sleep_ic 1194
-sleep_n 1195
-sleep_nc 1196
-sizeof_i_i 1197
-sizeof_i_ic 1198
-store_lex_s_p 1199
-store_lex_sc_p 1200
-find_lex_p_s 1201
-find_lex_p_sc 1202
-find_caller_lex_p_s 1203
-find_caller_lex_p_sc 1204
-get_namespace_p 1205
-get_namespace_p_p 1206
-get_namespace_p_pc 1207
-get_hll_namespace_p 1208
-get_hll_namespace_p_p 1209
-get_hll_namespace_p_pc 1210
-get_root_namespace_p 1211
-get_root_namespace_p_p 1212
-get_root_namespace_p_pc 1213
-get_global_p_s 1214
-get_global_p_sc 1215
-get_global_p_p_s 1216
-get_global_p_pc_s 1217
-get_global_p_p_sc 1218
-get_global_p_pc_sc 1219
-get_hll_global_p_s 1220
-get_hll_global_p_sc 1221
-get_hll_global_p_p_s 1222
-get_hll_global_p_pc_s 1223
-get_hll_global_p_p_sc 1224
-get_hll_global_p_pc_sc 1225
-get_root_global_p_s 1226
-get_root_global_p_sc 1227
-get_root_global_p_p_s 1228
-get_root_global_p_pc_s 1229
-get_root_global_p_p_sc 1230
-get_root_global_p_pc_sc 1231
-set_global_s_p 1232
-set_global_sc_p 1233
-set_global_p_s_p 1234
-set_global_pc_s_p 1235
-set_global_p_sc_p 1236
-set_global_pc_sc_p 1237
-set_hll_global_s_p 1238
-set_hll_global_sc_p 1239
-set_hll_global_p_s_p 1240
-set_hll_global_pc_s_p 1241
-set_hll_global_p_sc_p 1242
-set_hll_global_pc_sc_p 1243
-set_root_global_s_p 1244
-set_root_global_sc_p 1245
-set_root_global_p_s_p 1246
-set_root_global_pc_s_p 1247
-set_root_global_p_sc_p 1248
-set_root_global_pc_sc_p 1249
-find_name_p_s 1250
-find_name_p_sc 1251
-find_sub_not_null_p_s 1252
-find_sub_not_null_p_sc 1253
-store_dynamic_lex_s_p 1254
-store_dynamic_lex_sc_p 1255
-find_dynamic_lex_p_s 1256
-find_dynamic_lex_p_sc 1257
+new_p_s 782
+new_p_sc 783
+new_p_s_p 784
+new_p_sc_p 785
+new_p_s_pc 786
+new_p_sc_pc 787
+new_p_p 788
+new_p_pc 789
+new_p_p_p 790
+new_p_pc_p 791
+new_p_p_pc 792
+new_p_pc_pc 793
+root_new_p_p 794
+root_new_p_pc 795
+root_new_p_p_p 796
+root_new_p_pc_p 797
+root_new_p_p_pc 798
+root_new_p_pc_pc 799
+typeof_s_p 800
+typeof_p_p 801
+get_repr_s_p 802
+find_method_p_p_s 803
+find_method_p_p_sc 804
+defined_i_p 805
+defined_i_p_ki 806
+defined_i_p_kic 807
+defined_i_p_k 808
+defined_i_p_kc 809
+exists_i_p_ki 810
+exists_i_p_kic 811
+exists_i_p_k 812
+exists_i_p_kc 813
+delete_p_k 814
+delete_p_kc 815
+delete_p_ki 816
+delete_p_kic 817
+elements_i_p 818
+push_p_i 819
+push_p_ic 820
+push_p_n 821
+push_p_nc 822
+push_p_s 823
+push_p_sc 824
+push_p_p 825
+pop_i_p 826
+pop_n_p 827
+pop_s_p 828
+pop_p_p 829
+unshift_p_i 830
+unshift_p_ic 831
+unshift_p_n 832
+unshift_p_nc 833
+unshift_p_s 834
+unshift_p_sc 835
+unshift_p_p 836
+shift_i_p 837
+shift_n_p 838
+shift_s_p 839
+shift_p_p 840
+splice_p_p_i_i 841
+splice_p_p_ic_i 842
+splice_p_p_i_ic 843
+splice_p_p_ic_ic 844
+setprop_p_s_p 845
+setprop_p_sc_p 846
+getprop_p_s_p 847
+getprop_p_sc_p 848
+delprop_p_s 849
+delprop_p_sc 850
+prophash_p_p 851
+freeze_s_p 852
+thaw_p_s 853
+thaw_p_sc 854
+add_multi_s_s_p 855
+add_multi_sc_s_p 856
+add_multi_s_sc_p 857
+add_multi_sc_sc_p 858
+find_multi_p_s_s 859
+find_multi_p_sc_s 860
+find_multi_p_s_sc 861
+find_multi_p_sc_sc 862
+register_p 863
+unregister_p 864
+box_p_i 865
+box_p_ic 866
+box_p_n 867
+box_p_nc 868
+box_p_s 869
+box_p_sc 870
+iter_p_p 871
+morph_p_p 872
+morph_p_pc 873
+clone_s_s 874
+clone_s_sc 875
+exchange_i_i 876
+exchange_p_p 877
+exchange_n_n 878
+exchange_s_s 879
+set_i_i 880
+set_i_ic 881
+set_i_n 882
+set_i_nc 883
+set_i_s 884
+set_i_sc 885
+set_n_n 886
+set_n_nc 887
+set_n_i 888
+set_n_ic 889
+set_n_s 890
+set_n_sc 891
+set_n_p 892
+set_s_p 893
+set_s_s 894
+set_s_sc 895
+set_s_i 896
+set_s_ic 897
+set_s_n 898
+set_s_nc 899
+set_p_pc 900
+set_p_p 901
+set_p_i 902
+set_p_ic 903
+set_p_n 904
+set_p_nc 905
+set_p_s 906
+set_p_sc 907
+set_i_p 908
+assign_p_p 909
+assign_p_i 910
+assign_p_ic 911
+assign_p_n 912
+assign_p_nc 913
+assign_p_s 914
+assign_p_sc 915
+assign_s_s 916
+assign_s_sc 917
+setref_p_p 918
+deref_p_p 919
+setp_ind_i_p 920
+setp_ind_ic_p 921
+setn_ind_i_n 922
+setn_ind_ic_n 923
+setn_ind_i_nc 924
+setn_ind_ic_nc 925
+sets_ind_i_s 926
+sets_ind_ic_s 927
+sets_ind_i_sc 928
+sets_ind_ic_sc 929
+seti_ind_i_i 930
+seti_ind_ic_i 931
+seti_ind_i_ic 932
+seti_ind_ic_ic 933
+set_p_ki_i 934
+set_p_kic_i 935
+set_p_ki_ic 936
+set_p_kic_ic 937
+set_p_ki_n 938
+set_p_kic_n 939
+set_p_ki_nc 940
+set_p_kic_nc 941
+set_p_ki_s 942
+set_p_kic_s 943
+set_p_ki_sc 944
+set_p_kic_sc 945
+set_p_ki_p 946
+set_p_kic_p 947
+set_i_p_ki 948
+set_i_p_kic 949
+set_n_p_ki 950
+set_n_p_kic 951
+set_s_p_ki 952
+set_s_p_kic 953
+set_p_p_ki 954
+set_p_p_kic 955
+set_p_k_i 956
+set_p_kc_i 957
+set_p_k_ic 958
+set_p_kc_ic 959
+set_p_k_n 960
+set_p_kc_n 961
+set_p_k_nc 962
+set_p_kc_nc 963
+set_p_k_s 964
+set_p_kc_s 965
+set_p_k_sc 966
+set_p_kc_sc 967
+set_p_k_p 968
+set_p_kc_p 969
+set_i_p_k 970
+set_i_p_kc 971
+set_n_p_k 972
+set_n_p_kc 973
+set_s_p_k 974
+set_s_p_kc 975
+set_p_p_k 976
+set_p_p_kc 977
+clone_p_p 978
+clone_p_p_p 979
+clone_p_p_pc 980
+copy_p_p 981
+null_s 982
+null_i 983
+null_p 984
+null_n 985
+cleari 986
+clearn 987
+clears 988
+clearp 989
+ord_i_s 990
+ord_i_sc 991
+ord_i_s_i 992
+ord_i_sc_i 993
+ord_i_s_ic 994
+ord_i_sc_ic 995
+chr_s_i 996
+chr_s_ic 997
+chopn_s_i 998
+chopn_s_ic 999
+chopn_s_s_i 1000
+chopn_s_sc_i 1001
+chopn_s_s_ic 1002
+chopn_s_sc_ic 1003
+concat_s_s 1004
+concat_s_sc 1005
+concat_p_p 1006
+concat_p_s 1007
+concat_p_sc 1008
+concat_s_s_s 1009
+concat_s_sc_s 1010
+concat_s_s_sc 1011
+concat_p_p_s 1012
+concat_p_p_sc 1013
+concat_p_p_p 1014
+repeat_s_s_i 1015
+repeat_s_sc_i 1016
+repeat_s_s_ic 1017
+repeat_s_sc_ic 1018
+repeat_p_p_i 1019
+repeat_p_p_ic 1020
+repeat_p_p_p 1021
+repeat_p_i 1022
+repeat_p_ic 1023
+repeat_p_p 1024
+length_i_s 1025
+length_i_sc 1026
+bytelength_i_s 1027
+bytelength_i_sc 1028
+pin_s 1029
+unpin_s 1030
+substr_s_s_i 1031
+substr_s_sc_i 1032
+substr_s_s_ic 1033
+substr_s_sc_ic 1034
+substr_s_s_i_i 1035
+substr_s_sc_i_i 1036
+substr_s_s_ic_i 1037
+substr_s_sc_ic_i 1038
+substr_s_s_i_ic 1039
+substr_s_sc_i_ic 1040
+substr_s_s_ic_ic 1041
+substr_s_sc_ic_ic 1042
+substr_s_s_i_i_s 1043
+substr_s_s_ic_i_s 1044
+substr_s_s_i_ic_s 1045
+substr_s_s_ic_ic_s 1046
+substr_s_s_i_i_sc 1047
+substr_s_s_ic_i_sc 1048
+substr_s_s_i_ic_sc 1049
+substr_s_s_ic_ic_sc 1050
+substr_s_i_i_s 1051
+substr_s_ic_i_s 1052
+substr_s_i_ic_s 1053
+substr_s_ic_ic_s 1054
+substr_s_i_i_sc 1055
+substr_s_ic_i_sc 1056
+substr_s_i_ic_sc 1057
+substr_s_ic_ic_sc 1058
+substr_s_p_i_i 1059
+substr_s_p_ic_i 1060
+substr_s_p_i_ic 1061
+substr_s_p_ic_ic 1062
+index_i_s_s 1063
+index_i_sc_s 1064
+index_i_s_sc 1065
+index_i_sc_sc 1066
+index_i_s_s_i 1067
+index_i_sc_s_i 1068
+index_i_s_sc_i 1069
+index_i_sc_sc_i 1070
+index_i_s_s_ic 1071
+index_i_sc_s_ic 1072
+index_i_s_sc_ic 1073
+index_i_sc_sc_ic 1074
+sprintf_s_s_p 1075
+sprintf_s_sc_p 1076
+sprintf_p_p_p 1077
+new_s 1078
+new_s_i 1079
+new_s_ic 1080
+stringinfo_i_s_i 1081
+stringinfo_i_sc_i 1082
+stringinfo_i_s_ic 1083
+stringinfo_i_sc_ic 1084
+upcase_s_s 1085
+upcase_s_sc 1086
+upcase_s 1087
+downcase_s_s 1088
+downcase_s_sc 1089
+downcase_s 1090
+titlecase_s_s 1091
+titlecase_s_sc 1092
+titlecase_s 1093
+join_s_s_p 1094
+join_s_sc_p 1095
+split_p_s_s 1096
+split_p_sc_s 1097
+split_p_s_sc 1098
+split_p_sc_sc 1099
+charset_i_s 1100
+charset_i_sc 1101
+charsetname_s_i 1102
+charsetname_s_ic 1103
+find_charset_i_s 1104
+find_charset_i_sc 1105
+trans_charset_s_i 1106
+trans_charset_s_ic 1107
+trans_charset_s_s_i 1108
+trans_charset_s_sc_i 1109
+trans_charset_s_s_ic 1110
+trans_charset_s_sc_ic 1111
+encoding_i_s 1112
+encoding_i_sc 1113
+encodingname_s_i 1114
+encodingname_s_ic 1115
+find_encoding_i_s 1116
+find_encoding_i_sc 1117
+trans_encoding_s_i 1118
+trans_encoding_s_ic 1119
+trans_encoding_s_s_i 1120
+trans_encoding_s_sc_i 1121
+trans_encoding_s_s_ic 1122
+trans_encoding_s_sc_ic 1123
+is_cclass_i_i_s_i 1124
+is_cclass_i_ic_s_i 1125
+is_cclass_i_i_sc_i 1126
+is_cclass_i_ic_sc_i 1127
+is_cclass_i_i_s_ic 1128
+is_cclass_i_ic_s_ic 1129
+is_cclass_i_i_sc_ic 1130
+is_cclass_i_ic_sc_ic 1131
+find_cclass_i_i_s_i_i 1132
+find_cclass_i_ic_s_i_i 1133
+find_cclass_i_i_sc_i_i 1134
+find_cclass_i_ic_sc_i_i 1135
+find_cclass_i_i_s_ic_i 1136
+find_cclass_i_ic_s_ic_i 1137
+find_cclass_i_i_sc_ic_i 1138
+find_cclass_i_ic_sc_ic_i 1139
+find_cclass_i_i_s_i_ic 1140
+find_cclass_i_ic_s_i_ic 1141
+find_cclass_i_i_sc_i_ic 1142
+find_cclass_i_ic_sc_i_ic 1143
+find_cclass_i_i_s_ic_ic 1144
+find_cclass_i_ic_s_ic_ic 1145
+find_cclass_i_i_sc_ic_ic 1146
+find_cclass_i_ic_sc_ic_ic 1147
+find_not_cclass_i_i_s_i_i 1148
+find_not_cclass_i_ic_s_i_i 1149
+find_not_cclass_i_i_sc_i_i 1150
+find_not_cclass_i_ic_sc_i_i 1151
+find_not_cclass_i_i_s_ic_i 1152
+find_not_cclass_i_ic_s_ic_i 1153
+find_not_cclass_i_i_sc_ic_i 1154
+find_not_cclass_i_ic_sc_ic_i 1155
+find_not_cclass_i_i_s_i_ic 1156
+find_not_cclass_i_ic_s_i_ic 1157
+find_not_cclass_i_i_sc_i_ic 1158
+find_not_cclass_i_ic_sc_i_ic 1159
+find_not_cclass_i_i_s_ic_ic 1160
+find_not_cclass_i_ic_s_ic_ic 1161
+find_not_cclass_i_i_sc_ic_ic 1162
+find_not_cclass_i_ic_sc_ic_ic 1163
+escape_s_s 1164
+compose_s_s 1165
+compose_s_sc 1166
+spawnw_i_s 1167
+spawnw_i_sc 1168
+spawnw_i_p 1169
+err_i 1170
+err_s 1171
+err_s_i 1172
+err_s_ic 1173
+time_i 1174
+time_n 1175
+gmtime_s_i 1176
+gmtime_s_ic 1177
+localtime_s_i 1178
+localtime_s_ic 1179
+decodetime_p_i 1180
+decodetime_p_ic 1181
+decodelocaltime_p_i 1182
+decodelocaltime_p_ic 1183
+sysinfo_s_i 1184
+sysinfo_s_ic 1185
+sysinfo_i_i 1186
+sysinfo_i_ic 1187
+sleep_i 1188
+sleep_ic 1189
+sleep_n 1190
+sleep_nc 1191
+sizeof_i_i 1192
+sizeof_i_ic 1193
+store_lex_s_p 1194
+store_lex_sc_p 1195
+store_dynamic_lex_s_p 1196
+store_dynamic_lex_sc_p 1197
+find_lex_p_s 1198
+find_lex_p_sc 1199
+find_dynamic_lex_p_s 1200
+find_dynamic_lex_p_sc 1201
+find_caller_lex_p_s 1202
+find_caller_lex_p_sc 1203
+get_namespace_p 1204
+get_namespace_p_p 1205
+get_namespace_p_pc 1206
+get_hll_namespace_p 1207
+get_hll_namespace_p_p 1208
+get_hll_namespace_p_pc 1209
+get_root_namespace_p 1210
+get_root_namespace_p_p 1211
+get_root_namespace_p_pc 1212
+get_global_p_s 1213
+get_global_p_sc 1214
+get_global_p_p_s 1215
+get_global_p_pc_s 1216
+get_global_p_p_sc 1217
+get_global_p_pc_sc 1218
+get_hll_global_p_s 1219
+get_hll_global_p_sc 1220
+get_hll_global_p_p_s 1221
+get_hll_global_p_pc_s 1222
+get_hll_global_p_p_sc 1223
+get_hll_global_p_pc_sc 1224
+get_root_global_p_s 1225
+get_root_global_p_sc 1226
+get_root_global_p_p_s 1227
+get_root_global_p_pc_s 1228
+get_root_global_p_p_sc 1229
+get_root_global_p_pc_sc 1230
+set_global_s_p 1231
+set_global_sc_p 1232
+set_global_p_s_p 1233
+set_global_pc_s_p 1234
+set_global_p_sc_p 1235
+set_global_pc_sc_p 1236
+set_hll_global_s_p 1237
+set_hll_global_sc_p 1238
+set_hll_global_p_s_p 1239
+set_hll_global_pc_s_p 1240
+set_hll_global_p_sc_p 1241
+set_hll_global_pc_sc_p 1242
+set_root_global_s_p 1243
+set_root_global_sc_p 1244
+set_root_global_p_s_p 1245
+set_root_global_pc_s_p 1246
+set_root_global_p_sc_p 1247
+set_root_global_pc_sc_p 1248
+find_name_p_s 1249
+find_name_p_sc 1250
+find_sub_not_null_p_s 1251
+find_sub_not_null_p_sc 1252
Deleted: branches/gc-refactor/src/ops/pic.ops
==============================================================================
--- branches/gc-refactor/src/ops/pic.ops Wed Sep 16 18:24:30 2009 (r41301)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,323 +0,0 @@
-/*
- * $Id$
-** pic.ops
-*/
-
-BEGIN_OPS_PREAMBLE
-#include "parrot/oplib/ops.h"
-#include "../src/pmc/pmc_fixedintegerarray.h"
-
-typedef opcode_t* (*interface_f)(Interp*, INTVAL*, void **);
-END_OPS_PREAMBLE
-
-=head1 NAME
-
-pic.ops - PIC (Polymorphic Inline Cache) Opcodes [deprecated]
-
-=cut
-
-=head1 DESCRIPTION
-
-During predereferencing opcodes that allow caching are rewritten so that
-equivalent opcodes in this file are used. User code MUST never emit these
-opcodes directly.
-
-=head2 General infix operations
-
-These operations take an infix operation number and PMC arguments.
-
-=cut
-
-=over 4
-
-=item B<pic_infix__>(inconst INT, invar PMC, invar PMC)
-
-One for fun and MOPS.
-
-=cut
-
-inline op pic_infix__(inconst INT, invar PMC, invar PMC) :pic :flow {
- Parrot_MIC *mic;
- Parrot_PIC_lru *lru;
- PMC *left, *right;
- INTVAL lr_types;
-
- mic = (Parrot_MIC *) cur_opcode[1];
- left = $2;
- right = $3;
- lru = &mic->lru;
- lr_types = (VTABLE_type(interp, left) << 16) | VTABLE_type(interp, right);
- if (lru->u.type == lr_types) {
-runit_v_pp:
- ((mmd_f_v_pp)lru->f.real_function)(interp, left, right);
- goto NEXT();
- }
- if (mic->pic) {
- lru = mic->pic->lru;
- if (lru->u.type == lr_types)
- goto runit_v_pp;
- if (++lru->u.type == lr_types)
- goto runit_v_pp;
- if (++lru->u.type == lr_types)
- goto runit_v_pp;
- mic->pic->miss_count++;
- /*
- * RT#42353 if we got too often here just do a dynamic lookup
- */
- }
- parrot_pic_find_infix_v_pp(interp, left, right, mic, cur_opcode);
- /* rerun this opcode */
- goto OFFSET(0);
-}
-
-=item B<pic_inline_sub__>(inconst INT, invar PMC, invar PMC)
-
-And for more fun an inlined variant too.
-
-=cut
-
-inline op pic_inline_sub__(inconst INT, invar PMC, invar PMC) :pic {
- Parrot_MIC *mic;
- Parrot_PIC_lru *lru;
- PMC *left, *right;
- INTVAL lr_types, lt, rt;
-
- left = $2;
- mic = (Parrot_MIC *) cur_opcode[1];
- lt = VTABLE_type(interp, left);
- right = $3;
- lru = &mic->lru;
- rt = VTABLE_type(interp, right);
- lr_types = (lt << 16) | rt;
- if (lru->u.type == lr_types) {
- INTVAL a = VTABLE_get_integer(interp, left);
- INTVAL b = VTABLE_get_integer(interp, right);
- INTVAL c = a - b;
- if ((c^a) >= 0 || (c^~b) >= 0) {
- VTABLE_set_integer_native(interp, left, c);
- }
- else {
- if (PARROT_ERRORS_test(interp, PARROT_ERRORS_OVERFLOW_FLAG)) {
- opcode_t *handler = Parrot_ex_throw_from_op_args(interp, NULL,
- EXCEPTION_ERR_OVERFLOW,
- "Integer overflow");
- goto ADDRESS(handler);
- }
- /* #RT42354 preserve type system */
- VTABLE_morph(interp, left, interp->vtables[enum_class_BigInt]->pmc_class);
- VTABLE_set_integer_native(interp, left, a);
- $2 = VTABLE_subtract_int(interp, left, b, left);
- }
- }
- else {
- ((void**)cur_opcode)[0] =
- parrot_pic_opcode(interp, PARROT_OP_pic_infix___ic_p_p);
- goto OFFSET(0);
- }
-}
-
-=item B<pic_get_params__>(inconst PMC /* , ... */)
-
-Fetch function parameters for this subroutine.
-
-=item B<pic_set_returns__>(inconst PMC /* , ... */)
-
-Return values to caller.
-
-=cut
-
-inline op pic_get_params__(inconst PMC) :pic :flow {
- Parrot_MIC *mic;
- Parrot_PIC_lru *lru;
- PMC *sig, *ccont;
- opcode_t *src_pc;
- void **src_pred;
- PMC *caller_ctx, *ctx;
- int n;
-
- /* avoid load dependencies - intermix derefs
- * - yes, confusing but faster
- */
- ctx = CURRENT_CONTEXT(interp);
- src_pc = interp->current_args;
- mic = (Parrot_MIC *) cur_opcode[1];
- caller_ctx = Parrot_pcc_get_caller_ctx(interp, ctx);
- if (src_pc) {
- src_pred = (void**) src_pc - Parrot_pcc_get_pred_offset(interp, caller_ctx);
- sig = (PMC*)(src_pred[1]);
- }
- else {
- sig = NULL;
- src_pred = NULL; /* just for gcc */
- }
- lru = &mic->lru;
- if (lru->u.signature == sig) {
- if (sig) {
- n = ((arg_pass_f)lru->f.real_function)(interp, sig,
- (char*)Parrot_pcc_get_regs_ni(interp, caller_ctx)->regs_i, src_pred,
- _reg_base, (void**)cur_opcode);
- }
- else
- n = 2;
- ccont = Parrot_pcc_get_continuation(interp, ctx);
- if (PObj_get_FLAGS(ccont) & SUB_FLAG_TAILCALL) {
- PObj_get_FLAGS(ccont) &= ~SUB_FLAG_TAILCALL;
- Parrot_pcc_dec_recursion_depth(interp, ctx);
- Parrot_pcc_set_caller_ctx(interp, ctx,
- Parrot_pcc_get_caller_ctx(interp, caller_ctx));
- interp->current_args = NULL;
- }
-
- goto OFFSET(n);
- }
- /* no match redo plain opcode */
- ((void**)cur_opcode)[0] =
- parrot_pic_opcode(interp, PARROT_OP_get_params_pc);
- ((void**)cur_opcode)[1] = mic->m.sig;
- goto OFFSET(0);
-}
-
-inline op pic_set_returns__(inconst PMC) :pic :flow {
- Parrot_MIC *mic;
- Parrot_PIC_lru *lru;
- PMC *sig, *ccont;
- opcode_t *dest_pc;
- void **dest_pred;
- PMC *caller_ctx, *ctx;
- Parrot_Continuation_attributes *cc;
- int n;
-
- ctx = CURRENT_CONTEXT(interp);
- mic = (Parrot_MIC *) cur_opcode[1];
- ccont = Parrot_pcc_get_continuation(interp, ctx);
- cc = PMC_cont(ccont);
- if (!cc->address) {
- interp->current_returns = CUR_OPCODE;
- n = VTABLE_get_integer(interp, mic->m.sig);
- goto OFFSET(n + 2);
- }
- caller_ctx = cc->to_ctx;
- interp->current_args = NULL;
- dest_pc = Parrot_pcc_get_results(interp, caller_ctx);
- if (dest_pc) {
- dest_pred = (void**) dest_pc - Parrot_pcc_get_pred_offset(interp, caller_ctx);
- sig = (PMC*)(dest_pred[1]);
- }
- else {
- sig = NULL;
- dest_pred = NULL;
- }
- lru = &mic->lru;
- if (lru->u.signature == sig) {
- if (sig) {
- n = ((arg_pass_f)lru->f.real_function)(interp, mic->m.sig,
- _reg_base, (void**)cur_opcode,
- (char*)Parrot_pcc_get_regs_ni(interp, caller_ctx)->regs_i, dest_pred);
- }
- else
- n = 2;
- goto OFFSET(n);
- }
- /* no match redo plain opcode */
- ((void**)cur_opcode)[0] =
- parrot_pic_opcode(interp, PARROT_OP_set_returns_pc);
- ((void**)cur_opcode)[1] = mic->m.sig;
- goto OFFSET(0);
-}
-
-=item B<pic_callr__>(inconst PMC)
-
-Call the function $1 as C<pc = func(interp, 0, **args)>. args[0] holds the
-address of the function result, args[1..] are function arguments, both
-according to the C<get_results> and C<set_args> opcodes. The function is
-a C interface function (or NCI) or a JITed PIR function. args[n+1] holds the
-C<pc> of the next opcode and is usually just returned.
-
-=cut
-
-inline op pic_callr__(inconst PMC) :pic :flow {
- Parrot_MIC *mic;
- Parrot_PIC_lru *lru;
- void *args[6]; /* RT#42355 ARG_MAX */
- PMC *ctx;
- opcode_t *pc;
- void **pred_pc;
- INTVAL i, n_args, *sig_bits;
- PMC *sig;
-
- ctx = CURRENT_CONTEXT(interp);
- mic = (Parrot_MIC *) cur_opcode[1];
- /* get_results */
- pc = Parrot_pcc_get_results(interp, ctx);
- if (pc) {
- pred_pc = (void**) pc - Parrot_pcc_get_pred_offset(interp, ctx);
- sig = (PMC*)(pred_pc[1]);
- ASSERT_SIG_PMC(sig);
- PARROT_ASSERT(VTABLE_elements(interp, sig) <= 1);
- args[0] = VTABLE_elements(interp, sig) ?
- (_reg_base + ((opcode_t*)pred_pc)[2]) : NULL;
- }
- else
- args[0] = NULL;
- /* set_args */
- n_args = 0;
- sig = mic->m.sig;
- ASSERT_SIG_PMC(sig);
- n_args = VTABLE_elements(interp, sig);
- GETATTR_FixedIntegerArray_int_array(interp, sig, sig_bits);
- for (i = 0; i < n_args; ++i) {
- switch (sig_bits[i]) {
- case PARROT_ARG_INTVAL:
- args[1 + i] = (void*)*(INTVAL*)(_reg_base +
- ((opcode_t*)cur_opcode)[2 + i]);
- break;
- case PARROT_ARG_INTVAL|PARROT_ARG_CONSTANT:
- case PARROT_ARG_FLOATVAL|PARROT_ARG_CONSTANT:
- args[1 + i] = (void**)cur_opcode[2 + i];
- break;
- case PARROT_ARG_FLOATVAL:
- args[1 + i] = (_reg_base +
- ((opcode_t*)cur_opcode)[2 + i]);
- break;
- default:
- {
- opcode_t *handler = Parrot_ex_throw_from_op_args(interp, NULL,
- EXCEPTION_INVALID_OPERATION,
- "unhandled sig_bits");
- goto ADDRESS(handler);
- }
- }
- }
- /* set_args(); set_p_pc; get_results(1), x; invokecc_p */
- pc = CUR_OPCODE + 2 + n_args + 3 + 3 + 2;
- args[1 + n_args] = pc;
- lru = &mic->lru;
- /* RT#42356 verify $1 didn't change */
- (void) ((interface_f)lru->f.real_function)(interp, sig_bits, args);
- goto ADDRESS(pc);
-}
-
-=back
-
-=cut
-
-###############################################################################
-
-=head1 COPYRIGHT
-
-Copyright (C) 2005-2008, Parrot Foundation.
-
-=head1 LICENSE
-
-This program is free software. It is subject to the same license
-as the Parrot interpreter itself.
-
-=cut
-
-
-/*
- * Local variables:
- * c-file-style: "parrot"
- * End:
- * vim: expandtab shiftwidth=4:
- */
Modified: branches/gc-refactor/src/packfile.c
==============================================================================
--- branches/gc-refactor/src/packfile.c Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/packfile.c Wed Sep 16 18:24:30 2009 (r41302)
@@ -583,8 +583,6 @@
}
break;
case PF_UNKNOWN_SEG:
- if (memcmp(seg->name, "PIC_idx", 7) == 0)
- pf->cur_cs->pic_index = seg;
break;
case PF_DEBUG_SEG:
pf->cur_cs->debugs = (PackFile_Debug *)seg;
@@ -1771,9 +1769,6 @@
cur_cs->const_table->code = cur_cs;
- cur_cs->pic_index = create_seg(interp, &pf->directory,
- PF_UNKNOWN_SEG, "PIC_idx", file_name, add);
-
return cur_cs;
}
@@ -2051,6 +2046,7 @@
size_t i;
int offs;
+ PARROT_ASSERT(pf);
dir->num_segments = PF_fetch_opcode(pf, &cursor);
TRACE_PRINTF(("directory_unpack: %ld num_segments\n", dir->num_segments));
mem_realloc_n_typed(dir->segments, dir->num_segments, PackFile_Segment *);
@@ -2200,12 +2196,24 @@
PackFile_Directory * const dir = (PackFile_Directory *)self;
size_t i;
- for (i = 0; i < dir->num_segments; i++)
- PackFile_Segment_destroy(interp, dir->segments[i]);
+ for (i = 0; i < dir->num_segments; i++) {
+ PackFile_Segment *segment = dir->segments[i];
+ /* Prevent repeated destruction */
+ dir->segments[i] = NULL;
+
+ /* XXX Black magic here.
+ * There are some failures that looks like a segment directory
+ * inserted into another. Until that problems gets fixed,
+ * these checks are a workaround.
+ */
+ if (segment && segment != self && segment->type != PF_DIR_SEG)
+ PackFile_Segment_destroy(interp, segment);
+ }
if (dir->segments) {
mem_sys_free(dir->segments);
dir->segments = NULL;
+ dir->num_segments = 0;
}
}
@@ -2559,7 +2567,6 @@
#ifdef HAS_JIT
Parrot_destroy_jit(byte_code->jit_info);
#endif
- parrot_PIC_destroy(byte_code);
if (byte_code->prederef.code) {
Parrot_free_memalign(byte_code->prederef.code);
byte_code->prederef.code = NULL;
@@ -2572,7 +2579,6 @@
byte_code->fixups = NULL;
byte_code->const_table = NULL;
- byte_code->pic_index = NULL;
byte_code->debugs = NULL;
}
@@ -4807,6 +4813,8 @@
PARROT_LIB_PATH_INCLUDE);
Parrot_lib_add_path(interp, Parrot_str_append(interp, found_path, CONST_STRING(interp, "dynext/")),
PARROT_LIB_PATH_DYNEXT);
+ Parrot_lib_add_path(interp, Parrot_str_append(interp, found_path, CONST_STRING(interp, "library/")),
+ PARROT_LIB_PATH_LIBRARY);
/* Check if the file found was actually a bytecode file (.pbc extension) or
Modified: branches/gc-refactor/src/parrot_debugger.c
==============================================================================
--- branches/gc-refactor/src/parrot_debugger.c Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/parrot_debugger.c Wed Sep 16 18:24:30 2009 (r41302)
@@ -145,6 +145,7 @@
#include "../compilers/imcc/parser.h"
#include "parrot/embed.h"
#include "parrot/debugger.h"
+#include "parrot/runcore_api.h"
static void PDB_printwelcome(void);
static void PDB_run_code(PARROT_INTERP, int argc, char *argv[]);
Modified: branches/gc-refactor/src/pbc_merge.c
==============================================================================
--- branches/gc-refactor/src/pbc_merge.c Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pbc_merge.c Wed Sep 16 18:24:30 2009 (r41302)
@@ -140,19 +140,6 @@
__attribute__nonnull__(1)
__attribute__nonnull__(2);
-static void pbc_merge_pic_index(PARROT_INTERP,
- ARGMOD(pbc_merge_input **inputs),
- int num_inputs,
- ARGMOD(PackFile *pf),
- ARGMOD(PackFile_ByteCode *bc))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(4)
- __attribute__nonnull__(5)
- FUNC_MODIFIES(*inputs)
- FUNC_MODIFIES(*pf)
- FUNC_MODIFIES(*bc);
-
static void pbc_merge_write(PARROT_INTERP,
ARGMOD(PackFile *pf),
ARGIN(const char *filename))
@@ -192,11 +179,6 @@
#define ASSERT_ARGS_pbc_merge_loadpbc __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(fullname)
-#define ASSERT_ARGS_pbc_merge_pic_index __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(inputs) \
- || PARROT_ASSERT_ARG(pf) \
- || PARROT_ASSERT_ARG(bc)
#define ASSERT_ARGS_pbc_merge_write __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(pf) \
@@ -653,59 +635,6 @@
/*
-=item C<static void pbc_merge_pic_index(PARROT_INTERP, pbc_merge_input **inputs,
-int num_inputs, PackFile *pf, PackFile_ByteCode *bc)>
-
-This function merges the pic_index segments from the input PBC files.
-
-=cut
-
-*/
-
-static void
-pbc_merge_pic_index(PARROT_INTERP, ARGMOD(pbc_merge_input **inputs),
- int num_inputs, ARGMOD(PackFile *pf), ARGMOD(PackFile_ByteCode *bc))
-{
- ASSERT_ARGS(pbc_merge_pic_index)
- int i;
- PackFile_Segment *pic_index;
- size_t size;
- opcode_t cursor = 0;
- opcode_t start = 0;
- opcode_t last = 0;
-
- /* calc needed size */
- for (i = 0, size = 0; i < num_inputs; i++) {
- PackFile_Segment * const in_seg = inputs[i]->pf->cur_cs->pic_index;
- size += in_seg->size;
- }
- pic_index = PackFile_Segment_new_seg(interp,
- &pf->directory, PF_UNKNOWN_SEG, "PIC_idx_MERGED", 1);
- pic_index->data
- = (opcode_t *)mem_sys_allocate_zeroed(size * sizeof (opcode_t));
- pic_index->size = size;
-
- for (i = 0, size = 0; i < num_inputs; i++) {
- PackFile_Segment * const in_seg = inputs[i]->pf->cur_cs->pic_index;
- size_t j;
- /*
- * pic_index is 0 or an ever increasing (by 1) number
- */
- for (j = 0; j < in_seg->size; j++) {
- const opcode_t k = in_seg->data[j];
- if (k) {
- pic_index->data[cursor] = k + start;
- last = k;
- }
- cursor++;
- }
- start = last;
- }
- bc->pic_index = pic_index;
-}
-
-/*
-
=item C<static void pbc_merge_ctpointers(PARROT_INTERP, pbc_merge_input
**inputs, int num_inputs, PackFile_ByteCode *bc)>
@@ -822,7 +751,6 @@
pbc_merge_fixups(interp, inputs, num_inputs, merged, bc);
pbc_merge_debugs(interp, inputs, num_inputs, merged, bc);
- pbc_merge_pic_index(interp, inputs, num_inputs, merged, bc);
/* Walk bytecode and fix ops that reference the constants table. */
pbc_merge_ctpointers(interp, inputs, num_inputs, bc);
Deleted: branches/gc-refactor/src/pic.c
==============================================================================
--- branches/gc-refactor/src/pic.c Wed Sep 16 18:24:30 2009 (r41301)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,954 +0,0 @@
-/*
-Copyright (C) 2004-2009, Parrot Foundation.
-$Id$
-
-=head1 NAME
-
-src/pic.c - Polymorphic Inline Cache
-
-=head1 DESCRIPTION
-
-The PIC supports inline caching for MMD and object method lookups in
-prederefed run cores. Additionally opcodes that do some kind of lookup
-like C<new_p_sc> are changed to faster variants.
-
-For non-prederefed run-cores there's a less efficient variant which
-is basically:
-
- * the bytecode segment has an index per cached opcode (code->pic_index)
- * this index points into pic_store
- * TODO use the cache in opcodes
-
-=head1 OPERATION SCHEME
-
-Given this bytecode:
-
- 0 1 2 3 4 5
- +--------------+---------------+----+----+-----------------+----------+
- | infix_ic_p_p | .MMD_SUBTRACT | P5 | P6 | callmethodcc_sc | "method" |
- +--------------+---------------+----+----+-----------------+----------+
-
-In init_prederef the opcodes are replaced with prederef__, operands
-are replaced with their addresses (&) in the const table or offsets
-(+) in the register frame:
-
- 0 1 2 3 4 5
- +--------------+---------------+----+----+-----------------+----------+
- | prederef__ | .MMD_SUBTRACT | +P5| +P6| prederef__ |&"method" |
- +--------------+---------------+----+----+-----------------+----------+
-
-we have code->pic_index with an index into pic_store - the pic_index is
-half the size of the bytecode and addressed with pc_offset/2:
-
- 0 1 2
- +---+---+---+
- | 1 | | 2 |
- +---+---+---+
-
-During predereferencing the opcode gets rewritten to the PIC variant,
-the constant infix operation number is replaced with a pointer to the MIC
-in the pic_store at the index pic_index:
-
- 0 1 2 3
- +--------------------+-----+----+----+-----------------------+-----+
- | pic_infix___ic_p_p | MIC1|+P5 |+P6 | pic_callmethodcc___sc | MIC2|
- +--------------------+-----+----+----+-----------------------+-----+
-
-This can be further optimized due to static inlining:
-
- 0 1 2 3
- +--------------------+-----+----+----+-----------------------+-----+
- | pic_inline_sub_p_p | MIC1|+P5 |+P6 | pic_callmethodcc___sc | MIC2|
- +--------------------+-----+----+----+-----------------------+-----+
-
-The opcode is an opcode number for the switched core or the actual code address
-for the direct-threaded CGP core. With a little help of the JIT system we could
-also dynamicall create inlined code.
-
-Runcores with r/o (mmapped) bytecode can't be rewritten in this way, the
-lookup of the cache has to be done in the opcode itself.
-
-=head2 Functions
-
-=over 4
-
-=cut
-
-*/
-
-#include "parrot/parrot.h"
-#include "parrot/oplib/ops.h"
-#include "parrot/runcore_api.h"
-#include "pmc/pmc_fixedintegerarray.h"
-#include "pmc/pmc_continuation.h"
-#ifdef HAVE_COMPUTED_GOTO
-# include "parrot/oplib/core_ops_cgp.h"
-#endif
-
-#ifdef HAS_JIT
-# include "parrot/exec.h"
-# include "jit.h"
-#endif
-
-/* needs a Makefile dependency */
-/* #include "pmc/pmc_integer.h" */
-
-/* XXX Define this in a header file */
-extern void Parrot_Integer_i_subtract_Integer(Interp* , PMC* pmc, PMC* value);
-
-/*
- * hack to turn on inlining - just sub_p_p for mops done
- */
-
-#define ENABLE_INLINING 0
-
-/* HEADERIZER HFILE: include/parrot/pic.h */
-
-/* HEADERIZER BEGIN: static */
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-
-static int is_pic_func(PARROT_INTERP,
- ARGIN(void **pc),
- ARGOUT(Parrot_MIC *mic),
- ARGIN(Parrot_runcore_t *runcore))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- __attribute__nonnull__(4)
- FUNC_MODIFIES(*mic);
-
-static int is_pic_param(PARROT_INTERP,
- ARGIN(void **pc),
- ARGOUT(Parrot_MIC *mic),
- opcode_t op)
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- FUNC_MODIFIES(*mic);
-
-static int pass_int(PARROT_INTERP,
- ARGIN(PMC *sig),
- ARGIN(const char *src_base),
- ARGIN(const void **src),
- ARGOUT(char *dest_base),
- ARGIN(void * const *dest))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- __attribute__nonnull__(4)
- __attribute__nonnull__(5)
- __attribute__nonnull__(6)
- FUNC_MODIFIES(*dest_base);
-
-static int pass_mixed(PARROT_INTERP,
- ARGIN(PMC *sig),
- ARGIN(const char *src_base),
- ARGIN(void * const *src),
- ARGOUT(char *dest_base),
- ARGIN(void * const *dest))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- __attribute__nonnull__(4)
- __attribute__nonnull__(5)
- __attribute__nonnull__(6)
- FUNC_MODIFIES(*dest_base);
-
-static int pass_num(PARROT_INTERP,
- ARGIN(PMC *sig),
- ARGIN(const char *src_base),
- ARGIN(const void **src),
- ARGOUT(char *dest_base),
- ARGIN(void * const *dest))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- __attribute__nonnull__(4)
- __attribute__nonnull__(5)
- __attribute__nonnull__(6)
- FUNC_MODIFIES(*dest_base);
-
-static int pass_pmc(PARROT_INTERP,
- ARGIN(PMC *sig),
- ARGIN(const char *src_base),
- ARGIN(const void **src),
- ARGOUT(char *dest_base),
- ARGIN(void * const *dest))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- __attribute__nonnull__(4)
- __attribute__nonnull__(5)
- __attribute__nonnull__(6)
- FUNC_MODIFIES(*dest_base);
-
-static int pass_str(PARROT_INTERP,
- ARGIN(PMC *sig),
- ARGIN(const char *src_base),
- ARGIN(const void **src),
- ARGOUT(char *dest_base),
- ARGIN(void * const *dest))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- __attribute__nonnull__(4)
- __attribute__nonnull__(5)
- __attribute__nonnull__(6)
- FUNC_MODIFIES(*dest_base);
-
-#define ASSERT_ARGS_is_pic_func __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(pc) \
- || PARROT_ASSERT_ARG(mic) \
- || PARROT_ASSERT_ARG(runcore)
-#define ASSERT_ARGS_is_pic_param __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(pc) \
- || PARROT_ASSERT_ARG(mic)
-#define ASSERT_ARGS_pass_int __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(sig) \
- || PARROT_ASSERT_ARG(src_base) \
- || PARROT_ASSERT_ARG(src) \
- || PARROT_ASSERT_ARG(dest_base) \
- || PARROT_ASSERT_ARG(dest)
-#define ASSERT_ARGS_pass_mixed __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(sig) \
- || PARROT_ASSERT_ARG(src_base) \
- || PARROT_ASSERT_ARG(src) \
- || PARROT_ASSERT_ARG(dest_base) \
- || PARROT_ASSERT_ARG(dest)
-#define ASSERT_ARGS_pass_num __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(sig) \
- || PARROT_ASSERT_ARG(src_base) \
- || PARROT_ASSERT_ARG(src) \
- || PARROT_ASSERT_ARG(dest_base) \
- || PARROT_ASSERT_ARG(dest)
-#define ASSERT_ARGS_pass_pmc __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(sig) \
- || PARROT_ASSERT_ARG(src_base) \
- || PARROT_ASSERT_ARG(src) \
- || PARROT_ASSERT_ARG(dest_base) \
- || PARROT_ASSERT_ARG(dest)
-#define ASSERT_ARGS_pass_str __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(sig) \
- || PARROT_ASSERT_ARG(src_base) \
- || PARROT_ASSERT_ARG(src) \
- || PARROT_ASSERT_ARG(dest_base) \
- || PARROT_ASSERT_ARG(dest)
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-/* HEADERIZER END: static */
-
-
-/*
-
-=item C<void parrot_PIC_alloc_store(PackFile_ByteCode *cs, size_t n)>
-
-Initialize the PIC storage for the given code segment with the capacitiy of
-holding at least C<n> MIC entries. The PIC_store itself, room for C<n> MICs and
-some space for PICs is allocated as one piece. MICs are returned from the start
-of usable memory, PICs from the rear.
-
-=cut
-
-*/
-
-void
-parrot_PIC_alloc_store(ARGOUT(PackFile_ByteCode *cs), size_t n)
-{
- ASSERT_ARGS(parrot_PIC_alloc_store)
- Parrot_PIC_store *store;
- size_t size;
-
- /*
- * estimated 95% of calls are monomorphic, 5% are polymorphic
- * we need therefore:
- */
-#define POLYMORPHIC 0.05
- size_t poly = (size_t)(n * POLYMORPHIC) * sizeof (Parrot_PIC);
-
- if (!poly)
- poly = 2 * sizeof (Parrot_PIC);
-
- size = n * sizeof (Parrot_MIC) + poly + sizeof (Parrot_PIC_store);
-
- store = (Parrot_PIC_store *)mem_sys_allocate_zeroed(size);
- store->prev = NULL;
- cs->pic_store = store;
- store->pic = (Parrot_PIC *)((char *)store + size);
- store->usable = poly;
- store->mic = (Parrot_MIC *)((char*)store + sizeof (Parrot_PIC_store));
- store->n_mics = n;
-}
-
-/*
-
-=item C<void parrot_PIC_destroy(PackFile_ByteCode *cs)>
-
-Free memory for the PIC storage.
-
-=cut
-
-*/
-
-void
-parrot_PIC_destroy(ARGMOD(PackFile_ByteCode *cs))
-{
- ASSERT_ARGS(parrot_PIC_destroy)
- Parrot_PIC_store *store = cs->pic_store;
-
- while (store) {
- Parrot_PIC_store * const prev = store->prev;
- mem_sys_free(store);
- store = prev;
- }
-
- cs->pic_store = NULL;
-}
-
-/*
-
-=item C<int parrot_PIC_op_is_cached(int op_code)>
-
-Return true, if the opcode needs a PIC slot.
-
-=cut
-
-*/
-
-PARROT_CONST_FUNCTION
-int
-parrot_PIC_op_is_cached(int op_code)
-{
- ASSERT_ARGS(parrot_PIC_op_is_cached)
- switch (op_code) {
- case PARROT_OP_get_params_pc:
- case PARROT_OP_set_returns_pc:
- case PARROT_OP_set_args_pc:
- return 1;
- default:
- return 0;
- }
-}
-
-/*
-
-=item C<Parrot_MIC* parrot_PIC_alloc_mic(const PARROT_INTERP, size_t n)>
-
-Allocate a new MIC structure for the C<n>th cached opcode in this
-bytecode segement.
-
-=cut
-
-*/
-
-PARROT_WARN_UNUSED_RESULT
-PARROT_CANNOT_RETURN_NULL
-Parrot_MIC*
-parrot_PIC_alloc_mic(const PARROT_INTERP, size_t n)
-{
- ASSERT_ARGS(parrot_PIC_alloc_mic)
- Parrot_PIC_store * const store = interp->code->pic_store;
- PARROT_ASSERT(n < store->n_mics);
- return store->mic + n;
-}
-
-/*
-
-=item C<Parrot_PIC* parrot_PIC_alloc_pic(PARROT_INTERP)>
-
-Allocate a new PIC structure for the C<n>th cached opcode in this
-bytecode segement.
-
-=cut
-
-*/
-
-PARROT_WARN_UNUSED_RESULT
-PARROT_CANNOT_RETURN_NULL
-Parrot_PIC*
-parrot_PIC_alloc_pic(PARROT_INTERP)
-{
- ASSERT_ARGS(parrot_PIC_alloc_pic)
- Parrot_PIC_store *store = interp->code->pic_store;
- Parrot_PIC_store *new_store;
-
- if (store->usable < sizeof (Parrot_PIC)) {
- size_t size =
- (size_t)(store->n_mics * POLYMORPHIC) * sizeof (Parrot_PIC);
-
- if (size == 0)
- size = 2 * sizeof (Parrot_PIC);
-
- new_store = (Parrot_PIC_store *)
- mem_sys_allocate_zeroed(size + sizeof (Parrot_PIC_store));
- new_store->prev = store;
- interp->code->pic_store = new_store;
-
- new_store->pic = (Parrot_PIC *)((char *)new_store + size
- + sizeof (Parrot_PIC_store));
- new_store->usable = size;
-
- /* the addon store has only poly-morphic slots
- * point the monomorphic to the old store */
- new_store->mic = store->mic;
- new_store->n_mics = store->n_mics;
- store = new_store;
- }
- store->usable -= sizeof (Parrot_PIC);
- return --store->pic;
-}
-
-/*
-
-=item C<void * parrot_pic_opcode(PARROT_INTERP, INTVAL op)>
-
-=cut
-
-*/
-
-PARROT_WARN_UNUSED_RESULT
-PARROT_CAN_RETURN_NULL
-void *
-parrot_pic_opcode(PARROT_INTERP, INTVAL op)
-{
- ASSERT_ARGS(parrot_pic_opcode)
-#ifdef HAVE_COMPUTED_GOTO
- op_lib_t *cg_lib;
-#endif
- const Parrot_runcore_t *core = interp->run_core;
-
- if (PARROT_RUNCORE_PREDEREF_OPS_TEST(core)
- && !PARROT_RUNCORE_CGOTO_OPS_TEST(core))
- return (void *)op;
-#ifdef HAVE_COMPUTED_GOTO
- cg_lib = PARROT_CORE_CGP_OPLIB_INIT(1);
- return ((void **)cg_lib->op_func_table)[op];
-#else
- return NULL;
-#endif
-
-}
-
-/*
-
-=item C<static int pass_int(PARROT_INTERP, PMC *sig, const char *src_base, const
-void **src, char *dest_base, void * const *dest)>
-
-=cut
-
-*/
-
-static int
-pass_int(PARROT_INTERP, ARGIN(PMC *sig), ARGIN(const char *src_base),
- ARGIN(const void **src), ARGOUT(char *dest_base), ARGIN(void * const *dest))
-{
- ASSERT_ARGS(pass_int)
- int i;
- int n = VTABLE_elements(interp, sig);
-
- for (i = 2; n; ++i, --n) {
- const INTVAL arg = *(const INTVAL *)(src_base + ((const opcode_t*)src)[i]);
- *(INTVAL *)(dest_base + ((const opcode_t*)dest)[i]) = arg;
- }
- return i;
-}
-
-/*
-
-=item C<static int pass_num(PARROT_INTERP, PMC *sig, const char *src_base, const
-void **src, char *dest_base, void * const *dest)>
-
-=cut
-
-*/
-
-static int
-pass_num(PARROT_INTERP, ARGIN(PMC *sig), ARGIN(const char *src_base),
- ARGIN(const void **src), ARGOUT(char *dest_base), ARGIN(void * const *dest))
-{
- ASSERT_ARGS(pass_num)
- int i;
- int n = VTABLE_elements(interp, sig);
-
- for (i = 2; n; ++i, --n) {
- const FLOATVAL arg = *(const FLOATVAL *)(src_base + ((const opcode_t*)src)[i]);
- *(FLOATVAL *)(dest_base + ((const opcode_t*)dest)[i]) = arg;
- }
- return i;
-}
-
-/*
-
-=item C<static int pass_str(PARROT_INTERP, PMC *sig, const char *src_base, const
-void **src, char *dest_base, void * const *dest)>
-
-=cut
-
-*/
-
-static int
-pass_str(PARROT_INTERP, ARGIN(PMC *sig), ARGIN(const char *src_base),
- ARGIN(const void **src), ARGOUT(char *dest_base), ARGIN(void * const *dest))
-{
- ASSERT_ARGS(pass_str)
- int i;
- int n = VTABLE_elements(interp, sig);
-
- for (i = 2; n; ++i, --n) {
- STRING * const arg = *(STRING* const *)(src_base + ((const opcode_t*)src)[i]);
- *(STRING* *)(dest_base + ((const opcode_t*)dest)[i]) = arg;
- }
-
- return i;
-}
-
-/*
-
-=item C<static int pass_pmc(PARROT_INTERP, PMC *sig, const char *src_base, const
-void **src, char *dest_base, void * const *dest)>
-
-=cut
-
-*/
-
-static int
-pass_pmc(PARROT_INTERP, ARGIN(PMC *sig), ARGIN(const char *src_base),
- ARGIN(const void **src), ARGOUT(char *dest_base), ARGIN(void * const *dest))
-{
- ASSERT_ARGS(pass_pmc)
- int i;
- int n = VTABLE_elements(interp, sig);
-
- for (i = 2; n; ++i, --n) {
- PMC * const arg = *(PMC* const *)(src_base + ((const opcode_t*)src)[i]);
- *(PMC* *)(dest_base + ((const opcode_t*)dest)[i])= arg;
- }
- return i;
-}
-
-/*
-
-=item C<static int pass_mixed(PARROT_INTERP, PMC *sig, const char *src_base,
-void * const *src, char *dest_base, void * const *dest)>
-
-=cut
-
-*/
-
-static int
-pass_mixed(PARROT_INTERP, ARGIN(PMC *sig), ARGIN(const char *src_base),
- ARGIN(void * const *src), ARGOUT(char *dest_base), ARGIN(void * const *dest))
-{
- ASSERT_ARGS(pass_mixed)
- int i;
- INTVAL *bitp;
- int n = VTABLE_elements(interp, sig);
-
- ASSERT_SIG_PMC(sig);
- GETATTR_FixedIntegerArray_int_array(interp, sig, bitp);
-
- for (i = 2; n; ++i, --n) {
- const INTVAL bits = *bitp++;
- switch (bits) {
- case PARROT_ARG_INTVAL:
- {
- const INTVAL argI = *(const INTVAL *)(src_base + ((const opcode_t*)src)[i]);
- *(INTVAL *)(dest_base + ((const opcode_t*)dest)[i])= argI;
- }
- break;
- case PARROT_ARG_INTVAL|PARROT_ARG_CONSTANT:
- *(INTVAL *)(dest_base + ((const opcode_t*)dest)[i]) = (INTVAL)(src)[i];
- break;
- case PARROT_ARG_FLOATVAL:
- {
- const FLOATVAL argN = *(const FLOATVAL *)(src_base + ((const opcode_t*)src)[i]);
- *(FLOATVAL *)(dest_base + ((const opcode_t*)dest)[i])= argN;
- }
- break;
- case PARROT_ARG_FLOATVAL|PARROT_ARG_CONSTANT:
- {
- const FLOATVAL argN = *(const FLOATVAL*)(src)[i];
- *(FLOATVAL *)(dest_base + ((const opcode_t*)dest)[i])= argN;
- }
- break;
- case PARROT_ARG_STRING:
- {
- STRING *argS = *(STRING * const *)(src_base + ((const opcode_t *)src)[i]);
-
- if (argS && PObj_constant_TEST(argS))
- argS = Parrot_str_new_COW(interp, argS);
-
- *(STRING **)(dest_base + ((const opcode_t*)dest)[i]) = argS;
- }
- break;
- case PARROT_ARG_STRING|PARROT_ARG_CONSTANT:
- {
- STRING *argS = (STRING *)(src)[i];
- if (argS && PObj_constant_TEST(argS))
- argS = Parrot_str_new_COW(interp, argS);
- *(STRING **)(dest_base + ((const opcode_t *)dest)[i]) = argS;
- }
- break;
- case PARROT_ARG_PMC:
- {
- PMC* const argP = *(PMC * const *)(src_base + ((const opcode_t*)src)[i]);
- *(PMC* *)(dest_base + ((const opcode_t*)dest)[i])= argP;
- }
- break;
- case PARROT_ARG_PMC|PARROT_ARG_CONSTANT:
- {
- PMC* const argP = (PMC*)(src)[i];
- *(PMC* *)(dest_base + ((const opcode_t*)dest)[i])= argP;
- }
- break;
- default:
- Parrot_ex_throw_from_c_args(interp, NULL, 1,
- "bogus signature 0x%x", bits);
- break;
- }
- }
- return i;
-}
-
-/*
-
-=item C<int parrot_pic_check_sig(PARROT_INTERP, PMC *sig1, PMC *sig2, int
-*type)>
-
-return argument count and type of the signature or -1 if not pic-able
-the type PARROT_ARG_CONSTANT stands for mixed types or constants
-
-=cut
-
-*/
-
-PARROT_WARN_UNUSED_RESULT
-int
-parrot_pic_check_sig(PARROT_INTERP, ARGIN(PMC *sig1), ARGIN(PMC *sig2),
- ARGOUT(int *type))
-{
- ASSERT_ARGS(parrot_pic_check_sig)
- int i, n, t0;
-
- ASSERT_SIG_PMC(sig1);
- ASSERT_SIG_PMC(sig2);
-
- n = VTABLE_elements(interp, sig1);
-
- if (n != VTABLE_elements(interp, sig2))
- return -1;
-
- if (!n) {
- *type = 0;
- return 0;
- }
-
- for (i = 0; i < n; ++i) {
- int t1 = VTABLE_get_integer_keyed_int(interp, sig1, i);
- int t2 = VTABLE_get_integer_keyed_int(interp, sig2, i);
-
- if (i) {
- t0 = 0;
- }
- else {
- t0 = t1 & PARROT_ARG_TYPE_MASK;
- *type = t0;
- }
-
- if (t1 & PARROT_ARG_CONSTANT) {
- *type = PARROT_ARG_CONSTANT;
- t1 &= ~PARROT_ARG_CONSTANT;
- }
-
- if (t1 & ~PARROT_ARG_TYPE_MASK)
- return -1;
-
- if (t2 & PARROT_ARG_CONSTANT) {
- *type = PARROT_ARG_CONSTANT;
- t2 &= ~PARROT_ARG_CONSTANT;
- }
-
- if (t2 & ~PARROT_ARG_TYPE_MASK)
- return -1;
-
- if (t2 != t1)
- return -1;
-
- if (t1 != t0)
- *type = PARROT_ARG_CONSTANT;
- }
-
- return n;
-}
-
-/*
-
-=item C<static int is_pic_param(PARROT_INTERP, void **pc, Parrot_MIC *mic,
-opcode_t op)>
-
-=cut
-
-*/
-
-static int
-is_pic_param(PARROT_INTERP, ARGIN(void **pc), ARGOUT(Parrot_MIC *mic), opcode_t op)
-{
- ASSERT_ARGS(is_pic_param)
- PMC *sig2;
- PMC *caller_ctx;
- opcode_t *args;
- PMC * const sig1 = (PMC *)(pc[1]);
- PMC *ctx = CURRENT_CONTEXT(interp);
- int type = 0;
-
- /* check params */
-
- if (op == PARROT_OP_set_returns_pc) {
- PMC * const ccont = Parrot_pcc_get_continuation(interp, ctx);
- if (!PMC_cont(ccont)->address)
- return 0;
- caller_ctx = PMC_cont(ccont)->to_ctx;
- args = Parrot_pcc_get_results(interp, caller_ctx);
- }
- else {
- caller_ctx = Parrot_pcc_get_caller_ctx(interp, ctx);
- args = interp->current_args;
- }
-
- if (args) {
- const INTVAL const_nr = args[1];
- int n;
-
- /* check current_args signature */
- sig2 = Parrot_pcc_get_pmc_constant(interp, caller_ctx, const_nr);
- n = parrot_pic_check_sig(interp, sig1, sig2, &type);
-
- if (n == -1)
- return 0;
- }
- else {
- if (VTABLE_elements(interp, sig1) == 0) {
- sig2 = NULL;
- type = 0;
- }
- else
- return 0;
- }
-
- switch (type) {
- case PARROT_ARG_INTVAL:
- mic->lru.f.real_function = (funcptr_t)pass_int;
- break;
- case PARROT_ARG_FLOATVAL:
- mic->lru.f.real_function = (funcptr_t)pass_num;
- break;
- case PARROT_ARG_STRING:
- mic->lru.f.real_function = (funcptr_t)pass_str;
- break;
- case PARROT_ARG_PMC:
- mic->lru.f.real_function = (funcptr_t)pass_pmc;
- break;
- case PARROT_ARG_CONSTANT:
- mic->lru.f.real_function = (funcptr_t)pass_mixed;
- break;
- default:
- return 0;
- }
-
- mic->m.sig = sig1;
-
- /* remember this sig2 - it has to match the other end at call time */
- mic->lru.u.signature = sig2;
-
- return 1;
-}
-
-
-/*
-
-=item C<static int is_pic_func(PARROT_INTERP, void **pc, Parrot_MIC *mic,
-Parrot_runcore_t *runcore)>
-
-=cut
-
-*/
-
-static int
-is_pic_func(PARROT_INTERP, ARGIN(void **pc), ARGOUT(Parrot_MIC *mic),
- ARGIN(Parrot_runcore_t *runcore))
-{
- ASSERT_ARGS(is_pic_func)
- /*
- * if we have these opcodes
- *
- * set_args '..' ...
- * set_p_pc Px, PFunx
- * get_results '..' ...
- * invokecc_p Px
- *
- * and all args are matching the called sub and we don't have
- * too many args, and only INTVAL or FLOATVAL, the
- * whole sequence is replaced by the C<callr> pic opcode.
- *
- * Oh, I forgot to mention - the to-be-called C function is of
- * course compiled on-the-fly by the JIT compiler ;)
- *
- * pc is at set_args
- */
-
- PMC *sub, *sig_results;
- opcode_t *op, n;
- int flags;
-
- PMC * const ctx = CURRENT_CONTEXT(interp);
- PMC * const sig_args = (PMC *)(pc[1]);
-
- ASSERT_SIG_PMC(sig_args);
- n = VTABLE_elements(interp, sig_args);
- interp->current_args = (opcode_t*)pc + Parrot_pcc_get_pred_offset(interp, ctx);
- pc += 2 + n;
- op = (opcode_t*)pc + Parrot_pcc_get_pred_offset(interp, ctx);
-
- if (*op != PARROT_OP_set_p_pc)
- return 0;
-
- do_prederef(pc, interp, runcore);
- sub = (PMC *)(pc[2]);
-
- PARROT_ASSERT(PObj_is_PMC_TEST(sub));
-
- if (sub->vtable->base_type != enum_class_Sub)
- return 0;
-
- pc += 3; /* results */
- op = (opcode_t *)pc + Parrot_pcc_get_pred_offset(interp, ctx);
-
- if (*op != PARROT_OP_get_results_pc)
- return 0;
-
- do_prederef(pc, interp, runcore);
- sig_results = (PMC *)(pc[1]);
- ASSERT_SIG_PMC(sig_results);
-
- Parrot_pcc_set_results(interp, ctx, (opcode_t *)pc + Parrot_pcc_get_pred_offset(interp, ctx));
- if (!parrot_pic_is_safe_to_jit(interp, sub, sig_args, sig_results, &flags))
- return 0;
-
- mic->lru.f.real_function = parrot_pic_JIT_sub(interp, sub, flags);
- mic->m.sig = sig_args;
-
- return 1;
-}
-
-/*
-
-=item C<void parrot_PIC_prederef(PARROT_INTERP, opcode_t op, void **pc_pred,
-Parrot_runcore_t *core)>
-
-Define either the normal prederef function or the PIC stub, if PIC for
-this opcode function is available. Called from C<do_prederef>.
-
-=cut
-
-*/
-
-void
-parrot_PIC_prederef(PARROT_INTERP, opcode_t op, ARGOUT(void **pc_pred),
- ARGIN(Parrot_runcore_t *core))
-{
- ASSERT_ARGS(parrot_PIC_prederef)
- op_func_t * const prederef_op_func = interp->op_lib->op_func_table;
- opcode_t * const cur_opcode = (opcode_t *)pc_pred;
- Parrot_MIC *mic = NULL;
-
- if (parrot_PIC_op_is_cached(op)) {
- const PackFile_ByteCode * const cs = interp->code;
- size_t n = cur_opcode
- - (opcode_t *)cs->prederef.code;
-
- /*
- * pic_index is half the size of the code
- * XXX if it's there - pbc_merge needs updates
- */
- PARROT_ASSERT(cs->pic_index);
- n = cs->pic_index->data[n / 2];
- mic = parrot_PIC_alloc_mic(interp, n);
- }
-
- switch (op) {
- case PARROT_OP_get_params_pc:
- if (is_pic_param(interp, pc_pred, mic, op)) {
- pc_pred[1] = (void *)mic;
- op = PARROT_OP_pic_get_params___pc;
- }
- break;
- case PARROT_OP_set_returns_pc:
- if (is_pic_param(interp, pc_pred, mic, op)) {
- pc_pred[1] = (void *)mic;
- op = PARROT_OP_pic_set_returns___pc;
- }
- break;
- case PARROT_OP_set_args_pc:
- if (is_pic_func(interp, pc_pred, mic, core)) {
- pc_pred[1] = (void *)mic;
- op = PARROT_OP_pic_callr___pc;
- }
- break;
- default:
- break;
- }
-
- /* rewrite opcode */
- if (PARROT_RUNCORE_PREDEREF_OPS_TEST(core)
- && !PARROT_RUNCORE_CGOTO_OPS_TEST(core))
- *pc_pred = (void **)op;
- else
- *pc_pred = ((void **)prederef_op_func)[op];
-}
-
-/*
-
-=item C<void parrot_pic_find_infix_v_pp(PARROT_INTERP, PMC *left, PMC *right,
-Parrot_MIC *mic, opcode_t *cur_opcode)>
-
-=cut
-
-*/
-
-void
-parrot_pic_find_infix_v_pp(PARROT_INTERP, ARGIN(PMC *left), ARGIN(PMC *right),
- ARGOUT(Parrot_MIC *mic), ARGOUT(opcode_t *cur_opcode))
-{
- ASSERT_ARGS(parrot_pic_find_infix_v_pp)
- /* unused; deprecated */
-}
-
-/*
-
-=back
-
-=head1 AUTHOR
-
-Leopold Toetsch with many hints from Ken Fox.
-
-=head1 SEE ALSO
-
-L<src/multidispatch.c>, L<src/object.c>, L<src/interp/interpreter.c>,
-L<ops/core_ops_cgp.c>, L<include/parrot/pic.h>, L<ops/pic.ops>
-
-=cut
-
-*/
-
-
-/*
- * Local variables:
- * c-file-style: "parrot"
- * End:
- * vim: expandtab shiftwidth=4:
- */
Deleted: branches/gc-refactor/src/pic_jit.c
==============================================================================
--- branches/gc-refactor/src/pic_jit.c Wed Sep 16 18:24:30 2009 (r41301)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,605 +0,0 @@
-/*
-Copyright (C) 2006-2009, Parrot Foundation.
-$Id$
-
-=head1 NAME
-
-src/pic_jit.c - Polymorphic Inline Cache to JIT compilation
-
-=head1 DESCRIPTION
-
-Some statically known and simple subroutines are replaced by
-their JITted variants, if
-
- - JIT is supported and can JIT subroutines
- - arguments passing is simple
- - the code is fully JITtable
- - and more such checks
-
-TODO:
-
- - save jit_info in sub
- - check for multiple calls to the same sub
- either reuse code or create new
- - handle void calls/returns
-
-=head2 Functions
-
-=over 4
-
-=cut
-
-*/
-
-#include "parrot/parrot.h"
-#include "parrot/oplib/ops.h"
-#include "pmc/pmc_sub.h"
-#include "parrot/runcore_api.h"
-
-/* HEADERIZER HFILE: include/parrot/pic.h */
-
-/* HEADERIZER BEGIN: static */
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-
-PARROT_WARN_UNUSED_RESULT
-static int args_match_params(PARROT_INTERP,
- ARGIN(PMC *sig_args),
- ARGIN(const PackFile_ByteCode *seg),
- ARGIN(const opcode_t *start))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- __attribute__nonnull__(4);
-
-PARROT_WARN_UNUSED_RESULT
-static int call_is_safe(PARROT_INTERP,
- ARGIN(PMC *sub_pmc),
- ARGMOD(opcode_t **set_args))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- FUNC_MODIFIES(*set_args);
-
-PARROT_WARN_UNUSED_RESULT
-static int jit_can_compile_sub(PARROT_INTERP, ARGIN(PMC *sub_pmc))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2);
-
-PARROT_WARN_UNUSED_RESULT
-static int ops_jittable(PARROT_INTERP,
- ARGIN(PMC *sub),
- ARGIN(PMC *sig_results),
- ARGIN(const PackFile_ByteCode *seg),
- ARGIN(opcode_t *pc),
- ARGIN(const opcode_t *end),
- ARGOUT(int *flags))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- __attribute__nonnull__(4)
- __attribute__nonnull__(5)
- __attribute__nonnull__(6)
- __attribute__nonnull__(7)
- FUNC_MODIFIES(*flags);
-
-PARROT_WARN_UNUSED_RESULT
-PARROT_CAN_RETURN_NULL
-static opcode_t * pic_test_func(PARROT_INTERP,
- SHIM(INTVAL *sig_bits),
- ARGOUT(void **args))
- __attribute__nonnull__(1)
- __attribute__nonnull__(3)
- FUNC_MODIFIES(*args);
-
-PARROT_WARN_UNUSED_RESULT
-static int returns_match_results(PARROT_INTERP,
- ARGIN(PMC *sig_ret),
- ARGIN(PMC *sig_result))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3);
-
-#define ASSERT_ARGS_args_match_params __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(sig_args) \
- || PARROT_ASSERT_ARG(seg) \
- || PARROT_ASSERT_ARG(start)
-#define ASSERT_ARGS_call_is_safe __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(sub_pmc) \
- || PARROT_ASSERT_ARG(set_args)
-#define ASSERT_ARGS_jit_can_compile_sub __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(sub_pmc)
-#define ASSERT_ARGS_ops_jittable __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(sub) \
- || PARROT_ASSERT_ARG(sig_results) \
- || PARROT_ASSERT_ARG(seg) \
- || PARROT_ASSERT_ARG(pc) \
- || PARROT_ASSERT_ARG(end) \
- || PARROT_ASSERT_ARG(flags)
-#define ASSERT_ARGS_pic_test_func __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(args)
-#define ASSERT_ARGS_returns_match_results __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(sig_ret) \
- || PARROT_ASSERT_ARG(sig_result)
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-/* HEADERIZER END: static */
-
-
-#ifdef HAVE_COMPUTED_GOTO
-# include "parrot/oplib/core_ops_cgp.h"
-#endif
-
-#ifdef HAS_JIT
-# include "parrot/exec.h"
-# include "jit.h"
-
-extern const jit_arch_info *
-Parrot_jit_init(PARROT_INTERP);
-
-
-# ifdef PIC_TEST
-/*
- * just for testing the whole scheme ...
-
-
-.sub main :main
- .local int i
- i = 32
- i = __pic_test(i, 10)
- print i
- print "\n"
-.end
-.sub __pic_test
- .param int i
- .param int j
- $I0 = i + j
- .return ($I0)
-.end
-... prints 42, if PIC_TEST is 1, because the C function is called
- with cgp and switch runcores.
-*/
-
-/*
-
-=item C<static opcode_t * pic_test_func(PARROT_INTERP, INTVAL *sig_bits, void
-**args)>
-
-Determines whether the given subroutine C<sub> can be JIT'd. Counts the
-number of registers used by the sub, and returns C<0> if more registers
-are used then JIT supports. Returns 1 if it does not use too many registers.
-
-=cut
-
-*/
-
-PARROT_WARN_UNUSED_RESULT
-PARROT_CAN_RETURN_NULL
-static opcode_t *
-pic_test_func(PARROT_INTERP, SHIM(INTVAL *sig_bits), ARGOUT(void **args))
-{
- ASSERT_ARGS(pic_test_func)
- INTVAL * const result = (INTVAL*) args[0];
- INTVAL const i = (INTVAL) args[1];
- INTVAL const j = (INTVAL) args[2];
-
- *result = i + j;
-
- return args[3];
-}
-# endif
-
-/*
-
-=item C<static int jit_can_compile_sub(PARROT_INTERP, PMC *sub_pmc)>
-
-Determines whether the given subroutine C<sub> can be JIT'd. Counts the
-number of registers used by the sub, and returns C<0> if more registers
-are used then JIT supports. Returns 1 if it does not use too many registers.
-
-=cut
-
-*/
-
-PARROT_WARN_UNUSED_RESULT
-static int
-jit_can_compile_sub(PARROT_INTERP, ARGIN(PMC *sub_pmc))
-{
- ASSERT_ARGS(jit_can_compile_sub)
- const jit_arch_info * const info = Parrot_jit_init(interp);
- const jit_arch_regs * const regs = info->regs + JIT_CODE_SUB_REGS_ONLY;
- INTVAL *n_regs_used;
- Parrot_Sub_attributes *sub;
-
- PMC_get_sub(interp, sub_pmc, sub);
- n_regs_used = sub->n_regs_used;
-
- /* if the sub is using more regs than the arch has
- * we don't JIT it at all
- */
- if (n_regs_used[REGNO_INT] > regs->n_mapped_I)
- return 0;
-
- if (n_regs_used[REGNO_NUM] > regs->n_mapped_F)
- return 0;
-
- /* if the Sub is using S regs, we can't JIT it yet */
- if (n_regs_used[REGNO_STR])
- return 0;
-
- /* if the Sub is using more than 1 P reg, we can't JIT it yet
- * the P reg could be a (recursive) call to a sub
- */
- if (n_regs_used[REGNO_PMC] > 1)
- return 0;
-
- return 1;
-}
-
-
-/*
-
-=item C<static int args_match_params(PARROT_INTERP, PMC *sig_args, const
-PackFile_ByteCode *seg, const opcode_t *start)>
-
-Returns C<1> if the passed arguments match the subroutine's parameter list.
-Returns C<0> otherwise.
-
-=cut
-
-*/
-
-PARROT_WARN_UNUSED_RESULT
-static int
-args_match_params(PARROT_INTERP, ARGIN(PMC *sig_args), ARGIN(const PackFile_ByteCode *seg),
- ARGIN(const opcode_t *start))
-{
- ASSERT_ARGS(args_match_params)
- PMC *sig_params;
- int n, type;
-
- if (*start != PARROT_OP_get_params_pc)
- return 0;
-
- sig_params = seg->const_table->constants[start[1]]->u.key;
-
- /* verify that we actually can pass arguments */
- ASSERT_SIG_PMC(sig_params);
-
- n = parrot_pic_check_sig(interp, sig_args, sig_params, &type);
-
- /* arg count mismatch */
- if (n == -1)
- return 0;
-
- /* no args - this would be safe, if the JIT code could already
- * deal with no args
- * TODO
- */
- if (!n)
- return 0;
-
- switch (type & ~PARROT_ARG_CONSTANT) {
- case PARROT_ARG_INTVAL:
- case PARROT_ARG_FLOATVAL:
- return 1;
- default:
- return 0;
- }
-}
-
-/*
-
-=item C<static int returns_match_results(PARROT_INTERP, PMC *sig_ret, PMC
-*sig_result)>
-
-Returns 1 if the return values match the returned results. Returns C<0>
-otherwise.
-
-=cut
-
-*/
-
-PARROT_WARN_UNUSED_RESULT
-static int
-returns_match_results(PARROT_INTERP, ARGIN(PMC *sig_ret), ARGIN(PMC *sig_result))
-{
- ASSERT_ARGS(returns_match_results)
- int type;
- const int n = parrot_pic_check_sig(interp, sig_ret, sig_result, &type);
-
- /* arg count mismatch */
- if (n == -1)
- return 0;
-
- /* no args - this would be safe, if the JIT code could already
- * deal with no args
- * TODO
- */
- if (!n)
- return 0;
-
- switch (type & ~PARROT_ARG_CONSTANT) {
- case PARROT_ARG_INTVAL:
- case PARROT_ARG_FLOATVAL:
- return 1;
- default:
- return 0;
- }
-}
-
-/*
-
-=item C<static int call_is_safe(PARROT_INTERP, PMC *sub_pmc, opcode_t
-**set_args)>
-
-Returns C<1> if the passed arguments match the subroutine's parameter list.
-Returns C<0> otherwise.
-
-=cut
-
-*/
-
-PARROT_WARN_UNUSED_RESULT
-static int
-call_is_safe(PARROT_INTERP, ARGIN(PMC *sub_pmc), ARGMOD(opcode_t **set_args))
-{
- ASSERT_ARGS(call_is_safe)
- PMC *called, *sig_results;
- Parrot_Sub_attributes *sub;
- PMC *sig_args;
- opcode_t *pc = *set_args;
-
- PMC_get_sub(interp, sub_pmc, sub);
- sig_args = sub->seg->const_table->constants[pc[1]]->u.key;
-
- /* ignore the signature for now */
- pc += 2 + VTABLE_elements(interp, sig_args);
-
- if (*pc != PARROT_OP_set_p_pc)
- return 0;
-
- called = sub->seg->const_table->constants[pc[2]]->u.key;
-
- /* we can JIT just recursive subs for now */
- if (called != sub_pmc)
- return 0;
-
- pc += 3;
-
- if (*pc != PARROT_OP_get_results_pc)
- return 0;
-
- sig_results = sub->seg->const_table->constants[pc[1]]->u.key;
- pc += 2 + VTABLE_elements(interp, sig_results);
-
- if (*pc != PARROT_OP_invokecc_p)
- return 0;
-
- pc += 2;
- *set_args = pc;
-
- return 1;
-}
-
-/*
-
-=item C<static int ops_jittable(PARROT_INTERP, PMC *sub, PMC *sig_results, const
-PackFile_ByteCode *seg, opcode_t *pc, const opcode_t *end, int *flags)>
-
-Returns 1 if the return values match the returned results. Returns C<0>
-otherwise.
-
-=cut
-
-*/
-
-PARROT_WARN_UNUSED_RESULT
-static int
-ops_jittable(PARROT_INTERP, ARGIN(PMC *sub), ARGIN(PMC *sig_results),
- ARGIN(const PackFile_ByteCode *seg), ARGIN(opcode_t *pc),
- ARGIN(const opcode_t *end), ARGOUT(int *flags))
-{
- ASSERT_ARGS(ops_jittable)
- while (pc < end) {
- /* special opcodes which are handled, but not marked as JITtable */
- int i;
-
- const int op = *pc;
- const op_info_t * const op_info = interp->op_info_table + op;
- int n = op_info->op_count;
-
- switch (op) {
- case PARROT_OP_returncc:
- case PARROT_OP_get_params_pc:
- goto op_is_ok;
- break;
- case PARROT_OP_set_returns_pc:
- {
- PMC * const sig_ret = seg->const_table->constants[pc[1]]->u.key;
- if (!returns_match_results(interp, sig_ret, sig_results))
- return 0;
- }
- goto op_is_ok;
- break;
- case PARROT_OP_set_args_pc:
- /* verify call, return address after the call */
- if (!call_is_safe(interp, sub, &pc))
- return 0;
- *flags |= JIT_CODE_RECURSIVE;
- continue;
- default:
- /* non-jitted or JITted vtable */
- if (op_jit[op].extcall != 0)
- return 0;
- break;
- }
- /*
- * there are some JITted opcodes like set_s_s, which we can't
- * handle (yet)
- */
- for (i = 1; i < n; i++) {
- const int type = op_info->types[i - 1];
- switch (type) {
- case PARROT_ARG_I:
- case PARROT_ARG_N:
- case PARROT_ARG_IC:
- case PARROT_ARG_NC:
- break;
- default:
- return 0;
- }
- }
-op_is_ok:
- ADD_OP_VAR_PART(interp, seg, pc, n);
- pc += n;
- }
- return 1;
-}
-
-#endif /* HAS_JIT */
-
-
-/*
-
-=item C<int parrot_pic_is_safe_to_jit(PARROT_INTERP, PMC *sub_pmc, PMC
-*sig_args, PMC *sig_results, int *flags)>
-
-=cut
-
-*/
-
-PARROT_WARN_UNUSED_RESULT
-int
-parrot_pic_is_safe_to_jit(PARROT_INTERP, ARGIN(PMC *sub_pmc), ARGIN(PMC *sig_args),
- ARGIN(PMC *sig_results), ARGOUT(int *flags))
-{
- ASSERT_ARGS(parrot_pic_is_safe_to_jit)
-#ifdef HAS_JIT
- opcode_t *base, *start, *end;
- Parrot_Sub_attributes *sub;
-
- *flags = 0;
-
- /*
- * 0) if runcore setting doesn't contain JIT
- * forget it
- */
- if (!(PARROT_RUNCORE_JIT_OPS_TEST(interp->run_core)))
- return 0;
-
- /* 1) if the JIT system can't JIT_CODE_SUB_REGS_ONLY
- * or the sub is using too many registers
- */
- if (!jit_can_compile_sub(interp, sub_pmc))
- return 0;
-
- /*
- * 2) check if get_params is matching set_args
- */
-
- PMC_get_sub(interp, sub_pmc, sub);
- base = sub->seg->base.data;
- start = base + sub->start_offs;
- end = base + sub->end_offs;
-
- if (!args_match_params(interp, sig_args, sub->seg, start))
- return 0;
-
- /*
- * 3) verify if all opcodes are JITtable, also check set_returns
- * if it's reached
- */
- if (!ops_jittable(interp, sub_pmc, sig_results, sub->seg, start, end, flags))
- return 0;
-
- return 1;
-#else
- UNUSED(interp);
- UNUSED(sub_pmc);
- UNUSED(sig_args);
- UNUSED(sig_results);
- UNUSED(flags);
-
- return 0;
-#endif
-}
-
-/*
-
-=item C<funcptr_t parrot_pic_JIT_sub(PARROT_INTERP, PMC *sub_pmc, int flags)>
-
-=cut
-
-*/
-
-funcptr_t
-parrot_pic_JIT_sub(PARROT_INTERP, ARGIN(PMC *sub_pmc), int flags)
-{
- ASSERT_ARGS(parrot_pic_JIT_sub)
-#ifdef HAS_JIT
-# ifdef PIC_TEST
- UNUSED(interp);
- UNUSED(sub_pmc);
- return (funcptr_t) pic_test_func;
-# else
- /*
- * create JIT code - just a test
- */
- Parrot_Sub_attributes *sub;
- opcode_t *base;
- opcode_t *start;
- opcode_t *end;
- Parrot_jit_info_t *jit_info;
-
- PMC_get_sub(interp, sub_pmc, sub);
- base = sub->seg->base.data;
- start = base + sub->start_offs;
- end = base + sub->end_offs;
- /* TODO pass Sub */
-
- jit_info = parrot_build_asm(interp,
- start, end, NULL, JIT_CODE_SUB_REGS_ONLY | flags);
-
- if (!jit_info)
- return NULLfunc;
-
- return (funcptr_t) jit_info->arena.start;
-# endif
-#else
- UNUSED(interp);
- UNUSED(sub_pmc);
- UNUSED(flags);
-
- return NULLfunc;
-#endif
-}
-
-
-/*
-
-=back
-
-=head1 AUTHOR
-
-Leopold Toetsch
-
-=head1 SEE ALSO
-
-F<src/pic.c>, F<src/jit.c>, F<ops/core_ops_cgp.c>,
-F<include/parrot/pic.h>, F<ops/pic.ops>
-
-=cut
-
-*/
-
-/*
- * Local variables:
- * c-file-style: "parrot"
- * End:
- * vim: expandtab shiftwidth=4:
- */
Modified: branches/gc-refactor/src/pmc/bigint.pmc
==============================================================================
--- branches/gc-refactor/src/pmc/bigint.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pmc/bigint.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -591,40 +591,6 @@
RETURN(STRING *version);
}
-/*
-
-=item C<PMC *instantiate(PMC *sig)>
-
-Object constructor. SELF is a BigInt Class object. Return a new
-BigInt object.
-
-=cut
-
-*/
- VTABLE PMC *instantiate(PMC *sig) {
- UNUSED(sig)
- return PMCNULL;
-
- /* TODO -- actually build this thing */
-#if 0
- int argcP = REG_INT(interp, 3);
- int base;
- PMC *res;
- STRING *num;
-
- res = pmc_new(INTERP, enum_class_BigInt);
- if (!argcP) {
- return res;
- }
- base = 10;
- if (argcP == 2)
- base = VTABLE_get_integer(INTERP, REG_PMC(interp, 6));
- num = VTABLE_get_string(INTERP, REG_PMC(interp, 5));
- VTABLE_set_string_keyed_int(INTERP, res, base, num);
- return res;
-#endif
- }
-
VTABLE void init() {
bigint_init(INTERP, SELF);
PObj_custom_destroy_SET(SELF);
Modified: branches/gc-refactor/src/pmc/bignum.pmc
==============================================================================
--- branches/gc-refactor/src/pmc/bignum.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pmc/bignum.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -807,38 +807,6 @@
RETURN(STRING *version);
}
-/*
-
-=item C<PMC *instantiate(PMC *sig)>
-
-Object constructor. SELF is a BigNum Class object. Return a new
-BigNum object.
-
-=cut
-
-*/
- VTABLE PMC *instantiate(PMC *sig) {
-#ifdef PARROT_HAS_GMP
- int argcP = REG_INT(interp, 3);
- int base;
- PMC *res;
- STRING *num;
-
- res = pmc_new(INTERP, enum_class_BigNum);
- if (!argcP) {
- return res;
- }
- base = 10;
- if (argcP == 2)
- base = VTABLE_get_integer(INTERP, REG_PMC(interp, 6));
- num = VTABLE_get_string(INTERP, REG_PMC(interp, 5));
- VTABLE_set_string_keyed_int(INTERP, res, base, num);
- return res;
-#else
- return PMCNULL;
-#endif
- }
-
VTABLE void init() {
bignum_init(INTERP, SELF);
PObj_custom_destroy_SET(SELF);
Modified: branches/gc-refactor/src/pmc/boolean.pmc
==============================================================================
--- branches/gc-refactor/src/pmc/boolean.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pmc/boolean.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -25,23 +25,20 @@
/*
-=item C<PMC *instantiate(PMC *sig)>
+=item C<void init_pmc(PMC *value)>
-Object constructor. SELF is a Boolean Class object. Return a new
-C<bool> object according to the passed PMC value.
+Initialises SELF value according to the boolean value of the passed PMC.
=cut
*/
- VTABLE PMC *instantiate(PMC *sig) {
- /* XXX other types */
- const int argcP = REG_INT(interp, 3);
- PMC * const res = pmc_new(interp, enum_class_Boolean);
-
- if (argcP)
- SELF.set_bool(VTABLE_get_bool(interp, REG_PMC(interp, 5)));
-
- return PMCNULL; /* TODO */
+ VTABLE void init_pmc(PMC *value) {
+ if (!PMC_IS_NULL(value)) {
+ SELF.set_bool(VTABLE_get_bool(INTERP, value));
+ }
+ else {
+ SELF.set_bool(0);
+ }
}
/*
Modified: branches/gc-refactor/src/pmc/complex.pmc
==============================================================================
--- branches/gc-refactor/src/pmc/complex.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pmc/complex.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -224,63 +224,6 @@
/*
-=item C<PMC *instantiate(PMC *sig)>
-
-Create a new complex PMC with passed arguments according to pdd03.
-
-=cut
-
-*/
-
- VTABLE PMC *instantiate(PMC *sig) {
- return PMCNULL;
-
- /* TODO -- really build this thing */
-#if 0
- PMC *res = pmc_new(INTERP, enum_class_Complex);
- FLOATVAL re = 0.0;
- FLOATVAL im = 0.0;
- int argcI = REG_INT(interp, 1);
- int argcS = REG_INT(interp, 2);
- int argcP = REG_INT(interp, 3);
- int argcN = REG_INT(interp, 4);
-
- /*
- * we can only allow 0..2 arguments of one kind. For
- * mixed (e.g. N, P) args the order of arguments isn't fixed
- */
- if (argcP) {
- re = VTABLE_get_number(INTERP, REG_PMC(interp, 5));
-
- if (argcP == 2)
- im = VTABLE_get_number(INTERP, REG_PMC(interp, 6));
- /* TODO throw exception if argument mismatch */
- }
- else if (argcN) {
- re = REG_NUM(interp, 5);
-
- if (argcN == 2)
- im = REG_NUM(interp, 6);
- }
- else if (argcI) {
- re = REG_INT(interp, 5);
-
- if (argcI == 2)
- im = REG_INT(interp, 6);
- }
- else if (argcS == 1) {
- complex_parse_string(INTERP, &RE(res), &IM(res), REG_STR(interp, 5));
- return res;
- }
-
- RE(res) = re;
- IM(res) = im;
- return res;
-#endif
- }
-
-/*
-
=item C<opcode_t *invoke(void *next)>
Pythonic object constructor. SELF is a Complex Class object. Return a new
Modified: branches/gc-refactor/src/pmc/continuation.pmc
==============================================================================
--- branches/gc-refactor/src/pmc/continuation.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pmc/continuation.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -76,8 +76,7 @@
attrs->address = NULL;
attrs->current_results = Parrot_pcc_get_results(interp, attrs->to_ctx);
- PObj_active_destroy_SET(SELF);
- PObj_custom_mark_destroy_SETALL(SELF);
+ PObj_custom_mark_SET(SELF);
/* PANIC("don't do that"); */
/*
@@ -101,8 +100,7 @@
attrs->address = theirs->address;
attrs->current_results = Parrot_pcc_get_results(interp, attrs->to_ctx);
- PObj_active_destroy_SET(SELF);
- PObj_custom_mark_destroy_SETALL(SELF);
+ PObj_custom_mark_SET(SELF);
/* PANIC("don't do that"); */
/*
@@ -129,8 +127,10 @@
VTABLE void mark() {
Parrot_Continuation_attributes * const cc = PARROT_CONTINUATION(SELF);
- if (cc->seg)
- Parrot_gc_mark_PObj_alive(interp, (PObj *)cc->seg);
+ /* If Continuation wasn't fully constructed yet */
+ if (!cc)
+ return;
+
if (cc->to_ctx)
Parrot_gc_mark_PObj_alive(INTERP, (PObj *) cc->to_ctx);
if (cc->from_ctx)
Modified: branches/gc-refactor/src/pmc/coroutine.pmc
==============================================================================
--- branches/gc-refactor/src/pmc/coroutine.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pmc/coroutine.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -57,8 +57,9 @@
}
pmclass Coroutine extends Sub auto_attrs {
- ATTR PackFile_ByteCode *caller_seg; /* bytecode segment */
- ATTR opcode_t *address; /* next address to run - toggled each time */
+ ATTR PackFile_ByteCode *caller_seg; /* bytecode segment */
+ ATTR opcode_t *address; /* next address to run - toggled each time */
+ ATTR INTVAL yield; /* yield in process */
/*
@@ -110,6 +111,20 @@
/*
+=item C<void increment()>
+
+Signals the start of a yield.
+
+=cut
+
+*/
+
+ VTABLE void increment() {
+ SET_ATTR_yield(INTERP, SELF, 1);
+ }
+
+/*
+
=item C<opcode_t *invoke(void *next)>
Swaps the "context".
@@ -144,11 +159,8 @@
co->ctx = ctx;
- Parrot_pcc_set_caller_ctx(INTERP, ctx, caller_ctx);
PARROT_CONTINUATION(ccont)->from_ctx = ctx;
Parrot_pcc_set_sub(INTERP, ctx, SELF);
- Parrot_pcc_set_HLL(interp, ctx, co->HLL_id);
- Parrot_pcc_set_namespace(INTERP, ctx, co->namespace_stash);
Parrot_pcc_set_continuation(INTERP, ctx, ccont);
Parrot_pcc_set_object(interp, ctx, PMCNULL);
INTERP->current_object = PMCNULL;
@@ -189,6 +201,12 @@
else {
PMC * const ccont = Parrot_pcc_get_continuation(INTERP, co->ctx);
PMC * const ctx = PARROT_CONTINUATION(ccont)->to_ctx;
+ INTVAL yield;
+ GET_ATTR_yield(INTERP, SELF, yield);
+ if (! yield)
+ Parrot_ex_throw_from_c_args(INTERP, NULL, CONTROL_ERROR,
+ "Cannot resume dead coroutine.");
+ SET_ATTR_yield(INTERP, SELF, 0);
PObj_get_FLAGS(SELF) &= ~SUB_FLAG_CORO_FF;
/* switch back to last remembered code seg and context */
@@ -200,7 +218,8 @@
the "Call an exited coroutine" case in t/pmc/coroutine.t; the
problem is that the defunct coroutine yields up one more
result before we get here. -- rgr, 7-Oct-06.
- */
+ * This may be unneeded after the yield fix, see TT #1003
+ */
Parrot_ex_throw_from_c_args(INTERP, NULL, CONTROL_ERROR,
"Cannot resume dead coroutine.");
}
Modified: branches/gc-refactor/src/pmc/cpointer.pmc
==============================================================================
--- branches/gc-refactor/src/pmc/cpointer.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pmc/cpointer.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -64,7 +64,7 @@
SET_ATTR_pointer(INTERP, SELF, NULL);
SET_ATTR_sig(INTERP, SELF, NULL);
- PObj_custom_mark_destroy_SETALL(SELF);
+ PObj_custom_mark_SET(SELF);
}
/*
@@ -103,19 +103,6 @@
/*
-=item C<void destroy()>
-
-Destroys the PMC and frees all allocated memory.
-
-=cut
-
-*/
-
- VTABLE void destroy() {
- }
-
-/*
-
=item C<PMC *clone()>
Creates and returns a clone of the pointer.
@@ -126,8 +113,16 @@
VTABLE PMC *clone() {
PMC * const dest = pmc_new_noinit(INTERP, SELF->vtable->base_type);
+ void *ptr;
+ STRING *sig;
+
+ GET_ATTR_pointer(INTERP, SELF, ptr);
+ SET_ATTR_pointer(INTERP, dest, ptr);
+
+ GET_ATTR_sig(INTERP, SELF, sig);
+ SET_ATTR_sig(INTERP, dest, sig);
+
PObj_custom_mark_SET(dest);
- PMC_data(dest) = PMC_data(SELF);
return dest;
}
Modified: branches/gc-refactor/src/pmc/eval.pmc
==============================================================================
--- branches/gc-refactor/src/pmc/eval.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pmc/eval.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -185,14 +185,25 @@
return;
}
+ /* XXX Quick and dirty fix for TT #995 */
+ if ((struct PackFile *)cur_cs == interp->initial_pf
+ || cur_cs == interp->code) {
+ SUPER();
+ return;
+ }
+
/* RT#46685 create PF API, move it there */
seg = (PackFile_Segment *)cur_cs->const_table;
- if (seg)
+ if (seg) {
PackFile_Segment_destroy(INTERP, seg);
+ cur_cs->const_table = NULL;
+ }
seg = (PackFile_Segment *)cur_cs->debugs;
- if (seg)
+ if (seg) {
PackFile_Segment_destroy(INTERP, seg);
+ cur_cs->debugs = NULL;
+ }
seg = (PackFile_Segment *)cur_cs->fixups;
if (seg) {
@@ -200,15 +211,17 @@
cur_cs->fixups = NULL;
}
- seg = cur_cs->pic_index;
- if (seg)
- PackFile_Segment_destroy(INTERP, seg);
+/* XXX Commenting out this to fix TT #995 and related problems.
+ * May leak some memory, need further revision.
seg = (PackFile_Segment *)cur_cs;
if (seg)
PackFile_Segment_destroy(INTERP, seg);
+ * XXX End of commented out section.
+ */
sub_data->seg = NULL;
+
SUPER();
}
@@ -252,10 +265,6 @@
PackFile_add_segment(INTERP, &pf->directory,
(PackFile_Segment *)seg->fixups);
- if (seg->pic_index)
- PackFile_add_segment(INTERP, &pf->directory,
- (PackFile_Segment *)seg->pic_index);
-
size = PackFile_pack_size(INTERP, pf) * sizeof (opcode_t);
/*
Modified: branches/gc-refactor/src/pmc/exception.pmc
==============================================================================
--- branches/gc-refactor/src/pmc/exception.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pmc/exception.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -84,7 +84,6 @@
VTABLE void init() {
/* Set flags for custom GC mark and destroy. */
- PObj_custom_destroy_SET(SELF);
PObj_custom_mark_SET(SELF);
SET_ATTR_severity(INTERP, SELF, EXCEPT_error);
@@ -124,7 +123,6 @@
}
/* Set flags for custom GC mark. */
- PObj_custom_destroy_SET(SELF);
PObj_custom_mark_SET(SELF);
/* Set up the core struct and default values for the exception object. */
Modified: branches/gc-refactor/src/pmc/exceptionhandler.pmc
==============================================================================
--- branches/gc-refactor/src/pmc/exceptionhandler.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pmc/exceptionhandler.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -52,8 +52,9 @@
* of an "earlier" context, which is contained in the interpreter's
* context - the stacks can only be deeper in the interpreter - so no
* mark of context is needed */
- PObj_custom_mark_destroy_SETALL(SELF);
+ PObj_custom_mark_SET(SELF);
}
+
/*
=item C<void mark()>
@@ -74,18 +75,6 @@
SUPER();
}
- VTABLE void destroy() {
- Parrot_ExceptionHandler_attributes *attrs = PARROT_EXCEPTIONHANDLER(SELF);
-
- if (attrs->handled_types){
- PObj_on_free_list_SET((PObj *) attrs->handled_types);
- }
- if (attrs->handled_types_except){
- PObj_on_free_list_SET((PObj *) attrs->handled_types_except);
- }
- SUPER();
- }
-
VTABLE PMC *clone() {
PMC * const result = SUPER();
/* This looks wrong, why wouldn't we want to mark the clone? */
Modified: branches/gc-refactor/src/pmc/fixedbooleanarray.pmc
==============================================================================
--- branches/gc-refactor/src/pmc/fixedbooleanarray.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pmc/fixedbooleanarray.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -17,12 +17,24 @@
=over 4
+=item C<static UINTVAL get_size_in_bytes(UINTVAL size)>
+
+Auxiliar function to avoid repeating the size evaluation.
+
=cut
*/
#define BITS_PER_CHAR 8
+PARROT_INLINE
+static UINTVAL
+get_size_in_bytes(UINTVAL size)
+{
+ return (size + BITS_PER_CHAR - 1) / BITS_PER_CHAR;
+}
+
+
pmclass FixedBooleanArray auto_attrs provides array {
ATTR UINTVAL size; /* # of bits this fba holds */
ATTR UINTVAL resize_threshold; /* max capacity before resizing */
@@ -32,7 +44,7 @@
=back
-=head2 Methods
+=head2 Vtable functions
=over 4
@@ -85,12 +97,11 @@
GET_ATTR_resize_threshold(INTERP, SELF, resize_threshold);
if (my_bit_array) {
- size_t size_in_bytes;
+ const size_t size_in_bytes = get_size_in_bytes(resize_threshold);
SET_ATTR_size(INTERP, dest, size);
SET_ATTR_resize_threshold(INTERP, dest, resize_threshold);
- size_in_bytes = resize_threshold / BITS_PER_CHAR;
clone_bit_array = (unsigned char*)mem_sys_allocate(size_in_bytes);
mem_sys_memcopy(clone_bit_array, my_bit_array, size_in_bytes);
@@ -317,7 +328,7 @@
*/
VTABLE void set_integer_native(INTVAL size) {
- size_t size_in_bytes;
+ const size_t size_in_bytes = get_size_in_bytes(size);
UINTVAL old_size;
GET_ATTR_size(INTERP, SELF, old_size);
@@ -326,7 +337,6 @@
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_OUT_OF_BOUNDS,
"FixedBooleanArray: Can't resize!");
- size_in_bytes = size / BITS_PER_CHAR + 1;
SET_ATTR_size(INTERP, SELF, size);
SET_ATTR_resize_threshold(INTERP, SELF, size_in_bytes * BITS_PER_CHAR);
SET_ATTR_bit_array(INTERP, SELF,
@@ -565,6 +575,12 @@
/*
+=back
+
+=head2 Methods
+
+=over 4
+
=item C<METHOD fill(INTVAL fill)>
Sets all of the entires to true if fill is a true value, otherwise
@@ -577,16 +593,14 @@
METHOD fill(INTVAL fill) {
UINTVAL size;
unsigned char * bit_array;
- size_t j;
+ size_t size_in_bytes;
GET_ATTR_bit_array(INTERP, SELF, bit_array);
GET_ATTR_size(INTERP, SELF, size);
- j = size / BITS_PER_CHAR + 1;
+ size_in_bytes = get_size_in_bytes(size);
- if (fill)
- memset(bit_array, 0xff, j);
- else
- memset(bit_array, 0, j);
+ if (size_in_bytes)
+ memset(bit_array, fill ? 0xff : 0, size_in_bytes);
}
}
Modified: branches/gc-refactor/src/pmc/fixedpmcarray.pmc
==============================================================================
--- branches/gc-refactor/src/pmc/fixedpmcarray.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pmc/fixedpmcarray.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -44,8 +44,15 @@
METHOD sort(PMC *cmp_func :optional) {
const INTVAL n = SELF.elements();
- if (n > 1)
- Parrot_quicksort(interp, (void **)PMC_array(SELF), n, cmp_func);
+ if (n > 1) {
+ /* XXX Workaround for TT #218 */
+ if (PObj_is_object_TEST(SELF)) {
+ PMC *parent = SELF.get_attr_str(CONST_STRING(interp, "proxy"));
+ Parrot_pcc_invoke_method_from_c_args(interp, parent, CONST_STRING(interp, "sort"), "P->", cmp_func);
+ }
+ else
+ Parrot_quicksort(interp, (void **)PMC_array(SELF), n, cmp_func);
+ }
}
/*
@@ -189,12 +196,10 @@
for (i = 0; i < n; ++i) {
PMC * const val = SELF.get_pmc_keyed_int(i);
+ if (i > 0)
+ res = Parrot_str_append(INTERP, res, CONST_STRING(INTERP, ", "));
res = Parrot_str_append(INTERP, res, VTABLE_get_repr(INTERP, val));
- if (n == 1)
- res = Parrot_str_append(INTERP, res, CONST_STRING(INTERP, ","));
- else if (i < n - 1)
- res = Parrot_str_append(INTERP, res, CONST_STRING(INTERP, ", "));
}
res = Parrot_str_append(INTERP, res, CONST_STRING(INTERP, ")"));
@@ -366,6 +371,10 @@
if (!size)
return;
+ if (size < 0)
+ Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_OUT_OF_BOUNDS,
+ _("FixedPMCArray: Cannot set array size to a negative number"));
+
PMC_size(SELF) = size;
data = mem_allocate_n_typed(size, PMC *);
@@ -584,7 +593,7 @@
VTABLE INTVAL is_equal(PMC *value) {
INTVAL j, n;
- if (value->vtable->base_type != enum_class_FixedPMCArray)
+ if (value->vtable->base_type != SELF->vtable->base_type)
return 0;
n = SELF.elements();
Modified: branches/gc-refactor/src/pmc/float.pmc
==============================================================================
--- branches/gc-refactor/src/pmc/float.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pmc/float.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -179,22 +179,6 @@
/*
-=item C<void set_number_same(PMC *value)>
-
-Sets the value of the number to the value of C<*value>.
-
-=cut
-
-*/
-
- VTABLE void set_number_same(PMC *value) {
- FLOATVAL fv;
- GET_ATTR_fv(INTERP, value, fv);
- SET_ATTR_fv(INTERP, SELF, fv);
- }
-
-/*
-
=item C<void set_string_native(STRING *value)>
Sets the value of the number to the value of C<*value>.
Modified: branches/gc-refactor/src/pmc/hash.pmc
==============================================================================
--- branches/gc-refactor/src/pmc/hash.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pmc/hash.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -545,7 +545,7 @@
break;
default:
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED,
- "Hash: unsupported entry_type");
+ "Hash: unsupported entry_type %d", type);
}
PARROT_HASH(SELF)->hash = new_hash;
@@ -1330,7 +1330,6 @@
for (j = 0; j < n; ++j) {
STRING * const key = VTABLE_shift_string(INTERP, iter);
PMC *item1, *item2;
- INTVAL result;
if (!VTABLE_exists_keyed_str(INTERP, value, key))
return 0;
@@ -1341,9 +1340,7 @@
if (item1 == item2)
continue;
- Parrot_mmd_multi_dispatch_from_c_args(INTERP, "is_equal",
- "PP->I", item1, item2, &result);
- if (!result)
+ if (!VTABLE_is_equal(INTERP, item1, item2))
return 0;
}
Modified: branches/gc-refactor/src/pmc/integer.pmc
==============================================================================
--- branches/gc-refactor/src/pmc/integer.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pmc/integer.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -47,7 +47,8 @@
ATTR INTVAL iv; /* the value of this Integer */
/*
-=item C<PMC instantiate(PMC *sig)>
+
+=item C<PMC init_pmc(PMC *init)>
Create a new Integer with arguments passed according to pdd03.
@@ -59,37 +60,18 @@
*/
- VTABLE PMC *instantiate(PMC *sig) {
- PMC * const ret = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
- const opcode_t * const arg_op = interp->current_args;
- INTVAL init = 0;
-
- if (VTABLE_elements(interp, sig) == 2) {
- switch (VTABLE_get_integer_keyed_int(INTERP, sig, 1)) {
- case PARROT_ARG_I:
- init = REG_INT(interp, arg_op[3]);
- break;
- case PARROT_ARG_IC:
- init = arg_op[3];
- break;
- default:
- Parrot_ex_throw_from_c_args(INTERP, NULL,
- EXCEPTION_SYNTAX_ERROR,
- "Integer.instantiate: unhandled initializer");
- break;
- }
- }
+ VTABLE void init() {
+ Parrot_Integer_attributes * const attrs =
+ (Parrot_Integer_attributes *)PMC_data(SELF);
- VTABLE_set_integer_native(INTERP, ret, init);
- return ret;
+ attrs->iv = 0;
}
-
- VTABLE void init() {
+ VTABLE void init_pmc(PMC *init) {
Parrot_Integer_attributes * const attrs =
(Parrot_Integer_attributes *)PMC_data(SELF);
- attrs->iv = 0;
+ attrs->iv = VTABLE_get_integer(INTERP, init);
}
/*
@@ -258,8 +240,6 @@
/*
-=item C<void set_integer_same(PMC *value)>
-
=item C<void set_integer_native(INTVAL value)>
Sets the value of the integer to the value of the C<Integer> C<*value>.
@@ -268,11 +248,6 @@
*/
- VTABLE void set_integer_same(PMC *value) {
- SELF.set_integer_native(VTABLE_get_integer(INTERP, value));
- }
-
-
VTABLE void set_integer_native(INTVAL value) {
SET_ATTR_iv(INTERP, SELF, value);
}
Modified: branches/gc-refactor/src/pmc/lexinfo.pmc
==============================================================================
--- branches/gc-refactor/src/pmc/lexinfo.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pmc/lexinfo.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -58,20 +58,13 @@
}
VTABLE void init_pmc(PMC *sub) {
- Hash *hash;
Parrot_LexInfo_attributes *attrs =
(Parrot_LexInfo_attributes *) PMC_data(SELF);
PARROT_ASSERT(PObj_constant_TEST(SELF));
- hash = parrot_create_hash(INTERP,
- (PARROT_DATA_TYPE)enum_hash_int,
- Hash_key_type_STRING,
- (hash_comp_fn)Parrot_str_not_equal, /* STRING compare */
- (hash_hash_key_fn)Parrot_str_to_hashval); /* hash */
-
- SELF.set_pointer(hash);
- PObj_custom_destroy_SET(SELF);
+ /* Set value type to INTVAL */
+ Parrot_PCCINVOKE(interp, SELF, CONST_STRING(INTERP, "set_value_type"), "I->", (INTVAL)enum_type_INTVAL);
}
/*
@@ -81,20 +74,12 @@
Declare a lexical variable that is an alias for a PMC register. The PIR
compiler calls this method in response to a ".lex STRING, PREG" directive.
-=item C<INTVAL elements()>
-
-Returns the number of elements in the LexInfo hash.
-
=cut
*/
METHOD declare_lex_preg(STRING *name, INTVAL preg) {
- parrot_hash_put(INTERP, (Hash *)SELF.get_pointer(), name, (void*)preg);
- }
-
- VTABLE INTVAL elements() {
- return parrot_hash_size(INTERP, (Hash *)SELF.get_pointer());
+ VTABLE_set_integer_keyed_str(INTERP, SELF, name, preg);
}
Modified: branches/gc-refactor/src/pmc/nci.pmc
==============================================================================
--- branches/gc-refactor/src/pmc/nci.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pmc/nci.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -236,6 +236,10 @@
Parrot_gc_mark_PObj_alive(interp, (PObj*)nci_info->signature);
if (nci_info->pcc_params_signature)
Parrot_gc_mark_PObj_alive(interp, (PObj*)nci_info->pcc_params_signature);
+ if (nci_info->long_signature)
+ Parrot_gc_mark_PObj_alive(interp, (PObj*)nci_info->long_signature);
+ if (nci_info->multi_sig)
+ Parrot_gc_mark_PObj_alive(interp, (PObj*)nci_info->multi_sig);
}
}
Modified: branches/gc-refactor/src/pmc/packfile.pmc
==============================================================================
--- branches/gc-refactor/src/pmc/packfile.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pmc/packfile.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -43,7 +43,7 @@
}
-pmclass Packfile {
+pmclass Packfile auto_attrs {
ATTR INTVAL wordsize;
ATTR INTVAL byteorder;
ATTR INTVAL fptype;
@@ -67,41 +67,23 @@
*/
VTABLE void init() {
Parrot_Packfile_attributes *attrs =
- mem_allocate_zeroed_typed(Parrot_Packfile_attributes);
+ PMC_data_typed(SELF, Parrot_Packfile_attributes*);
PackFile *pf;
attrs->uuid = Parrot_str_new_noinit(INTERP, enum_stringrep_one, 0);
attrs->directory = pmc_new(INTERP, enum_class_PackfileDirectory);
- PMC_data(SELF) = attrs;
/* Create dummy PackFile and copy default attributes to self */
pf = PackFile_new(interp, 0);
copy_packfile_header(interp, SELF, pf);
PackFile_destroy(interp, pf);
- PObj_custom_mark_destroy_SETALL(SELF);
+ PObj_custom_mark_SET(SELF);
}
/*
-=item C<void destroy()>
-
-Destroys the PackFile object.
-
-=cut
-
-*/
-
- VTABLE void destroy() {
- if (PARROT_PACKFILE(SELF)) {
- mem_sys_free(PARROT_PACKFILE(SELF));
- PMC_data(SELF) = NULL;
- }
- }
-
-/*
-
=item C<void mark()>
Marks the Packfile as alive.
@@ -115,7 +97,7 @@
if (attrs->uuid)
Parrot_gc_mark_PObj_alive(INTERP, (PObj *)attrs->uuid);
- if (attrs->directory)
+ if (!PMC_IS_NULL(attrs->directory))
Parrot_gc_mark_PObj_alive(INTERP, (PObj *)attrs->directory);
}
/*
Modified: branches/gc-refactor/src/pmc/packfileannotation.pmc
==============================================================================
--- branches/gc-refactor/src/pmc/packfileannotation.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pmc/packfileannotation.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -19,7 +19,7 @@
*/
-pmclass PackfileAnnotation {
+pmclass PackfileAnnotation auto_attrs {
ATTR STRING *name;
ATTR INTVAL offset;
ATTR INTVAL value_type;
@@ -40,32 +40,33 @@
VTABLE void init() {
Parrot_PackfileAnnotation_attributes * attrs =
- mem_allocate_zeroed_typed(Parrot_PackfileAnnotation_attributes);
+ PMC_data_typed(SELF, Parrot_PackfileAnnotation_attributes*);
- PObj_custom_destroy_SET(SELF);
+ PObj_custom_mark_SET(SELF);
PMC_data(SELF) = attrs;
}
/*
-=item C<void destroy()>
+=item C<void mark()>
-Destroys the PMC and frees all allocated memory.
+Marks the object as live.
=cut
*/
- VTABLE void destroy() {
+ VTABLE void mark() {
Parrot_PackfileAnnotation_attributes * attrs =
PARROT_PACKFILEANNOTATION(SELF);
- if (attrs) {
- mem_sys_free(attrs);
- PMC_data(SELF) = NULL;
- }
+ if (attrs->name)
+ Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->name);
+ if ((attrs->value_type == PF_ANNOTATION_KEY_TYPE_STR) && attrs->str_value)
+ Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->str_value);
}
+
/*
=item C<INTVAL get_offset()>
Modified: branches/gc-refactor/src/pmc/packfileannotations.pmc
==============================================================================
--- branches/gc-refactor/src/pmc/packfileannotations.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pmc/packfileannotations.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -29,7 +29,7 @@
#include "pmc_packfileannotation.h"
-pmclass PackfileAnnotations extends PackfileSegment {
+pmclass PackfileAnnotations auto_attrs extends PackfileSegment {
/* ConstantTable used for names lookup */
ATTR PMC *const_table;
@@ -47,12 +47,15 @@
*/
VTABLE void init() {
Parrot_PackfileAnnotations_attributes * attrs =
- mem_allocate_zeroed_typed(Parrot_PackfileAnnotations_attributes);
+ PMC_data_typed(SELF, Parrot_PackfileAnnotations_attributes*);
attrs->annotations = pmc_new(interp, enum_class_ResizablePMCArray);
+ /*
+ Don't initialize C<const_table>. It will be set to NULL bu auto_attrs
+ handling. And should be set to proper PMC in set_directory.
+ */
- PObj_custom_mark_destroy_SETALL(SELF);
- PMC_data(SELF) = attrs;
+ PObj_custom_mark_SET(SELF);
}
/*
@@ -69,35 +72,15 @@
Parrot_PackfileAnnotations_attributes * attrs =
PARROT_PACKFILEANNOTATIONS(SELF);
- if (attrs->const_table)
+ if (!PMC_IS_NULL(attrs->const_table))
Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->const_table);
- if (attrs->annotations)
+ if (!PMC_IS_NULL(attrs->annotations))
Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->annotations);
SUPER();
}
-/*
-
-=item C<void destroy()>
-
-Destroys the PMC and frees all allocated memory.
-
-=cut
-
-*/
-
- VTABLE void destroy() {
- Parrot_PackfileAnnotations_attributes * attrs =
- PARROT_PACKFILEANNOTATIONS(SELF);
-
- if (attrs) {
- mem_sys_free(attrs);
- PMC_data(SELF) = NULL;
- }
- }
-
/*
Modified: branches/gc-refactor/src/pmc/packfileconstanttable.pmc
==============================================================================
--- branches/gc-refactor/src/pmc/packfileconstanttable.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pmc/packfileconstanttable.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -24,7 +24,7 @@
*/
-pmclass PackfileConstantTable extends PackfileSegment {
+pmclass PackfileConstantTable auto_attrs extends PackfileSegment {
/* ResizablePMCArray for storing constants */
ATTR PMC *constants;
@@ -43,12 +43,12 @@
VTABLE void init() {
Parrot_PackfileConstantTable_attributes * attrs =
- mem_allocate_zeroed_typed(Parrot_PackfileConstantTable_attributes);
+ PMC_data_typed(SELF, Parrot_PackfileConstantTable_attributes*);
attrs->constants = pmc_new(interp, enum_class_ResizablePMCArray);
attrs->types = pmc_new(interp, enum_class_ResizableIntegerArray);
- PObj_custom_mark_destroy_SETALL(SELF);
+ PObj_custom_mark_SET(SELF);
PMC_data(SELF) = attrs;
}
@@ -66,35 +66,14 @@
Parrot_PackfileConstantTable_attributes * attrs =
PARROT_PACKFILECONSTANTTABLE(SELF);
- if (attrs->constants)
+ if (!PMC_IS_NULL(attrs->constants))
Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->constants);
- if (attrs->types)
+ if (!PMC_IS_NULL(attrs->types))
Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->types);
SUPER();
}
-/*
-
-=item C<void destroy()>
-
-Destroys the PMC and frees all allocated memory.
-
-=cut
-
-*/
-
- VTABLE void destroy() {
- Parrot_PackfileConstantTable_attributes * attrs =
- PARROT_PACKFILECONSTANTTABLE(SELF);
-
- if (attrs) {
- mem_sys_free(attrs);
- PMC_data(SELF) = NULL;
- }
- }
-
-
/*
Modified: branches/gc-refactor/src/pmc/packfiledirectory.pmc
==============================================================================
--- branches/gc-refactor/src/pmc/packfiledirectory.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pmc/packfiledirectory.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -25,7 +25,7 @@
*/
-pmclass PackfileDirectory extends PackfileSegment {
+pmclass PackfileDirectory auto_attrs extends PackfileSegment {
/* Directory is a hash of Segments */
ATTR PMC *hash;
@@ -40,12 +40,11 @@
*/
VTABLE void init() {
Parrot_PackfileDirectory_attributes * attrs =
- mem_allocate_zeroed_typed(Parrot_PackfileDirectory_attributes);
+ PMC_data_typed(SELF, Parrot_PackfileDirectory_attributes*);
attrs->hash = pmc_new(interp, enum_class_Hash);
- PObj_custom_mark_destroy_SETALL(SELF);
- PMC_data(SELF) = attrs;
+ PObj_custom_mark_SET(SELF);
}
/*
@@ -62,7 +61,7 @@
Parrot_PackfileDirectory_attributes * attrs =
PARROT_PACKFILEDIRECTORY(SELF);
- if (attrs->hash)
+ if (!PMC_IS_NULL(attrs->hash))
Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->hash);
SUPER();
Modified: branches/gc-refactor/src/pmc/packfilefixupentry.pmc
==============================================================================
--- branches/gc-refactor/src/pmc/packfilefixupentry.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pmc/packfilefixupentry.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -19,7 +19,7 @@
*/
-pmclass PackfileFixupEntry {
+pmclass PackfileFixupEntry auto_attrs {
ATTR INTVAL type;
ATTR STRING *name;
ATTR INTVAL offset;
@@ -36,12 +36,11 @@
*/
VTABLE void init() {
Parrot_PackfileFixupEntry_attributes * attrs =
- mem_allocate_zeroed_typed(Parrot_PackfileFixupEntry_attributes);
+ PMC_data_typed(SELF, Parrot_PackfileFixupEntry_attributes*);
attrs->name = Parrot_str_new_noinit(interp, enum_stringrep_one, 0);
- PObj_custom_mark_destroy_SETALL(SELF);
- PMC_data(SELF) = attrs;
+ PObj_custom_mark_SET(SELF);
}
/*
@@ -64,27 +63,6 @@
/*
-=item C<void destroy()>
-
-Destroys the PMC and frees all allocated memory.
-
-=cut
-
-*/
-
- VTABLE void destroy() {
- Parrot_PackfileFixupEntry_attributes * attrs =
- PARROT_PACKFILEFIXUPENTRY(SELF);
-
- if (attrs) {
- mem_sys_free(attrs);
- PMC_data(SELF) = NULL;
- }
- }
-
-
-/*
-
=item C<void set_pointer(void *pointer)>
Initialize from PackFile_FixupEntry pointer.
Modified: branches/gc-refactor/src/pmc/packfilefixuptable.pmc
==============================================================================
--- branches/gc-refactor/src/pmc/packfilefixuptable.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pmc/packfilefixuptable.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -24,7 +24,7 @@
*/
-pmclass PackfileFixupTable extends PackfileSegment {
+pmclass PackfileFixupTable auto_attrs extends PackfileSegment {
/* RPA of entries */
ATTR PMC *entries;
@@ -40,12 +40,11 @@
VTABLE void init() {
Parrot_PackfileFixupTable_attributes * attrs =
- mem_allocate_zeroed_typed(Parrot_PackfileFixupTable_attributes);
+ PMC_data_typed(SELF, Parrot_PackfileFixupTable_attributes*);
attrs->entries = pmc_new(interp, enum_class_ResizablePMCArray);
- PObj_custom_mark_destroy_SETALL(SELF);
- PMC_data(SELF) = attrs;
+ PObj_custom_mark_SET(SELF);
}
/*
@@ -62,7 +61,7 @@
Parrot_PackfileFixupTable_attributes * attrs =
PARROT_PACKFILEFIXUPTABLE(SELF);
- if (attrs->entries)
+ if (!PMC_IS_NULL(attrs->entries))
Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->entries);
SUPER();
@@ -70,28 +69,6 @@
/*
-=item C<void destroy()>
-
-Destroys the PMC and frees all allocated memory.
-
-=cut
-
-*/
-
- VTABLE void destroy() {
- Parrot_PackfileFixupTable_attributes * attrs =
- PARROT_PACKFILEFIXUPTABLE(SELF);
-
- if (attrs) {
- mem_sys_free(attrs);
- PMC_data(SELF) = NULL;
- }
- }
-
-
-
-/*
-
=item C<void set_pointer(void *pointer)>
Initialize from PackFile_FixupTable pointer.
Modified: branches/gc-refactor/src/pmc/packfilerawsegment.pmc
==============================================================================
--- branches/gc-refactor/src/pmc/packfilerawsegment.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pmc/packfilerawsegment.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -24,7 +24,7 @@
*/
-pmclass PackfileRawSegment extends PackfileSegment {
+pmclass PackfileRawSegment auto_attrs extends PackfileSegment {
/* Type of segment */
ATTR INTVAL type;
/* ResizableIntegerArray of opcodes */
@@ -42,13 +42,12 @@
VTABLE void init() {
Parrot_PackfileRawSegment_attributes * attrs =
- mem_allocate_zeroed_typed(Parrot_PackfileRawSegment_attributes);
+ PMC_data_typed(SELF, Parrot_PackfileRawSegment_attributes*);
attrs->opcodes = pmc_new(interp, enum_class_ResizableIntegerArray);
attrs->type = PF_BYTEC_SEG;
- PObj_custom_mark_destroy_SETALL(SELF);
- PMC_data(SELF) = attrs;
+ PObj_custom_mark_SET(SELF);
}
/*
@@ -65,33 +64,12 @@
Parrot_PackfileRawSegment_attributes * attrs =
PARROT_PACKFILERAWSEGMENT(SELF);
- if (attrs->opcodes)
+ if (!PMC_IS_NULL(attrs->opcodes))
Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->opcodes);
SUPER();
}
-/*
-
-=item C<void destroy()>
-
-Destroys the PMC and frees all allocated memory.
-
-=cut
-
-*/
-
- VTABLE void destroy() {
- Parrot_PackfileRawSegment_attributes * attrs =
- PARROT_PACKFILERAWSEGMENT(SELF);
-
- if (attrs) {
- mem_sys_free(attrs);
- PMC_data(SELF) = NULL;
- }
- }
-
-
/*
Modified: branches/gc-refactor/src/pmc/packfilesegment.pmc
==============================================================================
--- branches/gc-refactor/src/pmc/packfilesegment.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pmc/packfilesegment.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -23,7 +23,7 @@
*/
-pmclass PackfileSegment {
+pmclass PackfileSegment auto_attrs {
/*
Directory which owns this segment. Required for correct pack/unpack
Annotations.
@@ -42,12 +42,11 @@
*/
VTABLE void init() {
Parrot_PackfileSegment_attributes * attrs =
- mem_allocate_zeroed_typed(Parrot_PackfileSegment_attributes);
+ PMC_data_typed(SELF, Parrot_PackfileSegment_attributes*);
- attrs->directory = NULL;
+ attrs->directory = PMCNULL;
- PObj_custom_mark_destroy_SETALL(SELF);
- PMC_data(SELF) = attrs;
+ PObj_custom_mark_SET(SELF);
}
/*
@@ -64,32 +63,12 @@
Parrot_PackfileSegment_attributes * attrs =
PARROT_PACKFILESEGMENT(SELF);
- if (attrs->directory)
+ if (!PMC_IS_NULL(attrs->directory))
Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->directory);
}
/*
-=item C<void destroy()>
-
-Destroys the PMC and frees all allocated memory.
-
-=cut
-
-*/
-
- VTABLE void destroy() {
- Parrot_PackfileSegment_attributes * attrs =
- PARROT_PACKFILESEGMENT(SELF);
-
- if (attrs) {
- mem_sys_free(attrs);
- PMC_data(SELF) = NULL;
- }
- }
-
-/*
-
=item C<void set_pointer(void *ptr)>
Initialize PMC internals.
Modified: branches/gc-refactor/src/pmc/parrotlibrary.pmc
==============================================================================
--- branches/gc-refactor/src/pmc/parrotlibrary.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pmc/parrotlibrary.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -120,6 +120,20 @@
/*
+=item C<void *get_pointer()>
+
+Get the pointer to the shared library handle.
+
+=cut
+
+*/
+
+ VTABLE void *get_pointer() {
+ return PMC_dlhandle(SELF);
+ }
+
+/*
+
=item C<void set_pointer(void *handle)>
Set the pointer to the shared library handle.
Modified: branches/gc-refactor/src/pmc/parrotthread.pmc
==============================================================================
--- branches/gc-refactor/src/pmc/parrotthread.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pmc/parrotthread.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -63,6 +63,11 @@
INTVAL clone_flags, PMC *sub, PMC *args) {
INTVAL tid = VTABLE_get_integer(interp, thread);
+ if (PMC_IS_NULL(sub)) {
+ Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
+ "Invalid thread sub");
+ }
+
clone_interpreter(PMC_interp(thread), interp, clone_flags);
interp->flags &= ~PARROT_THR_COPY_INTERP; /* XXX */
Modified: branches/gc-refactor/src/pmc/resizablepmcarray.pmc
==============================================================================
--- branches/gc-refactor/src/pmc/resizablepmcarray.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pmc/resizablepmcarray.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -597,45 +597,6 @@
/*
-=item C<INTVAL is_equal(PMC *value)>
-
-The C<==> operation. Compares two array to hold equal elements.
-
-=cut
-
-*/
-
- VTABLE INTVAL is_equal(PMC *value) {
- INTVAL j, n;
-
- if (value->vtable->base_type != enum_class_ResizablePMCArray)
- return 0;
-
- n = SELF.elements();
-
- if (VTABLE_elements(INTERP, value) != n)
- return 0;
-
- for (j = 0; j < n; ++j) {
- PMC *item1 = SELF.get_pmc_keyed_int(j);
- PMC *item2 = VTABLE_get_pmc_keyed_int(INTERP, value, j);
- INTVAL result;
-
- if (item1 == item2)
- continue;
-
- Parrot_mmd_multi_dispatch_from_c_args(INTERP,
- "is_equal", "PP->I", item1, item2, &result);
-
- if (!result)
- return 0;
- }
-
- return 1;
- }
-
-/*
-
=item METHOD append(PMC *other)
Append the other array to this array.
Modified: branches/gc-refactor/src/pmc/resizablestringarray.pmc
==============================================================================
--- branches/gc-refactor/src/pmc/resizablestringarray.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pmc/resizablestringarray.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -38,7 +38,8 @@
VTABLE STRING *get_string_keyed_int(INTVAL key) {
STRING **str_array;
- INTVAL size = SELF.elements();
+ INTVAL size;
+ GET_ATTR_size(interp, SELF, size);
if (key < 0) {
if (key < -size)
@@ -72,7 +73,8 @@
VTABLE void set_string_keyed_int(INTVAL key, STRING *value) {
STRING **str_array;
- INTVAL size = SELF.elements();
+ INTVAL size;
+ GET_ATTR_size(interp, SELF, size);
if (key < 0) {
if (key < -size)
@@ -101,7 +103,8 @@
*/
VTABLE void push_string(STRING *value) {
- INTVAL next_idx = SELF.elements();
+ INTVAL next_idx;
+ GET_ATTR_size(interp, SELF, next_idx);
SELF.set_string_keyed_int(next_idx, value);
}
@@ -116,8 +119,9 @@
*/
VTABLE STRING *pop_string() {
- INTVAL size = SELF.elements();
STRING *value;
+ INTVAL size;
+ GET_ATTR_size(interp, SELF, size);
if (size == 0)
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_OUT_OF_BOUNDS,
@@ -213,7 +217,8 @@
else if (new_size <= resize_threshold) {
/* zero out anything that was previously allocated
* if we're growing the array */
- INTVAL old_size = SELF.elements();
+ INTVAL old_size;
+ GET_ATTR_size(interp, SELF, old_size);
if (new_size > old_size) {
INTVAL i;
for (i = old_size; i < new_size; i++)
@@ -260,8 +265,10 @@
VTABLE PMC *clone() {
PMC *copy = SUPER();
+ INTVAL size;
+ GET_ATTR_size(interp, SELF, size);
/* copy trimmed extra space */
- SET_ATTR_resize_threshold(INTERP, copy, SELF.elements());
+ SET_ATTR_resize_threshold(INTERP, copy, size);
return copy;
}
@@ -276,8 +283,9 @@
*/
VTABLE STRING *shift_string() {
- INTVAL size = SELF.elements();
STRING *value;
+ INTVAL size;
+ GET_ATTR_size(interp, SELF, size);
if (size == 0)
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_OUT_OF_BOUNDS,
Modified: branches/gc-refactor/src/pmc/scalar.pmc
==============================================================================
--- branches/gc-refactor/src/pmc/scalar.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pmc/scalar.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -96,41 +96,41 @@
*/
VTABLE void assign_pmc(PMC *value) {
- STRING * const s_int = CONST_STRING(INTERP, "Integer");
- STRING *s_num;
- STRING *s_str;
+ INTVAL self_type = VTABLE_type(INTERP, SELF);
+ INTVAL val_type = VTABLE_type(INTERP, value);
- if (SELF->vtable->base_type == enum_class_Boolean)
+ if (self_type == enum_class_Boolean)
/* doesn't morph */
- pmc_reuse(INTERP, SELF, value->vtable->base_type, 0);
+ pmc_reuse(INTERP, SELF, val_type, 0);
- if (value->vtable->base_type == enum_class_Undef) {
- pmc_reuse(INTERP, SELF, value->vtable->base_type, 0);
+ if (val_type == enum_class_Undef) {
+ pmc_reuse(INTERP, SELF, val_type, 0);
return;
}
- if (VTABLE_isa(INTERP, value, s_int)) {
+ if (VTABLE_isa(INTERP, value, CONST_STRING(INTERP, "Undef"))) {
+ pmc_reuse(INTERP, SELF, enum_class_Undef, 0);
+ return;
+ }
+
+ if (VTABLE_isa(INTERP, value, CONST_STRING(INTERP, "Integer"))) {
const INTVAL v = VTABLE_get_integer(INTERP, value);
SELF.set_integer_native(v);
return;
}
- s_num = CONST_STRING(INTERP, "Float");
-
- if (VTABLE_isa(INTERP, value, s_num)) {
+ if (VTABLE_isa(INTERP, value, CONST_STRING(INTERP, "Float"))) {
const FLOATVAL v = VTABLE_get_number(INTERP, value);
SELF.set_number_native(v);
return;
}
- s_str = CONST_STRING(INTERP, "String");
-
- if (VTABLE_isa(INTERP, value, s_str)) {
+ if (VTABLE_isa(INTERP, value, CONST_STRING(INTERP, "String"))) {
STRING * const v = VTABLE_get_string(INTERP, value);
SELF.set_string_native(v);
return;
}
- pmc_reuse(INTERP, SELF, value->vtable->base_type, 0);
+ pmc_reuse(INTERP, SELF, val_type, 0);
SELF.set_pmc(value);
}
Modified: branches/gc-refactor/src/pmc/string.pmc
==============================================================================
--- branches/gc-refactor/src/pmc/string.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pmc/string.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -256,22 +256,6 @@
/*
-=item C<VOID set_string_same(PMC *value)>
-
-Sets the value of the string to the value of
-the specified C<String> PMC.
-
-=cut
-
-*/
-
- VTABLE void set_string_same(PMC *value) {
- SET_ATTR_str_val(INTERP, SELF,
- Parrot_str_set(INTERP, SELF.get_string(), VTABLE_get_string(INTERP, value)));
- }
-
-/*
-
=item C<VOID set_pmc(PMC *value)>
Sets the value of the string to the string value of
@@ -992,8 +976,10 @@
PMC * const ret = SUPER();
GET_ATTR_str_val(INTERP, SELF, str_val);
- /* prevent wrong garbage collection */
- PObj_is_shared_SET(str_val);
+ if (!STRING_IS_NULL(str_val)) {
+ /* prevent wrong garbage collection */
+ PObj_is_shared_SET(str_val);
+ }
return ret;
}
Modified: branches/gc-refactor/src/pmc/sub.pmc
==============================================================================
--- branches/gc-refactor/src/pmc/sub.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pmc/sub.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -278,8 +278,6 @@
* create new context, place it in interpreter */
context = Parrot_set_new_context(INTERP, sub->n_regs_used);
Parrot_pcc_set_sub(interp, context, SELF);
- Parrot_pcc_set_caller_ctx(interp, context, caller_ctx);
- Parrot_pcc_set_pc(interp, context, pc);
Parrot_pcc_set_continuation(interp, context, ccont);
/* check recursion/call depth */
@@ -304,9 +302,6 @@
INTERP->current_object = NULL;
}
- Parrot_pcc_set_HLL(interp, context, sub->HLL_id);
- Parrot_pcc_set_namespace(interp, context, sub->namespace_stash);
-
/* create pad if needed
* TODO move this up in front of argument passing
* and factor out common code with coroutine pmc
Modified: branches/gc-refactor/src/pmc/undef.pmc
==============================================================================
--- branches/gc-refactor/src/pmc/undef.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pmc/undef.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -208,6 +208,22 @@
/*
+=item C<INTVAL logical_not()>
+
+Returns 1.
+
+=cut
+
+*/
+
+ VTABLE PMC *logical_not(PMC *dest) {
+ dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
+ VTABLE_set_bool(INTERP, dest, 1);
+ return dest;
+ }
+
+/*
+
=item C<void share()>
Unknown. (TODO)
Modified: branches/gc-refactor/src/pmc/unmanagedstruct.pmc
==============================================================================
--- branches/gc-refactor/src/pmc/unmanagedstruct.pmc Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pmc/unmanagedstruct.pmc Wed Sep 16 18:24:30 2009 (r41302)
@@ -502,7 +502,7 @@
if (type == enum_type_cstr) {
/* assuming 0-terminated C-string here;
* we can't use Parrot_str_to_cstring easily */
- char *cstr = value->strstart;
+ char *cstr = (char *)Buffer_bufstart(value);
*(char **)p = cstr;
}
else
Modified: branches/gc-refactor/src/pmc_freeze.c
==============================================================================
--- branches/gc-refactor/src/pmc_freeze.c Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/pmc_freeze.c Wed Sep 16 18:24:30 2009 (r41302)
@@ -38,13 +38,6 @@
/* HEADERIZER BEGIN: static */
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-static void add_pmc_next_for_GC(SHIM_INTERP,
- ARGIN(PMC *pmc),
- ARGOUT(visit_info *info))
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- FUNC_MODIFIES(*info);
-
static void add_pmc_todo_list(PARROT_INTERP,
ARGIN_NULLOK(PMC *pmc),
ARGIN(visit_info *info))
@@ -87,56 +80,11 @@
__attribute__nonnull__(1)
__attribute__nonnull__(2);
-static UINTVAL id_from_pmc(PARROT_INTERP, ARGIN(PMC* pmc))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2);
-
-PARROT_INLINE
-static int next_for_GC_seen(PARROT_INTERP,
- ARGIN_NULLOK(PMC *pmc),
- ARGIN(visit_info *info),
- ARGOUT(UINTVAL *id))
- __attribute__nonnull__(1)
- __attribute__nonnull__(3)
- __attribute__nonnull__(4)
- FUNC_MODIFIES(*id);
-
-static void op_append(PARROT_INTERP,
- ARGIN(STRING *s),
- opcode_t b,
- size_t len)
- __attribute__nonnull__(1)
- __attribute__nonnull__(2);
-
PARROT_INLINE
static void op_check_size(PARROT_INTERP, ARGIN(STRING *s), size_t len)
__attribute__nonnull__(1)
__attribute__nonnull__(2);
-static void push_ascii_integer(PARROT_INTERP, ARGIN(IMAGE_IO *io), INTVAL v)
- __attribute__nonnull__(1)
- __attribute__nonnull__(2);
-
-static void push_ascii_number(PARROT_INTERP,
- ARGIN(const IMAGE_IO *io),
- FLOATVAL v)
- __attribute__nonnull__(1)
- __attribute__nonnull__(2);
-
-static void push_ascii_pmc(PARROT_INTERP,
- ARGIN(IMAGE_IO *io),
- ARGIN(const PMC* v))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3);
-
-static void push_ascii_string(PARROT_INTERP,
- ARGIN(IMAGE_IO *io),
- ARGIN(const STRING *s))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3);
-
static void push_opcode_integer(PARROT_INTERP,
ARGIN(IMAGE_IO *io),
INTVAL v)
@@ -171,23 +119,6 @@
__attribute__nonnull__(1)
__attribute__nonnull__(2);
-static INTVAL shift_ascii_integer(SHIM_INTERP, ARGIN(IMAGE_IO *io))
- __attribute__nonnull__(2);
-
-static FLOATVAL shift_ascii_number(SHIM_INTERP, ARGIN(IMAGE_IO *io))
- __attribute__nonnull__(2);
-
-PARROT_WARN_UNUSED_RESULT
-PARROT_CAN_RETURN_NULL
-static PMC* shift_ascii_pmc(SHIM_INTERP, ARGIN(IMAGE_IO *io))
- __attribute__nonnull__(2);
-
-PARROT_WARN_UNUSED_RESULT
-PARROT_CAN_RETURN_NULL
-static STRING* shift_ascii_string(PARROT_INTERP, ARGIN(IMAGE_IO *io))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2);
-
static INTVAL shift_opcode_integer(SHIM_INTERP, ARGIN(IMAGE_IO *io))
__attribute__nonnull__(2);
@@ -206,15 +137,6 @@
__attribute__nonnull__(1)
__attribute__nonnull__(2);
-static void str_append(PARROT_INTERP,
- ARGMOD(STRING *s),
- ARGIN(const void *b),
- size_t len)
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- FUNC_MODIFIES(*s);
-
PARROT_INLINE
PARROT_CANNOT_RETURN_NULL
static PMC* thaw_create_pmc(PARROT_INTERP,
@@ -253,26 +175,12 @@
FUNC_MODIFIES(*info)
FUNC_MODIFIES(*id);
-static void visit_loop_next_for_GC(PARROT_INTERP,
- ARGIN(PMC *current),
- ARGIN(visit_info *info))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3);
-
static void visit_loop_todo_list(PARROT_INTERP,
ARGIN_NULLOK(PMC *current),
ARGIN(visit_info *info))
__attribute__nonnull__(1)
__attribute__nonnull__(3);
-static void visit_next_for_GC(PARROT_INTERP,
- ARGIN(PMC* pmc),
- ARGIN(visit_info* info))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3);
-
static void visit_todo_list(PARROT_INTERP,
ARGIN_NULLOK(PMC* pmc),
ARGIN(visit_info* info))
@@ -285,9 +193,6 @@
__attribute__nonnull__(1)
__attribute__nonnull__(3);
-#define ASSERT_ARGS_add_pmc_next_for_GC __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(pmc) \
- || PARROT_ASSERT_ARG(info)
#define ASSERT_ARGS_add_pmc_todo_list __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(info)
@@ -306,33 +211,9 @@
#define ASSERT_ARGS_ft_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(info)
-#define ASSERT_ARGS_id_from_pmc __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(pmc)
-#define ASSERT_ARGS_next_for_GC_seen __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(info) \
- || PARROT_ASSERT_ARG(id)
-#define ASSERT_ARGS_op_append __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(s)
#define ASSERT_ARGS_op_check_size __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(s)
-#define ASSERT_ARGS_push_ascii_integer __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(io)
-#define ASSERT_ARGS_push_ascii_number __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(io)
-#define ASSERT_ARGS_push_ascii_pmc __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(io) \
- || PARROT_ASSERT_ARG(v)
-#define ASSERT_ARGS_push_ascii_string __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(io) \
- || PARROT_ASSERT_ARG(s)
#define ASSERT_ARGS_push_opcode_integer __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(io)
@@ -350,15 +231,6 @@
#define ASSERT_ARGS_run_thaw __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(image)
-#define ASSERT_ARGS_shift_ascii_integer __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(io)
-#define ASSERT_ARGS_shift_ascii_number __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(io)
-#define ASSERT_ARGS_shift_ascii_pmc __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(io)
-#define ASSERT_ARGS_shift_ascii_string __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(io)
#define ASSERT_ARGS_shift_opcode_integer __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(io)
#define ASSERT_ARGS_shift_opcode_number __attribute__unused__ int _ASSERT_ARGS_CHECK = \
@@ -369,10 +241,6 @@
#define ASSERT_ARGS_shift_opcode_string __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(io)
-#define ASSERT_ARGS_str_append __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(s) \
- || PARROT_ASSERT_ARG(b)
#define ASSERT_ARGS_thaw_create_pmc __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(info)
@@ -389,17 +257,9 @@
|| PARROT_ASSERT_ARG(pmc) \
|| PARROT_ASSERT_ARG(info) \
|| PARROT_ASSERT_ARG(id)
-#define ASSERT_ARGS_visit_loop_next_for_GC __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(current) \
- || PARROT_ASSERT_ARG(info)
#define ASSERT_ARGS_visit_loop_todo_list __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(info)
-#define ASSERT_ARGS_visit_next_for_GC __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(pmc) \
- || PARROT_ASSERT_ARG(info)
#define ASSERT_ARGS_visit_todo_list __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(info)
@@ -409,319 +269,16 @@
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: static */
-/*
- * define this to 1 for testing. TODO: 1 is broken.
- */
-#ifndef FREEZE_ASCII
-# define FREEZE_ASCII 0
-#endif
-
-/* normal freeze can use next_for_GC ptrs or a seen hash */
-#define FREEZE_USE_NEXT_FOR_GC 0
-
/* when thawing a string longer then this size, we first do a GC run and then
* block GC - the system can't give us more headers */
#define THAW_BLOCK_GC_SIZE 100000
/* preallocate freeze image for aggregates with this estimation */
-#if FREEZE_ASCII
-# define FREEZE_BYTES_PER_ITEM 17
-#else
-# define FREEZE_BYTES_PER_ITEM 9
-#endif
-
-/*
-
-=head2 Image Stream Functions
-
-=over 4
-
-=item C<static void str_append(PARROT_INTERP, STRING *s, const void *b, size_t
-len)>
-
-Appends C<len> bytes from buffer C<*b> to string C<*s>.
-
-Plain ascii - for testing only:
-
-For speed reasons we mess around with the string buffers directly.
-
-No encoding of strings, no transcoding.
-
-=cut
-
-*/
-
-static void
-str_append(PARROT_INTERP, ARGMOD(STRING *s), ARGIN(const void *b), size_t len)
-{
- ASSERT_ARGS(str_append)
-
- const size_t used = s->bufused;
- const int need_free = (int)Buffer_buflen(s) - used - len;
-
- /* grow by factor 1.5 or such */
- if (need_free <= 16) {
- size_t new_size = (size_t) (Buffer_buflen(s) * 1.5);
- if (new_size < Buffer_buflen(s) - need_free + 512)
- new_size = Buffer_buflen(s) - need_free + 512;
-
- Parrot_gc_reallocate_string_storage(interp, s, new_size);
- PARROT_ASSERT(Buffer_buflen(s) - used - len >= 15);
- }
-
- mem_sys_memcopy((void *)((ptrcast_t)s->strstart + used), b, len);
-
- s->bufused += len;
- s->strlen += len;
-}
-
-
-/*
-
-=item C<static void push_ascii_integer(PARROT_INTERP, IMAGE_IO *io, INTVAL v)>
-
-Pushes an ASCII version of the integer C<v> onto the end of the C<*io>
-"stream".
-
-=cut
-
-*/
-
-static void
-push_ascii_integer(PARROT_INTERP, ARGIN(IMAGE_IO *io), INTVAL v)
-{
- ASSERT_ARGS(push_ascii_integer)
- char buffer[20];
- const size_t len = snprintf(buffer, sizeof (buffer), "%d ", (int) v);
- str_append(interp, io->image, buffer, len);
-}
-
-
-/*
-
-=item C<static void push_ascii_number(PARROT_INTERP, const IMAGE_IO *io,
-FLOATVAL v)>
-
-Pushes an ASCII version of the number C<v> onto the end of the C<*io>
-"stream".
-
-=cut
-
-*/
-
-static void
-push_ascii_number(PARROT_INTERP, ARGIN(const IMAGE_IO *io), FLOATVAL v)
-{
- ASSERT_ARGS(push_ascii_number)
- char buffer[40];
- const size_t len = snprintf(buffer, sizeof (buffer), "%g ", (double) v);
- str_append(interp, io->image, buffer, len);
-}
-
-
-/*
-
-=item C<static void push_ascii_string(PARROT_INTERP, IMAGE_IO *io, const STRING
-*s)>
-
-Pushes an ASCII version of the string C<*s> onto the end of the C<*io>
-"stream".
-
-For testing only - no encodings and such.
-
-XXX no string delimiters - so no space allowed.
-
-=cut
-
-*/
-
-static void
-push_ascii_string(PARROT_INTERP, ARGIN(IMAGE_IO *io), ARGIN(const STRING *s))
-{
- ASSERT_ARGS(push_ascii_string)
- const UINTVAL length = Parrot_str_byte_length(interp, s);
-
- /* XXX Why 4? What does that mean? */
- char * const buffer = mem_allocate_n_typed(4 * length, char);
- char *cursor = buffer;
- UINTVAL idx = 0;
-
- /* temporary--write out in UTF-8 */
- for (idx = 0; idx < length; ++idx) {
- *cursor++ = (unsigned char)Parrot_str_indexed(interp, s, idx);
- }
-
- str_append(interp, io->image, buffer, cursor - buffer);
- str_append(interp, io->image, " ", 1);
-
- mem_sys_free(buffer);
-}
-
-
-/*
-
-=item C<static void push_ascii_pmc(PARROT_INTERP, IMAGE_IO *io, const PMC* v)>
-
-Pushes an ASCII version of the PMC C<*v> onto the end of the C<*io>
-"stream".
-
-=cut
-
-*/
-
-static void
-push_ascii_pmc(PARROT_INTERP, ARGIN(IMAGE_IO *io), ARGIN(const PMC* v))
-{
- ASSERT_ARGS(push_ascii_pmc)
- char buffer[20];
- const size_t len = snprintf(buffer, sizeof (buffer), "%p ", (const void *)v);
- str_append(interp, io->image, buffer, len);
-}
-
+#define FREEZE_BYTES_PER_ITEM 9
/*
-=item C<static INTVAL shift_ascii_integer(PARROT_INTERP, IMAGE_IO *io)>
-
-Removes and returns an integer from the start of the C<*io> "stream".
-
-=cut
-
-*/
-
-static INTVAL
-shift_ascii_integer(SHIM_INTERP, ARGIN(IMAGE_IO *io))
-{
- ASSERT_ARGS(shift_ascii_integer)
-
- char * const start = (char *)io->image->strstart;
- char *p = start;
- const INTVAL i = strtoul(p, &p, 10);
-
- ++p;
- PARROT_ASSERT(p <= start + io->image->bufused);
-
- io->image->strstart = p;
- io->image->bufused -= (p - start);
- io->image->strlen -= (p - start);
-
- PARROT_ASSERT((int)io->image->bufused >= 0);
-
- return i;
-}
-
-
-/*
-
-=item C<static FLOATVAL shift_ascii_number(PARROT_INTERP, IMAGE_IO *io)>
-
-Removes and returns an number from the start of the C<*io> "stream".
-
-=cut
-
-*/
-
-static FLOATVAL
-shift_ascii_number(SHIM_INTERP, ARGIN(IMAGE_IO *io))
-{
- ASSERT_ARGS(shift_ascii_number)
-
- char * const start = (char *)io->image->strstart;
- char *p = start;
- const FLOATVAL f = (FLOATVAL) strtod(p, &p);
-
- ++p;
- PARROT_ASSERT(p <= start + io->image->bufused);
-
- io->image->strstart = p;
- io->image->bufused -= (p - start);
- io->image->strlen -= (p - start);
-
- PARROT_ASSERT((int)io->image->bufused >= 0);
-
- return f;
-}
-
-
-/*
-
-=item C<static STRING* shift_ascii_string(PARROT_INTERP, IMAGE_IO *io)>
-
-Removes and returns an string from the start of the C<*io> "stream".
-
-=cut
-
-*/
-
-PARROT_WARN_UNUSED_RESULT
-PARROT_CAN_RETURN_NULL
-static STRING*
-shift_ascii_string(PARROT_INTERP, ARGIN(IMAGE_IO *io))
-{
- ASSERT_ARGS(shift_ascii_string)
- STRING *s;
-
- char * const start = (char *)io->image->strstart;
- char *p = start;
-
- while (*p != ' ')
- ++p;
-
- ++p;
- PARROT_ASSERT(p <= start + io->image->bufused);
-
- io->image->strstart = p;
- io->image->bufused -= (p - start);
- io->image->strlen -= (p - start);
-
- PARROT_ASSERT((int)io->image->bufused >= 0);
- /* probably should be UTF-8 */
- s = string_make(interp, start, p - start - 1, "iso-8859-1", 0);
-
- return s;
-}
-
-
-/*
-
-=item C<static PMC* shift_ascii_pmc(PARROT_INTERP, IMAGE_IO *io)>
-
-Removes and returns a PMC from the start of the C<*io> "stream".
-
-=cut
-
-*/
-
-PARROT_WARN_UNUSED_RESULT
-PARROT_CAN_RETURN_NULL
-static PMC*
-shift_ascii_pmc(SHIM_INTERP, ARGIN(IMAGE_IO *io))
-{
- ASSERT_ARGS(shift_ascii_pmc)
-
- char * const start = (char *)io->image->strstart;
- char *p = start;
- const unsigned long i = strtoul(p, &p, 16);
-
- ++p;
-
- PARROT_ASSERT(p <= start + io->image->bufused);
-
- io->image->strstart = p;
- io->image->bufused -= (p - start);
- io->image->strlen -= (p - start);
-
- PARROT_ASSERT((int)io->image->bufused >= 0);
-
- return (PMC *)i;
-}
-
-
-/*
-
-=back
-
=head2 C<opcode_t> IO Functions
=over 4
@@ -761,32 +318,6 @@
/*
-=item C<static void op_append(PARROT_INTERP, STRING *s, opcode_t b, size_t len)>
-
-Appends the opcode C<b> to the string C<*s>.
-
-=cut
-
-*/
-
-static void
-op_append(PARROT_INTERP, ARGIN(STRING *s), opcode_t b, size_t len)
-{
- ASSERT_ARGS(op_append)
- char *str_pos;
-
- op_check_size(interp, s, len);
-
- str_pos = s->strstart + s->bufused;
- *((opcode_t *)(str_pos)) = b;
-
- s->bufused += len;
- s->strlen += len;
-}
-
-
-/*
-
=item C<static void push_opcode_integer(PARROT_INTERP, IMAGE_IO *io, INTVAL v)>
Pushes the integer C<v> onto the end of the C<*io> "stream".
@@ -801,8 +332,12 @@
push_opcode_integer(PARROT_INTERP, ARGIN(IMAGE_IO *io), INTVAL v)
{
ASSERT_ARGS(push_opcode_integer)
+ UINTVAL size = sizeof (opcode_t);
+ STRING *op = Parrot_str_new_init(interp, (char *)&v, size,
+ Parrot_fixed_8_encoding_ptr, Parrot_binary_charset_ptr, 0);
+
PARROT_ASSERT(sizeof (opcode_t) == sizeof (INTVAL));
- op_append(interp, io->image, (opcode_t)v, sizeof (opcode_t));
+ io->image = Parrot_str_append(interp, io->image, op);
}
@@ -878,7 +413,10 @@
push_opcode_pmc(PARROT_INTERP, ARGIN(IMAGE_IO *io), ARGIN(PMC* v))
{
ASSERT_ARGS(push_opcode_pmc)
- op_append(interp, io->image, (opcode_t)v, sizeof (opcode_t));
+ UINTVAL size = sizeof (opcode_t);
+ STRING *op = Parrot_str_new_init(interp, (char *)&v, size,
+ Parrot_fixed_8_encoding_ptr, Parrot_binary_charset_ptr, 0);
+ io->image = Parrot_str_append(interp, io->image, op);
}
@@ -1012,18 +550,6 @@
* TODO add read/write header functions, e.g. vtable->init_pmc
*/
-#if FREEZE_ASCII
-static image_funcs ascii_funcs = {
- push_ascii_integer,
- push_ascii_pmc,
- push_ascii_string,
- push_ascii_number,
- shift_ascii_integer,
- shift_ascii_pmc,
- shift_ascii_string,
- shift_ascii_number
-};
-#else
static image_funcs opcode_funcs = {
push_opcode_integer,
push_opcode_pmc,
@@ -1034,7 +560,6 @@
shift_opcode_string,
shift_opcode_number
};
-#endif
/*
@@ -1062,11 +587,7 @@
info->image_io = mem_allocate_typed(IMAGE_IO);
info->image_io->image = s = info->image;
-#if FREEZE_ASCII
- info->image_io->vtable = &ascii_funcs;
-#else
info->image_io->vtable = &opcode_funcs;
-#endif
pf = info->image_io->pf = PackFile_new(interp, 0);
@@ -1265,8 +786,8 @@
=item C<static void do_action(PARROT_INTERP, PMC *pmc, visit_info *info, int
seen, UINTVAL id)>
-Called from C<visit_next_for_GC()> and C<visit_todo_list()> to perform
-the action specified in C<< info->what >>.
+Called from C<visit_todo_list()> to perform the action specified in
+C<< info->what >>.
Currently only C<VISIT_FREEZE_NORMAL> and C<VISIT_FREEZE_AT_DESTRUCT> are
implemented.
@@ -1385,20 +906,8 @@
/* else maybe VTABLE_thaw ... but there is no other extra stuff */
-#if FREEZE_USE_NEXT_FOR_GC
- /*
- * the next_for_GC method doesn't keep track of repeated scalars
- * and such, as these are lacking the next_for_GC pointer, so
- * these are just duplicated with their data.
- * But we track these when thawing, so that we don't create dups
- */
- if (!must_have_seen) {
- /* so we must consume the bytecode */
- VTABLE_thaw(interp, pmc, info);
- }
-#else
PARROT_ASSERT(must_have_seen);
-#endif
+
*info->thaw_ptr = pmc;
return;
}
@@ -1428,92 +937,6 @@
/*
-=item C<static UINTVAL id_from_pmc(PARROT_INTERP, PMC* pmc)>
-
-Finds a PMC in an arena and returns an id (left-shifted 2 bits), based on its
-position.
-
-If not found, throws an exception.
-
-=cut
-
-*/
-
-static UINTVAL
-id_from_pmc(PARROT_INTERP, ARGIN(PMC* pmc))
-{
- ASSERT_ARGS(id_from_pmc)
- return Parrot_gc_get_pmc_index(interp, pmc) << 2;
-}
-
-
-/*
-
-=item C<static void add_pmc_next_for_GC(PARROT_INTERP, PMC *pmc, visit_info
-*info)>
-
-Remembers the PMC for later processing.
-
-=cut
-
-*/
-
-static void
-add_pmc_next_for_GC(SHIM_INTERP, ARGIN(PMC *pmc), ARGOUT(visit_info *info))
-{
- ASSERT_ARGS(add_pmc_next_for_GC)
- PMC_next_for_GC(info->mark_ptr) = pmc;
- info->mark_ptr = PMC_next_for_GC(pmc) = pmc;
-
-}
-
-
-/*
-
-=item C<static int next_for_GC_seen(PARROT_INTERP, PMC *pmc, visit_info *info,
-UINTVAL *id)>
-
-Remembers next child to visit via the C<next_for_GC pointer>. Generates a
-unique ID per PMC and freezes the ID (not the PMC address) so that in thaw, the
-hash-lookup can be replaced by an array lookup.
-
-=cut
-
-*/
-
-PARROT_INLINE
-static int
-next_for_GC_seen(PARROT_INTERP, ARGIN_NULLOK(PMC *pmc),
- ARGIN(visit_info *info), ARGOUT(UINTVAL *id))
-{
- ASSERT_ARGS(next_for_GC_seen)
- int seen = 0;
-
- if (PMC_IS_NULL(pmc)) {
- *id = 0;
- return 1;
- }
-
- /* already seen? */
- if (!PMC_IS_NULL(PMC_next_for_GC(pmc))) {
- seen = 1;
- goto skip;
- }
-
- /* put pmc at the end of the list */
- PMC_next_for_GC(info->mark_ptr) = pmc;
-
- /* make end self-referential */
- info->mark_ptr = PMC_next_for_GC(pmc) = pmc;
-
-skip:
- *id = id_from_pmc(interp, pmc);
- return seen;
-}
-
-
-/*
-
=item C<static void add_pmc_todo_list(PARROT_INTERP, PMC *pmc, visit_info
*info)>
@@ -1576,42 +999,6 @@
/*
-=item C<static void visit_next_for_GC(PARROT_INTERP, PMC* pmc, visit_info*
-info)>
-
-C<visit_child> callbacks:
-
-Checks if the PMC was seen. If not, generates an ID for it.
-
-=cut
-
-*/
-
-static void
-visit_next_for_GC(PARROT_INTERP, ARGIN(PMC* pmc), ARGIN(visit_info* info))
-{
- ASSERT_ARGS(visit_next_for_GC)
- UINTVAL id;
- const int seen = next_for_GC_seen(interp, pmc, info, &id);
- UNUSED(seen);
-
- Parrot_ex_throw_from_c_args(interp, NULL, 1, "todo convert to depth first");
- /* do_action(interp, pmc, info, seen, id); UNCOMMENT WHEN TODO IS DONE*/
- /*
- * TODO probe for class methods that override the default.
- * To avoid overhead, we could have an array[class_enums]
- * which (after first find_method) has a bit, if a user
- * callback is there.
- */
- /* UNCOMMENT WHEN TODO IS DONE
- if (!seen)
- (info->visit_action)(interp, pmc, info);
- */
-}
-
-
-/*
-
=item C<static void visit_todo_list(PARROT_INTERP, PMC* pmc, visit_info* info)>
Checks the seen PMC via the todo list.
@@ -1664,34 +1051,6 @@
/*
-=item C<static void visit_loop_next_for_GC(PARROT_INTERP, PMC *current,
-visit_info *info)>
-
-Put first item on todo list, then run as long as there are items to be
-done.
-
-=cut
-
-*/
-
-static void
-visit_loop_next_for_GC(PARROT_INTERP, ARGIN(PMC *current),
- ARGIN(visit_info *info))
-{
- ASSERT_ARGS(visit_loop_next_for_GC)
- PMC *prev = NULL;
- visit_next_for_GC(interp, current, info);
-
- while (current != prev) {
- VTABLE_visit(interp, current, info);
- prev = current;
- current = PMC_next_for_GC(current);
- }
-}
-
-
-/*
-
=item C<static void visit_loop_todo_list(PARROT_INTERP, PMC *current, visit_info
*info)>
@@ -1797,7 +1156,8 @@
else
len = FREEZE_BYTES_PER_ITEM;
- info->image = Parrot_str_new_noinit(interp, enum_stringrep_one, len);
+ info->image = Parrot_str_new_init(interp, NULL, len,
+ Parrot_fixed_8_encoding_ptr, Parrot_binary_charset_ptr, 0);
}
@@ -1808,15 +1168,11 @@
Performs thawing. C<what> indicates what to be thawed.
-Thaw could use the C<next_for_GC> pointers as todo-list too, but this
-would need 2 runs through the arenas to clean the C<next_for_GC>
-pointers.
-
For now it seems cheaper to use a list for remembering contained
aggregates. We could of course decide dynamically, which strategy to
use, e.g.: given a big image, the first thawed item is a small
aggregate. This implies, it probably contains (or some big strings) more
-nested containers, for which the C<next_for_GC> approach could be a win.
+nested containers, for which another approach could be a win.
=cut
@@ -1892,48 +1248,6 @@
=over 4
-=item C<STRING* Parrot_freeze_at_destruct(PARROT_INTERP, PMC* pmc)>
-
-This function must not consume any resources (except the image itself). It
-uses the C<next_for_GC> pointer, so it's not reentrant and must not be
-interrupted by a GC run.
-
-=cut
-
-*/
-
-PARROT_EXPORT
-PARROT_WARN_UNUSED_RESULT
-PARROT_CAN_RETURN_NULL
-STRING*
-Parrot_freeze_at_destruct(PARROT_INTERP, ARGIN(PMC* pmc))
-{
- ASSERT_ARGS(Parrot_freeze_at_destruct)
- visit_info info;
-
- Parrot_block_GC_mark(interp);
- Parrot_gc_cleanup_next_for_GC(interp);
-
- info.what = VISIT_FREEZE_AT_DESTRUCT;
- info.mark_ptr = pmc;
- info.thaw_ptr = NULL;
- info.visit_pmc_now = visit_next_for_GC;
- info.visit_pmc_later = add_pmc_next_for_GC;
-
- create_image(interp, pmc, &info);
- ft_init(interp, &info);
-
- visit_loop_next_for_GC(interp, pmc, &info);
-
- Parrot_unblock_GC_mark(interp);
- PackFile_destroy(interp, info.image_io->pf);
- mem_sys_free(info.image_io);
- return info.image;
-}
-
-
-/*
-
=item C<STRING* Parrot_freeze(PARROT_INTERP, PMC *pmc)>
Freeze using either method.
@@ -1949,13 +1263,6 @@
Parrot_freeze(PARROT_INTERP, ARGIN(PMC *pmc))
{
ASSERT_ARGS(Parrot_freeze)
-#if FREEZE_USE_NEXT_FOR_GC
- ASSERT_ARGS(Parrot_freeze)
- /*
- * we could do a GC run here before, to free resources
- */
- return Parrot_freeze_at_destruct(interp, pmc);
-#else
/*
* freeze using a todo list and seen hash
* Please note that both have to be PMCs, so that trace_system_stack
@@ -1972,7 +1279,6 @@
PackFile_destroy(interp, info.image_io->pf);
mem_sys_free(info.image_io);
return info.image;
-#endif
}
Modified: branches/gc-refactor/src/runcore/cores.c
==============================================================================
--- branches/gc-refactor/src/runcore/cores.c Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/runcore/cores.c Wed Sep 16 18:24:30 2009 (r41302)
@@ -269,14 +269,6 @@
/* HEADERIZER BEGIN: static */
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-PARROT_CAN_RETURN_NULL
-static void * init_profiling_core(PARROT_INTERP,
- ARGIN(Parrot_profiling_runcore_t *runcore),
- ARGIN(opcode_t *pc))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3);
-
PARROT_WARN_UNUSED_RESULT
PARROT_CAN_RETURN_NULL
static opcode_t * runops_cgoto_core(PARROT_INTERP,
@@ -333,24 +325,6 @@
PARROT_WARN_UNUSED_RESULT
PARROT_CAN_RETURN_NULL
-static opcode_t * runops_jit_core(PARROT_INTERP,
- ARGIN(Parrot_runcore_t *runcore),
- ARGIN(opcode_t *pc))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3);
-
-PARROT_WARN_UNUSED_RESULT
-PARROT_CAN_RETURN_NULL
-static opcode_t * runops_profiling_core(PARROT_INTERP,
- ARGIN(Parrot_profiling_runcore_t *runcore),
- ARGIN(opcode_t *pc))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3);
-
-PARROT_WARN_UNUSED_RESULT
-PARROT_CAN_RETURN_NULL
static opcode_t * runops_slow_core(PARROT_INTERP,
ARGIN(Parrot_runcore_t *runcore),
ARGIN(opcode_t *pc))
@@ -376,10 +350,6 @@
__attribute__nonnull__(2)
__attribute__nonnull__(3);
-#define ASSERT_ARGS_init_profiling_core __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(runcore) \
- || PARROT_ASSERT_ARG(pc)
#define ASSERT_ARGS_runops_cgoto_core __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(runcore) \
@@ -404,14 +374,6 @@
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(runcore) \
|| PARROT_ASSERT_ARG(pc)
-#define ASSERT_ARGS_runops_jit_core __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(runcore) \
- || PARROT_ASSERT_ARG(pc)
-#define ASSERT_ARGS_runops_profiling_core __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(runcore) \
- || PARROT_ASSERT_ARG(pc)
#define ASSERT_ARGS_runops_slow_core __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(runcore) \
@@ -455,9 +417,6 @@
PARROT_RUNCORE_FUNC_TABLE_SET(coredata);
Parrot_runcore_register(interp, coredata);
-
- /* it's the first runcore and the default runcore */
- Parrot_runcore_switch(interp, coredata->name);
}
@@ -523,67 +482,6 @@
/*
-=item C<void Parrot_runcore_jit_init(PARROT_INTERP)>
-
-Registers the jit runcore with Parrot.
-
-=cut
-
-*/
-
-void
-Parrot_runcore_jit_init(PARROT_INTERP)
-{
- ASSERT_ARGS(Parrot_runcore_jit_init)
-
- Parrot_runcore_t *coredata = mem_allocate_typed(Parrot_runcore_t);
- coredata->name = CONST_STRING(interp, "jit");
- coredata->id = PARROT_JIT_CORE;
- coredata->opinit = PARROT_CORE_OPLIB_INIT;
- coredata->prepare_run = init_jit_run;
- coredata->runops = runops_jit_core;
- coredata->destroy = NULL;
- coredata->flags = 0;
-
- PARROT_RUNCORE_JIT_OPS_SET(coredata);
-
- Parrot_runcore_register(interp, coredata);
-}
-
-
-/*
-
-=item C<void Parrot_runcore_switch_jit_init(PARROT_INTERP)>
-
-Registers the switch_jit runcore with Parrot.
-
-=cut
-
-*/
-
-void
-Parrot_runcore_switch_jit_init(PARROT_INTERP)
-{
- ASSERT_ARGS(Parrot_runcore_switch_jit_init)
-
- Parrot_runcore_t *coredata = mem_allocate_typed(Parrot_runcore_t);
- coredata->name = CONST_STRING(interp, "switch_jit");
- coredata->id = PARROT_SWITCH_JIT_CORE;
- coredata->opinit = PARROT_CORE_SWITCH_OPLIB_INIT;
- coredata->destroy = NULL;
- coredata->prepare_run = init_prederef;
- coredata->runops = runops_switch_core;
- coredata->flags = 0;
-
- PARROT_RUNCORE_PREDEREF_OPS_SET(coredata);
- PARROT_RUNCORE_JIT_OPS_SET(coredata);
-
- Parrot_runcore_register(interp, coredata);
-}
-
-
-/*
-
=item C<void Parrot_runcore_exec_init(PARROT_INTERP)>
Registers the exec runcore with Parrot.
@@ -736,71 +634,8 @@
}
-/*
-
-=item C<void Parrot_runcore_cgp_jit_init(PARROT_INTERP)>
-
-Registers the CGP/JIT runcore with Parrot.
-
-=cut
-
-*/
-
-
-void
-Parrot_runcore_cgp_jit_init(PARROT_INTERP)
-{
- ASSERT_ARGS(Parrot_runcore_cgp_jit_init)
-
- Parrot_runcore_t *coredata = mem_allocate_typed(Parrot_runcore_t);
- coredata->name = CONST_STRING(interp, "cgp_jit");
- coredata->id = PARROT_CGP_JIT_CORE;
- coredata->opinit = PARROT_CORE_CGP_OPLIB_INIT;
- coredata->prepare_run = init_prederef;
- coredata->runops = runops_cgp_core;
- coredata->destroy = NULL;
- coredata->flags = 0;
-
- PARROT_RUNCORE_JIT_OPS_SET(coredata);
- PARROT_RUNCORE_CGOTO_OPS_SET(coredata);
- PARROT_RUNCORE_EVENT_CHECK_SET(coredata);
- PARROT_RUNCORE_PREDEREF_OPS_SET(coredata);
-
- Parrot_runcore_register(interp, coredata);
-}
-
#endif /* #ifdef HAVE_COMPUTED_GOTO */
-/*
-
-=item C<void Parrot_runcore_profiling_init(PARROT_INTERP)>
-
-Registers the profiling runcore with Parrot.
-
-=cut
-
-*/
-
-void
-Parrot_runcore_profiling_init(PARROT_INTERP)
-{
- ASSERT_ARGS(Parrot_runcore_profiling_init)
-
- Parrot_profiling_runcore_t *coredata =
- mem_allocate_typed(Parrot_profiling_runcore_t);
- coredata->name = CONST_STRING(interp, "profiling");
- coredata->id = PARROT_PROFILING_CORE;
- coredata->opinit = PARROT_CORE_OPLIB_INIT;
- coredata->runops = (Parrot_runcore_runops_fn_t) init_profiling_core;
- coredata->destroy = NULL;
- coredata->prepare_run = NULL;
- coredata->flags = 0;
-
- PARROT_RUNCORE_FUNC_TABLE_SET(coredata);
-
- Parrot_runcore_register(interp, (Parrot_runcore_t *) coredata);
-}
-
/*
@@ -1051,291 +886,6 @@
}
-/*
-
-=item C<static void * init_profiling_core(PARROT_INTERP,
-Parrot_profiling_runcore_t *runcore, opcode_t *pc)>
-
-Perform initialization for the profiling runcore.
-
-=cut
-
-*/
-
-PARROT_CAN_RETURN_NULL
-static void *
-init_profiling_core(PARROT_INTERP, ARGIN(Parrot_profiling_runcore_t *runcore), ARGIN(opcode_t *pc))
-{
- ASSERT_ARGS(init_profiling_core)
-
- char *profile_filename, *profile_output_var;
- int free_env_var;
-
- profile_output_var = Parrot_getenv("PARROT_PROFILING_OUTPUT", &free_env_var);
-
- if (profile_output_var) {
-
- STRING *lc_filename;
- runcore->profile_filename = Parrot_str_new(interp, profile_output_var, 0);
- profile_filename = Parrot_str_to_cstring(interp, runcore->profile_filename);
- lc_filename = Parrot_str_downcase(interp, runcore->profile_filename);
-
- if (Parrot_str_equal(interp, lc_filename, CONST_STRING(interp, "stderr"))) {
- runcore->profile_fd = stderr;
- runcore->profile_filename = lc_filename;
- }
- else if (Parrot_str_equal(interp, lc_filename, CONST_STRING(interp, "stdout"))) {
- runcore->profile_fd = stdout;
- runcore->profile_filename = lc_filename;
- }
- else {
- runcore->profile_fd = fopen(profile_filename, "w");
- }
-
- if (free_env_var)
- mem_sys_free(profile_output_var);
- }
- else {
- runcore->profile_filename = Parrot_sprintf_c(interp, "parrot.pprof.%d", getpid());
- profile_filename = Parrot_str_to_cstring(interp, runcore->profile_filename);
- runcore->profile_fd = fopen(profile_filename, "w");
- }
-
- /* profile_filename gets collected if it's not marked or in the root set. */
- gc_register_pmc(interp, (PMC *) runcore->profile_filename);
-
- runcore->runops = (Parrot_runcore_runops_fn_t) runops_profiling_core;
- runcore->destroy = (Parrot_runcore_destroy_fn_t) destroy_profiling_core;
-
- runcore->prev_ctx = 0;
- runcore->profiling_flags = 0;
- runcore->runloop_count = 0;
- runcore->level = 0;
- runcore->time_size = 32;
- runcore->time = mem_allocate_n_typed(runcore->time_size, UHUGEINTVAL);
- Profiling_first_loop_SET(runcore);
-
- if (!runcore->profile_fd) {
- fprintf(stderr, "unable to open %s for writing", profile_filename);
- Parrot_str_free_cstring(profile_filename);
- exit(1);
- }
-
- Parrot_str_free_cstring(profile_filename);
-
- return runops_profiling_core(interp, runcore, pc);
-}
-
-/*
-
-=item C<static opcode_t * runops_profiling_core(PARROT_INTERP,
-Parrot_profiling_runcore_t *runcore, opcode_t *pc)>
-
-Runs the Parrot operations starting at C<pc> until there are no more
-operations, with tracing, bounds checking, and profiling enabled.
-
-=cut
-
-*/
-
-PARROT_WARN_UNUSED_RESULT
-PARROT_CAN_RETURN_NULL
-static opcode_t *
-runops_profiling_core(PARROT_INTERP, ARGIN(Parrot_profiling_runcore_t *runcore),
-ARGIN(opcode_t *pc))
-{
- ASSERT_ARGS(runops_profiling_core)
-
- Parrot_Context_info preop_info, postop_info;
- PMC *preop_sub, *argv;
- opcode_t *preop_pc;
- UHUGEINTVAL op_time;
- STRING *unknown_file = CONST_STRING(interp, "<unknown file>");
-
- runcore->runcore_start = Parrot_hires_get_time();
-
- /* if we're in a nested runloop, */
- if (runcore->level != 0) {
-
- if (runcore->level > runcore->time_size) {
- runcore->time_size *= 2;
- runcore->time =
- mem_realloc_n_typed(runcore->time, runcore->time_size+1, UHUGEINTVAL);
- }
-
- /* store the time between DO_OP and the start of this runcore in this
- * op's running total */
- runcore->time[runcore->level] = runcore->runcore_start - runcore->op_start;
- }
-
- Parrot_Context_get_info(interp, CURRENT_CONTEXT(interp), &postop_info);
-
- argv = VTABLE_get_pmc_keyed_int(interp, interp->iglobals, IGLOBALS_ARGV_LIST);
-
- if (argv && !Profiling_have_printed_cli_TEST(runcore)) {
-
- /* silly way to avoid line length codingstds nit */
- PMC *iglobals = interp->iglobals;
- PMC *executable = VTABLE_get_pmc_keyed_int(interp, iglobals, IGLOBALS_EXECUTABLE);
- STRING *command_line = Parrot_str_join(interp, CONST_STRING(interp, " "), argv);
-
- char *exec_cstr, *command_line_cstr;
-
- exec_cstr = Parrot_str_to_cstring(interp, VTABLE_get_string(interp, executable));
- command_line_cstr = Parrot_str_to_cstring(interp, command_line);
-
- /* The CLI line won't reflect any options passed to the parrot binary. */
- fprintf(runcore->profile_fd, "CLI:%s %s\n", exec_cstr, command_line_cstr);
-
- Parrot_str_free_cstring(exec_cstr);
- Parrot_str_free_cstring(command_line_cstr);
-
- Profiling_have_printed_cli_SET(runcore);
- }
-
-
- if (Profiling_first_loop_TEST(runcore)) {
-
- fprintf(runcore->profile_fd, "VERSION:1\n");
- /* silly hack to make all separate runloops appear to come from a single source */
- /* NOTE: yes, {x{ foo:bar }x} is ugly an inefficient. Escaping would
- * be more effort but the priority right now is to get the runcore
- * working correctly. Once all the bugs are ironed out we'll switch to
- * a nice efficient compressed binary format. */
- fprintf(runcore->profile_fd,
- "CS:{x{ns:main}x}{x{file:no_file}x}{x{sub:0x1}x}{x{ctx:0x1}x}\n");
- fprintf(runcore->profile_fd,
- "OP:{x{line:%d}x}{x{time:0}x}{x{op:noop}x}\n", (int) runcore->runloop_count);
- runcore->runloop_count++;
- Profiling_first_loop_CLEAR(runcore);
- }
-
- while (pc) {
-
- STRING *postop_file_name;
- Parrot_Context *preop_ctx;
-
- if (pc < code_start || pc >= code_end) {
- Parrot_ex_throw_from_c_args(interp, NULL, 1,
- "attempt to access code outside of current code segment");
- }
-
- /* avoid an extra call to Parrot_Context_get_info */
- mem_sys_memcopy(&preop_info, &postop_info, sizeof (Parrot_Context_info));
-
- Parrot_Context_get_info(interp, CURRENT_CONTEXT(interp), &postop_info);
-
- CONTEXT(interp)->current_pc = pc;
- preop_sub = CONTEXT(interp)->current_sub;
- preop_pc = pc;
- preop_ctx = CONTEXT(interp);
-
- runcore->level++;
- Profiling_exit_check_CLEAR(runcore);
- runcore->op_start = Parrot_hires_get_time();
- DO_OP(pc, interp);
- runcore->op_finish = Parrot_hires_get_time();
-
- if (Profiling_exit_check_TEST(runcore)) {
- op_time = runcore->op_finish - runcore->runcore_finish;
- op_time += runcore->time[runcore->level];
- runcore->time[runcore->level] = 0;
- }
- else {
- op_time = runcore->op_finish - runcore->op_start;
- }
-
- runcore->level--;
- postop_file_name = postop_info.file;
-
- if (!postop_file_name) postop_file_name = unknown_file;
-
- /* if current context changed since the last time a CS line was printed... */
- /* Occasionally the ctx stays the same while the sub changes, possible
- * with a call to a subclass' method. */
- if ((runcore->prev_ctx != preop_ctx) || runcore->prev_sub != preop_ctx->current_sub) {
-
- if (preop_ctx->current_sub) {
- STRING *sub_name;
- char *sub_cstr, *filename_cstr, *ns_cstr;
-
- GETATTR_Sub_name(interp, preop_ctx->current_sub, sub_name);
- sub_cstr = Parrot_str_to_cstring(interp, sub_name);
- filename_cstr = Parrot_str_to_cstring(interp, postop_file_name);
- ns_cstr = Parrot_str_to_cstring(interp,
- VTABLE_get_string(interp, preop_ctx->current_namespace));
-
- fprintf(runcore->profile_fd,
- "CS:{x{ns:%s;%s}x}{x{file:%s}x}{x{sub:0x%p}x}{x{ctx:0x%p}x}\n",
- ns_cstr, sub_cstr, filename_cstr,
- preop_ctx->current_sub,
- preop_ctx);
-
- Parrot_str_free_cstring(sub_cstr);
- Parrot_str_free_cstring(filename_cstr);
- Parrot_str_free_cstring(ns_cstr);
- }
-
- runcore->prev_ctx = preop_ctx;
- runcore->prev_sub = preop_ctx->current_sub;
- }
-
- /* I'd expect that preop_info.line would be the right thing to use here
- * but it gives me obviously incorrect results while postop_info.line
- * works. It might be an imcc bug or it might just be me
- * misunderstanding something. */
- fprintf(runcore->profile_fd, "OP:{x{line:%d}x}{x{time:%li}x}{x{op:%s}x}\n",
- postop_info.line, (unsigned long)op_time,
- (interp->op_info_table)[*preop_pc].name);
-
- } /* while (pc) */
-
- /* make it easy to tell separate runloops apart */
- if (runcore->level == 0) {
- fprintf(runcore->profile_fd, "END_OF_RUNLOOP\n");
- /* silly hack to make all separate runloops appear to come from a single source */
- fprintf(runcore->profile_fd,
- "CS:{x{ns:main}x}{x{file:no_file}x}{x{sub:0x1}x}{x{ctx:0x1}x}\n");
- fprintf(runcore->profile_fd,
- "OP:{x{line:%d}x}{x{time:0}x}{x{op:noop}x}\n", (int) runcore->runloop_count);
- runcore->runloop_count++;
- }
-
- Profiling_exit_check_SET(runcore);
- runcore->runcore_finish = Parrot_hires_get_time();;
- return pc;
-}
-
-
-/*
-
-=item C<void * destroy_profiling_core(PARROT_INTERP, Parrot_profiling_runcore_t
-*runcore)>
-
-Perform any finalization needed by the profiling runcore.
-
-=cut
-
-*/
-
-PARROT_CAN_RETURN_NULL
-void *
-destroy_profiling_core(PARROT_INTERP, ARGIN(Parrot_profiling_runcore_t *runcore))
-{
- ASSERT_ARGS(destroy_profiling_core)
-
- char *filename_cstr = Parrot_str_to_cstring(interp, runcore->profile_filename);
- fprintf(stderr, "\nPROFILING RUNCORE: wrote profile to %s\n", filename_cstr);
- fprintf(stderr, "Use tools/dev/pprof2cg.pl to generate Callgrind-compatible "
- "output from this file.\n");
- Parrot_str_free_cstring(filename_cstr);
-
- fclose(runcore->profile_fd);
- mem_sys_free(runcore->time);
-
- return NULL;
-}
-
#undef code_start
#undef code_end
@@ -1480,19 +1030,11 @@
ADD_OP_VAR_PART(interp, interp->code, pc, n);
- /* count ops that need a PIC */
- if (parrot_PIC_op_is_cached(*pc))
- n_pics++;
-
pc += n;
i += n;
}
interp->code->prederef.code = temp;
-
- /* allocate pic store, which starts from 1 */
- if (n_pics)
- parrot_PIC_alloc_store(interp->code, n_pics + 1);
}
return NULL;
@@ -1553,73 +1095,6 @@
/*
-=item C<void * init_jit_run(PARROT_INTERP, Parrot_runcore_t *runcore)>
-
-Initializes JIT function for the specified opcode and runs it.
-
-=cut
-
-*/
-
-PARROT_WARN_UNUSED_RESULT
-PARROT_CANNOT_RETURN_NULL
-void *
-init_jit_run(PARROT_INTERP, ARGIN(Parrot_runcore_t *runcore))
-{
- ASSERT_ARGS(init_jit_run)
- return init_jit(interp, interp->code->base.data);
-}
-
-
-#ifdef PARROT_EXEC_OS_AIX
-extern void* aix_get_toc();
-#endif
-
-/*
-
-=item C<static opcode_t * runops_jit_core(PARROT_INTERP, Parrot_runcore_t
-*runcore, opcode_t *pc)>
-
-Runs the JIT code for the specified opcode.
-
-=cut
-
-*/
-
-PARROT_WARN_UNUSED_RESULT
-PARROT_CAN_RETURN_NULL
-static opcode_t *
-runops_jit_core(PARROT_INTERP, ARGIN(Parrot_runcore_t *runcore), ARGIN(opcode_t *pc))
-{
- ASSERT_ARGS(runops_jit_core)
-#if JIT_CAPABLE
-# ifdef PARROT_EXEC_OS_AIX
- /* AIX calling convention requires that function-call-by-ptr be made
- through the following struct: */
- struct ptrgl_t { jit_f functPtr; void *toc; void *env; } ptrgl_t;
-
- ptrgl_t.functPtr = (jit_f) D2FPTR(init_jit(interp, pc));
- ptrgl_t.env = NULL;
-
- /* r2 (TOC) needs to point back here so we can return from non-JIT
- functions */
- ptrgl_t.toc = aix_get_toc();
-
- ((jit_f) D2FPTR(&ptrgl_t)) (interp, pc);
-# else
- jit_f jit_code = (jit_f)(init_jit(interp, pc));
- (jit_code) (interp, pc);
-# endif
-#else
- UNUSED(interp);
- UNUSED(pc);
-#endif
- return NULL;
-}
-
-
-/*
-
=item C<static opcode_t * runops_exec_core(PARROT_INTERP, Parrot_runcore_t
*runcore, opcode_t *pc)>
@@ -1653,18 +1128,7 @@
# endif
# endif
# endif
- if (Parrot_exec_run == 2) {
- void *ignored;
- Parrot_exec_run = 0;
-
- Parrot_runcore_switch(interp, CONST_STRING(interp, "jit"));
-
- ignored = runops_jit_core(interp, runcore, pc);
- UNUSED(ignored);
-
- Parrot_runcore_switch(interp, CONST_STRING(interp, "exec"));
- }
- else if (Parrot_exec_run == 1)
+ if (Parrot_exec_run == 1)
Parrot_exec(interp, pc, code_start, code_end);
else
run_native(interp, pc, code_start);
Modified: branches/gc-refactor/src/runcore/main.c
==============================================================================
--- branches/gc-refactor/src/runcore/main.c Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/runcore/main.c Wed Sep 16 18:24:30 2009 (r41302)
@@ -34,9 +34,12 @@
#include "parrot/parrot.h"
#include "parrot/runcore_api.h"
+#include "parrot/runcore_profiling.h"
#include "parrot/oplib/core_ops.h"
#include "parrot/oplib/core_ops_switch.h"
#include "parrot/oplib/ops.h"
+#include "main.str"
+
#if JIT_CAPABLE
# include "parrot/exec.h"
# include "../jit.h"
@@ -125,26 +128,31 @@
Parrot_runcore_init(PARROT_INTERP)
{
ASSERT_ARGS(Parrot_runcore_init)
+#ifdef NDEBUG
+ STRING * const default_core = CONST_STRING(interp, "slow");
+#else
+ STRING * const default_core = CONST_STRING(interp, "fast");
+#endif
- interp->cores = NULL;
- interp->num_cores = 0;
+ interp->cores = NULL;
+ interp->num_cores = 0;
Parrot_runcore_slow_init(interp);
Parrot_runcore_fast_init(interp);
Parrot_runcore_switch_init(interp);
- Parrot_runcore_jit_init(interp);
- Parrot_runcore_switch_jit_init(interp);
Parrot_runcore_exec_init(interp);
Parrot_runcore_gc_debug_init(interp);
Parrot_runcore_debugger_init(interp);
Parrot_runcore_profiling_init(interp);
+ /* set the default runcore */
+ Parrot_runcore_switch(interp, default_core);
+
#ifdef HAVE_COMPUTED_GOTO
Parrot_runcore_cgp_init(interp);
Parrot_runcore_cgoto_init(interp);
- Parrot_runcore_cgp_jit_init(interp);
#endif
}
@@ -357,8 +365,11 @@
prederef_args(pc_prederef, interp, pc, opinfo);
- if (PARROT_RUNCORE_PREDEREF_OPS_TEST(runcore))
- parrot_PIC_prederef(interp, *pc, pc_prederef, interp->run_core);
+ if (PARROT_RUNCORE_PREDEREF_OPS_TEST(runcore)) {
+ *pc_prederef = PARROT_RUNCORE_CGOTO_OPS_TEST(runcore)
+ ? ((void **)interp->op_lib->op_func_table)[*pc]
+ : (void**)*pc;
+ }
else
Parrot_ex_throw_from_c_args(interp, NULL, 1,
"Tried to prederef wrong core");
Copied: branches/gc-refactor/src/runcore/profiling.c (from r41301, trunk/src/runcore/profiling.c)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/gc-refactor/src/runcore/profiling.c Wed Sep 16 18:24:30 2009 (r41302, copy of r41301, trunk/src/runcore/profiling.c)
@@ -0,0 +1,392 @@
+/*
+Copyright (C) 2009, Parrot Foundation.
+$Id$
+
+=head2 Functions
+
+=over 4
+
+=cut
+
+*/
+
+#include "parrot/runcore_api.h"
+#include "parrot/embed.h"
+#include "parrot/runcore_profiling.h"
+#include "parrot/oplib/core_ops.h"
+
+#include "profiling.str"
+
+#include "../pmc/pmc_sub.h"
+
+#ifdef WIN32
+# define getpid _getpid
+#endif
+
+#define code_start interp->code->base.data
+#define code_end (interp->code->base.data + interp->code->base.size)
+
+/* HEADERIZER HFILE: include/parrot/runcore_profiling.h */
+
+/* HEADERIZER BEGIN: static */
+/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
+
+PARROT_CAN_RETURN_NULL
+static void * init_profiling_core(PARROT_INTERP,
+ ARGIN(Parrot_profiling_runcore_t *runcore),
+ ARGIN(opcode_t *pc))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2)
+ __attribute__nonnull__(3);
+
+PARROT_WARN_UNUSED_RESULT
+PARROT_CAN_RETURN_NULL
+static opcode_t * runops_profiling_core(PARROT_INTERP,
+ ARGIN(Parrot_profiling_runcore_t *runcore),
+ ARGIN(opcode_t *pc))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2)
+ __attribute__nonnull__(3);
+
+#define ASSERT_ARGS_init_profiling_core __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(interp) \
+ || PARROT_ASSERT_ARG(runcore) \
+ || PARROT_ASSERT_ARG(pc)
+#define ASSERT_ARGS_runops_profiling_core __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(interp) \
+ || PARROT_ASSERT_ARG(runcore) \
+ || PARROT_ASSERT_ARG(pc)
+/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
+/* HEADERIZER END: static */
+
+
+/*
+
+=item C<void Parrot_runcore_profiling_init(PARROT_INTERP)>
+
+Registers the profiling runcore with Parrot.
+
+=cut
+
+*/
+
+void
+Parrot_runcore_profiling_init(PARROT_INTERP)
+{
+ ASSERT_ARGS(Parrot_runcore_profiling_init)
+
+ Parrot_profiling_runcore_t *coredata =
+ mem_allocate_typed(Parrot_profiling_runcore_t);
+
+ coredata->name = CONST_STRING(interp, "profiling");
+ coredata->id = PARROT_PROFILING_CORE;
+ coredata->opinit = PARROT_CORE_OPLIB_INIT;
+ coredata->runops = (Parrot_runcore_runops_fn_t) init_profiling_core;
+ coredata->destroy = NULL;
+ coredata->prepare_run = NULL;
+ coredata->flags = 0;
+
+ PARROT_RUNCORE_FUNC_TABLE_SET(coredata);
+
+ Parrot_runcore_register(interp, (Parrot_runcore_t *) coredata);
+}
+
+
+/*
+
+=item C<static void * init_profiling_core(PARROT_INTERP,
+Parrot_profiling_runcore_t *runcore, opcode_t *pc)>
+
+Perform initialization for the profiling runcore.
+
+=cut
+
+*/
+
+PARROT_CAN_RETURN_NULL
+static void *
+init_profiling_core(PARROT_INTERP, ARGIN(Parrot_profiling_runcore_t *runcore), ARGIN(opcode_t *pc))
+{
+ ASSERT_ARGS(init_profiling_core)
+
+ char *profile_filename, *profile_output_var;
+ int free_env_var;
+
+ profile_output_var = Parrot_getenv("PARROT_PROFILING_OUTPUT", &free_env_var);
+
+ if (profile_output_var) {
+ STRING *lc_filename;
+ runcore->profile_filename = Parrot_str_new(interp, profile_output_var, 0);
+ profile_filename = Parrot_str_to_cstring(interp, runcore->profile_filename);
+ lc_filename = Parrot_str_downcase(interp, runcore->profile_filename);
+
+ if (Parrot_str_equal(interp, lc_filename, CONST_STRING(interp, "stderr"))) {
+ runcore->profile_fd = stderr;
+ runcore->profile_filename = lc_filename;
+ }
+ else if (Parrot_str_equal(interp, lc_filename, CONST_STRING(interp, "stdout"))) {
+ runcore->profile_fd = stdout;
+ runcore->profile_filename = lc_filename;
+ }
+ else
+ runcore->profile_fd = fopen(profile_filename, "w");
+
+ if (free_env_var)
+ mem_sys_free(profile_output_var);
+ }
+ else {
+ runcore->profile_filename = Parrot_sprintf_c(interp, "parrot.pprof.%d", getpid());
+ profile_filename = Parrot_str_to_cstring(interp, runcore->profile_filename);
+ runcore->profile_fd = fopen(profile_filename, "w");
+ }
+
+ /* profile_filename gets collected if it's not marked or in the root set. */
+ gc_register_pmc(interp, (PMC *) runcore->profile_filename);
+
+ runcore->runops = (Parrot_runcore_runops_fn_t) runops_profiling_core;
+ runcore->destroy = (Parrot_runcore_destroy_fn_t) destroy_profiling_core;
+
+ runcore->prev_ctx = 0;
+ runcore->profiling_flags = 0;
+ runcore->runloop_count = 0;
+ runcore->level = 0;
+ runcore->time_size = 32;
+ runcore->time = mem_allocate_n_typed(runcore->time_size,
+ UHUGEINTVAL);
+ Profiling_first_loop_SET(runcore);
+
+ if (!runcore->profile_fd) {
+ fprintf(stderr, "unable to open %s for writing", profile_filename);
+ Parrot_str_free_cstring(profile_filename);
+ exit(1);
+ }
+
+ Parrot_str_free_cstring(profile_filename);
+
+ return runops_profiling_core(interp, runcore, pc);
+}
+
+
+/*
+
+=item C<static opcode_t * runops_profiling_core(PARROT_INTERP,
+Parrot_profiling_runcore_t *runcore, opcode_t *pc)>
+
+Runs the Parrot operations starting at C<pc> until there are no more
+operations, with tracing, bounds checking, and profiling enabled.
+
+=cut
+
+*/
+
+PARROT_WARN_UNUSED_RESULT
+PARROT_CAN_RETURN_NULL
+static opcode_t *
+runops_profiling_core(PARROT_INTERP, ARGIN(Parrot_profiling_runcore_t *runcore),
+ARGIN(opcode_t *pc))
+{
+ ASSERT_ARGS(runops_profiling_core)
+
+ PMC *preop_sub, *argv;
+ opcode_t *preop_pc;
+ STRING *unknown_file = CONST_STRING(interp, "<unknown file>");
+ UHUGEINTVAL op_time;
+
+ runcore->runcore_start = Parrot_hires_get_time();
+
+ /* if we're in a nested runloop, */
+ if (runcore->level != 0) {
+
+ if (runcore->level >= runcore->time_size) {
+ runcore->time_size *= 2;
+ runcore->time =
+ mem_realloc_n_typed(runcore->time, runcore->time_size + 1,
+ UHUGEINTVAL);
+ }
+
+ /* store the time between DO_OP and the start of this runcore in this
+ * op's running total */
+ runcore->time[runcore->level] =
+ runcore->runcore_start - runcore->op_start;
+ }
+
+ argv = VTABLE_get_pmc_keyed_int(interp, interp->iglobals, IGLOBALS_ARGV_LIST);
+
+ if (argv && !Profiling_have_printed_cli_TEST(runcore)) {
+ /* silly way to avoid line length codingstds nit */
+ PMC *iglobals = interp->iglobals;
+ PMC *executable = VTABLE_get_pmc_keyed_int(interp, iglobals,
+ IGLOBALS_EXECUTABLE);
+ STRING *command_line = Parrot_str_join(interp, CONST_STRING(interp, " "), argv);
+
+ char *exec_cstr, *command_line_cstr;
+
+ exec_cstr = Parrot_str_to_cstring(interp,
+ VTABLE_get_string(interp, executable));
+ command_line_cstr = Parrot_str_to_cstring(interp, command_line);
+
+ /* CLI line won't reflect any options passed to the parrot binary. */
+ fprintf(runcore->profile_fd, "CLI:%s %s\n", exec_cstr, command_line_cstr);
+
+ Parrot_str_free_cstring(exec_cstr);
+ Parrot_str_free_cstring(command_line_cstr);
+
+ Profiling_have_printed_cli_SET(runcore);
+ }
+
+ if (Profiling_first_loop_TEST(runcore)) {
+ fprintf(runcore->profile_fd, "VERSION:1\n");
+
+ /* silly hack to make all separate runloops appear to come from a
+ * single source
+ * NOTE: yes, {x{ foo:bar }x} is ugly an inefficient. Escaping would
+ * be more effort but the priority right now is to get the runcore
+ * working correctly. Once all the bugs are ironed out we'll switch to
+ * a nice efficient compressed binary format. */
+ fprintf(runcore->profile_fd,
+ "CS:{x{ns:main}x}{x{file:no_file}x}{x{sub:0x1}x}{x{ctx:0x1}x}\n"
+ "OP:{x{line:%d}x}{x{time:0}x}{x{op:noop}x}\n",
+ (int) runcore->runloop_count);
+
+ runcore->runloop_count++;
+ Profiling_first_loop_CLEAR(runcore);
+ }
+
+ while (pc) {
+ STRING *postop_filename;
+ Parrot_Context *preop_ctx;
+ INTVAL preop_line;
+
+ if (pc < code_start || pc >= code_end)
+ Parrot_ex_throw_from_c_args(interp, NULL, 1,
+ "attempt to access code outside of current code segment");
+
+ preop_line = Parrot_Sub_get_line_from_pc(interp,
+ Parrot_pcc_get_sub(interp, CURRENT_CONTEXT(interp)),
+ CONTEXT(interp)->current_pc);
+
+ CONTEXT(interp)->current_pc = pc;
+ preop_sub = CONTEXT(interp)->current_sub;
+ preop_pc = pc;
+ preop_ctx = CONTEXT(interp);
+
+ runcore->level++;
+ Profiling_exit_check_CLEAR(runcore);
+
+ runcore->op_start = Parrot_hires_get_time();
+ DO_OP(pc, interp);
+ runcore->op_finish = Parrot_hires_get_time();
+
+ if (Profiling_exit_check_TEST(runcore)) {
+ op_time = runcore->op_finish - runcore->runcore_finish;
+ op_time += runcore->time[runcore->level];
+ runcore->time[runcore->level] = 0;
+ }
+ else
+ op_time = runcore->op_finish - runcore->op_start;
+
+ runcore->level--;
+ postop_filename = Parrot_Sub_get_filename_from_pc(interp,
+ Parrot_pcc_get_sub(interp, CURRENT_CONTEXT(interp)), pc);
+
+ /* if current context changed since the last printing of a CS line... */
+ /* Occasionally the ctx stays the same while the sub changes, possible
+ * with a call to a subclass' method. */
+
+ if ((runcore->prev_ctx != preop_ctx)
+ || runcore->prev_sub != preop_ctx->current_sub) {
+
+ if (preop_ctx->current_sub) {
+ STRING *sub_name;
+ char *sub_cstr, *filename_cstr, *ns_cstr;
+
+ GETATTR_Sub_name(interp, preop_ctx->current_sub, sub_name);
+ sub_cstr = Parrot_str_to_cstring(interp, sub_name);
+ filename_cstr = Parrot_str_to_cstring(interp, postop_filename);
+ ns_cstr = Parrot_str_to_cstring(interp,
+ VTABLE_get_string(interp,
+ preop_ctx->current_namespace));
+
+ fprintf(runcore->profile_fd,
+ "CS:{x{ns:%s;%s}x}{x{file:%s}x}{x{sub:0x%p}x}{x{ctx:0x%p}x}\n",
+ ns_cstr, sub_cstr, filename_cstr,
+ preop_ctx->current_sub, preop_ctx);
+
+ Parrot_str_free_cstring(sub_cstr);
+ Parrot_str_free_cstring(filename_cstr);
+ Parrot_str_free_cstring(ns_cstr);
+ }
+
+ runcore->prev_ctx = preop_ctx;
+ runcore->prev_sub = preop_ctx->current_sub;
+ }
+
+ fprintf(runcore->profile_fd,
+ "OP:{x{line:%d}x}{x{time:%li}x}{x{op:%s}x}\n",
+ (int)preop_line, (unsigned long)op_time,
+ (interp->op_info_table)[*preop_pc].name);
+ }
+
+ /* make it easy to tell separate runloops apart */
+ if (runcore->level == 0) {
+ fprintf(runcore->profile_fd, "END_OF_RUNLOOP\n");
+
+ /* silly hack to make all separate runloops appear to come from a
+ * single source */
+ fprintf(runcore->profile_fd,
+ "CS:{x{ns:main}x}{x{file:no_file}x}{x{sub:0x1}x}{x{ctx:0x1}x}\n"
+ "OP:{x{line:%d}x}{x{time:0}x}{x{op:noop}x}\n",
+ (int) runcore->runloop_count);
+
+ runcore->runloop_count++;
+ }
+
+ Profiling_exit_check_SET(runcore);
+ runcore->runcore_finish = Parrot_hires_get_time();;
+ return pc;
+}
+
+
+/*
+
+=item C<void * destroy_profiling_core(PARROT_INTERP, Parrot_profiling_runcore_t
+*runcore)>
+
+Perform any finalization needed by the profiling runcore.
+
+=cut
+
+*/
+
+PARROT_CAN_RETURN_NULL
+void *
+destroy_profiling_core(PARROT_INTERP, ARGIN(Parrot_profiling_runcore_t *runcore))
+{
+ ASSERT_ARGS(destroy_profiling_core)
+
+ char *filename_cstr = Parrot_str_to_cstring(interp, runcore->profile_filename);
+
+ fprintf(stderr, "\nPROFILING RUNCORE: wrote profile to %s\n"
+ "Use tools/dev/pprof2cg.pl to generate Callgrind-compatible "
+ "output from this file.\n", filename_cstr);
+
+ Parrot_str_free_cstring(filename_cstr);
+
+ fclose(runcore->profile_fd);
+ mem_sys_free(runcore->time);
+
+ return NULL;
+}
+
+/*
+
+=back
+
+*/
+
+/*
+ * Local variables:
+ * c-file-style: "parrot"
+ * End:
+ * vim: expandtab shiftwidth=4:
+ */
Modified: branches/gc-refactor/src/string/api.c
==============================================================================
--- branches/gc-refactor/src/string/api.c Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/string/api.c Wed Sep 16 18:24:30 2009 (r41302)
@@ -48,9 +48,25 @@
__attribute__nonnull__(2)
FUNC_MODIFIES(*s);
+PARROT_INLINE
+PARROT_WARN_UNUSED_RESULT
+PARROT_CAN_RETURN_NULL
+static const CHARSET * string_rep_compatible(SHIM_INTERP,
+ ARGIN(const STRING *a),
+ ARGIN(const STRING *b),
+ ARGOUT(const ENCODING **e))
+ __attribute__nonnull__(2)
+ __attribute__nonnull__(3)
+ __attribute__nonnull__(4)
+ FUNC_MODIFIES(*e);
+
#define ASSERT_ARGS_make_writable __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(s)
+#define ASSERT_ARGS_string_rep_compatible __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(a) \
+ || PARROT_ASSERT_ARG(b) \
+ || PARROT_ASSERT_ARG(e)
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: static */
@@ -378,8 +394,8 @@
/*
-=item C<const CHARSET * string_rep_compatible(PARROT_INTERP, const STRING *a,
-const STRING *b, const ENCODING **e)>
+=item C<static const CHARSET * string_rep_compatible(PARROT_INTERP, const STRING
+*a, const STRING *b, const ENCODING **e)>
Find the "lowest" possible charset and encoding for the given string. E.g.
@@ -392,10 +408,10 @@
*/
-PARROT_EXPORT
+PARROT_INLINE
PARROT_WARN_UNUSED_RESULT
PARROT_CAN_RETURN_NULL
-const CHARSET *
+static const CHARSET *
string_rep_compatible(SHIM_INTERP,
ARGIN(const STRING *a), ARGIN(const STRING *b), ARGOUT(const ENCODING **e))
{
@@ -406,8 +422,8 @@
}
/* a table could possibly simplify the logic */
- if (a->encoding == Parrot_utf8_encoding_ptr &&
- b->charset == Parrot_ascii_charset_ptr) {
+ if (a->encoding == Parrot_utf8_encoding_ptr
+ && b->charset == Parrot_ascii_charset_ptr) {
if (a->strlen == a->bufused) {
*e = Parrot_fixed_8_encoding_ptr;
return b->charset;
@@ -415,8 +431,9 @@
*e = a->encoding;
return a->charset;
}
- if (b->encoding == Parrot_utf8_encoding_ptr &&
- a->charset == Parrot_ascii_charset_ptr) {
+
+ if (b->encoding == Parrot_utf8_encoding_ptr
+ && a->charset == Parrot_ascii_charset_ptr) {
if (b->strlen == b->bufused) {
*e = Parrot_fixed_8_encoding_ptr;
return a->charset;
@@ -424,11 +441,15 @@
*e = b->encoding;
return b->charset;
}
+
if (a->encoding != b->encoding)
return NULL;
+
if (a->encoding != Parrot_fixed_8_encoding_ptr)
return NULL;
+
*e = Parrot_fixed_8_encoding_ptr;
+
if (a->charset == b->charset)
return a->charset;
if (b->charset == Parrot_ascii_charset_ptr)
@@ -439,9 +460,11 @@
return a->charset;
if (b->charset == Parrot_binary_charset_ptr)
return b->charset;
+
return NULL;
}
+
/*
=item C<STRING * Parrot_str_concat(PARROT_INTERP, STRING *a, STRING *b, UINTVAL
@@ -464,8 +487,8 @@
ARGIN_NULLOK(STRING *b), UINTVAL Uflags)
{
ASSERT_ARGS(Parrot_str_concat)
- if (a != NULL && a->strlen != 0) {
- if (b != NULL && b->strlen != 0) {
+ if (a && a->strlen) {
+ if (b && b->strlen) {
const ENCODING *enc;
const CHARSET *cs = string_rep_compatible(interp, a, b, &enc);
STRING *result;
@@ -536,6 +559,7 @@
return Parrot_str_concat(interp, a, b, 0);
cs = string_rep_compatible(interp, a, b, &enc);
+
if (cs) {
a->charset = cs;
a->encoding = enc;
Modified: branches/gc-refactor/src/sub.c
==============================================================================
--- branches/gc-refactor/src/sub.c Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/sub.c Wed Sep 16 18:24:30 2009 (r41302)
@@ -190,6 +190,7 @@
ASSERT_ARGS(Parrot_Context_get_info)
PMC *subpmc;
Parrot_Sub_attributes *sub;
+ opcode_t *pc;
/* set file/line/pc defaults */
info->file = CONST_STRING(interp, "(unknown file)");
@@ -228,15 +229,17 @@
info->fullname = Parrot_full_sub_name(interp, subpmc);
}
+ pc = Parrot_pcc_get_pc(interp, ctx);
+
/* return here if there is no current pc */
- if (Parrot_pcc_get_pc(interp, ctx) == NULL)
+ if (!pc)
return 1;
/* calculate the current pc */
- info->pc = Parrot_pcc_get_pc(interp, ctx) - sub->seg->base.data;
+ info->pc = pc - sub->seg->base.data;
/* determine the current source file/line */
- if (Parrot_pcc_get_pc(interp, ctx)) {
+ if (pc) {
const size_t offs = info->pc;
size_t i, n;
opcode_t *pc = sub->seg->base.data;
@@ -261,9 +264,93 @@
pc += op_info->op_count + var_args;
}
}
+
return 1;
}
+
+/*
+
+=item C<INTVAL Parrot_Sub_get_line_from_pc(PARROT_INTERP, PMC *subpmc, opcode_t
+*pc)>
+
+Given a PMC sub and the current opcode, returns the corresponding PIR line
+number.
+
+=cut
+
+*/
+
+INTVAL
+Parrot_Sub_get_line_from_pc(PARROT_INTERP, ARGIN_NULLOK(PMC *subpmc), ARGIN_NULLOK(opcode_t *pc))
+{
+ ASSERT_ARGS(Parrot_Sub_get_line_from_pc)
+ Parrot_Sub_attributes *sub;
+ PackFile_Debug *debug;
+ opcode_t *base_pc;
+ size_t i, n, offs;
+
+ if (!subpmc || !pc)
+ return -1;
+
+ PMC_get_sub(interp, subpmc, sub);
+
+ offs = pc - sub->seg->base.data;
+ debug = sub->seg->debugs;
+ base_pc = sub->seg->base.data;
+
+ for (i = n = 0; n < sub->seg->base.size; i++) {
+ op_info_t * const op_info = &interp->op_info_table[*base_pc];
+ opcode_t var_args = 0;
+
+ if (i >= debug->base.size)
+ return -1;
+
+ if (n >= offs)
+ return debug->base.data[i];
+
+ ADD_OP_VAR_PART(interp, sub->seg, base_pc, var_args);
+ n += op_info->op_count + var_args;
+ base_pc += op_info->op_count + var_args;
+ }
+
+ return -1;
+}
+
+
+/*
+
+=item C<STRING * Parrot_Sub_get_filename_from_pc(PARROT_INTERP, PMC *subpmc,
+opcode_t *pc)>
+
+Given a PMC sub and the current opcode, returns the corresponding PIR file
+name.
+
+=cut
+
+*/
+
+PARROT_CANNOT_RETURN_NULL
+STRING *
+Parrot_Sub_get_filename_from_pc(PARROT_INTERP, ARGIN_NULLOK(PMC *subpmc),
+ ARGIN_NULLOK(opcode_t *pc))
+{
+ ASSERT_ARGS(Parrot_Sub_get_filename_from_pc)
+ Parrot_Sub_attributes *sub;
+ PackFile_Debug *debug;
+ int position;
+
+ if (!subpmc || !pc)
+ return CONST_STRING(interp, "unknown file");
+
+ PMC_get_sub(interp, subpmc, sub);
+
+ debug = sub->seg->debugs;
+ position = pc - sub->seg->base.data;
+
+ return Parrot_debug_pc_to_filename(interp, debug, position);
+}
+
/*
=item C<STRING* Parrot_Context_infostr(PARROT_INTERP, PMC *ctx)>
Modified: branches/gc-refactor/src/vtable.tbl
==============================================================================
--- branches/gc-refactor/src/vtable.tbl Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/src/vtable.tbl Wed Sep 16 18:24:30 2009 (r41302)
@@ -66,13 +66,11 @@
[STORE] :write
void set_integer_native(INTVAL value)
-void set_integer_same(PMC* value)
void set_integer_keyed(PMC* key, INTVAL value)
void set_integer_keyed_int(INTVAL key, INTVAL value)
void set_integer_keyed_str(STRING* key, INTVAL value)
void set_number_native(FLOATVAL value)
-void set_number_same(PMC* value)
void set_number_keyed(PMC* key, FLOATVAL value)
void set_number_keyed_int(INTVAL key, FLOATVAL value)
void set_number_keyed_str(STRING* key, FLOATVAL value)
@@ -83,7 +81,6 @@
void set_string_native(STRING* value)
void assign_string_native(STRING* value)
-void set_string_same(PMC* value)
void set_string_keyed(PMC* key, STRING* value)
void set_string_keyed_int(INTVAL key, STRING* value)
void set_string_keyed_str(STRING* key, STRING* value)
Modified: branches/gc-refactor/t/codingstd/c_function_docs.t
==============================================================================
--- branches/gc-refactor/t/codingstd/c_function_docs.t Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/t/codingstd/c_function_docs.t Wed Sep 16 18:24:30 2009 (r41302)
@@ -71,7 +71,7 @@
$missing = 'missing';
}
if ($missing) {
- push @missing_docs, "$path ($missing)\n$function_decl\n";
+ push @missing_docs, "$path ($missing)\n$function_decl\nWant:\n$escaped_decl\n";
}
}
@@ -79,7 +79,7 @@
local $TODO = 'Missing function docs' if $todos{$path};
ok ( ! @missing_docs, $path)
- or diag( scalar @missing_docs
+ or diag( @missing_docs
. " function(s) lacking documentation:\n"
. join ("\n", @missing_docs, "\n"));
}
Modified: branches/gc-refactor/t/compilers/tge/grammar.t
==============================================================================
--- branches/gc-refactor/t/compilers/tge/grammar.t Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/t/compilers/tge/grammar.t Wed Sep 16 18:24:30 2009 (r41302)
@@ -301,12 +301,12 @@
GRAMMAR
- .local object testing
+ .local pmc testing
testing = new 'Hash'
# Compile a grammar from the source
.local pmc grammar
- $P1 = new 'TGE;Compiler'
+ $P1 = new ['TGE';'Compiler']
grammar = $P1.'compile'(source)
# Apply the grammar to the test tree
Modified: branches/gc-refactor/t/harness
==============================================================================
--- branches/gc-refactor/t/harness Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/t/harness Wed Sep 16 18:24:30 2009 (r41302)
@@ -1,5 +1,5 @@
#!perl
-# Copyright (C) 2001-2008, Parrot Foundation.
+# Copyright (C) 2001-2009, Parrot Foundation.
# $Id$
use strict;
@@ -147,7 +147,7 @@
=item C<-j>
-Run with JIT enabled.
+Alias for running with the fast core.
=item C<-C>
Modified: branches/gc-refactor/t/op/calling.t
==============================================================================
--- branches/gc-refactor/t/op/calling.t Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/t/op/calling.t Wed Sep 16 18:24:30 2009 (r41302)
@@ -1406,7 +1406,10 @@
ok
OUTPUT
-pir_output_is( <<'CODE', <<'OUTPUT', "clone_key_arg" );
+my @todo = ( todo => 'broken with JIT (TT #983)' )
+ if ( defined $ENV{TEST_PROG_ARGS} and
+ $ENV{TEST_PROG_ARGS} =~ /--runcore=jit/ );
+pir_output_is( <<'CODE', <<'OUTPUT', "clone_key_arg", @todo );
.sub main :main
foo()
print "ok\n"
Modified: branches/gc-refactor/t/op/interp.t
==============================================================================
--- branches/gc-refactor/t/op/interp.t Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/t/op/interp.t Wed Sep 16 18:24:30 2009 (r41302)
@@ -162,9 +162,6 @@
if $I0 == .PARROT_SWITCH_CORE goto ok1
if $I0 == .PARROT_CGOTO_CORE goto ok1
if $I0 == .PARROT_CGP_CORE goto ok1
- if $I0 == .PARROT_JIT_CORE goto ok1
- if $I0 == .PARROT_SWITCH_JIT_CORE goto ok1
- if $I0 == .PARROT_CGP_JIT_CORE goto ok1
if $I0 == .PARROT_EXEC_CORE goto ok1
if $I0 == .PARROT_GC_DEBUG_CORE goto ok1
print 'not '
Modified: branches/gc-refactor/t/pmc/boolean.t
==============================================================================
--- branches/gc-refactor/t/pmc/boolean.t Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/t/pmc/boolean.t Wed Sep 16 18:24:30 2009 (r41302)
@@ -19,8 +19,9 @@
.sub main :main
.include 'test_more.pir'
- plan(28)
+ plan(30)
init_int_tests()
+ instantiate_tests()
num_tests()
string_tests()
pmc_to_pmc_tests()
@@ -46,6 +47,21 @@
is($I0, 1, "Boolean converts negative int to true")
.end
+.sub instantiate_tests
+ $P0 = new ['Boolean']
+
+ $P0 = 1
+ $P2 = get_class ['Boolean']
+ $P1 = new $P2, $P0
+ $I0 = $P1
+ is($I0, 1, "Boolean instantiated to true")
+
+ $P0 = 0
+ $P1 = new ['Boolean'], $P0
+ $I0 = $P1
+ is($I0, 0, "Boolean instantiated to false")
+.end
+
.sub num_tests
$P0 = new ['Boolean']
Modified: branches/gc-refactor/t/pmc/coroutine.t
==============================================================================
--- branches/gc-refactor/t/pmc/coroutine.t Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/t/pmc/coroutine.t Wed Sep 16 18:24:30 2009 (r41302)
@@ -308,7 +308,7 @@
CODE
pir_output_like(
- <<'CODE', <<'OUTPUT', "Call an exited coroutine", todo => 'goes one iteration too far.' );
+ <<'CODE', <<'OUTPUT', "Call an exited coroutine", todo => 'goes one iteration too far TT #1003' );
.sub main :main
.local pmc c
c = get_global "coro"
Modified: branches/gc-refactor/t/pmc/fixedbooleanarray.t
==============================================================================
--- branches/gc-refactor/t/pmc/fixedbooleanarray.t Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/t/pmc/fixedbooleanarray.t Wed Sep 16 18:24:30 2009 (r41302)
@@ -1,13 +1,7 @@
-#! perl
-# Copyright (C) 2001-2007, Parrot Foundation.
+#! parrot
+# Copyright (C) 2001-2009, Parrot Foundation.
# $Id$
-use strict;
-use warnings;
-use lib qw( . lib ../lib ../../lib );
-use Test::More;
-use Parrot::Test tests => 14;
-
=head1 NAME
t/pmc/fixedbooleanarray.t - FixedBooleanArray PMC
@@ -23,268 +17,214 @@
=cut
-pasm_output_is( <<'CODE', <<'OUTPUT', "Setting array size" );
- new P0, ['FixedBooleanArray']
+.const int TESTS = 36
+
+.sub 'test' :main
+ .include 'test_more.pir'
+
+ plan(TESTS)
+
+ setting_array_size()
+ resizing_not_allowed()
+ setting_first_element()
+ setting_second_element()
+ setting_out_of_bounds()
+ getting_out_of_bounds()
+ set_pmc_access_int()
+ set_int_access_pmc()
+ interface()
+ truth()
+ pmc_keys_and_values()
+ freeze_thaw()
+ 'clone'()
+ get_iter()
+ fill()
+.end
+
+.sub 'setting_array_size'
+ $P0 = new ['FixedBooleanArray']
+ $I0 = $P0
+ is($I0, 0, 'size is initially zero')
+
+ $P0 = 1
+ $I0 = $P0
+ is($I0, 1, 'size set to 1')
+.end
+
+.sub 'resizing_not_allowed'
+ $P0 = new ['FixedBooleanArray']
+
+ push_eh resizing_not_allowed_handler
+ $P0 = 1
+ $P0 = 2
+ nok(1, 'resizing should not have succeeded')
+ pop_eh
+ .return()
+
+ resizing_not_allowed_handler:
+ .get_results($P0)
+ $S0 = $P0
+ like($S0, ":s FixedBooleanArray\\: Can\\'t resize\\!", 'Resetting array size (and getting an exception)')
+.end
+
+.sub 'setting_first_element'
+ $P0 = new ['FixedBooleanArray']
+ $P0 = 1
+
+ $P0[0] = -7
+ $I0 = $P0[0]
+ is($I0, 1, 'setting first element to a true int value')
+
+ $P0[0] = 3.7
+ $N0 = $P0[0]
+ is($N0, 1.0, 'setting first element to a true num value')
+
+ $P0[0] = "17"
+ $S0 = $P0[0]
+ is($S0, "1", 'setting first element to a true string value')
+.end
+
+.sub 'setting_second_element'
+ $P0 = new ['FixedBooleanArray']
+ $P0 = 2
+
+ $P0[1] = -7
+ $I0 = $P0[1]
+ is($I0, 1, 'setting second element to a true int value')
+
+ $P0[1] = 3.7
+ $N0 = $P0[1]
+ is($N0, 1.0, 'setting second element to a true num value')
+
+ $P0[1] = "17"
+ $S0 = $P0[1]
+ is($S0, "1", 'setting second element to a true string value')
+.end
+
+.sub 'setting_out_of_bounds'
+ $P0 = new ['FixedBooleanArray']
+ $P0 = 1
+
+ push_eh setting_out_of_bounds_handler
+ $P0[1] = -7
+ pop_eh
+ nok(1, "Setting out-of-bounds element wrongly succeeded")
+ .return()
+
+ setting_out_of_bounds_handler:
+ .get_results($P0)
+ $S0 = $P0
+ like($S0, ":s FixedBooleanArray\\: index out of bounds\\!", "Setting out-of-bounds elements")
+.end
+
+.sub 'getting_out_of_bounds'
+ $P0 = new ['FixedBooleanArray']
+ $P0 = 1
+
+ push_eh getting_out_of_bounds_handler
+ $I0 = $P0[1]
+ pop_eh
+ nok(1, "Getting out-of-bounds element wrongly succeeded")
+ .return()
+
+ getting_out_of_bounds_handler:
+ .get_results($P0)
+ $S0 = $P0
+ like($S0, ":s FixedBooleanArray\\: index out of bounds\\!", "Getting out-of-bounds elements")
+.end
+
+.sub 'set_pmc_access_int'
+ $P0 = new ['FixedBooleanArray']
+ $P0 = 3
+ $P1 = new ['Key']
+
+ $P1 = 0
+ $P0[$P1] = 25
- set I0,P0
- eq I0,0,OK_1
- print "not "
-OK_1: print "ok 1\n"
-
- set P0,1
- set I0,P0
- eq I0,1,OK_2
- print "not "
-OK_2: print "ok 2\n"
-
- end
-CODE
-ok 1
-ok 2
-OUTPUT
-
-pasm_error_output_like( <<'CODE', <<'OUTPUT', "Resetting array size (and getting an exception)" );
- new P0, ['FixedBooleanArray']
-
- set I0,P0
- set P0,1
- set P0,2
- print "Should have gotten an exception\n"
-
-
- end
-CODE
-/FixedBooleanArray: Can't resize!
-current instr\.:/
-OUTPUT
-
-#VIM's syntax highlighter needs this line
-
-pasm_output_is( <<'CODE', <<'OUTPUT', "Setting first element" );
- new P0, ['FixedBooleanArray']
- set P0, 1
-
- set P0[0],-7
- set I0,P0[0]
- eq I0,1,OK_1
- print "not "
-OK_1: print "ok 1\n"
-
- set P0[0],3.7
- set N0,P0[0]
- eq N0,1.0,OK_2
- print "not "
-OK_2: print "ok 2\n"
-
- set P0[0],"17"
- set S0,P0[0]
- eq S0,"1",OK_3
- print "not "
-OK_3: print "ok 3\n"
-
- end
-CODE
-ok 1
-ok 2
-ok 3
-OUTPUT
-
-pasm_output_is( <<'CODE', <<'OUTPUT', "Setting second element" );
- new P0, ['FixedBooleanArray']
- set P0, 2
-
- set P0[1], -7
- set I0, P0[1]
- eq I0,1,OK_1
- print "not "
-OK_1: print "ok 1\n"
-
- set P0[1], 3.7
- set N0, P0[1]
- eq N0,1.0,OK_2
- print "not "
-OK_2: print "ok 2\n"
-
- set P0[1],"17"
- set S0, P0[1]
- eq S0,"1",OK_3
- print "not "
-OK_3: print "ok 3\n"
-
- end
-CODE
-ok 1
-ok 2
-ok 3
-OUTPUT
-
-pasm_error_output_like( <<'CODE', <<'OUTPUT', "Setting out-of-bounds elements" );
- new P0, ['FixedBooleanArray']
- set P0, 1
-
- set P0[1], -7
-
- end
-CODE
-/FixedBooleanArray: index out of bounds!
-current instr\.:/
-OUTPUT
-
-pasm_error_output_like( <<'CODE', <<'OUTPUT', "Getting out-of-bounds elements" );
- new P0, ['FixedBooleanArray']
- set P0, 1
-
- set I0, P0[1]
- end
-CODE
-/FixedBooleanArray: index out of bounds!
-current instr\.:/
-OUTPUT
-
-pasm_output_is( <<"CODE", <<'OUTPUT', "Set via PMC keys, access via INTs" );
- .include 'fp_equality.pasm'
- new P0, ['FixedBooleanArray']
- set P0, 3
- new P1, ['Key']
-
- set P1, 0
- set P0[P1], 25
-
- set P1, 1
- set P0[P1], 2.5
-
- set P1, 2
- set P0[P1], "17"
-
- set I0, P0[0]
- eq I0, 1, OK1
- print "not "
-OK1: print "ok 1\\n"
-
- set N0, P0[1]
- .fp_eq_pasm(N0, 1.0, OK2)
- print "not "
-OK2: print "ok 2\\n"
-
- set S0, P0[2]
- eq S0, "1", OK3
- print "not "
-OK3: print "ok 3\\n"
-
- end
-CODE
-ok 1
-ok 2
-ok 3
-OUTPUT
-
-pasm_output_is( <<"CODE", <<'OUTPUT', "Set via INTs, access via PMC Keys" );
- .include 'fp_equality.pasm'
- new P0, ['FixedBooleanArray']
- set P0, 1024
-
- set P0[25], 125
- set P0[128], 10.2
- set P0[513], "17"
- new P1, ['Integer']
- set P1, 123456
- set P0[1023], P1
-
- new P2, ['Key']
- set P2, 25
- set I0, P0[P2]
- eq I0, 1, OK1
- print "not "
-OK1: print "ok 1\\n"
-
- set P2, 128
- set N0, P0[P2]
- .fp_eq_pasm(N0, 1.0, OK2)
- print "not "
-OK2: print "ok 2\\n"
-
- set P2, 513
- set S0, P0[P2]
- eq S0, "1", OK3
- print "not "
-OK3: print "ok 3\\n"
-
- set P2, 1023
- set P3, P0[P2]
- set I1, P3
- eq I1, 1, OK4
- print "not "
-OK4: print "ok 4\\n"
-
- end
-CODE
-ok 1
-ok 2
-ok 3
-ok 4
-OUTPUT
-
-pir_output_is( << 'CODE', << 'OUTPUT', "check whether interface is done" );
-
-.sub _main
- .local pmc pmc1
- pmc1 = new ['FixedBooleanArray']
- .local int bool1
- does bool1, pmc1, "scalar"
- print bool1
- print "\n"
- does bool1, pmc1, "array"
- print bool1
- print "\n"
- does bool1, pmc1, "no_interface"
- print bool1
- print "\n"
- end
-.end
-CODE
-0
-1
-0
-OUTPUT
-
-pasm_output_is( << 'CODE', << 'OUTPUT', "Truth" );
- new P0, ['FixedBooleanArray']
- unless P0, OK1
- print "not "
-OK1: print "ok 1\n"
- set P0, 1
- if P0, OK2
- print "not "
-OK2: print "ok 2\n"
- set P0[0], 0
- if P0, OK3
- print "not "
-OK3: print "ok 3\n"
- end
-CODE
-ok 1
-ok 2
-ok 3
-OUTPUT
-
-pasm_output_is( << 'CODE', << 'OUTPUT', "PMC keys & values" );
- new P0, ['FixedBooleanArray']
- set P0, 2
- new P1, ['Key']
- set P1, 1
- new P2, ['Integer']
- set P2, 1
- set P0[P1], P2
- set I0, P0[P1]
- print I0
- print "\n"
- end
-CODE
-1
-OUTPUT
+ $P1 = 1
+ $P0[$P1] = 2.5
-pir_output_is( <<'CODE', <<'OUTPUT', "freeze/thaw" );
-.sub main :main
+ $P1 = 2
+ $P0[$P1] = "17"
+
+ $I0 = $P0[0]
+ is($I0, 1, "Set via PMC keys, access via INTs: int value")
+
+ $N0 = $P0[1]
+ is($N0, 1.0, "Set via PMC keys, access via INTs: num value")
+
+ $S0 = $P0[0]
+ is($S0, "1", "Set via PMC keys, access via INTs: string value")
+.end
+
+.sub 'set_int_access_pmc'
+ $P0 = new ['FixedBooleanArray']
+ $P0 = 1024
+
+ $P0[25] = 125
+ $P0[128] = 10.2
+ $P0[513] = "17"
+ $P1 = new ['Integer']
+ $P1 = 123456
+ $P0[1023] = $P1
+
+ $P2 = new ['Key']
+
+ $P2 = 25
+ $I0 = $P0[$P2]
+ is($I0, 1, 'Set via INTs, access via PMC Keys: int value')
+
+ $P2 = 128
+ $N0 = $P0[$P2]
+ is($N0, 1.0, 'Set via INTs, access via PMC Keys: num value')
+
+ $P2 = 513
+ $S0 = $P0[$P2]
+ is($S0, '1', 'Set via INTs, access via PMC Keys: string value')
+
+ $P2 = 1023
+ $P3 = $P0[$P2]
+ is($P3, 1, 'Set via INTs, access via PMC Keys: PMC value')
+.end
+
+.sub 'interface'
+ $P0 = new ['FixedBooleanArray']
+
+ $I0 = does $P0, 'scalar'
+ nok($I0, 'FixedBooleanArray does not scalar')
+ $I0 = does $P0, 'array'
+ ok($I0, 'FixedBooleanArray does array')
+ $I0 = does $P0, 'no_interface'
+ nok($I0, 'FixedBooleanArray does not no_interface')
+.end
+
+.sub 'truth'
+ $P0 = new ['FixedBooleanArray']
+
+ nok($P0, 'Empty FixedBooleanArray is false')
+
+ $P0 = 1
+ ok($P0, 'Non-empty FixedBooleanArray is true')
+
+ $P0[0] = 0
+ ok($P0, 'FixedBooleanArray is true, no matter what its values are')
+.end
+
+.sub 'pmc_keys_and_values'
+ $P0 = new ['FixedBooleanArray']
+ $P0 = 2
+
+ $P1 = new ['Key']
+ $P1 = 1
+ $P2 = new ['Integer']
+ $P2 = 1
+ $P0[$P1] = $P2
+
+ $I0 = $P0[$P1]
+ is($I0, 1, 'PMC keys & values')
+.end
+
+.sub 'freeze_thaw'
.local pmc fba
.local int i
.local string s
@@ -298,21 +238,16 @@
fba[12] = 1
fba[15] = 1
- say fba
+ $S0 = fba
+ is($S0, '01001000100010010', 'FixedBooleanArray before freeze')
s = freeze fba
fba.'fill'(0)
fba = thaw s
- say fba
-
+ $S0 = fba
+ is($S0, '01001000100010010', 'FixedBooleanArray after thaw')
.end
-CODE
-01001000100010010
-01001000100010010
-OUTPUT
-
-pir_output_is( <<'CODE', <<'OUTPUT', "clone" );
-.sub main :main
+.sub 'clone'
.local pmc fba1, fba2
.local int i
.local string s
@@ -326,40 +261,66 @@
fba1[12] = 1
fba1[15] = 1
- say fba1
+ $S0 = fba1
+ is($S0, '01001000100010010', 'FixedBooleanArray before clone')
fba2 = clone fba1
- say fba2
-
+ $S1 = fba2
+ is($S0, $S1, "clones have the same string representation")
.end
-CODE
-01001000100010010
-01001000100010010
-OUTPUT
-
-pir_output_is( <<'CODE', <<'OUTPUT', "get_iter" );
-.sub 'main' :main
+.sub 'get_iter'
$P0 = new ['FixedBooleanArray']
$P0 = 3
$P0[0] = 1
$P0[1] = 0
$P0[2] = 1
+
$P1 = iter $P0
-loop:
- unless $P1 goto loop_end
- $S2 = shift $P1
- say $S2
- goto loop
-loop_end:
-.end
-CODE
-1
-0
-1
-OUTPUT
+ $I2 = shift $P1
+ is($I2, 1, 'get_iter: first element')
+ $I2 = shift $P1
+ is($I2, 0, 'get_iter: second element')
+ $I2 = shift $P1
+ is($I2, 1, 'get_iter: third element')
+ nok($P1, 'iterator exhausted')
+.end
+
+.sub 'fill'
+ $P0 = new ['FixedBooleanArray']
+ $P0.'fill'(0)
+ ok(1, 'Filling empty array')
-1;
+ .local int result, i, size
+ size = 1564
+ $P0 = size
+
+ $P0.'fill'(0)
+ i = 0
+ result = 0
+ $I1 = 0
+ fill_false_loop:
+ unless i < size goto fill_false_end
+ $I0 = $P0[i]
+ result = or result, $I0
+ inc i
+ goto fill_false_loop
+ fill_false_end:
+ nok(result, "Fill with 0")
+
+ $P0.'fill'(1)
+ i = 0
+ result = 1
+ $I1 = 0
+ fill_true_loop:
+ unless i < size goto fill_true_end
+ $I0 = $P0[i]
+ result = and result, $I0
+ inc i
+ goto fill_true_loop
+ fill_true_end:
+ ok(result, "Fill with 1")
+.end
# Local Variables:
Modified: branches/gc-refactor/t/pmc/fixedpmcarray.t
==============================================================================
--- branches/gc-refactor/t/pmc/fixedpmcarray.t Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/t/pmc/fixedpmcarray.t Wed Sep 16 18:24:30 2009 (r41302)
@@ -1,14 +1,7 @@
-#! perl
+#! parrot
# Copyright (C) 2001-2009, Parrot Foundation.
# $Id$
-use strict;
-use warnings;
-use lib qw(lib . ../lib ../../lib);
-
-use Parrot::Test tests => 26;
-use Test::More;
-
=head1 NAME
t/pmc/fixedpmcarray.t - FixedPMCArray PMC
@@ -24,370 +17,96 @@
=cut
-pasm_output_is( <<'CODE', <<'OUTPUT', "Setting array size" );
- new P0, ['FixedPMCArray']
-
- set I0,P0
- eq I0,0,OK_1
- print "not "
-OK_1: print "ok 1\n"
-
- set P0,1
- set I0,P0
- eq I0,1,OK_2
- print "not "
-OK_2: print "ok 2\n"
-
- end
-CODE
-ok 1
-ok 2
-OUTPUT
-
-pir_output_is( <<'CODE', <<'OUTPUT', "Assign from other FPA");
-.sub main
- .local pmc arr1, arr2
- .local int n
- arr1 = new ['FixedPMCArray']
- arr1 = 32
- arr2 = new ['FixedPMCArray']
- arr2 = 15
- assign arr1, arr2
- n = arr1
- say n
-.end
-CODE
-15
-OUTPUT
-
-pir_output_is( <<'CODE', <<'OUTPUT', "Assign to self");
-.sub main
- .local pmc arr
- arr = new ['FixedPMCArray']
- assign arr, arr
- say 'Done'
+.sub main :main
+ .include 'test_more.pir'
+ plan(76)
+ test_setting_array_size()
+ test_assign_from_another()
+ test_assign_self()
+ test_assign_non_array()
+ test_resize_exception()
+ test_truthiness()
+ test_tt991()
+ test_setting_first_elem()
+ test_setting_second_elem()
+ test_negative_index()
+ test_oob_elem()
+ test_set_pmc_keys_access_ints()
+ test_set_ints_access_pmc_keys()
+ test_interface()
+ test_get_uninitialized()
+ test_get_null_elem()
+ test_definedness()
+ test_splice_oob()
+ test_get_repr()
+ test_elements()
+ test_equality()
+ test_multi_keys()
+ test_splice()
+ test_sort()
+ test_exists()
.end
-CODE
-Done
-OUTPUT
-pir_output_is( <<'CODE', <<'OUTPUT', "Assign from non-array");
-.sub main
- .local pmc arr, other
- .local int n
- arr = new ['FixedPMCArray']
- other = new ['Integer']
- push_eh catch
- say 'Assign'
- assign arr, other
- say 'Never here!'
- goto done
-catch:
- say 'Catched'
-done:
+.sub test_exists
+ .local pmc fpa
+ fpa = new ['FixedPMCArray']
+ fpa = 5
+ $I0 = exists fpa[3]
+ nok($I0,'FixedPMCArray element existence')
+ fpa[2] = 42
+ $I0 = exists fpa[2]
+ ok($I0,'FixedPMCArray element existence')
+
+ new $P1, ['Key']
+ set $P1, 0
+ fpa[$P1] = 99
+ $I0 = exists fpa[$P1]
+ ok($I0,'FixedPMCArray element existence')
.end
-CODE
-Assign
-Catched
-OUTPUT
-
-pasm_error_output_like( <<'CODE', <<'OUTPUT', "Resetting array size (and getting an exception)" );
- new P0, ['FixedPMCArray']
-
- set I0,P0
- set P0,1
- set P0,2
- print "Should have gotten an exception\n "
-
-
- end
-CODE
-/FixedPMCArray: Can't resize!
-current instr\.:/
-OUTPUT
-
-#VIM's syntax highlighter needs this line
-
-pasm_output_is( <<'CODE', <<'OUTPUT', "Truth and falsehood" );
- new P0, ['FixedPMCArray']
-
- set P0, 0
- if P0, NOK_1
- branch OK_1
-NOK_1: print "not "
-OK_1: print "ok 1\n"
- unless P0, OK_2
- print "not "
-OK_2: print "ok 2\n"
-
- set P0, 1
- unless P0, NOK_3
- branch OK_3
-NOK_3: print "not "
-OK_3: print "ok 3\n"
- if P0, OK_4
- print "not "
-OK_4: print "ok 4\n"
-
- end
-CODE
-ok 1
-ok 2
-ok 3
-ok 4
-OUTPUT
-
-pasm_output_is( <<'CODE', <<'OUTPUT', "Setting first element" );
- new P0, ['FixedPMCArray']
- set P0, 1
-
- set P0[0],-7
- set I0,P0[0]
- eq I0,-7,OK_1
- print "not "
-OK_1: print "ok 1\n"
-
- set P0[0],3.7
- set N0,P0[0]
- eq N0,3.7,OK_2
- print "not "
-OK_2: print "ok 2\n"
-
- set P0[0],"muwhahaha"
- set S0,P0[0]
- eq S0,"muwhahaha",OK_3
- print "not "
-OK_3: print "ok 3\n"
-
- end
-CODE
-ok 1
-ok 2
-ok 3
-OUTPUT
-
-pasm_output_is( <<'CODE', <<'OUTPUT', "Setting second element" );
- new P0, ['FixedPMCArray']
- set P0, 2
-
- set P0[1], -7
- set I0, P0[1]
- eq I0,-7,OK_1
- print "not "
-OK_1: print "ok 1\n"
-
- set P0[1], 3.7
- set N0, P0[1]
- eq N0,3.7,OK_2
- print "not "
-OK_2: print "ok 2\n"
-
- set P0[1],"purple"
- set S0, P0[1]
- eq S0,"purple",OK_3
- print "not "
-OK_3: print "ok 3\n"
-
- end
-CODE
-ok 1
-ok 2
-ok 3
-OUTPUT
-
-pasm_output_is( <<'CODE', <<'OUTPUT', "Setting negatively indexed elements" );
- new P0, ['FixedPMCArray']
- set P0, 1
-
- push_eh caught
- set P0[-1], -7
- pop_eh
- say "no exception"
- end
-caught:
- say "caught an exception"
- end
-CODE
-caught an exception
-OUTPUT
-
-pasm_output_is( <<'CODE', <<'OUTPUT', "Getting negatively indexed elements" );
- new P0, ['FixedPMCArray']
- set P0, 1
-
- push_eh caught
- set I0, P0[-1]
- pop_eh
- say "no exception"
- end
-caught:
- say "caught an exception"
- end
-CODE
-caught an exception
-OUTPUT
-
-
-pasm_output_is( <<'CODE', <<'OUTPUT', "Setting out-of-bounds elements" );
- new P0, ['FixedPMCArray']
- set P0, 1
-
- push_eh caught
- set P0[1], -7
- pop_eh
- say "no exception"
- end
-caught:
- say "caught an exception"
- end
-CODE
-caught an exception
-OUTPUT
-
-pasm_output_is( <<'CODE', <<'OUTPUT', "Getting out-of-bounds elements" );
- new P0, ['FixedPMCArray']
- set P0, 1
-
- push_eh caught
- set I0, P0[1]
- pop_eh
- say "no exception"
- end
-caught:
- say "caught an exception"
- end
-CODE
-caught an exception
-OUTPUT
-
-pasm_output_is( <<"CODE", <<'OUTPUT', "Set via PMC keys, access via INTs" );
- .include 'fp_equality.pasm'
- new P0, ['FixedPMCArray']
- set P0, 3
- new P1, ['Key']
-
- set P1, 0
- set P0[P1], 25
-
- set P1, 1
- set P0[P1], 2.5
-
- set P1, 2
- set P0[P1], "bleep"
-
- set I0, P0[0]
- eq I0, 25, OK1
- print "not "
-OK1: print "ok 1\\n"
-
- set N0, P0[1]
- .fp_eq_pasm(N0, 2.5, OK2)
- print "not "
-OK2: print "ok 2\\n"
-
- set S0, P0[2]
- eq S0, "bleep", OK3
- print "not "
-OK3: print "ok 3\\n"
-
- end
-CODE
-ok 1
-ok 2
-ok 3
-OUTPUT
-
-pasm_output_is( <<"CODE", <<'OUTPUT', "Set via INTs, access via PMC Keys" );
- .include 'fp_equality.pasm'
- new P0, ['FixedPMCArray']
- set P0, 1024
-
- set P0[25], 125
- set P0[128], 10.2
- set P0[513], "cow"
- new P1, ['Integer']
- set P1, 123456
- set P0[1023], P1
-
- new P2, ['Key']
- set P2, 25
- set I0, P0[P2]
- eq I0, 125, OK1
- print "not "
-OK1: print "ok 1\\n"
-
- set P2, 128
- set N0, P0[P2]
- .fp_eq_pasm(N0, 10.2, OK2)
- print "not "
-OK2: print "ok 2\\n"
-
- set P2, 513
- set S0, P0[P2]
- eq S0, "cow", OK3
- print "not "
-OK3: print "ok 3\\n"
-
- set P2, 1023
- set P3, P0[P2]
- set I1, P3
- eq I1, 123456, OK4
- print "not "
-OK4: print "ok 4\\n"
-
- end
-CODE
-ok 1
-ok 2
-ok 3
-ok 4
-OUTPUT
-pir_output_like(
- <<'CODE',
-
-.sub main :main
+.sub test_sort
.local pmc compares, cmp_fun
# RT #46855 doesnt work wit prederef of JIT
bounds 1
compares = new ['Integer']
compares = 0
set_global "compares", compares
- cmp_fun = get_global "cmp_fun"
+ cmp_fun = get_global "cmp_fun"
sort_ar()
sort_ar(cmp_fun)
.end
+
+# this is used by test_sort
.sub sort_ar
.param pmc cmp_fun :optional
.local pmc compares
compares = get_global "compares"
compares = 0
- .local pmc ar
- ar = new ['FixedPMCArray']
- ar = 5
- ar[0] = 10
- ar[1] = 2
- ar[2] = 5
- ar[3] = 9
- ar[4] = 1
- ar."sort"(cmp_fun)
- print "ok 1\n"
-
- .local pmc it
- iter it, ar
-lp:
- unless it goto done
- $P0 = shift it
- print $P0
- print " "
- goto lp
-done:
- print "x\n"
- print "compares: "
- print compares
- print "\n"
+ .local pmc array
+ array = new ['FixedPMCArray']
+ array = 5
+ array[0] = 10
+ array[1] = 2
+ array[2] = 5
+ array[3] = 9
+ array[4] = 1
+ array."sort"(cmp_fun)
+ ok(1,'call sort on FixedPMCArray')
+
+ .local pmc test1
+ test1 = new ['FixedPMCArray']
+ test1 = 5
+ test1[0] = 1
+ test1[1] = 2
+ test1[2] = 5
+ test1[3] = 9
+ test1[4] = 10
+
+ is_deeply( array, test1 )
+
.end
+# this is used by test_sort
.sub cmp_fun
.param pmc a
.param pmc b
@@ -399,79 +118,58 @@
.set_return $I0
.end_return
.end
-CODE
- qr/ok 1
-1 2 5 9 10 x
-compares: 0
-ok 1
-1 2 5 9 10 x
-compares: [1-9]\d*/, "sort"
-);
+.sub test_splice
+ .local pmc one
+ .local pmc test1, test2, test3
+ one = new ['Integer']
+ one = 1
-pir_output_is( << 'CODE', << 'OUTPUT', "check whether interface is done" );
+ .local pmc fpa
+ fpa = new ['FixedPMCArray']
+ fpa = 5
-.sub _main
- .local pmc pmc1
- pmc1 = new ['FixedPMCArray']
- .local int bool1
- does bool1, pmc1, "scalar"
- print bool1
- print "\n"
- does bool1, pmc1, "array"
- print bool1
- print "\n"
- does bool1, pmc1, "no_interface"
- print bool1
- print "\n"
- end
-.end
-CODE
-0
-1
-0
-OUTPUT
+ splice fpa, one, 0, 5
+ test1 = new ['FixedPMCArray']
+ test1 = 5
+ test1[0] = 1
+ test1[1] = 1
+ test1[2] = 1
+ test1[3] = 1
+ test1[4] = 1
-pir_error_output_like( <<'CODE', <<'OUTPUT', "Getting unitialized elements" );
+ is_deeply(fpa, test1 )
-.sub main :main
- .local pmc arr1
- arr1 = new ['FixedPMCArray']
- arr1 = 2005
- .local pmc elem_1956
- elem_1956 = arr1[1956]
- .local string type_1956
- type_1956 = typeof elem_1956
- print type_1956
-.end
-CODE
-/Null PMC access in name()/
-OUTPUT
+ .local pmc two
+ two = new ['Integer']
+ two = 2
-pir_output_is(<<'CODE', <<'OUTPUT', "Getting null elements");
+ splice fpa, two, 1, 3
+ test2 = new ['FixedPMCArray']
+ test2 = 5
+ test2[0] = 1
+ test2[1] = 2
+ test2[2] = 2
+ test2[3] = 2
+ test2[4] = 1
+ is_deeply(fpa, test2 )
-.sub main :main
- .local pmc arr1, n
- .local int i
- .local string s
- arr1 = new ['FixedPMCArray']
- arr1 = 1
- arr1[0] = n
- i = arr1[0]
- say i
- s = arr1[0]
- print '"'
- print s
- say '"'
-.end
-CODE
-0
-""
-OUTPUT
+ .local pmc three
+ three = new ['Integer']
+ three = 3
-pir_output_is( << 'CODE', << 'OUTPUT', "Multi keys" );
+ splice fpa, three, 2, 3
+ test3 = new ['FixedPMCArray']
+ test3 = 5
+ test3[0] = 1
+ test3[1] = 2
+ test3[2] = 3
+ test3[3] = 3
+ test3[4] = 3
+ is_deeply(fpa, test3 )
+.end
-.sub test :main
+.sub test_multi_keys
.local pmc matrix, row
.local pmc elem_in_pmc
.local pmc elem_out_pmc
@@ -492,116 +190,62 @@
matrix[0;3] = "asdf"
elem_out_int = matrix[0;0]
- print "set_integer_keyed, get_integer_keyed: "
- print elem_out_int
- print "\n"
+ is(elem_out_int,128)
- print "set_integer_keyed, get_pmc_keyed: "
elem_out_pmc = matrix[0;0]
- print elem_out_pmc
- print "\n"
+ is(elem_out_pmc,128)
- print "set_integer_keyed, get_number_keyed: "
elem_out_num = matrix[0;0]
- print elem_out_num
- print "\n"
+ is(elem_out_num,128)
- print "set_integer_keyed, get_string_keyed: "
elem_out_string = matrix[0;0]
- print elem_out_string
- print "\n"
+ is(elem_out_string,128)
- print "set_number_keyed, get_pmc_keyed: "
elem_out_pmc = matrix[0;1]
- print elem_out_pmc
- print "\n"
+ is(elem_out_pmc,"128.128")
- print "set_number_keyed, get_number_keyed: "
elem_out_num = matrix[0;1]
- print elem_out_num
- print "\n"
+ is(elem_out_num,"128.128")
- print "set_number_keyed, get_string_keyed: "
elem_out_string = matrix[0;1]
- print elem_out_string
- print "\n"
+ is(elem_out_string,"128.128")
elem_out_int = matrix[0;2]
- print "set_pmc_keyed, get_integer_keyed: "
- print elem_out_int
- print "\n"
+ is(elem_out_int,256)
- print "set_pmc_keyed, get_pmc_keyed: "
elem_out_pmc = matrix[0;2]
- print elem_out_pmc
- print "\n"
+ is(elem_out_pmc,256)
- print "set_pmc_keyed, get_number_keyed: "
elem_out_num = matrix[0;2]
- print elem_out_num
- print "\n"
+ is(elem_out_num,256)
- print "set_pmc_keyed, get_string_keyed: "
elem_out_string = matrix[0;2]
- print elem_out_string
- print "\n"
+ is(elem_out_string,256)
elem_out_int = matrix[0;0]
- print "set_integer_keyed, get_integer_keyed: "
- print elem_out_int
- print "\n"
+ is(elem_out_int,128)
- print "set_integer_keyed, get_pmc_keyed: "
elem_out_pmc = matrix[0;0]
- print elem_out_pmc
- print "\n"
+ is(elem_out_pmc,128)
- print "set_integer_keyed, get_number_keyed: "
elem_out_num = matrix[0;0]
- print elem_out_num
- print "\n"
+ is(elem_out_num,128)
- print "set_integer_keyed, get_string_keyed: "
elem_out_string = matrix[0;0]
- print elem_out_string
- print "\n"
+ is(elem_out_string,128)
.end
-CODE
-set_integer_keyed, get_integer_keyed: 128
-set_integer_keyed, get_pmc_keyed: 128
-set_integer_keyed, get_number_keyed: 128
-set_integer_keyed, get_string_keyed: 128
-set_number_keyed, get_pmc_keyed: 128.128
-set_number_keyed, get_number_keyed: 128.128
-set_number_keyed, get_string_keyed: 128.128
-set_pmc_keyed, get_integer_keyed: 256
-set_pmc_keyed, get_pmc_keyed: 256
-set_pmc_keyed, get_number_keyed: 256
-set_pmc_keyed, get_string_keyed: 256
-set_integer_keyed, get_integer_keyed: 128
-set_integer_keyed, get_pmc_keyed: 128
-set_integer_keyed, get_number_keyed: 128
-set_integer_keyed, get_string_keyed: 128
-OUTPUT
-pir_output_is( <<'CODE', <<'OUTPUT', "equality" );
-.sub main :main
+.sub test_equality
.local pmc fpa1, fpa2, p1, p2
.local int i
fpa1 = new ['FixedPMCArray']
fpa2 = new ['FixedPMCArray']
- print "1:"
- if fpa1 == fpa2 goto L1
- print "not "
-L1: say "equal"
+ is(fpa1,fpa2)
fpa1 = 3
- print "2:"
- if fpa1 == fpa2 goto L2
- print "not "
-L2: say "equal"
+ isnt(fpa1,fpa2)
fpa2 = 3
@@ -613,10 +257,7 @@
fpa1[0] = p1
fpa2[0] = p2
- print "3:"
- if fpa1 == fpa2 goto L3
- print "not "
-L3: say "equal"
+ is(fpa1,fpa2)
p1 = new ['String']
p2 = new ['String']
@@ -625,196 +266,362 @@
fpa1[1] = p1
- print "4:"
- if fpa1 == fpa2 goto L4
- print "not "
-L4: say "equal"
+ isnt(fpa1,fpa2)
fpa2[1] = p2
- print "5:"
- if fpa1 == fpa2 goto L5
- print "not "
-L5: say "equal"
-
-.end
-CODE
-1:equal
-2:not equal
-3:equal
-4:not equal
-5:equal
-OUTPUT
+ is(fpa1,fpa2)
-pir_output_is( <<'CODE', <<'OUTPUT', "defined" );
-.sub main :main
- .local pmc arr1
- arr1 = new ['FixedPMCArray']
- arr1 = 2005
- .local int defined_elem_1956
- defined_elem_1956 = defined arr1[1956]
- print defined_elem_1956
- arr1[1956] = 42
- defined_elem_1956 = defined arr1[1956]
- print defined_elem_1956
- .local pmc val
- null val
- arr1[1956] = val
- defined_elem_1956 = defined arr1[1956]
- print defined_elem_1956
- print "\n"
.end
-CODE
-010
-OUTPUT
-pir_output_is( <<'CODE', <<'OUTPUT', "elements, get_integer, get_number" );
-.sub 'test' :main
+.sub test_elements
.local pmc arr1
.local int elems_i
.local num elems_f
arr1 = new ['FixedPMCArray']
arr1 = 0
elems_i = elements arr1
- if elems_i == 0 goto ok_1
- print 'not '
- ok_1:
- say 'ok 1'
+ is(elems_i,0)
elems_i = arr1
- if elems_i == 0 goto ok_2
- print 'not '
- ok_2:
- say 'ok 2'
+ is(elems_i,0)
elems_f = arr1
- if elems_f == 0 goto ok_3
- print 'not '
- ok_3:
- say 'ok 3'
+ is(elems_f,0)
arr1 = new ['FixedPMCArray']
arr1 = 2048
elems_i = elements arr1
- if elems_i == 2048 goto ok_4
- print 'not '
- ok_4:
- say 'ok 4'
+ is(elems_i,2048)
elems_i = arr1
- if elems_i == 2048 goto ok_5
- print 'not '
- ok_5:
- say 'ok 5'
+ is(elems_i,2048)
elems_f = arr1
- if elems_f == 2048 goto ok_6
- print 'not '
- ok_6:
- say 'ok 6'
-.end
-CODE
-ok 1
-ok 2
-ok 3
-ok 4
-ok 5
-ok 6
-OUTPUT
+ is(elems_f,2048)
+.end
-pir_output_is(<<'CODE', <<'OUTPUT', 'basic splice');
-.sub 'main'
- .local pmc one
- one = new ['Integer']
- one = 1
+.sub test_get_repr
+ .local string s, aux
+ s = get_repr_fpa_n(0)
+ aux = get_repr_fpa_n(1)
+ concat s, aux
+ aux = get_repr_fpa_n(2)
+ concat s, aux
+ aux = get_repr_fpa_n(3)
+ concat s, aux
+ like(s,'\(\)\(0\)\(0\,\s*1\)\(0\,\s*1\,\s*2\)','get_repr')
+.end
- .local pmc fpa
+.sub get_repr_fpa_n
+ .param int n
+ .local int i
+ .local pmc fpa, p
+ .local string s
fpa = new ['FixedPMCArray']
- fpa = 5
+ fpa = n
+ i = 0
+next:
+ if i == n goto done
+ p = box i
+ fpa[i] = p
+ inc i
+ goto next
+done:
+ s = get_repr fpa
+ .return(s)
+.end
- splice fpa, one, 0, 5
- print_array( fpa )
+.sub test_splice_oob
+ throws_like(<<'CODE',':s FixedPMCArray\: index out of bounds','splice oob, offset 0')
+ .sub main
+ .local pmc fpa
+ fpa = new ['FixedPMCArray']
+ fpa = 5
- .local pmc two
- two = new ['Integer']
- two = 2
+ .local pmc nil
+ nil = new ['Undef']
- splice fpa, two, 1, 3
- print_array( fpa )
+ splice fpa, nil, 0, 6
+ .end
+CODE
+ throws_like(<<'CODE',':s FixedPMCArray\: index out of bounds','splice oob, big offset')
+ .sub main
+ .local pmc fpa
+ fpa = new ['FixedPMCArray']
+ fpa = 5
- .local pmc three
- three = new ['Integer']
- three = 3
+ .local pmc nil
+ nil = new ['Undef']
- splice fpa, three, 2, 3
- print_array( fpa )
+ splice fpa, nil, 6, 0
+ .end
+CODE
.end
-.sub 'print_array'
- .param pmc fpa
-
- .local pmc it
- iter it, fpa
+.sub test_definedness
+ .local pmc arr1
+ arr1 = new ['FixedPMCArray']
+ arr1 = 2005
+ .local int defined_elem_1956
+ defined_elem_1956 = defined arr1[1956]
+ is(defined_elem_1956,0,'definedness')
+ arr1[1956] = 42
+ defined_elem_1956 = defined arr1[1956]
+ is(defined_elem_1956,1,'definedness')
+ .local pmc val
+ null val
+ arr1[1956] = val
+ defined_elem_1956 = defined arr1[1956]
+ is(defined_elem_1956,0,'definedness')
+.end
- .local pmc elem
- iter_start:
- elem = shift it
- print elem
- if it goto iter_start
- iter_end:
- print "\n"
+.sub test_get_null_elem
+ .local pmc arr1, n
+ .local int i
+ .local string s
+ arr1 = new ['FixedPMCArray']
+ arr1 = 1
+ arr1[0] = n
+ i = arr1[0]
+ is(i,0,'null int is 0')
+ s = arr1[0]
+ is(s,"",'null string is empty string')
.end
+
+.sub test_get_uninitialized
+ throws_like(<<'CODE',':s Null PMC access in name','get uninitialized')
+ .sub main
+ .local pmc arr1
+ arr1 = new ['FixedPMCArray']
+ arr1 = 2005
+ .local pmc elem_1956
+ elem_1956 = arr1[1956]
+ .local string type_1956
+ type_1956 = typeof elem_1956
+ print type_1956
+ .end
CODE
-11111
-12221
-12333
-OUTPUT
+.end
-pir_error_output_like(<<'CODE', <<'OUTPUT', 'splice out of bounds, offset 0');
-.sub 'main'
- .local pmc fpa
- fpa = new ['FixedPMCArray']
- fpa = 5
+.sub test_interface
+ .local pmc pmc1
+ pmc1 = new ['FixedPMCArray']
+ .local int bool1
+ does bool1, pmc1, "scalar"
+ nok(bool1,'FixedPMCArray does not scalar')
+ does bool1, pmc1, "array"
+ ok(bool1,'FixedPMCArray does array')
+ does bool1, pmc1, "no_interface"
+ nok(bool1,'no interface')
+.end
+.sub test_set_ints_access_pmc_keys
+ new $P0, ['FixedPMCArray']
+ set $P0, 1024
+
+ set $P0[25], 125
+ set $P0[128], 10.2
+ set $P0[513], "cow"
+ new $P1, ['Integer']
+ set $P1, 123456
+ set $P0[1023], $P1
+
+ new $P2, ['Key']
+ set $P2, 25
+ set $I0, $P0[$P2]
+ is($I0, 125,'got int with pmc key')
+
+ set $P2, 128
+ set $N0, $P0[$P2]
+ is($N0,10.2,'got float with pmc key',0.00001)
- .local pmc nil
- nil = new ['Undef']
+ set $P2, 513
+ set $S0, $P0[$P2]
+ is($S0, "cow", 'got string with pmc key')
- splice fpa, nil, 0, 6
+ set $P2, 1023
+ set $P3, $P0[$P2]
+ set $I1, $P3
+ is($I1, 123456, 'got another int with pmc key')
.end
+
+.sub test_set_pmc_keys_access_ints
+ new $P0, ['FixedPMCArray']
+ set $P0, 3
+ new $P1, ['Key']
+
+ set $P1, 0
+ set $P0[$P1], 25
+
+ set $P1, 1
+ set $P0[$P1], 2.5
+
+ set $P1, 2
+ set $P0[$P1], "bleep"
+
+ set $I0, $P0[0]
+ is($I0, 25,'got integer with int lookup')
+ set $N0, $P0[1]
+ is($N0,2.5,'got float with int lookup',0.00001)
+
+ set $S0, $P0[2]
+ is($S0, "bleep",'got string with int lookup')
+.end
+
+.sub test_oob_elem
+ throws_like(<<'CODE',':s FixedPMCArray\: index out of bounds\!','set out-of-bounds index')
+ .sub main
+ new $P0, ['FixedPMCArray']
+ set $P0, 1
+ set $P0[1], -7
+ .end
+CODE
+ throws_like(<<'CODE',':s FixedPMCArray\: index out of bounds\!','set out-of-bounds index')
+ .sub main
+ new $P0, ['FixedPMCArray']
+ set $P0, 1
+ set $I0, $P0[1]
+ .end
CODE
-/FixedPMCArray: index out of bounds!/
-OUTPUT
-pir_error_output_like(<<'CODE', <<'OUTPUT', 'splice out of bounds, big offset');
-.sub 'main'
- .local pmc fpa
- fpa = new ['FixedPMCArray']
- fpa = 5
+.end
- .local pmc nil
- nil = new ['Undef']
+.sub test_negative_index
+ throws_like(<<'CODE',':s FixedPMCArray\: index out of bounds\!','set negative index')
+.sub main
+ new $P0, ['FixedPMCArray']
+ set $P0, 1
+ set $P0[-1], -7
+.end
+CODE
+ throws_like(<<'CODE',':s FixedPMCArray\: index out of bounds\!','get negative index')
+.sub main
+ new $P0, ['FixedPMCArray']
+ set $P0, 1
+ set $I0, $P0[-1]
+.end
+CODE
- splice fpa, nil, 6, 0
.end
+
+.sub test_setting_second_elem
+ new $P0, ['FixedPMCArray']
+ set $P0, 2
+
+ set $P0[1],-7
+ set $I0,$P0[1]
+ is($I0,-7,'set second elem to int')
+
+ set $P0[1],3.7
+ set $N0,$P0[1]
+ is($N0,3.7,'set second elem to float')
+
+ set $P0[1],"muwhahaha"
+ set $S0,$P0[1]
+ is($S0,"muwhahaha",'set second elem to string')
+.end
+
+.sub test_setting_first_elem
+ new $P0, ['FixedPMCArray']
+ set $P0, 1
+
+ set $P0[0],-7
+ set $I0,$P0[0]
+ is($I0,-7,'set first elem to int')
+
+ set $P0[0],3.7
+ set $N0,$P0[0]
+ is($N0,3.7,'set first elem to float')
+
+ set $P0[0],"muwhahaha"
+ set $S0,$P0[0]
+ is($S0,"muwhahaha",'set first elem to string')
+.end
+
+.sub test_truthiness
+ new $P0, ['FixedPMCArray']
+ set $P0, 0
+ nok($P0,'length 0 FixedPMCArray is falsey')
+ set $P0, 1
+ ok($P0, 'length 1 FixedPMCArray is truthy')
+.end
+
+.sub test_tt991
+ throws_like(<<'CODE',':s FixedPMCArray\: Cannot set array size to a negative number','cannot create a negative length array')
+ .sub main
+ new $P0, ['FixedPMCArray']
+ set $P0, -1
+ .end
CODE
-/FixedPMCArray: index out of bounds!/
-OUTPUT
+.end
-pir_output_like( <<'CODE', <<'OUTPUT', 'get_repr');
-.sub 'main'
- .local pmc fpa, n
- .local string s
- fpa = new ['FixedPMCArray']
- fpa = 2
- n = box 1
- fpa[0] = n
- fpa[1] = n
- s = get_repr fpa
- say s
+.sub test_resize_exception
+ throws_like(<<'CODE',':s FixedPMCArray\: Can.t resize','cannot resize FixedPMCArray')
+ .sub main
+ new $P0, ['FixedPMCArray']
+ set $I0,$P0
+ set $P0,1
+ set $P0,2
+ .end
+CODE
+
+ throws_like(<<'CODE',":s set_number_native.* not implemented in class .*FixedPMCArray", 'cannot use float as length to FixedPMCArray')
+ .sub main
+ new $P0, ['FixedPMCArray']
+ set $P0, 42.0
+ .end
+CODE
+
+ throws_like(<<'CODE',":s set_string_native.* not implemented in class .*FixedPMCArray", 'cannot use string as length to FixedPMCArray')
+ .sub main
+ new $P0, ['FixedPMCArray']
+ set $P0,"GIGO"
+ .end
+CODE
.end
+
+.sub test_assign_non_array
+ throws_like(<<'CODE', ':s Can.t set self from this type','assign from non-array')
+ .sub main
+ .local pmc arr, other
+ .local int n
+ arr = new ['FixedPMCArray']
+ other = new ['Integer']
+ assign arr, other
+ .end
CODE
-/(1,\s*1)/
-OUTPUT
+.end
+
+.sub test_assign_self
+ .local pmc arr
+ arr = new ['FixedPMCArray']
+ assign arr, arr
+ ok(1, 'Can assign FixedPMCArray to itself')
+.end
+
+.sub test_assign_from_another
+ .local pmc arr1, arr2
+ .local int n
+ arr1 = new ['FixedPMCArray']
+ arr1 = 32
+ arr2 = new ['FixedPMCArray']
+ arr2 = 15
+ assign arr1, arr2
+ n = arr1
+ is(n,15,'assigning to FixedPMCArray from another FixedPMCArray')
+.end
+
+.sub test_setting_array_size
+ new $P0, ['FixedPMCArray']
+
+ set $I0, $P0
+ is($I0,0,'size of new FixedPMCArray is 0')
+
+ set $P0, 1
+ set $I0, $P0
+
+ is($I0,1,'size of FixedPMCArray is 1')
+.end
# Local Variables:
# mode: cperl
Modified: branches/gc-refactor/t/pmc/hash.t
==============================================================================
--- branches/gc-refactor/t/pmc/hash.t Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/t/pmc/hash.t Wed Sep 16 18:24:30 2009 (r41302)
@@ -23,7 +23,7 @@
.include 'except_types.pasm'
.include 'datatypes.pasm'
- plan(161)
+ plan(165)
initial_hash_tests()
more_than_one_hash()
@@ -71,6 +71,7 @@
integer_keys()
value_types_convertion()
elements_in_hash()
+ equality_tests()
.end
.sub initial_hash_tests
@@ -1369,6 +1370,40 @@
.end
+.sub 'equality_tests'
+ .local pmc hash1, hash2, hash3, hash4, hash5
+ hash1 = new ['Hash']
+ hash2 = new ['Hash']
+ hash3 = new ['Hash']
+ hash4 = new ['Hash']
+
+ hash1['one'] = "Hello Parrot!"
+ hash1['two'] = 1664
+ hash1['three'] = 2.718
+
+ hash2['ONE'] = "Hello Parrot!"
+ hash2['TWO'] = 1664
+ hash2['THREE'] = 2.718
+
+ $P0 = box "Hello Parrot!"
+ hash3['one'] = $P0
+ $P0 = box 1664
+ hash3['two'] = $P0
+ $P0 = box 2.718
+ hash3['three'] = $P0
+
+ hash4['one'] = "Goodbye Parrot!"
+ hash4['two'] = 1664
+ hash4['three'] = 2.718
+
+ hash5 = clone hash1
+
+ isnt(hash1, hash2, 'Hashes with different keys')
+ is(hash1, hash3, 'Equal hashes, physically disjoint')
+ isnt(hash1, hash4, 'Different hash values')
+ is(hash1, hash5, 'Clones are equal')
+.end
+
# Local Variables:
# mode: pir
# fill-column: 100
Modified: branches/gc-refactor/t/pmc/integer.t
==============================================================================
--- branches/gc-refactor/t/pmc/integer.t Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/t/pmc/integer.t Wed Sep 16 18:24:30 2009 (r41302)
@@ -19,7 +19,8 @@
.sub 'test' :main
.include 'test_more.pir'
- plan(60)
+ plan(62)
+ test_init()
test_basic_math()
test_truthiness_and_definedness()
test_set_string_native()
@@ -40,6 +41,15 @@
test_cmp_RT59336()
.end
+.sub test_init
+ .local pmc i1, i2
+ i1 = new ['Integer']
+ is(i1, 0, "Default value of Integer is 0")
+ i1 = 42
+ i2 = new ['Integer'], i1
+ is(i2, 42, "Initialize with argument set correct value")
+.end
+
.sub test_get_as_base_bounds_check
throws_like(<<'CODE', ':s get_as_base\: base out of bounds', 'get_as_base lower bound check')
.sub main
Modified: branches/gc-refactor/t/pmc/resizablefloatarray.t
==============================================================================
--- branches/gc-refactor/t/pmc/resizablefloatarray.t Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/t/pmc/resizablefloatarray.t Wed Sep 16 18:24:30 2009 (r41302)
@@ -1,13 +1,7 @@
-#! perl
-# Copyright (C) 2001-2008, Parrot Foundation.
+#! parrot
+# Copyright (C) 2001-2009, Parrot Foundation.
# $Id$
-use strict;
-use warnings;
-use lib qw( . lib ../lib ../../lib );
-use Test::More;
-use Parrot::Test tests => 22;
-
=head1 NAME
t/pmc/resizablefloatarray.t - ResizableFloatArray PMC
@@ -23,495 +17,453 @@
=cut
-pasm_output_is( <<'CODE', <<'OUTPUT', 'creation' );
- new P0, ['ResizableFloatArray']
- print "ok\n"
- end
-CODE
-ok
-OUTPUT
-
-pasm_output_is( <<'CODE', <<'OUTPUT', "Setting array size" );
- new P0, ['ResizableFloatArray']
-
- set I0,P0
- eq I0,0,OK_1
- print "not "
-OK_1: print "ok 1\n"
-
- set P0,1
- set I0,P0
- eq I0,1,OK_2
- print "not "
-OK_2: print "ok 2\n"
-
- set P0,5
- set I0,P0
- eq I0,5,OK_3
- print "not "
-OK_3: print "ok 3\n"
-
- set P0,9
- set I0,P0
- eq I0,9,OK_4
- print "not "
-OK_4: print "ok 4\n"
-
- set P0,7
- set I0,P0
- eq I0,7,OK_5
- print "not "
-OK_5: print "ok 5\n"
-
- end
-CODE
-ok 1
-ok 2
-ok 3
-ok 4
-ok 5
-OUTPUT
-
-pasm_error_output_like( <<'CODE', <<'OUTPUT', "Setting negative array size" );
- new P0, ['ResizableFloatArray']
- set P0, -100
- end
-CODE
-/ResizableFloatArray: Can't resize to negative value!/
-OUTPUT
-
-pasm_output_is( <<'CODE', <<'OUTPUT', "Setting first element" );
- new P0, ['ResizableFloatArray']
- set P0, 1
-
- set P0[0],-7
- set I0,P0[0]
- eq I0,-7,OK_1
- print "not "
-OK_1: print "ok 1\n"
-
- set P0[0],3.7
- set N0,P0[0]
- eq N0,3.7,OK_2
- print "not "
-OK_2: print "ok 2\n"
-
- set P0[0],"17.2"
- set S0,P0[0]
- eq S0,"17.2",OK_3
- print "not "
-OK_3: print "ok 3\n"
-
- end
-CODE
-ok 1
-ok 2
-ok 3
-OUTPUT
-
-pasm_output_is( <<'CODE', <<'OUTPUT', "Setting second element" );
- new P0, ['ResizableFloatArray']
-
- set P0[1], -7
- set I0, P0[1]
- eq I0,-7,OK_1
- print "not "
-OK_1: print "ok 1\n"
-
- set P0[1], 3.7
- set N0, P0[1]
- eq N0,3.7,OK_2
- print "not "
-OK_2: print "ok 2\n"
-
- set P0[1],"17.1"
- set S0, P0[1]
- eq S0,"17.1",OK_3
- print "not "
-OK_3: print "ok 3\n"
-
- end
-CODE
-ok 1
-ok 2
-ok 3
-OUTPUT
-
-pasm_output_is( <<'CODE', <<'OUTPUT', "Setting negatively indexed elements" );
- new P0, ['ResizableFloatArray']
- set P0, 1
+.const int TESTS = 55
+.const num PRECISION = 1e-6
+
+.sub 'test' :main
+ .include 'test_more.pir'
+ .include 'fp_equality.pasm'
+
+ plan(TESTS)
+
+ creation()
+ setting_size()
+ negative_size()
+ setting_first_element()
+ setting_second_element()
+ setting_negative_index()
+ getting_negative_index()
+ setting_out_of_bounds()
+ getting_out_of_bounds()
+ set_pmc_get_int()
+ set_int_get_pmc()
+ basic_push()
+ push_many_values()
+ basic_pop()
+ pop_many_values()
+ push_pop()
+ pop_empty()
+ shift_empty()
+ push_float()
+ shift_float()
+ unshift_float()
+ check_interface()
+ get_iter()
+ 'clone'()
+.end
+
+.sub 'creation'
+ $P0 = new ['ResizableFloatArray']
+ ok(1, 'creation')
+.end
+
+.sub 'setting_size'
+ $P0 = new ['ResizableFloatArray']
+
+ $I0 = $P0
+ is($I0, 0, 'size is initially 0')
+
+ $P0 = 1
+ $I0 = $P0
+ is($I0, 1, 'setting size to 1')
+
+ $P0 = 5
+ $I0 = $P0
+ is($I0, 5, 'resizing to 5')
+
+ $P0 = 9
+ $I0 = $P0
+ is($I0, 9, 'resizing to 9')
+
+ $P0 = 7
+ $I0 = $P0
+ is($I0, 7, 'resizing to 7')
+.end
+
+.sub 'negative_size'
+ $P0 = new ['ResizableFloatArray']
+
+ push_eh negative_size_handler
+ $P0 = -100
+ pop_eh
+ nok(1, 'setting negative array size')
+ .return()
+
+ negative_size_handler:
+ .get_results ($P1)
+ $S1 = $P1
+ like($S1, ":s ResizableFloatArray\\: Can\\'t resize to negative value\\!", 'setting negative array size')
+.end
+
+.sub 'setting_first_element'
+ $P0 = new ['ResizableFloatArray']
+ $P0 = 1
+
+ $P0[0] = -7
+ $I0 = $P0[0]
+ is($I0, -7, 'setting first element from int')
+
+ $P0[0] = 3.7
+ $N0 = $P0[0]
+ is($N0, 3.7, 'setting first element from number')
+
+ $P0[0] = "17.2"
+ $S0 = $P0[0]
+ is($S0, "17.2", 'setting first element from string')
+.end
+
+.sub 'setting_second_element'
+ $P0 = new ['ResizableFloatArray']
+
+ $P0[1] = -7
+ $I0 = $P0[1]
+ is($I0, -7, 'setting second element from int')
+
+ $P0[1] = 3.7
+ $N0 = $P0[1]
+ is($N0, 3.7, 'setting second element from number')
+
+ $P0[1] = "17.1"
+ $S0 = $P0[1]
+ is($S0, "17.1", 'setting second element from string')
+.end
+
+.sub 'setting_negative_index'
+ $P0 = new ['ResizableFloatArray']
+ $P0 = 1
+
+ push_eh setting_negative_index_handler
+ $P0[-1] = -7
+ pop_eh
+ nok(1, 'setting negatively indexed elements')
+ .return ()
+
+ setting_negative_index_handler:
+ ok(1, 'setting negatively indexed elements')
+.end
+
+.sub 'getting_negative_index'
+ $P0 = new ['ResizableFloatArray']
+ $P0 = 1
+
+ push_eh getting_negative_index_handler
+ $I0 = $P0[-1]
+ pop_eh
+ nok(1, 'getting negatively indexed elements')
+ .return ()
+
+ getting_negative_index_handler:
+ ok(1, 'getting negatively indexed elements')
+.end
+
+.sub 'setting_out_of_bounds'
+ $P0 = new ['ResizableFloatArray']
+ $P0 = 1
+
+ $P0[1] = -7
+ ok(1, 'setting out-of-bounds elements')
+.end
+
+.sub 'getting_out_of_bounds'
+ $P0 = new ['ResizableFloatArray']
+ $P0 = 1
+
+ $I0 = $P0[1]
+ ok(1, 'getting out-of-bounds elements')
+.end
+
+.sub 'set_pmc_get_int'
+ $P0 = new ['ResizableFloatArray']
+ $P1 = new ['Key']
+
+ $P1 = 0
+ $P0[$P1] = 25
+
+ $P1 = 1
+ $P0[$P1] = 2.5
+
+ $P1 = 2
+ $P0[$P1] = "17.32"
+
+ $I0 = $P0[0]
+ is($I0, 25, 'Set via PMC keys, access via INTs (1)')
+
+ $N0 = $P0[1]
+ is($N0, 2.5, 'Set via PMC keys, access via INTs (2)', PRECISION)
+
+ $S0 = $P0[2]
+ is($S0, "17.32", 'Set via PMC keys, access via INTs (3)')
+.end
+
+.sub 'set_int_get_pmc'
+ $P0 = new ['ResizableFloatArray']
+ $P0 = 1
+
+ $P0[25] = 125
+ $P0[128] = 10.2
+ $P0[513] = "17.3"
+ $P1 = new ['Integer']
+ $P1 = 123456
+ $P0[1023] = $P1
+
+ $P2 = new ['Key']
+
+ $P2 = 25
+ $I0 = $P0[$P2]
+ is($I0, 125, 'Set via INTs, access via PMC Keys (1)')
+
+ $P2 = 128
+ $N0 = $P0[$P2]
+ is($N0, 10.2, 'Set via INTs, access via PMC Keys (2)', PRECISION)
+
+ $P2 = 513
+ $S0 = $P0[$P2]
+ is($S0, "17.3", 'Set via INTs, access via PMC Keys (3)')
+
+ $P2 = 1023
+ $I0 = $P0[$P2]
+ is($I0, 123456, 'Set via INTs, access via PMC Keys (4)')
+.end
+
+.sub 'basic_push'
+ $P0 = new ['ResizableFloatArray']
+ push $P0, 1.0
+ push $P0, 2.0
+ push $P0, 3.0
+
+ $N0 = $P0[0]
+ is($N0, 1.0, 'basic push (1)', PRECISION)
+
+ $N0 = $P0[1]
+ is($N0, 2.0, 'basic push (2)', PRECISION)
+
+ $N0 = $P0[2]
+ is($N0, 3.0, 'basic push (3)', PRECISION)
+.end
+
+.sub 'push_many_values'
+ $P0 = new ['ResizableFloatArray']
+
+ $I0 = 0
+ push_many_values_fill:
+ $N0 = $I0
+ push $P0, $N0
+ inc $I0
+ if $I0 < 100000 goto push_many_values_fill
+
+ push_many_values_test:
+ dec $I0
+ $N0 = $I0
+ $N1 = $P0[$I0]
+ .fp_ne($N0, $N1, push_many_values_evil)
+ if $I0 > 0 goto push_many_values_test
+
+ ok(1, 'push many values')
+ .return ()
- push_eh caught
- set P0[-1], -7
+ push_many_values_evil:
+ nok(1, 'push many values is evil')
+.end
+
+.sub 'basic_pop'
+ $P0 = new ['ResizableFloatArray']
+ $P0[0] = 1.0
+ $P0[1] = 2.0
+ $P0[2] = 3.0
+
+ $N0 = pop $P0
+ is($N0, 3.0, 'basic pop (1)', PRECISION)
+
+ $N0 = pop $P0
+ is($N0, 2.0, 'basic pop (2)', PRECISION)
+
+ $N0 = pop $P0
+ is($N0, 1.0, 'basic pop (3)', PRECISION)
+.end
+
+.sub 'pop_many_values'
+ $P0 = new ['ResizableFloatArray']
+
+ $I0 = 0
+ pop_many_values_fill:
+ $N0 = $I0
+ $P0[$I0] = $N0
+ inc $I0
+ if $I0 < 100000 goto pop_many_values_fill
+
+ pop_many_values_test:
+ dec $I0
+ $N0 = $I0
+ $N1 = pop $P0
+ .fp_ne($N0, $N1, pop_many_values_evil)
+ if $I0 > 0 goto pop_many_values_test
+
+ ok(1, 'pop many values')
+ .return ()
+
+ pop_many_values_evil:
+ nok(1, 'pop many values is evil')
+.end
+
+.sub 'push_pop'
+ $P0 = new ['ResizableFloatArray']
+ push $P0, 1.0
+ push $P0, 2.0
+ push $P0, 3.0
+
+ $N0 = pop $P0
+ is($N0, 3.0, 'push/pop (1)')
+
+ $N0 = pop $P0
+ is($N0, 2.0, 'push/pop (2)')
+
+ $N0 = pop $P0
+ is($N0, 1.0, 'push/pop (3)')
+.end
+
+.sub 'pop_empty'
+ $P0 = new ['ResizableFloatArray']
+
+ push_eh pop_empty_handler
+ $N0 = pop $P0
pop_eh
- print "no exception\n"
- end
-caught:
- say "caught something"
- end
-CODE
-caught something
-OUTPUT
-
-pasm_output_is( <<'CODE', <<'OUTPUT', "Getting negatively indexed elements" );
- new P0, ['ResizableFloatArray']
- set P0, 1
+ nok(1, 'pop from empty array')
+ .return()
+
+ pop_empty_handler:
+ .get_results($P0)
+ $S0 = $P0
+ like($S0, ":s ResizableFloatArray\\: Can\\'t pop from an empty array\\!", 'pop from empty array')
+.end
+
+.sub 'shift_empty'
+ $P0 = new ['ResizableFloatArray']
- push_eh caught
- set I0, P0[-1]
+ push_eh shift_empty_handler
+ $N0 = shift $P0
pop_eh
- say "no exception"
- end
-caught:
- say "caught an exception"
- end
-CODE
-caught an exception
-OUTPUT
-
-pasm_output_is( <<'CODE', <<'OUTPUT', "Setting out-of-bounds elements" );
- new P0, ['ResizableFloatArray']
- set P0, 1
-
- set P0[1], -7
- print "ok 1\n"
-
- end
-CODE
-ok 1
-OUTPUT
-
-pasm_output_is( <<'CODE', <<'OUTPUT', "Getting out-of-bounds elements" );
- new P0, ['ResizableFloatArray']
- set P0, 1
-
- set I0, P0[1]
- print "ok 1\n"
- end
-CODE
-ok 1
-OUTPUT
-
-pasm_output_is( <<"CODE", <<'OUTPUT', "Set via PMC keys, access via INTs" );
- .include 'fp_equality.pasm'
- new P0, ['ResizableFloatArray']
- new P1, ['Key']
-
- set P1, 0
- set P0[P1], 25
-
- set P1, 1
- set P0[P1], 2.5
-
- set P1, 2
- set P0[P1], "17.32"
-
- set I0, P0[0]
- eq I0, 25, OK1
- print "not "
-OK1: print "ok 1\\n"
-
- set N0, P0[1]
- .fp_eq_pasm(N0, 2.5, OK2)
- print "not "
-OK2: print "ok 2\\n"
-
- set S0, P0[2]
- eq S0, "17.32", OK3
- print "not "
-OK3: print "ok 3\\n"
-
- end
-CODE
-ok 1
-ok 2
-ok 3
-OUTPUT
-
-pasm_output_is( <<"CODE", <<'OUTPUT', "Set via INTs, access via PMC Keys" );
- .include 'fp_equality.pasm'
- new P0, ['ResizableFloatArray']
- set P0, 1
-
- set P0[25], 125
- set P0[128], 10.2
- set P0[513], "17.3"
- new P1, ['Integer']
- set P1, 123456
- set P0[1023], P1
-
- new P2, ['Key']
- set P2, 25
- set I0, P0[P2]
- eq I0, 125, OK1
- print "not "
-OK1: print "ok 1\\n"
-
- set P2, 128
- set N0, P0[P2]
- .fp_eq_pasm(N0, 10.2, OK2)
- print "not "
-OK2: print "ok 2\\n"
-
- set P2, 513
- set S0, P0[P2]
- eq S0, "17.3", OK3
- print "not "
-OK3: print "ok 3\\n"
-
- set P2, 1023
- set P3, P0[P2]
- set I1, P3
- eq I1, 123456, OK4
- print "not "
-OK4: print "ok 4\\n"
-
- end
-CODE
-ok 1
-ok 2
-ok 3
-ok 4
-OUTPUT
-
-pasm_output_is( <<"CODE", <<'OUTPUT', 'basic push' );
- .include 'fp_equality.pasm'
- new P0, ['ResizableFloatArray']
- push P0, 1.0
- push P0, 2.0
- push P0, 3.0
- set N0, P0[0]
- .fp_eq_pasm(N0, 1.0, OK1)
- print "not "
-OK1: print "ok 1\\n"
-
- set N0, P0[1]
- .fp_eq_pasm(N0, 2.0, OK2)
- print "not "
-OK2: print "ok 2\\n"
-
- set N0, P0[2]
- .fp_eq_pasm(N0, 3.0, OK3)
- print "not "
-OK3: print "ok 3\\n"
- end
-CODE
-ok 1
-ok 2
-ok 3
-OUTPUT
-
-pasm_output_is( <<"CODE", <<'OUTPUT', 'push many values' );
- .include 'fp_equality.pasm'
- new P0, ['ResizableFloatArray']
- set I0, 0
-L1: set N0, I0
- push P0, N0
- inc I0
- lt I0, 100000, L1
-
- set N0, P0[99999]
- .fp_eq_pasm(N0, 99999.0, OK1)
- print N0
- print "not "
-OK1: print "ok 1\\n"
- end
-CODE
-ok 1
-OUTPUT
-
-pasm_output_is( <<"CODE", <<'OUTPUT', 'basic pop' );
- .include 'fp_equality.pasm'
- new P0, ['ResizableFloatArray']
- set P0[0], 1.0
- set P0[1], 2.0
- set P0[2], 3.0
- pop N0, P0
- .fp_eq_pasm(N0, 3.0, OK1)
- print "not "
-OK1: print "ok 1\\n"
-
- pop N0, P0
- .fp_eq_pasm(N0, 2.0, OK2)
- print "not "
-OK2: print "ok 2\\n"
-
- pop N0, P0
- .fp_eq_pasm(N0, 1.0, OK3)
- print "not "
-OK3: print "ok 3\\n"
- end
-CODE
-ok 1
-ok 2
-ok 3
-OUTPUT
-
-pasm_output_is( <<"CODE", <<'OUTPUT', 'pop many values' );
- .include 'fp_equality.pasm'
- new P0, ['ResizableFloatArray']
- set I0, 0
-L1: set N0, I0
- set P0[I0], N0
- inc I0
- lt I0, 100000, L1
-
-L2: dec I0
- set N1, I0
- pop N0, P0
- .fp_eq_pasm(N0, N1, OK)
- branch NOT_OK
-OK: gt I0, 0, L2
- print "ok\\n"
- end
-
-NOT_OK:
- print N0
- print "\\n"
- print N1
- print "\\n"
- end
-CODE
-ok
-OUTPUT
-
-pasm_output_is( <<"CODE", <<'OUTPUT', 'push/pop' );
- .include 'fp_equality.pasm'
- new P0, ['ResizableFloatArray']
- push P0, 1.0
- push P0, 2.0
- push P0, 3.0
- pop N0, P0
- .fp_eq_pasm(N0, 3.0, OK1)
- print "not "
-OK1: print "ok 1\\n"
- end
-CODE
-ok 1
-OUTPUT
-
-pasm_error_output_like( <<'CODE', <<'OUTPUT', 'pop from empty array' );
- new P0, ['ResizableFloatArray']
- pop N0, P0
- end
-CODE
-/ResizableFloatArray: Can't pop from an empty array!/
-OUTPUT
-
-pir_output_is( << 'CODE', << 'OUTPUT', "check whether interface is done" );
-
-.sub _main
- .local pmc pmc1
- pmc1 = new ['ResizableFloatArray']
- .local int bool1
- does bool1, pmc1, "scalar"
- print bool1
- print "\n"
- does bool1, pmc1, "array"
- print bool1
- print "\n"
- does bool1, pmc1, "no_interface"
- print bool1
- print "\n"
- end
-.end
-CODE
-0
-1
-0
-OUTPUT
-
-pir_output_is( << 'CODE', << 'OUTPUT', "push float" );
-
-.sub _main
- .local pmc pmc1
- pmc1 = new ['ResizableFloatArray']
- pmc1[9999] = 10000.10000
- push pmc1, 123.123
- .local int elements
- elements = pmc1
- print elements
- print "\n"
- .local string last
- last = pmc1[10000]
- print last
- print "\n"
- end
-.end
-CODE
-10001
-123.123
-OUTPUT
-
-pir_output_is( << 'CODE', << 'OUTPUT', "shift float" );
-.sub test :main
- .local pmc ar
- ar = new ['ResizableFloatArray']
- ar[0] = 10.1
- ar[1] = 20.2
- $I0 = elements ar
- print $I0
- print ' '
- $N0 = shift ar
- print $N0
- print ' '
- $I0 = elements ar
- print $I0
- print ' '
- $N0 = shift ar
- print $N0
- print ' '
- $I0 = elements ar
- print $I0
- print "\n"
-.end
-CODE
-2 10.1 1 20.2 0
-OUTPUT
-
-pir_output_is( << 'CODE', << 'OUTPUT', "unshift float" );
-.sub test :main
- .local pmc ar
- ar = new ['ResizableFloatArray']
- unshift ar, 10.1
- unshift ar, 20.2
- $I0 = elements ar
- print $I0
- print ' '
- $N0 = ar[0]
- print $N0
- print ' '
- $N0 = ar[1]
- print $N0
- print "\n"
-.end
-CODE
-2 20.2 10.1
-OUTPUT
+ nok(1, 'shift from empty array')
+ .return()
+
+ shift_empty_handler:
+ .get_results($P0)
+ $S0 = $P0
+ like($S0, ":s ResizableFloatArray\\: Can\\'t shift from an empty array\\!", 'shift from empty array')
+.end
+
+.sub 'check_interface'
+ $P0 = new ['ResizableFloatArray']
+
+ $I0 = does $P0, 'scalar'
+ nok($I0, 'ResizableFloatArray does not scalar')
-pir_output_is( << 'CODE', << 'OUTPUT', "get_iter" );
-.sub main :main
+ $I0 = does $P0, 'array'
+ ok($I0, 'ResizableFloatArray does array')
+
+ $I0 = does $P0, 'no_interface'
+ nok($I0, 'ResizableFloatArray does not no_interface')
+.end
+
+.sub 'push_float'
+ $P0 = new ['ResizableFloatArray']
+ $P0[9999] = 10000.10000
+ push $P0, 123.123
+
+ $I0 = elements $P0
+ is($I0, 10001, 'push float: size')
+
+ $N0 = $P0[10000]
+ is($N0, 123.123, 'push float: test pushed element', PRECISION)
+.end
+
+.sub 'shift_float'
+ $P0 = new ['ResizableFloatArray']
+ $P0[0] = 10.1
+ $P0[1] = 20.2
+
+ $I0 = elements $P0
+ is($I0, 2, 'shift float: size')
+
+ $N0 = shift $P0
+ is($N0, 10.1, 'shift float: first element', PRECISION)
+
+ $N0 = shift $P0
+ is($N0, 20.2, 'shift float: second element', PRECISION)
+
+ $I0 = elements $P0
+ is($I0, 0, 'shift float: array now empty')
+.end
+
+.sub 'unshift_float'
+ $P0 = new ['ResizableFloatArray']
+ unshift $P0, 10.1
+ unshift $P0, 20.2
+
+ $I0 = elements $P0
+ is($I0, 2, 'unshift float: size')
+
+ $N0 = $P0[0]
+ is($N0, 20.2, 'unshift float: first element', PRECISION)
+
+ $N0 = $P0[1]
+ is($N0, 10.1, 'unshift float: second element', PRECISION)
+.end
+
+.sub 'get_iter'
$P0 = new ['ResizableFloatArray']
$P0[0] = 1.1
$P0[1] = 99.99
$P0[2] = -345.001
+
$P1 = iter $P0
-loop:
- unless $P1 goto loop_end
- $S2 = shift $P1
- say $S2
- goto loop
- loop_end:
-.end
-CODE
-1.1
-99.99
--345.001
-OUTPUT
+
+ $N0 = shift $P1
+ is($N0, 1.1, 'get_iter: first element ok', PRECISION)
+
+ $N0 = shift $P1
+ is($N0, 99.99, 'get_iter: second element ok', PRECISION)
+
+ $N0 = shift $P1
+ is($N0, -345.001, 'get_iter: third element ok', PRECISION)
+
+ nok($P1, 'get_iter: iterator emptied')
+.end
+
+.sub 'clone'
+ .local int i
+ $P0 = new ['ResizableFloatArray']
+
+ $I30 = 3000
+ i = 0
+ clone_fill:
+ unless i < $I30 goto clone_filled
+ $N0 = i + 0.01
+ $P0[i] = $N0
+ inc i
+ goto clone_fill
+
+ clone_filled:
+ $P1 = clone $P0
+ $I0 = $P0
+ $I1 = $P1
+ is($I0, $I1, 'clones have the same size')
+
+ clone_iter_loop:
+ dec $I0
+ $N0 = $P1[$I0]
+ $N1 = $I0 + 0.01
+ .fp_ne($N0, $N1, clone_evil)
+ if $I0 > 0 goto clone_iter_loop
+
+ ok(1, 'clone make a good clone')
+ .return()
+
+ clone_evil:
+ nok(0, 'clone made an evil clone')
+.end
# Local Variables:
-# mode: cperl
-# cperl-indent-level: 4
+# mode: pir
# fill-column: 100
# End:
-# vim: expandtab shiftwidth=4:
+# vim: expandtab shiftwidth=4 ft=pir:
Modified: branches/gc-refactor/t/pmc/resizablepmcarray.t
==============================================================================
--- branches/gc-refactor/t/pmc/resizablepmcarray.t Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/t/pmc/resizablepmcarray.t Wed Sep 16 18:24:30 2009 (r41302)
@@ -21,7 +21,7 @@
.include 'fp_equality.pasm'
.include 'test_more.pir'
- plan(121)
+ plan(125)
resize_tests()
negative_array_size()
@@ -30,6 +30,7 @@
set_keyed_get_keyed_tests()
interface_check()
inherited_sort_method()
+ sort_subclass()
push_pmc()
push_int()
push_string()
@@ -48,6 +49,7 @@
method_forms_of_unshift_etc()
sort_with_broken_cmp()
addr_tests()
+ equality_tests()
.end
@@ -328,6 +330,35 @@
.end
+.sub sort_subclass
+ .local pmc subrpa, arr
+ subrpa = subclass ['ResizablePMCArray'], 'ssRPA'
+ arr = new subrpa
+ arr[0] = 'p'
+ arr[1] = 'a'
+ arr[2] = 'z'
+ # Use a comparator that gives a reverse alphabetical order
+ # to make sure sort is using it, and not some default from
+ # elsewhere.
+ .local pmc comparator
+ comparator = get_global 'compare_reverse'
+ arr.'sort'(comparator)
+ .local string s, aux
+ s = typeof arr
+ concat s, ':'
+ aux = join '-', arr
+ concat s, aux
+ is(s, 'ssRPA:z-p-a', "sort works in a pir subclass, TT #218")
+.end
+
+.sub compare_reverse
+ .param string a
+ .param string b
+ $I0 = cmp_str b, a
+ .return($I0)
+.end
+
+
.sub push_pmc
.local pmc pmc_arr, pmc_9999, pmc_10000
pmc_arr = new ['ResizablePMCArray']
@@ -912,6 +943,33 @@
is($I0, $I1, 'Adding element to RPA keeps same addr')
.end
+.sub 'equality_tests'
+ .local pmc array1, array2, array3, array4
+ array1 = new ['ResizablePMCArray']
+ array2 = new ['ResizablePMCArray']
+ array3 = new ['ResizablePMCArray']
+
+ array1[0] = "Hello Parrot!"
+ array1[1] = 1664
+ array1[2] = 2.718
+
+ $P0 = box "Hello Parrot!"
+ array2[0] = $P0
+ $P0 = box 1664
+ array2[1] = $P0
+ $P0 = box 2.718
+ array2[2] = $P0
+
+ array3[0] = "Goodbye Parrot!"
+ array3[1] = 1664
+ array3[2] = 2.718
+
+ array4 = clone array1
+
+ is(array1, array2, 'Physically disjoint, but equal arrays')
+ is(array1, array4, 'Clones are equal')
+ isnt(array1, array3, 'Different arrays')
+.end
# don't forget to change the test plan
Modified: branches/gc-refactor/t/pmc/sub.t
==============================================================================
--- branches/gc-refactor/t/pmc/sub.t Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/t/pmc/sub.t Wed Sep 16 18:24:30 2009 (r41302)
@@ -9,7 +9,7 @@
use Test::More;
use Parrot::Test::Util 'create_tempfile';
-use Parrot::Test tests => 67;
+use Parrot::Test tests => 68;
use Parrot::Config;
=head1 NAME
@@ -835,7 +835,10 @@
main
OUTPUT
-pir_output_is( <<'CODE', <<'OUTPUT', "caller introspection via interp" );
+my @todo = ( todo => 'broken with JIT (TT #983)' )
+ if ( defined $ENV{TEST_PROG_ARGS} and
+ $ENV{TEST_PROG_ARGS} =~ /--runcore=jit/ );
+pir_output_is( <<'CODE', <<'OUTPUT', "caller introspection via interp", @todo );
.sub main :main
.include "interpinfo.pasm"
# this test will fail when run with -Oc
@@ -1435,7 +1438,7 @@
OUTPUT
$ENV{TEST_PROG_ARGS} ||= '';
-my @todo = $ENV{TEST_PROG_ARGS} =~ /--run-pbc/
+ at todo = $ENV{TEST_PROG_ARGS} =~ /--run-pbc/
? ( todo => 'lexicals not thawed properly from PBC, RT #60652' )
: ();
pir_output_is( <<'CODE', <<'OUTPUT', ':outer with identical sub names', @todo );
@@ -1589,6 +1592,47 @@
bazsubid
OUTPUT
+pir_output_is( <<'CODE', <<'OUTPUT', 'Thaw PIR subclass', todo => 'See TT#132' );
+.sub main :main
+
+ $P0 = get_class 'Sub'
+ $P1 = subclass $P0, 'myProc'
+
+ .local pmc pirC
+ pirC = compreg 'PIR'
+
+ .local string code
+ code = <<"END_CODE"
+
+.sub bar
+ say "hi"
+.end
+END_CODE
+
+ .local pmc compiled
+ compiled = pirC(code)
+ compiled = compiled[0] # just want the first executable sub here.
+
+ compiled() # works
+
+ .local pmc sub
+ sub = new 'myProc'
+ assign sub, compiled
+ sub() # works
+
+ $S0 = freeze sub
+ say "frozen"
+ $P2 = thaw $S0
+ say "thawed"
+ $P2()
+.end
+CODE
+hi
+hi
+frozen
+thawed
+hi
+OUTPUT
# Local Variables:
# mode: cperl
Modified: branches/gc-refactor/t/pmc/threads.t
==============================================================================
--- branches/gc-refactor/t/pmc/threads.t Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/t/pmc/threads.t Wed Sep 16 18:24:30 2009 (r41302)
@@ -508,7 +508,7 @@
.local pmc thread
thread = new ['ParrotThread']
.local pmc _thread_func
- _thread_func = get_global ['main'], 'thread_test_func'
+ _thread_func = get_hll_global ['main'], 'thread_test_func'
$I0 = .PARROT_CLONE_CODE
bor $I0, $I0, .PARROT_CLONE_CLASSES
print "in thread:\n"
Modified: branches/gc-refactor/t/pmc/undef.t
==============================================================================
--- branches/gc-refactor/t/pmc/undef.t Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/t/pmc/undef.t Wed Sep 16 18:24:30 2009 (r41302)
@@ -19,7 +19,7 @@
.sub main :main
.include 'test_more.pir'
- plan(22)
+ plan(23)
morph_to_string()
undef_pmc_is_false()
@@ -49,9 +49,18 @@
pmc1 = new ['Undef']
if pmc1 goto PMC1_IS
ok( 1, 'PMC Undef created by new is false' )
- .return()
+ goto logical_not
PMC1_IS:
ok( 0, 'PMC Undef created by new is false' )
+
+ logical_not:
+ unless pmc1 goto logical_not_passed
+ ok( 0, 'logical_not of PMC Undef created by new is false' )
+ goto done
+ logical_not_passed:
+ ok( 1, 'logical_not of PMC Undef created by new is true' )
+
+ done:
.end
.sub undef_pmc_is_not_defined
Modified: branches/gc-refactor/t/tools/pbc_dump.t
==============================================================================
--- branches/gc-refactor/t/tools/pbc_dump.t Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/t/tools/pbc_dump.t Wed Sep 16 18:24:30 2009 (r41302)
@@ -46,10 +46,10 @@
plan skip_all => "pbc_dump hasn't been built. Run make parrot_utils";
exit(0);
}
- plan tests => 7;
+ plan tests => 6;
}
-dump_output_like( <<PIR, "pir", [qr/FIXUP_t/, qr/PIC_idx/, qr/CONSTANT_t/, qr/BYTECODE_t/], 'pbc_dump basic sanity');
+dump_output_like( <<PIR, "pir", [qr/FIXUP_t/, qr/CONSTANT_t/, qr/BYTECODE_t/], 'pbc_dump basic sanity');
.sub main :main
\$I0 = 42
.end
Modified: branches/gc-refactor/tools/build/nativecall.pl
==============================================================================
--- branches/gc-refactor/tools/build/nativecall.pl Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/tools/build/nativecall.pl Wed Sep 16 18:24:30 2009 (r41302)
@@ -370,7 +370,7 @@
/p/ && do {
push @{$temps_ref}, "PMC *t_$temp_num;";
push @{$extra_preamble_ref}, "t_$temp_num = GET_NCI_P($reg_num);";
- return "VTABLE_get_pointer(interp, t_$temp_num)";
+ return "(PMC_IS_NULL(t_$temp_num) ? NULL : VTABLE_get_pointer(interp, t_$temp_num))";
};
/V/ && do {
push @{$temps_ref}, "PMC *t_$temp_num;";
Modified: branches/gc-refactor/tools/build/pmc2c.pl
==============================================================================
--- branches/gc-refactor/tools/build/pmc2c.pl Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/tools/build/pmc2c.pl Wed Sep 16 18:24:30 2009 (r41302)
@@ -86,8 +86,8 @@
=head2 Other Options
-Create fooX.c and pmc_fooX.h from fooX.dump files, also create libfoo.c
-containing the initialization function for all fooX PMCs.
+Create foo.c and pmc_foo.h from foo.dump files, also create libfoo.c
+containing the initialization function for all foo PMCs.
% perl tools/build/pmc2c.pl --library libfoo -c \
src/pmc/foo1.pmc src/pmc/foo2.pmc ...
@@ -117,6 +117,11 @@
=back
+=head1 NOTES
+
+You must use lowercase filenames for C<.pmc> files, and lowercase group
+names in the PMC specification in those files.
+
=cut
# Local Variables:
Copied: branches/gc-refactor/tools/dev/vgp_darwin (from r41301, trunk/tools/dev/vgp_darwin)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/gc-refactor/tools/dev/vgp_darwin Wed Sep 16 18:24:30 2009 (r41302, copy of r41301, trunk/tools/dev/vgp_darwin)
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+valgrind --suppressions=tools/dev/parrot.supp \
+ --num-callers=50 \
+ --leak-check=full \
+ --leak-resolution=high \
+ --show-reachable=yes \
+ --dsymutil=yes \
+ ./parrot --leak-test $@
+
Modified: branches/gc-refactor/tools/util/release.json
==============================================================================
--- branches/gc-refactor/tools/util/release.json Wed Sep 16 17:52:15 2009 (r41301)
+++ branches/gc-refactor/tools/util/release.json Wed Sep 16 18:24:30 2009 (r41302)
@@ -1,9 +1,9 @@
{
- "release.version" : "1.5.0",
- "release.name" : "TEH PARROTZ!",
+ "release.version" : "1.6.0",
+ "release.name" : "half-pie",
"release.day" : "Tuesday",
- "release.date" : "18 August 2009",
- "release.nextdate" : "15 September 2009",
+ "release.date" : "15 September 2009",
+ "release.nextdate" : "20 October 2009",
"web.root" : "http://parrot.org/",
"web.source" : "download",
@@ -11,13 +11,13 @@
"web.repository" : "https://svn.parrot.org/parrot/trunk/",
"bugday.day" : "Saturday",
- "bugday.date" : "12 September 2009",
+ "bugday.date" : "17 October 2009",
"wiki.root" : "https://trac.parrot.org/parrot/wiki/",
- "wiki.bugday" : "bug_day_2009_09_12",
+ "wiki.bugday" : "bug_day_2009_10_17",
"cpan.search" : "http://search.cpan.org/dist/parrot",
- "ftp.path" : "ftp://ftp.parrot.org/pub/parrot/releases/devel/1.5.0/",
+ "ftp.path" : "ftp://ftp.parrot.org/pub/parrot/releases/devel/1.6.0/",
"subversion.root" : "http://subversion.tigris.org/",
"svk.root" : "http://svk.bestpractical.com/"
}
More information about the parrot-commits
mailing list