[MLton-commit] r4602
Matthew Fluet
MLton@mlton.org
Thu, 25 May 2006 06:00:04 -0700
Move /bytecode to /runtime/bytecode.
One warning about "shadows global" that couldn't be easily fixed, so
interpret.c is compiled with -Wno-shadow.
----------------------------------------------------------------------
U mlton/branches/on-20050822-x86_64-branch/Makefile
D mlton/branches/on-20050822-x86_64-branch/bytecode/
U mlton/branches/on-20050822-x86_64-branch/include/c-chunk.h
U mlton/branches/on-20050822-x86_64-branch/runtime/Makefile
A mlton/branches/on-20050822-x86_64-branch/runtime/bytecode/
U mlton/branches/on-20050822-x86_64-branch/runtime/bytecode/.ignore
U mlton/branches/on-20050822-x86_64-branch/runtime/bytecode/Makefile
U mlton/branches/on-20050822-x86_64-branch/runtime/bytecode/interpret.c
U mlton/branches/on-20050822-x86_64-branch/runtime/bytecode/opcode.h
U mlton/branches/on-20050822-x86_64-branch/runtime/bytecode/print-opcodes.c
U mlton/branches/on-20050822-x86_64-branch/runtime/gen/.ignore
U mlton/branches/on-20050822-x86_64-branch/runtime/gen/gen-basis-ffi.sml
----------------------------------------------------------------------
Modified: mlton/branches/on-20050822-x86_64-branch/Makefile
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/Makefile 2006-05-25 12:41:18 UTC (rev 4601)
+++ mlton/branches/on-20050822-x86_64-branch/Makefile 2006-05-25 13:00:03 UTC (rev 4602)
@@ -282,20 +282,17 @@
$(MAKE) -C runtime
$(CP) include/*.h "$(INC)/"
$(CP) runtime/*.a "$(LIB)/$(TARGET)/"
- cp runtime/gen/c-types.sml \
+ $(CP) runtime/gen/c-types.sml \
basis-library/config/c/$(TARGET_ARCH)-$(TARGET_OS)/c-types.sml
- cp runtime/gen/basis-ffi.sml \
+ $(CP) runtime/gen/basis-ffi.sml \
basis-library/primitive/basis-ffi.sml
+ $(CP) runtime/bytecode/opcodes "$(LIB)/"
$(CP) runtime/*.h "$(INC)/"
for d in basis basis/Real basis/Word gc platform util; do \
mkdir -p "$(INC)/$$d"; \
$(CP) runtime/$$d/*.h "$(INC)/$$d"; \
done
- $(CP) bytecode/interpret.h "$(INC)"
- $(MAKE) -C bytecode
- bytecode/print-opcodes >"$(LIB)/opcodes"
- ar r "$(LIB)/$(TARGET)/libmlton.a" bytecode/interpret.o
- ar r "$(LIB)/$(TARGET)/libmlton-gdb.a" bytecode/interpret-gdb.o
+ $(CP) runtime/bytecode/interpret.h "$(INC)"
for x in "$(LIB)"/"$(TARGET)"/*.a; do $(RANLIB) "$$x"; done
.PHONY: script
Modified: mlton/branches/on-20050822-x86_64-branch/include/c-chunk.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/include/c-chunk.h 2006-05-25 12:41:18 UTC (rev 4601)
+++ mlton/branches/on-20050822-x86_64-branch/include/c-chunk.h 2006-05-25 13:00:03 UTC (rev 4602)
@@ -27,7 +27,7 @@
#define DEBUG_CCODEGEN FALSE
#endif
-extern struct cont (*nextChunks []) ();
+extern struct cont (*nextChunks []) (void);
extern int nextFun;
extern int returnToC;
extern struct GC_state gcState;
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/Makefile
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/Makefile 2006-05-25 12:41:18 UTC (rev 4601)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Makefile 2006-05-25 13:00:03 UTC (rev 4602)
@@ -148,10 +148,16 @@
BASISHFILES = \
$(shell find basis -type f | grep '\.h$$')
+BYTECFILES = \
+ $(shell find bytecode -type f | grep '\.c$$')
+BYTEHFILES = \
+ $(shell find bytecode -type f | grep '\.h$$')
+
CFILES = \
$(UTILCFILES) \
$(shell find basis -type f | grep '\.c$$' | grep -v Real/) \
gc.c \
+ bytecode/interpret.c \
platform.c
HFILES = \
@@ -189,7 +195,9 @@
OBJS += $(foreach f, $(EXTRA_FILES), $(f).o)
DEBUG_OBJS += $(foreach f, $(EXTRA_FILES), $(f)-gdb.o)
-all: libgdtoa.a libmlton.a libmlton-gdb.a
+all: libgdtoa.a libmlton.a libmlton-gdb.a \
+ gen/c-types.sml gen/basis-ffi.sml \
+ bytecode/opcodes
libgdtoa.a: gdtoa/arith.h
cd gdtoa && \
@@ -234,27 +242,46 @@
util/%.o: util/%.c util.h $(UTILHFILES)
$(CC) $(OPTCFLAGS) $(WARNCFLAGS) -c -o $@ $<
-c-types.h ml-types.h: gen/gen-types.c util.h $(UTILOFILES)
- rm -f c-types.h ml-types.h
+gen/c-types.h gen/c-types.sml gen/ml-types.h: gen/gen-types.c util.h $(UTILOFILES)
$(CC) $(OPTCFLAGS) $(WARNCFLAGS) -o gen/gen-types gen/gen-types.c $(UTILOFILES)
+ rm -f gen/c-types.h gen/c-types.sml gen/ml-types.h
cd gen && ./gen-types
- mv gen/c-types.h c-types.h
- mv gen/ml-types.h ml-types.h
rm -f gen/gen-types
-basis-ffi.h: gen/gen-basis-ffi.sml gen/basis-ffi.def
- rm -f basis-ffi.h
- cd gen && mlton gen-basis-ffi.sml
+c-types.h ml-types.h: gen/c-types.h gen/ml-types.h
+ rm -f c-types.h ml-types.h
+ cp gen/c-types.h c-types.h
+ cp gen/ml-types.h ml-types.h
+
+gen/basis-ffi.h gen/basis-ffi.sml: gen/gen-basis-ffi.sml gen/basis-ffi.def
+ mlton -output gen/gen-basis-ffi gen/gen-basis-ffi.sml
+ rm -f gen/basis-ffi.h gen/basis-ffi.sml
cd gen && ./gen-basis-ffi
- mv gen/basis-ffi.h basis-ffi.h
rm -f gen/gen-basis-ffi
+basis-ffi.h: gen/basis-ffi.h
+ rm -f basis-ffi.h
+ cp gen/basis-ffi.h basis-ffi.h
+
+bytecode/opcodes: bytecode/print-opcodes.c bytecode/opcode.h
+ $(CC) $(OPTCFLAGS) $(WARNCFLAGS) -o bytecode/print-opcodes bytecode/print-opcodes.c
+ rm -f bytecode/opcodes
+ cd bytecode && ./print-opcodes > opcodes
+ rm -f bytecode/print-opcodes
+
+
gc-gdb.o: gc.c $(GCCFILES) $(HFILES)
$(CC) $(DEBUGCFLAGS) $(DEBUGWARNCFLAGS) -c -o $@ $<
gc.o: gc.c $(GCCFILES) $(HFILES)
$(CC) $(OPTCFLAGS) $(GCOPTCFLAGS) $(OPTWARNCFLAGS) -c -o $@ $<
+bytecode/interpret-gdb.o: bytecode/interpret.c bytecode/opcode.h $(HFILES)
+ $(CC) -I../include $(DEBUGCFLAGS) $(DEBUGWARNCFLAGS) -Wno-float-equal -Wno-shadow -c -o $@ $<
+
+bytecode/interpret.o: bytecode/interpret.c bytecode/opcode.h $(HFILES)
+ $(CC) -I../include $(OPTCFLAGS) $(GCOPTCFLAGS) $(OPTWARNCFLAGS) -Wno-float-equal -Wno-shadow -c -o $@ $<
+
# It looks like we don't follow the C spec w.r.t. aliasing. And gcc
# -O2 catches us on the code in Real/*.c where we treat a double as a
# chunk of two words. Files that have been known to cause problems
Copied: mlton/branches/on-20050822-x86_64-branch/runtime/bytecode (from rev 4601, mlton/branches/on-20050822-x86_64-branch/bytecode)
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/bytecode/.ignore
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/bytecode/.ignore 2006-05-25 12:41:18 UTC (rev 4601)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/bytecode/.ignore 2006-05-25 13:00:03 UTC (rev 4602)
@@ -1,2 +1 @@
-interpret
-print-opcodes
+opcodes
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/bytecode/Makefile
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/bytecode/Makefile 2006-05-25 12:41:18 UTC (rev 4601)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/bytecode/Makefile 2006-05-25 13:00:03 UTC (rev 4602)
@@ -5,47 +5,8 @@
# See the file MLton-LICENSE for details.
##
-TARGET_ARCH = $(shell ../bin/host-arch)
-TARGET_OS = $(shell ../bin/host-os)
+all:
-all: interpret.o interpret-gdb.o print-opcodes
-
-CC = gcc -std=gnu99
-CFLAGS = -fomit-frame-pointer -I../runtime -I../include -Wall
-DEBUGFLAGS = $(CFLAGS)
-ifneq ($(TARGET_ARCH), ia64)
-ifneq ($(TARGET_ARCH), powerpc)
-DEBUGFLAGS += -gstabs+
-endif
-endif
-DEBUGFLAGS += -g2
-
-ifeq ($(TARGET_ARCH), amd64)
-CFLAGS += -mtune=opteron -m32
-endif
-
-ifeq ($(TARGET_OS), freebsd)
-CFLAGS += -I/usr/local/include
-endif
-
-ifeq ($(TARGET_OS), openbsd)
-CFLAGS += -I/usr/local/include
-endif
-
-interpret.o: interpret.c interpret.h opcode.h
- $(CC) $(CFLAGS) -c -O2 interpret.c
-
-interpret-gdb.o: interpret.c interpret.h
- $(CC) $(DEBUGFLAGS) -c -o $@ -DASSERT=1 interpret.c
-
-print-opcodes: print-opcodes.c opcode.h
- $(CC) $(CFLAGS) -o print-opcodes -I../runtime -L../runtime \
- print-opcodes.c -lmlton
-
-.PHONY: clean
+.PHONY:
clean:
- ../bin/clean
-
-.PHONY: exp
-exp:
- $(CC) -E -I../runtime -I../include interpret.c >/tmp/z.exp
+ ../../bin/clean
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/bytecode/interpret.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/bytecode/interpret.c 2006-05-25 12:41:18 UTC (rev 4601)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/bytecode/interpret.c 2006-05-25 13:00:03 UTC (rev 4602)
@@ -116,16 +116,16 @@
case opcodeSymOfTy2 (ty, mode##ArrayOffset): \
{ \
ArrayOffset arrayOffset; \
- Pointer base; \
- Word32 index; \
- Scale scale; \
+ Pointer arrayBase; \
+ Word32 arrayIndex; \
+ Scale arrayScale; \
Fetch (ArrayOffset, arrayOffset); \
- Fetch (Scale, scale); \
+ Fetch (Scale, arrayScale); \
if (disassemble) goto mainLoop; \
- index = PopReg (Word32); \
- base = (Pointer) (PopReg (Word32)); \
+ arrayIndex = PopReg (Word32); \
+ arrayBase = (Pointer) (PopReg (Word32)); \
loadStore (mode, ty, \
- *(ty*)(base + (index * scale) + arrayOffset)); \
+ *(ty*)(arrayBase + (arrayIndex * arrayScale) + arrayOffset)); \
goto mainLoop; \
}
@@ -357,7 +357,7 @@
fprintf (stderr, "\n" #ty "Reg[%d] = 0x%08x", \
i, (unsigned int)(ty##Reg[i]));
-void displayRegs () {
+static inline void displayRegs (void) {
int i;
disp (Word8);
@@ -368,11 +368,11 @@
disp (Real64);
}
-static inline void interpret (Bytecode b, Word32 codeOffset, Bool disassemble) {
+static void interpret (Bytecode b, Word32 codeOffset, Bool disassemble) {
CallCIndex callCIndex;
Pointer code;
Pointer frontier;
- int i;
+ unsigned int i;
String name;
String *offsetToLabel = NULL;
Opcode opc;
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/bytecode/opcode.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/bytecode/opcode.h 2006-05-25 12:41:18 UTC (rev 4601)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/bytecode/opcode.h 2006-05-25 13:00:03 UTC (rev 4602)
@@ -162,7 +162,7 @@
#define opcodeGen(z) #z,
-char *opcodeStrings [] = {
+const char *opcodeStrings [] = {
opcodes ()
};
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/bytecode/print-opcodes.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/bytecode/print-opcodes.c 2006-05-25 12:41:18 UTC (rev 4601)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/bytecode/print-opcodes.c 2006-05-25 13:00:03 UTC (rev 4602)
@@ -9,9 +9,10 @@
#include <stdio.h>
#include "opcode.h"
-int main () {
+int main (__attribute__((unused)) int argc,
+ __attribute__((unused)) char* argv[]) {
Opcode opc;
- int i;
+ unsigned int i;
unless (cardof (opcodeStrings) < (1 << (8 * sizeof (opc))))
die ("too many opcodes\n");
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gen/.ignore
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gen/.ignore 2006-05-25 12:41:18 UTC (rev 4601)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gen/.ignore 2006-05-25 13:00:03 UTC (rev 4602)
@@ -1,2 +1,5 @@
+basis-ffi.h
basis-ffi.sml
+c-types.h
c-types.sml
+ml-types.h
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gen/gen-basis-ffi.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gen/gen-basis-ffi.sml 2006-05-25 12:41:18 UTC (rev 4601)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gen/gen-basis-ffi.sml 2006-05-25 13:00:03 UTC (rev 4602)
@@ -340,8 +340,11 @@
fun print s = TextIO.output (f, s)
fun println s = if s <> "" then (print s; print "\n") else ()
- val () = println "/* This file is automatically generated. Do not edit. */\n"
+ val () = println "/* This file is automatically generated. Do not edit. */\n\n"
+ val () = println "#ifndef _MLTON_BASIS_FFI_H_\n"
+ val () = println "#define _MLTON_BASIS_FFI_H_\n"
val () = List.app (fn entry => println (Entry.toC entry)) entries
+ val () = println "#endif /* _MLTON_BASIS_FFI_H_ */\n"
val () = TextIO.closeOut f
in
()