-
-
Notifications
You must be signed in to change notification settings - Fork 402
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
Refactoring Value (decouple Gc
from Value
)
#465
Comments
This is needed for the VM also, we want to be able to store Sized Values on the stack without them being wrapped in the GC. For now we’re just storing he cloned pointer on the stack (which isn’t ideal but can change it once this is done) I’m glad you raised this, it’s refactor I agree with |
Gc
from Value
)
It seems that (correct me if I'm wrong), |
I think you're right yes, all the other values are immutable (even the symbol). Looking at SpiderMonkey: They use it whenever a new object is needed: |
Also I think we can make it even better by making the This should be a much better option than garbage collecting it, in terms of performance. What do you think? @Razican @jasonwilliams Edit: I think we can make it even better 😅 , by not storing it as a I think, although I'm not sure, but If we store them as a This will greatly improve performance when checking strings, especially large strings I think we should use |
Wouldn't this be almost interning them? What if we have two I think in that case we wouldn't be able to get the optimisation, right? We currently create each string separately, so I don't think there is a case where the But I like this idea, maybe we should try to intern them again (and we should have a benchmark for string comparison and concatenation). |
Not exactly. In string interning the strings are held in an interner structure and the interned strings live as long as the interner lives, but with
Then a normal string compare is done. in this case we would not have the optimization.
I think let x = "hello";
let y = x;
x == y // just a pointer check is needed we technically already have a
We should have this, definitely, I would also like to see the speed up for #419 |
Ok, yes, I see it. String interning would give better performance, but this is an almost free optimisation that will probably be easy to implement, so we should do it.
Let me create a couple of benchmarks for strings, I will PR today. |
#419 Has been merged, I'll start working on this :) |
Whats wrong with the current implementation?
The current implementation after #383 coupled the
Gc
andValue
together and the operations were promoted to the gc level, the problem with this is thatGc
values are stored in the heap which means a performance penalty. Furthermore we need to do some checks before accessing the underlyingValueData
.Changes
Value
logic/operations =>ValueData
ValueData
=>Value
(it makes more sense to call itValue
)Gc<...>
toValue::Object
field (Value::Object(Gc<GcCell<Object>>)
)If you have any suggestions on how to improve it, or even how other engines to it, please comment :)
I would like to start working on this preferably after #419 because the rebase is going to be a nightmare
The text was updated successfully, but these errors were encountered: