File tree Expand file tree Collapse file tree 6 files changed +24
-4
lines changed Expand file tree Collapse file tree 6 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -269,6 +269,8 @@ ifneq ($(AVR), 0)
269
269
@$(MD5SUM) test.hex
270
270
$(TINYGO) build -size short -o test.hex -target=digispark examples/blinky1
271
271
@$(MD5SUM) test.hex
272
+ $(TINYGO) build -size short -o test.hex -target=digispark -gc=leaking examples/blinky1
273
+ @$(MD5SUM) test.hex
272
274
endif
273
275
$(TINYGO) build -size short -o test.hex -target=hifive1b examples/blinky1
274
276
@$(MD5SUM) test.hex
Original file line number Diff line number Diff line change @@ -318,7 +318,7 @@ func markRoots(start, end uintptr) {
318
318
}
319
319
}
320
320
321
- for addr := start ; addr != end ; addr += unsafe .Sizeof (addr ) {
321
+ for addr := start ; addr != end ; addr += unsafe .Alignof (addr ) {
322
322
root := * (* uintptr )(unsafe .Pointer (addr ))
323
323
markRoot (addr , root )
324
324
}
Original file line number Diff line number Diff line change @@ -60,3 +60,12 @@ __vector_WDT:
60
60
61
61
pop r16
62
62
reti
63
+
64
+ ; This is necessary for the garbage collector.
65
+ ; It returns the stack pointer as an uintptr.
66
+ .section .text .runtime.getCurrentStackPointer
67
+ .global runtime.getCurrentStackPointer
68
+ runtime.getCurrentStackPointer:
69
+ in r24, 0x3d ; SPL
70
+ in r25, 0x3e ; SPH
71
+ ret
Original file line number Diff line number Diff line change 3
3
"goos" : " linux" ,
4
4
"goarch" : " arm" ,
5
5
"compiler" : " avr-gcc" ,
6
- "gc" : " leaking " ,
6
+ "gc" : " conservative " ,
7
7
"linker" : " avr-gcc" ,
8
8
"ldflags" : [
9
9
" -T" , " targets/avr.ld" ,
Original file line number Diff line number Diff line change @@ -46,3 +46,5 @@ SECTIONS
46
46
/* For the memory allocator. */
47
47
_heap_start = _ebss;
48
48
_heap_end = ORIGIN (RAM) + LENGTH (RAM);
49
+ _globals_start = _sdata;
50
+ _globals_end = _ebss;
Original file line number Diff line number Diff line change @@ -23,6 +23,13 @@ var scalarSlices [4][]byte
23
23
var randSeeds [4 ]uint32
24
24
25
25
func testNonPointerHeap () {
26
+ maxSliceSize := uint32 (1024 )
27
+ if ^ uintptr (0 ) <= 0xffff {
28
+ // 16-bit and lower devices, such as AVR.
29
+ // Heap size is a real issue there, while it is still useful to run
30
+ // these tests. Therefore, lower the max slice size.
31
+ maxSliceSize = 64
32
+ }
26
33
// Allocate roughly 0.5MB of memory.
27
34
for i := 0 ; i < 1000 ; i ++ {
28
35
// Pick a random index that the optimizer can't predict.
@@ -38,9 +45,9 @@ func testNonPointerHeap() {
38
45
}
39
46
40
47
// Allocate a randomly-sized slice, randomly sliced to be smaller.
41
- sliceLen := randuint32 () % 1024
48
+ sliceLen := randuint32 () % maxSliceSize
42
49
slice := make ([]byte , sliceLen )
43
- cutLen := randuint32 () % 1024
50
+ cutLen := randuint32 () % maxSliceSize
44
51
if cutLen < sliceLen {
45
52
slice = slice [cutLen :]
46
53
}
You can’t perform that action at this time.
0 commit comments