Repository navigation
Expand file tree
/
Copy pathCodeCacheQueue.h
More file actions
42 lines (33 loc) · 1.79 KB
/
Copy pathCodeCacheQueue.h
File metadata and controls
42 lines (33 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef NATIVESCRIPT_COMMON_LOADER_CODE_CACHE_QUEUE_H_
#define NATIVESCRIPT_COMMON_LOADER_CODE_CACHE_QUEUE_H_
#include <v8.h>
#include <memory>
#include "ns/RuntimeLiveness.h"
#include "ns/loader/CodeCache.h"
// Deferred code-cache creation, one queue per isolate.
//
// Creating a cache needs the isolate's thread and costs about a fifth of a
// cold compile. So it waits until loading has been quiet for 0.5 s, then
// creates one cache per event-loop task, 16 ms apart, and hands the bytes to
// the core's writer thread (PostCodeCacheWrite).
namespace nativescript::common::loader {
// Queues creation of the cache for a script compiled from the source that
// entry.source describes. Call it when there was no cache or V8 rejected the
// one it was given: a rejected cache stays on disk until it is republished.
// Isolate thread, under the Locker.
void QueueCodeCache(v8::Isolate* isolate,
v8::Local<v8::UnboundModuleScript> script,
CodeCacheEntry entry);
void QueueCodeCache(v8::Isolate* isolate, v8::Local<v8::UnboundScript> script,
CodeCacheEntry entry);
// The app moved to the background, where the deferred tasks may never run:
// creates every cache queued for the runtime in one event-loop task. The
// platform calls it for each runtime it wants flushed, with the token it took
// from loader::LivenessFor on the isolate's thread; null does nothing. Any
// thread.
void NotifyAppBackgrounded(const std::shared_ptr<RuntimeLiveness>& liveness);
// The same through the isolate, for a caller that keeps the runtime alive
// across the call (its own thread, or a pin on its teardown). Any thread.
void NotifyAppBackgrounded(v8::Isolate* isolate);
} // namespace nativescript::common::loader
#endif // NATIVESCRIPT_COMMON_LOADER_CODE_CACHE_QUEUE_H_