v8::ScriptOrigin line/column offset

27 views
Skip to first unread message

Bit Cortex

unread,
Nov 11, 2020, 3:26:30 PM11/11/20
to v8-users
Hello!

Could someone describe the purpose of the line and column offset properties of v8::ScriptOrigin? What effect do nonzero values have?

Thanks!

Ben Noordhuis

unread,
Nov 11, 2020, 5:05:50 PM11/11/20
to v8-users
I believe they're intended to offset IIFEs[1] and other wrappers that
embedders may want to add around the user's script code.

[https://en.wikipedia.org/wiki/Immediately-invoked_function_expression]

Bit Cortex

unread,
Nov 12, 2020, 9:13:48 AM11/12/20
to v8-users
Thanks, but what's the actual effect of setting the line or column offset to a nonzero value?

Based on your description, I'd guess that it might affect stack traces and possibly debugging.

Can someone confirm that? Or do I not understand correctly?

Ben Ernst

unread,
Nov 12, 2020, 11:26:51 PM11/12/20
to v8-u...@googlegroups.com
Yes that's right, when a debugger or an error message says you're on line X and column Y, it deducts the values you specify in the offsets. So if you transform user's code in some form, the error messages can be adjusted to still have the right line numbers and column numbers.



--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/v8-users/f9f3c898-d022-48d9-b14b-d670731b8008n%40googlegroups.com.

Simon Zünd

unread,
Nov 13, 2020, 1:22:51 AM11/13/20
to v8-users
This is used e.g. when your script is inline in <script> tags in HTML. Then the ScriptOrigin will contain the line/column of the opening <script> tag, so stack traces contain the absolute line/column number inside the HTML document.

I don't know if the information is used in other places besides stack traces and debugging though.

Bit Cortex

unread,
Nov 13, 2020, 9:05:16 AM11/13/20
to v8-users
Thanks for your responses!
Reply all
Reply to author
Forward
0 new messages