Skip to content

Commit

Permalink
Update TGE to output load_bytecode_p_s. Update several more bits of t…
Browse files Browse the repository at this point in the history
…he runtime
  • Loading branch information
Whiteknight committed Mar 11, 2012
1 parent 1b2a3df commit 1336403
Show file tree
Hide file tree
Showing 9 changed files with 201 additions and 24 deletions.
18 changes: 16 additions & 2 deletions compilers/tge/TGE/Compiler.pir
Expand Up @@ -404,12 +404,26 @@ loop_end:
inherit_key = self.'classname_key'(inherit)
type_key = self.'classname_key'(type)

code = "\n.namespace"
code = "# DO NOT EDIT THIS FILE!!!\n"
code .= "# This code is generated by TGE/Compiler.pir\n\n"
code .= ".namespace"
code .= type_key
no_type:
code .= "\n\n"
code .= ".sub '__onload' :tag('load') :tag('init')\n"
code .= " load_bytecode 'TGE.pbc'\n"
code .= " $P0 = load_bytecode 'TGE.pbc'\n"
code .= " $I0 = $P0.'is_initialized'('load')\n"
code .= " if $I0 goto done_initialization\n"
code .= " $P1 = $P0.'subs_by_tag'('load')\n"
code .= " $P2 = iter $P1\n"
code .= " loop_top:\n"
code .= " unless $P2 goto loop_bottom\n"
code .= " $P3 = shift $P2\n"
code .= " $P3()\n"
code .= " goto loop_top\n"
code .= " loop_bottom:\n"
code .= " $P0.'mark_initialized'('load')\n"
code .= " done_initialization:\n"
code .= " push_eh class_loaded\n"
code .= " $P1 = subclass "
code .= inherit_key
Expand Down
4 changes: 2 additions & 2 deletions config/gen/makefiles/root.in
Expand Up @@ -655,7 +655,7 @@ $(LIBRARY_DIR)/HTTP/Message.pbc: $(DYNEXT_DIR)/sys_ops$(LOAD_EXT) $(DYNEXT_DIR)/

$(LIBRARY_DIR)/distutils.pbc: $(DYNEXT_DIR)/sys_ops$(LOAD_EXT) $(DYNEXT_DIR)/io_ops$(LOAD_EXT)

$(LIBRARY_DIR)/pcre.pbc: $(DYNEXT_DIR)/sys_ops$(LOAD_EXT)
$(LIBRARY_DIR)/pcre.pbc: $(DYNEXT_DIR)/sys_ops$(LOAD_EXT) $(LIBRARY_DIR)/libpcre.pbc

$(LIBRARY_DIR)/uuid.pbc: $(DYNEXT_DIR)/math_ops$(LOAD_EXT)

Expand Down Expand Up @@ -3021,7 +3021,7 @@ src/glut_callbacks$(O): \
$(EXTEND_HEADERS) \
src/glut_callbacks.c

src/glut_nci_thunks.c: $(NCI_THUNK_GEN)
src/glut_nci_thunks.c: $(NCI_THUNK_GEN) runtime/parrot/library/String/Utils.pbc
$(NCI_THUNK_GEN) \
--loader-name=Parrot_glut_nci_loader \
--loader-storage-class=PARROT_DYNEXT_EXPORT \
Expand Down
34 changes: 32 additions & 2 deletions ext/winxed/driver.pir
Expand Up @@ -2,7 +2,21 @@
# Begin generated code

.sub initial_load_bytecode :anon :tag('load') :tag('init')
load_bytecode 'Getopt/Obj.pbc'
$P0 = load_bytecode 'Getopt/Obj.pbc'
$I0 = $P0.'is_initialized'('load')
if $I0 goto done_initialization

$P1 = $P0.'subs_by_tag'('load')
$P2 = iter $P1
loop_top:
unless $P2 goto loop_bottom
$P3 = shift $P2
$P3()
goto loop_top
loop_bottom:

$P0.'mark_initialized'('load')
done_initialization:
.end

# end libs
Expand Down Expand Up @@ -236,7 +250,23 @@
new $P2, 'ExceptionHandler'
set_label $P2, __label_1
push_eh $P2
load_language 'winxed'

$P0 = load_language 'winxed'
$I0 = $P0.'is_initialized'('load')
if $I0 goto done_initialization

$P1 = $P0.'subs_by_tag'('load')
$P2 = iter $P1
loop_top:
unless $P2 goto loop_bottom
$P3 = shift $P2
$P3()
goto loop_top
loop_bottom:

$P0.'mark_initialized'('load')
done_initialization:

compreg $P1, 'winxed'
pop_eh
goto __label_2
Expand Down
31 changes: 28 additions & 3 deletions runtime/parrot/library/Test/Builder.pir
Expand Up @@ -46,10 +46,12 @@ This class defines the following methods:

.namespace [ 'Test'; 'Builder' ]



.sub '_initialize' :tag('load')
load_bytecode 'Test/Builder/Test.pbc'
load_bytecode 'Test/Builder/Output.pbc'
load_bytecode 'Test/Builder/TestPlan.pbc'
'__load_bytecode'('Test/Builder/Test.pbc')
'__load_bytecode'('Test/Builder/Output.pbc')
'__load_bytecode'('Test/Builder/TestPlan.pbc')

.local pmc tb_class

Expand Down Expand Up @@ -589,6 +591,29 @@ also calls C<exit>.
output.'write'( report )
.end
.sub '__load_bytecode' :anon
.param string pbc_name
.local string tag
tag = "load"
$P0 = load_bytecode pbc_name
$I0 = $P0.'is_initialized'(tag)
if $I0 goto done_initialization
$P1 = $P0.'subs_by_tag'(tag)
$P2 = iter $P1
loop_top:
unless $P2 goto loop_bottom
$P3 = shift $P2
$P3()
goto loop_top
loop_bottom:
$P0.'mark_initialized'(tag)
done_initialization:
.return()
.end
=back
=head1 AUTHOR
Expand Down
24 changes: 23 additions & 1 deletion runtime/parrot/library/Test/Class.pir
Expand Up @@ -64,7 +64,7 @@ everything.
.namespace [ 'Test'; 'Class' ]

.sub '__init__' :tag('load')
load_bytecode 'Test/More.pbc'
'__load_bytecode'('Test/More.pbc')

.local pmc class
class = newclass [ 'Test'; 'Class' ]
Expand Down Expand Up @@ -291,6 +291,28 @@ everything.
.return()
.end

.sub '__load_bytecode' :anon
.param string pbc_name
.param string tag

$P0 = load_bytecode pbc_name
$I0 = $P0.'is_initialized'(tag)
if $I0 goto done_initialization

$P1 = $P0.'subs_by_tag'(tag)
$P2 = iter $P1
loop_top:
unless $P2 goto loop_bottom
$P3 = shift $P2
$P3()
goto loop_top
loop_bottom:

$P0.'mark_initialized'(tag)
done_initialization:
.return()
.end

=head1 AUTHOR

Written and maintained by chromatic, C<< chromatic at wgz dot org >>, based on
Expand Down
32 changes: 27 additions & 5 deletions runtime/parrot/library/Test/More.pir
Expand Up @@ -75,7 +75,7 @@ This class defines the following functions:
.namespace [ 'Test'; 'More' ]

.sub _initialize :tag('load')
load_bytecode 'Test/Builder.pbc'
'__load_bytecode'('Test/Builder.pbc')

.local pmc test
test = new [ 'Test'; 'Builder' ]
Expand Down Expand Up @@ -1425,10 +1425,10 @@ optional test description in C<description>.
get_hll_global test, [ 'Test'; 'More' ], '_test'
.local pmc p6rule_compile
load_bytecode "PGE.pbc"
load_bytecode "PGE/Dumper.pbc"
load_bytecode "PGE/Text.pbc"
load_bytecode "PGE/Util.pbc"
'__load_bytecode'("PGE.pbc")
'__load_bytecode'("PGE/Dumper.pbc")
'__load_bytecode'("PGE/Text.pbc")
'__load_bytecode'("PGE/Util.pbc")
p6rule_compile = compreg "PGE::Perl6Regex"
.local pmc diagnostic
Expand Down Expand Up @@ -1615,6 +1615,28 @@ Bad input: "C<test that the return from Foo is correct type>"
.return( $S0 )
.end
.sub '__load_bytecode' :anon
.param string pbc_name
.param string tag
$P0 = load_bytecode pbc_name
$I0 = $P0.'is_initialized'(tag)
if $I0 goto done_initialization
$P1 = $P0.'subs_by_tag'(tag)
$P2 = iter $P1
loop_top:
unless $P2 goto loop_bottom
$P3 = shift $P2
$P3()
goto loop_top
loop_bottom:
$P0.'mark_initialized'(tag)
done_initialization:
.return()
.end
=back
=head1 AUTHOR
Expand Down
41 changes: 34 additions & 7 deletions runtime/parrot/library/distutils.pir
Expand Up @@ -140,7 +140,7 @@ Inno Setup
.sub 'main' :main
.param pmc args
$S0 = shift args
load_bytecode 'distutils.pbc'
'__load_bytecode'('distutils.pbc', 'load')

$P0 = new 'Hash'
$P1 = new 'Hash'
Expand Down Expand Up @@ -206,7 +206,7 @@ L<http://github.com/ekiru/tree-optimization/blob/master/setup.nqp>
.include 'errors.pasm'

.sub '__onload' :tag('load') :tag('init') :anon
load_bytecode 'osutils.pbc'
'__load_bytecode'('osutils.pbc', 'load')
$P0 = new 'Hash'
set_global '%step', $P0

Expand Down Expand Up @@ -2149,7 +2149,7 @@ the default value is "t/*.t"
.param pmc kv :slurpy :named
run_step('build', kv :flat :named)

load_bytecode 'TAP/Harness.pbc'
'__load_bytecode'('TAP/Harness.pbc', 'load')
.local pmc opts, files, harness, aggregate
opts = new 'Hash'
$I0 = exists kv['prove_exec']
Expand Down Expand Up @@ -2249,7 +2249,7 @@ the server. The default is "parrot-autobot:qa_rocks"
.param pmc kv :slurpy :named
run_step('build', kv :flat :named)

load_bytecode 'TAP/Harness.pbc'
'__load_bytecode'('TAP/Harness.pbc', 'load')
.local pmc opts, files, harness, aggregate
opts = new 'Hash'
$I0 = exists kv['prove_exec']
Expand Down Expand Up @@ -2352,7 +2352,7 @@ the server. The default is "parrot-autobot:qa_rocks"
$P1 = $P0[1]
push contents, 'password'
push contents, $P1
load_bytecode 'LWP/UserAgent.pir'
'__load_bytecode'('LWP/UserAgent.pir', 'load')
.local pmc ua, response
ua = new ['LWP';'UserAgent']
ua.'env_proxy'()
Expand Down Expand Up @@ -3232,7 +3232,7 @@ the default value is setup.pir
.param pmc kv :slurpy :named
run_step('manifest', kv :flat :named)

load_bytecode 'Archive/Tar.pbc'
'__load_bytecode'('Archive/Tar.pbc', 'load')
$S0 = slurp('MANIFEST')
$P0 = split "\n", $S0
$S0 = pop $P0
Expand Down Expand Up @@ -4861,7 +4861,7 @@ SOURCE_C
.sub 'runtests' :multi()
.param pmc files :slurpy
.param pmc opts :slurpy :named
load_bytecode 'TAP/Harness.pbc'
'__load_bytecode'('TAP/Harness.pbc', 'load')
.local pmc harness
harness = new ['TAP';'Harness']
harness.'process_args'(opts)
Expand All @@ -4884,6 +4884,33 @@ SOURCE_C
.tailcall runtests(array :flat, hash :flat :named)
.end

=item __load_bytecode

=cut

.sub '__load_bytecode' :anon
.param string pbc_name
.param string tag

$P0 = load_bytecode pbc_name
$I0 = $P0.'is_initialized'(tag)
if $I0 goto done_initialization

$P1 = $P0.'subs_by_tag'(tag)
$P2 = iter $P1
loop_top:
unless $P2 goto loop_bottom
$P3 = shift $P2
$P3()
goto loop_top
loop_bottom:

$P0.'mark_initialized'(tag)
done_initialization:
.return()
.end


=back

=head1 AUTHOR
Expand Down
25 changes: 24 additions & 1 deletion runtime/parrot/library/dumper.pir
Expand Up @@ -152,7 +152,7 @@ Returns the global dumper instance used by the non object interface.
goto TYPE_OK
load_dd_pir:
load_bytecode "Data/Dumper.pbc"
'__load_bytecode'("Data/Dumper.pbc")
get_class dd_class, ['Data'; 'Dumper']
if null dd_class goto no_class
goto TYPE_OK
Expand All @@ -173,6 +173,29 @@ END:
.return( self )
.end
.sub '__load_bytecode' :anon
.param string pbc_name
.param string tag
$P0 = load_bytecode pbc_name
$I0 = $P0.'is_initialized'(tag)
if $I0 goto done_initialization
$P1 = $P0.'subs_by_tag'(tag)
$P2 = iter $P1
loop_top:
unless $P2 goto loop_bottom
$P3 = shift $P2
$P3()
goto loop_top
loop_bottom:
$P0.'mark_initialized'(tag)
done_initialization:
.return()
.end
=back
=head1 AUTHOR
Expand Down
16 changes: 15 additions & 1 deletion runtime/parrot/library/pcre.pir
Expand Up @@ -103,7 +103,21 @@ LIB_CYGWIN:
LIB_LOADED:
set_hll_global ['PCRE'], 'lib', libpcre

load_bytecode 'libpcre.pbc'
$P0 = load_bytecode 'libpcre.pbc'
$I0 = $P0.'is_initialized'('load')
if $I0 goto pbc_done_initialization

$P1 = $P0.'subs_by_tag'('load')
$P2 = iter $P1
pbc_loop_top:
unless $P2 goto pbc_loop_bottom
$P3 = shift $P2
$P3()
goto pbc_loop_top
pbc_loop_bottom:

$P0.'mark_initialized'('load')
pbc_done_initialization:

# pcre *pcre_compile(const char *pattern, int options,
# const char **errptr, int *erroffset,
Expand Down

0 comments on commit 1336403

Please sign in to comment.