-
Notifications
You must be signed in to change notification settings - Fork 1
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
Refactor: Using values of Smtml
#128
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't seen everything. But the more I see. The more I think we should use Smtml.Expr.Ptr
for locations. I'm going to fix Ptr
so that we can apply it here more easily.
I'll review more during the day
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More reviews, could you also change the smtml pin to commit ff3c34ad926f7b4329fe7412fe31d270c7b2220b?
|
||
let equal (e1 : value) (e2 : value) : bool = E.equal e1 e2 [@@inline] | ||
let hash (e : value) = E.hash e [@@inline] | ||
let compare (e1 : value) (e2 : value) = compare (hash e1) (hash e2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compare
should probably be defined in Smtml
and we just use that
@@ -327,11 +327,11 @@ function NumberPrototypeToFixedAlt(global, this, strict, items) { | |||
z := ""; | |||
counter := 0; | |||
while (!(counter <= (f - k))) { | |||
z := s_concat(z, "0"); | |||
z := s_concat[z, "0"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s_concat
receives a list as parameter?
z := s_concat[z, "0"]; | |
z := s_concat [z, "0"]; |
I know for parsing it's all the same, but adding a space would make this look better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s_concat receives a list as parameter?
Yes, I think s_concat
already received a list as parameter before the change.
Maybe, in this case it was receiving a tuple instead of a list? Because I didn't change the semantics of the s_concat
, it is still an unary operator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, it might have been receiving a tuple. I don't know how this worked. But it was on ecmaref5 which supposedly we're not going to maintain?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, it might have been receiving a tuple. I don't know how this worked. But it was on ecmaref5 which supposedly we're not going to maintain?
The idea is to stop maintaining the ECMARef5, yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you run dune fmt
just to verify that everything is well formatted? Otherwise, I think I'm done.
@andreffnascimento This will probably break some tests for test262. But I'd rather not wait long to merge this as it is a monster PR 😅 and I want to catch the bugs earlier rather than later. If you can also just see if there is anything you'd like to change before we merge. @julianayang777 Could you rebase on main and add the description of changes you provided here to |
Ok, maybe it's better to do it after André has done the review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm done with my review. I'm going to approve this, so that you can merge this soon, but first take I look at my comments/proposals. I'm not going to merge #129 until this is done to avoid introducing extra merge conflicts. Also, I can run the entire Test262 to see how we are doing, but only after we are passing the CI. Btw, here is a link with the previous test results
if (el = "R") { return "Reference" } | ||
elif (el = "C") { return "Completion" } | ||
elif (el = "P") { return "PropertyIdentifier" } | ||
else { return "List" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@filipeom how sure are we that this is not going to break?? 😅
If we evaluate a list where the first element matches one of these cases, we will not get the correct type right? This used to be fine since tuples were only used internally, never in the JS AST, now I'm not sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@filipeom how sure are we that this is not going to break?? 😅
I'm confident it will break at some point 😅
If we evaluate a list where the first element matches one of these cases, we will not get the correct type right? This used to be fine since tuples were only used internally, never in the JS AST, now I'm not sure
Exactly. That's why I believe the completions and objects we return in lists should be something else. Since they are never extended, we could use esl arrays, which are simply OCaml arrays. Besides allowing O(1) read/write operations, they would also be more memory efficient. We could use this efficiency to add metadata in the initial element of the array, such as a unique location to a global object used only when building these completion arrays.
For example, in this function, we would know exactly what we have instead of hoping the list is as expected. I asked Juliana to open an issue about this here: #132. I think we can implement this without compromising the similarity of ecmaref to the standard.
| t = dtype_target; { Value.App (`Op t, []) } | ||
|
||
let dtype_target := | ||
| DTYPE_NULL; { Type.NullType } | ||
| DTYPE_INT; { Type.IntType } | ||
| DTYPE_FLT; { Type.FltType } | ||
| DTYPE_STR; { Type.StrType } | ||
| DTYPE_BOOL; { Type.BoolType } | ||
| DTYPE_SYMBOL; { Type.SymbolType } | ||
| DTYPE_LOC; { Type.LocType } | ||
| DTYPE_LIST; { Type.ListType } | ||
| DTYPE_TUPLE; { Type.TupleType } | ||
| DTYPE_CURRY; { Type.CurryType } | ||
| DTYPE_NULL; { "NullType" } | ||
| DTYPE_INT; { "IntType" } | ||
| DTYPE_FLT; { "FltType" } | ||
| DTYPE_STR; { "StrType" } | ||
| DTYPE_BOOL; { "BoolType" } | ||
| DTYPE_SYMBOL; { "SymbolType" } | ||
| DTYPE_LOC; { "LocType" } | ||
| DTYPE_LIST; { "ListType" } | ||
| DTYPE_TUPLE; { "TupleType" } | ||
| DTYPE_CURRY; { "CurryType" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a very strong opinion on this, so we can leave it as it is (specially because this may break things / slow things down). But shouldn't these types be stored as: Value.App (`Op "type", ["null"]
. I mean, it looks more consistent, but I'm not sure it is worth it. Opinions @filipeom @julianayang777
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that it looks more consistent, but yes, in both cases we will break things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that it looks more consistent. It also might help in pattern matching situations? For the solver it's all the same. Value applications are unitary so the strings in the list will be concatenated with the string in Op
to make an uninterpreted symbol.
So we can probably do it and optimize later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I will not change now because I am not sure if it will influence my other branch merge
. However, I will make the change in the next PR for branch merge
.
@@ -327,11 +327,11 @@ function NumberPrototypeToFixedAlt(global, this, strict, items) { | |||
z := ""; | |||
counter := 0; | |||
while (!(counter <= (f - k))) { | |||
z := s_concat(z, "0"); | |||
z := s_concat[z, "0"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, it might have been receiving a tuple. I don't know how this worked. But it was on ecmaref5 which supposedly we're not going to maintain?
The idea is to stop maintaining the ECMARef5, yes
@julianayang777 I'll just make |
- At this stage, the symbolic interpreter does not work for now using Encoding values instaed of val - At this stage, the symbolic interpreter does not work for now restore value `Loc`
Fixes most of the type errors reported by the typechecker while also trying to use more ternary operators to reduce branching. And, forces ecmaref6 compilation test to use typechecker.
e10eb8a
to
2deacaf
Compare
This will reduce the number of rules dune produces from 750k to 10k. Will not make compilation faster but it does make dune more responsive.
568387f
to
fc7dbe6
Compare
Can we merge this? |
For me, yes |
Changes
exp
,random
,typeof
and tuple related operators were removed from syntax and became external functions.Val.ml
) were changed to the values ofSmtml
. In the next code snippet, you can see how it was converted:Val.ml
toEExpr.ml
so that I could deleteVal.ml
. (But this might be the best approach😕).Concrete Interpreter
In the concrete execution, all the tests passed using the command
dune runtest
. However, for thetest262
suite, some tests are still failing. To fix it, we might change the ecmaref. (for instance, some of the tests failed due to change 3)Symbolic Interpreter
In the symbolic execution, the tests are not passing, which might be due to the way we have defined the symbol
undefined
. And the way of handling error insymbolic_value.ml
can be improved, because for now I have just putfailwith
.