chakra-core / ChakraCore

ChakraCore is an open source Javascript engine with a C API.
MIT License
9.13k stars 1.2k forks source link

perf: Context independent, shared null && undefined #3847

Open obastemur opened 7 years ago

obastemur commented 7 years ago

Currently null and undefined are created per JavascriptLibrary.

Any objections to making null, undefined values are allocated per framework only once?

Is there anything else that we could use the same approach?

MikeHolman commented 7 years ago

true and false are potentially useful additions.

I like the idea of sharing more static data between contexts, but I'm concerned that there may be a number of places where the ScriptContext is considered and will lead to us going down slow paths, and that you may run into a bunch of asserts.

obastemur commented 7 years ago

but I'm concerned that there may be a number of places where the ScriptContext is considered and will lead to us going down slow paths, and that you may run into a bunch of asserts.

@MikeHolman could you provide more context on this?

MikeHolman commented 7 years ago

The example I'm thinking of is that for property caches, if an object's scriptContext isn't the current context we won't cache it. I think there are a number of places where we will do these type of comparisons.

obastemur commented 7 years ago

I see. How your scenario could prevent us from having a single undefined or null framework wide? (this is the part I didn't understand though)

MikeHolman commented 7 years ago

I'm having a hard time coming up with anything that will concretely be a problem, so maybe there isn't anything. I just have a feeling that there will be a number of subtle issues.