diff options
author | Ian Lance Taylor <iant@golang.org> | 2019-06-21 14:14:58 +0000 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2019-06-21 14:14:58 +0000 |
commit | 0971481c541b5cce7de3e943c594182fbe28f02d (patch) | |
tree | daa083891ba7e3c96f4ac7419562dc67146822a6 /libgo | |
parent | 86a7e0826ec2730ed310be5c4a62d0fcf88a7a9f (diff) |
compiler: open code string slice expressions
Currently a string slice expression is implemented with a runtime
call __go_string_slice. Change it to open code it, which is more
efficient, and allows the backend to further optimize it.
Also omit the write barrier for length-only update (i.e.
s = s[:n]).
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/182540
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@272549 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo')
-rw-r--r-- | libgo/Makefile.am | 1 | ||||
-rw-r--r-- | libgo/Makefile.in | 16 | ||||
-rw-r--r-- | libgo/runtime/go-strslice.c | 30 |
3 files changed, 6 insertions, 41 deletions
diff --git a/libgo/Makefile.am b/libgo/Makefile.am index 6324170816a..4bfed3facf7 100644 --- a/libgo/Makefile.am +++ b/libgo/Makefile.am @@ -468,7 +468,6 @@ runtime_files = \ runtime/go-runtime-error.c \ runtime/go-setenv.c \ runtime/go-signal.c \ - runtime/go-strslice.c \ runtime/go-unsafe-pointer.c \ runtime/go-unsetenv.c \ runtime/go-unwind.c \ diff --git a/libgo/Makefile.in b/libgo/Makefile.in index 08a39266ccc..837e1e8a621 100644 --- a/libgo/Makefile.in +++ b/libgo/Makefile.in @@ -248,12 +248,12 @@ am__objects_3 = runtime/aeshash.lo runtime/go-assert.lo \ runtime/go-nanotime.lo runtime/go-now.lo runtime/go-nosys.lo \ runtime/go-reflect-call.lo runtime/go-runtime-error.lo \ runtime/go-setenv.lo runtime/go-signal.lo \ - runtime/go-strslice.lo runtime/go-unsafe-pointer.lo \ - runtime/go-unsetenv.lo runtime/go-unwind.lo \ - runtime/go-varargs.lo runtime/env_posix.lo runtime/panic.lo \ - runtime/print.lo runtime/proc.lo runtime/runtime_c.lo \ - runtime/stack.lo runtime/yield.lo runtime/go-context.lo \ - $(am__objects_1) $(am__objects_2) + runtime/go-unsafe-pointer.lo runtime/go-unsetenv.lo \ + runtime/go-unwind.lo runtime/go-varargs.lo \ + runtime/env_posix.lo runtime/panic.lo runtime/print.lo \ + runtime/proc.lo runtime/runtime_c.lo runtime/stack.lo \ + runtime/yield.lo runtime/go-context.lo $(am__objects_1) \ + $(am__objects_2) am_libgo_llgo_la_OBJECTS = $(am__objects_3) libgo_llgo_la_OBJECTS = $(am_libgo_llgo_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) @@ -901,7 +901,6 @@ runtime_files = \ runtime/go-runtime-error.c \ runtime/go-setenv.c \ runtime/go-signal.c \ - runtime/go-strslice.c \ runtime/go-unsafe-pointer.c \ runtime/go-unsetenv.c \ runtime/go-unwind.c \ @@ -1362,8 +1361,6 @@ runtime/go-setenv.lo: runtime/$(am__dirstamp) \ runtime/$(DEPDIR)/$(am__dirstamp) runtime/go-signal.lo: runtime/$(am__dirstamp) \ runtime/$(DEPDIR)/$(am__dirstamp) -runtime/go-strslice.lo: runtime/$(am__dirstamp) \ - runtime/$(DEPDIR)/$(am__dirstamp) runtime/go-unsafe-pointer.lo: runtime/$(am__dirstamp) \ runtime/$(DEPDIR)/$(am__dirstamp) runtime/go-unsetenv.lo: runtime/$(am__dirstamp) \ @@ -1448,7 +1445,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@runtime/$(DEPDIR)/go-runtime-error.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@runtime/$(DEPDIR)/go-setenv.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@runtime/$(DEPDIR)/go-signal.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@runtime/$(DEPDIR)/go-strslice.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@runtime/$(DEPDIR)/go-unsafe-pointer.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@runtime/$(DEPDIR)/go-unsetenv.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@runtime/$(DEPDIR)/go-unwind.Plo@am__quote@ diff --git a/libgo/runtime/go-strslice.c b/libgo/runtime/go-strslice.c deleted file mode 100644 index d51c2493781..00000000000 --- a/libgo/runtime/go-strslice.c +++ /dev/null @@ -1,30 +0,0 @@ -/* go-strslice.c -- the go string slice function. - - Copyright 2009 The Go Authors. All rights reserved. - Use of this source code is governed by a BSD-style - license that can be found in the LICENSE file. */ - -#include "runtime.h" - -String -__go_string_slice (String s, intgo start, intgo end) -{ - intgo len; - String ret; - - len = s.len; - if (end == -1) - end = len; - if (start > len || end < start || end > len) - runtime_panicstring ("string index out of bounds"); - ret.len = end - start; - // If the length of the new string is zero, the str field doesn't - // matter, so just set it to nil. This avoids the problem of - // s.str + start pointing just past the end of the string, - // which may keep the next memory block alive unnecessarily. - if (ret.len == 0) - ret.str = nil; - else - ret.str = s.str + start; - return ret; -} |