diff options
author | Ian Lance Taylor <iant@google.com> | 2011-06-14 05:53:10 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-06-14 05:53:10 +0000 |
commit | 3b8dffe701e9a1f6641f3ff1f08899614ce38ae0 (patch) | |
tree | 075a60d271b289fa96fb47546b7be74d188590e1 /libgo | |
parent | 8365a060e613196d31719832af2a4cb2b9886a30 (diff) | |
download | gcc-3b8dffe701e9a1f6641f3ff1f08899614ce38ae0.tar.gz |
Change builtin make to runtime call at lowering time.
Use kindNoPointers as 6g does.
* Make-lang.in (go/expressions.o): Depend on $(GO_RUNTIME_H).
From-SVN: r175008
Diffstat (limited to 'libgo')
-rw-r--r-- | libgo/Makefile.am | 1 | ||||
-rw-r--r-- | libgo/Makefile.in | 71 | ||||
-rw-r--r-- | libgo/runtime/go-new-channel.c | 13 | ||||
-rw-r--r-- | libgo/runtime/go-new-map.c | 4 | ||||
-rw-r--r-- | libgo/runtime/go-reflect-call.c | 2 | ||||
-rw-r--r-- | libgo/runtime/go-reflect-chan.c | 3 | ||||
-rw-r--r-- | libgo/runtime/go-reflect.c | 2 | ||||
-rw-r--r-- | libgo/runtime/go-type.h | 6 |
8 files changed, 62 insertions, 40 deletions
diff --git a/libgo/Makefile.am b/libgo/Makefile.am index c98a17637d3..761a11ad265 100644 --- a/libgo/Makefile.am +++ b/libgo/Makefile.am @@ -381,6 +381,7 @@ runtime_files = \ runtime/go-interface-eface-compare.c \ runtime/go-interface-val-compare.c \ runtime/go-lock-os-thread.c \ + runtime/go-make-slice.c \ runtime/go-map-delete.c \ runtime/go-map-index.c \ runtime/go-map-len.c \ diff --git a/libgo/Makefile.in b/libgo/Makefile.in index ac5de78dca4..8637ec41b7d 100644 --- a/libgo/Makefile.in +++ b/libgo/Makefile.in @@ -184,18 +184,18 @@ am__libgo_la_SOURCES_DIST = runtime/go-append.c runtime/go-assert.c \ runtime/go-interface-compare.c \ runtime/go-interface-eface-compare.c \ runtime/go-interface-val-compare.c runtime/go-lock-os-thread.c \ - runtime/go-map-delete.c runtime/go-map-index.c \ - runtime/go-map-len.c runtime/go-map-range.c \ - runtime/go-nanotime.c runtime/go-new-channel.c \ - runtime/go-new-map.c runtime/go-new.c runtime/go-note.c \ - runtime/go-panic.c runtime/go-panic-defer.c runtime/go-print.c \ - runtime/go-rec-big.c runtime/go-rec-nb-big.c \ - runtime/go-rec-nb-small.c runtime/go-rec-small.c \ - runtime/go-recover.c runtime/go-reflect.c \ - runtime/go-reflect-call.c runtime/go-reflect-chan.c \ - runtime/go-reflect-map.c runtime/go-rune.c \ - runtime/go-runtime-error.c runtime/go-sched.c \ - runtime/go-select.c runtime/go-semacquire.c \ + runtime/go-make-slice.c runtime/go-map-delete.c \ + runtime/go-map-index.c runtime/go-map-len.c \ + runtime/go-map-range.c runtime/go-nanotime.c \ + runtime/go-new-channel.c runtime/go-new-map.c runtime/go-new.c \ + runtime/go-note.c runtime/go-panic.c runtime/go-panic-defer.c \ + runtime/go-print.c runtime/go-rec-big.c \ + runtime/go-rec-nb-big.c runtime/go-rec-nb-small.c \ + runtime/go-rec-small.c runtime/go-recover.c \ + runtime/go-reflect.c runtime/go-reflect-call.c \ + runtime/go-reflect-chan.c runtime/go-reflect-map.c \ + runtime/go-rune.c runtime/go-runtime-error.c \ + runtime/go-sched.c runtime/go-select.c runtime/go-semacquire.c \ runtime/go-send-big.c runtime/go-send-nb-big.c \ runtime/go-send-nb-small.c runtime/go-send-small.c \ runtime/go-setenv.c runtime/go-signal.c runtime/go-strcmp.c \ @@ -227,25 +227,25 @@ am__objects_3 = go-append.lo go-assert.lo go-assert-interface.lo \ go-gomaxprocs.lo go-int-array-to-string.lo go-int-to-string.lo \ go-interface-compare.lo go-interface-eface-compare.lo \ go-interface-val-compare.lo go-lock-os-thread.lo \ - go-map-delete.lo go-map-index.lo go-map-len.lo go-map-range.lo \ - go-nanotime.lo go-new-channel.lo go-new-map.lo go-new.lo \ - go-note.lo go-panic.lo go-panic-defer.lo go-print.lo \ - go-rec-big.lo go-rec-nb-big.lo go-rec-nb-small.lo \ - go-rec-small.lo go-recover.lo go-reflect.lo go-reflect-call.lo \ - go-reflect-chan.lo go-reflect-map.lo go-rune.lo \ - go-runtime-error.lo go-sched.lo go-select.lo go-semacquire.lo \ - go-send-big.lo go-send-nb-big.lo go-send-nb-small.lo \ - go-send-small.lo go-setenv.lo go-signal.lo go-strcmp.lo \ - go-string-to-byte-array.lo go-string-to-int-array.lo \ - go-strplus.lo go-strslice.lo go-trampoline.lo go-type-eface.lo \ - go-type-error.lo go-type-identity.lo go-type-interface.lo \ - go-type-string.lo go-typedesc-equal.lo go-typestring.lo \ - go-unreflect.lo go-unsafe-new.lo go-unsafe-newarray.lo \ - go-unsafe-pointer.lo go-unwind.lo cpuprof.lo mcache.lo \ - mcentral.lo $(am__objects_1) mfinal.lo mfixalloc.lo mgc0.lo \ - mheap.lo msize.lo proc.lo thread.lo $(am__objects_2) chan.lo \ - iface.lo malloc.lo map.lo mprof.lo reflect.lo sigqueue.lo \ - string.lo + go-make-slice.lo go-map-delete.lo go-map-index.lo \ + go-map-len.lo go-map-range.lo go-nanotime.lo go-new-channel.lo \ + go-new-map.lo go-new.lo go-note.lo go-panic.lo \ + go-panic-defer.lo go-print.lo go-rec-big.lo go-rec-nb-big.lo \ + go-rec-nb-small.lo go-rec-small.lo go-recover.lo go-reflect.lo \ + go-reflect-call.lo go-reflect-chan.lo go-reflect-map.lo \ + go-rune.lo go-runtime-error.lo go-sched.lo go-select.lo \ + go-semacquire.lo go-send-big.lo go-send-nb-big.lo \ + go-send-nb-small.lo go-send-small.lo go-setenv.lo go-signal.lo \ + go-strcmp.lo go-string-to-byte-array.lo \ + go-string-to-int-array.lo go-strplus.lo go-strslice.lo \ + go-trampoline.lo go-type-eface.lo go-type-error.lo \ + go-type-identity.lo go-type-interface.lo go-type-string.lo \ + go-typedesc-equal.lo go-typestring.lo go-unreflect.lo \ + go-unsafe-new.lo go-unsafe-newarray.lo go-unsafe-pointer.lo \ + go-unwind.lo cpuprof.lo mcache.lo mcentral.lo $(am__objects_1) \ + mfinal.lo mfixalloc.lo mgc0.lo mheap.lo msize.lo proc.lo \ + thread.lo $(am__objects_2) chan.lo iface.lo malloc.lo map.lo \ + mprof.lo reflect.lo sigqueue.lo string.lo am_libgo_la_OBJECTS = $(am__objects_3) libgo_la_OBJECTS = $(am_libgo_la_OBJECTS) libgo_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ @@ -800,6 +800,7 @@ runtime_files = \ runtime/go-interface-eface-compare.c \ runtime/go-interface-val-compare.c \ runtime/go-lock-os-thread.c \ + runtime/go-make-slice.c \ runtime/go-map-delete.c \ runtime/go-map-index.c \ runtime/go-map-len.c \ @@ -2309,6 +2310,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/go-interface-val-compare.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/go-lock-os-thread.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/go-main.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/go-make-slice.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/go-map-delete.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/go-map-index.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/go-map-len.Plo@am__quote@ @@ -2610,6 +2612,13 @@ go-lock-os-thread.lo: runtime/go-lock-os-thread.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o go-lock-os-thread.lo `test -f 'runtime/go-lock-os-thread.c' || echo '$(srcdir)/'`runtime/go-lock-os-thread.c +go-make-slice.lo: runtime/go-make-slice.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT go-make-slice.lo -MD -MP -MF $(DEPDIR)/go-make-slice.Tpo -c -o go-make-slice.lo `test -f 'runtime/go-make-slice.c' || echo '$(srcdir)/'`runtime/go-make-slice.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/go-make-slice.Tpo $(DEPDIR)/go-make-slice.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='runtime/go-make-slice.c' object='go-make-slice.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o go-make-slice.lo `test -f 'runtime/go-make-slice.c' || echo '$(srcdir)/'`runtime/go-make-slice.c + go-map-delete.lo: runtime/go-map-delete.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT go-map-delete.lo -MD -MP -MF $(DEPDIR)/go-map-delete.Tpo -c -o go-map-delete.lo `test -f 'runtime/go-map-delete.c' || echo '$(srcdir)/'`runtime/go-map-delete.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/go-map-delete.Tpo $(DEPDIR)/go-map-delete.Plo diff --git a/libgo/runtime/go-new-channel.c b/libgo/runtime/go-new-channel.c index e440e873652..0c6f39185de 100644 --- a/libgo/runtime/go-new-channel.c +++ b/libgo/runtime/go-new-channel.c @@ -13,17 +13,26 @@ #include "channel.h" struct __go_channel* -__go_new_channel (const struct __go_type_descriptor *element_type, +__go_new_channel (const struct __go_type_descriptor *channel_type, uintptr_t entries) { + const struct __go_channel_type *ctd; + const struct __go_type_descriptor *element_type; uintptr_t element_size; + int ientries; struct __go_channel* ret; size_t alloc_size; int i; + __go_assert (channel_type->__code == GO_CHAN); + ctd = (const struct __go_channel_type *) channel_type; + element_type = ctd->__element_type; + element_size = element_type->__size; - if ((uintptr_t) (int) entries != entries + ientries = (int) entries; + if (ientries < 0 + || (uintptr_t) ientries != entries || entries > (uintptr_t) -1 / element_size) __go_panic_msg ("chan size out of range"); diff --git a/libgo/runtime/go-new-map.c b/libgo/runtime/go-new-map.c index 3a471299b22..05ac8a1a40c 100644 --- a/libgo/runtime/go-new-map.c +++ b/libgo/runtime/go-new-map.c @@ -106,9 +106,11 @@ __go_map_next_prime (uintptr_t n) struct __go_map * __go_new_map (const struct __go_map_descriptor *descriptor, uintptr_t entries) { + int ientries; struct __go_map *ret; - if ((uintptr_t) (int) entries != entries) + ientries = (int) entries; + if (ientries < 0 || (uintptr_t) ientries != entries) __go_panic_msg ("map size out of range"); if (entries == 0) diff --git a/libgo/runtime/go-reflect-call.c b/libgo/runtime/go-reflect-call.c index a769142c3df..27177e2fc73 100644 --- a/libgo/runtime/go-reflect-call.c +++ b/libgo/runtime/go-reflect-call.c @@ -161,7 +161,7 @@ go_complex_to_ffi (ffi_type *float_type) static ffi_type * go_type_to_ffi (const struct __go_type_descriptor *descriptor) { - switch (descriptor->__code) + switch (descriptor->__code & GO_CODE_MASK) { case GO_BOOL: if (sizeof (_Bool) == 1) diff --git a/libgo/runtime/go-reflect-chan.c b/libgo/runtime/go-reflect-chan.c index d568024b3df..61e360212f0 100644 --- a/libgo/runtime/go-reflect-chan.c +++ b/libgo/runtime/go-reflect-chan.c @@ -26,9 +26,6 @@ makechan (const struct __go_type_descriptor *typ, uint32_t size) struct __go_channel *channel; void *ret; - __go_assert (typ->__code == GO_CHAN); - typ = ((const struct __go_channel_type *) typ)->__element_type; - channel = __go_new_channel (typ, size); ret = __go_alloc (sizeof (void *)); diff --git a/libgo/runtime/go-reflect.c b/libgo/runtime/go-reflect.c index bf13a11fae2..af7d5e8968f 100644 --- a/libgo/runtime/go-reflect.c +++ b/libgo/runtime/go-reflect.c @@ -57,7 +57,7 @@ extern const struct __go_type_descriptor ptr_struct_descriptor const struct __go_type_descriptor * get_descriptor (int code) { - switch (code) + switch (code & GO_CODE_MASK) { case GO_BOOL: return &ptr_bool_descriptor; diff --git a/libgo/runtime/go-type.h b/libgo/runtime/go-type.h index e048141e93e..6e2193982d6 100644 --- a/libgo/runtime/go-type.h +++ b/libgo/runtime/go-type.h @@ -53,13 +53,17 @@ #define GO_STRUCT 25 #define GO_UNSAFE_POINTER 26 +#define GO_NO_POINTERS (1 << 7) + +#define GO_CODE_MASK 0x7f + /* For each Go type the compiler constructs one of these structures. This is used for type reflectin, interfaces, maps, and reference counting. */ struct __go_type_descriptor { - /* The type code for this type, a value in enum __go_type_codes. + /* The type code for this type, one of the type kind values above. This is used by unsafe.Reflect and unsafe.Typeof to determine the type descriptor to return for this type itself. It is also used by reflect.toType when mapping to a reflect Type structure. */ |