Skip to content

Instantly share code, notes, and snippets.

@FROGGS
Last active December 24, 2015 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FROGGS/2ab383d2b3803d8bcf8f to your computer and use it in GitHub Desktop.
Save FROGGS/2ab383d2b3803d8bcf8f to your computer and use it in GitHub Desktop.
diff --git a/3rdparty/dyncall b/3rdparty/dyncall
--- a/3rdparty/dyncall
+++ b/3rdparty/dyncall
@@ -1 +1 @@
-Subproject commit a9e6eec70785f43f63ef17189fc2733d4ceb8446
+Subproject commit a9e6eec70785f43f63ef17189fc2733d4ceb8446-dirty
diff --git a/lib/MAST/Ops.nqp b/lib/MAST/Ops.nqp
index 20daafc..c3d14fe 100644
--- a/lib/MAST/Ops.nqp
+++ b/lib/MAST/Ops.nqp
@@ -503,7 +503,9 @@ BEGIN {
1199,
1200,
1201,
- 1203);
+ 1203,
+ 1205,
+ 1205);
MAST::Ops.WHO<@counts> := nqp::list_i(0,
1,
2,
@@ -1004,7 +1006,9 @@ BEGIN {
1,
1,
2,
- 2);
+ 2,
+ 0,
+ 0);
MAST::Ops.WHO<@values> := nqp::list_i(72,
33,
72,
@@ -2710,7 +2714,9 @@ BEGIN {
'rethrow', 497,
'resume', 498,
'settypehll', 499,
- 'settypehllrole', 500);
+ 'settypehllrole', 500,
+ 'usecompileehllconfig', 501,
+ 'usecompilerhllconfig', 502);
MAST::Ops.WHO<@names> := nqp::list('no_op',
'goto',
'if_i',
@@ -3211,5 +3217,7 @@ BEGIN {
'rethrow',
'resume',
'settypehll',
- 'settypehllrole');
+ 'settypehllrole',
+ 'usecompileehllconfig',
+ 'usecompilerhllconfig');
}
diff --git a/nqp-cc/src/QASTOperationsMAST.nqp b/nqp-cc/src/QASTOperationsMAST.nqp
index 704ffda..dfd4ea1 100644
--- a/nqp-cc/src/QASTOperationsMAST.nqp
+++ b/nqp-cc/src/QASTOperationsMAST.nqp
@@ -1869,6 +1869,8 @@ QAST::MASTOperations.add_core_moarop_mapping('sethllconfig', 'sethllconfig');
QAST::MASTOperations.add_core_moarop_mapping('loadbytecode', 'loadbytecode');
QAST::MASTOperations.add_core_moarop_mapping('settypehll', 'settypehll', 0);
QAST::MASTOperations.add_core_moarop_mapping('settypehllrole', 'settypehllrole', 0);
+QAST::MASTOperations.add_core_moarop_mapping('usecompileehllconfig', 'usecompileehllconfig');
+QAST::MASTOperations.add_core_moarop_mapping('usecompilerhllconfig', 'usecompilerhllconfig');
# regex engine related opcodes
QAST::MASTOperations.add_core_moarop_mapping('nfafromstatelist', 'nfafromstatelist');
diff --git a/src/core/hll.c b/src/core/hll.c
index 4a98e31..9da0c1d 100644
--- a/src/core/hll.c
+++ b/src/core/hll.c
@@ -68,3 +68,8 @@ MVMObject * MVM_hll_set_config(MVMThreadContext *tc, MVMString *name, MVMObject
MVMHLLConfig *MVM_hll_current(MVMThreadContext *tc) {
return (*tc->interp_cu)->body.hll_config;
}
+
+/* Switches to a HLL configuration specified by name. */
+void MVM_hll_switch(MVMThreadContext *tc, MVMString *name) {
+ (*tc->interp_cu)->body.hll_config = MVM_hll_get_config_for(tc, name);
+}
diff --git a/src/core/hll.h b/src/core/hll.h
index 2da46fc..9f4c697 100644
--- a/src/core/hll.h
+++ b/src/core/hll.h
@@ -31,3 +31,4 @@ struct MVMHLLConfig {
MVMHLLConfig *MVM_hll_get_config_for(MVMThreadContext *tc, MVMString *name);
MVMObject *MVM_hll_set_config(MVMThreadContext *tc, MVMString *name, MVMObject *config_hash);
MVMHLLConfig *MVM_hll_current(MVMThreadContext *tc);
+void MVM_hll_switch(MVMThreadContext *tc, MVMString *name);
diff --git a/src/core/interp.c b/src/core/interp.c
index 0e30758..acee207 100644
--- a/src/core/interp.c
+++ b/src/core/interp.c
@@ -3415,6 +3415,12 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
STABLE(GET_REG(cur_op, 0).o)->hll_role = GET_REG(cur_op, 2).i64;
cur_op += 4;
goto NEXT;
+ OP(usecompileehllconfig):
+ MVM_hll_switch(tc, MVM_string_ascii_decode(tc, tc->instance->VMString, "compilee", 8));
+ goto NEXT;
+ OP(usecompilerhllconfig):
+ MVM_hll_switch(tc, MVM_string_ascii_decode(tc, tc->instance->VMString, "compiler", 8));
+ goto NEXT;
#if !MVM_CGOTO
default:
MVM_panic(MVM_exitcode_invalidopcode, "Invalid opcode executed (corrupt bytecode stream?) opcode %u", *(cur_op-2));
diff --git a/src/core/oplabels.h b/src/core/oplabels.h
index 80a5b0e..87fc02b 100644
--- a/src/core/oplabels.h
+++ b/src/core/oplabels.h
@@ -501,5 +501,7 @@ static const void * const LABELS[] = {
&&OP_rethrow,
&&OP_resume,
&&OP_settypehll,
- &&OP_settypehllrole
+ &&OP_settypehllrole,
+ &&OP_usecompileehllconfig,
+ &&OP_usecompilerhllconfig
};
diff --git a/src/core/oplist b/src/core/oplist
index 54f7c7d..ba7d491 100644
--- a/src/core/oplist
+++ b/src/core/oplist
@@ -556,3 +556,5 @@ rethrow r(obj)
resume r(obj)
settypehll r(obj) r(str)
settypehllrole r(obj) r(int64)
+usecompileehllconfig
+usecompilerhllconfig
diff --git a/src/core/ops.c b/src/core/ops.c
index 8c657ca..0608a24 100644
--- a/src/core/ops.c
+++ b/src/core/ops.c
@@ -3515,9 +3515,21 @@ static MVMOpInfo MVM_op_infos[] = {
2,
{ MVM_operand_read_reg | MVM_operand_obj, MVM_operand_read_reg | MVM_operand_int64 }
},
+ {
+ MVM_OP_usecompileehllconfig,
+ "usecompileehllconfig",
+ " ",
+ 0,
+ },
+ {
+ MVM_OP_usecompilerhllconfig,
+ "usecompilerhllconfig",
+ " ",
+ 0,
+ },
};
-static unsigned short MVM_op_counts = 501;
+static unsigned short MVM_op_counts = 503;
MVMOpInfo * MVM_op_get_op(unsigned short op) {
if (op >= MVM_op_counts)
diff --git a/src/core/ops.h b/src/core/ops.h
index 61cb5ed..5f0565f 100644
--- a/src/core/ops.h
+++ b/src/core/ops.h
@@ -502,5 +502,7 @@
#define MVM_OP_resume 498
#define MVM_OP_settypehll 499
#define MVM_OP_settypehllrole 500
+#define MVM_OP_usecompileehllconfig 501
+#define MVM_OP_usecompilerhllconfig 502
MVMOpInfo * MVM_op_get_op(unsigned short op);
diff --git a/src/vm/moar/ModuleLoader.nqp b/src/vm/moar/ModuleLoader.nqp
index 5b72a7a..449eb47 100644
--- a/src/vm/moar/ModuleLoader.nqp
+++ b/src/vm/moar/ModuleLoader.nqp
@@ -42,8 +42,13 @@ knowhow ModuleLoader {
else {
my $*CTXSAVE := self;
my $*MAIN_CTX := ModuleLoader;
+ my $boot_mode;
+ try { my $hack; $boot_mode := %*COMPILING<%?OPTIONS><bootstrap>; }
+ $boot_mode := !nqp::isnull($boot_mode) && $boot_mode;
my $preserve_global := nqp::getcurhllsym('GLOBAL');
+ nqp::usecompileehllconfig() if $boot_mode;
nqp::loadbytecode($path);
+ nqp::usecompilerhllconfig() if $boot_mode;
nqp::bindcurhllsym('GLOBAL', $preserve_global);
%modules_loaded{$path} := $module_ctx := $*MAIN_CTX;
}
@@ -139,8 +144,13 @@ knowhow ModuleLoader {
unless nqp::existskey(%settings_loaded, $path) {
my $*CTXSAVE := self;
my $*MAIN_CTX := ModuleLoader;
+ my $boot_mode;
+ try { my $hack; $boot_mode := %*COMPILING<%?OPTIONS><bootstrap>; }
+ $boot_mode := !nqp::isnull($boot_mode) && $boot_mode;
my $preserve_global := nqp::getcurhllsym('GLOBAL');
+ nqp::usecompileehllconfig() if $boot_mode;
nqp::loadbytecode($path);
+ nqp::usecompilerhllconfig() if $boot_mode;
nqp::bindcurhllsym('GLOBAL', $preserve_global);
unless nqp::defined($*MAIN_CTX) {
nqp::die("Unable to load setting $setting_name; maybe it is missing a YOU_ARE_HERE?");
diff --git a/src/vm/moar/QAST/QASTOperationsMAST.nqp b/src/vm/moar/QAST/QASTOperationsMAST.nqp
index 96e36bd..7797742 100644
--- a/src/vm/moar/QAST/QASTOperationsMAST.nqp
+++ b/src/vm/moar/QAST/QASTOperationsMAST.nqp
@@ -1852,6 +1852,8 @@ QAST::MASTOperations.add_core_moarop_mapping('sethllconfig', 'sethllconfig');
QAST::MASTOperations.add_core_moarop_mapping('loadbytecode', 'loadbytecode');
QAST::MASTOperations.add_core_moarop_mapping('settypehll', 'settypehll', 0);
QAST::MASTOperations.add_core_moarop_mapping('settypehllrole', 'settypehllrole', 0);
+QAST::MASTOperations.add_core_moarop_mapping('usecompileehllconfig', 'usecompileehllconfig');
+QAST::MASTOperations.add_core_moarop_mapping('usecompilerhllconfig', 'usecompilerhllconfig');
# regex engine related opcodes
QAST::MASTOperations.add_core_moarop_mapping('nfafromstatelist', 'nfafromstatelist');
diff --git a/src/vm/moar/stage0/ModuleLoader.moarvm b/src/vm/moar/stage0/ModuleLoader.moarvm
index 359f461..afea7ee 100644
Binary files a/src/vm/moar/stage0/ModuleLoader.moarvm and b/src/vm/moar/stage0/ModuleLoader.moarvm differ
diff --git a/src/vm/moar/stage0/NQPCOREMoar.setting.moarvm b/src/vm/moar/stage0/NQPCOREMoar.setting.moarvm
index 01ddf3f..8b17cd7 100644
Binary files a/src/vm/moar/stage0/NQPCOREMoar.setting.moarvm and b/src/vm/moar/stage0/NQPCOREMoar.setting.moarvm differ
diff --git a/src/vm/moar/stage0/NQPHLLMoar.moarvm b/src/vm/moar/stage0/NQPHLLMoar.moarvm
index 4ac1b8f..42e73f8 100644
Binary files a/src/vm/moar/stage0/NQPHLLMoar.moarvm and b/src/vm/moar/stage0/NQPHLLMoar.moarvm differ
diff --git a/src/vm/moar/stage0/NQPP6QRegexMoar.moarvm b/src/vm/moar/stage0/NQPP6QRegexMoar.moarvm
index cb44d8a..dad0364 100644
Binary files a/src/vm/moar/stage0/NQPP6QRegexMoar.moarvm and b/src/vm/moar/stage0/NQPP6QRegexMoar.moarvm differ
diff --git a/src/vm/moar/stage0/QASTMoar.moarvm b/src/vm/moar/stage0/QASTMoar.moarvm
index d50bec4..03c86f7 100644
Binary files a/src/vm/moar/stage0/QASTMoar.moarvm and b/src/vm/moar/stage0/QASTMoar.moarvm differ
diff --git a/src/vm/moar/stage0/QASTNodesMoar.moarvm b/src/vm/moar/stage0/QASTNodesMoar.moarvm
index 8645b80..29179a6 100644
Binary files a/src/vm/moar/stage0/QASTNodesMoar.moarvm and b/src/vm/moar/stage0/QASTNodesMoar.moarvm differ
diff --git a/src/vm/moar/stage0/QRegexMoar.moarvm b/src/vm/moar/stage0/QRegexMoar.moarvm
index da20d45..6cf1eac 100644
Binary files a/src/vm/moar/stage0/QRegexMoar.moarvm and b/src/vm/moar/stage0/QRegexMoar.moarvm differ
diff --git a/src/vm/moar/stage0/nqp-mo.moarvm b/src/vm/moar/stage0/nqp-mo.moarvm
index c556652..7eddb18 100644
Binary files a/src/vm/moar/stage0/nqp-mo.moarvm and b/src/vm/moar/stage0/nqp-mo.moarvm differ
diff --git a/src/vm/moar/stage0/nqp.moarvm b/src/vm/moar/stage0/nqp.moarvm
index 5e510c7..bf137dc 100644
Binary files a/src/vm/moar/stage0/nqp.moarvm and b/src/vm/moar/stage0/nqp.moarvm differ
diff --git a/tools/build/Makefile-Moar.in b/tools/build/Makefile-Moar.in
index 3018fd2..7283dfc 100644
--- a/tools/build/Makefile-Moar.in
+++ b/tools/build/Makefile-Moar.in
@@ -116,8 +116,12 @@ STAGE1_OUTPUT = $(STAGE1)/$(NQP_MO_MOAR) $(STAGE1)/$(MODULE_LOADER_MOAR) \
$(STAGE1)/$(QAST_MOAR) $(STAGE1)/$(P6QREGEX_MOAR) \
$(STAGE1)/$(NQP_MOAR)
+STAGE2_OUTPUT = $(STAGE2)/$(NQP_MO_MOAR)
+
all: $(STAGE1)
+stage2: $(STAGE2)
+
clean:
$(PERL) -MExtUtils::Command -e rm_rf *.moarvm src/stage1 src/stage2 nqp nqp.bat
@@ -192,5 +196,13 @@ $(STAGE1)/$(NQP_MOAR): $(STAGE0) $(NQP_SOURCES) $(STAGE1)/$(P6QREGEX_MOAR)
--setting=NQPCORE --target=mbc --no-regex-lib \
--output=$(STAGE1)/$(NQP_MOAR) $(STAGE1)/$(NQP_COMBINED)
+$(STAGE2): $(STAGE2_OUTPUT)
+
+$(STAGE2)/$(NQP_MO_MOAR): $(STAGE1)
+ $(MKPATH) $(STAGE2)/gen
+ $(PERL) tools/build/gen-cat.pl moar $(NQP_MO_SOURCES) > $(STAGE2)/$(NQP_MO_COMBINED)
+ $(STAGE1_NQP) --setting=NULL --no-regex-lib --target=mbc \
+ --output=$(STAGE2)/$(NQP_MO_MOAR) $(STAGE2)/$(NQP_MO_COMBINED)
+
# nqp::makefile <-- tells NQP::Configure to treat this file as a makefile,
# performing win32 slash and makefile conversions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment