Permalink
Browse files

Revive pbc

The parrot utils could not load pbc compatible, but older pbc fils anymore
because opslib directories and the init function hardcoded the parrot version
(even with patch!) and not the PBC_COMPAT version.

Replaced all parrot version triples in the pbc format with the PBC version duple.
parrot utils can now load older but compatible pbc files (again).

Replaced the hardcoded version numbers with c preprocessor macros in the
bootstrapped opslib sources and headers, to be more independent and simplier
implementation. If the ops did not change, the ops do not need to get regenerated
anymore for each version bump.
The Ops::Emitter version method is not used anymore, since bootstrap-ops has
been simplified.

Sanified the Makefile by adding missing dependencies and do proper identation
for depends and commands. Prev. line-broken depends were not visually
indistuingishible from commands, and line-broken commands neither.

Store PBC_MAJOR and PBC_MINOR in the config hash, stored by auto::revision.

Bump PBC_COMPAT to 13.0, the opslib directories store now only two version
numbers, not three.
  • Loading branch information...
1 parent b659b74 commit 3b487769a3b3211e887a5e11444da907cb6458b0 Reini Urban committed Sep 1, 2012
View
@@ -18,16 +18,14 @@
# - other core changes that invalidate byte code :)
#
# After changing PBC_COMPAT either disable t/native_pbc tests or
-# better, if you have an i386 box at hand, regenerate the PBCs
+# better, if you have an i386 and ppc box at hand, regenerate the PBCs
# with tools/dev/mk_native_pbc and commit the changes
# TODO TT #361: all .pbc files should make-depend on PBC_COMPAT
-# Also, don't forget to run tools/dev/mk_packfile_pbc to rebuild PBCs
-# used for testing Packfile* PMCs.
-
# please insert tab separated entries at the top of the list
+13.0 2012.09.04 rurban opslib bytecode version, released 4.8.0
12.1 2012.09.03 rurban moved dynpmc os back to pmc
12.0 2011.10.18 dukeleto released 3.9.0
11.0 2011.07.19 jkeenan released 3.6.0
View
@@ -4,22 +4,24 @@ $(LIBRARY_DIR)/opsc.pbc: $(NQP_RX) $(OPSC_SOURCES) $(NQPRX_LIB_SETTING)
$(OPSC_DIR)/gen/Ops/Compiler.pir: $(OPSC_DIR)/src/Ops/Compiler.pm $(NQP_RX)
$(NQP_RX) --target=pir --output=$@ $(OPSC_DIR)/src/Ops/Compiler.pm
-$(OPSC_DIR)/gen/Ops/Compiler/Actions.pir: $(OPSC_DIR)/src/Ops/Compiler/Actions.pm $(NQP_RX)
+$(OPSC_DIR)/gen/Ops/Compiler/Actions.pir: $(OPSC_DIR)/src/Ops/Compiler/Actions.pm $(NQP_RX) \
+ $(LIBRARY_DIR)/nqp-setting.pbc
$(NQP_RX) --target=pir --output=$@ $(OPSC_DIR)/src/Ops/Compiler/Actions.pm
-$(OPSC_DIR)/gen/Ops/Compiler/Grammar.pir: $(OPSC_DIR)/src/Ops/Compiler/Grammar.pm $(NQP_RX)
+$(OPSC_DIR)/gen/Ops/Compiler/Grammar.pir: $(OPSC_DIR)/src/Ops/Compiler/Grammar.pm $(NQP_RX) \
+ $(LIBRARY_DIR)/HLL.pbc
$(NQP_RX) --target=pir --output=$@ $(OPSC_DIR)/src/Ops/Compiler/Grammar.pm
$(OPSC_DIR)/gen/Ops/Emitter.pir: $(OPSC_DIR)/src/Ops/Emitter.pm $(NQP_RX)
$(NQP_RX) --target=pir --output=$@ $(OPSC_DIR)/src/Ops/Emitter.pm
-$(OPSC_DIR)/gen/Ops/File.pir: $(OPSC_DIR)/src/Ops/File.pm $(NQP_RX)
+$(OPSC_DIR)/gen/Ops/File.pir: $(OPSC_DIR)/src/Ops/File.pm $(NQP_RX) $(LIBRARY_DIR)/config.pbc
$(NQP_RX) --target=pir --output=$@ $(OPSC_DIR)/src/Ops/File.pm
-$(OPSC_DIR)/gen/Ops/Op.pir: $(OPSC_DIR)/src/Ops/Op.pm $(NQP_RX)
+$(OPSC_DIR)/gen/Ops/Op.pir: $(OPSC_DIR)/src/Ops/Op.pm $(NQP_RX) $(LIBRARY_DIR)/dumper.pbc
$(NQP_RX) --target=pir --output=$@ $(OPSC_DIR)/src/Ops/Op.pm
-$(OPSC_DIR)/gen/Ops/OpLib.pir: $(OPSC_DIR)/src/Ops/OpLib.pm $(NQP_RX)
+$(OPSC_DIR)/gen/Ops/OpLib.pir: $(OPSC_DIR)/src/Ops/OpLib.pm $(NQP_RX) $(LIBRARY_DIR)/dumper.pbc
$(NQP_RX) --target=pir --output=$@ $(OPSC_DIR)/src/Ops/OpLib.pm
$(OPSC_DIR)/gen/Ops/Trans.pir: $(OPSC_DIR)/src/Ops/Trans.pm $(NQP_RX)
@@ -1,5 +1,5 @@
#! nqp
-# Copyright (C) 2010, Parrot Foundation.
+# Copyright (C) 2010-2012, Parrot Foundation.
class Ops::Emitter is Hash;
@@ -52,7 +52,7 @@ method new(:$ops_file!, :$trans!, :$script!, :$file, :%flags!) {
!! 'PARROT_DYNEXT_EXPORT';
self<init_func> := join('_',
- 'Parrot', 'DynOp', $base ~ $suffix, |$ops_file.version );
+ 'PARROT', 'DYNOP', uc($base ~ $suffix), 'INIT' );
# Prepare ops
$trans.prepare_ops(self, $ops_file);
@@ -212,6 +212,7 @@ method _emit_source_preamble($fh) {
self._emit_preamble($fh);
$fh.print(qq|
#include "{self<include>}"
+#include "parrot/pbcversion.h"
#include "pmc/pmc_parrotlibrary.h"
#include "pmc/pmc_callcontext.h"
@@ -239,9 +240,8 @@ op_lib_t | ~ self.bs ~ q|op_lib = {| ~ qq|
"{self.suffix}", /* suffix */
$core_type, /* core_type = PARROT_XX_CORE */
0, /* flags */
- {self.ops_file.version_major}, /* major_version */
- {self.ops_file.version_minor}, /* minor_version */
- {self.ops_file.version_patch}, /* patch_version */
+ PARROT_PBC_MAJOR,
+ PARROT_PBC_MINOR,
{+self.ops_file.ops}, /* op_count */
{self.trans.op_info(self)}, /* op_info_table */
{self.trans.op_func(self)}, /* op_func_table */
@@ -256,8 +256,8 @@ method _emit_init_func($fh) {
my $dispatch := self.trans.init_func_disaptch;
# TODO There is a bug in NQP about \{
- $fh.print((self.flags<core> ?? 'PARROT_EXPORT' !! '') ~ q|
-op_lib_t *
+ $fh.print(qq|\n\n| ~ (self.flags<core> ?? "PARROT_EXPORT\n" !! '')
+~ q|op_lib_t *
| ~ self.init_func ~ q|(PARROT_INTERP, long init) {
/* initialize and return op_lib ptr */
if (init == 1) {
@@ -354,8 +354,11 @@ method _emit_includes($fh) {
$fh.print(qq|
#include "parrot/parrot.h"
#include "parrot/oplib.h"
+#include "parrot/pbcversion.h"
#include "parrot/runcore_api.h"
+#define | ~ self.init_func ~ ' Parrot_DynOp_' ~ self.bs ~ q| ## PARROT_PBC_MAJOR ## _ ## PARROT_PBC_MINOR
+
| ~ (self.flags<core> ?? 'PARROT_EXPORT' !! '') ~ qq|
op_lib_t *{self.init_func}(PARROT_INTERP, long init);
@@ -1,5 +1,5 @@
#! nqp
-# Copyright (C) 2001-2009, Parrot Foundation.
+# Copyright (C) 2001-2012, Parrot Foundation.
# XXX Better to put this into docs/ somewhere.
@@ -217,8 +217,6 @@ method new_str($str, :$oplib) {
self._set_version();
- self._set_version();
-
self.compile_ops($str);
self;
@@ -281,9 +279,9 @@ method ops() { self<ops> };
method oplib() { self<oplib> };
method version() { self<version>; }
-method version_major() { self<version_major> }
-method version_minor() { self<version_minor> }
-method version_patch() { self<version_patch> }
+# unused. Replaced by cpp macros from pbcversion.h
+method bytecode_major() { self<bytecode_major> }
+method bytecode_minor() { self<bytecode_minor> }
method _calculate_op_codes() {
@@ -296,36 +294,11 @@ method _calculate_op_codes() {
method _set_version() {
my $config := _config();
- my $version_filename;
- if $config<installed> {
- $version_filename :=
- $config<libdir> ~
- $config<versiondir> ~
- $config<slash> ~
- 'VERSION';
- }
- else {
- $version_filename :=
- $config<prefix> ~
- $config<slash> ~
- 'VERSION';
- }
-
- grammar VERSION {
- rule TOP { <version> }
- rule version { $<major>=(\d+) '.' $<minor>=(\d+) '.' $<patch>=(\d+) }
- }
-
- my $version := slurp($version_filename);
- my $version_match := VERSION.parse($version);
- #say("# $version");
- self<version_major> := +$version_match<version><major>;
- self<version_minor> := +$version_match<version><minor>;
- self<version_patch> := +$version_match<version><patch>;
+ self<bytecode_major> := +$config<PBC_MAJOR>;
+ self<bytecode_minor> := +$config<PBC_MINOR>;
self<version> := [
- +self<version_major>,
- +self<version_minor>,
- +self<version_patch>,
+ +self<bytecode_major>,
+ +self<bytecode_minor>,
];
}
View
@@ -18,6 +18,7 @@ use warnings;
use base qw(Parrot::Configure::Step);
use Parrot::Revision;
+use Parrot::BuildUtil;
sub _init {
my $self = shift;
@@ -38,6 +39,10 @@ sub runstep {
$conf->data->set( revision => $revision );
+ my ( $bc_major, $bc_minor ) = Parrot::BuildUtil::get_bc_version();
+ $conf->data->set( 'PBC_MAJOR' => $bc_major,
+ 'PBC_MINOR' => $bc_minor );
+
if ( defined $revision ) {
$self->set_result($revision);
}
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2011, Parrot Foundation.
+/* Copyright (C) 2001-2012, Parrot Foundation.
*/
/* config.h
@@ -138,8 +138,9 @@ typedef struct _vtable VTABLE;
typedef void DPOINTER;
/* Oplib and dynamic ops related. */
+#include "parrot/pbcversion.h"
#define PARROT_CORE_OPLIB_NAME "core_ops"
-#define PARROT_CORE_OPLIB_INIT Parrot_DynOp_core_@MAJOR@_@MINOR@_@PATCH@
+#define PARROT_CORE_OPLIB_INIT Parrot_DynOp_core_ ## PARROT_PBC_MAJOR ## _ ## PARROT_PBC_MINOR
#define PARROT_GET_CORE_OPLIB(i) PARROT_CORE_OPLIB_INIT((i), 1)
View
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2011, Parrot Foundation.
+# Copyright (C) 2001-2012, Parrot Foundation.
=head1 NAME
@@ -1,4 +1,4 @@
-# Copyright (C) 2004-2009, Parrot Foundation.
+# Copyright (C) 2004-2012, Parrot Foundation.
.include 'datatypes.pasm'
.include 'parrot_version.pir'
Oops, something went wrong.

0 comments on commit 3b48776

Please sign in to comment.