Skip to content

Commit

Permalink
Revive pbc
Browse files Browse the repository at this point in the history
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
Reini Urban committed Dec 6, 2012
1 parent c63a337 commit b97b7bd
Show file tree
Hide file tree
Showing 17 changed files with 151 additions and 181 deletions.
7 changes: 2 additions & 5 deletions PBC_COMPAT
Expand Up @@ -18,17 +18,14 @@
# - other core changes that invalidate byte code :) # - other core changes that invalidate byte code :)
# #
# After changing PBC_COMPAT either disable t/native_pbc tests or # 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 # with tools/dev/mk_native_pbc and commit the changes


# TODO TT #361: all .pbc files should make-depend on PBC_COMPAT # 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 # please insert tab separated entries at the top of the list


13.0 2012.12.03 rurban threads and added Proxy PMC 13.0 2012.12.04 rurban opslib bytecode version, threads, Proxy
12.1 2012.09.03 rurban moved dynpmc os back to pmc 12.1 2012.09.03 rurban moved dynpmc os back to pmc
12.0 2011.10.18 dukeleto released 3.9.0 12.0 2011.10.18 dukeleto released 3.9.0
11.0 2011.07.19 jkeenan released 3.6.0 11.0 2011.07.19 jkeenan released 3.6.0
Expand Down
12 changes: 7 additions & 5 deletions compilers/opsc/Rules.mak
Expand Up @@ -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) $(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 $(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 $(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 $(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) $(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 $(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 $(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 $(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 $(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) $(OPSC_DIR)/gen/Ops/Trans.pir: $(OPSC_DIR)/src/Ops/Trans.pm $(NQP_RX)
Expand Down
17 changes: 10 additions & 7 deletions compilers/opsc/src/Ops/Emitter.pm
@@ -1,5 +1,5 @@
#! nqp #! nqp
# Copyright (C) 2010, Parrot Foundation. # Copyright (C) 2010-2012, Parrot Foundation.


class Ops::Emitter is Hash; class Ops::Emitter is Hash;


Expand Down Expand Up @@ -52,7 +52,7 @@ method new(:$ops_file!, :$trans!, :$script!, :$file, :%flags!) {
!! 'PARROT_DYNEXT_EXPORT'; !! 'PARROT_DYNEXT_EXPORT';


self<init_func> := join('_', self<init_func> := join('_',
'Parrot', 'DynOp', $base ~ $suffix, |$ops_file.version ); 'PARROT', 'DYNOP', uc($base ~ $suffix), 'INIT' );


# Prepare ops # Prepare ops
$trans.prepare_ops(self, $ops_file); $trans.prepare_ops(self, $ops_file);
Expand Down Expand Up @@ -212,6 +212,7 @@ method _emit_source_preamble($fh) {
self._emit_preamble($fh); self._emit_preamble($fh);
$fh.print(qq| $fh.print(qq|
#include "{self<include>}" #include "{self<include>}"
#include "parrot/pbcversion.h"
#include "pmc/pmc_parrotlibrary.h" #include "pmc/pmc_parrotlibrary.h"
#include "pmc/pmc_callcontext.h" #include "pmc/pmc_callcontext.h"
Expand Down Expand Up @@ -239,9 +240,8 @@ op_lib_t | ~ self.bs ~ q|op_lib = {| ~ qq|
"{self.suffix}", /* suffix */ "{self.suffix}", /* suffix */
$core_type, /* core_type = PARROT_XX_CORE */ $core_type, /* core_type = PARROT_XX_CORE */
0, /* flags */ 0, /* flags */
{self.ops_file.version_major}, /* major_version */ PARROT_PBC_MAJOR,
{self.ops_file.version_minor}, /* minor_version */ PARROT_PBC_MINOR,
{self.ops_file.version_patch}, /* patch_version */
{+self.ops_file.ops}, /* op_count */ {+self.ops_file.ops}, /* op_count */
{self.trans.op_info(self)}, /* op_info_table */ {self.trans.op_info(self)}, /* op_info_table */
{self.trans.op_func(self)}, /* op_func_table */ {self.trans.op_func(self)}, /* op_func_table */
Expand All @@ -256,8 +256,8 @@ method _emit_init_func($fh) {
my $dispatch := self.trans.init_func_disaptch; my $dispatch := self.trans.init_func_disaptch;


# TODO There is a bug in NQP about \{ # TODO There is a bug in NQP about \{
$fh.print((self.flags<core> ?? 'PARROT_EXPORT' !! '') ~ q| $fh.print(qq|\n\n| ~ (self.flags<core> ?? "PARROT_EXPORT\n" !! '')
op_lib_t * ~ q|op_lib_t *
| ~ self.init_func ~ q|(PARROT_INTERP, long init) { | ~ self.init_func ~ q|(PARROT_INTERP, long init) {
/* initialize and return op_lib ptr */ /* initialize and return op_lib ptr */
if (init == 1) { if (init == 1) {
Expand Down Expand Up @@ -354,8 +354,11 @@ method _emit_includes($fh) {
$fh.print(qq| $fh.print(qq|
#include "parrot/parrot.h" #include "parrot/parrot.h"
#include "parrot/oplib.h" #include "parrot/oplib.h"
#include "parrot/pbcversion.h"
#include "parrot/runcore_api.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| | ~ (self.flags<core> ?? 'PARROT_EXPORT' !! '') ~ qq|
op_lib_t *{self.init_func}(PARROT_INTERP, long init); op_lib_t *{self.init_func}(PARROT_INTERP, long init);
Expand Down
43 changes: 8 additions & 35 deletions compilers/opsc/src/Ops/File.pm
@@ -1,5 +1,5 @@
#! nqp #! nqp
# Copyright (C) 2001-2009, Parrot Foundation. # Copyright (C) 2001-2012, Parrot Foundation.


# XXX Better to put this into docs/ somewhere. # XXX Better to put this into docs/ somewhere.


Expand Down Expand Up @@ -217,8 +217,6 @@ method new_str($str, :$oplib) {


self._set_version(); self._set_version();


self._set_version();

self.compile_ops($str); self.compile_ops($str);


self; self;
Expand Down Expand Up @@ -281,9 +279,9 @@ method ops() { self<ops> };
method oplib() { self<oplib> }; method oplib() { self<oplib> };
method version() { self<version>; } method version() { self<version>; }


method version_major() { self<version_major> } # unused. Replaced by cpp macros from pbcversion.h
method version_minor() { self<version_minor> } method bytecode_major() { self<bytecode_major> }
method version_patch() { self<version_patch> } method bytecode_minor() { self<bytecode_minor> }


method _calculate_op_codes() { method _calculate_op_codes() {


Expand All @@ -296,36 +294,11 @@ method _calculate_op_codes() {


method _set_version() { method _set_version() {
my $config := _config(); my $config := _config();
my $version_filename; self<bytecode_major> := +$config<PBC_MAJOR>;
if $config<installed> { self<bytecode_minor> := +$config<PBC_MINOR>;
$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<version> := [ self<version> := [
+self<version_major>, +self<bytecode_major>,
+self<version_minor>, +self<bytecode_minor>,
+self<version_patch>,
]; ];
} }


Expand Down
5 changes: 5 additions & 0 deletions config/auto/revision.pm
Expand Up @@ -18,6 +18,7 @@ use warnings;
use base qw(Parrot::Configure::Step); use base qw(Parrot::Configure::Step);


use Parrot::Revision; use Parrot::Revision;
use Parrot::BuildUtil;


sub _init { sub _init {
my $self = shift; my $self = shift;
Expand All @@ -38,6 +39,10 @@ sub runstep {


$conf->data->set( revision => $revision ); $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 ) { if ( defined $revision ) {
$self->set_result($revision); $self->set_result($revision);
} }
Expand Down
5 changes: 3 additions & 2 deletions config/gen/config_h/config_h.in
@@ -1,4 +1,4 @@
/* Copyright (C) 2001-2011, Parrot Foundation. /* Copyright (C) 2001-2012, Parrot Foundation.
*/ */


/* config.h /* config.h
Expand Down Expand Up @@ -138,8 +138,9 @@ typedef struct _vtable VTABLE;
typedef void DPOINTER; typedef void DPOINTER;


/* Oplib and dynamic ops related. */ /* Oplib and dynamic ops related. */
#include "parrot/pbcversion.h"
#define PARROT_CORE_OPLIB_NAME "core_ops" #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) #define PARROT_GET_CORE_OPLIB(i) PARROT_CORE_OPLIB_INIT((i), 1)


Expand Down

0 comments on commit b97b7bd

Please sign in to comment.