Skip to content

Clean up legacy tags handling #7309

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

# 12.0.0-alpha.10 (Unreleased)

#### :house: Internal

- Clean up legacy tags handling. https://github.com/rescript-lang/rescript/pull/7309

# 12.0.0-alpha.9

#### :boom: Breaking Change
Expand Down
5 changes: 4 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ Make sure you have [opam](https://opam.ocaml.org/doc/Install.html) installed on
opam init

# Any recent OCaml version works as a development compiler
opam switch create 5.3.0 # can also create local switch with opam switch create
# Can also create local switch with opam switch create
# If you get "No compiler matching `5.3.0' found" error,
# then you need to run `opam update && opam upgrade` first
opam switch create 5.3.0

# Install dev dependencies from OPAM
opam install . --deps-only --with-test --with-dev-setup -y
Expand Down
4 changes: 0 additions & 4 deletions compiler/core/js_exp_make.ml
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,6 @@ let eight_int_literal : t =
let nine_int_literal : t =
{expression_desc = Number (Int {i = 9l; c = None}); comment = None}

let obj_int_tag_literal : t =
{expression_desc = Number (Int {i = 248l; c = None}); comment = None}

let int ?comment ?c i : t = {expression_desc = Number (Int {i; c}); comment}

let bigint ?comment sign i : t =
Expand All @@ -364,7 +361,6 @@ let small_int i : t =
| 7 -> seven_int_literal
| 8 -> eight_int_literal
| 9 -> nine_int_literal
| 248 -> obj_int_tag_literal
| i -> int (Int32.of_int i)

let true_ : t = {comment = None; expression_desc = Bool true}
Expand Down
1 change: 0 additions & 1 deletion compiler/core/js_exp_make.mli
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ val zero_int_literal : t

(* val one_int_literal : t *)
val zero_float_lit : t
(* val obj_int_tag_literal : t *)

val zero_bigint_literal : t

Expand Down
14 changes: 5 additions & 9 deletions lib/es6/Primitive_hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,11 @@ function hash(count, _limit, seed, obj) {
if (size !== 0) {
let obj_tag = obj$1.TAG;
let tag = (size << 10) | obj_tag;
if (obj_tag === 248) {
s = hash_mix_int(s, obj$1[1]);
} else {
s = hash_mix_int(s, tag);
let v = size - 1 | 0;
let block = v < num ? v : num;
for (let i = 0; i <= block; ++i) {
push_back(queue, obj$1[i]);
}
s = hash_mix_int(s, tag);
let v = size - 1 | 0;
let block = v < num ? v : num;
for (let i = 0; i <= block; ++i) {
push_back(queue, obj$1[i]);
}
} else {
let size$1 = (function(obj,cb){
Expand Down
21 changes: 0 additions & 21 deletions lib/es6/Primitive_object.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@


import * as Primitive_int from "./Primitive_int.js";
import * as Primitive_bool from "./Primitive_bool.js";
import * as Primitive_float from "./Primitive_float.js";
import * as Primitive_string from "./Primitive_string.js";
Expand Down Expand Up @@ -107,16 +106,6 @@ function compare(a, b) {
}
let tag_a = a.TAG;
let tag_b = b.TAG;
if (tag_a === 248) {
return Primitive_int.compare(a[1], b[1]);
}
if (tag_a === 251) {
throw {
RE_EXN_ID: "Invalid_argument",
_1: "equal: abstract value",
Error: new Error()
};
}
if (tag_a !== tag_b) {
if (tag_a < tag_b) {
return -1;
Expand Down Expand Up @@ -247,16 +236,6 @@ function equal(a, b) {
}
let tag_a = a.TAG;
let tag_b = b.TAG;
if (tag_a === 248) {
return a[1] === b[1];
}
if (tag_a === 251) {
throw {
RE_EXN_ID: "Invalid_argument",
_1: "equal: abstract value",
Error: new Error()
};
}
if (tag_a !== tag_b) {
return false;
}
Expand Down
14 changes: 5 additions & 9 deletions lib/js/Primitive_hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,11 @@ function hash(count, _limit, seed, obj) {
if (size !== 0) {
let obj_tag = obj$1.TAG;
let tag = (size << 10) | obj_tag;
if (obj_tag === 248) {
s = hash_mix_int(s, obj$1[1]);
} else {
s = hash_mix_int(s, tag);
let v = size - 1 | 0;
let block = v < num ? v : num;
for (let i = 0; i <= block; ++i) {
push_back(queue, obj$1[i]);
}
s = hash_mix_int(s, tag);
let v = size - 1 | 0;
let block = v < num ? v : num;
for (let i = 0; i <= block; ++i) {
push_back(queue, obj$1[i]);
}
} else {
let size$1 = (function(obj,cb){
Expand Down
21 changes: 0 additions & 21 deletions lib/js/Primitive_object.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

let Primitive_int = require("./Primitive_int.js");
let Primitive_bool = require("./Primitive_bool.js");
let Primitive_float = require("./Primitive_float.js");
let Primitive_string = require("./Primitive_string.js");
Expand Down Expand Up @@ -107,16 +106,6 @@ function compare(a, b) {
}
let tag_a = a.TAG;
let tag_b = b.TAG;
if (tag_a === 248) {
return Primitive_int.compare(a[1], b[1]);
}
if (tag_a === 251) {
throw {
RE_EXN_ID: "Invalid_argument",
_1: "equal: abstract value",
Error: new Error()
};
}
if (tag_a !== tag_b) {
if (tag_a < tag_b) {
return -1;
Expand Down Expand Up @@ -247,16 +236,6 @@ function equal(a, b) {
}
let tag_a = a.TAG;
let tag_b = b.TAG;
if (tag_a === 248) {
return a[1] === b[1];
}
if (tag_a === 251) {
throw {
RE_EXN_ID: "Invalid_argument",
_1: "equal: abstract value",
Error: new Error()
};
}
if (tag_a !== tag_b) {
return false;
}
Expand Down
24 changes: 10 additions & 14 deletions runtime/Primitive_hash.res
Original file line number Diff line number Diff line change
Expand Up @@ -174,22 +174,18 @@ let hash = (count: int, _limit, seed: int, obj: Obj.t): int => {
if size != 0 {
let obj_tag = Obj.tag(obj)
let tag = lor(lsl(size, 10), obj_tag)
if obj_tag == 248 /* Obj.object_tag */ {
s.contents = hash_mix_int(s.contents, (Obj.obj(Obj.getField(obj, 1)): int))
} else {
s.contents = hash_mix_int(s.contents, tag)
let block = {
let v = size - 1
if v < num.contents {
v
} else {
num.contents
}
}
for i in 0 to block {
push_back(queue, Obj.getField(obj, i))
s.contents = hash_mix_int(s.contents, tag)
let block = {
let v = size - 1
if v < num.contents {
v
} else {
num.contents
}
}
for i in 0 to block {
push_back(queue, Obj.getField(obj, i))
}
} else {
let size: int = %raw(`function(obj,cb){
var size = 0
Expand Down
13 changes: 2 additions & 11 deletions runtime/Primitive_object.res
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ type t = Primitive_object_extern.t
let repr = Primitive_object_extern.repr
let magic = Primitive_object_extern.magic
let tag = Primitive_object_extern.tag
let field = Primitive_object_extern.getField
let size = Primitive_object_extern.size

module O = {
Expand Down Expand Up @@ -145,11 +144,7 @@ let rec compare = (a: t, b: t): int =>
} else {
let tag_a = tag(a)
let tag_b = tag(b)
if tag_a == 248 /* object/exception */ {
Pervasives.compare((magic(field(a, 1)): int), magic(field(b, 1)))
} else if tag_a == 251 /* abstract_tag */ {
raise(Invalid_argument("equal: abstract value"))
} else if tag_a != tag_b {
if tag_a != tag_b {
if tag_a < tag_b {
-1
} else {
Expand Down Expand Up @@ -277,11 +272,7 @@ let rec equal = (a: t, b: t): bool =>
/* [a] [b] could not be null, so it can not raise */
let tag_a = tag(a)
let tag_b = tag(b)
if tag_a == 248 /* object/exception */ {
magic(field(a, 1)) === magic(field(b, 1))
} else if tag_a == 251 /* abstract_tag */ {
raise(Invalid_argument("equal: abstract value"))
} else if tag_a != tag_b {
if tag_a != tag_b {
false
} else {
let len_a = size(a)
Expand Down