Permalink
Browse files

Made the changes to figure out mask bits for various register and stack

chunks


git-svn-id: https://svn.parrot.org/parrot/trunk@309 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
1 parent 24756aa commit 9d000b4e8c70e36a4b06e08ea2b2ea48a38437b4 @dsugalski dsugalski committed Oct 12, 2001
Showing with 75 additions and 5 deletions.
  1. +42 −2 Configure.pl
  2. +1 −0 MANIFEST
  3. +1 −0 config_h.in
  4. +6 −3 hints/vms.pl
  5. +25 −0 testparrotsizes_c.in
View
@@ -85,6 +85,7 @@ END
perl => $^X,
debugging => $opt_debugging,
rm_f => 'rm -f',
+ stacklow => '(~0xfff)',
);
#copy the things from --define foo=bar
@@ -187,6 +188,30 @@ END
# and the types file
buildfile("Types_pm", "Parrot");
+# and now we figure out how big our things are
+print <<"END";
+
+Alright, now I'm gonna check some stuff by compiling and running
+another small C program. This could take a bit...
+END
+
+{
+ my %newc;
+
+ buildfile("testparrotsizes_c");
+ compiletestc("testparrotsizes");
+ %newc=eval(runtestc()) or die "Can't run the test program: $!";
+
+ @c{keys %newc}=values %newc;
+
+ @c{qw(stacklow intlow numlow strlow pmclow)} = lowbitmask(@c{qw(stackchunk iregchunk nregchunk sregchunk pregchunk)});
+
+ unlink('testparrotsizes.c', "test_siz$c{exe}", "test$c{o}");
+}
+
+# rewrite the config file with the updated info
+buildfile("config_h", "include/parrot");
+
print <<"END";
Okay, we're done!
@@ -294,9 +319,24 @@ END
}
sub compiletestc {
- system("$c{cc} $c{ccflags} -o test_siz$c{exe} test.c") and die "C compiler died!";
+ my $name;
+ $name = shift;
+ $name = "test" unless $name;
+ system("$c{cc} $c{ccflags} -o test_siz$c{exe} $name.c") and die "C compiler died!";
}
sub runtestc {
`./test_siz$c{exe}`
-}
+}
+
+# Find the bitmask for the low bits of any passed-in size
+sub lowbitmask {
+ my @returns;
+ foreach (@_) {
+ my $vector = unpack("b*", pack("V", $_));
+ my $offset = rindex($vector, "1")+1;
+ my $mask = 2**$offset - 1;
+ push @returns, "(~0x".sprintf("%x", $mask).")";
+ }
+ return @returns;
+}
View
@@ -93,6 +93,7 @@ t/test2.pasm
t/test3.pasm
test_c.in
test_main.c
+testparrotsizes_c.in
transcode.c
vtable_h.pl
vtable.tbl
View
@@ -27,6 +27,7 @@ typedef void SYNC;
#define FRAMES_PER_STR_REG_CHUNK FRAMES_PER_CHUNK
#define MASK_CHUNK_LOW_BITS (~0xfff)
+#define MASK_STACK_CHUNK_LOW_BITS ${stacklow}
${headers}
View
@@ -4,11 +4,14 @@
local $^W; #no warnings on redefinition
*compiletestc=sub {
- system("$c{cc} $c{ccflags} test.c") and die "C compiler died!";
- system("link/exe=test_siz test") and die "Link failed!";
+ my $name;
+ $name = shift;
+ $name = "test" unless $name;
+ system("$c{cc} $c{ccflags} $name.c") and die "C compiler died!";
+ system("link/exe=test_siz $name") and die "Link failed!";
};
*runtestc=sub {
`mcr []test_siz`
};
-}
+}
View
@@ -0,0 +1,25 @@
+/*
+ * test_parrot_sizes.c - figure out some sizes of Parrot things
+ *
+ * This file is automatically generated by Configure
+ * from test_parrot_sizes_c.in.
+ */
+
+#include <stdio.h>
+#include "parrot/parrot.h"
+
+int main(int argc, char **argv) {
+ printf("(");
+
+ printf("\tiregchunk=> %d,\n", sizeof(struct IRegChunk));
+ printf("\tsregchunk=> %d,\n", sizeof(struct SRegChunk));
+ printf("\tnregchunk=> %d,\n", sizeof(struct NRegChunk));
+ printf("\tpregchunk=> %d,\n", sizeof(struct PRegChunk));
+ printf("\tstackchunk=> %d,\n", sizeof(struct StackChunk));
+
+
+ printf(");");
+
+ return 0;
+}
+

0 comments on commit 9d000b4

Please sign in to comment.