- update vendor

master
dtapps 1 month ago
parent 1f3831a39c
commit b4cf941dd9

@ -1,38 +1,39 @@
module go.dtapp.net/dorm
go 1.21.5
go 1.22.1
require (
github.com/basgys/goxml2json v1.1.0
github.com/redis/go-redis/v9 v9.4.0
github.com/redis/go-redis/v9 v9.5.1
github.com/sirupsen/logrus v1.9.3
go.dtapp.net/gojson v1.0.4
go.dtapp.net/gotime v1.0.7
go.dtapp.net/gotime v1.0.8
go.mongodb.org/mongo-driver v1.14.0
gorm.io/driver/mysql v1.5.4
gorm.io/driver/postgres v1.5.6
gorm.io/driver/mysql v1.5.6
gorm.io/driver/postgres v1.5.7
gorm.io/gen v0.3.25
gorm.io/gorm v1.25.7
gorm.io/gorm v1.25.9
)
require (
github.com/bytedance/sonic v1.10.2 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/bytedance/sonic v1.11.3 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
github.com/chenzhuoyu/iasm v0.9.1 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/go-sql-driver/mysql v1.7.1 // indirect
github.com/go-sql-driver/mysql v1.8.1 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 // indirect
github.com/jackc/pgx/v5 v5.5.3 // indirect
github.com/jackc/pgx/v5 v5.5.5 // indirect
github.com/jackc/puddle/v2 v2.2.1 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.6 // indirect
github.com/klauspost/cpuid/v2 v2.2.6 // indirect
github.com/klauspost/compress v1.17.7 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/montanaflynn/stats v0.7.1 // indirect
@ -42,14 +43,14 @@ require (
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
golang.org/x/arch v0.7.0 // indirect
golang.org/x/crypto v0.19.0 // indirect
golang.org/x/mod v0.15.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/mod v0.16.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.18.0 // indirect
golang.org/x/tools v0.19.0 // indirect
gorm.io/datatypes v1.2.0 // indirect
gorm.io/hints v1.1.2 // indirect
gorm.io/plugin/dbresolver v1.5.0 // indirect
gorm.io/plugin/dbresolver v1.5.1 // indirect
)

@ -1,3 +1,5 @@
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
github.com/basgys/goxml2json v1.1.0 h1:4ln5i4rseYfXNd86lGEB+Vi652IsIXIvggKM/BhUKVw=
github.com/basgys/goxml2json v1.1.0/go.mod h1:wH7a5Np/Q4QoECFIU8zTQlZwZkrilY0itPfecMw41Dw=
github.com/bitly/go-simplejson v0.5.1 h1:xgwPbetQScXt1gh9BmoJ6j9JMr3TElvuIyjR8pgdoow=
@ -8,8 +10,8 @@ github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM=
github.com/bytedance/sonic v1.10.2 h1:GQebETVBxYB7JGWJtLBi07OVzWwt+8dWA00gEVW2ZFE=
github.com/bytedance/sonic v1.10.2/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4=
github.com/bytedance/sonic v1.11.3 h1:jRN+yEjakWh8aK5FzrciUHG8OFXK+4/KrAX/ysEtHAA=
github.com/bytedance/sonic v1.11.3/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
@ -26,8 +28,8 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/r
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI=
github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y=
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 h1:au07oEsX2xN0ktxqI+Sida1w446QrXBRJ0nee3SNZlA=
@ -43,8 +45,8 @@ github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsI
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 h1:L0QtFUgDarD7Fpv9jeVMgy/+Ec0mtnmYuImjTz6dtDA=
github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
github.com/jackc/pgx/v5 v5.5.3 h1:Ces6/M3wbDXYpM8JyyPD57ivTtJACFZJd885pdIaV2s=
github.com/jackc/pgx/v5 v5.5.3/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A=
github.com/jackc/pgx/v5 v5.5.5 h1:amBjrZVmksIdNjxGW/IiIMzxMKZFelXbUoPNb+8sjQw=
github.com/jackc/pgx/v5 v5.5.5/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A=
github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk=
github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
@ -54,11 +56,11 @@ github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/klauspost/compress v1.17.6 h1:60eq2E/jlfwQXtvZEeBUYADs+BwKBWURIY+Gj2eRGjI=
github.com/klauspost/compress v1.17.6/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg=
github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc=
github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
@ -74,8 +76,8 @@ github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8
github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/redis/go-redis/v9 v9.4.0 h1:Yzoz33UZw9I/mFhx4MNrB6Fk+XHO1VukNcCa1+lwyKk=
github.com/redis/go-redis/v9 v9.4.0/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M=
github.com/redis/go-redis/v9 v9.5.1 h1:H1X4D3yHPaYrkL5X06Wh6xNVM/pX0Ft4RV0vMGvLBh8=
github.com/redis/go-redis/v9 v9.5.1/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
@ -100,8 +102,8 @@ github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a/go.mod h1:ul22v+Nro/
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.dtapp.net/gojson v1.0.4 h1:9en9iyOOLWoEIo2eKhqt3/Djh/3HhwsTpXxgI9efPRo=
go.dtapp.net/gojson v1.0.4/go.mod h1:G9CMVzNSRkbNzIic/vJqHCOyKtw6BW2YM8Vyn64zfM0=
go.dtapp.net/gotime v1.0.7 h1:R9FJZWXrU9fcuRZkJnfhQvb5wMQmIM3pPBcx/qhI4Nc=
go.dtapp.net/gotime v1.0.7/go.mod h1:Gq7eNLr2iMLP18UNWONRq4V3Uhf/ADp4bIrS+Tc6ktY=
go.dtapp.net/gotime v1.0.8 h1:ngKBp7j3Ime1t2jU94gUeshPX1StV5E2x4STlzDMmLU=
go.dtapp.net/gotime v1.0.8/go.mod h1:BQT911XSfaJDBYPiEKGFwMjvgnZtx1F3nWu4GTg5ISY=
go.mongodb.org/mongo-driver v1.14.0 h1:P98w8egYRjYe3XDjxhYJagTokP/H6HzlsnojRgZRd80=
go.mongodb.org/mongo-driver v1.14.0/go.mod h1:Vzb0Mk/pa7e6cWw85R4F/endUC3u0U9jGcNU603k65c=
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
@ -110,17 +112,17 @@ golang.org/x/arch v0.7.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo=
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8=
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic=
golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc=
golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
@ -133,8 +135,8 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@ -146,8 +148,8 @@ golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ=
golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg=
golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw=
golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
@ -158,10 +160,10 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/datatypes v1.2.0 h1:5YT+eokWdIxhJgWHdrb2zYUimyk0+TaFth+7a0ybzco=
gorm.io/datatypes v1.2.0/go.mod h1:o1dh0ZvjIjhH/bngTpypG6lVRJ5chTBxE09FH/71k04=
gorm.io/driver/mysql v1.4.3/go.mod h1:sSIebwZAVPiT+27jK9HIwvsqOGKx3YMPmrA3mBJR10c=
gorm.io/driver/mysql v1.5.4 h1:igQmHfKcbaTVyAIHNhhB888vvxh8EdQ2uSUT0LPcBso=
gorm.io/driver/mysql v1.5.4/go.mod h1:9rYxJph/u9SWkWc9yY4XJ1F/+xO0S/ChOmbk3+Z5Tvs=
gorm.io/driver/postgres v1.5.6 h1:ydr9xEd5YAM0vxVDY0X139dyzNz10spDiDlC7+ibLeU=
gorm.io/driver/postgres v1.5.6/go.mod h1:3e019WlBaYI5o5LIdNV+LyxCMNtLOQETBXL2h4chKpA=
gorm.io/driver/mysql v1.5.6 h1:Ld4mkIickM+EliaQZQx3uOJDJHtrd70MxAUqWqlx3Y8=
gorm.io/driver/mysql v1.5.6/go.mod h1:sEtPWMiqiN1N1cMXoXmBbd8C6/l+TESwriotuRRpkDM=
gorm.io/driver/postgres v1.5.7 h1:8ptbNJTDbEmhdr62uReG5BGkdQyeasu/FZHxI0IMGnM=
gorm.io/driver/postgres v1.5.7/go.mod h1:3e019WlBaYI5o5LIdNV+LyxCMNtLOQETBXL2h4chKpA=
gorm.io/driver/sqlite v1.5.0 h1:zKYbzRCpBrT1bNijRnxLDJWPjVfImGEn0lSnUY5gZ+c=
gorm.io/driver/sqlite v1.5.0/go.mod h1:kDMDfntV9u/vuMmz8APHtHF0b4nyBB7sfCieC6G8k8I=
gorm.io/driver/sqlserver v1.4.1 h1:t4r4r6Jam5E6ejqP7N82qAJIJAht27EGT41HyPfXRw0=
@ -172,12 +174,12 @@ gorm.io/gorm v1.23.8/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=
gorm.io/gorm v1.24.7-0.20230306060331-85eaf9eeda11/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
gorm.io/gorm v1.25.0/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
gorm.io/gorm v1.25.2/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
gorm.io/gorm v1.25.7-0.20240204074919-46816ad31dde/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
gorm.io/gorm v1.25.7 h1:VsD6acwRjz2zFxGO50gPO6AkNs7KKnvfzUjHQhZDz/A=
gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
gorm.io/gorm v1.25.9 h1:wct0gxZIELDk8+ZqF/MVnHLkA1rvYlBWUMv2EdsK1g8=
gorm.io/gorm v1.25.9/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
gorm.io/hints v1.1.2 h1:b5j0kwk5p4+3BtDtYqqfY+ATSxjj+6ptPgVveuynn9o=
gorm.io/hints v1.1.2/go.mod h1:/ARdpUHAtyEMCh5NNi3tI7FsGh+Cj/MIUlvNxCNCFWg=
gorm.io/plugin/dbresolver v1.5.0 h1:XVHLxh775eP0CqVh3vcfJtYqja3uFl5Wr3cKlY8jgDY=
gorm.io/plugin/dbresolver v1.5.0/go.mod h1:l4Cn87EHLEYuqUncpEeTC2tTJQkjngPSD+lo8hIvcT0=
gorm.io/plugin/dbresolver v1.5.1 h1:s9Dj9f7r+1rE3nx/Ywzc85nXptUEaeOO0pt27xdopM8=
gorm.io/plugin/dbresolver v1.5.1/go.mod h1:l4Cn87EHLEYuqUncpEeTC2tTJQkjngPSD+lo8hIvcT0=
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=

@ -0,0 +1,27 @@
Copyright (c) 2009 The Go Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

@ -0,0 +1,14 @@
# filippo.io/edwards25519
```
import "filippo.io/edwards25519"
```
This library implements the edwards25519 elliptic curve, exposing the necessary APIs to build a wide array of higher-level primitives.
Read the docs at [pkg.go.dev/filippo.io/edwards25519](https://pkg.go.dev/filippo.io/edwards25519).
The code is originally derived from Adam Langley's internal implementation in the Go standard library, and includes George Tankersley's [performance improvements](https://golang.org/cl/71950). It was then further developed by Henry de Valence for use in ristretto255, and was finally [merged back into the Go standard library](https://golang.org/cl/276272) as of Go 1.17. It now tracks the upstream codebase and extends it with additional functionality.
Most users don't need this package, and should instead use `crypto/ed25519` for signatures, `golang.org/x/crypto/curve25519` for Diffie-Hellman, or `github.com/gtank/ristretto255` for prime order group logic. However, for anyone currently using a fork of `crypto/internal/edwards25519`/`crypto/ed25519/internal/edwards25519` or `github.com/agl/edwards25519`, this package should be a safer, faster, and more powerful alternative.
Since this package is meant to curb proliferation of edwards25519 implementations in the Go ecosystem, it welcomes requests for new APIs or reviewable performance improvements.

@ -0,0 +1,20 @@
// Copyright (c) 2021 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.
// Package edwards25519 implements group logic for the twisted Edwards curve
//
// -x^2 + y^2 = 1 + -(121665/121666)*x^2*y^2
//
// This is better known as the Edwards curve equivalent to Curve25519, and is
// the curve used by the Ed25519 signature scheme.
//
// Most users don't need this package, and should instead use crypto/ed25519 for
// signatures, golang.org/x/crypto/curve25519 for Diffie-Hellman, or
// github.com/gtank/ristretto255 for prime order group logic.
//
// However, developers who do need to interact with low-level edwards25519
// operations can use this package, which is an extended version of
// crypto/internal/edwards25519 from the standard library repackaged as
// an importable module.
package edwards25519

@ -0,0 +1,427 @@
// Copyright (c) 2017 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.
package edwards25519
import (
"errors"
"filippo.io/edwards25519/field"
)
// Point types.
type projP1xP1 struct {
X, Y, Z, T field.Element
}
type projP2 struct {
X, Y, Z field.Element
}
// Point represents a point on the edwards25519 curve.
//
// This type works similarly to math/big.Int, and all arguments and receivers
// are allowed to alias.
//
// The zero value is NOT valid, and it may be used only as a receiver.
type Point struct {
// Make the type not comparable (i.e. used with == or as a map key), as
// equivalent points can be represented by different Go values.
_ incomparable
// The point is internally represented in extended coordinates (X, Y, Z, T)
// where x = X/Z, y = Y/Z, and xy = T/Z per https://eprint.iacr.org/2008/522.
x, y, z, t field.Element
}
type incomparable [0]func()
func checkInitialized(points ...*Point) {
for _, p := range points {
if p.x == (field.Element{}) && p.y == (field.Element{}) {
panic("edwards25519: use of uninitialized Point")
}
}
}
type projCached struct {
YplusX, YminusX, Z, T2d field.Element
}
type affineCached struct {
YplusX, YminusX, T2d field.Element
}
// Constructors.
func (v *projP2) Zero() *projP2 {
v.X.Zero()
v.Y.One()
v.Z.One()
return v
}
// identity is the point at infinity.
var identity, _ = new(Point).SetBytes([]byte{
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})
// NewIdentityPoint returns a new Point set to the identity.
func NewIdentityPoint() *Point {
return new(Point).Set(identity)
}
// generator is the canonical curve basepoint. See TestGenerator for the
// correspondence of this encoding with the values in RFC 8032.
var generator, _ = new(Point).SetBytes([]byte{
0x58, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66})
// NewGeneratorPoint returns a new Point set to the canonical generator.
func NewGeneratorPoint() *Point {
return new(Point).Set(generator)
}
func (v *projCached) Zero() *projCached {
v.YplusX.One()
v.YminusX.One()
v.Z.One()
v.T2d.Zero()
return v
}
func (v *affineCached) Zero() *affineCached {
v.YplusX.One()
v.YminusX.One()
v.T2d.Zero()
return v
}
// Assignments.
// Set sets v = u, and returns v.
func (v *Point) Set(u *Point) *Point {
*v = *u
return v
}
// Encoding.
// Bytes returns the canonical 32-byte encoding of v, according to RFC 8032,
// Section 5.1.2.
func (v *Point) Bytes() []byte {
// This function is outlined to make the allocations inline in the caller
// rather than happen on the heap.
var buf [32]byte
return v.bytes(&buf)
}
func (v *Point) bytes(buf *[32]byte) []byte {
checkInitialized(v)
var zInv, x, y field.Element
zInv.Invert(&v.z) // zInv = 1 / Z
x.Multiply(&v.x, &zInv) // x = X / Z
y.Multiply(&v.y, &zInv) // y = Y / Z
out := copyFieldElement(buf, &y)
out[31] |= byte(x.IsNegative() << 7)
return out
}
var feOne = new(field.Element).One()
// SetBytes sets v = x, where x is a 32-byte encoding of v. If x does not
// represent a valid point on the curve, SetBytes returns nil and an error and
// the receiver is unchanged. Otherwise, SetBytes returns v.
//
// Note that SetBytes accepts all non-canonical encodings of valid points.
// That is, it follows decoding rules that match most implementations in
// the ecosystem rather than RFC 8032.
func (v *Point) SetBytes(x []byte) (*Point, error) {
// Specifically, the non-canonical encodings that are accepted are
// 1) the ones where the field element is not reduced (see the
// (*field.Element).SetBytes docs) and
// 2) the ones where the x-coordinate is zero and the sign bit is set.
//
// Read more at https://hdevalence.ca/blog/2020-10-04-its-25519am,
// specifically the "Canonical A, R" section.
y, err := new(field.Element).SetBytes(x)
if err != nil {
return nil, errors.New("edwards25519: invalid point encoding length")
}
// -x² + y² = 1 + dx²y²
// x² + dx²y² = x²(dy² + 1) = y² - 1
// x² = (y² - 1) / (dy² + 1)
// u = y² - 1
y2 := new(field.Element).Square(y)
u := new(field.Element).Subtract(y2, feOne)
// v = dy² + 1
vv := new(field.Element).Multiply(y2, d)
vv = vv.Add(vv, feOne)
// x = +√(u/v)
xx, wasSquare := new(field.Element).SqrtRatio(u, vv)
if wasSquare == 0 {
return nil, errors.New("edwards25519: invalid point encoding")
}
// Select the negative square root if the sign bit is set.
xxNeg := new(field.Element).Negate(xx)
xx = xx.Select(xxNeg, xx, int(x[31]>>7))
v.x.Set(xx)
v.y.Set(y)
v.z.One()
v.t.Multiply(xx, y) // xy = T / Z
return v, nil
}
func copyFieldElement(buf *[32]byte, v *field.Element) []byte {
copy(buf[:], v.Bytes())
return buf[:]
}
// Conversions.
func (v *projP2) FromP1xP1(p *projP1xP1) *projP2 {
v.X.Multiply(&p.X, &p.T)
v.Y.Multiply(&p.Y, &p.Z)
v.Z.Multiply(&p.Z, &p.T)
return v
}
func (v *projP2) FromP3(p *Point) *projP2 {
v.X.Set(&p.x)
v.Y.Set(&p.y)
v.Z.Set(&p.z)
return v
}
func (v *Point) fromP1xP1(p *projP1xP1) *Point {
v.x.Multiply(&p.X, &p.T)
v.y.Multiply(&p.Y, &p.Z)
v.z.Multiply(&p.Z, &p.T)
v.t.Multiply(&p.X, &p.Y)
return v
}
func (v *Point) fromP2(p *projP2) *Point {
v.x.Multiply(&p.X, &p.Z)
v.y.Multiply(&p.Y, &p.Z)
v.z.Square(&p.Z)
v.t.Multiply(&p.X, &p.Y)
return v
}
// d is a constant in the curve equation.
var d, _ = new(field.Element).SetBytes([]byte{
0xa3, 0x78, 0x59, 0x13, 0xca, 0x4d, 0xeb, 0x75,
0xab, 0xd8, 0x41, 0x41, 0x4d, 0x0a, 0x70, 0x00,
0x98, 0xe8, 0x79, 0x77, 0x79, 0x40, 0xc7, 0x8c,
0x73, 0xfe, 0x6f, 0x2b, 0xee, 0x6c, 0x03, 0x52})
var d2 = new(field.Element).Add(d, d)
func (v *projCached) FromP3(p *Point) *projCached {
v.YplusX.Add(&p.y, &p.x)
v.YminusX.Subtract(&p.y, &p.x)
v.Z.Set(&p.z)
v.T2d.Multiply(&p.t, d2)
return v
}
func (v *affineCached) FromP3(p *Point) *affineCached {
v.YplusX.Add(&p.y, &p.x)
v.YminusX.Subtract(&p.y, &p.x)
v.T2d.Multiply(&p.t, d2)
var invZ field.Element
invZ.Invert(&p.z)
v.YplusX.Multiply(&v.YplusX, &invZ)
v.YminusX.Multiply(&v.YminusX, &invZ)
v.T2d.Multiply(&v.T2d, &invZ)
return v
}
// (Re)addition and subtraction.
// Add sets v = p + q, and returns v.
func (v *Point) Add(p, q *Point) *Point {
checkInitialized(p, q)
qCached := new(projCached).FromP3(q)
result := new(projP1xP1).Add(p, qCached)
return v.fromP1xP1(result)
}
// Subtract sets v = p - q, and returns v.
func (v *Point) Subtract(p, q *Point) *Point {
checkInitialized(p, q)
qCached := new(projCached).FromP3(q)
result := new(projP1xP1).Sub(p, qCached)
return v.fromP1xP1(result)
}
func (v *projP1xP1) Add(p *Point, q *projCached) *projP1xP1 {
var YplusX, YminusX, PP, MM, TT2d, ZZ2 field.Element
YplusX.Add(&p.y, &p.x)
YminusX.Subtract(&p.y, &p.x)
PP.Multiply(&YplusX, &q.YplusX)
MM.Multiply(&YminusX, &q.YminusX)
TT2d.Multiply(&p.t, &q.T2d)
ZZ2.Multiply(&p.z, &q.Z)
ZZ2.Add(&ZZ2, &ZZ2)
v.X.Subtract(&PP, &MM)
v.Y.Add(&PP, &MM)
v.Z.Add(&ZZ2, &TT2d)
v.T.Subtract(&ZZ2, &TT2d)
return v
}
func (v *projP1xP1) Sub(p *Point, q *projCached) *projP1xP1 {
var YplusX, YminusX, PP, MM, TT2d, ZZ2 field.Element
YplusX.Add(&p.y, &p.x)
YminusX.Subtract(&p.y, &p.x)
PP.Multiply(&YplusX, &q.YminusX) // flipped sign
MM.Multiply(&YminusX, &q.YplusX) // flipped sign
TT2d.Multiply(&p.t, &q.T2d)
ZZ2.Multiply(&p.z, &q.Z)
ZZ2.Add(&ZZ2, &ZZ2)
v.X.Subtract(&PP, &MM)
v.Y.Add(&PP, &MM)
v.Z.Subtract(&ZZ2, &TT2d) // flipped sign
v.T.Add(&ZZ2, &TT2d) // flipped sign
return v
}
func (v *projP1xP1) AddAffine(p *Point, q *affineCached) *projP1xP1 {
var YplusX, YminusX, PP, MM, TT2d, Z2 field.Element
YplusX.Add(&p.y, &p.x)
YminusX.Subtract(&p.y, &p.x)
PP.Multiply(&YplusX, &q.YplusX)
MM.Multiply(&YminusX, &q.YminusX)
TT2d.Multiply(&p.t, &q.T2d)
Z2.Add(&p.z, &p.z)
v.X.Subtract(&PP, &MM)
v.Y.Add(&PP, &MM)
v.Z.Add(&Z2, &TT2d)
v.T.Subtract(&Z2, &TT2d)
return v
}
func (v *projP1xP1) SubAffine(p *Point, q *affineCached) *projP1xP1 {
var YplusX, YminusX, PP, MM, TT2d, Z2 field.Element
YplusX.Add(&p.y, &p.x)
YminusX.Subtract(&p.y, &p.x)
PP.Multiply(&YplusX, &q.YminusX) // flipped sign
MM.Multiply(&YminusX, &q.YplusX) // flipped sign
TT2d.Multiply(&p.t, &q.T2d)
Z2.Add(&p.z, &p.z)
v.X.Subtract(&PP, &MM)
v.Y.Add(&PP, &MM)
v.Z.Subtract(&Z2, &TT2d) // flipped sign
v.T.Add(&Z2, &TT2d) // flipped sign
return v
}
// Doubling.
func (v *projP1xP1) Double(p *projP2) *projP1xP1 {
var XX, YY, ZZ2, XplusYsq field.Element
XX.Square(&p.X)
YY.Square(&p.Y)
ZZ2.Square(&p.Z)
ZZ2.Add(&ZZ2, &ZZ2)
XplusYsq.Add(&p.X, &p.Y)
XplusYsq.Square(&XplusYsq)
v.Y.Add(&YY, &XX)
v.Z.Subtract(&YY, &XX)
v.X.Subtract(&XplusYsq, &v.Y)
v.T.Subtract(&ZZ2, &v.Z)
return v
}
// Negation.
// Negate sets v = -p, and returns v.
func (v *Point) Negate(p *Point) *Point {
checkInitialized(p)
v.x.Negate(&p.x)
v.y.Set(&p.y)
v.z.Set(&p.z)
v.t.Negate(&p.t)
return v
}
// Equal returns 1 if v is equivalent to u, and 0 otherwise.
func (v *Point) Equal(u *Point) int {
checkInitialized(v, u)
var t1, t2, t3, t4 field.Element
t1.Multiply(&v.x, &u.z)
t2.Multiply(&u.x, &v.z)
t3.Multiply(&v.y, &u.z)
t4.Multiply(&u.y, &v.z)
return t1.Equal(&t2) & t3.Equal(&t4)
}
// Constant-time operations
// Select sets v to a if cond == 1 and to b if cond == 0.
func (v *projCached) Select(a, b *projCached, cond int) *projCached {
v.YplusX.Select(&a.YplusX, &b.YplusX, cond)
v.YminusX.Select(&a.YminusX, &b.YminusX, cond)
v.Z.Select(&a.Z, &b.Z, cond)
v.T2d.Select(&a.T2d, &b.T2d, cond)
return v
}
// Select sets v to a if cond == 1 and to b if cond == 0.
func (v *affineCached) Select(a, b *affineCached, cond int) *affineCached {
v.YplusX.Select(&a.YplusX, &b.YplusX, cond)
v.YminusX.Select(&a.YminusX, &b.YminusX, cond)
v.T2d.Select(&a.T2d, &b.T2d, cond)
return v
}
// CondNeg negates v if cond == 1 and leaves it unchanged if cond == 0.
func (v *projCached) CondNeg(cond int) *projCached {
v.YplusX.Swap(&v.YminusX, cond)
v.T2d.Select(new(field.Element).Negate(&v.T2d), &v.T2d, cond)
return v
}
// CondNeg negates v if cond == 1 and leaves it unchanged if cond == 0.
func (v *affineCached) CondNeg(cond int) *affineCached {
v.YplusX.Swap(&v.YminusX, cond)
v.T2d.Select(new(field.Element).Negate(&v.T2d), &v.T2d, cond)
return v
}

@ -0,0 +1,349 @@
// Copyright (c) 2021 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.
package edwards25519
// This file contains additional functionality that is not included in the
// upstream crypto/internal/edwards25519 package.
import (
"errors"
"filippo.io/edwards25519/field"
)
// ExtendedCoordinates returns v in extended coordinates (X:Y:Z:T) where
// x = X/Z, y = Y/Z, and xy = T/Z as in https://eprint.iacr.org/2008/522.
func (v *Point) ExtendedCoordinates() (X, Y, Z, T *field.Element) {
// This function is outlined to make the allocations inline in the caller
// rather than happen on the heap. Don't change the style without making
// sure it doesn't increase the inliner cost.
var e [4]field.Element
X, Y, Z, T = v.extendedCoordinates(&e)
return
}
func (v *Point) extendedCoordinates(e *[4]field.Element) (X, Y, Z, T *field.Element) {
checkInitialized(v)
X = e[0].Set(&v.x)
Y = e[1].Set(&v.y)
Z = e[2].Set(&v.z)
T = e[3].Set(&v.t)
return
}
// SetExtendedCoordinates sets v = (X:Y:Z:T) in extended coordinates where
// x = X/Z, y = Y/Z, and xy = T/Z as in https://eprint.iacr.org/2008/522.
//
// If the coordinates are invalid or don't represent a valid point on the curve,
// SetExtendedCoordinates returns nil and an error and the receiver is
// unchanged. Otherwise, SetExtendedCoordinates returns v.
func (v *Point) SetExtendedCoordinates(X, Y, Z, T *field.Element) (*Point, error) {
if !isOnCurve(X, Y, Z, T) {
return nil, errors.New("edwards25519: invalid point coordinates")
}
v.x.Set(X)
v.y.Set(Y)
v.z.Set(Z)
v.t.Set(T)
return v, nil
}
func isOnCurve(X, Y, Z, T *field.Element) bool {
var lhs, rhs field.Element
XX := new(field.Element).Square(X)
YY := new(field.Element).Square(Y)
ZZ := new(field.Element).Square(Z)
TT := new(field.Element).Square(T)
// -x² + y² = 1 + dx²y²
// -(X/Z)² + (Y/Z)² = 1 + d(T/Z)²
// -X² + Y² = Z² + dT²
lhs.Subtract(YY, XX)
rhs.Multiply(d, TT).Add(&rhs, ZZ)
if lhs.Equal(&rhs) != 1 {
return false
}
// xy = T/Z
// XY/Z² = T/Z
// XY = TZ
lhs.Multiply(X, Y)
rhs.Multiply(T, Z)
return lhs.Equal(&rhs) == 1
}
// BytesMontgomery converts v to a point on the birationally-equivalent
// Curve25519 Montgomery curve, and returns its canonical 32 bytes encoding
// according to RFC 7748.
//
// Note that BytesMontgomery only encodes the u-coordinate, so v and -v encode
// to the same value. If v is the identity point, BytesMontgomery returns 32
// zero bytes, analogously to the X25519 function.
//
// The lack of an inverse operation (such as SetMontgomeryBytes) is deliberate:
// while every valid edwards25519 point has a unique u-coordinate Montgomery
// encoding, X25519 accepts inputs on the quadratic twist, which don't correspond
// to any edwards25519 point, and every other X25519 input corresponds to two
// edwards25519 points.
func (v *Point) BytesMontgomery() []byte {
// This function is outlined to make the allocations inline in the caller
// rather than happen on the heap.
var buf [32]byte
return v.bytesMontgomery(&buf)
}
func (v *Point) bytesMontgomery(buf *[32]byte) []byte {
checkInitialized(v)
// RFC 7748, Section 4.1 provides the bilinear map to calculate the
// Montgomery u-coordinate
//
// u = (1 + y) / (1 - y)
//
// where y = Y / Z.
var y, recip, u field.Element
y.Multiply(&v.y, y.Invert(&v.z)) // y = Y / Z
recip.Invert(recip.Subtract(feOne, &y)) // r = 1/(1 - y)
u.Multiply(u.Add(feOne, &y), &recip) // u = (1 + y)*r
return copyFieldElement(buf, &u)
}
// MultByCofactor sets v = 8 * p, and returns v.
func (v *Point) MultByCofactor(p *Point) *Point {
checkInitialized(p)
result := projP1xP1{}
pp := (&projP2{}).FromP3(p)
result.Double(pp)
pp.FromP1xP1(&result)
result.Double(pp)
pp.FromP1xP1(&result)
result.Double(pp)
return v.fromP1xP1(&result)
}
// Given k > 0, set s = s**(2*i).
func (s *Scalar) pow2k(k int) {
for i := 0; i < k; i++ {
s.Multiply(s, s)
}
}
// Invert sets s to the inverse of a nonzero scalar v, and returns s.
//
// If t is zero, Invert returns zero.
func (s *Scalar) Invert(t *Scalar) *Scalar {
// Uses a hardcoded sliding window of width 4.
var table [8]Scalar
var tt Scalar
tt.Multiply(t, t)
table[0] = *t
for i := 0; i < 7; i++ {
table[i+1].Multiply(&table[i], &tt)
}
// Now table = [t**1, t**3, t**5, t**7, t**9, t**11, t**13, t**15]
// so t**k = t[k/2] for odd k
// To compute the sliding window digits, use the following Sage script:
// sage: import itertools
// sage: def sliding_window(w,k):
// ....: digits = []
// ....: while k > 0:
// ....: if k % 2 == 1:
// ....: kmod = k % (2**w)
// ....: digits.append(kmod)
// ....: k = k - kmod
// ....: else:
// ....: digits.append(0)
// ....: k = k // 2
// ....: return digits
// Now we can compute s roughly as follows:
// sage: s = 1
// sage: for coeff in reversed(sliding_window(4,l-2)):
// ....: s = s*s
// ....: if coeff > 0 :
// ....: s = s*t**coeff
// This works on one bit at a time, with many runs of zeros.
// The digits can be collapsed into [(count, coeff)] as follows:
// sage: [(len(list(group)),d) for d,group in itertools.groupby(sliding_window(4,l-2))]
// Entries of the form (k, 0) turn into pow2k(k)
// Entries of the form (1, coeff) turn into a squaring and then a table lookup.
// We can fold the squaring into the previous pow2k(k) as pow2k(k+1).
*s = table[1/2]
s.pow2k(127 + 1)
s.Multiply(s, &table[1/2])
s.pow2k(4 + 1)
s.Multiply(s, &table[9/2])
s.pow2k(3 + 1)
s.Multiply(s, &table[11/2])
s.pow2k(3 + 1)
s.Multiply(s, &table[13/2])
s.pow2k(3 + 1)
s.Multiply(s, &table[15/2])
s.pow2k(4 + 1)
s.Multiply(s, &table[7/2])
s.pow2k(4 + 1)
s.Multiply(s, &table[15/2])
s.pow2k(3 + 1)
s.Multiply(s, &table[5/2])
s.pow2k(3 + 1)
s.Multiply(s, &table[1/2])
s.pow2k(4 + 1)
s.Multiply(s, &table[15/2])
s.pow2k(4 + 1)
s.Multiply(s, &table[15/2])
s.pow2k(4 + 1)
s.Multiply(s, &table[7/2])
s.pow2k(3 + 1)
s.Multiply(s, &table[3/2])
s.pow2k(4 + 1)
s.Multiply(s, &table[11/2])
s.pow2k(5 + 1)
s.Multiply(s, &table[11/2])
s.pow2k(9 + 1)
s.Multiply(s, &table[9/2])
s.pow2k(3 + 1)
s.Multiply(s, &table[3/2])
s.pow2k(4 + 1)
s.Multiply(s, &table[3/2])
s.pow2k(4 + 1)
s.Multiply(s, &table[3/2])
s.pow2k(4 + 1)
s.Multiply(s, &table[9/2])
s.pow2k(3 + 1)
s.Multiply(s, &table[7/2])
s.pow2k(3 + 1)
s.Multiply(s, &table[3/2])
s.pow2k(3 + 1)
s.Multiply(s, &table[13/2])
s.pow2k(3 + 1)
s.Multiply(s, &table[7/2])
s.pow2k(4 + 1)
s.Multiply(s, &table[9/2])
s.pow2k(3 + 1)
s.Multiply(s, &table[15/2])
s.pow2k(4 + 1)
s.Multiply(s, &table[11/2])
return s
}
// MultiScalarMult sets v = sum(scalars[i] * points[i]), and returns v.
//
// Execution time depends only on the lengths of the two slices, which must match.
func (v *Point) MultiScalarMult(scalars []*Scalar, points []*Point) *Point {
if len(scalars) != len(points) {
panic("edwards25519: called MultiScalarMult with different size inputs")
}
checkInitialized(points...)
// Proceed as in the single-base case, but share doublings
// between each point in the multiscalar equation.
// Build lookup tables for each point
tables := make([]projLookupTable, len(points))
for i := range tables {
tables[i].FromP3(points[i])
}
// Compute signed radix-16 digits for each scalar
digits := make([][64]int8, len(scalars))
for i := range digits {
digits[i] = scalars[i].signedRadix16()
}
// Unwrap first loop iteration to save computing 16*identity
multiple := &projCached{}
tmp1 := &projP1xP1{}
tmp2 := &projP2{}
// Lookup-and-add the appropriate multiple of each input point
for j := range tables {
tables[j].SelectInto(multiple, digits[j][63])
tmp1.Add(v, multiple) // tmp1 = v + x_(j,63)*Q in P1xP1 coords
v.fromP1xP1(tmp1) // update v
}
tmp2.FromP3(v) // set up tmp2 = v in P2 coords for next iteration
for i := 62; i >= 0; i-- {
tmp1.Double(tmp2) // tmp1 = 2*(prev) in P1xP1 coords
tmp2.FromP1xP1(tmp1) // tmp2 = 2*(prev) in P2 coords
tmp1.Double(tmp2) // tmp1 = 4*(prev) in P1xP1 coords
tmp2.FromP1xP1(tmp1) // tmp2 = 4*(prev) in P2 coords
tmp1.Double(tmp2) // tmp1 = 8*(prev) in P1xP1 coords
tmp2.FromP1xP1(tmp1) // tmp2 = 8*(prev) in P2 coords
tmp1.Double(tmp2) // tmp1 = 16*(prev) in P1xP1 coords
v.fromP1xP1(tmp1) // v = 16*(prev) in P3 coords
// Lookup-and-add the appropriate multiple of each input point
for j := range tables {
tables[j].SelectInto(multiple, digits[j][i])
tmp1.Add(v, multiple) // tmp1 = v + x_(j,i)*Q in P1xP1 coords
v.fromP1xP1(tmp1) // update v
}
tmp2.FromP3(v) // set up tmp2 = v in P2 coords for next iteration
}
return v
}
// VarTimeMultiScalarMult sets v = sum(scalars[i] * points[i]), and returns v.
//
// Execution time depends on the inputs.
func (v *Point) VarTimeMultiScalarMult(scalars []*Scalar, points []*Point) *Point {
if len(scalars) != len(points) {
panic("edwards25519: called VarTimeMultiScalarMult with different size inputs")
}
checkInitialized(points...)
// Generalize double-base NAF computation to arbitrary sizes.
// Here all the points are dynamic, so we only use the smaller
// tables.
// Build lookup tables for each point
tables := make([]nafLookupTable5, len(points))
for i := range tables {
tables[i].FromP3(points[i])
}
// Compute a NAF for each scalar
nafs := make([][256]int8, len(scalars))
for i := range nafs {
nafs[i] = scalars[i].nonAdjacentForm(5)
}
multiple := &projCached{}
tmp1 := &projP1xP1{}
tmp2 := &projP2{}
tmp2.Zero()
// Move from high to low bits, doubling the accumulator
// at each iteration and checking whether there is a nonzero
// coefficient to look up a multiple of.
//
// Skip trying to find the first nonzero coefficent, because
// searching might be more work than a few extra doublings.
for i := 255; i >= 0; i-- {
tmp1.Double(tmp2)
for j := range nafs {
if nafs[j][i] > 0 {
v.fromP1xP1(tmp1)
tables[j].SelectInto(multiple, nafs[j][i])
tmp1.Add(v, multiple)
} else if nafs[j][i] < 0 {
v.fromP1xP1(tmp1)
tables[j].SelectInto(multiple, -nafs[j][i])
tmp1.Sub(v, multiple)
}
}
tmp2.FromP1xP1(tmp1)
}
v.fromP2(tmp2)
return v
}

@ -0,0 +1,420 @@
// Copyright (c) 2017 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.
// Package field implements fast arithmetic modulo 2^255-19.
package field
import (
"crypto/subtle"
"encoding/binary"
"errors"
"math/bits"
)
// Element represents an element of the field GF(2^255-19). Note that this
// is not a cryptographically secure group, and should only be used to interact
// with edwards25519.Point coordinates.
//
// This type works similarly to math/big.Int, and all arguments and receivers
// are allowed to alias.
//
// The zero value is a valid zero element.
type Element struct {
// An element t represents the integer
// t.l0 + t.l1*2^51 + t.l2*2^102 + t.l3*2^153 + t.l4*2^204
//
// Between operations, all limbs are expected to be lower than 2^52.
l0 uint64
l1 uint64
l2 uint64
l3 uint64
l4 uint64
}
const maskLow51Bits uint64 = (1 << 51) - 1
var feZero = &Element{0, 0, 0, 0, 0}
// Zero sets v = 0, and returns v.
func (v *Element) Zero() *Element {
*v = *feZero
return v
}
var feOne = &Element{1, 0, 0, 0, 0}
// One sets v = 1, and returns v.
func (v *Element) One() *Element {
*v = *feOne
return v
}
// reduce reduces v modulo 2^255 - 19 and returns it.
func (v *Element) reduce() *Element {
v.carryPropagate()
// After the light reduction we now have a field element representation
// v < 2^255 + 2^13 * 19, but need v < 2^255 - 19.
// If v >= 2^255 - 19, then v + 19 >= 2^255, which would overflow 2^255 - 1,
// generating a carry. That is, c will be 0 if v < 2^255 - 19, and 1 otherwise.
c := (v.l0 + 19) >> 51
c = (v.l1 + c) >> 51
c = (v.l2 + c) >> 51
c = (v.l3 + c) >> 51
c = (v.l4 + c) >> 51
// If v < 2^255 - 19 and c = 0, this will be a no-op. Otherwise, it's
// effectively applying the reduction identity to the carry.
v.l0 += 19 * c
v.l1 += v.l0 >> 51
v.l0 = v.l0 & maskLow51Bits
v.l2 += v.l1 >> 51
v.l1 = v.l1 & maskLow51Bits
v.l3 += v.l2 >> 51
v.l2 = v.l2 & maskLow51Bits
v.l4 += v.l3 >> 51
v.l3 = v.l3 & maskLow51Bits
// no additional carry
v.l4 = v.l4 & maskLow51Bits
return v
}
// Add sets v = a + b, and returns v.
func (v *Element) Add(a, b *Element) *Element {
v.l0 = a.l0 + b.l0
v.l1 = a.l1 + b.l1
v.l2 = a.l2 + b.l2
v.l3 = a.l3 + b.l3
v.l4 = a.l4 + b.l4
// Using the generic implementation here is actually faster than the
// assembly. Probably because the body of this function is so simple that
// the compiler can figure out better optimizations by inlining the carry
// propagation.
return v.carryPropagateGeneric()
}
// Subtract sets v = a - b, and returns v.
func (v *Element) Subtract(a, b *Element) *Element {
// We first add 2 * p, to guarantee the subtraction won't underflow, and
// then subtract b (which can be up to 2^255 + 2^13 * 19).
v.l0 = (a.l0 + 0xFFFFFFFFFFFDA) - b.l0
v.l1 = (a.l1 + 0xFFFFFFFFFFFFE) - b.l1
v.l2 = (a.l2 + 0xFFFFFFFFFFFFE) - b.l2
v.l3 = (a.l3 + 0xFFFFFFFFFFFFE) - b.l3
v.l4 = (a.l4 + 0xFFFFFFFFFFFFE) - b.l4
return v.carryPropagate()
}
// Negate sets v = -a, and returns v.
func (v *Element) Negate(a *Element) *Element {
return v.Subtract(feZero, a)
}
// Invert sets v = 1/z mod p, and returns v.
//
// If z == 0, Invert returns v = 0.
func (v *Element) Invert(z *Element) *Element {
// Inversion is implemented as exponentiation with exponent p 2. It uses the
// same sequence of 255 squarings and 11 multiplications as [Curve25519].
var z2, z9, z11, z2_5_0, z2_10_0, z2_20_0, z2_50_0, z2_100_0, t Element
z2.Square(z) // 2
t.Square(&z2) // 4
t.Square(&t) // 8
z9.Multiply(&t, z) // 9
z11.Multiply(&z9, &z2) // 11
t.Square(&z11) // 22
z2_5_0.Multiply(&t, &z9) // 31 = 2^5 - 2^0
t.Square(&z2_5_0) // 2^6 - 2^1
for i := 0; i < 4; i++ {
t.Square(&t) // 2^10 - 2^5
}
z2_10_0.Multiply(&t, &z2_5_0) // 2^10 - 2^0
t.Square(&z2_10_0) // 2^11 - 2^1
for i := 0; i < 9; i++ {
t.Square(&t) // 2^20 - 2^10
}
z2_20_0.Multiply(&t, &z2_10_0) // 2^20 - 2^0
t.Square(&z2_20_0) // 2^21 - 2^1
for i := 0; i < 19; i++ {
t.Square(&t) // 2^40 - 2^20
}
t.Multiply(&t, &z2_20_0) // 2^40 - 2^0
t.Square(&t) // 2^41 - 2^1
for i := 0; i < 9; i++ {
t.Square(&t) // 2^50 - 2^10
}
z2_50_0.Multiply(&t, &z2_10_0) // 2^50 - 2^0
t.Square(&z2_50_0) // 2^51 - 2^1
for i := 0; i < 49; i++ {
t.Square(&t) // 2^100 - 2^50
}
z2_100_0.Multiply(&t, &z2_50_0) // 2^100 - 2^0
t.Square(&z2_100_0) // 2^101 - 2^1
for i := 0; i < 99; i++ {
t.Square(&t) // 2^200 - 2^100
}
t.Multiply(&t, &z2_100_0) // 2^200 - 2^0
t.Square(&t) // 2^201 - 2^1
for i := 0; i < 49; i++ {
t.Square(&t) // 2^250 - 2^50
}
t.Multiply(&t, &z2_50_0) // 2^250 - 2^0
t.Square(&t) // 2^251 - 2^1
t.Square(&t) // 2^252 - 2^2
t.Square(&t) // 2^253 - 2^3
t.Square(&t) // 2^254 - 2^4
t.Square(&t) // 2^255 - 2^5
return v.Multiply(&t, &z11) // 2^255 - 21
}
// Set sets v = a, and returns v.
func (v *Element) Set(a *Element) *Element {
*v = *a
return v
}
// SetBytes sets v to x, where x is a 32-byte little-endian encoding. If x is
// not of the right length, SetBytes returns nil and an error, and the
// receiver is unchanged.
//
// Consistent with RFC 7748, the most significant bit (the high bit of the
// last byte) is ignored, and non-canonical values (2^255-19 through 2^255-1)
// are accepted. Note that this is laxer than specified by RFC 8032, but
// consistent with most Ed25519 implementations.
func (v *Element) SetBytes(x []byte) (*Element, error) {
if len(x) != 32 {
return nil, errors.New("edwards25519: invalid field element input size")
}
// Bits 0:51 (bytes 0:8, bits 0:64, shift 0, mask 51).
v.l0 = binary.LittleEndian.Uint64(x[0:8])
v.l0 &= maskLow51Bits
// Bits 51:102 (bytes 6:14, bits 48:112, shift 3, mask 51).
v.l1 = binary.LittleEndian.Uint64(x[6:14]) >> 3
v.l1 &= maskLow51Bits
// Bits 102:153 (bytes 12:20, bits 96:160, shift 6, mask 51).
v.l2 = binary.LittleEndian.Uint64(x[12:20]) >> 6
v.l2 &= maskLow51Bits
// Bits 153:204 (bytes 19:27, bits 152:216, shift 1, mask 51).
v.l3 = binary.LittleEndian.Uint64(x[19:27]) >> 1
v.l3 &= maskLow51Bits
// Bits 204:255 (bytes 24:32, bits 192:256, shift 12, mask 51).
// Note: not bytes 25:33, shift 4, to avoid overread.
v.l4 = binary.LittleEndian.Uint64(x[24:32]) >> 12
v.l4 &= maskLow51Bits
return v, nil
}
// Bytes returns the canonical 32-byte little-endian encoding of v.
func (v *Element) Bytes() []byte {
// This function is outlined to make the allocations inline in the caller
// rather than happen on the heap.
var out [32]byte
return v.bytes(&out)
}
func (v *Element) bytes(out *[32]byte) []byte {
t := *v
t.reduce()
var buf [8]byte
for i, l := range [5]uint64{t.l0, t.l1, t.l2, t.l3, t.l4} {
bitsOffset := i * 51
binary.LittleEndian.PutUint64(buf[:], l<<uint(bitsOffset%8))
for i, bb := range buf {
off := bitsOffset/8 + i
if off >= len(out) {
break
}
out[off] |= bb
}
}
return out[:]
}
// Equal returns 1 if v and u are equal, and 0 otherwise.
func (v *Element) Equal(u *Element) int {
sa, sv := u.Bytes(), v.Bytes()
return subtle.ConstantTimeCompare(sa, sv)
}
// mask64Bits returns 0xffffffff if cond is 1, and 0 otherwise.
func mask64Bits(cond int) uint64 { return ^(uint64(cond) - 1) }
// Select sets v to a if cond == 1, and to b if cond == 0.
func (v *Element) Select(a, b *Element, cond int) *Element {
m := mask64Bits(cond)
v.l0 = (m & a.l0) | (^m & b.l0)
v.l1 = (m & a.l1) | (^m & b.l1)
v.l2 = (m & a.l2) | (^m & b.l2)
v.l3 = (m & a.l3) | (^m & b.l3)
v.l4 = (m & a.l4) | (^m & b.l4)
return v
}
// Swap swaps v and u if cond == 1 or leaves them unchanged if cond == 0, and returns v.
func (v *Element) Swap(u *Element, cond int) {
m := mask64Bits(cond)
t := m & (v.l0 ^ u.l0)
v.l0 ^= t
u.l0 ^= t
t = m & (v.l1 ^ u.l1)
v.l1 ^= t
u.l1 ^= t
t = m & (v.l2 ^ u.l2)
v.l2 ^= t
u.l2 ^= t
t = m & (v.l3 ^ u.l3)
v.l3 ^= t
u.l3 ^= t
t = m & (v.l4 ^ u.l4)
v.l4 ^= t
u.l4 ^= t
}
// IsNegative returns 1 if v is negative, and 0 otherwise.
func (v *Element) IsNegative() int {
return int(v.Bytes()[0] & 1)
}
// Absolute sets v to |u|, and returns v.
func (v *Element) Absolute(u *Element) *Element {
return v.Select(new(Element).Negate(u), u, u.IsNegative())
}
// Multiply sets v = x * y, and returns v.
func (v *Element) Multiply(x, y *Element) *Element {
feMul(v, x, y)
return v
}
// Square sets v = x * x, and returns v.
func (v *Element) Square(x *Element) *Element {
feSquare(v, x)
return v
}
// Mult32 sets v = x * y, and returns v.
func (v *Element) Mult32(x *Element, y uint32) *Element {
x0lo, x0hi := mul51(x.l0, y)
x1lo, x1hi := mul51(x.l1, y)
x2lo, x2hi := mul51(x.l2, y)
x3lo, x3hi := mul51(x.l3, y)
x4lo, x4hi := mul51(x.l4, y)
v.l0 = x0lo + 19*x4hi // carried over per the reduction identity
v.l1 = x1lo + x0hi
v.l2 = x2lo + x1hi
v.l3 = x3lo + x2hi
v.l4 = x4lo + x3hi
// The hi portions are going to be only 32 bits, plus any previous excess,
// so we can skip the carry propagation.
return v
}
// mul51 returns lo + hi * 2⁵¹ = a * b.
func mul51(a uint64, b uint32) (lo uint64, hi uint64) {
mh, ml := bits.Mul64(a, uint64(b))
lo = ml & maskLow51Bits
hi = (mh << 13) | (ml >> 51)
return
}
// Pow22523 set v = x^((p-5)/8), and returns v. (p-5)/8 is 2^252-3.
func (v *Element) Pow22523(x *Element) *Element {
var t0, t1, t2 Element
t0.Square(x) // x^2
t1.Square(&t0) // x^4
t1.Square(&t1) // x^8
t1.Multiply(x, &t1) // x^9
t0.Multiply(&t0, &t1) // x^11
t0.Square(&t0) // x^22
t0.Multiply(&t1, &t0) // x^31
t1.Square(&t0) // x^62
for i := 1; i < 5; i++ { // x^992
t1.Square(&t1)
}
t0.Multiply(&t1, &t0) // x^1023 -> 1023 = 2^10 - 1
t1.Square(&t0) // 2^11 - 2
for i := 1; i < 10; i++ { // 2^20 - 2^10
t1.Square(&t1)
}
t1.Multiply(&t1, &t0) // 2^20 - 1
t2.Square(&t1) // 2^21 - 2
for i := 1; i < 20; i++ { // 2^40 - 2^20
t2.Square(&t2)
}
t1.Multiply(&t2, &t1) // 2^40 - 1
t1.Square(&t1) // 2^41 - 2
for i := 1; i < 10; i++ { // 2^50 - 2^10
t1.Square(&t1)
}
t0.Multiply(&t1, &t0) // 2^50 - 1
t1.Square(&t0) // 2^51 - 2
for i := 1; i < 50; i++ { // 2^100 - 2^50
t1.Square(&t1)
}
t1.Multiply(&t1, &t0) // 2^100 - 1
t2.Square(&t1) // 2^101 - 2
for i := 1; i < 100; i++ { // 2^200 - 2^100
t2.Square(&t2)
}
t1.Multiply(&t2, &t1) // 2^200 - 1
t1.Square(&t1) // 2^201 - 2
for i := 1; i < 50; i++ { // 2^250 - 2^50
t1.Square(&t1)
}
t0.Multiply(&t1, &t0) // 2^250 - 1
t0.Square(&t0) // 2^251 - 2
t0.Square(&t0) // 2^252 - 4
return v.Multiply(&t0, x) // 2^252 - 3 -> x^(2^252-3)
}
// sqrtM1 is 2^((p-1)/4), which squared is equal to -1 by Euler's Criterion.
var sqrtM1 = &Element{1718705420411056, 234908883556509,
2233514472574048, 2117202627021982, 765476049583133}
// SqrtRatio sets r to the non-negative square root of the ratio of u and v.
//
// If u/v is square, SqrtRatio returns r and 1. If u/v is not square, SqrtRatio
// sets r according to Section 4.3 of draft-irtf-cfrg-ristretto255-decaf448-00,
// and returns r and 0.
func (r *Element) SqrtRatio(u, v *Element) (R *Element, wasSquare int) {
t0 := new(Element)
// r = (u * v3) * (u * v7)^((p-5)/8)
v2 := new(Element).Square(v)
uv3 := new(Element).Multiply(u, t0.Multiply(v2, v))
uv7 := new(Element).Multiply(uv3, t0.Square(v2))
rr := new(Element).Multiply(uv3, t0.Pow22523(uv7))
check := new(Element).Multiply(v, t0.Square(rr)) // check = v * r^2
uNeg := new(Element).Negate(u)
correctSignSqrt := check.Equal(u)
flippedSignSqrt := check.Equal(uNeg)
flippedSignSqrtI := check.Equal(t0.Multiply(uNeg, sqrtM1))
rPrime := new(Element).Multiply(rr, sqrtM1) // r_prime = SQRT_M1 * r
// r = CT_SELECT(r_prime IF flipped_sign_sqrt | flipped_sign_sqrt_i ELSE r)
rr.Select(rPrime, rr, flippedSignSqrt|flippedSignSqrtI)
r.Absolute(rr) // Choose the nonnegative square root.
return r, correctSignSqrt | flippedSignSqrt
}

@ -0,0 +1,16 @@
// Code generated by command: go run fe_amd64_asm.go -out ../fe_amd64.s -stubs ../fe_amd64.go -pkg field. DO NOT EDIT.
//go:build amd64 && gc && !purego
// +build amd64,gc,!purego
package field
// feMul sets out = a * b. It works like feMulGeneric.
//
//go:noescape
func feMul(out *Element, a *Element, b *Element)
// feSquare sets out = a * a. It works like feSquareGeneric.
//
//go:noescape
func feSquare(out *Element, a *Element)

@ -0,0 +1,379 @@
// Code generated by command: go run fe_amd64_asm.go -out ../fe_amd64.s -stubs ../fe_amd64.go -pkg field. DO NOT EDIT.
//go:build amd64 && gc && !purego
// +build amd64,gc,!purego
#include "textflag.h"
// func feMul(out *Element, a *Element, b *Element)
TEXT ·feMul(SB), NOSPLIT, $0-24
MOVQ a+8(FP), CX
MOVQ b+16(FP), BX
// r0 = a0×b0
MOVQ (CX), AX
MULQ (BX)
MOVQ AX, DI
MOVQ DX, SI
// r0 += 19×a1×b4
MOVQ 8(CX), AX
IMUL3Q $0x13, AX, AX
MULQ 32(BX)
ADDQ AX, DI
ADCQ DX, SI
// r0 += 19×a2×b3
MOVQ 16(CX), AX
IMUL3Q $0x13, AX, AX
MULQ 24(BX)
ADDQ AX, DI
ADCQ DX, SI
// r0 += 19×a3×b2
MOVQ 24(CX), AX
IMUL3Q $0x13, AX, AX
MULQ 16(BX)
ADDQ AX, DI
ADCQ DX, SI
// r0 += 19×a4×b1
MOVQ 32(CX), AX
IMUL3Q $0x13, AX, AX
MULQ 8(BX)
ADDQ AX, DI
ADCQ DX, SI
// r1 = a0×b1
MOVQ (CX), AX
MULQ 8(BX)
MOVQ AX, R9
MOVQ DX, R8
// r1 += a1×b0
MOVQ 8(CX), AX
MULQ (BX)
ADDQ AX, R9
ADCQ DX, R8
// r1 += 19×a2×b4
MOVQ 16(CX), AX
IMUL3Q $0x13, AX, AX
MULQ 32(BX)
ADDQ AX, R9
ADCQ DX, R8
// r1 += 19×a3×b3
MOVQ 24(CX), AX
IMUL3Q $0x13, AX, AX
MULQ 24(BX)
ADDQ AX, R9
ADCQ DX, R8
// r1 += 19×a4×b2
MOVQ 32(CX), AX
IMUL3Q $0x13, AX, AX
MULQ 16(BX)
ADDQ AX, R9
ADCQ DX, R8
// r2 = a0×b2
MOVQ (CX), AX
MULQ 16(BX)
MOVQ AX, R11
MOVQ DX, R10
// r2 += a1×b1
MOVQ 8(CX), AX
MULQ 8(BX)
ADDQ AX, R11
ADCQ DX, R10
// r2 += a2×b0
MOVQ 16(CX), AX
MULQ (BX)
ADDQ AX, R11
ADCQ DX, R10
// r2 += 19×a3×b4
MOVQ 24(CX), AX
IMUL3Q $0x13, AX, AX
MULQ 32(BX)
ADDQ AX, R11
ADCQ DX, R10
// r2 += 19×a4×b3
MOVQ 32(CX), AX
IMUL3Q $0x13, AX, AX
MULQ 24(BX)
ADDQ AX, R11
ADCQ DX, R10
// r3 = a0×b3
MOVQ (CX), AX
MULQ 24(BX)
MOVQ AX, R13
MOVQ DX, R12
// r3 += a1×b2
MOVQ 8(CX), AX
MULQ 16(BX)
ADDQ AX, R13
ADCQ DX, R12
// r3 += a2×b1
MOVQ 16(CX), AX
MULQ 8(BX)
ADDQ AX, R13
ADCQ DX, R12
// r3 += a3×b0
MOVQ 24(CX), AX
MULQ (BX)
ADDQ AX, R13
ADCQ DX, R12
// r3 += 19×a4×b4
MOVQ 32(CX), AX
IMUL3Q $0x13, AX, AX
MULQ 32(BX)
ADDQ AX, R13
ADCQ DX, R12
// r4 = a0×b4
MOVQ (CX), AX
MULQ 32(BX)
MOVQ AX, R15
MOVQ DX, R14
// r4 += a1×b3
MOVQ 8(CX), AX
MULQ 24(BX)
ADDQ AX, R15
ADCQ DX, R14
// r4 += a2×b2
MOVQ 16(CX), AX
MULQ 16(BX)
ADDQ AX, R15
ADCQ DX, R14
// r4 += a3×b1
MOVQ 24(CX), AX
MULQ 8(BX)
ADDQ AX, R15
ADCQ DX, R14
// r4 += a4×b0
MOVQ 32(CX), AX
MULQ (BX)
ADDQ AX, R15
ADCQ DX, R14
// First reduction chain
MOVQ $0x0007ffffffffffff, AX
SHLQ $0x0d, DI, SI
SHLQ $0x0d, R9, R8
SHLQ $0x0d, R11, R10
SHLQ $0x0d, R13, R12
SHLQ $0x0d, R15, R14
ANDQ AX, DI
IMUL3Q $0x13, R14, R14
ADDQ R14, DI
ANDQ AX, R9
ADDQ SI, R9
ANDQ AX, R11
ADDQ R8, R11
ANDQ AX, R13
ADDQ R10, R13
ANDQ AX, R15
ADDQ R12, R15
// Second reduction chain (carryPropagate)
MOVQ DI, SI
SHRQ $0x33, SI
MOVQ R9, R8
SHRQ $0x33, R8
MOVQ R11, R10
SHRQ $0x33, R10
MOVQ R13, R12
SHRQ $0x33, R12
MOVQ R15, R14
SHRQ $0x33, R14
ANDQ AX, DI
IMUL3Q $0x13, R14, R14
ADDQ R14, DI
ANDQ AX, R9
ADDQ SI, R9
ANDQ AX, R11
ADDQ R8, R11
ANDQ AX, R13
ADDQ R10, R13
ANDQ AX, R15
ADDQ R12, R15
// Store output
MOVQ out+0(FP), AX
MOVQ DI, (AX)
MOVQ R9, 8(AX)
MOVQ R11, 16(AX)
MOVQ R13, 24(AX)
MOVQ R15, 32(AX)
RET
// func feSquare(out *Element, a *Element)
TEXT ·feSquare(SB), NOSPLIT, $0-16
MOVQ a+8(FP), CX
// r0 = l0×l0
MOVQ (CX), AX
MULQ (CX)
MOVQ AX, SI
MOVQ DX, BX
// r0 += 38×l1×l4
MOVQ 8(CX), AX
IMUL3Q $0x26, AX, AX
MULQ 32(CX)
ADDQ AX, SI
ADCQ DX, BX
// r0 += 38×l2×l3
MOVQ 16(CX), AX
IMUL3Q $0x26, AX, AX
MULQ 24(CX)
ADDQ AX, SI
ADCQ DX, BX
// r1 = 2×l0×l1
MOVQ (CX), AX
SHLQ $0x01, AX
MULQ 8(CX)
MOVQ AX, R8
MOVQ DX, DI
// r1 += 38×l2×l4
MOVQ 16(CX), AX
IMUL3Q $0x26, AX, AX
MULQ 32(CX)
ADDQ AX, R8
ADCQ DX, DI
// r1 += 19×l3×l3
MOVQ 24(CX), AX
IMUL3Q $0x13, AX, AX
MULQ 24(CX)
ADDQ AX, R8
ADCQ DX, DI
// r2 = 2×l0×l2
MOVQ (CX), AX
SHLQ $0x01, AX
MULQ 16(CX)
MOVQ AX, R10
MOVQ DX, R9
// r2 += l1×l1
MOVQ 8(CX), AX
MULQ 8(CX)
ADDQ AX, R10
ADCQ DX, R9
// r2 += 38×l3×l4
MOVQ 24(CX), AX
IMUL3Q $0x26, AX, AX
MULQ 32(CX)
ADDQ AX, R10
ADCQ DX, R9
// r3 = 2×l0×l3
MOVQ (CX), AX
SHLQ $0x01, AX
MULQ 24(CX)
MOVQ AX, R12
MOVQ DX, R11
// r3 += 2×l1×l2
MOVQ 8(CX), AX
IMUL3Q $0x02, AX, AX
MULQ 16(CX)
ADDQ AX, R12
ADCQ DX, R11
// r3 += 19×l4×l4
MOVQ 32(CX), AX
IMUL3Q $0x13, AX, AX
MULQ 32(CX)
ADDQ AX, R12
ADCQ DX, R11
// r4 = 2×l0×l4
MOVQ (CX), AX
SHLQ $0x01, AX
MULQ 32(CX)
MOVQ AX, R14
MOVQ DX, R13
// r4 += 2×l1×l3
MOVQ 8(CX), AX
IMUL3Q $0x02, AX, AX
MULQ 24(CX)
ADDQ AX, R14
ADCQ DX, R13
// r4 += l2×l2
MOVQ 16(CX), AX
MULQ 16(CX)
ADDQ AX, R14
ADCQ DX, R13
// First reduction chain
MOVQ $0x0007ffffffffffff, AX
SHLQ $0x0d, SI, BX
SHLQ $0x0d, R8, DI
SHLQ $0x0d, R10, R9
SHLQ $0x0d, R12, R11
SHLQ $0x0d, R14, R13
ANDQ AX, SI
IMUL3Q $0x13, R13, R13
ADDQ R13, SI
ANDQ AX, R8
ADDQ BX, R8
ANDQ AX, R10
ADDQ DI, R10
ANDQ AX, R12
ADDQ R9, R12
ANDQ AX, R14
ADDQ R11, R14
// Second reduction chain (carryPropagate)
MOVQ SI, BX
SHRQ $0x33, BX
MOVQ R8, DI
SHRQ $0x33, DI
MOVQ R10, R9
SHRQ $0x33, R9
MOVQ R12, R11
SHRQ $0x33, R11
MOVQ R14, R13
SHRQ $0x33, R13
ANDQ AX, SI
IMUL3Q $0x13, R13, R13
ADDQ R13, SI
ANDQ AX, R8
ADDQ BX, R8
ANDQ AX, R10
ADDQ DI, R10
ANDQ AX, R12
ADDQ R9, R12
ANDQ AX, R14
ADDQ R11, R14
// Store output
MOVQ out+0(FP), AX
MOVQ SI, (AX)
MOVQ R8, 8(AX)
MOVQ R10, 16(AX)
MOVQ R12, 24(AX)
MOVQ R14, 32(AX)
RET

@ -0,0 +1,12 @@
// Copyright (c) 2019 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.
//go:build !amd64 || !gc || purego
// +build !amd64 !gc purego
package field
func feMul(v, x, y *Element) { feMulGeneric(v, x, y) }
func feSquare(v, x *Element) { feSquareGeneric(v, x) }

@ -0,0 +1,16 @@
// Copyright (c) 2020 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.
//go:build arm64 && gc && !purego
// +build arm64,gc,!purego
package field
//go:noescape
func carryPropagate(v *Element)
func (v *Element) carryPropagate() *Element {
carryPropagate(v)
return v
}

@ -0,0 +1,42 @@
// Copyright (c) 2020 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.
//go:build arm64 && gc && !purego
#include "textflag.h"
// carryPropagate works exactly like carryPropagateGeneric and uses the
// same AND, ADD, and LSR+MADD instructions emitted by the compiler, but
// avoids loading R0-R4 twice and uses LDP and STP.
//
// See https://golang.org/issues/43145 for the main compiler issue.
//
// func carryPropagate(v *Element)
TEXT ·carryPropagate(SB),NOFRAME|NOSPLIT,$0-8
MOVD v+0(FP), R20
LDP 0(R20), (R0, R1)
LDP 16(R20), (R2, R3)
MOVD 32(R20), R4
AND $0x7ffffffffffff, R0, R10
AND $0x7ffffffffffff, R1, R11
AND $0x7ffffffffffff, R2, R12
AND $0x7ffffffffffff, R3, R13
AND $0x7ffffffffffff, R4, R14
ADD R0>>51, R11, R11
ADD R1>>51, R12, R12
ADD R2>>51, R13, R13
ADD R3>>51, R14, R14
// R4>>51 * 19 + R10 -> R10
LSR $51, R4, R21
MOVD $19, R22
MADD R22, R10, R21, R10
STP (R10, R11), 0(R20)
STP (R12, R13), 16(R20)
MOVD R14, 32(R20)
RET

@ -0,0 +1,12 @@
// Copyright (c) 2021 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.
//go:build !arm64 || !gc || purego
// +build !arm64 !gc purego
package field
func (v *Element) carryPropagate() *Element {
return v.carryPropagateGeneric()
}

@ -0,0 +1,50 @@
// Copyright (c) 2021 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.
package field
import "errors"
// This file contains additional functionality that is not included in the
// upstream crypto/ed25519/edwards25519/field package.
// SetWideBytes sets v to x, where x is a 64-byte little-endian encoding, which
// is reduced modulo the field order. If x is not of the right length,
// SetWideBytes returns nil and an error, and the receiver is unchanged.
//
// SetWideBytes is not necessary to select a uniformly distributed value, and is
// only provided for compatibility: SetBytes can be used instead as the chance
// of bias is less than 2⁻²⁵⁰.
func (v *Element) SetWideBytes(x []byte) (*Element, error) {
if len(x) != 64 {
return nil, errors.New("edwards25519: invalid SetWideBytes input size")
}
// Split the 64 bytes into two elements, and extract the most significant
// bit of each, which is ignored by SetBytes.
lo, _ := new(Element).SetBytes(x[:32])
loMSB := uint64(x[31] >> 7)
hi, _ := new(Element).SetBytes(x[32:])
hiMSB := uint64(x[63] >> 7)
// The output we want is
//
// v = lo + loMSB * 2²⁵⁵ + hi * 2²⁵⁶ + hiMSB * 2⁵¹¹
//
// which applying the reduction identity comes out to
//
// v = lo + loMSB * 19 + hi * 2 * 19 + hiMSB * 2 * 19²
//
// l0 will be the sum of a 52 bits value (lo.l0), plus a 5 bits value
// (loMSB * 19), a 6 bits value (hi.l0 * 2 * 19), and a 10 bits value
// (hiMSB * 2 * 19²), so it fits in a uint64.
v.l0 = lo.l0 + loMSB*19 + hi.l0*2*19 + hiMSB*2*19*19
v.l1 = lo.l1 + hi.l1*2*19
v.l2 = lo.l2 + hi.l2*2*19
v.l3 = lo.l3 + hi.l3*2*19
v.l4 = lo.l4 + hi.l4*2*19
return v.carryPropagate(), nil
}

@ -0,0 +1,266 @@
// Copyright (c) 2017 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.
package field
import "math/bits"
// uint128 holds a 128-bit number as two 64-bit limbs, for use with the
// bits.Mul64 and bits.Add64 intrinsics.
type uint128 struct {
lo, hi uint64
}
// mul64 returns a * b.
func mul64(a, b uint64) uint128 {
hi, lo := bits.Mul64(a, b)
return uint128{lo, hi}
}
// addMul64 returns v + a * b.
func addMul64(v uint128, a, b uint64) uint128 {
hi, lo := bits.Mul64(a, b)
lo, c := bits.Add64(lo, v.lo, 0)
hi, _ = bits.Add64(hi, v.hi, c)
return uint128{lo, hi}
}
// shiftRightBy51 returns a >> 51. a is assumed to be at most 115 bits.
func shiftRightBy51(a uint128) uint64 {
return (a.hi << (64 - 51)) | (a.lo >> 51)
}
func feMulGeneric(v, a, b *Element) {
a0 := a.l0
a1 := a.l1
a2 := a.l2
a3 := a.l3
a4 := a.l4
b0 := b.l0
b1 := b.l1
b2 := b.l2
b3 := b.l3
b4 := b.l4
// Limb multiplication works like pen-and-paper columnar multiplication, but
// with 51-bit limbs instead of digits.
//
// a4 a3 a2 a1 a0 x
// b4 b3 b2 b1 b0 =
// ------------------------
// a4b0 a3b0 a2b0 a1b0 a0b0 +
// a4b1 a3b1 a2b1 a1b1 a0b1 +
// a4b2 a3b2 a2b2 a1b2 a0b2 +
// a4b3 a3b3 a2b3 a1b3 a0b3 +
// a4b4 a3b4 a2b4 a1b4 a0b4 =
// ----------------------------------------------
// r8 r7 r6 r5 r4 r3 r2 r1 r0
//
// We can then use the reduction identity (a * 2²⁵⁵ + b = a * 19 + b) to
// reduce the limbs that would overflow 255 bits. r5 * 2²⁵⁵ becomes 19 * r5,
// r6 * 2³⁰⁶ becomes 19 * r6 * 2⁵¹, etc.
//
// Reduction can be carried out simultaneously to multiplication. For
// example, we do not compute r5: whenever the result of a multiplication
// belongs to r5, like a1b4, we multiply it by 19 and add the result to r0.
//
// a4b0 a3b0 a2b0 a1b0 a0b0 +
// a3b1 a2b1 a1b1 a0b1 19×a4b1 +
// a2b2 a1b2 a0b2 19×a4b2 19×a3b2 +
// a1b3 a0b3 19×a4b3 19×a3b3 19×a2b3 +
// a0b4 19×a4b4 19×a3b4 19×a2b4 19×a1b4 =
// --------------------------------------
// r4 r3 r2 r1 r0
//
// Finally we add up the columns into wide, overlapping limbs.
a1_19 := a1 * 19
a2_19 := a2 * 19
a3_19 := a3 * 19
a4_19 := a4 * 19
// r0 = a0×b0 + 19×(a1×b4 + a2×b3 + a3×b2 + a4×b1)
r0 := mul64(a0, b0)
r0 = addMul64(r0, a1_19, b4)
r0 = addMul64(r0, a2_19, b3)
r0 = addMul64(r0, a3_19, b2)
r0 = addMul64(r0, a4_19, b1)
// r1 = a0×b1 + a1×b0 + 19×(a2×b4 + a3×b3 + a4×b2)
r1 := mul64(a0, b1)
r1 = addMul64(r1, a1, b0)
r1 = addMul64(r1, a2_19, b4)
r1 = addMul64(r1, a3_19, b3)
r1 = addMul64(r1, a4_19, b2)
// r2 = a0×b2 + a1×b1 + a2×b0 + 19×(a3×b4 + a4×b3)
r2 := mul64(a0, b2)
r2 = addMul64(r2, a1, b1)
r2 = addMul64(r2, a2, b0)
r2 = addMul64(r2, a3_19, b4)
r2 = addMul64(r2, a4_19, b3)
// r3 = a0×b3 + a1×b2 + a2×b1 + a3×b0 + 19×a4×b4
r3 := mul64(a0, b3)
r3 = addMul64(r3, a1, b2)
r3 = addMul64(r3, a2, b1)
r3 = addMul64(r3, a3, b0)
r3 = addMul64(r3, a4_19, b4)
// r4 = a0×b4 + a1×b3 + a2×b2 + a3×b1 + a4×b0
r4 := mul64(a0, b4)
r4 = addMul64(r4, a1, b3)
r4 = addMul64(r4, a2, b2)
r4 = addMul64(r4, a3, b1)
r4 = addMul64(r4, a4, b0)
// After the multiplication, we need to reduce (carry) the five coefficients
// to obtain a result with limbs that are at most slightly larger than 2⁵¹,
// to respect the Element invariant.
//
// Overall, the reduction works the same as carryPropagate, except with
// wider inputs: we take the carry for each coefficient by shifting it right
// by 51, and add it to the limb above it. The top carry is multiplied by 19
// according to the reduction identity and added to the lowest limb.
//
// The largest coefficient (r0) will be at most 111 bits, which guarantees
// that all carries are at most 111 - 51 = 60 bits, which fits in a uint64.
//
// r0 = a0×b0 + 19×(a1×b4 + a2×b3 + a3×b2 + a4×b1)
// r0 < 2⁵²×2⁵² + 19×(2⁵²×2⁵² + 2⁵²×2⁵² + 2⁵²×2⁵² + 2⁵²×2⁵²)
// r0 < (1 + 19 × 4) × 2⁵² × 2⁵²
// r0 < 2⁷ × 2⁵² × 2⁵²
// r0 < 2¹¹¹
//
// Moreover, the top coefficient (r4) is at most 107 bits, so c4 is at most
// 56 bits, and c4 * 19 is at most 61 bits, which again fits in a uint64 and
// allows us to easily apply the reduction identity.
//
// r4 = a0×b4 + a1×b3 + a2×b2 + a3×b1 + a4×b0
// r4 < 5 × 2⁵² × 2⁵²
// r4 < 2¹⁰⁷
//
c0 := shiftRightBy51(r0)
c1 := shiftRightBy51(r1)
c2 := shiftRightBy51(r2)
c3 := shiftRightBy51(r3)
c4 := shiftRightBy51(r4)
rr0 := r0.lo&maskLow51Bits + c4*19
rr1 := r1.lo&maskLow51Bits + c0
rr2 := r2.lo&maskLow51Bits + c1
rr3 := r3.lo&maskLow51Bits + c2
rr4 := r4.lo&maskLow51Bits + c3
// Now all coefficients fit into 64-bit registers but are still too large to
// be passed around as an Element. We therefore do one last carry chain,
// where the carries will be small enough to fit in the wiggle room above 2⁵¹.
*v = Element{rr0, rr1, rr2, rr3, rr4}
v.carryPropagate()
}
func feSquareGeneric(v, a *Element) {
l0 := a.l0
l1 := a.l1
l2 := a.l2
l3 := a.l3
l4 := a.l4
// Squaring works precisely like multiplication above, but thanks to its
// symmetry we get to group a few terms together.
//
// l4 l3 l2 l1 l0 x
// l4 l3 l2 l1 l0 =
// ------------------------
// l4l0 l3l0 l2l0 l1l0 l0l0 +
// l4l1 l3l1 l2l1 l1l1 l0l1 +
// l4l2 l3l2 l2l2 l1l2 l0l2 +
// l4l3 l3l3 l2l3 l1l3 l0l3 +
// l4l4 l3l4 l2l4 l1l4 l0l4 =
// ----------------------------------------------
// r8 r7 r6 r5 r4 r3 r2 r1 r0
//
// l4l0 l3l0 l2l0 l1l0 l0l0 +
// l3l1 l2l1 l1l1 l0l1 19×l4l1 +
// l2l2 l1l2 l0l2 19×l4l2 19×l3l2 +
// l1l3 l0l3 19×l4l3 19×l3l3 19×l2l3 +
// l0l4 19×l4l4 19×l3l4 19×l2l4 19×l1l4 =
// --------------------------------------
// r4 r3 r2 r1 r0
//
// With precomputed 2×, 19×, and 2×19× terms, we can compute each limb with
// only three Mul64 and four Add64, instead of five and eight.
l0_2 := l0 * 2
l1_2 := l1 * 2
l1_38 := l1 * 38
l2_38 := l2 * 38
l3_38 := l3 * 38
l3_19 := l3 * 19
l4_19 := l4 * 19
// r0 = l0×l0 + 19×(l1×l4 + l2×l3 + l3×l2 + l4×l1) = l0×l0 + 19×2×(l1×l4 + l2×l3)
r0 := mul64(l0, l0)
r0 = addMul64(r0, l1_38, l4)
r0 = addMul64(r0, l2_38, l3)
// r1 = l0×l1 + l1×l0 + 19×(l2×l4 + l3×l3 + l4×l2) = 2×l0×l1 + 19×2×l2×l4 + 19×l3×l3
r1 := mul64(l0_2, l1)
r1 = addMul64(r1, l2_38, l4)
r1 = addMul64(r1, l3_19, l3)
// r2 = l0×l2 + l1×l1 + l2×l0 + 19×(l3×l4 + l4×l3) = 2×l0×l2 + l1×l1 + 19×2×l3×l4
r2 := mul64(l0_2, l2)
r2 = addMul64(r2, l1, l1)
r2 = addMul64(r2, l3_38, l4)
// r3 = l0×l3 + l1×l2 + l2×l1 + l3×l0 + 19×l4×l4 = 2×l0×l3 + 2×l1×l2 + 19×l4×l4
r3 := mul64(l0_2, l3)
r3 = addMul64(r3, l1_2, l2)
r3 = addMul64(r3, l4_19, l4)
// r4 = l0×l4 + l1×l3 + l2×l2 + l3×l1 + l4×l0 = 2×l0×l4 + 2×l1×l3 + l2×l2
r4 := mul64(l0_2, l4)
r4 = addMul64(r4, l1_2, l3)
r4 = addMul64(r4, l2, l2)
c0 := shiftRightBy51(r0)
c1 := shiftRightBy51(r1)
c2 := shiftRightBy51(r2)
c3 := shiftRightBy51(r3)
c4 := shiftRightBy51(r4)
rr0 := r0.lo&maskLow51Bits + c4*19
rr1 := r1.lo&maskLow51Bits + c0
rr2 := r2.lo&maskLow51Bits + c1
rr3 := r3.lo&maskLow51Bits + c2
rr4 := r4.lo&maskLow51Bits + c3
*v = Element{rr0, rr1, rr2, rr3, rr4}
v.carryPropagate()
}
// carryPropagateGeneric brings the limbs below 52 bits by applying the reduction
// identity (a * 2²⁵⁵ + b = a * 19 + b) to the l4 carry.
func (v *Element) carryPropagateGeneric() *Element {
c0 := v.l0 >> 51
c1 := v.l1 >> 51
c2 := v.l2 >> 51
c3 := v.l3 >> 51
c4 := v.l4 >> 51
// c4 is at most 64 - 51 = 13 bits, so c4*19 is at most 18 bits, and
// the final l0 will be at most 52 bits. Similarly for the rest.
v.l0 = v.l0&maskLow51Bits + c4*19
v.l1 = v.l1&maskLow51Bits + c0
v.l2 = v.l2&maskLow51Bits + c1
v.l3 = v.l3&maskLow51Bits + c2
v.l4 = v.l4&maskLow51Bits + c3
return v
}

@ -0,0 +1,343 @@
// Copyright (c) 2016 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.
package edwards25519
import (
"encoding/binary"
"errors"
)
// A Scalar is an integer modulo
//
// l = 2^252 + 27742317777372353535851937790883648493
//
// which is the prime order of the edwards25519 group.
//
// This type works similarly to math/big.Int, and all arguments and
// receivers are allowed to alias.
//
// The zero value is a valid zero element.
type Scalar struct {
// s is the scalar in the Montgomery domain, in the format of the
// fiat-crypto implementation.
s fiatScalarMontgomeryDomainFieldElement
}
// The field implementation in scalar_fiat.go is generated by the fiat-crypto
// project (https://github.com/mit-plv/fiat-crypto) at version v0.0.9 (23d2dbc)
// from a formally verified model.
//
// fiat-crypto code comes under the following license.
//
// Copyright (c) 2015-2020 The fiat-crypto Authors. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// THIS SOFTWARE IS PROVIDED BY the fiat-crypto authors "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Berkeley Software Design,
// Inc. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// NewScalar returns a new zero Scalar.
func NewScalar() *Scalar {
return &Scalar{}
}
// MultiplyAdd sets s = x * y + z mod l, and returns s. It is equivalent to
// using Multiply and then Add.
func (s *Scalar) MultiplyAdd(x, y, z *Scalar) *Scalar {
// Make a copy of z in case it aliases s.
zCopy := new(Scalar).Set(z)
return s.Multiply(x, y).Add(s, zCopy)
}
// Add sets s = x + y mod l, and returns s.
func (s *Scalar) Add(x, y *Scalar) *Scalar {
// s = 1 * x + y mod l
fiatScalarAdd(&s.s, &x.s, &y.s)
return s
}
// Subtract sets s = x - y mod l, and returns s.
func (s *Scalar) Subtract(x, y *Scalar) *Scalar {
// s = -1 * y + x mod l
fiatScalarSub(&s.s, &x.s, &y.s)
return s
}
// Negate sets s = -x mod l, and returns s.
func (s *Scalar) Negate(x *Scalar) *Scalar {
// s = -1 * x + 0 mod l
fiatScalarOpp(&s.s, &x.s)
return s
}
// Multiply sets s = x * y mod l, and returns s.
func (s *Scalar) Multiply(x, y *Scalar) *Scalar {
// s = x * y + 0 mod l
fiatScalarMul(&s.s, &x.s, &y.s)
return s
}
// Set sets s = x, and returns s.
func (s *Scalar) Set(x *Scalar) *Scalar {
*s = *x
return s
}
// SetUniformBytes sets s = x mod l, where x is a 64-byte little-endian integer.
// If x is not of the right length, SetUniformBytes returns nil and an error,
// and the receiver is unchanged.
//
// SetUniformBytes can be used to set s to a uniformly distributed value given
// 64 uniformly distributed random bytes.
func (s *Scalar) SetUniformBytes(x []byte) (*Scalar, error) {
if len(x) != 64 {
return nil, errors.New("edwards25519: invalid SetUniformBytes input length")
}
// We have a value x of 512 bits, but our fiatScalarFromBytes function
// expects an input lower than l, which is a little over 252 bits.
//
// Instead of writing a reduction function that operates on wider inputs, we
// can interpret x as the sum of three shorter values a, b, and c.
//
// x = a + b * 2^168 + c * 2^336 mod l
//
// We then precompute 2^168 and 2^336 modulo l, and perform the reduction
// with two multiplications and two additions.
s.setShortBytes(x[:21])
t := new(Scalar).setShortBytes(x[21:42])
s.Add(s, t.Multiply(t, scalarTwo168))
t.setShortBytes(x[42:])
s.Add(s, t.Multiply(t, scalarTwo336))
return s, nil
}
// scalarTwo168 and scalarTwo336 are 2^168 and 2^336 modulo l, encoded as a
// fiatScalarMontgomeryDomainFieldElement, which is a little-endian 4-limb value
// in the 2^256 Montgomery domain.
var scalarTwo168 = &Scalar{s: [4]uint64{0x5b8ab432eac74798, 0x38afddd6de59d5d7,
0xa2c131b399411b7c, 0x6329a7ed9ce5a30}}
var scalarTwo336 = &Scalar{s: [4]uint64{0xbd3d108e2b35ecc5, 0x5c3a3718bdf9c90b,
0x63aa97a331b4f2ee, 0x3d217f5be65cb5c}}
// setShortBytes sets s = x mod l, where x is a little-endian integer shorter
// than 32 bytes.
func (s *Scalar) setShortBytes(x []byte) *Scalar {
if len(x) >= 32 {
panic("edwards25519: internal error: setShortBytes called with a long string")
}
var buf [32]byte
copy(buf[:], x)
fiatScalarFromBytes((*[4]uint64)(&s.s), &buf)
fiatScalarToMontgomery(&s.s, (*fiatScalarNonMontgomeryDomainFieldElement)(&s.s))
return s
}
// SetCanonicalBytes sets s = x, where x is a 32-byte little-endian encoding of
// s, and returns s. If x is not a canonical encoding of s, SetCanonicalBytes
// returns nil and an error, and the receiver is unchanged.
func (s *Scalar) SetCanonicalBytes(x []byte) (*Scalar, error) {
if len(x) != 32 {
return nil, errors.New("invalid scalar length")
}
if !isReduced(x) {
return nil, errors.New("invalid scalar encoding")
}
fiatScalarFromBytes((*[4]uint64)(&s.s), (*[32]byte)(x))
fiatScalarToMontgomery(&s.s, (*fiatScalarNonMontgomeryDomainFieldElement)(&s.s))
return s, nil
}
// scalarMinusOneBytes is l - 1 in little endian.
var scalarMinusOneBytes = [32]byte{236, 211, 245, 92, 26, 99, 18, 88, 214, 156, 247, 162, 222, 249, 222, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16}
// isReduced returns whether the given scalar in 32-byte little endian encoded
// form is reduced modulo l.
func isReduced(s []byte) bool {
if len(s) != 32 {
return false
}
for i := len(s) - 1; i >= 0; i-- {
switch {
case s[i] > scalarMinusOneBytes[i]:
return false
case s[i] < scalarMinusOneBytes[i]:
return true
}
}
return true
}
// SetBytesWithClamping applies the buffer pruning described in RFC 8032,
// Section 5.1.5 (also known as clamping) and sets s to the result. The input
// must be 32 bytes, and it is not modified. If x is not of the right length,
// SetBytesWithClamping returns nil and an error, and the receiver is unchanged.
//
// Note that since Scalar values are always reduced modulo the prime order of
// the curve, the resulting value will not preserve any of the cofactor-clearing
// properties that clamping is meant to provide. It will however work as
// expected as long as it is applied to points on the prime order subgroup, like
// in Ed25519. In fact, it is lost to history why RFC 8032 adopted the
// irrelevant RFC 7748 clamping, but it is now required for compatibility.
func (s *Scalar) SetBytesWithClamping(x []byte) (*Scalar, error) {
// The description above omits the purpose of the high bits of the clamping
// for brevity, but those are also lost to reductions, and are also
// irrelevant to edwards25519 as they protect against a specific
// implementation bug that was once observed in a generic Montgomery ladder.
if len(x) != 32 {
return nil, errors.New("edwards25519: invalid SetBytesWithClamping input length")
}
// We need to use the wide reduction from SetUniformBytes, since clamping
// sets the 2^254 bit, making the value higher than the order.
var wideBytes [64]byte
copy(wideBytes[:], x[:])
wideBytes[0] &= 248
wideBytes[31] &= 63
wideBytes[31] |= 64
return s.SetUniformBytes(wideBytes[:])
}
// Bytes returns the canonical 32-byte little-endian encoding of s.
func (s *Scalar) Bytes() []byte {
// This function is outlined to make the allocations inline in the caller
// rather than happen on the heap.
var encoded [32]byte
return s.bytes(&encoded)
}
func (s *Scalar) bytes(out *[32]byte) []byte {
var ss fiatScalarNonMontgomeryDomainFieldElement
fiatScalarFromMontgomery(&ss, &s.s)
fiatScalarToBytes(out, (*[4]uint64)(&ss))
return out[:]
}
// Equal returns 1 if s and t are equal, and 0 otherwise.
func (s *Scalar) Equal(t *Scalar) int {
var diff fiatScalarMontgomeryDomainFieldElement
fiatScalarSub(&diff, &s.s, &t.s)
var nonzero uint64
fiatScalarNonzero(&nonzero, (*[4]uint64)(&diff))
nonzero |= nonzero >> 32
nonzero |= nonzero >> 16
nonzero |= nonzero >> 8
nonzero |= nonzero >> 4
nonzero |= nonzero >> 2
nonzero |= nonzero >> 1
return int(^nonzero) & 1
}
// nonAdjacentForm computes a width-w non-adjacent form for this scalar.
//
// w must be between 2 and 8, or nonAdjacentForm will panic.
func (s *Scalar) nonAdjacentForm(w uint) [256]int8 {
// This implementation is adapted from the one
// in curve25519-dalek and is documented there:
// https://github.com/dalek-cryptography/curve25519-dalek/blob/f630041af28e9a405255f98a8a93adca18e4315b/src/scalar.rs#L800-L871
b := s.Bytes()
if b[31] > 127 {
panic("scalar has high bit set illegally")
}
if w < 2 {
panic("w must be at least 2 by the definition of NAF")
} else if w > 8 {
panic("NAF digits must fit in int8")
}
var naf [256]int8
var digits [5]uint64
for i := 0; i < 4; i++ {
digits[i] = binary.LittleEndian.Uint64(b[i*8:])
}
width := uint64(1 << w)
windowMask := uint64(width - 1)
pos := uint(0)
carry := uint64(0)
for pos < 256 {
indexU64 := pos / 64
indexBit := pos % 64
var bitBuf uint64
if indexBit < 64-w {
// This window's bits are contained in a single u64
bitBuf = digits[indexU64] >> indexBit
} else {
// Combine the current 64 bits with bits from the next 64
bitBuf = (digits[indexU64] >> indexBit) | (digits[1+indexU64] << (64 - indexBit))
}
// Add carry into the current window
window := carry + (bitBuf & windowMask)
if window&1 == 0 {
// If the window value is even, preserve the carry and continue.
// Why is the carry preserved?
// If carry == 0 and window & 1 == 0,
// then the next carry should be 0
// If carry == 1 and window & 1 == 0,
// then bit_buf & 1 == 1 so the next carry should be 1
pos += 1
continue
}
if window < width/2 {
carry = 0
naf[pos] = int8(window)
} else {
carry = 1
naf[pos] = int8(window) - int8(width)
}
pos += w
}
return naf
}
func (s *Scalar) signedRadix16() [64]int8 {
b := s.Bytes()
if b[31] > 127 {
panic("scalar has high bit set illegally")
}
var digits [64]int8
// Compute unsigned radix-16 digits:
for i := 0; i < 32; i++ {
digits[2*i] = int8(b[i] & 15)
digits[2*i+1] = int8((b[i] >> 4) & 15)
}
// Recenter coefficients:
for i := 0; i < 63; i++ {
carry := (digits[i] + 8) >> 4
digits[i] -= carry << 4
digits[i+1] += carry
}
return digits
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,214 @@
// Copyright (c) 2019 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.
package edwards25519
import "sync"
// basepointTable is a set of 32 affineLookupTables, where table i is generated
// from 256i * basepoint. It is precomputed the first time it's used.
func basepointTable() *[32]affineLookupTable {
basepointTablePrecomp.initOnce.Do(func() {
p := NewGeneratorPoint()
for i := 0; i < 32; i++ {
basepointTablePrecomp.table[i].FromP3(p)
for j := 0; j < 8; j++ {
p.Add(p, p)
}
}
})
return &basepointTablePrecomp.table
}
var basepointTablePrecomp struct {
table [32]affineLookupTable
initOnce sync.Once
}
// ScalarBaseMult sets v = x * B, where B is the canonical generator, and
// returns v.
//
// The scalar multiplication is done in constant time.
func (v *Point) ScalarBaseMult(x *Scalar) *Point {
basepointTable := basepointTable()
// Write x = sum(x_i * 16^i) so x*B = sum( B*x_i*16^i )
// as described in the Ed25519 paper
//
// Group even and odd coefficients
// x*B = x_0*16^0*B + x_2*16^2*B + ... + x_62*16^62*B
// + x_1*16^1*B + x_3*16^3*B + ... + x_63*16^63*B
// x*B = x_0*16^0*B + x_2*16^2*B + ... + x_62*16^62*B
// + 16*( x_1*16^0*B + x_3*16^2*B + ... + x_63*16^62*B)
//
// We use a lookup table for each i to get x_i*16^(2*i)*B
// and do four doublings to multiply by 16.
digits := x.signedRadix16()
multiple := &affineCached{}
tmp1 := &projP1xP1{}
tmp2 := &projP2{}
// Accumulate the odd components first
v.Set(NewIdentityPoint())
for i := 1; i < 64; i += 2 {
basepointTable[i/2].SelectInto(multiple, digits[i])
tmp1.AddAffine(v, multiple)
v.fromP1xP1(tmp1)
}
// Multiply by 16
tmp2.FromP3(v) // tmp2 = v in P2 coords
tmp1.Double(tmp2) // tmp1 = 2*v in P1xP1 coords
tmp2.FromP1xP1(tmp1) // tmp2 = 2*v in P2 coords
tmp1.Double(tmp2) // tmp1 = 4*v in P1xP1 coords
tmp2.FromP1xP1(tmp1) // tmp2 = 4*v in P2 coords
tmp1.Double(tmp2) // tmp1 = 8*v in P1xP1 coords
tmp2.FromP1xP1(tmp1) // tmp2 = 8*v in P2 coords
tmp1.Double(tmp2) // tmp1 = 16*v in P1xP1 coords
v.fromP1xP1(tmp1) // now v = 16*(odd components)
// Accumulate the even components
for i := 0; i < 64; i += 2 {
basepointTable[i/2].SelectInto(multiple, digits[i])
tmp1.AddAffine(v, multiple)
v.fromP1xP1(tmp1)
}
return v
}
// ScalarMult sets v = x * q, and returns v.
//
// The scalar multiplication is done in constant time.
func (v *Point) ScalarMult(x *Scalar, q *Point) *Point {
checkInitialized(q)
var table projLookupTable
table.FromP3(q)
// Write x = sum(x_i * 16^i)
// so x*Q = sum( Q*x_i*16^i )
// = Q*x_0 + 16*(Q*x_1 + 16*( ... + Q*x_63) ... )
// <------compute inside out---------
//
// We use the lookup table to get the x_i*Q values
// and do four doublings to compute 16*Q
digits := x.signedRadix16()
// Unwrap first loop iteration to save computing 16*identity
multiple := &projCached{}
tmp1 := &projP1xP1{}
tmp2 := &projP2{}
table.SelectInto(multiple, digits[63])
v.Set(NewIdentityPoint())
tmp1.Add(v, multiple) // tmp1 = x_63*Q in P1xP1 coords
for i := 62; i >= 0; i-- {
tmp2.FromP1xP1(tmp1) // tmp2 = (prev) in P2 coords
tmp1.Double(tmp2) // tmp1 = 2*(prev) in P1xP1 coords
tmp2.FromP1xP1(tmp1) // tmp2 = 2*(prev) in P2 coords
tmp1.Double(tmp2) // tmp1 = 4*(prev) in P1xP1 coords
tmp2.FromP1xP1(tmp1) // tmp2 = 4*(prev) in P2 coords
tmp1.Double(tmp2) // tmp1 = 8*(prev) in P1xP1 coords
tmp2.FromP1xP1(tmp1) // tmp2 = 8*(prev) in P2 coords
tmp1.Double(tmp2) // tmp1 = 16*(prev) in P1xP1 coords
v.fromP1xP1(tmp1) // v = 16*(prev) in P3 coords
table.SelectInto(multiple, digits[i])
tmp1.Add(v, multiple) // tmp1 = x_i*Q + 16*(prev) in P1xP1 coords
}
v.fromP1xP1(tmp1)
return v
}
// basepointNafTable is the nafLookupTable8 for the basepoint.
// It is precomputed the first time it's used.
func basepointNafTable() *nafLookupTable8 {
basepointNafTablePrecomp.initOnce.Do(func() {
basepointNafTablePrecomp.table.FromP3(NewGeneratorPoint())
})
return &basepointNafTablePrecomp.table
}
var basepointNafTablePrecomp struct {
table nafLookupTable8
initOnce sync.Once
}
// VarTimeDoubleScalarBaseMult sets v = a * A + b * B, where B is the canonical
// generator, and returns v.
//
// Execution time depends on the inputs.
func (v *Point) VarTimeDoubleScalarBaseMult(a *Scalar, A *Point, b *Scalar) *Point {
checkInitialized(A)
// Similarly to the single variable-base approach, we compute
// digits and use them with a lookup table. However, because
// we are allowed to do variable-time operations, we don't
// need constant-time lookups or constant-time digit
// computations.
//
// So we use a non-adjacent form of some width w instead of
// radix 16. This is like a binary representation (one digit
// for each binary place) but we allow the digits to grow in
// magnitude up to 2^{w-1} so that the nonzero digits are as
// sparse as possible. Intuitively, this "condenses" the
// "mass" of the scalar onto sparse coefficients (meaning
// fewer additions).
basepointNafTable := basepointNafTable()
var aTable nafLookupTable5
aTable.FromP3(A)
// Because the basepoint is fixed, we can use a wider NAF
// corresponding to a bigger table.
aNaf := a.nonAdjacentForm(5)
bNaf := b.nonAdjacentForm(8)
// Find the first nonzero coefficient.
i := 255
for j := i; j >= 0; j-- {
if aNaf[j] != 0 || bNaf[j] != 0 {
break
}
}
multA := &projCached{}
multB := &affineCached{}
tmp1 := &projP1xP1{}
tmp2 := &projP2{}
tmp2.Zero()
// Move from high to low bits, doubling the accumulator
// at each iteration and checking whether there is a nonzero
// coefficient to look up a multiple of.
for ; i >= 0; i-- {
tmp1.Double(tmp2)
// Only update v if we have a nonzero coeff to add in.
if aNaf[i] > 0 {
v.fromP1xP1(tmp1)
aTable.SelectInto(multA, aNaf[i])
tmp1.Add(v, multA)
} else if aNaf[i] < 0 {
v.fromP1xP1(tmp1)
aTable.SelectInto(multA, -aNaf[i])
tmp1.Sub(v, multA)
}
if bNaf[i] > 0 {
v.fromP1xP1(tmp1)
basepointNafTable.SelectInto(multB, bNaf[i])
tmp1.AddAffine(v, multB)
} else if bNaf[i] < 0 {
v.fromP1xP1(tmp1)
basepointNafTable.SelectInto(multB, -bNaf[i])
tmp1.SubAffine(v, multB)
}
tmp2.FromP1xP1(tmp1)
}
v.fromP2(tmp2)
return v
}

@ -0,0 +1,129 @@
// Copyright (c) 2019 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.
package edwards25519
import (
"crypto/subtle"
)
// A dynamic lookup table for variable-base, constant-time scalar muls.
type projLookupTable struct {
points [8]projCached
}
// A precomputed lookup table for fixed-base, constant-time scalar muls.
type affineLookupTable struct {
points [8]affineCached
}
// A dynamic lookup table for variable-base, variable-time scalar muls.
type nafLookupTable5 struct {
points [8]projCached
}
// A precomputed lookup table for fixed-base, variable-time scalar muls.
type nafLookupTable8 struct {
points [64]affineCached
}
// Constructors.
// Builds a lookup table at runtime. Fast.
func (v *projLookupTable) FromP3(q *Point) {
// Goal: v.points[i] = (i+1)*Q, i.e., Q, 2Q, ..., 8Q
// This allows lookup of -8Q, ..., -Q, 0, Q, ..., 8Q
v.points[0].FromP3(q)
tmpP3 := Point{}
tmpP1xP1 := projP1xP1{}
for i := 0; i < 7; i++ {
// Compute (i+1)*Q as Q + i*Q and convert to a projCached
// This is needlessly complicated because the API has explicit
// receivers instead of creating stack objects and relying on RVO
v.points[i+1].FromP3(tmpP3.fromP1xP1(tmpP1xP1.Add(q, &v.points[i])))
}
}
// This is not optimised for speed; fixed-base tables should be precomputed.
func (v *affineLookupTable) FromP3(q *Point) {
// Goal: v.points[i] = (i+1)*Q, i.e., Q, 2Q, ..., 8Q
// This allows lookup of -8Q, ..., -Q, 0, Q, ..., 8Q
v.points[0].FromP3(q)
tmpP3 := Point{}
tmpP1xP1 := projP1xP1{}
for i := 0; i < 7; i++ {
// Compute (i+1)*Q as Q + i*Q and convert to affineCached
v.points[i+1].FromP3(tmpP3.fromP1xP1(tmpP1xP1.AddAffine(q, &v.points[i])))
}
}
// Builds a lookup table at runtime. Fast.
func (v *nafLookupTable5) FromP3(q *Point) {
// Goal: v.points[i] = (2*i+1)*Q, i.e., Q, 3Q, 5Q, ..., 15Q
// This allows lookup of -15Q, ..., -3Q, -Q, 0, Q, 3Q, ..., 15Q
v.points[0].FromP3(q)
q2 := Point{}
q2.Add(q, q)
tmpP3 := Point{}
tmpP1xP1 := projP1xP1{}
for i := 0; i < 7; i++ {
v.points[i+1].FromP3(tmpP3.fromP1xP1(tmpP1xP1.Add(&q2, &v.points[i])))
}
}
// This is not optimised for speed; fixed-base tables should be precomputed.
func (v *nafLookupTable8) FromP3(q *Point) {
v.points[0].FromP3(q)
q2 := Point{}
q2.Add(q, q)
tmpP3 := Point{}
tmpP1xP1 := projP1xP1{}
for i := 0; i < 63; i++ {
v.points[i+1].FromP3(tmpP3.fromP1xP1(tmpP1xP1.AddAffine(&q2, &v.points[i])))
}
}
// Selectors.
// Set dest to x*Q, where -8 <= x <= 8, in constant time.
func (v *projLookupTable) SelectInto(dest *projCached, x int8) {
// Compute xabs = |x|
xmask := x >> 7
xabs := uint8((x + xmask) ^ xmask)
dest.Zero()
for j := 1; j <= 8; j++ {
// Set dest = j*Q if |x| = j
cond := subtle.ConstantTimeByteEq(xabs, uint8(j))
dest.Select(&v.points[j-1], dest, cond)
}
// Now dest = |x|*Q, conditionally negate to get x*Q
dest.CondNeg(int(xmask & 1))
}
// Set dest to x*Q, where -8 <= x <= 8, in constant time.
func (v *affineLookupTable) SelectInto(dest *affineCached, x int8) {
// Compute xabs = |x|
xmask := x >> 7
xabs := uint8((x + xmask) ^ xmask)
dest.Zero()
for j := 1; j <= 8; j++ {
// Set dest = j*Q if |x| = j
cond := subtle.ConstantTimeByteEq(xabs, uint8(j))
dest.Select(&v.points[j-1], dest, cond)
}
// Now dest = |x|*Q, conditionally negate to get x*Q
dest.CondNeg(int(xmask & 1))
}
// Given odd x with 0 < x < 2^4, return x*Q (in variable time).
func (v *nafLookupTable5) SelectInto(dest *projCached, x int8) {
*dest = v.points[x/2]
}
// Given odd x with 0 < x < 2^7, return x*Q (in variable time).
func (v *nafLookupTable8) SelectInto(dest *affineCached, x int8) {
*dest = v.points[x/2]
}

@ -23,9 +23,9 @@ CPU_avx := amd64
CPU_avx2 := amd64
CPU_sse := amd64
TMPL_avx := fastint_amd64_test fastfloat_amd64_test native_amd64_test recover_amd64_test
TMPL_avx2 := fastint_amd64_test fastfloat_amd64_test native_amd64_test recover_amd64_test
TMPL_sse := fastint_amd64_test fastfloat_amd64_test native_amd64_test recover_amd64_test
TMPL_avx := native_test fastint_test fastfloat_test native_amd64 recover_test
TMPL_avx2 := native_test fastint_test fastfloat_test native_amd64 recover_test
TMPL_sse := native_test fastint_test fastfloat_test native_amd64 recover_test
CFLAGS_avx := -msse -mno-sse4 -mavx -mpclmul -mno-avx2 -mstack-alignment=0 -DUSE_AVX=1 -DUSE_AVX2=0
CFLAGS_avx2 := -msse -mno-sse4 -mavx -mpclmul -mavx2 -mstack-alignment=0 -DUSE_AVX=1 -DUSE_AVX2=1
@ -54,10 +54,14 @@ define build_tmpl
$(eval @arch := $(1))
$(eval @tmpl := $(2))
$(eval @dest := $(3))
$(eval @cpu := $(4))
${@dest}: ${@tmpl}
mkdir -p $(dir ${@dest})
echo '// Code generated by Makefile, DO NOT EDIT.' > ${@dest}
echo '// +build ${@cpu}' > ${@dest}
echo >> ${@dest}
echo >> ${@dest}
echo '// Code generated by Makefile, DO NOT EDIT.' >> ${@dest}
echo >> ${@dest}
sed -e 's/{{PACKAGE}}/${@arch}/g' ${@tmpl} >> ${@dest}
endef
@ -91,7 +95,8 @@ $(foreach \
build_tmpl, \
$(1), \
${OUT_DIR}/${tmpl}.tmpl, \
${OUT_DIR}/$(1)/${tmpl}.go \
${OUT_DIR}/$(1)/${tmpl}.go, \
$(value CPU_$(1)) \
)) \
)
endef

@ -5,18 +5,27 @@ English | [中文](README_ZH_CN.md)
A blazingly fast JSON serializing &amp; deserializing library, accelerated by JIT (just-in-time compiling) and SIMD (single-instruction-multiple-data).
## Requirement
- Go 1.16~1.21
- Go 1.16~1.22
- Linux / MacOS / Windows(need go1.17 above)
- Amd64 ARCH
## Features
- Runtime object binding without code generation
- Complete APIs for JSON value manipulation
- Fast, fast, fast!
## APIs
see [go.dev](https://pkg.go.dev/github.com/bytedance/sonic)
## Benchmarks
For **all sizes** of json and **all scenarios** of usage, **Sonic performs best**.
- [Medium](https://github.com/bytedance/sonic/blob/main/decoder/testdata_test.go#L19) (13KB, 300+ key, 6 layers)
```powershell
goversion: 1.17.1
goos: darwin
@ -81,6 +90,7 @@ BenchmarkLoadNode_Parallel/LoadAll()-16 5493 ns/op 2370.6
BenchmarkLoadNode/Interface()-16 17722 ns/op 734.85 MB/s 13323 B/op 88 allocs/op
BenchmarkLoadNode_Parallel/Interface()-16 10330 ns/op 1260.70 MB/s 15178 B/op 88 allocs/op
```
- [Small](https://github.com/bytedance/sonic/blob/main/testdata/small.go) (400B, 11 keys, 3 layers)
![small benchmarks](./docs/imgs/bench-small.png)
- [Large](https://github.com/bytedance/sonic/blob/main/testdata/twitter.json) (635KB, 10000+ key, 6 layers)
@ -89,6 +99,7 @@ BenchmarkLoadNode_Parallel/Interface()-16 10330 ns/op 1260.7
See [bench.sh](https://github.com/bytedance/sonic/blob/main/scripts/bench.sh) for benchmark codes.
## How it works
See [INTRODUCTION.md](./docs/INTRODUCTION.md).
## Usage
@ -96,6 +107,7 @@ See [INTRODUCTION.md](./docs/INTRODUCTION.md).
### Marshal/Unmarshal
Default behaviors are mostly consistent with `encoding/json`, except HTML escaping form (see [Escape HTML](https://github.com/bytedance/sonic/blob/main/README.md#escape-html)) and `SortKeys` feature (optional support see [Sort Keys](https://github.com/bytedance/sonic/blob/main/README.md#sort-keys)) that is **NOT** in conformity to [RFC8259](https://datatracker.ietf.org/doc/html/rfc8259).
```go
import "github.com/bytedance/sonic"
@ -107,8 +119,11 @@ err := sonic.Unmarshal(output, &data)
```
### Streaming IO
Sonic supports decoding json from `io.Reader` or encoding objects into `io.Writer`, aims at handling multiple values as well as reducing memory consumption.
- encoder
```go
var o1 = map[string]interface{}{
"a": "b",
@ -123,7 +138,9 @@ fmt.Println(w.String())
// {"a":"b"}
// 1
```
- decoder
```go
var o = map[string]interface{}{}
var r = strings.NewReader(`{"a":"b"}{"1":"2"}`)
@ -136,6 +153,7 @@ fmt.Printf("%+v", o)
```
### Use Number/Use Int64
```go
import "github.com/bytedance/sonic/decoder"
@ -164,7 +182,9 @@ fm := root.Interface().(float64) // jn == jm
```
### Sort Keys
On account of the performance loss from sorting (roughly 10%), sonic doesn't enable this feature by default. If your component depends on it to work (like [zstd](https://github.com/facebook/zstd)), Use it like this:
```go
import "github.com/bytedance/sonic"
import "github.com/bytedance/sonic/encoder"
@ -177,19 +197,26 @@ v, err := encoder.Encode(m, encoder.SortMapKeys)
var root := sonic.Get(JSON)
err := root.SortKeys()
```
### Escape HTML
On account of the performance loss (roughly 15%), sonic doesn't enable this feature by default. You can use `encoder.EscapeHTML` option to open this feature (align with `encoding/json.HTMLEscape`).
```go
import "github.com/bytedance/sonic"
v := map[string]string{"&&":"<>"}
ret, err := Encode(v, EscapeHTML) // ret == `{"\u0026\u0026":{"X":"\u003c\u003e"}}`
```
### Compact Format
Sonic encodes primitive objects (struct/map...) as compact-format JSON by default, except marshaling `json.RawMessage` or `json.Marshaler`: sonic ensures validating their output JSON but **DONOT** compacting them for performance concerns. We provide the option `encoder.CompactMarshaler` to add compacting process.
### Print Error
If there invalid syntax in input JSON, sonic will return `decoder.SyntaxError`, which supports pretty-printing of error position
```go
import "github.com/bytedance/sonic"
import "github.com/bytedance/sonic/decoder"
@ -215,7 +242,9 @@ if err != nil {
```
#### Mismatched Types [Sonic v1.6.0]
If there a **mismatch-typed** value for a given key, sonic will report `decoder.MismatchTypeError` (if there are many, report the last one), but still skip wrong the value and keep decoding next JSON.
```go
import "github.com/bytedance/sonic"
import "github.com/bytedance/sonic/decoder"
@ -228,10 +257,15 @@ err := UnmarshalString(`{"A":"1","B":1}`, &data)
println(err.Error()) // Mismatch type int with value string "at index 5: mismatched type with value\n\n\t{\"A\":\"1\",\"B\":1}\n\t.....^.........\n"
fmt.Printf("%+v", data) // {A:0 B:1}
```
### Ast.Node
Sonic/ast.Node is a completely self-contained AST for JSON. It implements serialization and deserialization both and provides robust APIs for obtaining and modification of generic data.
#### Get/Index
Search partial JSON by given paths, which must be non-negative integer or string, or nil
```go
import "github.com/bytedance/sonic"
@ -245,10 +279,13 @@ raw := root.Raw() // == string(input)
root, err := sonic.Get(input, "key1", 1, "key2")
sub := root.Get("key3").Index(2).Int64() // == 3
```
**Tip**: since `Index()` uses offset to locate data, which is much faster than scanning like `Get()`, we suggest you use it as much as possible. And sonic also provides another API `IndexOrGet()` to underlying use offset as well as ensure the key is matched.
#### Set/Unset
Modify the json content by Set()/Unset()
```go
import "github.com/bytedance/sonic"
@ -265,7 +302,9 @@ println(root.Get("key4").Check()) // "value not exist"
```
#### Serialize
To encode `ast.Node` as json, use `MarshalJson()` or `json.Marshal()` (MUST pass the node's pointer)
```go
import (
"encoding/json"
@ -279,6 +318,7 @@ println(string(buf) == string(exp)) // true
```
#### APIs
- validation: `Check()`, `Error()`, `Valid()`, `Exist()`
- searching: `Index()`, `Get()`, `IndexPair()`, `IndexOrGet()`, `GetByPath()`
- go-type casting: `Int64()`, `Float64()`, `String()`, `Number()`, `Bool()`, `Map[UseNumber|UseNode]()`, `Array[UseNumber|UseNode]()`, `Interface[UseNumber|UseNode]()`
@ -287,7 +327,9 @@ println(string(buf) == string(exp)) // true
- modification: `Set()`, `SetByIndex()`, `Add()`
### Ast.Visitor
Sonic provides an advanced API for fully parsing JSON into non-standard types (neither `struct` not `map[string]interface{}`) without using any intermediate representation (`ast.Node` or `interface{}`). For example, you might have the following types which are like `interface{}` but actually not `interface{}`:
```go
type UserNode interface {}
@ -302,7 +344,9 @@ type (
UserArray struct{ Value []UserNode }
)
```
Sonic provides the following API to return **the preorder traversal of a JSON AST**. The `ast.Visitor` is a SAX style interface which is used in some C++ JSON library. You should implement `ast.Visitor` by yourself and pass it to `ast.Preorder()` method. In your visitor you can make your custom types to represent JSON values. There may be an O(n) space container (such as stack) in your visitor to record the object / array hierarchy.
```go
func Preorder(str string, visitor Visitor, opts *VisitorOptions) error
@ -323,12 +367,14 @@ type Visitor interface {
See [ast/visitor.go](https://github.com/bytedance/sonic/blob/main/ast/visitor.go) for detailed usage. We also implement a demo visitor for `UserNode` in [ast/visitor_test.go](https://github.com/bytedance/sonic/blob/main/ast/visitor_test.go).
## Compatibility
Sonic **DOES NOT** ensure to support all environments, due to the difficulty of developing high-performance codes. For developers who use sonic to build their applications in different environments, we have the following suggestions:
- Developing on **Mac M1**: Make sure you have Rosetta 2 installed on your machine, and set `GOARCH=amd64` when building your application. Rosetta 2 can automatically translate x86 binaries to arm64 binaries and run x86 applications on Mac M1.
- Developing on **Linux arm64**: You can install qemu and use the `qemu-x86_64 -cpu max` command to convert x86 binaries to amr64 binaries for applications built with sonic. The qemu can achieve a similar transfer effect to Rosetta 2 on Mac M1.
For developers who want to use sonic on Linux arm64 without qemu, or those who want to handle JSON strictly consistent with `encoding/json`, we provide some compatible APIs as `sonic.API`
- `ConfigDefault`: the sonic's default config (`EscapeHTML=false`,`SortKeys=false`...) to run on sonic-supporting environment. It will fall back to `encoding/json` with the corresponding config, and some options like `SortKeys=false` will be invalid.
- `ConfigStd`: the std-compatible config (`EscapeHTML=true`,`SortKeys=true`...) to run on sonic-supporting environment. It will fall back to `encoding/json`.
- `ConfigFastest`: the fastest config (`NoQuoteTextMarshaler=true`) to run on sonic-supporting environment. It will fall back to `encoding/json` with the corresponding config, and some options will be invalid.
@ -336,7 +382,9 @@ For developers who want to use sonic on Linux arm64 without qemu, or those who w
## Tips
### Pretouch
Since Sonic uses [golang-asm](https://github.com/twitchyliquid64/golang-asm) as a JIT assembler, which is NOT very suitable for runtime compiling, first-hit running of a huge schema may cause request-timeout or even process-OOM. For better stability, we advise **using `Pretouch()` for huge-schema or compact-memory applications** before `Marshal()/Unmarshal()`.
```go
import (
"reflect"
@ -362,17 +410,23 @@ func init() {
```
### Copy string
When decoding **string values without any escaped characters**, sonic references them from the origin JSON buffer instead of mallocing a new buffer to copy. This helps a lot for CPU performance but may leave the whole JSON buffer in memory as long as the decoded objects are being used. In practice, we found the extra memory introduced by referring JSON buffer is usually 20% ~ 80% of decoded objects. Once an application holds these objects for a long time (for example, cache the decoded objects for reusing), its in-use memory on the server may go up. We provide the option `decoder.CopyString()` for users to choose not to reference the JSON buffer, which may cause a decline in CPU performance to some degree.
When decoding **string values without any escaped characters**, sonic references them from the origin JSON buffer instead of mallocing a new buffer to copy. This helps a lot for CPU performance but may leave the whole JSON buffer in memory as long as the decoded objects are being used. In practice, we found the extra memory introduced by referring JSON buffer is usually 20% ~ 80% of decoded objects. Once an application holds these objects for a long time (for example, cache the decoded objects for reusing), its in-use memory on the server may go up. - `Config.CopyString`/`decoder.CopyString()`: We provide the option for `Decode()` / `Unmarshal()` users to choose not to reference the JSON buffer, which may cause a decline in CPU performance to some degree.
- `GetFromStringNoCopy()`: For memory safety, `sonic.Get()` / `sonic.GetFromString()` now copies return JSON. If users want to get json more quickly and not care about memory usage, you can use `GetFromStringNoCopy()` to return a JSON directly referenced from source.
### Pass string or []byte?
For alignment to `encoding/json`, we provide API to pass `[]byte` as an argument, but the string-to-bytes copy is conducted at the same time considering safety, which may lose performance when the origin JSON is huge. Therefore, you can use `UnmarshalString()` and `GetFromString()` to pass a string, as long as your origin data is a string or **nocopy-cast** is safe for your []byte. We also provide API `MarshalString()` for convenient **nocopy-cast** of encoded JSON []byte, which is safe since sonic's output bytes is always duplicated and unique.
### Accelerate `encoding.TextMarshaler`
To ensure data security, sonic.Encoder quotes and escapes string values from `encoding.TextMarshaler` interfaces by default, which may degrade performance much if most of your data is in form of them. We provide `encoder.NoQuoteTextMarshaler` to skip these operations, which means you **MUST** ensure their output string escaped and quoted following [RFC8259](https://datatracker.ietf.org/doc/html/rfc8259).
To ensure data security, sonic.Encoder quotes and escapes string values from `encoding.TextMarshaler` interfaces by default, which may degrade performance much if most of your data is in form of them. We provide `encoder.NoQuoteTextMarshaler` to skip these operations, which means you **MUST** ensure their output string escaped and quoted following [RFC8259](https://datatracker.ietf.org/doc/html/rfc8259).
### Better performance for generic data
In **fully-parsed** scenario, `Unmarshal()` performs better than `Get()`+`Node.Interface()`. But if you only have a part of the schema for specific json, you can combine `Get()` and `Unmarshal()` together:
```go
import "github.com/bytedance/sonic"
@ -380,7 +434,9 @@ node, err := sonic.GetFromString(_TwitterJson, "statuses", 3, "user")
var user User // your partial schema...
err = sonic.UnmarshalString(node.Raw(), &user)
```
Even if you don't have any schema, use `ast.Node` as the container of generic values instead of `map` or `interface`:
```go
import "github.com/bytedance/sonic"
@ -391,7 +447,9 @@ err = user.Check()
// err = user.LoadAll() // only call this when you want to use 'user' concurrently...
go someFunc(user)
```
Why? Because `ast.Node` stores its children using `array`:
- `Array`'s performance is **much better** than `Map` when Inserting (Deserialize) and Scanning (Serialize) data;
- **Hashing** (`map[x]`) is not as efficient as **Indexing** (`array[x]`), which `ast.Node` can conduct on **both array and object**;
- Using `Interface()`/`Map()` means Sonic must parse all the underlying values, while `ast.Node` can parse them **on demand**.
@ -399,6 +457,7 @@ Why? Because `ast.Node` stores its children using `array`:
**CAUTION:** `ast.Node` **DOESN'T** ensure concurrent security directly, due to its **lazy-load** design. However, you can call `Node.Load()`/`Node.LoadAll()` to achieve that, which may bring performance reduction while it still works faster than converting to `map` or `interface{}`
### Ast.Node or Ast.Visitor?
For generic data, `ast.Node` should be enough for your needs in most cases.
However, `ast.Node` is designed for partially processing JSON string. It has some special designs such as lazy-load which might not be suitable for directly parsing the whole JSON string like `Unmarshal()`. Although `ast.Node` is better then `map` or `interface{}`, it's also a kind of intermediate representation after all if your final types are customized and you have to convert the above types to your custom types after parsing.
@ -408,4 +467,5 @@ For better performance, in previous case the `ast.Visitor` will be the better ch
But `ast.Visitor` is not a very handy API. You might need to write a lot of code to implement your visitor and carefully maintain the tree hierarchy during decoding. Please read the comments in [ast/visitor.go](https://github.com/bytedance/sonic/blob/main/ast/visitor.go) carefully if you decide to use this API.
## Community
Sonic is a subproject of [CloudWeGo](https://www.cloudwego.io/). We are committed to building a cloud native ecosystem.

@ -6,10 +6,14 @@
## 依赖
- Go 1.16~1.21
- Go 1.16~1.22
- Linux / MacOS / Windows需要 Go1.17 以上)
- Amd64 架构
## 接口
详见 [go.dev](https://pkg.go.dev/github.com/bytedance/sonic)
## 特色
- 运行时对象绑定,无需代码生成
@ -19,7 +23,9 @@
## 基准测试
对于**所有大小**的 json 和**所有使用场景** **Sonic 表现均为最佳**
- [中型](https://github.com/bytedance/sonic/blob/main/decoder/testdata_test.go#L19) (13kB, 300+ 键, 6 层)
```powershell
goversion: 1.17.1
goos: darwin
@ -84,6 +90,7 @@ BenchmarkLoadNode_Parallel/LoadAll()-16 5493 ns/op 2370.6
BenchmarkLoadNode/Interface()-16 17722 ns/op 734.85 MB/s 13323 B/op 88 allocs/op
BenchmarkLoadNode_Parallel/Interface()-16 10330 ns/op 1260.70 MB/s 15178 B/op 88 allocs/op
```
- [小型](https://github.com/bytedance/sonic/blob/main/testdata/small.go) (400B, 11 个键, 3 层)
![small benchmarks](./docs/imgs/bench-small.png)
- [大型](https://github.com/bytedance/sonic/blob/main/testdata/twitter.json) (635kB, 10000+ 个键, 6 层)
@ -100,6 +107,7 @@ BenchmarkLoadNode_Parallel/Interface()-16 10330 ns/op 1260.7
### 序列化/反序列化
默认的行为基本上与 `encoding/json` 相一致,除了 HTML 转义形式(参见 [Escape HTML](https://github.com/bytedance/sonic/blob/main/README.md#escape-html)) 和 `SortKeys` 功能(参见 [Sort Keys](https://github.com/bytedance/sonic/blob/main/README.md#sort-keys)**没有**遵循 [RFC8259](https://datatracker.ietf.org/doc/html/rfc8259) 。
```go
import "github.com/bytedance/sonic"
@ -113,7 +121,9 @@ err := sonic.Unmarshal(output, &data)
### 流式输入输出
Sonic 支持解码 `io.Reader` 中输入的 json或将对象编码为 json 后输出至 `io.Writer`,以处理多个值并减少内存消耗。
- 编码器
```go
var o1 = map[string]interface{}{
"a": "b",
@ -128,7 +138,9 @@ fmt.Println(w.String())
// {"a":"b"}
// 1
```
- 解码器
```go
var o = map[string]interface{}{}
var r = strings.NewReader(`{"a":"b"}{"1":"2"}`)
@ -172,6 +184,7 @@ fm := root.Interface().(float64) // jn == jm
### 对键排序
考虑到排序带来的性能损失(约 10% sonic 默认不会启用这个功能。如果你的组件依赖这个行为(如 [zstd](https://github.com/facebook/zstd)) ,可以仿照下面的例子:
```go
import "github.com/bytedance/sonic"
import "github.com/bytedance/sonic/encoder"
@ -188,6 +201,7 @@ err := root.SortKeys()
### HTML 转义
考虑到性能损失约15% sonic 默认不会启用这个功能。你可以使用 `encoder.EscapeHTML` 选项来开启(与 `encoding/json.HTMLEscape` 行为一致)。
```go
import "github.com/bytedance/sonic"
@ -196,11 +210,13 @@ ret, err := Encode(v, EscapeHTML) // ret == `{"\u0026\u0026":{"X":"\u003c\u003e"
```
### 紧凑格式
Sonic 默认将基本类型( `struct` `map` 等)编码为紧凑格式的 JSON ,除非使用 `json.RawMessage` or `json.Marshaler` 进行编码: sonic 确保输出的 JSON 合法,但出于性能考虑,**不会**加工成紧凑格式。我们提供选项 `encoder.CompactMarshaler` 来添加此过程,
### 打印错误
如果输入的 JSON 存在无效的语法sonic 将返回 `decoder.SyntaxError`,该错误支持错误位置的美化输出。
```go
import "github.com/bytedance/sonic"
import "github.com/bytedance/sonic/decoder"
@ -228,6 +244,7 @@ if err != nil {
#### 类型不匹配 [Sonic v1.6.0]
如果给定键中存在**类型不匹配**的值, sonic 会抛出 `decoder.MismatchTypeError` (如果有多个,只会报告最后一个),但仍会跳过错误的值并解码下一个 JSON 。
```go
import "github.com/bytedance/sonic"
import "github.com/bytedance/sonic/decoder"
@ -240,6 +257,7 @@ err := UnmarshalString(`{"A":"1","B":1}`, &data)
println(err.Error()) // Mismatch type int with value string "at index 5: mismatched type with value\n\n\t{\"A\":\"1\",\"B\":1}\n\t.....^.........\n"
fmt.Printf("%+v", data) // {A:0 B:1}
```
### `Ast.Node`
Sonic/ast.Node 是完全独立的 JSON 抽象语法树库。它实现了序列化和反序列化,并提供了获取和修改通用数据的鲁棒的 API。
@ -247,6 +265,7 @@ Sonic/ast.Node 是完全独立的 JSON 抽象语法树库。它实现了序列
#### 查找/索引
通过给定的路径搜索 JSON 片段,路径必须为非负整数,字符串或 `nil`
```go
import "github.com/bytedance/sonic"
@ -260,11 +279,13 @@ raw := root.Raw() // == string(input)
root, err := sonic.Get(input, "key1", 1, "key2")
sub := root.Get("key3").Index(2).Int64() // == 3
```
**注意**:由于 `Index()` 使用偏移量来定位数据,比使用扫描的 `Get()` 要快的多,建议尽可能的使用 `Index` 。 Sonic 也提供了另一个 API `IndexOrGet()` ,以偏移量为基础并且也确保键的匹配。
#### 修改
使用 ` Set()` / `Unset()` 修改 json 的内容
使用 `Set()` / `Unset()` 修改 json 的内容
```go
import "github.com/bytedance/sonic"
@ -281,7 +302,9 @@ println(root.Get("key4").Check()) // "value not exist"
```
#### 序列化
要将 `ast.Node` 编码为 json ,使用 `MarshalJson()` 或者 `json.Marshal()` (必须传递指向节点的指针)
```go
import (
"encoding/json"
@ -295,6 +318,7 @@ println(string(buf) == string(exp)) // true
```
#### APIs
- 合法性检查: `Check()`, `Error()`, `Valid()`, `Exist()`
- 索引: `Index()`, `Get()`, `IndexPair()`, `IndexOrGet()`, `GetByPath()`
- 转换至 go 内置类型: `Int64()`, `Float64()`, `String()`, `Number()`, `Bool()`, `Map[UseNumber|UseNode]()`, `Array[UseNumber|UseNode]()`, `Interface[UseNumber|UseNode]()`
@ -303,7 +327,9 @@ println(string(buf) == string(exp)) // true
- 修改: `Set()`, `SetByIndex()`, `Add()`
### `Ast.Visitor`
Sonic 提供了一个高级的 API 用于直接全量解析 JSON 到非标准容器里 (既不是 `struct` 也不是 `map[string]interface{}`) 且不需要借助任何中间表示 (`ast.Node` 或 `interface{}`)。举个例子,你可能定义了下述的类型,它们看起来像 `interface{}`,但实际上并不是:
```go
type UserNode interface {}
@ -318,7 +344,9 @@ type (
UserArray struct{ Value []UserNode }
)
```
Sonic 提供了下述的 API 来返回 **“对 JSON AST 的前序遍历”**。`ast.Visitor` 是一个 SAX 风格的接口,这在某些 C++ 的 JSON 解析库中被使用到。你需要自己实现一个 `ast.Visitor`,将它传递给 `ast.Preorder()` 方法。在你的实现中你可以使用自定义的类型来表示 JSON 的值。在你的 `ast.Visitor` 中,可能需要有一个 O(n) 空间复杂度的容器(比如说栈)来记录 object / array 的层级。
```go
func Preorder(str string, visitor Visitor, opts *VisitorOptions) error
@ -335,15 +363,18 @@ type Visitor interface {
OnArrayEnd() error
}
```
详细用法参看 [ast/visitor.go](https://github.com/bytedance/sonic/blob/main/ast/visitor.go),我们还为 `UserNode` 实现了一个示例 `ast.Visitor`,你可以在 [ast/visitor_test.go](https://github.com/bytedance/sonic/blob/main/ast/visitor_test.go) 中找到它。
## 兼容性
由于开发高性能代码的困难性, Sonic **不**保证对所有环境的支持。对于在不同环境中使用 Sonic 构建应用程序的开发者,我们有以下建议:
- 在 **Mac M1** 上开发:确保在您的计算机上安装了 Rosetta 2并在构建时设置 `GOARCH=amd64` 。 Rosetta 2 可以自动将 x86 二进制文件转换为 arm64 二进制文件,并在 Mac M1 上运行 x86 应用程序。
- 在 **Linux arm64** 上开发:您可以安装 qemu 并使用 `qemu-x86_64 -cpu max` 命令来将 x86 二进制文件转换为 arm64 二进制文件。qemu可以实现与Mac M1上的Rosetta 2类似的转换效果。
对于希望在不使用 qemu 下使用 sonic 的开发者,或者希望处理 JSON 时与 `encoding/JSON` 严格保持一致的开发者,我们在 `sonic.API` 中提供了一些兼容性 API
- `ConfigDefault`: 在支持 sonic 的环境下 sonic 的默认配置(`EscapeHTML=false``SortKeys=false`等)。行为与具有相应配置的 `encoding/json` 一致,一些选项,如 `SortKeys=false` 将无效。
- `ConfigStd`: 在支持 sonic 的环境下与标准库兼容的配置(`EscapeHTML=true``SortKeys=true`等)。行为与 `encoding/json` 一致。
- `ConfigFastest`: 在支持 sonic 的环境下运行最快的配置(`NoQuoteTextMarshaler=true`)。行为与具有相应配置的 `encoding/json` 一致,某些选项将无效。
@ -351,7 +382,9 @@ type Visitor interface {
## 注意事项
### 预热
由于 Sonic 使用 [golang-asm](https://github.com/twitchyliquid64/golang-asm) 作为 JIT 汇编器,这个库并不适用于运行时编译,第一次运行一个大型模式可能会导致请求超时甚至进程内存溢出。为了更好地稳定性,我们建议在运行大型模式或在内存有限的应用中,在使用 `Marshal()/Unmarshal()` 前运行 `Pretouch()`
```go
import (
"reflect"
@ -381,16 +414,17 @@ func init() {
当解码 **没有转义字符的字符串**时, sonic 会从原始的 JSON 缓冲区内引用而不是复制到新的一个缓冲区中。这对 CPU 的性能方面很有帮助,但是可能因此在解码后对象仍在使用的时候将整个 JSON 缓冲区保留在内存中。实践中我们发现,通过引用 JSON 缓冲区引入的额外内存通常是解码后对象的 20% 至 80% ,一旦应用长期保留这些对象(如缓存以备重用),服务器所使用的内存可能会增加。我们提供了选项 `decoder.CopyString()` 供用户选择,不引用 JSON 缓冲区。这可能在一定程度上降低 CPU 性能。
### 传递字符串还是字节数组?
为了和 `encoding/json` 保持一致,我们提供了传递 `[]byte` 作为参数的 API ,但考虑到安全性,字符串到字节的复制是同时进行的,这在原始 JSON 非常大时可能会导致性能损失。因此,你可以使用 `UnmarshalString()``GetFromString()` 来传递字符串,只要你的原始数据是字符串,或**零拷贝类型转换**对于你的字节数组是安全的。我们也提供了 `MarshalString()` 的 API ,以便对编码的 JSON 字节数组进行**零拷贝类型转换**,因为 sonic 输出的字节始终是重复并且唯一的,所以这样是安全的。
### 加速 `encoding.TextMarshaler`
为了保证数据安全性, `sonic.Encoder` 默认会对来自 `encoding.TextMarshaler` 接口的字符串进行引用和转义,如果大部分数据都是这种形式那可能会导致很大的性能损失。我们提供了 `encoder.NoQuoteTextMarshaler` 选项来跳过这些操作,但你**必须**保证他们的输出字符串依照 [RFC8259](https://datatracker.ietf.org/doc/html/rfc8259) 进行了转义和引用。
### 泛型的性能优化
**完全解析**的场景下, `Unmarshal()` 表现得比 `Get()`+`Node.Interface()` 更好。但是如果你只有特定 JSON 的部分模式,你可以将 `Get()``Unmarshal()` 结合使用:
```go
import "github.com/bytedance/sonic"
@ -398,7 +432,9 @@ node, err := sonic.GetFromString(_TwitterJson, "statuses", 3, "user")
var user User // your partial schema...
err = sonic.UnmarshalString(node.Raw(), &user)
```
甚至如果你没有任何模式,可以用 `ast.Node` 代替 `map``interface` 作为泛型的容器:
```go
import "github.com/bytedance/sonic"
@ -409,7 +445,9 @@ err = user.Check()
// err = user.LoadAll() // only call this when you want to use 'user' concurrently...
go someFunc(user)
```
为什么?因为 `ast.Node` 使用 `array` 来存储其子节点:
- 在插入(反序列化)和扫描(序列化)数据时,`Array` 的性能比 `Map` **好得多**
- **哈希**`map[x]`)的效率不如**索引**`array[x]`)高效,而 `ast.Node` 可以在数组和对象上使用索引;
- 使用 `Interface()` / `Map()` 意味着 sonic 必须解析所有的底层值,而 `ast.Node` 可以**按需解析**它们。
@ -417,6 +455,7 @@ go someFunc(user)
**注意**:由于 `ast.Node` 的惰性加载设计,其**不能**直接保证并发安全性,但你可以调用 `Node.Load()` / `Node.LoadAll()` 来实现并发安全。尽管可能会带来性能损失,但仍比转换成 `map``interface{}` 更为高效。
### 使用 `ast.Node` 还是 `ast.Visitor`
对于泛型数据的解析,`ast.Node` 在大多数场景上应该能够满足你的需求。
然而,`ast.Node` 是一种针对部分解析 JSON 而设计的泛型容器,它包含一些特殊设计,比如惰性加载,如果你希望像 `Unmarshal()` 那样直接解析整个 JSON这些设计可能并不合适。尽管 `ast.Node` 相较于 `map``interface{}` 来说是更好的一种泛型容器,但它毕竟也是一种中间表示,如果你的最终类型是自定义的,你还得在解析完成后将上述类型转化成你自定义的类型。

@ -20,6 +20,7 @@ import (
`io`
`github.com/bytedance/sonic/ast`
`github.com/bytedance/sonic/internal/rt`
)
// Config is a combination of sonic/encoder.Options and sonic/decoder.Options
@ -73,10 +74,13 @@ type Config struct {
// NoValidateJSONMarshaler indicates that the encoder should not validate the output string
// after encoding the JSONMarshaler to JSON.
NoValidateJSONMarshaler bool
// NoEncoderNewline indicates that the encoder should not add a newline after every message
NoEncoderNewline bool
}
var (
// ConfigDefault is the default config of APIs, aiming at efficiency and safty.
// ConfigDefault is the default config of APIs, aiming at efficiency and safety.
ConfigDefault = Config{}.Froze()
// ConfigStd is the standard config of APIs, aiming at being compatible with encoding/json.
@ -114,7 +118,7 @@ type API interface {
NewEncoder(writer io.Writer) Encoder
// NewDecoder create a Decoder holding reader
NewDecoder(reader io.Reader) Decoder
// Valid validates the JSON-encoded bytes and reportes if it is valid
// Valid validates the JSON-encoded bytes and reports if it is valid
Valid(data []byte) bool
}
@ -170,27 +174,41 @@ func UnmarshalString(buf string, val interface{}) error {
return ConfigDefault.UnmarshalFromString(buf, val)
}
// Get searches the given path from json,
// and returns its representing ast.Node.
// Get searches and locates the given path from src json,
// and returns a ast.Node representing the partially json.
//
// Each path arg must be integer or string:
// - Integer is target index(>=0), means searching current node as array.
// - String is target key, means searching current node as object.
//
//
// Note, the api expects the json is well-formed at least,
// otherwise it may return unexpected result.
// Notice: It expects the src json is **Well-formed** and **Immutable** when calling,
// otherwise it may return unexpected result.
// Considering memory safety, the returned JSON is **Copied** from the input
func Get(src []byte, path ...interface{}) (ast.Node, error) {
return GetFromString(string(src), path...)
return GetCopyFromString(rt.Mem2Str(src), path...)
}
// GetFromString is same with Get except src is string,
// which can reduce unnecessary memory copy.
// GetFromString is same with Get except src is string.
//
// WARNING: The returned JSON is **Referenced** from the input.
// Caching or long-time holding the returned node may cause OOM.
// If your src is big, consider use GetFromStringCopy().
func GetFromString(src string, path ...interface{}) (ast.Node, error) {
return ast.NewSearcher(src).GetByPath(path...)
}
// GetCopyFromString is same with Get except src is string
func GetCopyFromString(src string, path ...interface{}) (ast.Node, error) {
return ast.NewSearcher(src).GetByPathCopy(path...)
}
// Valid reports whether data is a valid JSON encoding.
func Valid(data []byte) bool {
return ConfigDefault.Valid(data)
}
// Valid reports whether data is a valid JSON encoding.
func ValidString(data string) bool {
return ConfigDefault.Valid(rt.Str2Mem(data))
}

@ -1,4 +1,4 @@
// +build amd64,go1.16,!go1.22
// +build amd64,go1.16,!go1.23 arm64,go1.20,!go1.23
/*
* Copyright 2022 ByteDance Inc.
@ -27,7 +27,6 @@ import (
`github.com/bytedance/sonic/internal/native/types`
`github.com/bytedance/sonic/internal/rt`
uq `github.com/bytedance/sonic/unquote`
`github.com/chenzhuoyu/base64x`
)
var typeByte = rt.UnpackEface(byte(0)).Type
@ -77,14 +76,6 @@ func unquote(src string) (string, types.ParsingError) {
return uq.String(src)
}
func decodeBase64(src string) ([]byte, error) {
return base64x.StdEncoding.DecodeString(src)
}
func encodeBase64(src []byte) string {
return base64x.StdEncoding.EncodeToString(src)
}
func (self *Parser) decodeValue() (val types.JsonState) {
sv := (*rt.GoString)(unsafe.Pointer(&self.s))
flag := types.F_USE_NUMBER
@ -131,27 +122,3 @@ func (self *Parser) getByPath(path ...interface{}) (int, types.ParsingError) {
}
return start, 0
}
func (self *Searcher) GetByPath(path ...interface{}) (Node, error) {
var err types.ParsingError
var start int
self.parser.p = 0
start, err = self.parser.getByPath(path...)
if err != 0 {
// for compatibility with old version
if err == types.ERR_NOT_FOUND {
return Node{}, ErrNotExist
}
if err == types.ERR_UNSUPPORT_TYPE {
panic("path must be either int(>=0) or string")
}
return Node{}, self.parser.syntaxError(err)
}
t := switchRawType(self.parser.s[start])
if t == _V_NONE {
return Node{}, self.parser.ExportError(err)
}
return newRawNode(self.parser.s[start:self.parser.p], t), nil
}

@ -1,124 +1,105 @@
// +build !amd64 !go1.16 go1.22
// +build !amd64,!arm64 go1.23 !go1.16 arm64,!go1.20
/*
* Copyright 2022 ByteDance Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Copyright 2022 ByteDance Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ast
import (
`encoding/base64`
`encoding/json`
`fmt`
`encoding/json`
`github.com/bytedance/sonic/internal/native/types`
`github.com/bytedance/sonic/internal/rt`
`github.com/bytedance/sonic/internal/native/types`
`github.com/bytedance/sonic/internal/rt`
)
func init() {
println("WARNING: sonic only supports Go1.16~1.20 && CPU amd64, but your environment is not suitable")
println("WARNING:(ast) sonic only supports Go1.16~1.22, but your environment is not suitable")
}
func quote(buf *[]byte, val string) {
quoteString(buf, val)
quoteString(buf, val)
}
func unquote(src string) (string, types.ParsingError) {
sp := rt.IndexChar(src, -1)
out, ok := unquoteBytes(rt.BytesFrom(sp, len(src)+2, len(src)+2))
if !ok {
return "", types.ERR_INVALID_ESCAPE
}
return rt.Mem2Str(out), 0
}
func decodeBase64(src string) ([]byte, error) {
return base64.StdEncoding.DecodeString(src)
sp := rt.IndexChar(src, -1)
out, ok := unquoteBytes(rt.BytesFrom(sp, len(src)+2, len(src)+2))
if !ok {
return "", types.ERR_INVALID_ESCAPE
}
return rt.Mem2Str(out), 0
}
func encodeBase64(src []byte) string {
return base64.StdEncoding.EncodeToString(src)
}
func (self *Parser) decodeValue() (val types.JsonState) {
e, v := decodeValue(self.s, self.p, self.dbuf == nil)
if e < 0 {
return v
}
self.p = e
return v
e, v := decodeValue(self.s, self.p, self.dbuf == nil)
if e < 0 {
return v
}
self.p = e
return v
}
func (self *Parser) skip() (int, types.ParsingError) {
e, s := skipValue(self.s, self.p)
if e < 0 {
return self.p, types.ParsingError(-e)
}
self.p = e
return s, 0
e, s := skipValue(self.s, self.p)
if e < 0 {
return self.p, types.ParsingError(-e)
}
self.p = e
return s, 0
}
func (self *Parser) skipFast() (int, types.ParsingError) {
e, s := skipValueFast(self.s, self.p)
if e < 0 {
return self.p, types.ParsingError(-e)
}
self.p = e
return s, 0
e, s := skipValueFast(self.s, self.p)
if e < 0 {
return self.p, types.ParsingError(-e)
}
self.p = e
return s, 0
}
func (self *Node) encodeInterface(buf *[]byte) error {
out, err := json.Marshal(self.packAny())
if err != nil {
return err
}
*buf = append(*buf, out...)
return nil
out, err := json.Marshal(self.packAny())
if err != nil {
return err
}
*buf = append(*buf, out...)
return nil
}
func (self *Searcher) GetByPath(path ...interface{}) (Node, error) {
self.parser.p = 0
var err types.ParsingError
func (self *Parser) getByPath(path ...interface{}) (int, types.ParsingError) {
for _, p := range path {
if idx, ok := p.(int); ok && idx >= 0 {
if err = self.parser.searchIndex(idx); err != 0 {
return Node{}, self.parser.ExportError(err)
if err := self.searchIndex(idx); err != 0 {
return self.p, err
}
} else if key, ok := p.(string); ok {
if err = self.parser.searchKey(key); err != 0 {
return Node{}, self.parser.ExportError(err)
if err := self.searchKey(key); err != 0 {
return self.p, err
}
} else {
panic("path must be either int(>=0) or string")
}
}
var start = self.parser.p
if start, err = self.parser.skip(); err != 0 {
return Node{}, self.parser.ExportError(err)
}
ns := len(self.parser.s)
if self.parser.p > ns || start >= ns || start>=self.parser.p {
return Node{}, fmt.Errorf("skip %d char out of json boundary", start)
start, e := self.skip()
if e != 0 {
return self.p, e
}
t := switchRawType(self.parser.s[start])
if t == _V_NONE {
return Node{}, self.parser.ExportError(err)
}
return newRawNode(self.parser.s[start:self.parser.p], t), nil
}
// t := switchRawType(self.s[start])
// if t == _V_NUMBER {
// self.p = 1 + backward(self.s, self.p-1)
// }
return start, 0
}

@ -0,0 +1,31 @@
// +build amd64,go1.16
/**
* Copyright 2023 ByteDance Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ast
import (
`github.com/chenzhuoyu/base64x`
)
func decodeBase64(src string) ([]byte, error) {
return base64x.StdEncoding.DecodeString(src)
}
func encodeBase64(src []byte) string {
return base64x.StdEncoding.EncodeToString(src)
}

@ -0,0 +1,31 @@
// +build !amd64 !go1.16
/*
* Copyright 2022 ByteDance Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ast
import (
`encoding/base64`
)
func decodeBase64(src string) ([]byte, error) {
return base64.StdEncoding.DecodeString(src)
}
func encodeBase64(src []byte) string {
return base64.StdEncoding.EncodeToString(src)
}

@ -58,29 +58,89 @@ func (self *linkedNodes) At(i int) (*Node) {
return nil
}
func (self *linkedNodes) Add(v Node) {
if self.size < _DEFAULT_NODE_CAP {
self.head[self.size] = v
self.size++
func (self *linkedNodes) MoveOne(source int, target int) {
if source == target {
return
}
if source < 0 || source >= self.size || target < 0 || target >= self.size {
return
}
// reserve source
n := *self.At(source)
if source < target {
// move every element (source,target] one step back
for i:=source; i<target; i++ {
*self.At(i) = *self.At(i+1)
}
} else {
// move every element [target,source) one step forward
for i:=source; i>target; i-- {
*self.At(i) = *self.At(i-1)
}
}
// set target
*self.At(target) = n
}
func (self *linkedNodes) Pop() {
if self == nil || self.size == 0 {
return
}
self.Set(self.size-1, Node{})
self.size--
}
func (self *linkedPairs) Pop() {
if self == nil || self.size == 0 {
return
}
self.Set(self.size-1, Pair{})
self.size--
}
func (self *linkedNodes) Push(v Node) {
self.Set(self.size, v)
}
a, b, c := self.size/_DEFAULT_NODE_CAP-1 , self.size%_DEFAULT_NODE_CAP, cap(self.tail)
if a - c >= 0 {
func (self *linkedNodes) Set(i int, v Node) {
if i < _DEFAULT_NODE_CAP {
self.head[i] = v
if self.size <= i {
self.size = i+1
}
return
}
a, b := i/_DEFAULT_NODE_CAP-1, i%_DEFAULT_NODE_CAP
if a < 0 {
self.head[b] = v
} else {
self.growTailLength(a+1)
var n = &self.tail[a]
if *n == nil {
*n = new(nodeChunk)
}
(*n)[b] = v
}
if self.size <= i {
self.size = i+1
}
}
func (self *linkedNodes) growTailLength(l int) {
if l <= len(self.tail) {
return
}
c := cap(self.tail)
for c < l {
c += 1 + c>>_APPEND_GROW_SHIFT
tmp := make([]*nodeChunk, a + 1, c)
copy(tmp, self.tail)
self.tail = tmp
} else if a >= len(self.tail) {
self.tail = self.tail[:a+1]
}
var n = &self.tail[a]
if *n == nil {
*n = new(nodeChunk)
if c == cap(self.tail) {
self.tail = self.tail[:l]
return
}
(*n)[b] = v
self.size++
tmp := make([]*nodeChunk, l, c)
copy(tmp, self.tail)
self.tail = tmp
}
func (self *linkedNodes) ToSlice(con []Node) {
@ -169,29 +229,49 @@ func (self *linkedPairs) At(i int) *Pair {
return nil
}
func (self *linkedPairs) Add(v Pair) {
if self.size < _DEFAULT_NODE_CAP {
self.head[self.size] = v
self.size++
func (self *linkedPairs) Push(v Pair) {
self.Set(self.size, v)
}
func (self *linkedPairs) Set(i int, v Pair) {
if i < _DEFAULT_NODE_CAP {
self.head[i] = v
if self.size <= i {
self.size = i+1
}
return
}
a, b := i/_DEFAULT_NODE_CAP-1, i%_DEFAULT_NODE_CAP
if a < 0 {
self.head[b] = v
} else {
self.growTailLength(a+1)
var n = &self.tail[a]
if *n == nil {
*n = new(pairChunk)
}
(*n)[b] = v
}
if self.size <= i {
self.size = i+1
}
}
a, b, c := self.size/_DEFAULT_NODE_CAP-1 , self.size%_DEFAULT_NODE_CAP, cap(self.tail)
if a - c >= 0 {
func (self *linkedPairs) growTailLength(l int) {
if l <= len(self.tail) {
return
}
c := cap(self.tail)
for c < l {
c += 1 + c>>_APPEND_GROW_SHIFT
tmp := make([]*pairChunk, a + 1, c)
copy(tmp, self.tail)
self.tail = tmp
} else if a >= len(self.tail) {
self.tail = self.tail[:a+1]
}
var n = &self.tail[a]
if *n == nil {
*n = new(pairChunk)
if c == cap(self.tail) {
self.tail = self.tail[:l]
return
}
(*n)[b] = v
self.size++
tmp := make([]*pairChunk, l, c)
copy(tmp, self.tail)
self.tail = tmp
}
// linear search
@ -271,7 +351,7 @@ func (self *linkedPairs) Swap(i, j int) {
}
func (self *linkedPairs) Sort() {
sort.Sort(self)
sort.Stable(self)
}
// Compare two strings from the pos d.

@ -193,20 +193,9 @@ func (self *Node) encodeArray(buf *[]byte) error {
*buf = append(*buf, '[')
var s = (*linkedNodes)(self.p)
var started bool
if nb > 0 {
n := s.At(0)
if n.Exists() {
if err := n.encode(buf); err != nil {
return err
}
started = true
}
}
for i := 1; i < nb; i++ {
n := s.At(i)
for i := 0; i < nb; i++ {
n := self.nodeAt(i)
if !n.Exists() {
continue
}
@ -250,21 +239,10 @@ func (self *Node) encodeObject(buf *[]byte) error {
*buf = append(*buf, '{')
var s = (*linkedPairs)(self.p)
var started bool
if nb > 0 {
n := s.At(0)
if n.Value.Exists() {
if err := n.encode(buf); err != nil {
return err
}
started = true
}
}
for i := 1; i < nb; i++ {
n := s.At(i)
if !n.Value.Exists() {
for i := 0; i < nb; i++ {
n := self.pairAt(i)
if n == nil || !n.Value.Exists() {
continue
}
if started {

@ -32,7 +32,11 @@ func (self *Node) Values() (ListIterator, error) {
if err := self.should(types.V_ARRAY, "an array"); err != nil {
return ListIterator{}, err
}
return ListIterator{Iterator{p: self}}, nil
return self.values(), nil
}
func (self *Node) values() ListIterator {
return ListIterator{Iterator{p: self}}
}
// Properties returns iterator for object's children traversal
@ -40,7 +44,11 @@ func (self *Node) Properties() (ObjectIterator, error) {
if err := self.should(types.V_OBJECT, "an object"); err != nil {
return ObjectIterator{}, err
}
return ObjectIterator{Iterator{p: self}}, nil
return self.properties(), nil
}
func (self *Node) properties() ObjectIterator {
return ObjectIterator{Iterator{p: self}}
}
type Iterator struct {
@ -114,7 +122,7 @@ next_start:
} else {
n := self.p.pairAt(self.i)
self.i++
if !n.Value.Exists() {
if n == nil || !n.Value.Exists() {
goto next_start
}
return n

@ -491,7 +491,6 @@ func (self *Node) StrictFloat64() (float64, error) {
// Len returns children count of a array|object|string node
// WARN: For partially loaded node, it also works but only counts the parsed children
// WARN: For ARRAY|OBJECT nodes which has been conducted `UnsetXX()`, its length WON'T change
func (self *Node) Len() (int, error) {
if err := self.checkRaw(); err != nil {
return 0, err
@ -534,10 +533,12 @@ func (self *Node) Set(key string, node Node) (bool, error) {
if err := node.Check(); err != nil {
return false, err
}
if self.t == _V_NONE || self.t == types.V_NULL {
*self = NewObject([]Pair{{key, node}})
return false, nil
} else if self.itype() != types.V_OBJECT {
return false, ErrUnsupportType
}
p := self.Get(key)
@ -548,7 +549,7 @@ func (self *Node) Set(key string, node Node) (bool, error) {
*self = newObject(new(linkedPairs))
}
s := (*linkedPairs)(self.p)
s.Add(Pair{key, node})
s.Push(Pair{key, node})
self.l++
return false, nil
@ -565,20 +566,22 @@ func (self *Node) SetAny(key string, val interface{}) (bool, error) {
return self.Set(key, NewAny(val))
}
// Unset RESET the node of given key under object parent, and reports if the key has existed.
// WARN: After conducting `UnsetXX()`, the node's length WON'T change
// Unset REMOVE (soft) the node of given key under object parent, and reports if the key has existed.
func (self *Node) Unset(key string) (bool, error) {
if err := self.should(types.V_OBJECT, "an object"); err != nil {
return false, err
}
// NOTICE: must get acurate length before deduct
if err := self.skipAllKey(); err != nil {
return false, err
}
p, i := self.skipKey(key)
if !p.Exists() {
return false, nil
} else if err := p.Check(); err != nil {
return false, err
}
self.removePair(i)
self.removePairAt(i)
return true, nil
}
@ -614,22 +617,28 @@ func (self *Node) SetAnyByIndex(index int, val interface{}) (bool, error) {
return self.SetByIndex(index, NewAny(val))
}
// UnsetByIndex remove the node of given index
// WARN: After conducting `UnsetXX()`, the node's length WON'T change
// UnsetByIndex REOMVE (softly) the node of given index.
//
// WARN: this will change address of elements, which is a dangerous action.
// Use Unset() for object or Pop() for array instead.
func (self *Node) UnsetByIndex(index int) (bool, error) {
if err := self.Check(); err != nil {
if err := self.checkRaw(); err != nil {
return false, err
}
var p *Node
it := self.itype()
if it == types.V_ARRAY {
p = self.Index(index)
}else if it == types.V_OBJECT {
if err := self.checkRaw(); err != nil {
if err := self.skipAllIndex(); err != nil {
return false, err
}
pr := self.skipIndexPair(index)
p = self.nodeAt(index)
} else if it == types.V_OBJECT {
if err := self.skipAllKey(); err != nil {
return false, err
}
pr := self.pairAt(index)
if pr == nil {
return false, ErrNotExist
}
@ -642,6 +651,12 @@ func (self *Node) UnsetByIndex(index int) (bool, error) {
return false, ErrNotExist
}
// last elem
if index == self.len() - 1 {
return true, self.Pop()
}
// not last elem, self.len() change but linked-chunk not change
if it == types.V_ARRAY {
self.removeNode(index)
}else if it == types.V_OBJECT {
@ -665,16 +680,101 @@ func (self *Node) Add(node Node) error {
if err := self.should(types.V_ARRAY, "an array"); err != nil {
return err
}
s, err := self.unsafeArray()
if err != nil {
return err
}
s.Add(node)
// Notice: array won't have unset node in tail
s.Push(node)
self.l++
return nil
}
// Pop remove the last child of the V_Array or V_Object node.
func (self *Node) Pop() error {
if err := self.checkRaw(); err != nil {
return err
}
if it := self.itype(); it == types.V_ARRAY {
s, err := self.unsafeArray()
if err != nil {
return err
}
// remove tail unset nodes
for i := s.Len()-1; i >= 0; i-- {
if s.At(i).Exists() {
s.Pop()
self.l--
break
}
s.Pop()
}
} else if it == types.V_OBJECT {
s, err := self.unsafeMap()
if err != nil {
return err
}
// remove tail unset nodes
for i := s.Len()-1; i >= 0; i-- {
if p := s.At(i); p != nil && p.Value.Exists() {
s.Pop()
self.l--
break
}
s.Pop()
}
} else {
return ErrUnsupportType
}
return nil
}
// Move moves the child at src index to dst index,
// meanwhile slides sliblings from src+1 to dst.
//
// WARN: this will change address of elements, which is a dangerous action.
func (self *Node) Move(dst, src int) error {
if err := self.should(types.V_ARRAY, "an array"); err != nil {
return err
}
s, err := self.unsafeArray()
if err != nil {
return err
}
// check if any unset node exists
if l := s.Len(); self.len() != l {
di, si := dst, src
// find real pos of src and dst
for i := 0; i < l; i++ {
if s.At(i).Exists() {
di--
si--
}
if di == -1 {
dst = i
di--
}
if si == -1 {
src = i
si--
}
if di == -2 && si == -2 {
break
}
}
}
s.MoveOne(src, dst)
return nil
}
// SetAny wraps val with V_ANY node, and Add() the node.
func (self *Node) AddAny(val interface{}) error {
@ -721,8 +821,6 @@ func (self *Node) Get(key string) *Node {
// Index indexies node at given idx,
// node type CAN be either V_OBJECT or V_ARRAY
// WARN: After conducting `UnsetXX()`, the node's length WON'T change,
// thus its children's indexing WON'T change too
func (self *Node) Index(idx int) *Node {
if err := self.checkRaw(); err != nil {
return unwrapError(err)
@ -746,8 +844,6 @@ func (self *Node) Index(idx int) *Node {
// IndexPair indexies pair at given idx,
// node type MUST be either V_OBJECT
// WARN: After conducting `UnsetXX()`, the node's length WON'T change,
// thus its children's indexing WON'T change too
func (self *Node) IndexPair(idx int) *Pair {
if err := self.should(types.V_OBJECT, "an object"); err != nil {
return nil
@ -755,19 +851,30 @@ func (self *Node) IndexPair(idx int) *Pair {
return self.skipIndexPair(idx)
}
func (self *Node) indexOrGet(idx int, key string) (*Node, int) {
if err := self.should(types.V_OBJECT, "an object"); err != nil {
return unwrapError(err), idx
}
pr := self.skipIndexPair(idx)
if pr != nil && pr.Key == key {
return &pr.Value, idx
}
return self.skipKey(key)
}
// IndexOrGet firstly use idx to index a value and check if its key matches
// If not, then use the key to search value
func (self *Node) IndexOrGet(idx int, key string) *Node {
if err := self.should(types.V_OBJECT, "an object"); err != nil {
return unwrapError(err)
}
node, _ := self.indexOrGet(idx, key)
return node
}
pr := self.skipIndexPair(idx)
if pr != nil && pr.Key == key {
return &pr.Value
}
n, _ := self.skipKey(key)
return n
// IndexOrGetWithIdx attempts to retrieve a node by index and key, returning the node and its correct index.
// If the key does not match at the given index, it searches by key and returns the node with its updated index.
func (self *Node) IndexOrGetWithIdx(idx int, key string) (*Node, int) {
return self.indexOrGet(idx, key)
}
/** Generic Value Converters **/
@ -864,7 +971,7 @@ func (self *Node) SortKeys(recurse bool) error {
}
if self.itype() == types.V_OBJECT {
return self.sortKeys(recurse)
} else {
} else if self.itype() == types.V_ARRAY {
var err error
err2 := self.ForEach(func(path Sequence, node *Node) bool {
it := node.itype()
@ -880,10 +987,16 @@ func (self *Node) SortKeys(recurse bool) error {
return err
}
return err2
} else {
return nil
}
}
func (self *Node) sortKeys(recurse bool) (err error) {
// check raw node first
if err := self.checkRaw(); err != nil {
return err
}
ps, err := self.unsafeMap()
if err != nil {
return err
@ -1172,6 +1285,19 @@ func (self *Node) nodeAt(i int) *Node {
p = &stack.v
} else {
p = (*linkedNodes)(self.p)
if l := p.Len(); l != self.len() {
// some nodes got unset, iterate to skip them
for j:=0; j<l; j++ {
v := p.At(j)
if v.Exists() {
i--
}
if i < 0 {
return v
}
}
return nil
}
}
return p.At(i)
}
@ -1183,6 +1309,19 @@ func (self *Node) pairAt(i int) *Pair {
p = &stack.v
} else {
p = (*linkedPairs)(self.p)
if l := p.Len(); l != self.len() {
// some nodes got unset, iterate to skip them
for j:=0; j<l; j++ {
v := p.At(j)
if v != nil && v.Value.Exists() {
i--
}
if i < 0 {
return v
}
}
return nil
}
}
return p.At(i)
}
@ -1334,8 +1473,8 @@ func (self *Node) removeNode(i int) {
return
}
*node = Node{}
// NOTICE: for consistency with linkedNodes, we DOSEN'T reduce size here
// self.l--
// NOTICE: not be consistent with linkedNode.Len()
self.l--
}
func (self *Node) removePair(i int) {
@ -1344,8 +1483,18 @@ func (self *Node) removePair(i int) {
return
}
*last = Pair{}
// NOTICE: for consistency with linkedNodes, we DOSEN'T reduce size here
// self.l--
// NOTICE: should be consistent with linkedPair.Len()
self.l--
}
func (self *Node) removePairAt(i int) {
p := (*linkedPairs)(self.p).At(i)
if p == nil {
return
}
*p = Pair{}
// NOTICE: should be consistent with linkedPair.Len()
self.l--
}
func (self *Node) toGenericArray() ([]interface{}, error) {
@ -1353,17 +1502,16 @@ func (self *Node) toGenericArray() ([]interface{}, error) {
if nb == 0 {
return []interface{}{}, nil
}
ret := make([]interface{}, nb)
ret := make([]interface{}, 0, nb)
/* convert each item */
var s = (*linkedNodes)(self.p)
for i := 0; i < nb; i++ {
p := s.At(i)
x, err := p.Interface()
it := self.values()
for v := it.next(); v != nil; v = it.next() {
vv, err := v.Interface()
if err != nil {
return nil, err
}
ret[i] = x
ret = append(ret, vv)
}
/* all done */
@ -1375,17 +1523,16 @@ func (self *Node) toGenericArrayUseNumber() ([]interface{}, error) {
if nb == 0 {
return []interface{}{}, nil
}
ret := make([]interface{}, nb)
ret := make([]interface{}, 0, nb)
/* convert each item */
var s = (*linkedNodes)(self.p)
for i := 0; i < nb; i++ {
p := s.At(i)
x, err := p.InterfaceUseNumber()
it := self.values()
for v := it.next(); v != nil; v = it.next() {
vv, err := v.InterfaceUseNumber()
if err != nil {
return nil, err
}
ret[i] = x
ret = append(ret, vv)
}
/* all done */
@ -1413,14 +1560,13 @@ func (self *Node) toGenericObject() (map[string]interface{}, error) {
ret := make(map[string]interface{}, nb)
/* convert each item */
var s = (*linkedPairs)(self.p)
for i := 0; i < nb; i++ {
p := s.At(i)
x, err := p.Value.Interface()
it := self.properties()
for v := it.next(); v != nil; v = it.next() {
vv, err := v.Value.Interface()
if err != nil {
return nil, err
}
ret[p.Key] = x
ret[v.Key] = vv
}
/* all done */
@ -1436,14 +1582,13 @@ func (self *Node) toGenericObjectUseNumber() (map[string]interface{}, error) {
ret := make(map[string]interface{}, nb)
/* convert each item */
var s = (*linkedPairs)(self.p)
for i := 0; i < nb; i++ {
p := s.At(i)
x, err := p.Value.InterfaceUseNumber()
it := self.properties()
for v := it.next(); v != nil; v = it.next() {
vv, err := v.Value.InterfaceUseNumber()
if err != nil {
return nil, err
}
ret[p.Key] = x
ret[v.Key] = vv
}
/* all done */

@ -157,7 +157,7 @@ func (self *Parser) decodeArray(ret *linkedNodes) (Node, types.ParsingError) {
}
/* add the value to result */
ret.Add(val)
ret.Push(val)
self.p = self.lspace(self.p)
/* check for EOF */
@ -244,7 +244,7 @@ func (self *Parser) decodeObject(ret *linkedPairs) (Node, types.ParsingError) {
/* add the value to result */
// FIXME: ret's address may change here, thus previous referred node in ret may be invalid !!
ret.Add(Pair{Key: key, Value: val})
ret.Push(Pair{Key: key, Value: val})
self.p = self.lspace(self.p)
/* check for EOF */
@ -475,7 +475,7 @@ func (self *Node) skipNextNode() *Node {
}
/* add the value to result */
ret.Add(val)
ret.Push(val)
self.l++
parser.p = parser.lspace(parser.p)
@ -558,7 +558,7 @@ func (self *Node) skipNextPair() (*Pair) {
}
/* add the value to result */
ret.Add(Pair{Key: key, Value: val})
ret.Push(Pair{Key: key, Value: val})
self.l++
parser.p = parser.lspace(parser.p)

@ -16,6 +16,11 @@
package ast
import (
`github.com/bytedance/sonic/internal/rt`
`github.com/bytedance/sonic/internal/native/types`
)
type Searcher struct {
parser Parser
}
@ -28,3 +33,48 @@ func NewSearcher(str string) *Searcher {
},
}
}
// GetByPathCopy search in depth from top json and returns a **Copied** json node at the path location
func (self *Searcher) GetByPathCopy(path ...interface{}) (Node, error) {
return self.getByPath(true, path...)
}
// GetByPathNoCopy search in depth from top json and returns a **Referenced** json node at the path location
//
// WARN: this search directly refer partial json from top json, which has faster speed,
// may consumes more memory.
func (self *Searcher) GetByPath(path ...interface{}) (Node, error) {
return self.getByPath(false, path...)
}
func (self *Searcher) getByPath(copystring bool, path ...interface{}) (Node, error) {
var err types.ParsingError
var start int
self.parser.p = 0
start, err = self.parser.getByPath(path...)
if err != 0 {
// for compatibility with old version
if err == types.ERR_NOT_FOUND {
return Node{}, ErrNotExist
}
if err == types.ERR_UNSUPPORT_TYPE {
panic("path must be either int(>=0) or string")
}
return Node{}, self.parser.syntaxError(err)
}
t := switchRawType(self.parser.s[start])
if t == _V_NONE {
return Node{}, self.parser.ExportError(err)
}
// copy string to reducing memory usage
var raw string
if copystring {
raw = rt.Mem2Str([]byte(self.parser.s[start:self.parser.p]))
} else {
raw = self.parser.s[start:self.parser.p]
}
return newRawNode(raw, t), nil
}

@ -25,7 +25,7 @@ import (
// Visitor handles the callbacks during preorder traversal of a JSON AST.
//
// According to the JSON RFC8259, a JSON AST can be defined by
// the following rules without seperator / whitespace tokens.
// the following rules without separator / whitespace tokens.
//
// JSON-AST = value
// value = false / null / true / object / array / number / string

@ -1,4 +1,4 @@
// +build !amd64 !go1.16 go1.22
// +build !amd64 !go1.16 go1.23
/*
* Copyright 2021 ByteDance Inc.

@ -1,4 +1,4 @@
// +build amd64,go1.16,!go1.22
// +build amd64,go1.16,!go1.23
/*
* Copyright 2023 ByteDance Inc.

@ -1,4 +1,4 @@
// +build !amd64 !go1.16 go1.22
// +build !amd64 !go1.16 go1.23
/*
* Copyright 2023 ByteDance Inc.
@ -30,7 +30,7 @@ import (
)
func init() {
println("WARNING: sonic only supports Go1.16~1.20 && CPU amd64, but your environment is not suitable")
println("WARNING: sonic only supports Go1.16~1.22 && CPU amd64, but your environment is not suitable")
}
const (

@ -1,4 +1,4 @@
// +build amd64,go1.16,!go1.22
// +build amd64,go1.16,!go1.23
/*
* Copyright 2023 ByteDance Inc.
@ -63,6 +63,9 @@ const (
// after encoding the JSONMarshaler to JSON.
NoValidateJSONMarshaler Options = encoder.NoValidateJSONMarshaler
// NoEncoderNewline indicates that the encoder should not add a newline after every message
NoEncoderNewline Options = encoder.NoEncoderNewline
// CompatibleWithStd is used to be compatible with std encoder.
CompatibleWithStd Options = encoder.CompatibleWithStd
)

@ -1,4 +1,4 @@
// +build !amd64 !go1.16 go1.22
// +build !amd64 !go1.16 go1.23
/*
* Copyright 2023 ByteDance Inc.
@ -28,7 +28,7 @@ import (
)
func init() {
println("WARNING: sonic only supports Go1.16~1.20 && CPU amd64, but your environment is not suitable")
println("WARNING: sonic only supports Go1.16~1.22 && CPU amd64, but your environment is not suitable")
}
// Options is a set of encoding options.
@ -42,6 +42,7 @@ const (
bitNoNullSliceOrMap
bitValidateString
bitNoValidateJSONMarshaler
bitNoEncoderNewline
// used for recursive compile
bitPointerValue = 63
@ -77,6 +78,9 @@ const (
// NoValidateJSONMarshaler indicates that the encoder should not validate the output string
// after encoding the JSONMarshaler to JSON.
NoValidateJSONMarshaler Options = 1 << bitNoValidateJSONMarshaler
// NoEncoderNewline indicates that the encoder should not add a newline after every message
NoEncoderNewline Options = 1 << bitNoEncoderNewline
// CompatibleWithStd is used to be compatible with std encoder.
CompatibleWithStd Options = SortMapKeys | EscapeHTML | CompactMarshaler
@ -130,6 +134,15 @@ func (self *Encoder) SetNoValidateJSONMarshaler(f bool) {
}
}
// SetNoEncoderNewline specifies if option NoEncoderNewline opens
func (self *Encoder) SetNoEncoderNewline(f bool) {
if f {
self.Opts |= NoEncoderNewline
} else {
self.Opts &= ^NoEncoderNewline
}
}
// SetCompactMarshaler specifies if option CompactMarshaler opens
func (self *Encoder) SetCompactMarshaler(f bool) {
if f {

@ -1,4 +1,4 @@
// +build go1.21,!go1.22
// +build go1.21,!go1.23
// Copyright 2023 CloudWeGo Authors
//

@ -1,5 +1,4 @@
//go:build go1.17 && !go1.22
// +build go1.17,!go1.22
// +build go1.17,!go1.23
/*
* Copyright 2021 ByteDance Inc.

@ -1,4 +1,4 @@
// +build go1.17,!go1.22
// +build go1.17,!go1.23
/*
* Copyright 2021 ByteDance Inc.

@ -1,4 +1,4 @@
// +build go1.17,!go1.22
// +build go1.17,!go1.23
//
// Copyright 2021 ByteDance Inc.

@ -23,11 +23,12 @@ import (
`github.com/bytedance/sonic/internal/native`
`github.com/bytedance/sonic/internal/native/types`
`github.com/bytedance/sonic/internal/rt`
`github.com/bytedance/sonic/option`
)
var (
minLeftBufferShift uint = 1
minLeftBufferShift uint = 1
)
// StreamDecoder is the decoder context object for streaming input.
@ -58,95 +59,71 @@ func NewStreamDecoder(r io.Reader) *StreamDecoder {
// Either io error from underlying io.Reader (except io.EOF)
// or syntax error from data will be recorded and stop subsequently decoding.
func (self *StreamDecoder) Decode(val interface{}) (err error) {
if self.err != nil {
return self.err
}
var buf = self.buf[self.scanp:]
var p = 0
var recycle bool
if cap(buf) == 0 {
buf = bufPool.Get().([]byte)
recycle = true
}
var first = true
var repeat = true
read_more:
for {
l := len(buf)
realloc(&buf)
n, err := self.r.Read(buf[l:cap(buf)])
buf = buf[:l+n]
if err != nil {
repeat = false
if err == io.EOF {
if len(buf) == 0 {
return err
}
break
}
self.err = err
return err
}
if n > 0 || first {
break
}
}
first = false
l := len(buf)
if l > 0 {
self.Decoder.Reset(string(buf))
var x int
if ret := native.SkipOneFast(&self.s, &x); ret < 0 {
if repeat {
goto read_more
// read more data into buf
if self.More() {
// println(string(self.buf))
var s = self.scanp
try_skip:
var e = len(self.buf)
// println("s:", s, "e:", e, "scanned:",self.scanned, "scanp:",self.scanp, self.buf)
var src = rt.Mem2Str(self.buf[s:e])
// if len(src) > 5 {
// println(src[:5], src[len(src)-5:])
// } else {
// println(src)
// }
// try skip
var x = 0;
if y := native.SkipOneFast(&src, &x); y < 0 {
if self.readMore() {
// println("more")
goto try_skip
} else {
err = SyntaxError{x, self.s, types.ParsingError(-ret), ""}
self.err = err
// println("no more")
err = SyntaxError{e, self.s, types.ParsingError(-s), ""}
self.setErr(err)
return
}
} else {
s = y + s
e = x + s
}
// println("decode: ", s, e)
// must copy string here for safety
self.Decoder.Reset(string(self.buf[s:e]))
err = self.Decoder.Decode(val)
if err != nil {
self.err = err
self.setErr(err)
return
}
p = self.Decoder.Pos()
self.scanned += int64(p)
self.scanp = 0
}
if l > p {
// remain undecoded bytes, so copy them into self.buf
self.buf = append(self.buf[:0], buf[p:]...)
} else {
self.buf = nil
recycle = true
}
self.scanp = e
_, empty := self.scan()
if empty {
// println("recycle")
// no remain valid bytes, thus we just recycle buffer
mem := self.buf
self.buf = nil
bufPool.Put(mem[:0])
} else {
// println("keep")
// remain undecoded bytes, move them onto head
n := copy(self.buf, self.buf[self.scanp:])
self.buf = self.buf[:n]
}
if recycle {
buf = buf[:0]
bufPool.Put(buf)
}
return err
}
self.scanned += int64(self.scanp)
self.scanp = 0
}
func (self StreamDecoder) repeatable(err error) bool {
if ee, ok := err.(SyntaxError); ok &&
(ee.Code == types.ERR_EOF || (ee.Code == types.ERR_INVALID_CHAR && self.i >= len(self.s)-1)) {
return true
}
return false
return self.err
}
// InputOffset returns the input stream byte offset of the current decoder position.
// The offset gives the location of the end of the most recently returned token and the beginning of the next token.
func (self *StreamDecoder) InputOffset() int64 {
// println("input offset",self.scanned, self.scanp)
return self.scanned + int64(self.scanp)
}
@ -166,28 +143,72 @@ func (self *StreamDecoder) More() bool {
return err == nil && c != ']' && c != '}'
}
// More reports whether there is another element in the
// current array or object being parsed.
func (self *StreamDecoder) readMore() bool {
if self.err != nil {
return false
}
var err error
var n int
for {
// Grow buffer if not large enough.
l := len(self.buf)
realloc(&self.buf)
n, err = self.r.Read(self.buf[l:cap(self.buf)])
self.buf = self.buf[: l+n]
self.scanp = l
_, empty := self.scan()
if !empty {
return true
}
// buffer has been scanned, now report any error
if err != nil {
self.setErr(err)
return false
}
}
}
func (self *StreamDecoder) setErr(err error) {
self.err = err
mem := self.buf[:0]
self.buf = nil
bufPool.Put(mem)
}
func (self *StreamDecoder) peek() (byte, error) {
var err error
for {
for i := self.scanp; i < len(self.buf); i++ {
c := self.buf[i]
if isSpace(c) {
continue
}
self.scanp = i
return c, nil
c, empty := self.scan()
if !empty {
return byte(c), nil
}
// buffer has been scanned, now report any error
if err != nil {
if err != io.EOF {
self.err = err
}
self.setErr(err)
return 0, err
}
err = self.refill()
}
}
func (self *StreamDecoder) scan() (byte, bool) {
for i := self.scanp; i < len(self.buf); i++ {
c := self.buf[i]
if isSpace(c) {
continue
}
self.scanp = i
return c, false
}
return 0, true
}
func isSpace(c byte) bool {
return types.SPACE_MASK & (1 << c) != 0
}
@ -212,17 +233,25 @@ func (self *StreamDecoder) refill() error {
return err
}
func realloc(buf *[]byte) {
func realloc(buf *[]byte) bool {
l := uint(len(*buf))
c := uint(cap(*buf))
if c == 0 {
// println("use pool!")
*buf = bufPool.Get().([]byte)
return true
}
if c - l <= c >> minLeftBufferShift {
// println("realloc!")
e := l+(l>>minLeftBufferShift)
if e < option.DefaultDecoderBufferSize {
e = option.DefaultDecoderBufferSize
if e <= c {
e = c*2
}
tmp := make([]byte, l, e)
copy(tmp, *buf)
*buf = tmp
return true
}
return false
}

@ -1,4 +1,4 @@
// +build go1.21,!go1.22
// +build go1.21,!go1.23
// Copyright 2023 CloudWeGo Authors
//

@ -1,5 +1,4 @@
//go:build go1.17 && !go1.22
// +build go1.17,!go1.22
// +build go1.17,!go1.23
/*
* Copyright 2021 ByteDance Inc.

@ -831,7 +831,7 @@ func (self *_Compiler) compileStructFieldZero(p *_Program, vt reflect.Type) {
case reflect.Float32 : p.add(_OP_is_zero_4)
case reflect.Float64 : p.add(_OP_is_zero_8)
case reflect.String : p.add(_OP_is_nil_p1)
case reflect.Interface : p.add(_OP_is_nil_p1)
case reflect.Interface : p.add(_OP_is_nil)
case reflect.Map : p.add(_OP_is_zero_map)
case reflect.Ptr : p.add(_OP_is_nil)
case reflect.Slice : p.add(_OP_is_nil_p1)

@ -1,4 +1,4 @@
// +build go1.17,!go1.22
// +build go1.17,!go1.23
/*
* Copyright 2021 ByteDance Inc.

@ -41,6 +41,7 @@ const (
bitNoNullSliceOrMap
bitValidateString
bitNoValidateJSONMarshaler
bitNoEncoderNewline
// used for recursive compile
bitPointerValue = 63
@ -76,6 +77,9 @@ const (
// NoValidateJSONMarshaler indicates that the encoder should not validate the output string
// after encoding the JSONMarshaler to JSON.
NoValidateJSONMarshaler Options = 1 << bitNoValidateJSONMarshaler
// NoEncoderNewline indicates that the encoder should not add a newline after every message
NoEncoderNewline Options = 1 << bitNoEncoderNewline
// CompatibleWithStd is used to be compatible with std encoder.
CompatibleWithStd Options = SortMapKeys | EscapeHTML | CompactMarshaler
@ -129,6 +133,16 @@ func (self *Encoder) SetNoValidateJSONMarshaler(f bool) {
}
}
// SetNoEncoderNewline specifies if option NoEncoderNewline opens
func (self *Encoder) SetNoEncoderNewline(f bool) {
if f {
self.Opts |= NoEncoderNewline
} else {
self.Opts &= ^NoEncoderNewline
}
}
// SetCompactMarshaler specifies if option CompactMarshaler opens
func (self *Encoder) SetCompactMarshaler(f bool) {
if f {

@ -154,17 +154,17 @@ var (
)
var (
_F_assertI2I = jit.Func(assertI2I)
_F_assertI2I = jit.Func(rt.AssertI2I2)
)
func asText(v unsafe.Pointer) (string, error) {
text := assertI2I(_T_encoding_TextMarshaler, *(*rt.GoIface)(v))
text := rt.AssertI2I2(_T_encoding_TextMarshaler, *(*rt.GoIface)(v))
r, e := (*(*encoding.TextMarshaler)(unsafe.Pointer(&text))).MarshalText()
return rt.Mem2Str(r), e
}
func asJson(v unsafe.Pointer) (string, error) {
text := assertI2I(_T_json_Marshaler, *(*rt.GoIface)(v))
text := rt.AssertI2I2(_T_json_Marshaler, *(*rt.GoIface)(v))
r, e := (*(*json.Marshaler)(unsafe.Pointer(&text))).MarshalJSON()
return rt.Mem2Str(r), e
}

@ -36,7 +36,8 @@ func NewStreamEncoder(w io.Writer) *StreamEncoder {
// Encode encodes interface{} as JSON to io.Writer
func (enc *StreamEncoder) Encode(val interface{}) (err error) {
out := newBytes()
buf := newBytes()
out := buf
/* encode into the buffer */
err = EncodeInto(&out, val, enc.Opts)
@ -54,7 +55,9 @@ func (enc *StreamEncoder) Encode(val interface{}) (err error) {
}
// according to standard library, terminate each value with a newline...
buf.WriteByte('\n')
if enc.Opts & NoEncoderNewline == 0 {
buf.WriteByte('\n')
}
/* copy into io.Writer */
_, err = io.Copy(enc.w, buf)
@ -75,10 +78,12 @@ func (enc *StreamEncoder) Encode(val interface{}) (err error) {
}
// according to standard library, terminate each value with a newline...
enc.w.Write([]byte{'\n'})
if enc.Opts & NoEncoderNewline == 0 {
enc.w.Write([]byte{'\n'})
}
}
free_bytes:
freeBytes(out)
freeBytes(buf)
return err
}

@ -38,10 +38,6 @@ func memmove(to unsafe.Pointer, from unsafe.Pointer, n uintptr)
//goland:noinspection GoUnusedParameter
func growslice(et *rt.GoType, old rt.GoSlice, cap int) rt.GoSlice
//go:linkname assertI2I runtime.assertI2I
//goland:noinspection GoUnusedParameter
func assertI2I(inter *rt.GoType, i rt.GoIface) rt.GoIface
//go:linkname mapiternext runtime.mapiternext
//goland:noinspection GoUnusedParameter
func mapiternext(it *rt.GoMapIterator)

@ -38,10 +38,6 @@ func memmove(to unsafe.Pointer, from unsafe.Pointer, n uintptr)
//goland:noinspection GoUnusedParameter
func growslice(et *rt.GoType, old rt.GoSlice, cap int) rt.GoSlice
//go:linkname assertI2I runtime.assertI2I2
//goland:noinspection GoUnusedParameter
func assertI2I(inter *rt.GoType, i rt.GoIface) rt.GoIface
//go:linkname mapiternext runtime.mapiternext
//goland:noinspection GoUnusedParameter
func mapiternext(it *rt.GoMapIterator)

@ -38,10 +38,6 @@ func memmove(to unsafe.Pointer, from unsafe.Pointer, n uintptr)
//goland:noinspection GoUnusedParameter
func growslice(et *rt.GoType, old rt.GoSlice, cap int) rt.GoSlice
//go:linkname assertI2I runtime.assertI2I2
//goland:noinspection GoUnusedParameter
func assertI2I(inter *rt.GoType, i rt.GoIface) rt.GoIface
//go:linkname mapiternext runtime.mapiternext
//goland:noinspection GoUnusedParameter
func mapiternext(it *rt.GoMapIterator)

@ -38,10 +38,6 @@ func memmove(to unsafe.Pointer, from unsafe.Pointer, n uintptr)
//goland:noinspection GoUnusedParameter
func growslice(et *rt.GoType, old rt.GoSlice, cap int) rt.GoSlice
//go:linkname assertI2I runtime.assertI2I2
//goland:noinspection GoUnusedParameter
func assertI2I(inter *rt.GoType, i rt.GoIface) rt.GoIface
//go:linkname mapiternext runtime.mapiternext
//goland:noinspection GoUnusedParameter
func mapiternext(it *rt.GoMapIterator)

@ -24,11 +24,6 @@ import (
`github.com/twitchyliquid64/golang-asm/obj`
)
//go:noescape
//go:linkname getitab runtime.getitab
//goland:noinspection ALL
func getitab(inter *rt.GoType, typ *rt.GoType, canfail bool) *rt.GoItab
func Func(f interface{}) obj.Addr {
if p := rt.UnpackEface(f); p.Type.Kind() != reflect.Func {
panic("f is not a function")
@ -42,7 +37,7 @@ func Type(t reflect.Type) obj.Addr {
}
func Itab(i *rt.GoType, t reflect.Type) obj.Addr {
return Imm(int64(uintptr(unsafe.Pointer(getitab(i, rt.UnpackType(t), false)))))
return Imm(int64(uintptr(unsafe.Pointer(rt.Getitab(rt.IfaceType(i), rt.UnpackType(t), false)))))
}
func Gitab(i *rt.GoItab) obj.Addr {

@ -1,3 +1,6 @@
// +build amd64
// Code generated by Makefile, DO NOT EDIT.
// Code generated by Makefile, DO NOT EDIT.
@ -71,8 +74,6 @@ var (
__validate_utf8 func(s unsafe.Pointer, p unsafe.Pointer, m unsafe.Pointer) (ret int)
__validate_utf8_fast func(s unsafe.Pointer) (ret int)
__fsm_exec func(m unsafe.Pointer, s unsafe.Pointer, p unsafe.Pointer, flags uint64) (ret int)
)
//go:nosplit
@ -185,7 +186,3 @@ func validate_utf8_fast(s *string) (ret int) {
return __validate_utf8_fast(rt.NoEscape(unsafe.Pointer(s)))
}
//go:nosplit
func fsm_exec(m *types.StateMachine, s *string, p *int, flags uint64) (ret int) {
return __fsm_exec(rt.NoEscape(unsafe.Pointer(m)), rt.NoEscape(unsafe.Pointer(s)), rt.NoEscape(unsafe.Pointer(p)), flags)
}

@ -8,117 +8,111 @@ import (
)
const (
_entry__f32toa = 31024
_entry__f64toa = 176
_entry__format_significand = 35808
_entry__format_integer = 3424
_entry__fsm_exec = 18816
_entry__advance_string = 15056
_entry__advance_string_default = 37344
_entry__do_skip_number = 21376
_entry__get_by_path = 26416
_entry__skip_one_fast = 22880
_entry__unescape = 38256
_entry__unhex16_is = 9632
_entry__html_escape = 9824
_entry__i64toa = 3856
_entry__u64toa = 4128
_entry__f32toa = 31168
_entry__f64toa = 192
_entry__format_significand = 35344
_entry__format_integer = 3040
_entry__get_by_path = 25696
_entry__fsm_exec = 17920
_entry__advance_string = 14320
_entry__advance_string_default = 36736
_entry__do_skip_number = 20528
_entry__skip_one_fast = 22176
_entry__html_escape = 8912
_entry__i64toa = 3472
_entry__u64toa = 3584
_entry__lspace = 16
_entry__quote = 5552
_entry__skip_array = 18768
_entry__skip_number = 22464
_entry__skip_object = 21008
_entry__skip_one = 22640
_entry__unquote = 7296
_entry__validate_one = 22704
_entry__validate_utf8 = 29728
_entry__validate_utf8_fast = 30416
_entry__value = 13104
_entry__vnumber = 16368
_entry__atof_eisel_lemire64 = 11104
_entry__atof_native = 12496
_entry__decimal_to_f64 = 11504
_entry__left_shift = 36288
_entry__right_shift = 36832
_entry__vsigned = 18016
_entry__vstring = 14880
_entry__vunsigned = 18384
_entry__quote = 4864
_entry__skip_array = 17872
_entry__skip_number = 21792
_entry__skip_object = 20160
_entry__skip_one = 21952
_entry__unquote = 6576
_entry__validate_one = 22000
_entry__validate_utf8 = 29904
_entry__validate_utf8_fast = 30576
_entry__value = 12320
_entry__vnumber = 15648
_entry__atof_eisel_lemire64 = 10160
_entry__atof_native = 11712
_entry__decimal_to_f64 = 10528
_entry__right_shift = 36304
_entry__left_shift = 35808
_entry__vsigned = 17200
_entry__vstring = 14144
_entry__vunsigned = 17520
)
const (
_stack__f32toa = 64
_stack__f32toa = 48
_stack__f64toa = 80
_stack__format_significand = 24
_stack__format_integer = 16
_stack__fsm_exec = 160
_stack__advance_string = 72
_stack__advance_string_default = 56
_stack__do_skip_number = 32
_stack__get_by_path = 280
_stack__fsm_exec = 168
_stack__advance_string = 64
_stack__advance_string_default = 64
_stack__do_skip_number = 48
_stack__skip_one_fast = 176
_stack__unescape = 64
_stack__unhex16_is = 8
_stack__html_escape = 64
_stack__html_escape = 72
_stack__i64toa = 16
_stack__u64toa = 8
_stack__lspace = 8
_stack__quote = 80
_stack__skip_array = 168
_stack__skip_number = 88
_stack__skip_object = 168
_stack__skip_one = 168
_stack__unquote = 112
_stack__validate_one = 168
_stack__quote = 56
_stack__skip_array = 176
_stack__skip_number = 104
_stack__skip_object = 176
_stack__skip_one = 176
_stack__unquote = 88
_stack__validate_one = 176
_stack__validate_utf8 = 48
_stack__validate_utf8_fast = 24
_stack__value = 352
_stack__vnumber = 264
_stack__atof_eisel_lemire64 = 40
_stack__atof_native = 144
_stack__decimal_to_f64 = 88
_stack__left_shift = 32
_stack__right_shift = 16
_stack__value = 328
_stack__vnumber = 240
_stack__atof_eisel_lemire64 = 32
_stack__atof_native = 136
_stack__decimal_to_f64 = 80
_stack__right_shift = 8
_stack__left_shift = 24
_stack__vsigned = 16
_stack__vstring = 128
_stack__vunsigned = 24
_stack__vstring = 120
_stack__vunsigned = 8
)
const (
_size__f32toa = 3792
_size__f64toa = 3248
_size__format_significand = 480
_size__f32toa = 3392
_size__f64toa = 2848
_size__format_significand = 464
_size__format_integer = 432
_size__fsm_exec = 1656
_size__advance_string = 1264
_size__advance_string_default = 912
_size__do_skip_number = 876
_size__get_by_path = 3312
_size__get_by_path = 4208
_size__fsm_exec = 1692
_size__advance_string = 1280
_size__advance_string_default = 944
_size__do_skip_number = 924
_size__skip_one_fast = 3016
_size__unescape = 704
_size__unhex16_is = 128
_size__html_escape = 1280
_size__i64toa = 272
_size__u64toa = 1376
_size__lspace = 112
_size__quote = 1728
_size__html_escape = 1248
_size__i64toa = 48
_size__u64toa = 1232
_size__lspace = 144
_size__quote = 1696
_size__skip_array = 48
_size__skip_number = 160
_size__skip_object = 48
_size__skip_one = 48
_size__unquote = 2336
_size__unquote = 2272
_size__validate_one = 48
_size__validate_utf8 = 688
_size__validate_utf8 = 672
_size__validate_utf8_fast = 560
_size__value = 1268
_size__vnumber = 1648
_size__atof_eisel_lemire64 = 400
_size__value = 1308
_size__vnumber = 1552
_size__atof_eisel_lemire64 = 368
_size__atof_native = 608
_size__decimal_to_f64 = 992
_size__left_shift = 544
_size__right_shift = 480
_size__vsigned = 368
_size__decimal_to_f64 = 1184
_size__right_shift = 400
_size__left_shift = 496
_size__vsigned = 320
_size__vstring = 128
_size__vunsigned = 368
_size__vunsigned = 336
)
var (
@ -129,16 +123,14 @@ var (
{8, 24},
{10, 32},
{12, 40},
{13, 48},
{3734, 64},
{3738, 48},
{3739, 40},
{3741, 32},
{3743, 24},
{3745, 16},
{3747, 8},
{3751, 0},
{3781, 64},
{3350, 48},
{3351, 40},
{3353, 32},
{3355, 24},
{3357, 16},
{3359, 8},
{3363, 0},
{3385, 48},
}
_pcsp__f64toa = [][2]uint32{
{1, 0},
@ -148,24 +140,24 @@ var (
{10, 32},
{12, 40},
{13, 48},
{3124, 56},
{3128, 48},
{3129, 40},
{3131, 32},
{3133, 24},
{3135, 16},
{3137, 8},
{3141, 0},
{3234, 56},
{2788, 56},
{2792, 48},
{2793, 40},
{2795, 32},
{2797, 24},
{2799, 16},
{2801, 8},
{2805, 0},
{2843, 56},
}
_pcsp__format_significand = [][2]uint32{
{1, 0},
{4, 8},
{6, 16},
{468, 24},
{469, 16},
{471, 8},
{473, 0},
{452, 24},
{453, 16},
{455, 8},
{457, 0},
}
_pcsp__format_integer = [][2]uint32{
{1, 0},
@ -177,6 +169,24 @@ var (
{424, 8},
{426, 0},
}
_pcsp__get_by_path = [][2]uint32{
{1, 0},
{4, 8},
{6, 16},
{8, 24},
{10, 32},
{12, 40},
{13, 48},
{4012, 104},
{4016, 48},
{4017, 40},
{4019, 32},
{4021, 24},
{4023, 16},
{4025, 8},
{4026, 0},
{4194, 104},
}
_pcsp__fsm_exec = [][2]uint32{
{1, 0},
{4, 8},
@ -185,15 +195,15 @@ var (
{10, 32},
{12, 40},
{13, 48},
{1317, 88},
{1321, 48},
{1322, 40},
{1324, 32},
{1326, 24},
{1328, 16},
{1330, 8},
{1331, 0},
{1656, 88},
{1342, 104},
{1346, 48},
{1347, 40},
{1349, 32},
{1351, 24},
{1353, 16},
{1355, 8},
{1356, 0},
{1692, 104},
}
_pcsp__advance_string = [][2]uint32{
{14, 0},
@ -203,15 +213,15 @@ var (
{24, 32},
{26, 40},
{27, 48},
{529, 72},
{533, 48},
{534, 40},
{536, 32},
{538, 24},
{540, 16},
{542, 8},
{543, 0},
{1253, 72},
{557, 56},
{561, 48},
{562, 40},
{564, 32},
{566, 24},
{568, 16},
{570, 8},
{571, 0},
{1268, 56},
}
_pcsp__advance_string_default = [][2]uint32{
{1, 0},
@ -221,45 +231,31 @@ var (
{10, 32},
{12, 40},
{13, 48},
{381, 56},
{385, 48},
{386, 40},
{388, 32},
{390, 24},
{392, 16},
{394, 8},
{395, 0},
{911, 56},
{552, 64},
{556, 48},
{557, 40},
{559, 32},
{561, 24},
{563, 16},
{565, 8},
{566, 0},
{931, 64},
}
_pcsp__do_skip_number = [][2]uint32{
{1, 0},
{4, 8},
{6, 16},
{8, 24},
{739, 32},
{740, 24},
{742, 16},
{744, 8},
{745, 0},
{876, 32},
}
_pcsp__get_by_path = [][2]uint32{
{1, 0},
{4, 8},
{6, 16},
{8, 24},
{10, 32},
{12, 40},
{13, 48},
{3262, 104},
{3266, 48},
{3267, 40},
{3269, 32},
{3271, 24},
{3273, 16},
{3275, 8},
{3276, 0},
{3301, 104},
{849, 48},
{850, 40},
{852, 32},
{854, 24},
{856, 16},
{858, 8},
{859, 0},
{924, 48},
}
_pcsp__skip_one_fast = [][2]uint32{
{1, 0},
@ -269,44 +265,15 @@ var (
{10, 32},
{12, 40},
{13, 48},
{613, 176},
{614, 168},
{616, 160},
{618, 152},
{620, 144},
{622, 136},
{626, 128},
{658, 176},
{659, 168},
{661, 160},
{663, 152},
{665, 144},
{667, 136},
{671, 128},
{3016, 176},
}
_pcsp__unescape = [][2]uint32{
{1, 0},
{4, 8},
{6, 16},
{8, 24},
{10, 32},
{12, 40},
{13, 48},
{246, 56},
{250, 48},
{251, 40},
{253, 32},
{255, 24},
{257, 16},
{259, 8},
{260, 0},
{695, 56},
}
_pcsp__unhex16_is = [][2]uint32{
{1, 0},
{35, 8},
{36, 0},
{62, 8},
{63, 0},
{97, 8},
{98, 0},
{121, 8},
{123, 0},
}
_pcsp__html_escape = [][2]uint32{
{1, 0},
{4, 8},
@ -315,47 +282,39 @@ var (
{10, 32},
{12, 40},
{13, 48},
{1265, 64},
{1269, 48},
{1270, 40},
{1272, 32},
{1274, 24},
{1276, 16},
{1278, 8},
{1280, 0},
{1224, 72},
{1228, 48},
{1229, 40},
{1231, 32},
{1233, 24},
{1235, 16},
{1237, 8},
{1239, 0},
}
_pcsp__i64toa = [][2]uint32{
{1, 0},
{171, 8},
{172, 0},
{207, 8},
{208, 0},
{222, 8},
{223, 0},
{247, 8},
{248, 0},
{253, 8},
{259, 0},
{14, 0},
{34, 8},
{36, 0},
}
_pcsp__u64toa = [][2]uint32{
{13, 0},
{162, 8},
{163, 0},
{175, 8},
{240, 0},
{498, 8},
{499, 0},
{519, 8},
{592, 0},
{850, 8},
{928, 0},
{1374, 8},
{1376, 0},
{1, 0},
{161, 8},
{162, 0},
{457, 8},
{458, 0},
{756, 8},
{757, 0},
{1221, 8},
{1223, 0},
}
_pcsp__lspace = [][2]uint32{
{1, 0},
{85, 8},
{87, 0},
{89, 8},
{90, 0},
{103, 8},
{104, 0},
{111, 8},
{113, 0},
}
_pcsp__quote = [][2]uint32{
{1, 0},
@ -365,15 +324,15 @@ var (
{10, 32},
{12, 40},
{13, 48},
{1669, 80},
{1673, 48},
{1674, 40},
{1676, 32},
{1678, 24},
{1680, 16},
{1682, 8},
{1683, 0},
{1718, 80},
{1649, 56},
{1653, 48},
{1654, 40},
{1656, 32},
{1658, 24},
{1660, 16},
{1662, 8},
{1663, 0},
{1690, 56},
}
_pcsp__skip_array = [][2]uint32{
{1, 0},
@ -405,8 +364,8 @@ var (
}
_pcsp__skip_one = [][2]uint32{
{1, 0},
{28, 8},
{34, 0},
{30, 8},
{36, 0},
}
_pcsp__unquote = [][2]uint32{
{1, 0},
@ -416,20 +375,20 @@ var (
{10, 32},
{12, 40},
{13, 48},
{1614, 104},
{1618, 48},
{1619, 40},
{1621, 32},
{1623, 24},
{1625, 16},
{1627, 8},
{1628, 0},
{2329, 104},
{1684, 88},
{1688, 48},
{1689, 40},
{1691, 32},
{1693, 24},
{1695, 16},
{1697, 8},
{1698, 0},
{2270, 88},
}
_pcsp__validate_one = [][2]uint32{
{1, 0},
{33, 8},
{39, 0},
{35, 8},
{41, 0},
}
_pcsp__validate_utf8 = [][2]uint32{
{1, 0},
@ -438,14 +397,14 @@ var (
{8, 24},
{10, 32},
{11, 40},
{639, 48},
{643, 40},
{644, 32},
{646, 24},
{648, 16},
{650, 8},
{651, 0},
{682, 48},
{623, 48},
{627, 40},
{628, 32},
{630, 24},
{632, 16},
{634, 8},
{635, 0},
{666, 48},
}
_pcsp__validate_utf8_fast = [][2]uint32{
{1, 0},
@ -468,15 +427,15 @@ var (
{10, 32},
{12, 40},
{13, 48},
{439, 88},
{443, 48},
{444, 40},
{446, 32},
{448, 24},
{450, 16},
{452, 8},
{453, 0},
{1268, 88},
{495, 88},
{499, 48},
{500, 40},
{502, 32},
{504, 24},
{506, 16},
{508, 8},
{509, 0},
{1308, 88},
}
_pcsp__vnumber = [][2]uint32{
{1, 0},
@ -486,36 +445,34 @@ var (
{10, 32},
{12, 40},
{13, 48},
{150, 120},
{154, 48},
{155, 40},
{157, 32},
{159, 24},
{161, 16},
{163, 8},
{164, 0},
{1638, 120},
{803, 104},
{807, 48},
{808, 40},
{810, 32},
{812, 24},
{814, 16},
{816, 8},
{817, 0},
{1547, 104},
}
_pcsp__atof_eisel_lemire64 = [][2]uint32{
{1, 0},
{4, 8},
{6, 16},
{8, 24},
{10, 32},
{315, 40},
{316, 32},
{318, 24},
{320, 16},
{322, 8},
{323, 0},
{387, 40},
{292, 32},
{293, 24},
{295, 16},
{297, 8},
{298, 0},
{362, 32},
}
_pcsp__atof_native = [][2]uint32{
{1, 0},
{4, 8},
{596, 56},
{600, 8},
{602, 0},
{587, 56},
{591, 8},
{593, 0},
}
_pcsp__decimal_to_f64 = [][2]uint32{
{1, 0},
@ -525,62 +482,60 @@ var (
{10, 32},
{12, 40},
{13, 48},
{951, 56},
{955, 48},
{956, 40},
{958, 32},
{960, 24},
{962, 16},
{964, 8},
{965, 0},
{977, 56},
{1144, 56},
{1148, 48},
{1149, 40},
{1151, 32},
{1153, 24},
{1155, 16},
{1157, 8},
{1158, 0},
{1169, 56},
}
_pcsp__left_shift = [][2]uint32{
_pcsp__right_shift = [][2]uint32{
{1, 0},
{4, 8},
{6, 16},
{8, 24},
{418, 32},
{419, 24},
{421, 16},
{423, 8},
{424, 0},
{539, 32},
{318, 8},
{319, 0},
{387, 8},
{388, 0},
{396, 8},
{398, 0},
}
_pcsp__right_shift = [][2]uint32{
_pcsp__left_shift = [][2]uint32{
{1, 0},
{4, 8},
{452, 16},
{453, 8},
{454, 0},
{462, 16},
{463, 8},
{464, 0},
{472, 16},
{6, 16},
{363, 24},
{364, 16},
{366, 8},
{367, 0},
{470, 24},
{471, 16},
{473, 8},
{475, 0},
{474, 0},
{486, 24},
}
_pcsp__vsigned = [][2]uint32{
{1, 0},
{4, 8},
{113, 16},
{114, 8},
{115, 0},
{126, 16},
{127, 8},
{128, 0},
{278, 16},
{279, 8},
{280, 0},
{284, 16},
{285, 8},
{286, 0},
{340, 16},
{341, 8},
{342, 0},
{353, 16},
{354, 8},
{356, 0},
{112, 16},
{113, 8},
{114, 0},
{125, 16},
{126, 8},
{127, 0},
{260, 16},
{261, 8},
{262, 0},
{266, 16},
{267, 8},
{268, 0},
{306, 16},
{307, 8},
{308, 0},
{316, 16},
{317, 8},
{319, 0},
}
_pcsp__vstring = [][2]uint32{
{1, 0},
@ -599,32 +554,18 @@ var (
}
_pcsp__vunsigned = [][2]uint32{
{1, 0},
{4, 8},
{6, 16},
{74, 24},
{75, 16},
{77, 8},
{78, 0},
{89, 24},
{90, 16},
{92, 8},
{93, 0},
{116, 24},
{117, 16},
{119, 8},
{120, 0},
{281, 24},
{282, 16},
{284, 8},
{285, 0},
{336, 24},
{337, 16},
{339, 8},
{340, 0},
{348, 24},
{349, 16},
{351, 8},
{353, 0},
{71, 8},
{72, 0},
{83, 8},
{84, 0},
{107, 8},
{108, 0},
{273, 8},
{274, 0},
{312, 8},
{313, 0},
{320, 8},
{322, 0},
}
)
@ -634,14 +575,12 @@ var Funcs = []loader.CFunc{
{"_f64toa", _entry__f64toa, _size__f64toa, _stack__f64toa, _pcsp__f64toa},
{"_format_significand", _entry__format_significand, _size__format_significand, _stack__format_significand, _pcsp__format_significand},
{"_format_integer", _entry__format_integer, _size__format_integer, _stack__format_integer, _pcsp__format_integer},
{"_get_by_path", _entry__get_by_path, _size__get_by_path, _stack__get_by_path, _pcsp__get_by_path},
{"_fsm_exec", _entry__fsm_exec, _size__fsm_exec, _stack__fsm_exec, _pcsp__fsm_exec},
{"_advance_string", _entry__advance_string, _size__advance_string, _stack__advance_string, _pcsp__advance_string},
{"_advance_string_default", _entry__advance_string_default, _size__advance_string_default, _stack__advance_string_default, _pcsp__advance_string_default},
{"_do_skip_number", _entry__do_skip_number, _size__do_skip_number, _stack__do_skip_number, _pcsp__do_skip_number},
{"_get_by_path", _entry__get_by_path, _size__get_by_path, _stack__get_by_path, _pcsp__get_by_path},
{"_skip_one_fast", _entry__skip_one_fast, _size__skip_one_fast, _stack__skip_one_fast, _pcsp__skip_one_fast},
{"_unescape", _entry__unescape, _size__unescape, _stack__unescape, _pcsp__unescape},
{"_unhex16_is", _entry__unhex16_is, _size__unhex16_is, _stack__unhex16_is, _pcsp__unhex16_is},
{"_html_escape", _entry__html_escape, _size__html_escape, _stack__html_escape, _pcsp__html_escape},
{"_i64toa", _entry__i64toa, _size__i64toa, _stack__i64toa, _pcsp__i64toa},
{"_u64toa", _entry__u64toa, _size__u64toa, _stack__u64toa, _pcsp__u64toa},
@ -660,8 +599,8 @@ var Funcs = []loader.CFunc{
{"_atof_eisel_lemire64", _entry__atof_eisel_lemire64, _size__atof_eisel_lemire64, _stack__atof_eisel_lemire64, _pcsp__atof_eisel_lemire64},
{"_atof_native", _entry__atof_native, _size__atof_native, _stack__atof_native, _pcsp__atof_native},
{"_decimal_to_f64", _entry__decimal_to_f64, _size__decimal_to_f64, _stack__decimal_to_f64, _pcsp__decimal_to_f64},
{"_left_shift", _entry__left_shift, _size__left_shift, _stack__left_shift, _pcsp__left_shift},
{"_right_shift", _entry__right_shift, _size__right_shift, _stack__right_shift, _pcsp__right_shift},
{"_left_shift", _entry__left_shift, _size__left_shift, _stack__left_shift, _pcsp__left_shift},
{"_vsigned", _entry__vsigned, _size__vsigned, _stack__vsigned, _pcsp__vsigned},
{"_vstring", _entry__vstring, _size__vstring, _stack__vstring, _pcsp__vstring},
{"_vunsigned", _entry__vunsigned, _size__vunsigned, _stack__vunsigned, _pcsp__vunsigned},

File diff suppressed because it is too large Load Diff

@ -1,3 +1,6 @@
// +build amd64
// Code generated by Makefile, DO NOT EDIT.
// Code generated by Makefile, DO NOT EDIT.
@ -71,8 +74,6 @@ var (
__validate_utf8 func(s unsafe.Pointer, p unsafe.Pointer, m unsafe.Pointer) (ret int)
__validate_utf8_fast func(s unsafe.Pointer) (ret int)
__fsm_exec func(m unsafe.Pointer, s unsafe.Pointer, p unsafe.Pointer, flags uint64) (ret int)
)
//go:nosplit
@ -185,7 +186,3 @@ func validate_utf8_fast(s *string) (ret int) {
return __validate_utf8_fast(rt.NoEscape(unsafe.Pointer(s)))
}
//go:nosplit
func fsm_exec(m *types.StateMachine, s *string, p *int, flags uint64) (ret int) {
return __fsm_exec(rt.NoEscape(unsafe.Pointer(m)), rt.NoEscape(unsafe.Pointer(s)), rt.NoEscape(unsafe.Pointer(p)), flags)
}

@ -8,120 +8,114 @@ import (
)
const (
_entry__f32toa = 34640
_entry__f64toa = 368
_entry__format_significand = 39440
_entry__format_integer = 3616
_entry__fsm_exec = 22128
_entry__advance_ns = 17856
_entry__advance_string = 18592
_entry__advance_string_default = 41024
_entry__do_skip_number = 24624
_entry__get_by_path = 29616
_entry__skip_one_fast = 26736
_entry__unescape = 41824
_entry__unhex16_is = 11376
_entry__html_escape = 11712
_entry__i64toa = 4048
_entry__u64toa = 4320
_entry__f32toa = 34656
_entry__f64toa = 320
_entry__format_significand = 38880
_entry__format_integer = 3168
_entry__get_by_path = 28896
_entry__fsm_exec = 21072
_entry__advance_ns = 16928
_entry__advance_string = 17664
_entry__advance_string_default = 40320
_entry__do_skip_number = 23696
_entry__skip_one_fast = 25968
_entry__html_escape = 10560
_entry__i64toa = 3600
_entry__u64toa = 3712
_entry__lspace = 64
_entry__quote = 5872
_entry__skip_array = 22080
_entry__skip_number = 26128
_entry__skip_object = 24048
_entry__skip_one = 26304
_entry__unquote = 8816
_entry__validate_one = 26368
_entry__validate_utf8 = 30960
_entry__validate_utf8_fast = 31920
_entry__value = 16320
_entry__vnumber = 19680
_entry__atof_eisel_lemire64 = 13760
_entry__atof_native = 15712
_entry__decimal_to_f64 = 14240
_entry__left_shift = 39920
_entry__right_shift = 40464
_entry__vsigned = 21328
_entry__vstring = 18352
_entry__vunsigned = 21696
_entry__quote = 5104
_entry__skip_array = 21024
_entry__skip_number = 25392
_entry__skip_object = 23088
_entry__skip_one = 25552
_entry__unquote = 7888
_entry__validate_one = 25600
_entry__validate_utf8 = 31072
_entry__validate_utf8_fast = 32016
_entry__value = 15376
_entry__vnumber = 18800
_entry__atof_eisel_lemire64 = 12624
_entry__atof_native = 14768
_entry__decimal_to_f64 = 13056
_entry__right_shift = 39840
_entry__left_shift = 39344
_entry__vsigned = 20352
_entry__vstring = 17424
_entry__vunsigned = 20672
)
const (
_stack__f32toa = 64
_stack__f32toa = 48
_stack__f64toa = 80
_stack__format_significand = 24
_stack__format_integer = 16
_stack__fsm_exec = 136
_stack__get_by_path = 272
_stack__fsm_exec = 144
_stack__advance_ns = 8
_stack__advance_string = 48
_stack__advance_string = 56
_stack__advance_string_default = 48
_stack__do_skip_number = 40
_stack__get_by_path = 304
_stack__do_skip_number = 48
_stack__skip_one_fast = 184
_stack__unescape = 64
_stack__unhex16_is = 8
_stack__html_escape = 72
_stack__i64toa = 16
_stack__u64toa = 8
_stack__lspace = 8
_stack__quote = 72
_stack__skip_array = 144
_stack__skip_number = 96
_stack__skip_object = 144
_stack__skip_one = 144
_stack__unquote = 112
_stack__validate_one = 144
_stack__quote = 56
_stack__skip_array = 152
_stack__skip_number = 104
_stack__skip_object = 152
_stack__skip_one = 152
_stack__unquote = 72
_stack__validate_one = 152
_stack__validate_utf8 = 48
_stack__validate_utf8_fast = 176
_stack__value = 352
_stack__vnumber = 264
_stack__atof_eisel_lemire64 = 40
_stack__atof_native = 144
_stack__decimal_to_f64 = 88
_stack__left_shift = 32
_stack__right_shift = 16
_stack__value = 328
_stack__vnumber = 240
_stack__atof_eisel_lemire64 = 32
_stack__atof_native = 136
_stack__decimal_to_f64 = 80
_stack__right_shift = 8
_stack__left_shift = 24
_stack__vsigned = 16
_stack__vstring = 104
_stack__vunsigned = 24
_stack__vstring = 112
_stack__vunsigned = 8
)
const (
_size__f32toa = 3792
_size__f64toa = 3248
_size__format_significand = 480
_size__f32toa = 3392
_size__f64toa = 2848
_size__format_significand = 464
_size__format_integer = 432
_size__fsm_exec = 1380
_size__get_by_path = 2176
_size__fsm_exec = 1468
_size__advance_ns = 496
_size__advance_string = 1040
_size__advance_string_default = 800
_size__do_skip_number = 1300
_size__get_by_path = 1344
_size__skip_one_fast = 2360
_size__unescape = 704
_size__unhex16_is = 144
_size__html_escape = 2048
_size__i64toa = 272
_size__u64toa = 1408
_size__lspace = 256
_size__quote = 2896
_size__advance_string = 1088
_size__advance_string_default = 768
_size__do_skip_number = 1360
_size__skip_one_fast = 2428
_size__html_escape = 2064
_size__i64toa = 48
_size__u64toa = 1248
_size__lspace = 224
_size__quote = 2736
_size__skip_array = 48
_size__skip_number = 160
_size__skip_object = 48
_size__skip_one = 48
_size__unquote = 2560
_size__unquote = 2480
_size__validate_one = 64
_size__validate_utf8 = 688
_size__validate_utf8_fast = 2672
_size__value = 992
_size__vnumber = 1648
_size__atof_eisel_lemire64 = 416
_size__validate_utf8 = 672
_size__validate_utf8_fast = 2608
_size__value = 1000
_size__vnumber = 1552
_size__atof_eisel_lemire64 = 368
_size__atof_native = 608
_size__decimal_to_f64 = 1472
_size__left_shift = 544
_size__right_shift = 496
_size__vsigned = 368
_size__decimal_to_f64 = 1712
_size__right_shift = 416
_size__left_shift = 496
_size__vsigned = 320
_size__vstring = 144
_size__vunsigned = 368
_size__vunsigned = 336
)
var (
@ -132,16 +126,14 @@ var (
{8, 24},
{10, 32},
{12, 40},
{13, 48},
{3734, 64},
{3738, 48},
{3739, 40},
{3741, 32},
{3743, 24},
{3745, 16},
{3747, 8},
{3751, 0},
{3781, 64},
{3350, 48},
{3351, 40},
{3353, 32},
{3355, 24},
{3357, 16},
{3359, 8},
{3363, 0},
{3385, 48},
}
_pcsp__f64toa = [][2]uint32{
{1, 0},
@ -151,24 +143,24 @@ var (
{10, 32},
{12, 40},
{13, 48},
{3124, 56},
{3128, 48},
{3129, 40},
{3131, 32},
{3133, 24},
{3135, 16},
{3137, 8},
{3141, 0},
{3234, 56},
{2788, 56},
{2792, 48},
{2793, 40},
{2795, 32},
{2797, 24},
{2799, 16},
{2801, 8},
{2805, 0},
{2843, 56},
}
_pcsp__format_significand = [][2]uint32{
{1, 0},
{4, 8},
{6, 16},
{468, 24},
{469, 16},
{471, 8},
{473, 0},
{452, 24},
{453, 16},
{455, 8},
{457, 0},
}
_pcsp__format_integer = [][2]uint32{
{1, 0},
@ -180,6 +172,24 @@ var (
{424, 8},
{426, 0},
}
_pcsp__get_by_path = [][2]uint32{
{1, 0},
{4, 8},
{6, 16},
{8, 24},
{10, 32},
{12, 40},
{13, 48},
{2049, 88},
{2053, 48},
{2054, 40},
{2056, 32},
{2058, 24},
{2060, 16},
{2062, 8},
{2063, 0},
{2170, 88},
}
_pcsp__fsm_exec = [][2]uint32{
{1, 0},
{4, 8},
@ -188,23 +198,22 @@ var (
{10, 32},
{12, 40},
{13, 48},
{1017, 88},
{1021, 48},
{1022, 40},
{1024, 32},
{1026, 24},
{1028, 16},
{1030, 8},
{1031, 0},
{1380, 88},
{1157, 88},
{1161, 48},
{1162, 40},
{1164, 32},
{1166, 24},
{1168, 16},
{1170, 8},
{1171, 0},
{1468, 88},
}
_pcsp__advance_ns = [][2]uint32{
{1, 0},
{442, 8},
{446, 0},
{467, 8},
{471, 0},
{489, 8},
{453, 8},
{457, 0},
{481, 8},
{486, 0},
}
_pcsp__advance_string = [][2]uint32{
{14, 0},
@ -213,14 +222,16 @@ var (
{22, 24},
{24, 32},
{26, 40},
{396, 48},
{397, 40},
{399, 32},
{401, 24},
{403, 16},
{405, 8},
{409, 0},
{1031, 48},
{27, 48},
{433, 56},
{437, 48},
{438, 40},
{440, 32},
{442, 24},
{444, 16},
{446, 8},
{450, 0},
{1078, 56},
}
_pcsp__advance_string_default = [][2]uint32{
{1, 0},
@ -229,46 +240,30 @@ var (
{8, 24},
{10, 32},
{12, 40},
{314, 48},
{315, 40},
{317, 32},
{319, 24},
{321, 16},
{323, 8},
{327, 0},
{786, 48},
{332, 48},
{333, 40},
{335, 32},
{337, 24},
{339, 16},
{341, 8},
{345, 0},
{757, 48},
}
_pcsp__do_skip_number = [][2]uint32{
{1, 0},
{4, 8},
{6, 16},
{8, 24},
{10, 32},
{1253, 40},
{1254, 32},
{1256, 24},
{1258, 16},
{1260, 8},
{1264, 0},
{1300, 40},
}
_pcsp__get_by_path = [][2]uint32{
{1, 0},
{4, 8},
{6, 16},
{8, 24},
{10, 32},
{12, 40},
{13, 48},
{1293, 120},
{1297, 48},
{1298, 40},
{1300, 32},
{1302, 24},
{1304, 16},
{1306, 8},
{1307, 0},
{1344, 120},
{1274, 48},
{1275, 40},
{1277, 32},
{1279, 24},
{1281, 16},
{1283, 8},
{1287, 0},
{1360, 48},
}
_pcsp__skip_one_fast = [][2]uint32{
{1, 0},
@ -278,43 +273,14 @@ var (
{10, 32},
{12, 40},
{13, 48},
{396, 176},
{397, 168},
{399, 160},
{401, 152},
{403, 144},
{405, 136},
{409, 128},
{2360, 176},
}
_pcsp__unescape = [][2]uint32{
{1, 0},
{4, 8},
{6, 16},
{8, 24},
{10, 32},
{12, 40},
{13, 48},
{246, 56},
{250, 48},
{251, 40},
{253, 32},
{255, 24},
{257, 16},
{259, 8},
{260, 0},
{695, 56},
}
_pcsp__unhex16_is = [][2]uint32{
{1, 0},
{35, 8},
{36, 0},
{62, 8},
{63, 0},
{97, 8},
{98, 0},
{121, 8},
{123, 0},
{418, 176},
{419, 168},
{421, 160},
{423, 152},
{425, 144},
{427, 136},
{431, 128},
{2428, 176},
}
_pcsp__html_escape = [][2]uint32{
{1, 0},
@ -324,52 +290,39 @@ var (
{10, 32},
{12, 40},
{13, 48},
{2017, 72},
{2021, 48},
{2022, 40},
{2024, 32},
{2026, 24},
{2028, 16},
{2030, 8},
{2035, 0},
{2045, 72},
{2049, 48},
{2050, 40},
{2052, 32},
{2054, 24},
{2056, 16},
{2058, 8},
{2063, 0},
}
_pcsp__i64toa = [][2]uint32{
{1, 0},
{171, 8},
{172, 0},
{207, 8},
{208, 0},
{222, 8},
{223, 0},
{247, 8},
{248, 0},
{253, 8},
{259, 0},
{14, 0},
{34, 8},
{36, 0},
}
_pcsp__u64toa = [][2]uint32{
{13, 0},
{162, 8},
{163, 0},
{175, 8},
{240, 0},
{498, 8},
{499, 0},
{519, 8},
{592, 0},
{852, 8},
{928, 0},
{1376, 8},
{1378, 0},
{1, 0},
{161, 8},
{162, 0},
{457, 8},
{458, 0},
{758, 8},
{759, 0},
{1225, 8},
{1227, 0},
}
_pcsp__lspace = [][2]uint32{
{1, 0},
{186, 8},
{190, 0},
{199, 8},
{203, 0},
{210, 8},
{214, 0},
{232, 8},
{184, 8},
{188, 0},
{204, 8},
{208, 0},
{215, 8},
{220, 0},
}
_pcsp__quote = [][2]uint32{
{1, 0},
@ -379,15 +332,15 @@ var (
{10, 32},
{12, 40},
{13, 48},
{2828, 72},
{2832, 48},
{2833, 40},
{2835, 32},
{2837, 24},
{2839, 16},
{2841, 8},
{2845, 0},
{2876, 72},
{2687, 56},
{2691, 48},
{2692, 40},
{2694, 32},
{2696, 24},
{2698, 16},
{2700, 8},
{2704, 0},
{2731, 56},
}
_pcsp__skip_array = [][2]uint32{
{1, 0},
@ -419,8 +372,8 @@ var (
}
_pcsp__skip_one = [][2]uint32{
{1, 0},
{28, 8},
{34, 0},
{30, 8},
{36, 0},
}
_pcsp__unquote = [][2]uint32{
{1, 0},
@ -430,20 +383,20 @@ var (
{10, 32},
{12, 40},
{13, 48},
{1836, 104},
{1840, 48},
{1841, 40},
{1843, 32},
{1845, 24},
{1847, 16},
{1849, 8},
{1853, 0},
{2554, 104},
{79, 72},
{83, 48},
{84, 40},
{86, 32},
{88, 24},
{90, 16},
{92, 8},
{96, 0},
{2464, 72},
}
_pcsp__validate_one = [][2]uint32{
{1, 0},
{33, 8},
{39, 0},
{35, 8},
{41, 0},
}
_pcsp__validate_utf8 = [][2]uint32{
{1, 0},
@ -452,26 +405,26 @@ var (
{8, 24},
{10, 32},
{11, 40},
{639, 48},
{643, 40},
{644, 32},
{646, 24},
{648, 16},
{650, 8},
{651, 0},
{682, 48},
{623, 48},
{627, 40},
{628, 32},
{630, 24},
{632, 16},
{634, 8},
{635, 0},
{666, 48},
}
_pcsp__validate_utf8_fast = [][2]uint32{
{1, 0},
{4, 8},
{5, 16},
{1706, 176},
{1707, 168},
{1711, 160},
{2003, 176},
{2004, 168},
{2008, 160},
{2656, 176},
{1738, 176},
{1739, 168},
{1743, 160},
{2018, 176},
{2019, 168},
{2023, 160},
{2600, 176},
}
_pcsp__value = [][2]uint32{
{1, 0},
@ -481,14 +434,14 @@ var (
{10, 32},
{12, 40},
{13, 48},
{974, 88},
{978, 48},
{979, 40},
{981, 32},
{983, 24},
{985, 16},
{987, 8},
{992, 0},
{982, 88},
{986, 48},
{987, 40},
{989, 32},
{991, 24},
{993, 16},
{995, 8},
{1000, 0},
}
_pcsp__vnumber = [][2]uint32{
{1, 0},
@ -498,36 +451,34 @@ var (
{10, 32},
{12, 40},
{13, 48},
{150, 120},
{154, 48},
{155, 40},
{157, 32},
{159, 24},
{161, 16},
{163, 8},
{164, 0},
{1638, 120},
{803, 104},
{807, 48},
{808, 40},
{810, 32},
{812, 24},
{814, 16},
{816, 8},
{817, 0},
{1547, 104},
}
_pcsp__atof_eisel_lemire64 = [][2]uint32{
{1, 0},
{4, 8},
{6, 16},
{8, 24},
{10, 32},
{315, 40},
{316, 32},
{318, 24},
{320, 16},
{322, 8},
{323, 0},
{387, 40},
{292, 32},
{293, 24},
{295, 16},
{297, 8},
{298, 0},
{362, 32},
}
_pcsp__atof_native = [][2]uint32{
{1, 0},
{4, 8},
{596, 56},
{600, 8},
{602, 0},
{587, 56},
{591, 8},
{593, 0},
}
_pcsp__decimal_to_f64 = [][2]uint32{
{1, 0},
@ -537,62 +488,60 @@ var (
{10, 32},
{12, 40},
{13, 48},
{1431, 56},
{1435, 48},
{1436, 40},
{1438, 32},
{1440, 24},
{1442, 16},
{1444, 8},
{1448, 0},
{1460, 56},
{1673, 56},
{1677, 48},
{1678, 40},
{1680, 32},
{1682, 24},
{1684, 16},
{1686, 8},
{1690, 0},
{1702, 56},
}
_pcsp__left_shift = [][2]uint32{
_pcsp__right_shift = [][2]uint32{
{1, 0},
{4, 8},
{6, 16},
{8, 24},
{418, 32},
{419, 24},
{421, 16},
{423, 8},
{424, 0},
{539, 32},
{318, 8},
{319, 0},
{387, 8},
{388, 0},
{396, 8},
{398, 0},
}
_pcsp__right_shift = [][2]uint32{
_pcsp__left_shift = [][2]uint32{
{1, 0},
{4, 8},
{452, 16},
{453, 8},
{454, 0},
{462, 16},
{463, 8},
{464, 0},
{472, 16},
{6, 16},
{363, 24},
{364, 16},
{366, 8},
{367, 0},
{470, 24},
{471, 16},
{473, 8},
{475, 0},
{474, 0},
{486, 24},
}
_pcsp__vsigned = [][2]uint32{
{1, 0},
{4, 8},
{113, 16},
{114, 8},
{115, 0},
{126, 16},
{127, 8},
{128, 0},
{278, 16},
{279, 8},
{280, 0},
{284, 16},
{285, 8},
{286, 0},
{340, 16},
{341, 8},
{342, 0},
{353, 16},
{354, 8},
{356, 0},
{112, 16},
{113, 8},
{114, 0},
{125, 16},
{126, 8},
{127, 0},
{260, 16},
{261, 8},
{262, 0},
{266, 16},
{267, 8},
{268, 0},
{306, 16},
{307, 8},
{308, 0},
{316, 16},
{317, 8},
{319, 0},
}
_pcsp__vstring = [][2]uint32{
{1, 0},
@ -611,32 +560,18 @@ var (
}
_pcsp__vunsigned = [][2]uint32{
{1, 0},
{4, 8},
{6, 16},
{74, 24},
{75, 16},
{77, 8},
{78, 0},
{89, 24},
{90, 16},
{92, 8},
{93, 0},
{116, 24},
{117, 16},
{119, 8},
{120, 0},
{281, 24},
{282, 16},
{284, 8},
{285, 0},
{336, 24},
{337, 16},
{339, 8},
{340, 0},
{348, 24},
{349, 16},
{351, 8},
{353, 0},
{71, 8},
{72, 0},
{83, 8},
{84, 0},
{107, 8},
{108, 0},
{273, 8},
{274, 0},
{312, 8},
{313, 0},
{320, 8},
{322, 0},
}
)
@ -646,15 +581,13 @@ var Funcs = []loader.CFunc{
{"_f64toa", _entry__f64toa, _size__f64toa, _stack__f64toa, _pcsp__f64toa},
{"_format_significand", _entry__format_significand, _size__format_significand, _stack__format_significand, _pcsp__format_significand},
{"_format_integer", _entry__format_integer, _size__format_integer, _stack__format_integer, _pcsp__format_integer},
{"_get_by_path", _entry__get_by_path, _size__get_by_path, _stack__get_by_path, _pcsp__get_by_path},
{"_fsm_exec", _entry__fsm_exec, _size__fsm_exec, _stack__fsm_exec, _pcsp__fsm_exec},
{"_advance_ns", _entry__advance_ns, _size__advance_ns, _stack__advance_ns, _pcsp__advance_ns},
{"_advance_string", _entry__advance_string, _size__advance_string, _stack__advance_string, _pcsp__advance_string},
{"_advance_string_default", _entry__advance_string_default, _size__advance_string_default, _stack__advance_string_default, _pcsp__advance_string_default},
{"_do_skip_number", _entry__do_skip_number, _size__do_skip_number, _stack__do_skip_number, _pcsp__do_skip_number},
{"_get_by_path", _entry__get_by_path, _size__get_by_path, _stack__get_by_path, _pcsp__get_by_path},
{"_skip_one_fast", _entry__skip_one_fast, _size__skip_one_fast, _stack__skip_one_fast, _pcsp__skip_one_fast},
{"_unescape", _entry__unescape, _size__unescape, _stack__unescape, _pcsp__unescape},
{"_unhex16_is", _entry__unhex16_is, _size__unhex16_is, _stack__unhex16_is, _pcsp__unhex16_is},
{"_html_escape", _entry__html_escape, _size__html_escape, _stack__html_escape, _pcsp__html_escape},
{"_i64toa", _entry__i64toa, _size__i64toa, _stack__i64toa, _pcsp__i64toa},
{"_u64toa", _entry__u64toa, _size__u64toa, _stack__u64toa, _pcsp__u64toa},
@ -673,8 +606,8 @@ var Funcs = []loader.CFunc{
{"_atof_eisel_lemire64", _entry__atof_eisel_lemire64, _size__atof_eisel_lemire64, _stack__atof_eisel_lemire64, _pcsp__atof_eisel_lemire64},
{"_atof_native", _entry__atof_native, _size__atof_native, _stack__atof_native, _pcsp__atof_native},
{"_decimal_to_f64", _entry__decimal_to_f64, _size__decimal_to_f64, _stack__decimal_to_f64, _pcsp__decimal_to_f64},
{"_left_shift", _entry__left_shift, _size__left_shift, _stack__left_shift, _pcsp__left_shift},
{"_right_shift", _entry__right_shift, _size__right_shift, _stack__right_shift, _pcsp__right_shift},
{"_left_shift", _entry__left_shift, _size__left_shift, _stack__left_shift, _pcsp__left_shift},
{"_vsigned", _entry__vsigned, _size__vsigned, _stack__vsigned, _pcsp__vsigned},
{"_vstring", _entry__vstring, _size__vstring, _stack__vstring, _pcsp__vstring},
{"_vunsigned", _entry__vunsigned, _size__vunsigned, _stack__vunsigned, _pcsp__vunsigned},

File diff suppressed because it is too large Load Diff

@ -93,6 +93,8 @@ var (
__F64toa func(out unsafe.Pointer, val float64) (ret int)
__F32toa func(out unsafe.Pointer, val float32) (ret int)
__ValidateUTF8 func(s unsafe.Pointer, p unsafe.Pointer, m unsafe.Pointer) (ret int)
__ValidateUTF8Fast func(s unsafe.Pointer) (ret int)
@ -153,6 +155,11 @@ func F64toa(out *byte, val float64) (ret int) {
return __F64toa(rt.NoEscape(unsafe.Pointer(out)), val)
}
//go:nosplit
func F32toa(out *byte, val float32) (ret int) {
return __F32toa(rt.NoEscape(unsafe.Pointer(out)), val)
}
//go:nosplit
func ValidateUTF8(s *string, p *int, m *types.StateMachine) (ret int) {
return __ValidateUTF8(rt.NoEscape(unsafe.Pointer(s)), rt.NoEscape(unsafe.Pointer(p)), rt.NoEscape(unsafe.Pointer(m)))
@ -165,7 +172,7 @@ func ValidateUTF8Fast(s *string) (ret int) {
var stubs = []loader.GoC{
{"_f64toa", &S_f64toa, &__F64toa},
{"_f32toa", &S_f32toa, nil},
{"_f32toa", &S_f32toa, &__F32toa},
{"_i64toa", &S_i64toa, &__I64toa},
{"_u64toa", &S_u64toa, &__U64toa},
{"_lspace", &S_lspace, nil},

@ -0,0 +1,154 @@
/*
* Copyright 2021 ByteDance Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package native
import (
`unsafe`
neon `github.com/bytedance/sonic/internal/native/neon`
`github.com/bytedance/sonic/internal/native/types`
)
const (
MaxFrameSize uintptr = 200
BufPaddingSize int = 64
)
var (
S_f64toa uintptr
S_f32toa uintptr
S_i64toa uintptr
S_u64toa uintptr
S_lspace uintptr
)
var (
S_quote uintptr
S_unquote uintptr
)
var (
S_value uintptr
S_vstring uintptr
S_vnumber uintptr
S_vsigned uintptr
S_vunsigned uintptr
)
var (
S_skip_one uintptr
S_skip_one_fast uintptr
S_get_by_path uintptr
S_skip_array uintptr
S_skip_object uintptr
S_skip_number uintptr
)
//go:nosplit
//go:noescape
//go:linkname Quote github.com/bytedance/sonic/internal/native/neon.__quote
func Quote(s unsafe.Pointer, nb int, dp unsafe.Pointer, dn *int, flags uint64) int
//go:nosplit
//go:noescape
//go:linkname Unquote github.com/bytedance/sonic/internal/native/neon.__unquote
func Unquote(s unsafe.Pointer, nb int, dp unsafe.Pointer, ep *int, flags uint64) int
//go:nosplit
//go:noescape
//go:linkname HTMLEscape github.com/bytedance/sonic/internal/native/neon.__html_escape
func HTMLEscape(s unsafe.Pointer, nb int, dp unsafe.Pointer, dn *int) int
//go:nosplit
//go:noescape
//go:linkname Value github.com/bytedance/sonic/internal/native/neon.__value
func Value(s unsafe.Pointer, n int, p int, v *types.JsonState, flags uint64) int
//go:nosplit
//go:noescape
//go:linkname SkipOne github.com/bytedance/sonic/internal/native/neon.__skip_one
func SkipOne(s *string, p *int, m *types.StateMachine, flags uint64) int
//go:nosplit
//go:noescape
//go:linkname SkipOneFast github.com/bytedance/sonic/internal/native/neon.__skip_one_fast
func SkipOneFast(s *string, p *int) int
//go:nosplit
//go:noescape
//go:linkname GetByPath github.com/bytedance/sonic/internal/native/neon.__get_by_path
func GetByPath(s *string, p *int, path *[]interface{}, m *types.StateMachine) int
//go:nosplit
//go:noescape
//go:linkname ValidateOne github.com/bytedance/sonic/internal/native/neon.__validate_one
func ValidateOne(s *string, p *int, m *types.StateMachine) int
//go:nosplit
//go:noescape
//go:linkname I64toa github.com/bytedance/sonic/internal/native/neon.__i64toa
func I64toa(out *byte, val int64) (ret int)
//go:nosplit
//go:noescape
//go:linkname U64toa github.com/bytedance/sonic/internal/native/neon.__u64toa
func U64toa(out *byte, val uint64) (ret int)
//go:nosplit
//go:noescape
//go:linkname F64toa github.com/bytedance/sonic/internal/native/neon.__f64toa
func F64toa(out *byte, val float64) (ret int)
//go:nosplit
//go:noescape
//go:linkname F32toa github.com/bytedance/sonic/internal/native/neon.__f32toa
func F32toa(out *byte, val float32) (ret int)
//go:nosplit
//go:noescape
//go:linkname ValidateUTF8 github.com/bytedance/sonic/internal/native/neon.__validate_utf8
func ValidateUTF8(s *string, p *int, m *types.StateMachine) (ret int)
//go:nosplit
//go:noescape
//go:linkname ValidateUTF8Fast github.com/bytedance/sonic/internal/native/neon.__validate_utf8_fast
func ValidateUTF8Fast(s *string) (ret int)
func useNeon() {
S_f64toa = neon.S_f64toa
S_f32toa = neon.S_f32toa
S_i64toa = neon.S_i64toa
S_u64toa = neon.S_u64toa
S_lspace = neon.S_lspace
S_quote = neon.S_quote
S_unquote = neon.S_unquote
S_value = neon.S_value
S_vstring = neon.S_vstring
S_vnumber = neon.S_vnumber
S_vsigned = neon.S_vsigned
S_vunsigned = neon.S_vunsigned
S_skip_one = neon.S_skip_one
S_skip_one_fast = neon.S_skip_one_fast
S_skip_array = neon.S_skip_array
S_skip_object = neon.S_skip_object
S_skip_number = neon.S_skip_number
S_get_by_path = neon.S_get_by_path
}
func init() {
useNeon()
}

@ -69,8 +69,6 @@ var (
__validate_utf8 func(s unsafe.Pointer, p unsafe.Pointer, m unsafe.Pointer) (ret int)
__validate_utf8_fast func(s unsafe.Pointer) (ret int)
__fsm_exec func(m unsafe.Pointer, s unsafe.Pointer, p unsafe.Pointer, flags uint64) (ret int)
)
//go:nosplit
@ -183,7 +181,3 @@ func validate_utf8_fast(s *string) (ret int) {
return __validate_utf8_fast(rt.NoEscape(unsafe.Pointer(s)))
}
//go:nosplit
func fsm_exec(m *types.StateMachine, s *string, p *int, flags uint64) (ret int) {
return __fsm_exec(rt.NoEscape(unsafe.Pointer(m)), rt.NoEscape(unsafe.Pointer(s)), rt.NoEscape(unsafe.Pointer(p)), flags)
}

@ -0,0 +1,246 @@
// Code generated by Makefile, DO NOT EDIT.
/*
* Copyright 2021 ByteDance Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package {{PACKAGE}}
import (
`unsafe`
`github.com/bytedance/sonic/internal/native/types`
)
//go:nosplit
func i64toa(out *byte, val int64) (ret int) {
return __i64toa(out, val)
}
//go:nosplit
func u64toa(out *byte, val uint64) (ret int) {
return __u64toa(out, val)
}
//go:nosplit
func f64toa(out *byte, val float64) (ret int) {
return __f64toa(out, val)
}
//go:nosplit
func f32toa(out *byte, val float32) (ret int) {
return __f32toa(out, val)
}
//go:nosplit
func lspace(sp unsafe.Pointer, nb int, off int) (ret int) {
return __lspace(sp, nb, off)
}
//go:nosplit
func quote(sp unsafe.Pointer, nb int, dp unsafe.Pointer, dn *int, flags uint64) (ret int) {
return __quote(sp, nb, dp, dn, flags)
}
//go:nosplit
func html_escape(sp unsafe.Pointer, nb int, dp unsafe.Pointer, dn *int) (ret int) {
return __html_escape(sp, nb, dp, dn)
}
//go:nosplit
func unquote(sp unsafe.Pointer, nb int, dp unsafe.Pointer, ep *int, flags uint64) (ret int) {
return __unquote(sp, nb, dp, ep, flags)
}
//go:nosplit
func value(s unsafe.Pointer, n int, p int, v *types.JsonState, flags uint64) (ret int) {
return __value(s, n, p, v, flags)
}
//go:nosplit
func vstring(s *string, p *int, v *types.JsonState, flags uint64) {
__vstring(s, p, v, flags)
}
//go:nosplit
func vnumber(s *string, p *int, v *types.JsonState) {
__vnumber(s, p, v)
}
//go:nosplit
func vsigned(s *string, p *int, v *types.JsonState) {
__vsigned(s, p, v)
}
//go:nosplit
func vunsigned(s *string, p *int, v *types.JsonState) {
__vunsigned(s, p, v)
}
//go:nosplit
func skip_one(s *string, p *int, m *types.StateMachine, flags uint64) (ret int) {
return __skip_one(s, p, m, flags)
}
//go:nosplit
func skip_one_fast(s *string, p *int) (ret int) {
return __skip_one_fast(s, p)
}
//go:nosplit
func skip_array(s *string, p *int, m *types.StateMachine, flags uint64) (ret int) {
return __skip_array(s, p, m, flags)
}
//go:nosplit
func skip_object(s *string, p *int, m *types.StateMachine, flags uint64) (ret int) {
return __skip_object(s, p, m, flags)
}
//go:nosplit
func skip_number(s *string, p *int) (ret int) {
return __skip_number(s, p)
}
//go:nosplit
func validate_one(s *string, p *int, m *types.StateMachine) (ret int) {
return __validate_one(s, p, m)
}
//go:nosplit
func get_by_path(s *string, p *int, path *[]interface{}, m *types.StateMachine) (ret int) {
return __get_by_path(s, p, path, m)
}
//go:nosplit
func validate_utf8(s *string, p *int, m *types.StateMachine) (ret int) {
return __validate_utf8(s, p, m)
}
//go:nosplit
func validate_utf8_fast(s *string) (ret int) {
return __validate_utf8_fast(s)
}
//go:nosplit
//go:noescape
//goland:noinspection GoUnusedParameter
func __i64toa(out *byte, val int64) (ret int)
//go:nosplit
//go:noescape
//goland:noinspection GoUnusedParameter
func __u64toa(out *byte, val uint64) (ret int)
//go:nosplit
//go:noescape
//goland:noinspection GoUnusedParameter
func __f64toa(out *byte, val float64) (ret int)
//go:nosplit
//go:noescape
//goland:noinspection GoUnusedParameter
func __f32toa(out *byte, val float32) (ret int)
//go:nosplit
//go:noescape
//goland:noinspection GoUnusedParameter
func __lspace(sp unsafe.Pointer, nb int, off int) (ret int)
//go:nosplit
//go:noescape
//goland:noinspection GoUnusedParameter
func __quote(sp unsafe.Pointer, nb int, dp unsafe.Pointer, dn *int, flags uint64) (ret int)
//go:nosplit
//go:noescape
//goland:noinspection GoUnusedParameter
func __html_escape(sp unsafe.Pointer, nb int, dp unsafe.Pointer, dn *int) (ret int)
//go:nosplit
//go:noescape
//goland:noinspection GoUnusedParameter
func __unquote(sp unsafe.Pointer, nb int, dp unsafe.Pointer, ep *int, flags uint64) (ret int)
//go:nosplit
//go:noescape
//goland:noinspection GoUnusedParameter
func __value(s unsafe.Pointer, n int, p int, v *types.JsonState, flags uint64) (ret int)
//go:nosplit
//go:noescape
//goland:noinspection GoUnusedParameter
func __vstring(s *string, p *int, v *types.JsonState, flags uint64)
//go:nosplit
//go:noescape
//goland:noinspection GoUnusedParameter
func __vnumber(s *string, p *int, v *types.JsonState)
//go:nosplit
//go:noescape
//goland:noinspection GoUnusedParameter
func __vsigned(s *string, p *int, v *types.JsonState)
//go:nosplit
//go:noescape
//goland:noinspection GoUnusedParameter
func __vunsigned(s *string, p *int, v *types.JsonState)
//go:nosplit
//go:noescape
//goland:noinspection GoUnusedParameter
func __skip_one(s *string, p *int, m *types.StateMachine, flags uint64) (ret int)
//go:nosplit
//go:noescape
//goland:noinspection GoUnusedParameter
func __skip_one_fast(s *string, p *int) (ret int)
//go:nosplit
//go:noescape
//goland:noinspection GoUnusedParameter
func __skip_array(s *string, p *int, m *types.StateMachine, flags uint64) (ret int)
//go:nosplit
//go:noescape
//goland:noinspection GoUnusedParameter
func __skip_object(s *string, p *int, m *types.StateMachine, flags uint64) (ret int)
//go:nosplit
//go:noescape
//goland:noinspection GoUnusedParameter
func __skip_number(s *string, p *int) (ret int)
//go:nosplit
//go:noescape
//goland:noinspection GoUnusedParameter
func __validate_one(s *string, p *int, m *types.StateMachine) (ret int)
//go:nosplit
//go:noescape
//goland:noinspection GoUnusedParameter
func __get_by_path(s *string, p *int, path *[]interface{}, m *types.StateMachine) (ret int)
//go:nosplit
//go:noescape
//goland:noinspection GoUnusedParameter
func __validate_utf8(s *string, p *int, m *types.StateMachine) (ret int)
//go:nosplit
//go:noescape
//goland:noinspection GoUnusedParameter
func __validate_utf8_fast(s *string) (ret int)

@ -0,0 +1,47 @@
/*
* Copyright 2021 ByteDance Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package {{PACKAGE}}
var (
S_f64toa = _subr__f64toa
S_f32toa = _subr__f32toa
S_i64toa = _subr__i64toa
S_u64toa = _subr__u64toa
S_lspace = _subr__lspace
)
var (
S_quote = _subr__quote
S_unquote = _subr__unquote
)
var (
S_value = _subr__value
S_vstring = _subr__vstring
S_vnumber = _subr__vnumber
S_vsigned = _subr__vsigned
S_vunsigned = _subr__vunsigned
)
var (
S_skip_one = _subr__skip_one
S_skip_one_fast = _subr__skip_one_fast
S_skip_array = _subr__skip_array
S_skip_object = _subr__skip_object
S_skip_number = _subr__skip_number
S_get_by_path = _subr__get_by_path
)

@ -0,0 +1,31 @@
// Code generated by Makefile, DO NOT EDIT.
// Code generated by Makefile, DO NOT EDIT.
/*
* Copyright 2021 ByteDance Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package neon
//go:nosplit
func f32toa(out *byte, val float32) (ret int) {
return __f32toa(out, val)
}
//go:nosplit
//go:noescape
//goland:noinspection GoUnusedParameter
func __f32toa(out *byte, val float32) (ret int)

File diff suppressed because it is too large Load Diff

@ -0,0 +1,25 @@
// +build !noasm !appengine
// Code generated by asm2asm, DO NOT EDIT.
package neon
//go:nosplit
//go:noescape
//goland:noinspection ALL
func __f32toa_entry__() uintptr
var (
_subr__f32toa uintptr = __f32toa_entry__() + 0
)
const (
_stack__f32toa = 32
)
var (
_ = _subr__f32toa
)
const (
_ = _stack__f32toa
)

@ -0,0 +1,31 @@
// Code generated by Makefile, DO NOT EDIT.
// Code generated by Makefile, DO NOT EDIT.
/*
* Copyright 2021 ByteDance Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package neon
//go:nosplit
func f64toa(out *byte, val float64) (ret int) {
return __f64toa(out, val)
}
//go:nosplit
//go:noescape
//goland:noinspection GoUnusedParameter
func __f64toa(out *byte, val float64) (ret int)

File diff suppressed because it is too large Load Diff

@ -0,0 +1,25 @@
// +build !noasm !appengine
// Code generated by asm2asm, DO NOT EDIT.
package neon
//go:nosplit
//go:noescape
//goland:noinspection ALL
func __f64toa_entry__() uintptr
var (
_subr__f64toa uintptr = __f64toa_entry__() + 0
)
const (
_stack__f64toa = 32
)
var (
_ = _subr__f64toa
)
const (
_ = _stack__f64toa
)

@ -0,0 +1,35 @@
// Code generated by Makefile, DO NOT EDIT.
// Code generated by Makefile, DO NOT EDIT.
/*
* Copyright 2021 ByteDance Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package neon
import (
`github.com/bytedance/sonic/internal/native/types`
)
//go:nosplit
func get_by_path(s *string, p *int, path *[]interface{}, m *types.StateMachine) (ret int) {
return __get_by_path(s, p, path, m)
}
//go:nosplit
//go:noescape
//goland:noinspection GoUnusedParameter
func __get_by_path(s *string, p *int, path *[]interface{}, m *types.StateMachine) (ret int)

File diff suppressed because it is too large Load Diff

@ -0,0 +1,25 @@
// +build !noasm !appengine
// Code generated by asm2asm, DO NOT EDIT.
package neon
//go:nosplit
//go:noescape
//goland:noinspection ALL
func __get_by_path_entry__() uintptr
var (
_subr__get_by_path uintptr = __get_by_path_entry__() + 48
)
const (
_stack__get_by_path = 208
)
var (
_ = _subr__get_by_path
)
const (
_ = _stack__get_by_path
)

@ -0,0 +1,37 @@
// Code generated by Makefile, DO NOT EDIT.
// Code generated by Makefile, DO NOT EDIT.
/*
* Copyright 2021 ByteDance Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package neon
import (
`unsafe`
// `github.com/bytedance/sonic/internal/native/types`
)
//go:nosplit
func html_escape(sp unsafe.Pointer, nb int, dp unsafe.Pointer, dn *int) (ret int) {
return __html_escape(sp, nb, dp, dn)
}
//go:nosplit
//go:noescape
//goland:noinspection GoUnusedParameter
func __html_escape(sp unsafe.Pointer, nb int, dp unsafe.Pointer, dn *int) (ret int)

File diff suppressed because it is too large Load Diff

@ -0,0 +1,25 @@
// +build !noasm !appengine
// Code generated by asm2asm, DO NOT EDIT.
package neon
//go:nosplit
//go:noescape
//goland:noinspection ALL
func __html_escape_entry__() uintptr
var (
_subr__html_escape uintptr = __html_escape_entry__() + 32
)
const (
_stack__html_escape = 32
)
var (
_ = _subr__html_escape
)
const (
_ = _stack__html_escape
)

@ -0,0 +1,31 @@
// Code generated by Makefile, DO NOT EDIT.
// Code generated by Makefile, DO NOT EDIT.
/*
* Copyright 2021 ByteDance Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package neon
//go:nosplit
func i64toa(out *byte, val int64) (ret int) {
return __i64toa(out, val)
}
//go:nosplit
//go:noescape
//goland:noinspection GoUnusedParameter
func __i64toa(out *byte, val int64) (ret int)

@ -0,0 +1,985 @@
// +build !noasm !appengine
// Code generated by asm2asm, DO NOT EDIT.
#include "go_asm.h"
#include "funcdata.h"
#include "textflag.h"
TEXT ·__i64toa_entry__(SB), NOSPLIT, $16
NO_LOCAL_POINTERS
WORD $0x100000a0 // adr x0, .+20
MOVD R0, ret(FP)
RET
// .p2align 3, 0x00
lCPI0_0:
WORD $0x147b20c5
WORD $0x80003334
// // .word 8389
// .word 5243
// .word 13108
// .word 32768
lCPI0_1:
WORD $0x08000080
WORD $0x80002000
// // .word 128
// .word 2048
// .word 8192
// .word 32768
lCPI0_2:
WORD $0x08040201
WORD $0x80402010
WORD $0x08040201
WORD $0x80402010
// // .byte 1
// .byte 2
// .byte 4
// .byte 8
// .byte 16
// .byte 32
// .byte 64
// .byte 128
// .byte 1
// .byte 2
// .byte 4
// .byte 8
// .byte 16
// .byte 32
// .byte 64
// .byte 128
lCPI0_3:
WORD $0x09010800
WORD $0x0b030a02
WORD $0x0d050c04
WORD $0x0f070e06
// // .byte 0
// .byte 8
// .byte 1
// .byte 9
// .byte 2
// .byte 10
// .byte 3
// .byte 11
// .byte 4
// .byte 12
// .byte 5
// .byte 13
// .byte 6
// .byte 14
// .byte 7
// .byte 15
_i64toa:
WORD $0xd10083ff // sub sp, sp, #32
WORD $0xa900fbfd // stp fp, lr, [sp, #8]
WORD $0xa93ffbfd // stp fp, lr, [sp, #-8]
WORD $0xd10023fd // sub fp, sp, #8
WORD $0xb7f80641 // tbnz x1, #63, LBB0_10 $200(%rip)
WORD $0xd344fc28 // lsr x8, x1, #4
WORD $0xf109c11f // cmp x8, #624
WORD $0x540008e8 // b.hi LBB0_13 $284(%rip)
WORD $0x53023c28 // ubfx w8, w1, #2, #14
WORD $0x52828f69 // mov w9, #5243
WORD $0x1b097d08 // mul w8, w8, w9
WORD $0x53117d08 // lsr w8, w8, #17
WORD $0xd37f7d09 // ubfiz x9, x8, #1, #32
WORD $0x52800c8a // mov w10, #100
WORD $0x1b0a8508 // msub w8, w8, w10, w1
WORD $0x92403d08 // and x8, x8, #0xffff
WORD $0xd37ff908 // lsl x8, x8, #1
WORD $0x710fa03f // cmp w1, #1000
WORD $0x540000e3 // b.lo LBB0_4 $28(%rip)
Lloh0:
WORD $0x100054ea // adr x10, _Digits $2716(%rip)
Lloh1:
WORD $0x9100014a // add x10, x10, _Digits@PAGEOFF $0(%rip)
WORD $0x3869694a // ldrb w10, [x10, x9]
WORD $0x3900000a // strb w10, [x0]
WORD $0x5280002a // mov w10, #1
WORD $0x14000004 // b LBB0_6 $16(%rip)
LBB0_4:
WORD $0x7101903f // cmp w1, #100
WORD $0x540002e3 // b.lo LBB0_9 $92(%rip)
WORD $0x5280000a // mov w10, #0
LBB0_6:
Lloh2:
WORD $0x100053cb // adr x11, _Digits $2680(%rip)
Lloh3:
WORD $0x9100016b // add x11, x11, _Digits@PAGEOFF $0(%rip)
WORD $0x8b294169 // add x9, x11, w9, uxtw
WORD $0x3940052b // ldrb w11, [x9, #1]
WORD $0x11000549 // add w9, w10, #1
WORD $0x382a480b // strb w11, [x0, w10, uxtw]
LBB0_7:
Lloh4:
WORD $0x1000530a // adr x10, _Digits $2656(%rip)
Lloh5:
WORD $0x9100014a // add x10, x10, _Digits@PAGEOFF $0(%rip)
WORD $0x3868694b // ldrb w11, [x10, x8]
WORD $0x1100052a // add w10, w9, #1
WORD $0x3829480b // strb w11, [x0, w9, uxtw]
LBB0_8:
Lloh6:
WORD $0x10005269 // adr x9, _Digits $2636(%rip)
Lloh7:
WORD $0x91000129 // add x9, x9, _Digits@PAGEOFF $0(%rip)
WORD $0x8b282128 // add x8, x9, w8, uxth
WORD $0x39400509 // ldrb w9, [x8, #1]
WORD $0x11000548 // add w8, w10, #1
WORD $0x382a4809 // strb w9, [x0, w10, uxtw]
WORD $0xaa0803e0 // mov x0, x8
WORD $0xa940fbfd // ldp fp, lr, [sp, #8]
WORD $0x910083ff // add sp, sp, #32
WORD $0xd65f03c0 // ret
LBB0_9:
WORD $0x52800009 // mov w9, #0
WORD $0x5280000a // mov w10, #0
WORD $0x7100283f // cmp w1, #10
WORD $0x54fffdc2 // b.hs LBB0_7 $-72(%rip)
WORD $0x17fffff2 // b LBB0_8 $-56(%rip)
LBB0_10:
WORD $0x528005a9 // mov w9, #45
WORD $0xaa0003e8 // mov x8, x0
WORD $0x38001509 // strb w9, [x8], #1
WORD $0xcb0103e9 // neg x9, x1
WORD $0xd344fd2a // lsr x10, x9, #4
WORD $0xf109c15f // cmp x10, #624
WORD $0x54001068 // b.hi LBB0_28 $524(%rip)
WORD $0x53023d2a // ubfx w10, w9, #2, #14
WORD $0x52828f6b // mov w11, #5243
WORD $0x1b0b7d4a // mul w10, w10, w11
WORD $0x53117d4a // lsr w10, w10, #17
WORD $0xd37f7d4b // ubfiz x11, x10, #1, #32
WORD $0x52800c8c // mov w12, #100
WORD $0x1b0ca54a // msub w10, w10, w12, w9
WORD $0x92403d4a // and x10, x10, #0xffff
WORD $0xd37ff94a // lsl x10, x10, #1
WORD $0x710fa13f // cmp w9, #1000
WORD $0x540004e3 // b.lo LBB0_16 $156(%rip)
Lloh8:
WORD $0x10004e49 // adr x9, _Digits $2504(%rip)
Lloh9:
WORD $0x91000129 // add x9, x9, _Digits@PAGEOFF $0(%rip)
WORD $0x386b6929 // ldrb w9, [x9, x11]
WORD $0x39000109 // strb w9, [x8]
WORD $0x52800029 // mov w9, #1
WORD $0x14000024 // b LBB0_18 $144(%rip)
LBB0_13:
WORD $0x529c2008 // mov w8, #57600
WORD $0x72a0bea8 // movk w8, #1525, lsl #16
WORD $0xeb08003f // cmp x1, x8
WORD $0x540011c2 // b.hs LBB0_31 $568(%rip)
WORD $0x5282eb28 // mov w8, #5977
WORD $0x72ba36e8 // movk w8, #53687, lsl #16
WORD $0x92407c29 // and x9, x1, #0xffffffff
WORD $0x9ba87d28 // umull x8, w9, w8
WORD $0xd36dfd08 // lsr x8, x8, #45
WORD $0x529bd06a // mov w10, #56963
WORD $0x72a8636a // movk w10, #17179, lsl #16
WORD $0x9baa7d29 // umull x9, w9, w10
WORD $0xd371fd29 // lsr x9, x9, #49
WORD $0x927f312a // and x10, x9, #0x3ffe
WORD $0x53023d09 // ubfx w9, w8, #2, #14
WORD $0x52828f6b // mov w11, #5243
WORD $0x1b0b7d29 // mul w9, w9, w11
WORD $0x53117d29 // lsr w9, w9, #17
WORD $0x52800c8b // mov w11, #100
WORD $0x1b0ba129 // msub w9, w9, w11, w8
WORD $0x92403d29 // and x9, x9, #0xffff
WORD $0xd37ff929 // lsl x9, x9, #1
WORD $0x5292cfeb // mov w11, #38527
WORD $0x72a0130b // movk w11, #152, lsl #16
WORD $0x6b0b003f // cmp w1, w11
WORD $0x54000409 // b.ls LBB0_21 $128(%rip)
Lloh10:
WORD $0x10004a4b // adr x11, _Digits $2376(%rip)
Lloh11:
WORD $0x9100016b // add x11, x11, _Digits@PAGEOFF $0(%rip)
WORD $0x386a696b // ldrb w11, [x11, x10]
WORD $0x3900000b // strb w11, [x0]
WORD $0x5280002c // mov w12, #1
WORD $0x1400001f // b LBB0_23 $124(%rip)
LBB0_16:
WORD $0x7101913f // cmp w9, #100
WORD $0x540008a3 // b.lo LBB0_26 $276(%rip)
WORD $0x52800009 // mov w9, #0
LBB0_18:
Lloh12:
WORD $0x1000492c // adr x12, _Digits $2340(%rip)
Lloh13:
WORD $0x9100018c // add x12, x12, _Digits@PAGEOFF $0(%rip)
WORD $0x8b2b418b // add x11, x12, w11, uxtw
WORD $0x3940056c // ldrb w12, [x11, #1]
WORD $0x1100052b // add w11, w9, #1
WORD $0x3829490c // strb w12, [x8, w9, uxtw]
LBB0_19:
Lloh14:
WORD $0x10004869 // adr x9, _Digits $2316(%rip)
Lloh15:
WORD $0x91000129 // add x9, x9, _Digits@PAGEOFF $0(%rip)
WORD $0x386a6929 // ldrb w9, [x9, x10]
WORD $0x1100056c // add w12, w11, #1
WORD $0x382b4909 // strb w9, [x8, w11, uxtw]
LBB0_20:
Lloh16:
WORD $0x100047c9 // adr x9, _Digits $2296(%rip)
Lloh17:
WORD $0x91000129 // add x9, x9, _Digits@PAGEOFF $0(%rip)
WORD $0x8b2a2129 // add x9, x9, w10, uxth
WORD $0x3940052a // ldrb w10, [x9, #1]
WORD $0x11000589 // add w9, w12, #1
WORD $0x382c490a // strb w10, [x8, w12, uxtw]
WORD $0x11000528 // add w8, w9, #1
WORD $0xaa0803e0 // mov x0, x8
WORD $0xa940fbfd // ldp fp, lr, [sp, #8]
WORD $0x910083ff // add sp, sp, #32
WORD $0xd65f03c0 // ret
LBB0_21:
WORD $0x528847eb // mov w11, #16959
WORD $0x72a001eb // movk w11, #15, lsl #16
WORD $0x6b0b003f // cmp w1, w11
WORD $0x540005e9 // b.ls LBB0_27 $188(%rip)
WORD $0x5280000c // mov w12, #0
LBB0_23:
Lloh18:
WORD $0x100045cb // adr x11, _Digits $2232(%rip)
Lloh19:
WORD $0x9100016b // add x11, x11, _Digits@PAGEOFF $0(%rip)
WORD $0x8b2a416a // add x10, x11, w10, uxtw
WORD $0x3940054a // ldrb w10, [x10, #1]
WORD $0x1100058b // add w11, w12, #1
WORD $0x382c480a // strb w10, [x0, w12, uxtw]
LBB0_24:
Lloh20:
WORD $0x1000450a // adr x10, _Digits $2208(%rip)
Lloh21:
WORD $0x9100014a // add x10, x10, _Digits@PAGEOFF $0(%rip)
WORD $0x3869694c // ldrb w12, [x10, x9]
WORD $0x1100056a // add w10, w11, #1
WORD $0x382b480c // strb w12, [x0, w11, uxtw]
LBB0_25:
WORD $0x5284e20b // mov w11, #10000
WORD $0x1b0b8508 // msub w8, w8, w11, w1
WORD $0x53023d0b // ubfx w11, w8, #2, #14
WORD $0x52828f6c // mov w12, #5243
WORD $0x1b0c7d6b // mul w11, w11, w12
WORD $0x53117d6b // lsr w11, w11, #17
WORD $0x52800c8c // mov w12, #100
WORD $0x1b0ca168 // msub w8, w11, w12, w8
WORD $0x92403d08 // and x8, x8, #0xffff
WORD $0xd37ff908 // lsl x8, x8, #1
Lloh22:
WORD $0x1000432c // adr x12, _Digits $2148(%rip)
Lloh23:
WORD $0x9100018c // add x12, x12, _Digits@PAGEOFF $0(%rip)
WORD $0x8b292189 // add x9, x12, w9, uxth
WORD $0x39400529 // ldrb w9, [x9, #1]
WORD $0x8b2a400d // add x13, x0, w10, uxtw
WORD $0x390001a9 // strb w9, [x13]
WORD $0x786b5989 // ldrh w9, [x12, w11, uxtw #1]
WORD $0x780011a9 // sturh w9, [x13, #1]
WORD $0x38686989 // ldrb w9, [x12, x8]
WORD $0x39000da9 // strb w9, [x13, #3]
WORD $0x927f3908 // and x8, x8, #0xfffe
WORD $0x8b080188 // add x8, x12, x8
WORD $0x39400509 // ldrb w9, [x8, #1]
WORD $0x11001548 // add w8, w10, #5
WORD $0x390011a9 // strb w9, [x13, #4]
WORD $0xaa0803e0 // mov x0, x8
WORD $0xa940fbfd // ldp fp, lr, [sp, #8]
WORD $0x910083ff // add sp, sp, #32
WORD $0xd65f03c0 // ret
LBB0_26:
WORD $0x5280000b // mov w11, #0
WORD $0x5280000c // mov w12, #0
WORD $0x7100293f // cmp w9, #10
WORD $0x54fff802 // b.hs LBB0_19 $-256(%rip)
WORD $0x17ffffc4 // b LBB0_20 $-240(%rip)
LBB0_27:
WORD $0x5280000b // mov w11, #0
WORD $0x5280000a // mov w10, #0
WORD $0x53057c2c // lsr w12, w1, #5
WORD $0x7130d59f // cmp w12, #3125
WORD $0x54fffaa2 // b.hs LBB0_24 $-172(%rip)
WORD $0x17ffffd9 // b LBB0_25 $-156(%rip)
LBB0_28:
WORD $0x529c200a // mov w10, #57600
WORD $0x72a0beaa // movk w10, #1525, lsl #16
WORD $0xeb0a013f // cmp x9, x10
WORD $0x54001662 // b.hs LBB0_39 $716(%rip)
WORD $0x5282eb2a // mov w10, #5977
WORD $0x72ba36ea // movk w10, #53687, lsl #16
WORD $0x9baa7d2a // umull x10, w9, w10
WORD $0xd36dfd4a // lsr x10, x10, #45
WORD $0x529bd06b // mov w11, #56963
WORD $0x72a8636b // movk w11, #17179, lsl #16
WORD $0x92407d2c // and x12, x9, #0xffffffff
WORD $0x9bab7d8b // umull x11, w12, w11
WORD $0xd371fd6b // lsr x11, x11, #49
WORD $0x927f316c // and x12, x11, #0x3ffe
WORD $0x53023d4b // ubfx w11, w10, #2, #14
WORD $0x52828f6d // mov w13, #5243
WORD $0x1b0d7d6b // mul w11, w11, w13
WORD $0x53117d6b // lsr w11, w11, #17
WORD $0x52800c8d // mov w13, #100
WORD $0x1b0da96b // msub w11, w11, w13, w10
WORD $0x92403d6b // and x11, x11, #0xffff
WORD $0xd37ff96b // lsl x11, x11, #1
WORD $0x5292cfed // mov w13, #38527
WORD $0x72a0130d // movk w13, #152, lsl #16
WORD $0x6b0d013f // cmp w9, w13
WORD $0x54000d29 // b.ls LBB0_33 $420(%rip)
Lloh24:
WORD $0x10003c2d // adr x13, _Digits $1924(%rip)
Lloh25:
WORD $0x910001ad // add x13, x13, _Digits@PAGEOFF $0(%rip)
WORD $0x386c69ad // ldrb w13, [x13, x12]
WORD $0x3900010d // strb w13, [x8]
WORD $0x5280002e // mov w14, #1
WORD $0x14000068 // b LBB0_35 $416(%rip)
LBB0_31:
WORD $0xd2adf82a // mov x10, #1874919424
WORD $0xf2d0de4a // movk x10, #34546, lsl #32
WORD $0xf2e0046a // movk x10, #35, lsl #48
WORD $0xeb0a003f // cmp x1, x10
WORD $0x54001ea2 // b.hs LBB0_41 $980(%rip)
WORD $0xd299dfa9 // mov x9, #52989
WORD $0xf2b08c29 // movk x9, #33889, lsl #16
WORD $0xf2cee229 // movk x9, #30481, lsl #32
WORD $0xf2f57989 // movk x9, #43980, lsl #48
WORD $0x9bc97c29 // umulh x9, x1, x9
WORD $0xd35afd29 // lsr x9, x9, #26
WORD $0x1b088528 // msub w8, w9, w8, w1
WORD $0x6f00e400 // movi.2d v0, #0000000000000000
WORD $0x6f00e401 // movi.2d v1, #0000000000000000
WORD $0x4e041d21 // mov.s v1[0], w9
WORD $0x0ea12822 // xtn.2s v2, v1
WORD $0x5282eb29 // mov w9, #5977
WORD $0x72ba36e9 // movk w9, #53687, lsl #16
WORD $0x0e040d23 // dup.2s v3, w9
WORD $0x2ea3c042 // umull.2d v2, v2, v3
WORD $0x6f530442 // ushr.2d v2, v2, #45
WORD $0x0ea12844 // xtn.2s v4, v2
WORD $0x5284e209 // mov w9, #10000
WORD $0x0e040d25 // dup.2s v5, w9
WORD $0x2ea5c084 // umull.2d v4, v4, v5
WORD $0x6ea48421 // sub.4s v1, v1, v4
WORD $0x4e413841 // zip1.8h v1, v2, v1
WORD $0x4f425421 // shl.2d v1, v1, #2
WORD $0x4e413821 // zip1.8h v1, v1, v1
WORD $0x4e813821 // zip1.4s v1, v1, v1
Lloh26:
WORD $0x10ffdee9 // adr x9, lCPI0_0 $-1060(%rip)
Lloh27:
WORD $0xfd400122 // ldr d2, [x9, lCPI0_0@PAGEOFF] $0(%rip)
WORD $0x2e62c024 // umull.4s v4, v1, v2
WORD $0x6e014021 // ext.16b v1, v1, v1, #8
WORD $0x2e62c021 // umull.4s v1, v1, v2
WORD $0x4e415881 // uzp2.8h v1, v4, v1
Lloh28:
WORD $0x10ffde69 // adr x9, lCPI0_1 $-1076(%rip)
Lloh29:
WORD $0xfd400124 // ldr d4, [x9, lCPI0_1@PAGEOFF] $0(%rip)
WORD $0x2e64c026 // umull.4s v6, v1, v4
WORD $0x6e014021 // ext.16b v1, v1, v1, #8
WORD $0x2e64c021 // umull.4s v1, v1, v4
WORD $0x4e4158c1 // uzp2.8h v1, v6, v1
WORD $0x4f008546 // movi.8h v6, #10
WORD $0x4e669c27 // mul.8h v7, v1, v6
WORD $0x4f5054e7 // shl.2d v7, v7, #16
WORD $0x6e678421 // sub.8h v1, v1, v7
WORD $0x4e041d00 // mov.s v0[0], w8
WORD $0x0ea12807 // xtn.2s v7, v0
WORD $0x2ea3c0e3 // umull.2d v3, v7, v3
WORD $0x6f530463 // ushr.2d v3, v3, #45
WORD $0x0ea12867 // xtn.2s v7, v3
WORD $0x2ea5c0e5 // umull.2d v5, v7, v5
WORD $0x6ea58400 // sub.4s v0, v0, v5
WORD $0x4e403860 // zip1.8h v0, v3, v0
WORD $0x4f425400 // shl.2d v0, v0, #2
WORD $0x4e403800 // zip1.8h v0, v0, v0
WORD $0x4e803800 // zip1.4s v0, v0, v0
WORD $0x2e62c003 // umull.4s v3, v0, v2
WORD $0x6e004000 // ext.16b v0, v0, v0, #8
WORD $0x2e62c000 // umull.4s v0, v0, v2
WORD $0x4e405860 // uzp2.8h v0, v3, v0
WORD $0x2e64c002 // umull.4s v2, v0, v4
WORD $0x6e004000 // ext.16b v0, v0, v0, #8
WORD $0x2e64c000 // umull.4s v0, v0, v4
WORD $0x4e405840 // uzp2.8h v0, v2, v0
WORD $0x4e669c02 // mul.8h v2, v0, v6
WORD $0x4f505442 // shl.2d v2, v2, #16
WORD $0x6e628400 // sub.8h v0, v0, v2
WORD $0x2e212821 // sqxtun.8b v1, v1
WORD $0x6e212801 // sqxtun2.16b v1, v0
WORD $0x4f01e600 // movi.16b v0, #48
WORD $0x4e208420 // add.16b v0, v1, v0
WORD $0x4e209821 // cmeq.16b v1, v1, #0
Lloh30:
WORD $0x10ffda08 // adr x8, lCPI0_2 $-1216(%rip)
Lloh31:
WORD $0x3dc00102 // ldr q2, [x8, lCPI0_2@PAGEOFF] $0(%rip)
WORD $0x4e221c21 // and.16b v1, v1, v2
Lloh32:
WORD $0x10ffda28 // adr x8, lCPI0_3 $-1212(%rip)
Lloh33:
WORD $0x3dc00102 // ldr q2, [x8, lCPI0_3@PAGEOFF] $0(%rip)
WORD $0x4e020021 // tbl.16b v1, { v1 }, v2
WORD $0x4e71b821 // addv.8h h1, v1
WORD $0x1e260028 // fmov w8, s1
WORD $0x2a2803e8 // mvn w8, w8
WORD $0x32114108 // orr w8, w8, #0xffff8000
WORD $0x5ac00108 // rbit w8, w8
WORD $0x5ac01108 // clz w8, w8
Lloh34:
WORD $0x10003709 // adr x9, _VecShiftShuffles $1760(%rip)
Lloh35:
WORD $0x91000129 // add x9, x9, _VecShiftShuffles@PAGEOFF $0(%rip)
WORD $0x3ce85921 // ldr q1, [x9, w8, uxtw #4]
WORD $0x4f04e5e2 // movi.16b v2, #143
WORD $0x4e221c21 // and.16b v1, v1, v2
WORD $0x4e010000 // tbl.16b v0, { v0 }, v1
WORD $0x3d800000 // str q0, [x0]
WORD $0x52800209 // mov w9, #16
WORD $0x4b080128 // sub w8, w9, w8
WORD $0xaa0803e0 // mov x0, x8
WORD $0xa940fbfd // ldp fp, lr, [sp, #8]
WORD $0x910083ff // add sp, sp, #32
WORD $0xd65f03c0 // ret
LBB0_33:
WORD $0x528847ed // mov w13, #16959
WORD $0x72a001ed // movk w13, #15, lsl #16
WORD $0x6b0d013f // cmp w9, w13
WORD $0x54000569 // b.ls LBB0_38 $172(%rip)
WORD $0x5280000e // mov w14, #0
LBB0_35:
Lloh36:
WORD $0x10002e8d // adr x13, _Digits $1488(%rip)
Lloh37:
WORD $0x910001ad // add x13, x13, _Digits@PAGEOFF $0(%rip)
WORD $0x8b2c41ac // add x12, x13, w12, uxtw
WORD $0x3940058c // ldrb w12, [x12, #1]
WORD $0x110005cd // add w13, w14, #1
WORD $0x382e490c // strb w12, [x8, w14, uxtw]
LBB0_36:
Lloh38:
WORD $0x10002dcc // adr x12, _Digits $1464(%rip)
Lloh39:
WORD $0x9100018c // add x12, x12, _Digits@PAGEOFF $0(%rip)
WORD $0x386b698e // ldrb w14, [x12, x11]
WORD $0x110005ac // add w12, w13, #1
WORD $0x382d490e // strb w14, [x8, w13, uxtw]
LBB0_37:
WORD $0x5284e20d // mov w13, #10000
WORD $0x1b0da549 // msub w9, w10, w13, w9
WORD $0x53023d2a // ubfx w10, w9, #2, #14
WORD $0x52828f6d // mov w13, #5243
WORD $0x1b0d7d4a // mul w10, w10, w13
WORD $0x53117d4a // lsr w10, w10, #17
WORD $0x52800c8d // mov w13, #100
WORD $0x1b0da549 // msub w9, w10, w13, w9
WORD $0x92403d29 // and x9, x9, #0xffff
WORD $0xd37ff929 // lsl x9, x9, #1
Lloh40:
WORD $0x10002bed // adr x13, _Digits $1404(%rip)
Lloh41:
WORD $0x910001ad // add x13, x13, _Digits@PAGEOFF $0(%rip)
WORD $0x8b2b21ab // add x11, x13, w11, uxth
WORD $0x3940056b // ldrb w11, [x11, #1]
WORD $0x8b2c4108 // add x8, x8, w12, uxtw
WORD $0x3900010b // strb w11, [x8]
WORD $0x786a59aa // ldrh w10, [x13, w10, uxtw #1]
WORD $0x7800110a // sturh w10, [x8, #1]
WORD $0x386969aa // ldrb w10, [x13, x9]
WORD $0x39000d0a // strb w10, [x8, #3]
WORD $0x927f3929 // and x9, x9, #0xfffe
WORD $0x8b0901a9 // add x9, x13, x9
WORD $0x3940052a // ldrb w10, [x9, #1]
WORD $0x11001589 // add w9, w12, #5
WORD $0x3900110a // strb w10, [x8, #4]
WORD $0x11000528 // add w8, w9, #1
WORD $0xaa0803e0 // mov x0, x8
WORD $0xa940fbfd // ldp fp, lr, [sp, #8]
WORD $0x910083ff // add sp, sp, #32
WORD $0xd65f03c0 // ret
LBB0_38:
WORD $0x5280000d // mov w13, #0
WORD $0x5280000c // mov w12, #0
WORD $0x53057d2e // lsr w14, w9, #5
WORD $0x7130d5df // cmp w14, #3125
WORD $0x54fffb22 // b.hs LBB0_36 $-156(%rip)
WORD $0x17ffffdd // b LBB0_37 $-140(%rip)
LBB0_39:
WORD $0xd2adf82c // mov x12, #1874919424
WORD $0xf2d0de4c // movk x12, #34546, lsl #32
WORD $0xf2e0046c // movk x12, #35, lsl #48
WORD $0xeb0c013f // cmp x9, x12
WORD $0x540019e2 // b.hs LBB0_47 $828(%rip)
WORD $0xd299dfab // mov x11, #52989
WORD $0xf2b08c2b // movk x11, #33889, lsl #16
WORD $0xf2cee22b // movk x11, #30481, lsl #32
WORD $0xf2f5798b // movk x11, #43980, lsl #48
WORD $0x9bcb7d2b // umulh x11, x9, x11
WORD $0xd35afd6b // lsr x11, x11, #26
WORD $0x1b0aa569 // msub w9, w11, w10, w9
WORD $0x6f00e400 // movi.2d v0, #0000000000000000
WORD $0x6f00e401 // movi.2d v1, #0000000000000000
WORD $0x4e041d61 // mov.s v1[0], w11
WORD $0x0ea12822 // xtn.2s v2, v1
WORD $0x5282eb2a // mov w10, #5977
WORD $0x72ba36ea // movk w10, #53687, lsl #16
WORD $0x0e040d43 // dup.2s v3, w10
WORD $0x2ea3c042 // umull.2d v2, v2, v3
WORD $0x6f530442 // ushr.2d v2, v2, #45
WORD $0x0ea12844 // xtn.2s v4, v2
WORD $0x5284e20a // mov w10, #10000
WORD $0x0e040d45 // dup.2s v5, w10
WORD $0x2ea5c084 // umull.2d v4, v4, v5
WORD $0x6ea48421 // sub.4s v1, v1, v4
WORD $0x4e413841 // zip1.8h v1, v2, v1
WORD $0x4f425421 // shl.2d v1, v1, #2
WORD $0x4e413821 // zip1.8h v1, v1, v1
WORD $0x4e813821 // zip1.4s v1, v1, v1
Lloh42:
WORD $0x10ffcc2a // adr x10, lCPI0_0 $-1660(%rip)
Lloh43:
WORD $0xfd400142 // ldr d2, [x10, lCPI0_0@PAGEOFF] $0(%rip)
WORD $0x2e62c024 // umull.4s v4, v1, v2
WORD $0x6e014021 // ext.16b v1, v1, v1, #8
WORD $0x2e62c021 // umull.4s v1, v1, v2
WORD $0x4e415881 // uzp2.8h v1, v4, v1
Lloh44:
WORD $0x10ffcbaa // adr x10, lCPI0_1 $-1676(%rip)
Lloh45:
WORD $0xfd400144 // ldr d4, [x10, lCPI0_1@PAGEOFF] $0(%rip)
WORD $0x2e64c026 // umull.4s v6, v1, v4
WORD $0x6e014021 // ext.16b v1, v1, v1, #8
WORD $0x2e64c021 // umull.4s v1, v1, v4
WORD $0x4e4158c1 // uzp2.8h v1, v6, v1
WORD $0x4f008546 // movi.8h v6, #10
WORD $0x4e669c27 // mul.8h v7, v1, v6
WORD $0x4f5054e7 // shl.2d v7, v7, #16
WORD $0x6e678421 // sub.8h v1, v1, v7
WORD $0x4e041d20 // mov.s v0[0], w9
WORD $0x0ea12807 // xtn.2s v7, v0
WORD $0x2ea3c0e3 // umull.2d v3, v7, v3
WORD $0x6f530463 // ushr.2d v3, v3, #45
WORD $0x0ea12867 // xtn.2s v7, v3
WORD $0x2ea5c0e5 // umull.2d v5, v7, v5
WORD $0x6ea58400 // sub.4s v0, v0, v5
WORD $0x4e403860 // zip1.8h v0, v3, v0
WORD $0x4f425400 // shl.2d v0, v0, #2
WORD $0x4e403800 // zip1.8h v0, v0, v0
WORD $0x4e803800 // zip1.4s v0, v0, v0
WORD $0x2e62c003 // umull.4s v3, v0, v2
WORD $0x6e004000 // ext.16b v0, v0, v0, #8
WORD $0x2e62c000 // umull.4s v0, v0, v2
WORD $0x4e405860 // uzp2.8h v0, v3, v0
WORD $0x2e64c002 // umull.4s v2, v0, v4
WORD $0x6e004000 // ext.16b v0, v0, v0, #8
WORD $0x2e64c000 // umull.4s v0, v0, v4
WORD $0x4e405840 // uzp2.8h v0, v2, v0
WORD $0x4e669c02 // mul.8h v2, v0, v6
WORD $0x4f505442 // shl.2d v2, v2, #16
WORD $0x6e628400 // sub.8h v0, v0, v2
WORD $0x2e212821 // sqxtun.8b v1, v1
WORD $0x6e212801 // sqxtun2.16b v1, v0
WORD $0x4f01e600 // movi.16b v0, #48
WORD $0x4e208420 // add.16b v0, v1, v0
WORD $0x4e209821 // cmeq.16b v1, v1, #0
Lloh46:
WORD $0x10ffc749 // adr x9, lCPI0_2 $-1816(%rip)
Lloh47:
WORD $0x3dc00122 // ldr q2, [x9, lCPI0_2@PAGEOFF] $0(%rip)
WORD $0x4e221c21 // and.16b v1, v1, v2
Lloh48:
WORD $0x10ffc769 // adr x9, lCPI0_3 $-1812(%rip)
Lloh49:
WORD $0x3dc00122 // ldr q2, [x9, lCPI0_3@PAGEOFF] $0(%rip)
WORD $0x4e020021 // tbl.16b v1, { v1 }, v2
WORD $0x4e71b821 // addv.8h h1, v1
WORD $0x1e260029 // fmov w9, s1
WORD $0x2a2903e9 // mvn w9, w9
WORD $0x32114129 // orr w9, w9, #0xffff8000
WORD $0x5ac00129 // rbit w9, w9
WORD $0x5ac01129 // clz w9, w9
Lloh50:
WORD $0x1000244a // adr x10, _VecShiftShuffles $1160(%rip)
Lloh51:
WORD $0x9100014a // add x10, x10, _VecShiftShuffles@PAGEOFF $0(%rip)
WORD $0x3ce95941 // ldr q1, [x10, w9, uxtw #4]
WORD $0x4f04e5e2 // movi.16b v2, #143
WORD $0x4e221c21 // and.16b v1, v1, v2
WORD $0x4e010000 // tbl.16b v0, { v0 }, v1
WORD $0x3d800100 // str q0, [x8]
WORD $0x52800208 // mov w8, #16
WORD $0x4b090109 // sub w9, w8, w9
WORD $0x11000528 // add w8, w9, #1
WORD $0xaa0803e0 // mov x0, x8
WORD $0xa940fbfd // ldp fp, lr, [sp, #8]
WORD $0x910083ff // add sp, sp, #32
WORD $0xd65f03c0 // ret
LBB0_41:
WORD $0xd28f0ae9 // mov x9, #30807
WORD $0xf2b62269 // movk x9, #45331, lsl #16
WORD $0xf2cca5e9 // movk x9, #25903, lsl #32
WORD $0xf2e734a9 // movk x9, #14757, lsl #48
WORD $0x9bc97c29 // umulh x9, x1, x9
WORD $0xd373fd2b // lsr x11, x9, #51
WORD $0x7100257f // cmp w11, #9
WORD $0x540000a8 // b.hi LBB0_43 $20(%rip)
WORD $0x1100c169 // add w9, w11, #48
WORD $0x39000009 // strb w9, [x0]
WORD $0x52800029 // mov w9, #1
WORD $0x1400001b // b LBB0_46 $108(%rip)
LBB0_43:
WORD $0x71018d7f // cmp w11, #99
WORD $0x540000e8 // b.hi LBB0_45 $28(%rip)
Lloh52:
WORD $0x10001a89 // adr x9, _Digits $848(%rip)
Lloh53:
WORD $0x91000129 // add x9, x9, _Digits@PAGEOFF $0(%rip)
WORD $0x786b5929 // ldrh w9, [x9, w11, uxtw #1]
WORD $0x79000009 // strh w9, [x0]
WORD $0x52800049 // mov w9, #2
WORD $0x14000013 // b LBB0_46 $76(%rip)
LBB0_45:
WORD $0x5280a3e9 // mov w9, #1311
WORD $0x1b097d69 // mul w9, w11, w9
WORD $0x53117d29 // lsr w9, w9, #17
WORD $0x321c052c // orr w12, w9, #0x30
WORD $0x3900000c // strb w12, [x0]
WORD $0x52800c8c // mov w12, #100
WORD $0x1b0cad29 // msub w9, w9, w12, w11
WORD $0x92403d29 // and x9, x9, #0xffff
WORD $0xd37ff929 // lsl x9, x9, #1
Lloh54:
WORD $0x100018ac // adr x12, _Digits $788(%rip)
Lloh55:
WORD $0x9100018c // add x12, x12, _Digits@PAGEOFF $0(%rip)
WORD $0x3869698d // ldrb w13, [x12, x9]
WORD $0x3900040d // strb w13, [x0, #1]
WORD $0x927f3929 // and x9, x9, #0xfffe
WORD $0x8b090189 // add x9, x12, x9
WORD $0x39400529 // ldrb w9, [x9, #1]
WORD $0x39000809 // strb w9, [x0, #2]
WORD $0x52800069 // mov w9, #3
LBB0_46:
WORD $0x9b0a856a // msub x10, x11, x10, x1
WORD $0xd299dfab // mov x11, #52989
WORD $0xf2b08c2b // movk x11, #33889, lsl #16
WORD $0xf2cee22b // movk x11, #30481, lsl #32
WORD $0xf2f5798b // movk x11, #43980, lsl #48
WORD $0x9bcb7d4b // umulh x11, x10, x11
WORD $0xd35afd6b // lsr x11, x11, #26
WORD $0x6f00e400 // movi.2d v0, #0000000000000000
WORD $0x6f00e401 // movi.2d v1, #0000000000000000
WORD $0x4e041d61 // mov.s v1[0], w11
WORD $0x5282eb2c // mov w12, #5977
WORD $0x72ba36ec // movk w12, #53687, lsl #16
WORD $0x0e040d82 // dup.2s v2, w12
WORD $0x0ea12823 // xtn.2s v3, v1
WORD $0x2ea2c063 // umull.2d v3, v3, v2
WORD $0x6f530463 // ushr.2d v3, v3, #45
WORD $0x5284e20c // mov w12, #10000
WORD $0x0e040d84 // dup.2s v4, w12
WORD $0x0ea12865 // xtn.2s v5, v3
WORD $0x2ea4c0a5 // umull.2d v5, v5, v4
WORD $0x6ea58421 // sub.4s v1, v1, v5
WORD $0x4e413861 // zip1.8h v1, v3, v1
WORD $0x4f425421 // shl.2d v1, v1, #2
WORD $0x4e413821 // zip1.8h v1, v1, v1
WORD $0x4e813821 // zip1.4s v1, v1, v1
Lloh56:
WORD $0x10ffbbac // adr x12, lCPI0_0 $-2188(%rip)
Lloh57:
WORD $0xfd400183 // ldr d3, [x12, lCPI0_0@PAGEOFF] $0(%rip)
WORD $0x2e63c025 // umull.4s v5, v1, v3
WORD $0x6e014021 // ext.16b v1, v1, v1, #8
WORD $0x2e63c021 // umull.4s v1, v1, v3
WORD $0x4e4158a1 // uzp2.8h v1, v5, v1
Lloh58:
WORD $0x10ffbb2c // adr x12, lCPI0_1 $-2204(%rip)
Lloh59:
WORD $0xfd400185 // ldr d5, [x12, lCPI0_1@PAGEOFF] $0(%rip)
WORD $0x2e65c026 // umull.4s v6, v1, v5
WORD $0x6e014021 // ext.16b v1, v1, v1, #8
WORD $0x2e65c021 // umull.4s v1, v1, v5
WORD $0x4e4158c1 // uzp2.8h v1, v6, v1
WORD $0x4f008546 // movi.8h v6, #10
WORD $0x4e669c27 // mul.8h v7, v1, v6
WORD $0x4f5054e7 // shl.2d v7, v7, #16
WORD $0x6e678421 // sub.8h v1, v1, v7
WORD $0x1b08a968 // msub w8, w11, w8, w10
WORD $0x4e041d00 // mov.s v0[0], w8
WORD $0x0ea12807 // xtn.2s v7, v0
WORD $0x2ea2c0e2 // umull.2d v2, v7, v2
WORD $0x6f530442 // ushr.2d v2, v2, #45
WORD $0x0ea12847 // xtn.2s v7, v2
WORD $0x2ea4c0e4 // umull.2d v4, v7, v4
WORD $0x6ea48400 // sub.4s v0, v0, v4
WORD $0x4e403840 // zip1.8h v0, v2, v0
WORD $0x4f425400 // shl.2d v0, v0, #2
WORD $0x4e403800 // zip1.8h v0, v0, v0
WORD $0x4e803800 // zip1.4s v0, v0, v0
WORD $0x2e63c002 // umull.4s v2, v0, v3
WORD $0x6e004000 // ext.16b v0, v0, v0, #8
WORD $0x2e63c000 // umull.4s v0, v0, v3
WORD $0x4e405840 // uzp2.8h v0, v2, v0
WORD $0x2e65c002 // umull.4s v2, v0, v5
WORD $0x6e004000 // ext.16b v0, v0, v0, #8
WORD $0x2e65c000 // umull.4s v0, v0, v5
WORD $0x4e405840 // uzp2.8h v0, v2, v0
WORD $0x4e669c02 // mul.8h v2, v0, v6
WORD $0x4f505442 // shl.2d v2, v2, #16
WORD $0x6e628400 // sub.8h v0, v0, v2
WORD $0x2e212821 // sqxtun.8b v1, v1
WORD $0x6e212801 // sqxtun2.16b v1, v0
WORD $0x4f01e600 // movi.16b v0, #48
WORD $0x4e208420 // add.16b v0, v1, v0
WORD $0x3ca94800 // str q0, [x0, w9, uxtw]
WORD $0x321c0128 // orr w8, w9, #0x10
WORD $0xaa0803e0 // mov x0, x8
WORD $0xa940fbfd // ldp fp, lr, [sp, #8]
WORD $0x910083ff // add sp, sp, #32
WORD $0xd65f03c0 // ret
LBB0_47:
WORD $0xd28f0aeb // mov x11, #30807
WORD $0xf2b6226b // movk x11, #45331, lsl #16
WORD $0xf2cca5eb // movk x11, #25903, lsl #32
WORD $0xf2e734ab // movk x11, #14757, lsl #48
WORD $0x9bcb7d2b // umulh x11, x9, x11
WORD $0xd373fd6d // lsr x13, x11, #51
WORD $0x710025bf // cmp w13, #9
WORD $0x540000a8 // b.hi LBB0_49 $20(%rip)
WORD $0x1100c1ab // add w11, w13, #48
WORD $0x3900010b // strb w11, [x8]
WORD $0x5280002b // mov w11, #1
WORD $0x1400001c // b LBB0_52 $112(%rip)
LBB0_49:
WORD $0x71018dbf // cmp w13, #99
WORD $0x540000e8 // b.hi LBB0_51 $28(%rip)
Lloh60:
WORD $0x10000c8b // adr x11, _Digits $400(%rip)
Lloh61:
WORD $0x9100016b // add x11, x11, _Digits@PAGEOFF $0(%rip)
WORD $0x786d596b // ldrh w11, [x11, w13, uxtw #1]
WORD $0x7800100b // sturh w11, [x0, #1]
WORD $0x5280004b // mov w11, #2
WORD $0x14000014 // b LBB0_52 $80(%rip)
LBB0_51:
WORD $0x53023dab // ubfx w11, w13, #2, #14
WORD $0x52828f6e // mov w14, #5243
WORD $0x1b0e7d6b // mul w11, w11, w14
WORD $0x53117d6b // lsr w11, w11, #17
WORD $0x321c056e // orr w14, w11, #0x30
WORD $0x3900040e // strb w14, [x0, #1]
WORD $0x52800c8e // mov w14, #100
WORD $0x1b0eb56b // msub w11, w11, w14, w13
WORD $0x92403d6b // and x11, x11, #0xffff
WORD $0xd37ff96b // lsl x11, x11, #1
Lloh62:
WORD $0x10000a8e // adr x14, _Digits $336(%rip)
Lloh63:
WORD $0x910001ce // add x14, x14, _Digits@PAGEOFF $0(%rip)
WORD $0x386b69cf // ldrb w15, [x14, x11]
WORD $0x3900080f // strb w15, [x0, #2]
WORD $0x927f396b // and x11, x11, #0xfffe
WORD $0x8b0b01cb // add x11, x14, x11
WORD $0x3940056b // ldrb w11, [x11, #1]
WORD $0x39000c0b // strb w11, [x0, #3]
WORD $0x5280006b // mov w11, #3
LBB0_52:
WORD $0x9b0ca5a9 // msub x9, x13, x12, x9
WORD $0xd299dfac // mov x12, #52989
WORD $0xf2b08c2c // movk x12, #33889, lsl #16
WORD $0xf2cee22c // movk x12, #30481, lsl #32
WORD $0xf2f5798c // movk x12, #43980, lsl #48
WORD $0x9bcc7d2c // umulh x12, x9, x12
WORD $0xd35afd8c // lsr x12, x12, #26
WORD $0x6f00e400 // movi.2d v0, #0000000000000000
WORD $0x6f00e401 // movi.2d v1, #0000000000000000
WORD $0x4e041d81 // mov.s v1[0], w12
WORD $0x5282eb2d // mov w13, #5977
WORD $0x72ba36ed // movk w13, #53687, lsl #16
WORD $0x0e040da2 // dup.2s v2, w13
WORD $0x0ea12823 // xtn.2s v3, v1
WORD $0x2ea2c063 // umull.2d v3, v3, v2
WORD $0x6f530463 // ushr.2d v3, v3, #45
WORD $0x5284e20d // mov w13, #10000
WORD $0x0e040da4 // dup.2s v4, w13
WORD $0x0ea12865 // xtn.2s v5, v3
WORD $0x2ea4c0a5 // umull.2d v5, v5, v4
WORD $0x6ea58421 // sub.4s v1, v1, v5
WORD $0x4e413861 // zip1.8h v1, v3, v1
WORD $0x4f425421 // shl.2d v1, v1, #2
WORD $0x4e413821 // zip1.8h v1, v1, v1
WORD $0x4e813821 // zip1.4s v1, v1, v1
Lloh64:
WORD $0x10ffad8d // adr x13, lCPI0_0 $-2640(%rip)
Lloh65:
WORD $0xfd4001a3 // ldr d3, [x13, lCPI0_0@PAGEOFF] $0(%rip)
WORD $0x2e63c025 // umull.4s v5, v1, v3
WORD $0x6e014021 // ext.16b v1, v1, v1, #8
WORD $0x2e63c021 // umull.4s v1, v1, v3
WORD $0x4e4158a1 // uzp2.8h v1, v5, v1
Lloh66:
WORD $0x10ffad0d // adr x13, lCPI0_1 $-2656(%rip)
Lloh67:
WORD $0xfd4001a5 // ldr d5, [x13, lCPI0_1@PAGEOFF] $0(%rip)
WORD $0x2e65c026 // umull.4s v6, v1, v5
WORD $0x6e014021 // ext.16b v1, v1, v1, #8
WORD $0x2e65c021 // umull.4s v1, v1, v5
WORD $0x4e4158c1 // uzp2.8h v1, v6, v1
WORD $0x4f008546 // movi.8h v6, #10
WORD $0x4e669c27 // mul.8h v7, v1, v6
WORD $0x4f5054e7 // shl.2d v7, v7, #16
WORD $0x6e678421 // sub.8h v1, v1, v7
WORD $0x1b0aa589 // msub w9, w12, w10, w9
WORD $0x4e041d20 // mov.s v0[0], w9
WORD $0x0ea12807 // xtn.2s v7, v0
WORD $0x2ea2c0e2 // umull.2d v2, v7, v2
WORD $0x6f530442 // ushr.2d v2, v2, #45
WORD $0x0ea12847 // xtn.2s v7, v2
WORD $0x2ea4c0e4 // umull.2d v4, v7, v4
WORD $0x6ea48400 // sub.4s v0, v0, v4
WORD $0x4e403840 // zip1.8h v0, v2, v0
WORD $0x4f425400 // shl.2d v0, v0, #2
WORD $0x4e403800 // zip1.8h v0, v0, v0
WORD $0x4e803800 // zip1.4s v0, v0, v0
WORD $0x2e63c002 // umull.4s v2, v0, v3
WORD $0x6e004000 // ext.16b v0, v0, v0, #8
WORD $0x2e63c000 // umull.4s v0, v0, v3
WORD $0x4e405840 // uzp2.8h v0, v2, v0
WORD $0x2e65c002 // umull.4s v2, v0, v5
WORD $0x6e004000 // ext.16b v0, v0, v0, #8
WORD $0x2e65c000 // umull.4s v0, v0, v5
WORD $0x4e405840 // uzp2.8h v0, v2, v0
WORD $0x4e669c02 // mul.8h v2, v0, v6
WORD $0x4f505442 // shl.2d v2, v2, #16
WORD $0x6e628400 // sub.8h v0, v0, v2
WORD $0x2e212821 // sqxtun.8b v1, v1
WORD $0x6e212801 // sqxtun2.16b v1, v0
WORD $0x4f01e600 // movi.16b v0, #48
WORD $0x4e208420 // add.16b v0, v1, v0
WORD $0x3cab4900 // str q0, [x8, w11, uxtw]
WORD $0x321c0169 // orr w9, w11, #0x10
WORD $0x11000528 // add w8, w9, #1
WORD $0xaa0803e0 // mov x0, x8
WORD $0xa940fbfd // ldp fp, lr, [sp, #8]
WORD $0x910083ff // add sp, sp, #32
WORD $0xd65f03c0 // ret
_Digits:
WORD $0x31303030 // .ascii 4, '0001020304050607'
WORD $0x33303230 // .ascii 4, '0203040506070809'
WORD $0x35303430 // .ascii 4, '0405060708091011'
WORD $0x37303630 // .ascii 4, '0607080910111213'
WORD $0x39303830 // .ascii 4, '0809101112131415'
WORD $0x31313031 // .ascii 4, '1011121314151617'
WORD $0x33313231 // .ascii 4, '1213141516171819'
WORD $0x35313431 // .ascii 4, '1415161718192021'
WORD $0x37313631 // .ascii 4, '1617181920212223'
WORD $0x39313831 // .ascii 4, '1819202122232425'
WORD $0x31323032 // .ascii 4, '2021222324252627'
WORD $0x33323232 // .ascii 4, '2223242526272829'
WORD $0x35323432 // .ascii 4, '2425262728293031'
WORD $0x37323632 // .ascii 4, '2627282930313233'
WORD $0x39323832 // .ascii 4, '2829303132333435'
WORD $0x31333033 // .ascii 4, '3031323334353637'
WORD $0x33333233 // .ascii 4, '3233343536373839'
WORD $0x35333433 // .ascii 4, '3435363738394041'
WORD $0x37333633 // .ascii 4, '3637383940414243'
WORD $0x39333833 // .ascii 4, '3839404142434445'
WORD $0x31343034 // .ascii 4, '4041424344454647'
WORD $0x33343234 // .ascii 4, '4243444546474849'
WORD $0x35343434 // .ascii 4, '4445464748495051'
WORD $0x37343634 // .ascii 4, '4647484950515253'
WORD $0x39343834 // .ascii 4, '4849505152535455'
WORD $0x31353035 // .ascii 4, '5051525354555657'
WORD $0x33353235 // .ascii 4, '5253545556575859'
WORD $0x35353435 // .ascii 4, '5455565758596061'
WORD $0x37353635 // .ascii 4, '5657585960616263'
WORD $0x39353835 // .ascii 4, '5859606162636465'
WORD $0x31363036 // .ascii 4, '6061626364656667'
WORD $0x33363236 // .ascii 4, '6263646566676869'
WORD $0x35363436 // .ascii 4, '6465666768697071'
WORD $0x37363636 // .ascii 4, '6667686970717273'
WORD $0x39363836 // .ascii 4, '6869707172737475'
WORD $0x31373037 // .ascii 4, '7071727374757677'
WORD $0x33373237 // .ascii 4, '7273747576777879'
WORD $0x35373437 // .ascii 4, '7475767778798081'
WORD $0x37373637 // .ascii 4, '7677787980818283'
WORD $0x39373837 // .ascii 4, '7879808182838485'
WORD $0x31383038 // .ascii 4, '8081828384858687'
WORD $0x33383238 // .ascii 4, '8283848586878889'
WORD $0x35383438 // .ascii 4, '8485868788899091'
WORD $0x37383638 // .ascii 4, '8687888990919293'
WORD $0x39383838 // .ascii 4, '8889909192939495'
WORD $0x31393039 // .ascii 4, '9091929394959697'
WORD $0x33393239 // .ascii 4, '9293949596979899'
WORD $0x35393439 // .ascii 4, '949596979899'
WORD $0x37393639 // .ascii 4, '96979899'
WORD $0x39393839 // .ascii 4, '9899'
// .p2align 4, 0x00
_VecShiftShuffles:
WORD $0x03020100 // .ascii 4, '\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f'
WORD $0x07060504 // .ascii 4, '\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x01\x02\x03\x04'
WORD $0x0b0a0908 // .ascii 4, '\x08\t\n\x0b\x0c\r\x0e\x0f\x01\x02\x03\x04\x05\x06\x07\x08'
WORD $0x0f0e0d0c // .ascii 4, '\x0c\r\x0e\x0f\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c'
WORD $0x04030201 // .ascii 4, '\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\xff'
WORD $0x08070605 // .ascii 4, '\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\xff\x02\x03\x04\x05'
WORD $0x0c0b0a09 // .ascii 4, '\t\n\x0b\x0c\r\x0e\x0f\xff\x02\x03\x04\x05\x06\x07\x08\t'
WORD $0xff0f0e0d // .ascii 4, '\r\x0e\x0f\xff\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r'
WORD $0x05040302 // .ascii 4, '\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\xff\xff'
WORD $0x09080706 // .ascii 4, '\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\xff\xff\x03\x04\x05\x06'
WORD $0x0d0c0b0a // .ascii 4, '\n\x0b\x0c\r\x0e\x0f\xff\xff\x03\x04\x05\x06\x07\x08\t\n'
WORD $0xffff0f0e // .ascii 4, '\x0e\x0f\xff\xff\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e'
WORD $0x06050403 // .ascii 4, '\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\xff\xff\xff'
WORD $0x0a090807 // .ascii 4, '\x07\x08\t\n\x0b\x0c\r\x0e\x0f\xff\xff\xff\x04\x05\x06\x07'
WORD $0x0e0d0c0b // .ascii 4, '\x0b\x0c\r\x0e\x0f\xff\xff\xff\x04\x05\x06\x07\x08\t\n\x0b'
WORD $0xffffff0f // .ascii 4, '\x0f\xff\xff\xff\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f'
WORD $0x07060504 // .ascii 4, '\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\xff\xff\xff\xff'
WORD $0x0b0a0908 // .ascii 4, '\x08\t\n\x0b\x0c\r\x0e\x0f\xff\xff\xff\xff\x05\x06\x07\x08'
WORD $0x0f0e0d0c // .ascii 4, '\x0c\r\x0e\x0f\xff\xff\xff\xff\x05\x06\x07\x08\t\n\x0b\x0c'
WORD $0xffffffff // .ascii 4, '\xff\xff\xff\xff\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\xff'
WORD $0x08070605 // .ascii 4, '\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\xff\xff\xff\xff\xff'
WORD $0x0c0b0a09 // .ascii 4, '\t\n\x0b\x0c\r\x0e\x0f\xff\xff\xff\xff\xff\x06\x07\x08\t'
WORD $0xff0f0e0d // .ascii 4, '\r\x0e\x0f\xff\xff\xff\xff\xff\x06\x07\x08\t\n\x0b\x0c\r'
WORD $0xffffffff // .ascii 4, '\xff\xff\xff\xff\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\xff\xff'
WORD $0x09080706 // .ascii 4, '\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\xff\xff\xff\xff\xff\xff'
WORD $0x0d0c0b0a // .ascii 4, '\n\x0b\x0c\r\x0e\x0f\xff\xff\xff\xff\xff\xff\x07\x08\t\n'
WORD $0xffff0f0e // .ascii 4, '\x0e\x0f\xff\xff\xff\xff\xff\xff\x07\x08\t\n\x0b\x0c\r\x0e'
WORD $0xffffffff // .ascii 4, '\xff\xff\xff\xff\x07\x08\t\n\x0b\x0c\r\x0e\x0f\xff\xff\xff'
WORD $0x0a090807 // .ascii 4, '\x07\x08\t\n\x0b\x0c\r\x0e\x0f\xff\xff\xff\xff\xff\xff\xff'
WORD $0x0e0d0c0b // .ascii 4, '\x0b\x0c\r\x0e\x0f\xff\xff\xff\xff\xff\xff\xff\x08\t\n\x0b'
WORD $0xffffff0f // .ascii 4, '\x0f\xff\xff\xff\xff\xff\xff\xff\x08\t\n\x0b\x0c\r\x0e\x0f'
WORD $0xffffffff // .ascii 4, '\xff\xff\xff\xff\x08\t\n\x0b\x0c\r\x0e\x0f\xff\xff\xff\xff'
WORD $0x0b0a0908 // .ascii 4, '\x08\t\n\x0b\x0c\r\x0e\x0f\xff\xff\xff\xff\xff\xff\xff\xff'
WORD $0x0f0e0d0c // .ascii 4, '\x0c\r\x0e\x0f\xff\xff\xff\xff\xff\xff\xff\xff'
WORD $0xffffffff // .ascii 4, '\xff\xff\xff\xff\xff\xff\xff\xff'
WORD $0xffffffff // .ascii 4, '\xff\xff\xff\xff'
TEXT ·__i64toa(SB), NOSPLIT, $0-24
NO_LOCAL_POINTERS
_entry:
MOVD 16(g), R16
SUB $96, RSP, R17
CMP R16, R17
BLS _stack_grow
_i64toa:
MOVD out+0(FP), R0
MOVD val+8(FP), R1
MOVD ·_subr__i64toa(SB), R11
WORD $0x1000005e // adr x30, .+8
JMP (R11)
MOVD R0, ret+16(FP)
RET
_stack_grow:
MOVD R30, R3
CALL runtime·morestack_noctxt<>(SB)
JMP _entry

@ -0,0 +1,25 @@
// +build !noasm !appengine
// Code generated by asm2asm, DO NOT EDIT.
package neon
//go:nosplit
//go:noescape
//goland:noinspection ALL
func __i64toa_entry__() uintptr
var (
_subr__i64toa uintptr = __i64toa_entry__() + 48
)
const (
_stack__i64toa = 32
)
var (
_ = _subr__i64toa
)
const (
_ = _stack__i64toa
)

@ -0,0 +1,37 @@
// Code generated by Makefile, DO NOT EDIT.
// Code generated by Makefile, DO NOT EDIT.
/*
* Copyright 2021 ByteDance Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package neon
import (
`unsafe`
// `github.com/bytedance/sonic/internal/native/types`
)
//go:nosplit
func lspace(sp unsafe.Pointer, nb int, off int) (ret int) {
return __lspace(sp, nb, off)
}
//go:nosplit
//go:noescape
//goland:noinspection GoUnusedParameter
func __lspace(sp unsafe.Pointer, nb int, off int) (ret int)

@ -0,0 +1,68 @@
// +build !noasm !appengine
// Code generated by asm2asm, DO NOT EDIT.
#include "go_asm.h"
#include "funcdata.h"
#include "textflag.h"
TEXT ·__lspace_entry__(SB), NOSPLIT, $16
NO_LOCAL_POINTERS
WORD $0x100000a0 // adr x0, .+20
MOVD R0, ret(FP)
RET
// .p2align 2, 0x00
_lspace:
WORD $0xd10083ff // sub sp, sp, #32
WORD $0xa900fbfd // stp fp, lr, [sp, #8]
WORD $0xa93ffbfd // stp fp, lr, [sp, #-8]
WORD $0xd10023fd // sub fp, sp, #8
WORD $0xeb02003f // cmp x1, x2
WORD $0x54000061 // b.ne LBB0_2 $12(%rip)
WORD $0x8b020008 // add x8, x0, x2
WORD $0x1400000e // b LBB0_5 $56(%rip)
LBB0_2:
WORD $0x8b010008 // add x8, x0, x1
WORD $0x52800029 // mov w9, #1
WORD $0xd284c00a // mov x10, #9728
WORD $0xf2c0002a // movk x10, #1, lsl #32
LBB0_3:
WORD $0x3862680b // ldrb w11, [x0, x2]
WORD $0x7100817f // cmp w11, #32
WORD $0x9acb212b // lsl x11, x9, x11
WORD $0x8a0a016b // and x11, x11, x10
WORD $0xfa409964 // ccmp x11, #0, #4, ls
WORD $0x540000a0 // b.eq LBB0_6 $20(%rip)
WORD $0x91000442 // add x2, x2, #1
WORD $0xeb02003f // cmp x1, x2
WORD $0x54ffff01 // b.ne LBB0_3 $-32(%rip)
LBB0_5:
WORD $0xcb000102 // sub x2, x8, x0
LBB0_6:
WORD $0xaa0203e0 // mov x0, x2
WORD $0xa940fbfd // ldp fp, lr, [sp, #8]
WORD $0x910083ff // add sp, sp, #32
WORD $0xd65f03c0 // ret
TEXT ·__lspace(SB), NOSPLIT, $0-32
NO_LOCAL_POINTERS
_entry:
MOVD 16(g), R16
SUB $96, RSP, R17
CMP R16, R17
BLS _stack_grow
_lspace:
MOVD sp+0(FP), R0
MOVD nb+8(FP), R1
MOVD off+16(FP), R2
MOVD ·_subr__lspace(SB), R11
WORD $0x1000005e // adr x30, .+8
JMP (R11)
MOVD R0, ret+24(FP)
RET
_stack_grow:
MOVD R30, R3
CALL runtime·morestack_noctxt<>(SB)
JMP _entry

@ -0,0 +1,25 @@
// +build !noasm !appengine
// Code generated by asm2asm, DO NOT EDIT.
package neon
//go:nosplit
//go:noescape
//goland:noinspection ALL
func __lspace_entry__() uintptr
var (
_subr__lspace uintptr = __lspace_entry__() + 0
)
const (
_stack__lspace = 32
)
var (
_ = _subr__lspace
)
const (
_ = _stack__lspace
)

@ -0,0 +1,49 @@
// Code generated by Makefile, DO NOT EDIT.
/*
* Copyright 2021 ByteDance Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package neon
var (
S_f64toa = _subr__f64toa
S_f32toa = _subr__f32toa
S_i64toa = _subr__i64toa
S_u64toa = _subr__u64toa
S_lspace = _subr__lspace
)
var (
S_quote = _subr__quote
S_unquote = _subr__unquote
)
var (
S_value = _subr__value
S_vstring = _subr__vstring
S_vnumber = _subr__vnumber
S_vsigned = _subr__vsigned
S_vunsigned = _subr__vunsigned
)
var (
S_skip_one = _subr__skip_one
S_skip_one_fast = _subr__skip_one_fast
S_skip_array = _subr__skip_array
S_skip_object = _subr__skip_object
S_skip_number = _subr__skip_number
S_get_by_path = _subr__get_by_path
)

@ -0,0 +1,37 @@
// Code generated by Makefile, DO NOT EDIT.
// Code generated by Makefile, DO NOT EDIT.
/*
* Copyright 2021 ByteDance Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package neon
import (
`unsafe`
// `github.com/bytedance/sonic/internal/native/types`
)
//go:nosplit
func quote(sp unsafe.Pointer, nb int, dp unsafe.Pointer, dn *int, flags uint64) (ret int) {
return __quote(sp, nb, dp, dn, flags)
}
//go:nosplit
//go:noescape
//goland:noinspection GoUnusedParameter
func __quote(sp unsafe.Pointer, nb int, dp unsafe.Pointer, dn *int, flags uint64) (ret int)

File diff suppressed because it is too large Load Diff

@ -0,0 +1,25 @@
// +build !noasm !appengine
// Code generated by asm2asm, DO NOT EDIT.
package neon
//go:nosplit
//go:noescape
//goland:noinspection ALL
func __quote_entry__() uintptr
var (
_subr__quote uintptr = __quote_entry__() + 32
)
const (
_stack__quote = 32
)
var (
_ = _subr__quote
)
const (
_ = _stack__quote
)

@ -0,0 +1,37 @@
// Code generated by Makefile, DO NOT EDIT.
// Code generated by Makefile, DO NOT EDIT.
/*
* Copyright 2021 ByteDance Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package neon
import (
// `unsafe`
`github.com/bytedance/sonic/internal/native/types`
)
//go:nosplit
func skip_array(s *string, p *int, m *types.StateMachine, flags uint64) (ret int) {
return __skip_array(s, p, m, flags)
}
//go:nosplit
//go:noescape
//goland:noinspection GoUnusedParameter
func __skip_array(s *string, p *int, m *types.StateMachine, flags uint64) (ret int)

File diff suppressed because it is too large Load Diff

@ -0,0 +1,25 @@
// +build !noasm !appengine
// Code generated by asm2asm, DO NOT EDIT.
package neon
//go:nosplit
//go:noescape
//goland:noinspection ALL
func __skip_array_entry__() uintptr
var (
_subr__skip_array uintptr = __skip_array_entry__() + 48
)
const (
_stack__skip_array = 112
)
var (
_ = _subr__skip_array
)
const (
_ = _stack__skip_array
)

@ -0,0 +1,31 @@
// Code generated by Makefile, DO NOT EDIT.
// Code generated by Makefile, DO NOT EDIT.
/*
* Copyright 2021 ByteDance Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package neon
//go:nosplit
func skip_number(s *string, p *int) (ret int) {
return __skip_number(s, p)
}
//go:nosplit
//go:noescape
//goland:noinspection GoUnusedParameter
func __skip_number(s *string, p *int) (ret int)

@ -0,0 +1,373 @@
// +build !noasm !appengine
// Code generated by asm2asm, DO NOT EDIT.
#include "go_asm.h"
#include "funcdata.h"
#include "textflag.h"
TEXT ·__skip_number_entry__(SB), NOSPLIT, $32
NO_LOCAL_POINTERS
WORD $0x100000a0 // adr x0, .+20
MOVD R0, ret(FP)
RET
// .p2align 4, 0x00
lCPI0_0:
WORD $0x08040201
WORD $0x80402010
WORD $0x08040201
WORD $0x80402010
// // .byte 1
// .byte 2
// .byte 4
// .byte 8
// .byte 16
// .byte 32
// .byte 64
// .byte 128
// .byte 1
// .byte 2
// .byte 4
// .byte 8
// .byte 16
// .byte 32
// .byte 64
// .byte 128
lCPI0_1:
WORD $0x09010800
WORD $0x0b030a02
WORD $0x0d050c04
WORD $0x0f070e06
// // .byte 0
// .byte 8
// .byte 1
// .byte 9
// .byte 2
// .byte 10
// .byte 3
// .byte 11
// .byte 4
// .byte 12
// .byte 5
// .byte 13
// .byte 6
// .byte 14
// .byte 7
// .byte 15
_skip_number:
WORD $0xd100c3ff // sub sp, sp, #48
WORD $0xa900cff4 // stp x20, x19, [sp, #8]
WORD $0xa901fbfd // stp fp, lr, [sp, #24]
WORD $0xa93ffbfd // stp fp, lr, [sp, #-8]
WORD $0xd10023fd // sub fp, sp, #8
WORD $0xaa0003e8 // mov x8, x0
WORD $0xf9400020 // ldr x0, [x1]
WORD $0xa9402909 // ldp x9, x10, [x8]
WORD $0x8b000128 // add x8, x9, x0
WORD $0xaa0803eb // mov x11, x8
WORD $0x3840156c // ldrb w12, [x11], #1
WORD $0x7100b59f // cmp w12, #45
WORD $0x1a9f17ed // cset w13, eq
WORD $0x9a8b1108 // csel x8, x8, x11, ne
WORD $0xcb00014a // sub x10, x10, x0
WORD $0xeb0d014e // subs x14, x10, x13
WORD $0x54001c40 // b.eq LBB0_59 $904(%rip)
WORD $0x3940010a // ldrb w10, [x8]
WORD $0x5100e94b // sub w11, w10, #58
WORD $0x3100297f // cmn w11, #10
WORD $0x540017a3 // b.lo LBB0_52 $756(%rip)
WORD $0x7100c15f // cmp w10, #48
WORD $0x540001e1 // b.ne LBB0_6 $60(%rip)
WORD $0xf10005df // cmp x14, #1
WORD $0x54000061 // b.ne LBB0_5 $12(%rip)
LBB0_4:
WORD $0x5280002d // mov w13, #1
WORD $0x140000a9 // b LBB0_47 $676(%rip)
LBB0_5:
WORD $0x3940050a // ldrb w10, [x8, #1]
WORD $0x5100b94a // sub w10, w10, #46
WORD $0x7100dd5f // cmp w10, #55
WORD $0x5280002b // mov w11, #1
WORD $0x9aca216a // lsl x10, x11, x10
WORD $0xb20903eb // mov x11, #36028797027352576
WORD $0xf280002b // movk x11, #1
WORD $0x8a0b014a // and x10, x10, x11
WORD $0xfa409944 // ccmp x10, #0, #4, ls
WORD $0x54fffea0 // b.eq LBB0_4 $-44(%rip)
LBB0_6:
WORD $0xf10041df // cmp x14, #16
WORD $0x54001a63 // b.lo LBB0_60 $844(%rip)
WORD $0xd2800010 // mov x16, #0
WORD $0xd280000f // mov x15, #0
WORD $0x9280000a // mov x10, #-1
WORD $0x4f01e5c0 // movi.16b v0, #46
WORD $0x4f01e561 // movi.16b v1, #43
WORD $0x4f01e5a2 // movi.16b v2, #45
WORD $0x4f06e603 // movi.16b v3, #208
WORD $0x4f00e544 // movi.16b v4, #10
Lloh0:
WORD $0x10fff92b // adr x11, lCPI0_0 $-220(%rip)
Lloh1:
WORD $0x3dc00165 // ldr q5, [x11, lCPI0_0@PAGEOFF] $0(%rip)
WORD $0x4f06e7e6 // movi.16b v6, #223
WORD $0x4f02e4a7 // movi.16b v7, #69
Lloh2:
WORD $0x10fff92b // adr x11, lCPI0_1 $-220(%rip)
Lloh3:
WORD $0x3dc00170 // ldr q16, [x11, lCPI0_1@PAGEOFF] $0(%rip)
WORD $0x12800011 // mov w17, #-1
WORD $0x9280000c // mov x12, #-1
WORD $0x9280000b // mov x11, #-1
LBB0_8:
WORD $0x3cef6911 // ldr q17, [x8, x15]
WORD $0x6e208e32 // cmeq.16b v18, v17, v0
WORD $0x6e218e33 // cmeq.16b v19, v17, v1
WORD $0x6e228e34 // cmeq.16b v20, v17, v2
WORD $0x4e238635 // add.16b v21, v17, v3
WORD $0x6e353495 // cmhi.16b v21, v4, v21
WORD $0x4e261e31 // and.16b v17, v17, v6
WORD $0x6e278e31 // cmeq.16b v17, v17, v7
WORD $0x4eb41e73 // orr.16b v19, v19, v20
WORD $0x4eb21eb4 // orr.16b v20, v21, v18
WORD $0x4eb31e35 // orr.16b v21, v17, v19
WORD $0x4eb51e94 // orr.16b v20, v20, v21
WORD $0x4e251e52 // and.16b v18, v18, v5
WORD $0x4e100252 // tbl.16b v18, { v18 }, v16
WORD $0x4e71ba52 // addv.8h h18, v18
WORD $0x1e260243 // fmov w3, s18
WORD $0x4e251e31 // and.16b v17, v17, v5
WORD $0x4e100231 // tbl.16b v17, { v17 }, v16
WORD $0x4e71ba31 // addv.8h h17, v17
WORD $0x1e260224 // fmov w4, s17
WORD $0x4e251e71 // and.16b v17, v19, v5
WORD $0x4e100231 // tbl.16b v17, { v17 }, v16
WORD $0x4e71ba31 // addv.8h h17, v17
WORD $0x1e260226 // fmov w6, s17
WORD $0x4e251e91 // and.16b v17, v20, v5
WORD $0x4e100231 // tbl.16b v17, { v17 }, v16
WORD $0x4e71ba31 // addv.8h h17, v17
WORD $0x1e260222 // fmov w2, s17
WORD $0x2a2203e2 // mvn w2, w2
WORD $0x32103c42 // orr w2, w2, #0xffff0000
WORD $0x5ac00042 // rbit w2, w2
WORD $0x5ac01042 // clz w2, w2
WORD $0x1ac22225 // lsl w5, w17, w2
WORD $0x0a250067 // bic w7, w3, w5
WORD $0x0a250093 // bic w19, w4, w5
WORD $0x0a2500d4 // bic w20, w6, w5
WORD $0x7100405f // cmp w2, #16
WORD $0x1a870065 // csel w5, w3, w7, eq
WORD $0x1a930084 // csel w4, w4, w19, eq
WORD $0x1a9400c3 // csel w3, w6, w20, eq
WORD $0x510004a6 // sub w6, w5, #1
WORD $0x6a0500c6 // ands w6, w6, w5
WORD $0x54001041 // b.ne LBB0_55 $520(%rip)
WORD $0x51000486 // sub w6, w4, #1
WORD $0x6a0400c6 // ands w6, w6, w4
WORD $0x54000fe1 // b.ne LBB0_55 $508(%rip)
WORD $0x51000466 // sub w6, w3, #1
WORD $0x6a0300c6 // ands w6, w6, w3
WORD $0x54000f81 // b.ne LBB0_55 $496(%rip)
WORD $0x340000c5 // cbz w5, LBB0_14 $24(%rip)
WORD $0x5ac000a5 // rbit w5, w5
WORD $0x5ac010a5 // clz w5, w5
WORD $0xb100057f // cmn x11, #1
WORD $0x54000f81 // b.ne LBB0_56 $496(%rip)
WORD $0x8b0501eb // add x11, x15, x5
LBB0_14:
WORD $0x340000c4 // cbz w4, LBB0_17 $24(%rip)
WORD $0x5ac00084 // rbit w4, w4
WORD $0x5ac01084 // clz w4, w4
WORD $0xb100059f // cmn x12, #1
WORD $0x54000f21 // b.ne LBB0_57 $484(%rip)
WORD $0x8b0401ec // add x12, x15, x4
LBB0_17:
WORD $0x340000c3 // cbz w3, LBB0_20 $24(%rip)
WORD $0x5ac00063 // rbit w3, w3
WORD $0x5ac01063 // clz w3, w3
WORD $0xb100055f // cmn x10, #1
WORD $0x54000ec1 // b.ne LBB0_58 $472(%rip)
WORD $0x8b0301ea // add x10, x15, x3
LBB0_20:
WORD $0x7100405f // cmp w2, #16
WORD $0x54000621 // b.ne LBB0_35 $196(%rip)
WORD $0x910041ef // add x15, x15, #16
WORD $0xd1004210 // sub x16, x16, #16
WORD $0x8b1001c2 // add x2, x14, x16
WORD $0xf1003c5f // cmp x2, #15
WORD $0x54fff6e8 // b.hi LBB0_8 $-292(%rip)
WORD $0x8b0f0110 // add x16, x8, x15
WORD $0xeb0f01df // cmp x14, x15
WORD $0x54000560 // b.eq LBB0_36 $172(%rip)
LBB0_23:
WORD $0x8b02020e // add x14, x16, x2
WORD $0xaa3003ef // mvn x15, x16
WORD $0x8b090011 // add x17, x0, x9
WORD $0x8b1101ef // add x15, x15, x17
WORD $0x8b0d01ed // add x13, x15, x13
WORD $0xcb08020f // sub x15, x16, x8
WORD $0xaa1003f1 // mov x17, x16
WORD $0x14000009 // b LBB0_26 $36(%rip)
LBB0_24:
WORD $0xb100059f // cmn x12, #1
WORD $0xaa0f03ec // mov x12, x15
WORD $0x54000661 // b.ne LBB0_46 $204(%rip)
LBB0_25:
WORD $0xd10005ad // sub x13, x13, #1
WORD $0x910005ef // add x15, x15, #1
WORD $0xaa1103f0 // mov x16, x17
WORD $0xd1000442 // sub x2, x2, #1
WORD $0xb4000882 // cbz x2, LBB0_53 $272(%rip)
LBB0_26:
WORD $0x38401623 // ldrb w3, [x17], #1
WORD $0x5100c064 // sub w4, w3, #48
WORD $0x7100289f // cmp w4, #10
WORD $0x54ffff03 // b.lo LBB0_25 $-32(%rip)
WORD $0x7100b47f // cmp w3, #45
WORD $0x5400016d // b.le LBB0_32 $44(%rip)
WORD $0x7101947f // cmp w3, #101
WORD $0x54fffe20 // b.eq LBB0_24 $-60(%rip)
WORD $0x7101147f // cmp w3, #69
WORD $0x54fffde0 // b.eq LBB0_24 $-68(%rip)
WORD $0x7100b87f // cmp w3, #46
WORD $0x540001e1 // b.ne LBB0_36 $60(%rip)
WORD $0xb100057f // cmn x11, #1
WORD $0xaa0f03eb // mov x11, x15
WORD $0x54fffda0 // b.eq LBB0_25 $-76(%rip)
WORD $0x1400001e // b LBB0_46 $120(%rip)
LBB0_32:
WORD $0x7100ac7f // cmp w3, #43
WORD $0x54000060 // b.eq LBB0_34 $12(%rip)
WORD $0x7100b47f // cmp w3, #45
WORD $0x540000e1 // b.ne LBB0_36 $28(%rip)
LBB0_34:
WORD $0xb100055f // cmn x10, #1
WORD $0xaa0f03ea // mov x10, x15
WORD $0x54fffca0 // b.eq LBB0_25 $-108(%rip)
WORD $0x14000016 // b LBB0_46 $88(%rip)
LBB0_35:
WORD $0x8b22410d // add x13, x8, w2, uxtw
WORD $0x8b0f01b0 // add x16, x13, x15
LBB0_36:
WORD $0x9280000d // mov x13, #-1
WORD $0xb40003eb // cbz x11, LBB0_51 $124(%rip)
LBB0_37:
WORD $0xb40003ca // cbz x10, LBB0_51 $120(%rip)
WORD $0xb40003ac // cbz x12, LBB0_51 $116(%rip)
WORD $0xcb08020d // sub x13, x16, x8
WORD $0xd10005ae // sub x14, x13, #1
WORD $0xeb0e017f // cmp x11, x14
WORD $0x54000160 // b.eq LBB0_45 $44(%rip)
WORD $0xeb0e015f // cmp x10, x14
WORD $0x54000120 // b.eq LBB0_45 $36(%rip)
WORD $0xeb0e019f // cmp x12, x14
WORD $0x540000e0 // b.eq LBB0_45 $28(%rip)
WORD $0xf100054e // subs x14, x10, #1
WORD $0x540001cb // b.lt LBB0_48 $56(%rip)
WORD $0xeb0e019f // cmp x12, x14
WORD $0x54000180 // b.eq LBB0_48 $48(%rip)
WORD $0xaa2a03ed // mvn x13, x10
WORD $0x1400000f // b LBB0_51 $60(%rip)
LBB0_45:
WORD $0xcb0d03ed // neg x13, x13
LBB0_46:
WORD $0xb7f801ad // tbnz x13, #63, LBB0_51 $52(%rip)
LBB0_47:
WORD $0x8b0d0108 // add x8, x8, x13
WORD $0xcb090108 // sub x8, x8, x9
WORD $0xf9000028 // str x8, [x1]
WORD $0xa941fbfd // ldp fp, lr, [sp, #24]
WORD $0xa940cff4 // ldp x20, x19, [sp, #8]
WORD $0x9100c3ff // add sp, sp, #48
WORD $0xd65f03c0 // ret
LBB0_48:
WORD $0xaa0c016a // orr x10, x11, x12
WORD $0xb7f8022a // tbnz x10, #63, LBB0_54 $68(%rip)
WORD $0xeb0c017f // cmp x11, x12
WORD $0x540001eb // b.lt LBB0_54 $60(%rip)
WORD $0xaa2b03ed // mvn x13, x11
LBB0_51:
WORD $0xaa2d03ea // mvn x10, x13
WORD $0x8b0a0108 // add x8, x8, x10
LBB0_52:
WORD $0x92800020 // mov x0, #-2
WORD $0xcb090108 // sub x8, x8, x9
WORD $0xf9000028 // str x8, [x1]
WORD $0xa941fbfd // ldp fp, lr, [sp, #24]
WORD $0xa940cff4 // ldp x20, x19, [sp, #8]
WORD $0x9100c3ff // add sp, sp, #48
WORD $0xd65f03c0 // ret
LBB0_53:
WORD $0xaa0e03f0 // mov x16, x14
WORD $0x9280000d // mov x13, #-1
WORD $0xb5fffaeb // cbnz x11, LBB0_37 $-164(%rip)
WORD $0x17fffff4 // b LBB0_51 $-48(%rip)
LBB0_54:
WORD $0xd37ffd4a // lsr x10, x10, #63
WORD $0x5200014a // eor w10, w10, #0x1
WORD $0xd100058e // sub x14, x12, #1
WORD $0xeb0e017f // cmp x11, x14
WORD $0x1a9f17eb // cset w11, eq
WORD $0x6a0b015f // tst w10, w11
WORD $0xda8c01ad // csinv x13, x13, x12, eq
WORD $0x17ffffdf // b LBB0_46 $-132(%rip)
LBB0_55:
WORD $0x5ac000ca // rbit w10, w6
WORD $0x5ac0114a // clz w10, w10
WORD $0xaa2f03eb // mvn x11, x15
WORD $0xcb0a016d // sub x13, x11, x10
WORD $0x17ffffda // b LBB0_46 $-152(%rip)
LBB0_56:
WORD $0xaa2f03ea // mvn x10, x15
WORD $0xcb25414d // sub x13, x10, w5, uxtw
WORD $0x17ffffd7 // b LBB0_46 $-164(%rip)
LBB0_57:
WORD $0xaa2f03ea // mvn x10, x15
WORD $0xcb24414d // sub x13, x10, w4, uxtw
WORD $0x17ffffd4 // b LBB0_46 $-176(%rip)
LBB0_58:
WORD $0xaa2f03ea // mvn x10, x15
WORD $0xcb23414d // sub x13, x10, w3, uxtw
WORD $0x17ffffd1 // b LBB0_46 $-188(%rip)
LBB0_59:
WORD $0x92800000 // mov x0, #-1
WORD $0xcb090108 // sub x8, x8, x9
WORD $0xf9000028 // str x8, [x1]
WORD $0xa941fbfd // ldp fp, lr, [sp, #24]
WORD $0xa940cff4 // ldp x20, x19, [sp, #8]
WORD $0x9100c3ff // add sp, sp, #48
WORD $0xd65f03c0 // ret
LBB0_60:
WORD $0x9280000b // mov x11, #-1
WORD $0xaa0803f0 // mov x16, x8
WORD $0xaa0e03e2 // mov x2, x14
WORD $0x9280000c // mov x12, #-1
WORD $0x9280000a // mov x10, #-1
WORD $0x17ffff87 // b LBB0_23 $-484(%rip)
// .p2align 2, 0x00
_MASK_USE_NUMBER:
WORD $0x00000002 // .long 2
TEXT ·__skip_number(SB), NOSPLIT, $0-24
NO_LOCAL_POINTERS
_entry:
MOVD 16(g), R16
SUB $112, RSP, R17
CMP R16, R17
BLS _stack_grow
_skip_number:
MOVD s+0(FP), R0
MOVD p+8(FP), R1
MOVD ·_subr__skip_number(SB), R11
WORD $0x1000005e // adr x30, .+8
JMP (R11)
MOVD R0, ret+16(FP)
RET
_stack_grow:
MOVD R30, R3
CALL runtime·morestack_noctxt<>(SB)
JMP _entry

@ -0,0 +1,25 @@
// +build !noasm !appengine
// Code generated by asm2asm, DO NOT EDIT.
package neon
//go:nosplit
//go:noescape
//goland:noinspection ALL
func __skip_number_entry__() uintptr
var (
_subr__skip_number uintptr = __skip_number_entry__() + 32
)
const (
_stack__skip_number = 48
)
var (
_ = _subr__skip_number
)
const (
_ = _stack__skip_number
)

@ -0,0 +1,37 @@
// Code generated by Makefile, DO NOT EDIT.
// Code generated by Makefile, DO NOT EDIT.
/*
* Copyright 2021 ByteDance Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package neon
import (
// `unsafe`
`github.com/bytedance/sonic/internal/native/types`
)
//go:nosplit
func skip_object(s *string, p *int, m *types.StateMachine, flags uint64) (ret int) {
return __skip_object(s, p, m, flags)
}
//go:nosplit
//go:noescape
//goland:noinspection GoUnusedParameter
func __skip_object(s *string, p *int, m *types.StateMachine, flags uint64) (ret int)

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save