Skip to content

Commit 4477d9c

Browse files
author
Hongbo Zhang
committed
runtime compilation currently use unsafe option
1 parent 6d9d3c0 commit 4477d9c

File tree

7 files changed

+36
-41
lines changed

7 files changed

+36
-41
lines changed

jscomp/lam.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,6 @@ let prim ~primitive:(prim : Prim.t) ~args:(ll : t list) : t =
395395
Lift.int64 (Int64.neg a)
396396
| Pnot , Const_pointer (a,_)
397397
-> Lift.bool (a = 0 )
398-
399398
| _ -> default ()
400399
end
401400

jscomp/runtime/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ else
3232
BS_FLAGS= $(BS_COMMON_FLAGS) -bs-package-output lib/js
3333
endif
3434

35-
COMPFLAGS += $(BS_FLAGS) -I ../stdlib -nostdlib -nopervasives -open Pervasives -w -40
35+
COMPFLAGS += $(BS_FLAGS) -I ../stdlib -nostdlib -nopervasives -open Pervasives -unsafe -w -40
3636

3737

3838

lib/js/caml_format.js

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ function parse_sign_and_base(s) {
5757
var sign = 1;
5858
var base = /* Dec */2;
5959
var i = 0;
60-
if (Caml_string.get(s, i) === /* "-" */45) {
60+
if (s[i] === "-") {
6161
sign = -1;
6262
i = i + 1 | 0;
6363
}
64-
var match = Caml_string.get(s, i);
65-
var match$1 = Caml_string.get(s, i + 1 | 0);
64+
var match = s.charCodeAt(i);
65+
var match$1 = s.charCodeAt(i + 1 | 0);
6666
if (match === 48) {
6767
if (match$1 >= 89) {
6868
if (match$1 !== 98) {
@@ -114,7 +114,7 @@ function caml_int_of_string(s) {
114114
var base = int_of_string_base(match[2]);
115115
var threshold = 4294967295;
116116
var len = s.length;
117-
var c = i < len ? Caml_string.get(s, i) : /* "\000" */0;
117+
var c = i < len ? s.charCodeAt(i) : /* "\000" */0;
118118
var d = parse_digit(c);
119119
if (d < 0 || d >= base) {
120120
throw [
@@ -130,7 +130,7 @@ function caml_int_of_string(s) {
130130
return acc;
131131
}
132132
else {
133-
var a = Caml_string.get(s, k);
133+
var a = s.charCodeAt(k);
134134
if (a === /* "_" */95) {
135135
_k = k + 1 | 0;
136136
continue ;
@@ -209,7 +209,7 @@ function caml_int64_of_string(s) {
209209

210210
}
211211
var len = s.length;
212-
var c = i < len ? Caml_string.get(s, i) : /* "\000" */0;
212+
var c = i < len ? s.charCodeAt(i) : /* "\000" */0;
213213
var d = Caml_int64.of_int32(parse_digit(c));
214214
if (Caml_int64.lt(d, /* int64 */[
215215
/* hi */0,
@@ -228,7 +228,7 @@ function caml_int64_of_string(s) {
228228
return acc;
229229
}
230230
else {
231-
var a = Caml_string.get(s, k);
231+
var a = s.charCodeAt(k);
232232
if (a === /* "_" */95) {
233233
_k = k + 1 | 0;
234234
continue ;
@@ -332,7 +332,7 @@ function parse_format(fmt) {
332332
return f;
333333
}
334334
else {
335-
var c = Caml_string.get(fmt, i);
335+
var c = fmt.charCodeAt(i);
336336
var exit = 0;
337337
if (c >= 69) {
338338
if (c >= 88) {
@@ -433,11 +433,11 @@ function parse_format(fmt) {
433433
var j = i + 1 | 0;
434434
while((function(j){
435435
return function () {
436-
var w = Caml_string.get(fmt, j) - /* "0" */48 | 0;
436+
var w = fmt.charCodeAt(j) - /* "0" */48 | 0;
437437
return +(w >= 0 && w <= 9);
438438
}
439439
}(j))()) {
440-
f[/* prec */9] = (Caml_int32.imul(f[/* prec */9], 10) + Caml_string.get(fmt, j) | 0) - /* "0" */48 | 0;
440+
f[/* prec */9] = (Caml_int32.imul(f[/* prec */9], 10) + fmt.charCodeAt(j) | 0) - /* "0" */48 | 0;
441441
j = j + 1 | 0;
442442
};
443443
_i = j;
@@ -487,11 +487,11 @@ function parse_format(fmt) {
487487
var j$1 = i;
488488
while((function(j$1){
489489
return function () {
490-
var w = Caml_string.get(fmt, j$1) - /* "0" */48 | 0;
490+
var w = fmt.charCodeAt(j$1) - /* "0" */48 | 0;
491491
return +(w >= 0 && w <= 9);
492492
}
493493
}(j$1))()) {
494-
f[/* width */6] = (Caml_int32.imul(f[/* width */6], 10) + Caml_string.get(fmt, j$1) | 0) - /* "0" */48 | 0;
494+
f[/* width */6] = (Caml_int32.imul(f[/* width */6], 10) + fmt.charCodeAt(j$1) | 0) - /* "0" */48 | 0;
495495
j$1 = j$1 + 1 | 0;
496496
};
497497
_i = j$1;
@@ -622,30 +622,30 @@ function caml_int64_format(fmt, x) {
622622
/* lo */0
623623
], match$1[0]);
624624
var modulus = match$1[1];
625-
s = Caml_string.js_string_of_char(Caml_string.get(cvtbl, modulus[1] | 0)) + s;
625+
s = Caml_string.js_string_of_char(cvtbl.charCodeAt(modulus[1] | 0)) + s;
626626
while(Caml_int64.neq(quotient, /* int64 */[
627627
/* hi */0,
628628
/* lo */0
629629
])) {
630630
var match$2 = Caml_int64.div_mod(quotient, wbase);
631631
quotient = match$2[0];
632632
modulus = match$2[1];
633-
s = Caml_string.js_string_of_char(Caml_string.get(cvtbl, modulus[1] | 0)) + s;
633+
s = Caml_string.js_string_of_char(cvtbl.charCodeAt(modulus[1] | 0)) + s;
634634
};
635635
}
636636
else {
637637
var match$3 = Caml_int64.div_mod(x$1, wbase);
638638
var quotient$1 = match$3[0];
639639
var modulus$1 = match$3[1];
640-
s = Caml_string.js_string_of_char(Caml_string.get(cvtbl, modulus$1[1] | 0)) + s;
640+
s = Caml_string.js_string_of_char(cvtbl.charCodeAt(modulus$1[1] | 0)) + s;
641641
while(Caml_int64.neq(quotient$1, /* int64 */[
642642
/* hi */0,
643643
/* lo */0
644644
])) {
645645
var match$4 = Caml_int64.div_mod(quotient$1, wbase);
646646
quotient$1 = match$4[0];
647647
modulus$1 = match$4[1];
648-
s = Caml_string.js_string_of_char(Caml_string.get(cvtbl, modulus$1[1] | 0)) + s;
648+
s = Caml_string.js_string_of_char(cvtbl.charCodeAt(modulus$1[1] | 0)) + s;
649649
};
650650
}
651651
break;
@@ -673,30 +673,30 @@ function caml_int64_format(fmt, x) {
673673
/* lo */3435973836
674674
], match$5[0]), match$6[0]);
675675
var modulus$2 = match$6[1];
676-
s = Caml_string.js_string_of_char(Caml_string.get(cvtbl$1, modulus$2[1] | 0)) + s;
676+
s = Caml_string.js_string_of_char(cvtbl$1.charCodeAt(modulus$2[1] | 0)) + s;
677677
while(Caml_int64.neq(quotient$2, /* int64 */[
678678
/* hi */0,
679679
/* lo */0
680680
])) {
681681
var match$7 = Caml_int64.div_mod(quotient$2, wbase$1);
682682
quotient$2 = match$7[0];
683683
modulus$2 = match$7[1];
684-
s = Caml_string.js_string_of_char(Caml_string.get(cvtbl$1, modulus$2[1] | 0)) + s;
684+
s = Caml_string.js_string_of_char(cvtbl$1.charCodeAt(modulus$2[1] | 0)) + s;
685685
};
686686
}
687687
else {
688688
var match$8 = Caml_int64.div_mod(x$1, wbase$1);
689689
var quotient$3 = match$8[0];
690690
var modulus$3 = match$8[1];
691-
s = Caml_string.js_string_of_char(Caml_string.get(cvtbl$1, modulus$3[1] | 0)) + s;
691+
s = Caml_string.js_string_of_char(cvtbl$1.charCodeAt(modulus$3[1] | 0)) + s;
692692
while(Caml_int64.neq(quotient$3, /* int64 */[
693693
/* hi */0,
694694
/* lo */0
695695
])) {
696696
var match$9 = Caml_int64.div_mod(quotient$3, wbase$1);
697697
quotient$3 = match$9[0];
698698
modulus$3 = match$9[1];
699-
s = Caml_string.js_string_of_char(Caml_string.get(cvtbl$1, modulus$3[1] | 0)) + s;
699+
s = Caml_string.js_string_of_char(cvtbl$1.charCodeAt(modulus$3[1] | 0)) + s;
700700
};
701701
}
702702
break;
@@ -728,7 +728,7 @@ function caml_format_float(fmt, x) {
728728
case "e" :
729729
s = x$1.toExponential(prec);
730730
var i = s.length;
731-
if (Caml_string.get(s, i - 3 | 0) === /* "e" */101) {
731+
if (s[i - 3 | 0] === "e") {
732732
s = s.slice(0, i - 1 | 0) + ("0" + s.slice(i - 1 | 0));
733733
}
734734
break;
@@ -742,15 +742,15 @@ function caml_format_float(fmt, x) {
742742
var exp = +s.slice(j + 1 | 0);
743743
if (exp < -4 || x$1 >= 1e21 || x$1.toFixed(0).length > prec$1) {
744744
var i$1 = j - 1 | 0;
745-
while(Caml_string.get(s, i$1) === /* "0" */48) {
745+
while(s[i$1] === "0") {
746746
i$1 = i$1 - 1 | 0;
747747
};
748-
if (Caml_string.get(s, i$1) === /* "." */46) {
748+
if (s[i$1] === ".") {
749749
i$1 = i$1 - 1 | 0;
750750
}
751751
s = s.slice(0, i$1 + 1 | 0) + s.slice(j);
752752
var i$2 = s.length;
753-
if (Caml_string.get(s, i$2 - 3 | 0) === /* "e" */101) {
753+
if (s[i$2 - 3 | 0] === "e") {
754754
s = s.slice(0, i$2 - 1 | 0) + ("0" + s.slice(i$2 - 1 | 0));
755755
}
756756

@@ -771,10 +771,10 @@ function caml_format_float(fmt, x) {
771771
}
772772
if (p !== 0) {
773773
var k = s.length - 1 | 0;
774-
while(Caml_string.get(s, k) === /* "0" */48) {
774+
while(s[k] === "0") {
775775
k = k - 1 | 0;
776776
};
777-
if (Caml_string.get(s, k) === /* "." */46) {
777+
if (s[k] === ".") {
778778
k = k - 1 | 0;
779779
}
780780
s = s.slice(0, k + 1 | 0);

lib/js/caml_hash.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
var Caml_builtin_exceptions = require("./caml_builtin_exceptions");
44
var Caml_int32 = require("./caml_int32");
55
var Caml_queue = require("./caml_queue");
6-
var Caml_string = require("./caml_string");
76

87
function rotl32(x, n) {
98
return (x << n) | (x >>> (32 - n | 0));
@@ -33,13 +32,13 @@ function caml_hash_mix_string(h, s) {
3332
var hash = h;
3433
for(var i = 0; i <= block; ++i){
3534
var j = (i << 2);
36-
var w = Caml_string.get(s, j) | (Caml_string.get(s, j + 1 | 0) << 8) | (Caml_string.get(s, j + 2 | 0) << 16) | (Caml_string.get(s, j + 3 | 0) << 24);
35+
var w = s.charCodeAt(j) | (s.charCodeAt(j + 1 | 0) << 8) | (s.charCodeAt(j + 2 | 0) << 16) | (s.charCodeAt(j + 3 | 0) << 24);
3736
hash = mix(hash, w);
3837
}
3938
var modulo = len & 3;
4039
if (modulo !== 0) {
41-
var w$1 = modulo === 3 ? (Caml_string.get(s, len - 1 | 0) << 16) | (Caml_string.get(s, len - 2 | 0) << 8) | Caml_string.get(s, len - 3 | 0) : (
42-
modulo === 2 ? (Caml_string.get(s, len - 1 | 0) << 8) | Caml_string.get(s, len - 2 | 0) : Caml_string.get(s, len - 1 | 0)
40+
var w$1 = modulo === 3 ? (s.charCodeAt(len - 1 | 0) << 16) | (s.charCodeAt(len - 2 | 0) << 8) | s.charCodeAt(len - 3 | 0) : (
41+
modulo === 2 ? (s.charCodeAt(len - 1 | 0) << 8) | s.charCodeAt(len - 2 | 0) : s.charCodeAt(len - 1 | 0)
4342
);
4443
hash = mix(hash, w$1);
4544
}

lib/js/caml_int64.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ var Caml_builtin_exceptions = require("./caml_builtin_exceptions");
44
var Caml_obj = require("./caml_obj");
55
var Caml_int32 = require("./caml_int32");
66
var Caml_utils = require("./caml_utils");
7-
var Caml_string = require("./caml_string");
87

98
var min_int = /* record */[
109
/* hi */-2147483648,
@@ -586,8 +585,8 @@ function bits_of_float(x) {
586585
}
587586

588587
function get64(s, i) {
589-
var hi = (Caml_string.get(s, i + 4 | 0) << 32) | (Caml_string.get(s, i + 5 | 0) << 40) | (Caml_string.get(s, i + 6 | 0) << 48) | (Caml_string.get(s, i + 7 | 0) << 56);
590-
var lo = Caml_string.get(s, i) | (Caml_string.get(s, i + 1 | 0) << 8) | (Caml_string.get(s, i + 2 | 0) << 16) | (Caml_string.get(s, i + 3 | 0) << 24);
588+
var hi = (s.charCodeAt(i + 4 | 0) << 32) | (s.charCodeAt(i + 5 | 0) << 40) | (s.charCodeAt(i + 6 | 0) << 48) | (s.charCodeAt(i + 7 | 0) << 56);
589+
var lo = s.charCodeAt(i) | (s.charCodeAt(i + 1 | 0) << 8) | (s.charCodeAt(i + 2 | 0) << 16) | (s.charCodeAt(i + 3 | 0) << 24);
591590
return /* record */[
592591
/* hi */hi,
593592
/* lo */(lo >>> 0)

lib/js/caml_io.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
var Caml_builtin_exceptions = require("./caml_builtin_exceptions");
44
var Curry = require("./curry");
5-
var Caml_string = require("./caml_string");
65

76
function $caret(prim, prim$1) {
87
return prim + prim$1;
@@ -17,7 +16,7 @@ var stdout = /* record */[
1716
if (( (typeof process !== "undefined") && process.stdout && process.stdout.write)) {
1817
return ( process.stdout.write )(s);
1918
}
20-
else if (Caml_string.get(s, v) === /* "\n" */10) {
19+
else if (s[v] === "\n") {
2120
console.log(s.slice(0, v));
2221
return /* () */0;
2322
}
@@ -32,7 +31,7 @@ var stderr = /* record */[
3231
/* buffer */"",
3332
/* output */function (_, s) {
3433
var v = s.length - 1 | 0;
35-
if (Caml_string.get(s, v) === /* "\n" */10) {
34+
if (s[v] === "\n") {
3635
console.log(s.slice(0, v));
3736
return /* () */0;
3837
}

lib/js/caml_md5.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22

3-
var Caml_string = require("./caml_string");
43

54
function cmn(q, a, b, x, s, t) {
65
var a$1 = ((a + q | 0) + x | 0) + t | 0;
@@ -139,7 +138,7 @@ function caml_md5_string(s, start, len) {
139138
for(var i$1 = 1; i$1 <= i_end; ++i$1){
140139
for(var j = 0; j <= 15; ++j){
141140
var k = ((i$1 << 6) - 64 | 0) + (j << 2) | 0;
142-
md5blk[j] = ((Caml_string.get(s$1, k) + (Caml_string.get(s$1, k + 1 | 0) << 8) | 0) + (Caml_string.get(s$1, k + 2 | 0) << 16) | 0) + (Caml_string.get(s$1, k + 3 | 0) << 24) | 0;
141+
md5blk[j] = ((s$1.charCodeAt(k) + (s$1.charCodeAt(k + 1 | 0) << 8) | 0) + (s$1.charCodeAt(k + 2 | 0) << 16) | 0) + (s$1.charCodeAt(k + 3 | 0) << 24) | 0;
143142
}
144143
cycle(state, md5blk);
145144
}
@@ -149,7 +148,7 @@ function caml_md5_string(s, start, len) {
149148
}
150149
var i_end$1 = s_tail.length - 1 | 0;
151150
for(var i$2 = 0; i$2 <= i_end$1; ++i$2){
152-
md5blk[i$2 / 4 | 0] = md5blk[i$2 / 4 | 0] | (Caml_string.get(s_tail, i$2) << (i$2 % 4 << 3));
151+
md5blk[i$2 / 4 | 0] = md5blk[i$2 / 4 | 0] | (s_tail.charCodeAt(i$2) << (i$2 % 4 << 3));
153152
}
154153
var i$3 = i_end$1 + 1 | 0;
155154
md5blk[i$3 / 4 | 0] = md5blk[i$3 / 4 | 0] | (128 << (i$3 % 4 << 3));

0 commit comments

Comments
 (0)