-
Notifications
You must be signed in to change notification settings - Fork 335
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Manually tell V8 where the stack starts whenever we enter it. #544
Conversation
This uses a V8 patch. If the patch isn't present, it automatically skips it and relies on V8 to figure things out the normal way. The patch is needed in order to work around issues in our internal environment, especially the fact that /proc/self/maps is not accessible. The patch isn't needed when using workerd stand-alone.
@@ -2053,6 +2053,26 @@ class Lock { | |||
bool warningsLogged; | |||
}; | |||
|
|||
class V8StackScope { | |||
// One of this MUST be allocated on the stack before taking an isolate lock. It must be allocated | |||
// before any handles on the stack. This MUST NOT be allocated on the heap. |
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.
Non-blocking nit: should this use KJ_DISALLOW_COPY_AND_MOVE
?
@@ -310,7 +310,7 @@ class Isolate: public IsolateBase { | |||
// constructing a `Lock` on the stack. | |||
|
|||
public: | |||
Lock(const Isolate& isolate) | |||
Lock(const Isolate& isolate, V8StackScope& scope) |
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 assuming that this is passed here only to enforce the rule that it must exist before taking the lock? If so, a comment to that effect here would be helpful to warn off anyone who might come into this later and mistakenly assume that scope
should be removed because it is unused here.
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.
LGTM. It would likely be worthwhile adding a few comments on the use of this in the jsg README given that it'll be needed to be added to various tests from time to time.
// allocated on the heap. The purpose of V8StackScope is to capture the start of the stack | ||
// range that V8 must scan when performing conservative stack-scanning garbage collection. | ||
public: | ||
// No interface. |
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.
(not necessary) I wonder if in debug mode we can compare this with stack pointer and detect when it was created on the heap.
Agreed with comments but will address in a separate PR for logistical reasons. |
This uses a V8 patch. If the patch isn't present, it automatically skips it and relies on V8 to figure things out the normal way.
The patch is needed in order to work around issues in our internal environment, especially the fact that /proc/self/maps is not accessible. The patch isn't needed when using workerd stand-alone.