Object.ForceSet to bypass accessors.

65 views
Skip to first unread message

Jane Chen

unread,
Oct 6, 2015, 2:44:27 PM10/6/15
to v8-users
In v8 4.7.0, Object.ForceSet is deprecated.  What is the new recommended way of bypassing accessors?

The use case I have is that I lazily create global objects and functions using accessors.  Once it is created, I want to reset the accessor and force save the created objects on Global.  

Thanks.

Jakob Kummerow

unread,
Oct 6, 2015, 3:57:40 PM10/6/15
to v8-users
Have you checked bit.ly/v8-api-changes ?

--
--
v8-users mailing list
v8-u...@googlegroups.com
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups "v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Toon Verwaest

unread,
Oct 7, 2015, 3:52:08 AM10/7/15
to v8-users

We don't have such alternative right now (last time I checked). We're still working out the best way to support that use case, which is important to V8/DOM as well. One way would be to always go through the accessor, even after lazy instantiation. I can imagine this to be too slow right now though.

Regards,
Toon

Jane Chen

unread,
Oct 7, 2015, 8:55:51 PM10/7/15
to v8-users
Jacob, Toon,

Both of your replies are very helpful.  I'll keep the API change link for my reference going forward.

Thanks a lot!

Jane

Jane Chen

unread,
Oct 30, 2015, 5:35:57 PM10/30/15
to v8-users
If it was only a performance concern to always go through accessors, it is now also a functionality issue for profiling.  The function name in cpu profile result shows up as "get <property name>" for the last property this accessor function is associated to.

I tried CreateDataProperty in place of ForceSet, but that doesn't do it.  My function becomes undefined after the accessor is set to 0 and CreateDataProperty is called.  Is that expected behavior?


On Wednesday, October 7, 2015 at 12:52:08 AM UTC-7, Toon Verwaest wrote:

Toon Verwaest

unread,
Jan 27, 2016, 10:57:56 AM1/27/16
to v8-users
In https://codereview.chromium.org/1632603002/ I've changed the default setter behavior for accessors installed using "SetNativeDataProperty" to do exactly that: replace the accessor with a data property. If you don't provide a setter yourself, you'll get that behavior. Lazy computed properties like you suggest can just call "set" on themselves and they'll be transformed to data properties.

Does that work?
Toon

Jane Chen

unread,
Feb 1, 2016, 12:45:08 PM2/1/16
to v8-users
Toon,

Thanks for the heads-up.  I am currently on 4.6.88 and am still using ForceSet.  I'd love to try it out when I refresh my build.  Which release is this going into?

Jane
Reply all
Reply to author
Forward
0 new messages