[svn:parrot] r44273 - in branches/boehm_gc_2/lib/Parrot: . Pmc2c
bacek at svn.parrot.org
bacek at svn.parrot.org
Sun Feb 21 06:44:46 UTC 2010
Author: bacek
Date: Sun Feb 21 06:44:45 2010
New Revision: 44273
URL: https://trac.parrot.org/parrot/changeset/44273
Log:
Store ATTRibutes bitmap layout in VTABLE and calculate it in pmc2c
Modified:
branches/boehm_gc_2/lib/Parrot/Pmc2c/PMCEmitter.pm
branches/boehm_gc_2/lib/Parrot/Vtable.pm
Modified: branches/boehm_gc_2/lib/Parrot/Pmc2c/PMCEmitter.pm
==============================================================================
--- branches/boehm_gc_2/lib/Parrot/Pmc2c/PMCEmitter.pm Sun Feb 21 04:28:23 2010 (r44272)
+++ branches/boehm_gc_2/lib/Parrot/Pmc2c/PMCEmitter.pm Sun Feb 21 06:44:45 2010 (r44273)
@@ -460,7 +460,8 @@
NULL, /* attribute_defs */
NULL, /* ro_variant_vtable */
$methlist,
- 0 /* attr size */
+ 0, /* attr size */
+ -1, /* attr layout */
};
ENDOFCODE
return $cout;
@@ -802,6 +803,9 @@
$vtable_updates .= $set_attr_size;
+ # Calculate attr_layout
+ $vtable_updates .= ' vt->attr_layout = ' . $self->calculate_attr_layout . ";\n";
+
$cout .= <<"EOC";
$export
@@ -829,6 +833,10 @@
$vtable_updates .= $set_attr_size;
+ # Calculate attr_layout
+ $vtable_updates .= ' vt->attr_layout = ' . $self->calculate_attr_layout . ";\n";
+
+
$cout .= <<"EOC";
$export
@@ -1149,6 +1157,25 @@
}
}
+# Calculate bitmap of attrs layout.
+sub calculate_attr_layout {
+ my ($self) = @_;
+
+ my $result = 0;
+ my $bit = 1;
+ use Data::Dumper;
+ for my $attr (@{$self->attributes}) {
+ $result |= $bit if ($attr->{type} =~ m{\*$});
+ $bit *= 2;
+ }
+ #warn sprintf("%b %s\n", $result, Dumper($self->attributes));
+
+ # We can't handle more than 32 bits on 32 bits plaform ATM.
+ return -1 if $result >= 2**32;
+
+ return $result;
+}
+
1;
Modified: branches/boehm_gc_2/lib/Parrot/Vtable.pm
==============================================================================
--- branches/boehm_gc_2/lib/Parrot/Vtable.pm Sun Feb 21 04:28:23 2010 (r44272)
+++ branches/boehm_gc_2/lib/Parrot/Vtable.pm Sun Feb 21 06:44:45 2010 (r44273)
@@ -187,7 +187,11 @@
}
$struct .= <<'EOF';
+
UINTVAL attr_size; /* Size of the attributes struct */
+ UINTVAL attr_layout; /* Bitmap of pointer attributes in PMC. */
+ /* See Boehm GC for GC_bitmap description */
+ /* Can be used by any GC implementation actually */
EOF
$struct .= "} _vtable;\n";
More information about the parrot-commits
mailing list