From 1336403cfa6b35424de2f074f635d03c883fe9ce Mon Sep 17 00:00:00 2001 From: Whiteknight Date: Sat, 10 Mar 2012 21:59:06 -0500 Subject: [PATCH] Update TGE to output load_bytecode_p_s. Update several more bits of the runtime --- compilers/tge/TGE/Compiler.pir | 18 +++++++++-- config/gen/makefiles/root.in | 4 +-- ext/winxed/driver.pir | 34 ++++++++++++++++++-- runtime/parrot/library/Test/Builder.pir | 31 +++++++++++++++++-- runtime/parrot/library/Test/Class.pir | 24 ++++++++++++++- runtime/parrot/library/Test/More.pir | 32 ++++++++++++++++--- runtime/parrot/library/distutils.pir | 41 ++++++++++++++++++++----- runtime/parrot/library/dumper.pir | 25 ++++++++++++++- runtime/parrot/library/pcre.pir | 16 +++++++++- 9 files changed, 201 insertions(+), 24 deletions(-) diff --git a/compilers/tge/TGE/Compiler.pir b/compilers/tge/TGE/Compiler.pir index 76d4436316..86f4e81f65 100644 --- a/compilers/tge/TGE/Compiler.pir +++ b/compilers/tge/TGE/Compiler.pir @@ -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 diff --git a/config/gen/makefiles/root.in b/config/gen/makefiles/root.in index ff0954d950..e214c75e5d 100644 --- a/config/gen/makefiles/root.in +++ b/config/gen/makefiles/root.in @@ -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) @@ -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 \ diff --git a/ext/winxed/driver.pir b/ext/winxed/driver.pir index ec644bf9a0..42d87e0743 100644 --- a/ext/winxed/driver.pir +++ b/ext/winxed/driver.pir @@ -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 @@ -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 diff --git a/runtime/parrot/library/Test/Builder.pir b/runtime/parrot/library/Test/Builder.pir index cfe906af4f..3354773c18 100644 --- a/runtime/parrot/library/Test/Builder.pir +++ b/runtime/parrot/library/Test/Builder.pir @@ -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 @@ -589,6 +591,29 @@ also calls C. 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 diff --git a/runtime/parrot/library/Test/Class.pir b/runtime/parrot/library/Test/Class.pir index 4f73479d41..c88d442edc 100644 --- a/runtime/parrot/library/Test/Class.pir +++ b/runtime/parrot/library/Test/Class.pir @@ -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' ] @@ -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 diff --git a/runtime/parrot/library/Test/More.pir b/runtime/parrot/library/Test/More.pir index 7dda943304..208c509e25 100644 --- a/runtime/parrot/library/Test/More.pir +++ b/runtime/parrot/library/Test/More.pir @@ -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' ] @@ -1425,10 +1425,10 @@ optional test description in C. 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 @@ -1615,6 +1615,28 @@ Bad input: "C" .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 diff --git a/runtime/parrot/library/distutils.pir b/runtime/parrot/library/distutils.pir index ec6547baaf..a230a170de 100644 --- a/runtime/parrot/library/distutils.pir +++ b/runtime/parrot/library/distutils.pir @@ -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' @@ -206,7 +206,7 @@ L .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 @@ -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'] @@ -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'] @@ -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'() @@ -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 @@ -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) @@ -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 diff --git a/runtime/parrot/library/dumper.pir b/runtime/parrot/library/dumper.pir index 3438d502d6..0607f16bfd 100644 --- a/runtime/parrot/library/dumper.pir +++ b/runtime/parrot/library/dumper.pir @@ -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 @@ -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 diff --git a/runtime/parrot/library/pcre.pir b/runtime/parrot/library/pcre.pir index 56d2eaa4df..f99e962e74 100644 --- a/runtime/parrot/library/pcre.pir +++ b/runtime/parrot/library/pcre.pir @@ -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,