forked from radkomih/tinygo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
polkawasm: add custom gc that relies on an external allocator
- Loading branch information
Showing
15 changed files
with
735 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
//go:build gc.custom | ||
// +build gc.custom | ||
|
||
package runtime | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
//go:build gc.extalloc || gc.extalloc_leaking | ||
|
||
package runtime | ||
|
||
const gcDebug = false | ||
|
||
func printnum(num int) { | ||
if num == 0 { | ||
printstr("0") | ||
return | ||
} | ||
|
||
digits := [16]int{} // store up to 16 digits | ||
digitStrings := [10]string{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"} | ||
count := 0 // count of digits | ||
|
||
// extract digits from the number | ||
for ; num > 0; num /= 10 { | ||
digits[count] = num % 10 | ||
count++ | ||
} | ||
|
||
// reverse the digits | ||
for i := 0; i < count/2; i++ { | ||
j := count - i - 1 | ||
digits[i], digits[j] = digits[j], digits[i] | ||
} | ||
|
||
// print each digit | ||
for i := 0; i < count; i++ { | ||
printstr(digitStrings[digits[i]]) | ||
} | ||
} | ||
|
||
func printstr(str string) { | ||
if !gcDebug { | ||
return | ||
} | ||
|
||
for i := 0; i < len(str); i++ { | ||
if putcharPosition >= putcharBufferSize { | ||
break | ||
} | ||
|
||
putchar(str[i]) | ||
} | ||
} |
Oops, something went wrong.