Skip to content

Commit

Permalink
Add option to not compile the code generator.
Browse files Browse the repository at this point in the history
This is useful when developing on machines where there is no working
backend.  (E.g., currently my old Mac and my netbook.)  To use this
put the following line into your mk/build.mk:

    DisableAsm = Yes
  • Loading branch information
nominolo committed Sep 18, 2011
1 parent e758a8d commit 2b98eb1
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ ifneq ($(DebugLevel),)
EXTRA_CFLAGS := $(EXTRA_CFLAGS) -DLC_DEBUG_LEVEL=$(DebugLevel)
endif

ifeq "$(strip $(DisableAsm))" "Yes"
EXTRA_CFLAGS := $(EXTRA_CFLAGS) -DLC_HAS_ASM_BACKEND=0
endif

HSBUILDDIR = $(DIST)/build
LCC = $(HSBUILDDIR)/lcc
CABAL ?= cabal
Expand Down
6 changes: 5 additions & 1 deletion includes/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@

#ifndef LC_HAS_JIT
# define LC_HAS_JIT 1
#endif
#endif

#ifndef LC_HAS_ASM_BACKEND
# define LC_HAS_ASM_BACKEND 1
#endif

#undef NDEBUG
#define DEBUG
Expand Down
8 changes: 8 additions & 0 deletions mk/build.mk.sample
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,11 @@
# output.
#
# DebugLevel = 1

# Lambdachine is currently x86-64 only. You can still develop on 32
# bit systems (e.g., a netbook, or ARM) if you turn off the code
# generator. You can test the trace compiler by using the IR
# interpreter (it will of course be a lot slower). Uncomment this
# line to do just that.
#
# DisableAsm = Yes
10 changes: 10 additions & 0 deletions rts/InterpThreaded.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
#include "StorageManager.h"
#include "Jit.h"
#include "Stats.h"
#if LC_HAS_ASM_BACKEND
#include "InterpAsm.h"
#endif

#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -216,12 +218,16 @@ int engine(Capability *cap)
Closure *cl;
LC_ASSERT(F != NULL);
recordEvent(EV_TRACE, 0);
#if LC_HAS_ASM_BACKEND
if(J->param[JIT_P_enableasm]) {
asmEngine(cap, F);
}
else {
irEngine(cap, F);
}
#else
irEngine(cap, F);
#endif
DBG_PR("*** Continuing at: pc = %p, base = %p\n",
T->pc, T->base);
//LC_ASSERT(0);
Expand Down Expand Up @@ -475,12 +481,16 @@ int engine(Capability *cap)

LC_ASSERT(F != NULL);
recordEvent(EV_TRACE, 0);
#if LC_HAS_ASM_BACKEND
if(J->param[JIT_P_enableasm]) {
asmEngine(cap, F);
}
else {
irEngine(cap, F);
}
#else
irEngine(cap, F);
#endif
DBG_PR("*** Continuing at: pc = %p, base = %p\n", T->pc, T->base);

pc = T->pc;
Expand Down
4 changes: 4 additions & 0 deletions rts/Record.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
#include "Bitset.h"
#include "Stats.h"
#include "Opts.h"
#if LC_HAS_ASM_BACKEND
#include "AsmCodeGen.h"
#endif

#include <stdlib.h>
#include <stdio.h>
Expand Down Expand Up @@ -961,12 +963,14 @@ finishRecording(JitState *J)
DBG_PR("Overwriting startpc = %p, with: %x\n",
J->startpc, *J->startpc);

#if LC_HAS_ASM_BACKEND
if(J->param[JIT_P_enableasm]) {
//TODO: compute the actual framsize of a trace
//This number needs to be computed before a call to genAsm
J->cur.framesize = MAX_SLOTS;
genAsm(J, &J->cur);
}
#endif
return registerCurrentFragment(J);
}

Expand Down
7 changes: 5 additions & 2 deletions rts/Snapshot.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
//
#include "Snapshot.h"
#include "PrintIR.h"
#include "AsmTarget.h"
#include "Thread.h"
#if LC_HAS_ASM_BACKEND
#include "AsmTarget.h"
#endif

#include <stdlib.h>
#include <stdio.h>
Expand Down Expand Up @@ -154,6 +156,7 @@ printSnapshot(JitState *J, SnapShot *snap, SnapEntry *map)
fprintf(stderr, "pc = %p\n", pc);
}

#if LC_HAS_ASM_BACKEND
/* -- Snapshot restoration ------------------------------------------------ */
/* Initialize a Bloom Filter with all renamed refs.
** There are very few renames (often none), so the filter has
Expand Down Expand Up @@ -249,7 +252,7 @@ void restoreSnapshot(SnapNo snapno, void *exptr) {
T->base = base + smap[nent+1];
T->top = base + snap->nslots;
}

#endif /* LC_HAS_ASM_BACKEND */

#undef IR

Expand Down
5 changes: 5 additions & 0 deletions rts/codegen/AsmCodeGen.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
** Copyright (C) 2005-2011 Mike Pall. See Copyright Notice in luajit.h
*/

#include "Config.h"
#if LC_HAS_ASM_BACKEND

#include "AsmCodeGen.h"
#include "AsmTarget.h" // Target Machine Definitions
#include "Common.h"
Expand Down Expand Up @@ -1236,3 +1239,5 @@ void genAsm(JitState *J, Fragment *T) {
}

#undef IR

#endif
4 changes: 4 additions & 0 deletions rts/codegen/InterpAsm.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "Config.h"
#if LC_HAS_ASM_BACKEND

#include "Capability.h"
#include "Jit.h"
Expand Down Expand Up @@ -222,3 +224,5 @@ asmExitIsImplementedInAssembly() {
: : "i"(SAVE_SIZE + 256/* 256 bytes for int and float regs
* plus the extra space used by SAVE_SIZE */));
}

#endif
4 changes: 4 additions & 0 deletions rts/codegen/MCode.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
** Copyright (C) 2005-2011 Mike Pall. See Copyright Notice in luajit.h
*/

#include "Config.h"
#if LC_HAS_ASM_BACKEND

#include "Jit.h"
#include "MCode.h"
#include "InterpAsm.h" // for reference to asmExitHandler
Expand Down Expand Up @@ -231,3 +234,4 @@ void lj_mcode_limiterr(JitState *J, size_t need)
traceError(J, 1); /* Retry with new area. */
}

#endif

0 comments on commit 2b98eb1

Please sign in to comment.