Skip to content
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

Merged
merged 1 commit into from
Apr 15, 2023

Conversation

kentonv
Copy link
Member

@kentonv kentonv commented Apr 15, 2023

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.

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.
@kentonv kentonv requested review from mikea and dom96 April 15, 2023 02:44
@@ -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.
Copy link
Member

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)
Copy link
Member

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.

Copy link
Member

@jasnell jasnell left a 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.
Copy link
Contributor

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.

@kentonv
Copy link
Member Author

kentonv commented Apr 15, 2023

Agreed with comments but will address in a separate PR for logistical reasons.

@kentonv kentonv merged commit 2a71783 into main Apr 15, 2023
@kentonv kentonv deleted the kenton/stack-scope branch April 15, 2023 22:23
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants