Prechádzať zdrojové kódy

Add `@(rodata)` and `@(static, rodata)` where appropriate

gingerBill 1 rok pred
rodič
commit
3a9b86628a

+ 2 - 2
base/runtime/internal.odin

@@ -483,7 +483,7 @@ quaternion256_ne :: #force_inline proc "contextless" (a, b: quaternion256) -> bo
 string_decode_rune :: #force_inline proc "contextless" (s: string) -> (rune, int) {
 	// NOTE(bill): Duplicated here to remove dependency on package unicode/utf8
 
-	@static accept_sizes := [256]u8{
+	@(static, rodata) accept_sizes := [256]u8{
 		0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, // 0x00-0x0f
 		0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, // 0x10-0x1f
 		0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, // 0x20-0x2f
@@ -504,7 +504,7 @@ string_decode_rune :: #force_inline proc "contextless" (s: string) -> (rune, int
 	}
 	Accept_Range :: struct {lo, hi: u8}
 
-	@static accept_ranges := [5]Accept_Range{
+	@(static, rodata) accept_ranges := [5]Accept_Range{
 		{0x80, 0xbf},
 		{0xa0, 0xbf},
 		{0x80, 0x9f},

+ 1 - 1
core/math/cmplx/cmplx_trig.odin

@@ -350,7 +350,7 @@ _reduce_pi_f64 :: proc "contextless" (x: f64) -> f64 #no_bounds_check {
 	// that is, 1/PI = SUM bdpi[i]*2^(-64*i).
 	// 19 64-bit digits give 1216 bits of precision
 	// to handle the largest possible f64 exponent.
-	@static bdpi := [?]u64{
+	@(static, rodata) bdpi := [?]u64{
 		0x0000000000000000,
 		0x517cc1b727220a94,
 		0xfe13abe8fa9a6ee0,

+ 9 - 9
core/math/math.odin

@@ -130,10 +130,10 @@ pow10 :: proc{
 
 @(require_results)
 pow10_f16 :: proc "contextless" (n: f16) -> f16 {
-	@static pow10_pos_tab := [?]f16{
+	@(static, rodata) pow10_pos_tab := [?]f16{
 		1e00, 1e01, 1e02, 1e03, 1e04,
 	}
-	@static pow10_neg_tab := [?]f16{
+	@(static, rodata) pow10_neg_tab := [?]f16{
 		1e-00, 1e-01, 1e-02, 1e-03, 1e-04, 1e-05, 1e-06, 1e-07,
 	}
 
@@ -151,13 +151,13 @@ pow10_f16 :: proc "contextless" (n: f16) -> f16 {
 
 @(require_results)
 pow10_f32 :: proc "contextless" (n: f32) -> f32 {
-	@static pow10_pos_tab := [?]f32{
+	@(static, rodata) pow10_pos_tab := [?]f32{
 		1e00, 1e01, 1e02, 1e03, 1e04, 1e05, 1e06, 1e07, 1e08, 1e09,
 		1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,
 		1e20, 1e21, 1e22, 1e23, 1e24, 1e25, 1e26, 1e27, 1e28, 1e29,
 		1e30, 1e31, 1e32, 1e33, 1e34, 1e35, 1e36, 1e37, 1e38,
 	}
-	@static pow10_neg_tab := [?]f32{
+	@(static, rodata) pow10_neg_tab := [?]f32{
 		1e-00, 1e-01, 1e-02, 1e-03, 1e-04, 1e-05, 1e-06, 1e-07, 1e-08, 1e-09,
 		1e-10, 1e-11, 1e-12, 1e-13, 1e-14, 1e-15, 1e-16, 1e-17, 1e-18, 1e-19,
 		1e-20, 1e-21, 1e-22, 1e-23, 1e-24, 1e-25, 1e-26, 1e-27, 1e-28, 1e-29,
@@ -179,16 +179,16 @@ pow10_f32 :: proc "contextless" (n: f32) -> f32 {
 
 @(require_results)
 pow10_f64 :: proc "contextless" (n: f64) -> f64 {
-	@static pow10_tab := [?]f64{
+	@(static, rodata) pow10_tab := [?]f64{
 		1e00, 1e01, 1e02, 1e03, 1e04, 1e05, 1e06, 1e07, 1e08, 1e09,
 		1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,
 		1e20, 1e21, 1e22, 1e23, 1e24, 1e25, 1e26, 1e27, 1e28, 1e29,
 		1e30, 1e31,
 	}
-	@static pow10_pos_tab32 := [?]f64{
+	@(static, rodata) pow10_pos_tab32 := [?]f64{
 		1e00, 1e32, 1e64, 1e96, 1e128, 1e160, 1e192, 1e224, 1e256, 1e288,
 	}
-	@static pow10_neg_tab32 := [?]f64{
+	@(static, rodata) pow10_neg_tab32 := [?]f64{
 		1e-00, 1e-32, 1e-64, 1e-96, 1e-128, 1e-160, 1e-192, 1e-224, 1e-256, 1e-288, 1e-320,
 	}
 
@@ -1274,7 +1274,7 @@ binomial :: proc "contextless" (n, k: int) -> int {
 @(require_results)
 factorial :: proc "contextless" (n: int) -> int {
 	when size_of(int) == size_of(i64) {
-		@static table := [21]int{
+		@(static, rodata) table := [21]int{
 			1,
 			1,
 			2,
@@ -1298,7 +1298,7 @@ factorial :: proc "contextless" (n: int) -> int {
 			2_432_902_008_176_640_000,
 		}
 	} else {
-		@static table := [13]int{
+		@(static, rodata) table := [13]int{
 			1,
 			1,
 			2,

+ 3 - 3
core/math/math_gamma.odin

@@ -67,7 +67,7 @@ package math
 // masks any imprecision in the polynomial.
 @(private="file", require_results)
 stirling :: proc "contextless" (x: f64) -> (f64, f64) {
-	@(static) gamS := [?]f64{
+	@(static, rodata) gamS := [?]f64{
 		+7.87311395793093628397e-04,
 		-2.29549961613378126380e-04,
 		-2.68132617805781232825e-03,
@@ -103,7 +103,7 @@ gamma_f64 :: proc "contextless" (x: f64) -> f64 {
 		return false
 	}
 	
-	@(static) gamP := [?]f64{
+	@(static, rodata) gamP := [?]f64{
 		1.60119522476751861407e-04,
 		1.19135147006586384913e-03,
 		1.04213797561761569935e-02,
@@ -112,7 +112,7 @@ gamma_f64 :: proc "contextless" (x: f64) -> f64 {
 		4.94214826801497100753e-01,
 		9.99999999999999996796e-01,
 	}
-	@(static) gamQ := [?]f64{
+	@(static, rodata) gamQ := [?]f64{
 		-2.31581873324120129819e-05,
 		+5.39605580493303397842e-04,
 		-4.45641913851797240494e-03,

+ 7 - 7
core/math/math_lgamma.odin

@@ -123,7 +123,7 @@ lgamma_f64 :: proc "contextless" (x: f64) -> (lgamma: f64, sign: int) {
 		return -x
 	}
 	
-	@static lgamA := [?]f64{
+	@(static, rodata) lgamA := [?]f64{
 		0h3FB3C467E37DB0C8,
 		0h3FD4A34CC4A60FAD,
 		0h3FB13E001A5562A7,
@@ -137,7 +137,7 @@ lgamma_f64 :: proc "contextless" (x: f64) -> (lgamma: f64, sign: int) {
 		0h3EFA7074428CFA52,
 		0h3F07858E90A45837,
 	}
-	@static lgamR := [?]f64{
+	@(static, rodata) lgamR := [?]f64{
 		1.0,
 		0h3FF645A762C4AB74,
 		0h3FE71A1893D3DCDC,
@@ -146,7 +146,7 @@ lgamma_f64 :: proc "contextless" (x: f64) -> (lgamma: f64, sign: int) {
 		0h3F497DDACA41A95B,
 		0h3EDEBAF7A5B38140,
 	}
-	@static lgamS := [?]f64{
+	@(static, rodata) lgamS := [?]f64{
 		0hBFB3C467E37DB0C8,
 		0h3FCB848B36E20878,
 		0h3FD4D98F4F139F59,
@@ -155,7 +155,7 @@ lgamma_f64 :: proc "contextless" (x: f64) -> (lgamma: f64, sign: int) {
 		0h3F5E26B67368F239,
 		0h3F00BFECDD17E945,
 	}
-	@static lgamT := [?]f64{
+	@(static, rodata) lgamT := [?]f64{
 		0h3FDEF72BC8EE38A2,
 		0hBFC2E4278DC6C509,
 		0h3FB08B4294D5419B,
@@ -172,7 +172,7 @@ lgamma_f64 :: proc "contextless" (x: f64) -> (lgamma: f64, sign: int) {
 		0hBF347F24ECC38C38,
 		0h3F35FD3EE8C2D3F4,
 	}
-	@static lgamU := [?]f64{
+	@(static, rodata) lgamU := [?]f64{
 		0hBFB3C467E37DB0C8,
 		0h3FE4401E8B005DFF,
 		0h3FF7475CD119BD6F,
@@ -180,7 +180,7 @@ lgamma_f64 :: proc "contextless" (x: f64) -> (lgamma: f64, sign: int) {
 		0h3FCD4EAEF6010924,
 		0h3F8B678BBF2BAB09,
 	}
-	@static lgamV := [?]f64{
+	@(static, rodata) lgamV := [?]f64{
 		1.0,
 		0h4003A5D7C2BD619C,
 		0h40010725A42B18F5,
@@ -188,7 +188,7 @@ lgamma_f64 :: proc "contextless" (x: f64) -> (lgamma: f64, sign: int) {
 		0h3FBAAE55D6537C88,
 		0h3F6A5ABB57D0CF61,
 	}
-	@static lgamW := [?]f64{
+	@(static, rodata) lgamW := [?]f64{
 		0h3FDACFE390C97D69,
 		0h3FB555555555553B,
 		0hBF66C16C16B02E5C,

+ 1 - 1
core/math/math_sincos.odin

@@ -234,7 +234,7 @@ _trig_reduce_f64 :: proc "contextless" (x: f64) -> (j: u64, z: f64) #no_bounds_c
 	// that is, 4/pi = Sum bd_pi4[i]*2^(-64*i)
 	// 19 64-bit digits and the leading one bit give 1217 bits
 	// of precision to handle the largest possible f64 exponent.
-	@static bd_pi4 := [?]u64{
+	@(static, rodata) bd_pi4 := [?]u64{
 		0x0000000000000001,
 		0x45f306dc9c882a53,
 		0xf84eafa3ea69bb81,

+ 3 - 3
core/math/rand/exp.odin

@@ -19,7 +19,7 @@ import "core:math"
 exp_float64 :: proc(r: ^Rand = nil) -> f64 {
 	re :: 7.69711747013104972
 
-	@(static)
+	@(static, rodata)
 	ke := [256]u32{
 		0xe290a139, 0x0, 0x9beadebc, 0xc377ac71, 0xd4ddb990,
 		0xde893fb8, 0xe4a8e87c, 0xe8dff16a, 0xebf2deab, 0xee49a6e8,
@@ -74,7 +74,7 @@ exp_float64 :: proc(r: ^Rand = nil) -> f64 {
 		0xf7b577d2, 0xf69c650c, 0xf51530f0, 0xf2cb0e3c, 0xeeefb15d,
 		0xe6da6ecf,
 	}
-	@(static)
+	@(static, rodata)
 	we := [256]f32{
 		2.0249555e-09, 1.486674e-11, 2.4409617e-11, 3.1968806e-11,
 		3.844677e-11, 4.4228204e-11, 4.9516443e-11, 5.443359e-11,
@@ -141,7 +141,7 @@ exp_float64 :: proc(r: ^Rand = nil) -> f64 {
 		1.2393786e-09, 1.276585e-09, 1.3193139e-09, 1.3695435e-09,
 		1.4305498e-09, 1.508365e-09, 1.6160854e-09, 1.7921248e-09,
 	}
-	@(static)
+	@(static, rodata)
 	fe := [256]f32{
 		1, 0.9381437, 0.90046996, 0.87170434, 0.8477855, 0.8269933,
 		0.8084217, 0.7915276, 0.77595687, 0.7614634, 0.7478686,

+ 3 - 3
core/math/rand/normal.odin

@@ -21,7 +21,7 @@ import "core:math"
 norm_float64 :: proc(r: ^Rand = nil) -> f64 {
 	rn :: 3.442619855899
 
-	@(static)
+	@(static, rodata)
 	kn := [128]u32{
 		0x76ad2212, 0x00000000, 0x600f1b53, 0x6ce447a6, 0x725b46a2,
 		0x7560051d, 0x774921eb, 0x789a25bd, 0x799045c3, 0x7a4bce5d,
@@ -50,7 +50,7 @@ norm_float64 :: proc(r: ^Rand = nil) -> f64 {
 		0x7da61a1e, 0x7d72a0fb, 0x7d30e097, 0x7cd9b4ab, 0x7c600f1a,
 		0x7ba90bdc, 0x7a722176, 0x77d664e5,
 	}
-	@(static)
+	@(static, rodata)
 	wn := [128]f32{
 		1.7290405e-09, 1.2680929e-10, 1.6897518e-10, 1.9862688e-10,
 		2.2232431e-10, 2.4244937e-10, 2.601613e-10,  2.7611988e-10,
@@ -85,7 +85,7 @@ norm_float64 :: proc(r: ^Rand = nil) -> f64 {
 		1.2601323e-09, 1.2857697e-09, 1.3146202e-09, 1.347784e-09,
 		1.3870636e-09, 1.4357403e-09, 1.5008659e-09, 1.6030948e-09,
 	}
-	@(static)
+	@(static, rodata)
 	fn := [128]f32{
 		1.00000000,  0.9635997,   0.9362827,   0.9130436,   0.89228165,
 		0.87324303,  0.8555006,   0.8387836,   0.8229072,   0.8077383,

+ 1 - 1
core/os/os2/internal_util.odin

@@ -111,7 +111,7 @@ next_random :: proc(r: ^[2]u64) -> u64 {
 
 @(require_results)
 random_string :: proc(buf: []byte) -> string {
-	@static digits := "0123456789"
+	@(static, rodata) digits := "0123456789"
 
 	u := next_random(&random_string_seed)
 

+ 1 - 1
core/strconv/generic_float.odin

@@ -375,7 +375,7 @@ decimal_to_float_bits :: proc(d: ^decimal.Decimal, info: ^Float_Info) -> (b: u64
 		return
 	}
 
-	@static power_table := [?]int{1, 3, 6, 9, 13, 16, 19, 23, 26}
+	@(static, rodata) power_table := [?]int{1, 3, 6, 9, 13, 16, 19, 23, 26}
 
 	exp = 0
 	for d.decimal_point > 0 {

+ 1 - 1
core/strconv/strconv.odin

@@ -1095,7 +1095,7 @@ parse_f64_prefix :: proc(str: string) -> (value: f64, nr: int, ok: bool) {
 	}
 
 	trunc_block: if !trunc {
-		@static pow10 := [?]f64{
+		@(static, rodata) pow10 := [?]f64{
 			1e0,  1e1,  1e2,  1e3,  1e4,  1e5,  1e6,  1e7,  1e8,  1e9,
 			1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,
 			1e20, 1e21, 1e22,

+ 1 - 0
core/time/time.odin

@@ -389,6 +389,7 @@ is_leap_year :: proc "contextless" (year: int) -> (leap: bool) {
 	return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)
 }
 
+@(rodata)
 days_before := [?]i32{
 	0,
 	31,

+ 10 - 0
core/unicode/tables.odin

@@ -12,6 +12,7 @@ package unicode
 @(private) pLo    :: pLl | pLu // a letter that is neither upper nor lower case.
 @(private) pLmask :: pLo
 
+@(rodata)
 char_properties := [MAX_LATIN1+1]u8{
 	0x00 = pC,       // '\x00'
 	0x01 = pC,       // '\x01'
@@ -272,6 +273,7 @@ char_properties := [MAX_LATIN1+1]u8{
 }
 
 
+@(rodata)
 alpha_ranges := [?]i32{
 	0x00d8,  0x00f6,
 	0x00f8,  0x01f5,
@@ -427,6 +429,7 @@ alpha_ranges := [?]i32{
 	0xffda,  0xffdc,
 }
 
+@(rodata)
 alpha_singlets := [?]i32{
 	0x00aa,
 	0x00b5,
@@ -462,6 +465,7 @@ alpha_singlets := [?]i32{
 	0xfe74,
 }
 
+@(rodata)
 space_ranges := [?]i32{
 	0x0009,  0x000d, // tab and newline
 	0x0020,  0x0020, // space
@@ -477,6 +481,7 @@ space_ranges := [?]i32{
 	0xfeff,  0xfeff,
 }
 
+@(rodata)
 unicode_spaces := [?]i32{
 	0x0009, // tab
 	0x000a, // LF
@@ -494,6 +499,7 @@ unicode_spaces := [?]i32{
 	0xfeff, // unknown
 }
 
+@(rodata)
 to_upper_ranges := [?]i32{
 	0x0061,  0x007a, 468, // a-z A-Z
 	0x00e0,  0x00f6, 468,
@@ -532,6 +538,7 @@ to_upper_ranges := [?]i32{
 	0xff41,  0xff5a, 468,
 }
 
+@(rodata)
 to_upper_singlets := [?]i32{
 	0x00ff, 621,
 	0x0101, 499,
@@ -875,6 +882,7 @@ to_upper_singlets := [?]i32{
 	0x1ff3, 509,
 }
 
+@(rodata)
 to_lower_ranges := [?]i32{
 	0x0041,  0x005a, 532, // A-Z a-z
 	0x00c0,  0x00d6, 532, // - -
@@ -914,6 +922,7 @@ to_lower_ranges := [?]i32{
 	0xff21,  0xff3a, 532, // - -
 }
 
+@(rodata)
 to_lower_singlets := [?]i32{
 	0x0100, 501,
 	0x0102, 501,
@@ -1250,6 +1259,7 @@ to_lower_singlets := [?]i32{
 	0x1ffc, 491,
 }
 
+@(rodata)
 to_title_singlets := [?]i32{
 	0x01c4, 501,
 	0x01c6, 499,