dispatch_arm64.go 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*
  2. * Copyright 2021 ByteDance Inc.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package native
  17. import (
  18. `unsafe`
  19. neon `github.com/bytedance/sonic/internal/native/neon`
  20. `github.com/bytedance/sonic/internal/native/types`
  21. )
  22. const (
  23. MaxFrameSize uintptr = 200
  24. BufPaddingSize int = 64
  25. )
  26. var (
  27. S_f64toa uintptr
  28. S_f32toa uintptr
  29. S_i64toa uintptr
  30. S_u64toa uintptr
  31. S_lspace uintptr
  32. )
  33. var (
  34. S_quote uintptr
  35. S_unquote uintptr
  36. )
  37. var (
  38. S_value uintptr
  39. S_vstring uintptr
  40. S_vnumber uintptr
  41. S_vsigned uintptr
  42. S_vunsigned uintptr
  43. )
  44. var (
  45. S_skip_one uintptr
  46. S_skip_one_fast uintptr
  47. S_get_by_path uintptr
  48. S_skip_array uintptr
  49. S_skip_object uintptr
  50. S_skip_number uintptr
  51. S_parse_with_padding uintptr
  52. S_lookup_small_key uintptr
  53. )
  54. //go:nosplit
  55. //go:noescape
  56. //go:linkname Quote github.com/bytedance/sonic/internal/native/neon.__quote
  57. func Quote(s unsafe.Pointer, nb int, dp unsafe.Pointer, dn *int, flags uint64) int
  58. //go:nosplit
  59. //go:noescape
  60. //go:linkname Unquote github.com/bytedance/sonic/internal/native/neon.__unquote
  61. func Unquote(s unsafe.Pointer, nb int, dp unsafe.Pointer, ep *int, flags uint64) int
  62. //go:nosplit
  63. //go:noescape
  64. //go:linkname HTMLEscape github.com/bytedance/sonic/internal/native/neon.__html_escape
  65. func HTMLEscape(s unsafe.Pointer, nb int, dp unsafe.Pointer, dn *int) int
  66. //go:nosplit
  67. //go:noescape
  68. //go:linkname Value github.com/bytedance/sonic/internal/native/neon.__value
  69. func Value(s unsafe.Pointer, n int, p int, v *types.JsonState, flags uint64) int
  70. //go:nosplit
  71. //go:noescape
  72. //go:linkname SkipOne github.com/bytedance/sonic/internal/native/neon.__skip_one
  73. func SkipOne(s *string, p *int, m *types.StateMachine, flags uint64) int
  74. //go:nosplit
  75. //go:noescape
  76. //go:linkname SkipOneFast github.com/bytedance/sonic/internal/native/neon.__skip_one_fast
  77. func SkipOneFast(s *string, p *int) int
  78. //go:nosplit
  79. //go:noescape
  80. //go:linkname GetByPath github.com/bytedance/sonic/internal/native/neon.__get_by_path
  81. func GetByPath(s *string, p *int, path *[]interface{}, m *types.StateMachine) int
  82. //go:nosplit
  83. //go:noescape
  84. //go:linkname ValidateOne github.com/bytedance/sonic/internal/native/neon.__validate_one
  85. func ValidateOne(s *string, p *int, m *types.StateMachine, flags uint64) int
  86. //go:nosplit
  87. //go:noescape
  88. //go:linkname I64toa github.com/bytedance/sonic/internal/native/neon.__i64toa
  89. func I64toa(out *byte, val int64) (ret int)
  90. //go:nosplit
  91. //go:noescape
  92. //go:linkname U64toa github.com/bytedance/sonic/internal/native/neon.__u64toa
  93. func U64toa(out *byte, val uint64) (ret int)
  94. //go:nosplit
  95. //go:noescape
  96. //go:linkname F64toa github.com/bytedance/sonic/internal/native/neon.__f64toa
  97. func F64toa(out *byte, val float64) (ret int)
  98. //go:nosplit
  99. //go:noescape
  100. //go:linkname F32toa github.com/bytedance/sonic/internal/native/neon.__f32toa
  101. func F32toa(out *byte, val float32) (ret int)
  102. //go:nosplit
  103. //go:noescape
  104. //go:linkname ValidateUTF8 github.com/bytedance/sonic/internal/native/neon.__validate_utf8
  105. func ValidateUTF8(s *string, p *int, m *types.StateMachine) (ret int)
  106. //go:nosplit
  107. //go:noescape
  108. //go:linkname ValidateUTF8Fast github.com/bytedance/sonic/internal/native/neon.__validate_utf8_fast
  109. func ValidateUTF8Fast(s *string) (ret int)
  110. //go:nosplit
  111. //go:noescape
  112. //go:linkname ParseWithPadding github.com/bytedance/sonic/internal/native/neon.__parse_with_padding
  113. func ParseWithPadding(parser unsafe.Pointer) (ret int)
  114. //go:nosplit
  115. //go:noescape
  116. //go:linkname LookupSmallKey github.com/bytedance/sonic/internal/native/neon.__lookup_small_key
  117. func LookupSmallKey(key *string, table *[]byte, lowerOff int) (index int)
  118. func useNeon() {
  119. S_f64toa = neon.S_f64toa
  120. S_f32toa = neon.S_f32toa
  121. S_i64toa = neon.S_i64toa
  122. S_u64toa = neon.S_u64toa
  123. S_lspace = neon.S_lspace
  124. S_quote = neon.S_quote
  125. S_unquote = neon.S_unquote
  126. S_value = neon.S_value
  127. S_vstring = neon.S_vstring
  128. S_vnumber = neon.S_vnumber
  129. S_vsigned = neon.S_vsigned
  130. S_vunsigned = neon.S_vunsigned
  131. S_skip_one = neon.S_skip_one
  132. S_skip_one_fast = neon.S_skip_one_fast
  133. S_skip_array = neon.S_skip_array
  134. S_skip_object = neon.S_skip_object
  135. S_skip_number = neon.S_skip_number
  136. S_get_by_path = neon.S_get_by_path
  137. S_parse_with_padding = neon.S_parse_with_padding
  138. S_lookup_small_key = neon.S_lookup_small_key
  139. }
  140. func init() {
  141. useNeon()
  142. }