Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: let Node.js perform microtask checkpoint in the main process (#2…
…4131) (#24180) * fix: let Node.js perform microtask checkpoint in the main process * fix: don't specify v8::MicrotasksScope for explicit policy * fix: remove checkpoint from some call-sites We already perform checkpoint at the end of a task, either through MicrotaskRunner or through NodeBindings. There isn't a need to add them again when calling into JS except when dealing with promises. * fix: remove checkpoint from some call-sites We already perform checkpoint at the end of a task, either through MicrotaskRunner or through NodeBindings. There isn't a need to add them again when calling into JS except when dealing with promises. * fix incorrect specs * default constructor arguments are considered for explicit mark * add regression spec
- Loading branch information
1 parent
e74a402
commit 1ee98b4
Showing
19 changed files
with
149 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (c) 2020 GitHub, Inc. | ||
// Use of this source code is governed by the MIT license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "native_mate/microtasks_scope.h" | ||
|
||
namespace mate { | ||
|
||
MicrotasksScope::MicrotasksScope(v8::Isolate* isolate, | ||
bool ignore_browser_checkpoint) { | ||
if (v8::Locker::IsActive()) { | ||
if (!ignore_browser_checkpoint) | ||
v8::MicrotasksScope::PerformCheckpoint(isolate); | ||
} else { | ||
v8_microtasks_scope_ = std::make_unique<v8::MicrotasksScope>( | ||
isolate, v8::MicrotasksScope::kRunMicrotasks); | ||
} | ||
} | ||
|
||
MicrotasksScope::~MicrotasksScope() = default; | ||
|
||
} // namespace mate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) 2020 GitHub, Inc. | ||
// Use of this source code is governed by the MIT license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef NATIVE_MATE_NATIVE_MATE_MICROTASKS_SCOPE_H_ | ||
#define NATIVE_MATE_NATIVE_MATE_MICROTASKS_SCOPE_H_ | ||
|
||
#include <memory> | ||
|
||
#include "base/macros.h" | ||
#include "v8/include/v8.h" | ||
|
||
namespace mate { | ||
|
||
// In the browser process runs v8::MicrotasksScope::PerformCheckpoint | ||
// In the render process creates a v8::MicrotasksScope. | ||
class MicrotasksScope { | ||
public: | ||
explicit MicrotasksScope(v8::Isolate* isolate, | ||
bool ignore_browser_checkpoint = false); | ||
~MicrotasksScope(); | ||
|
||
private: | ||
std::unique_ptr<v8::MicrotasksScope> v8_microtasks_scope_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(MicrotasksScope); | ||
}; | ||
|
||
} // namespace mate | ||
|
||
#endif // NATIVE_MATE_NATIVE_MATE_MICROTASKS_SCOPE_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.