This repository was archived by the owner on Mar 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathIsolate.php
248 lines (219 loc) · 6.88 KB
/
Isolate.php
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
<?php declare(strict_types=1);
/**
* This file is part of the phpv8/php-v8 PHP extension.
*
* Copyright (c) 2015-2018 Bogdan Padalko <thepinepain@gmail.com>
*
* Licensed under the MIT license: http://opensource.org/licenses/MIT
*
* For the full copyright and license information, please view the
* LICENSE file that was distributed with this source or visit
* http://opensource.org/licenses/MIT
*/
namespace V8;
use Throwable;
use V8\Exceptions\ValueException;
class Isolate
{
const MEMORY_PRESSURE_LEVEL_NONE = 0;
const MEMORY_PRESSURE_LEVEL_MODERATE = 1;
const MEMORY_PRESSURE_LEVEL_CRITICAL = 2;
public function __construct(StartupData $snapshot = null)
{
}
/**
* Enter isolate and execute callback
*
* @param callable $callback Callback to execute. Current isolate object will be passed as first argument.
*
* @return mixed Value returned by callback
*/
public function within(callable $callback)
{
}
public function setMemoryLimit(int $memory_limit_in_bytes)
{
}
public function getMemoryLimit(): int
{
}
public function isMemoryLimitHit(): bool
{
}
public function setTimeLimit(float $time_limit_in_seconds)
{
}
public function getTimeLimit(): float
{
}
public function isTimeLimitHit(): bool
{
}
/**
* Optional notification that the system is running low on memory.
* V8 uses these notifications to guide heuristics.
* It is allowed to call this function from another thread while
* the isolate is executing long running JavaScript code.
*
* @param int $level
*
* @return void
*/
public function memoryPressureNotification(int $level)
{
}
/**
* Get statistics about the heap memory usage.
*
* @return HeapStatistics
*/
public function getHeapStatistics(): HeapStatistics
{
}
/**
* Returns true if this isolate has a current context.
*
* @return bool
*/
public function inContext(): bool
{
}
/**
* Returns the last entered context.
*
* @return Context
*/
public function getEnteredContext(): Context
{
}
/**
* Schedules an exception to be thrown when returning to JavaScript. When an
* exception has been scheduled it is illegal to invoke any JavaScript
* operation; the caller must return immediately and only after the exception
* has been handled does it become legal to invoke JavaScript operations.
*
* @param Context $context
* @param Value $value
* @param Throwable|null $e Exception to associate with a given value.
* Because how underlying object wiring done, wiring PHP to V8 exceptions
* is possible only for V8 exception that are instances of ObjectValue.
*
* @return void
*
* @throws ValueException When trying to associate external exception with non-object value
* @throws ValueException When another external exception is already associated with a given value
*/
public function throwException(Context $context, Value $value, Throwable $e = null)
{
}
/**
* Forcefully terminate the current thread of JavaScript execution
* in the given isolate.
*
* This method can be used by any thread even if that thread has not
* acquired the V8 lock with a Locker object.
*/
public function terminateExecution()
{
}
/**
* Is V8 terminating JavaScript execution.
*
* Returns true if JavaScript execution is currently terminating
* because of a call to TerminateExecution. In that case there are
* still JavaScript frames on the stack and the termination
* exception is still active.
*
* @return bool
*/
public function isExecutionTerminating(): bool
{
}
/**
* Resume execution capability in the given isolate, whose execution
* was previously forcefully terminated using TerminateExecution().
*
* When execution is forcefully terminated using TerminateExecution(),
* the isolate can not resume execution until all JavaScript frames
* have propagated the uncatchable exception which is generated. This
* method allows the program embedding the engine to handle the
* termination event and resume execution capability, even if
* JavaScript frames remain on the stack.
*
* This method can be used by any thread even if that thread has not
* acquired the V8 lock with a Locker object.
*/
public function cancelTerminateExecution()
{
}
/**
* Optional notification that the embedder is idle.
* V8 uses the notification to perform garbage collection.
* This call can be used repeatedly if the embedder remains idle.
* Returns true if the embedder should stop calling IdleNotificationDeadline
* until real work has been done. This indicates that V8 has done
* as much cleanup as it will be able to do.
*
* The deadline_in_seconds argument specifies the deadline V8 has to finish
* garbage collection work. deadline_in_seconds is compared with
* MonotonicallyIncreasingTime() and should be based on the same timebase as
* that function. There is no guarantee that the actual work will be done
* within the time limit.
*
* @param double $deadline_in_seconds
*
* @return bool
*/
public function idleNotificationDeadline($deadline_in_seconds): bool
{
}
/**
* Optional notification that the system is running low on memory.
* V8 uses these notifications to attempt to free memory.
*/
public function lowMemoryNotification()
{
}
/**
* Optional notification to tell V8 the current performance requirements
* of the embedder based on RAIL.
* V8 uses these notifications to guide heuristics.
* This is an unfinished experimental feature. Semantics and implementation
* may change frequently.
*
* @param int $rail_mode
*
* @return void
*/
public function setRAILMode(int $rail_mode)
{
}
/**
* Check if V8 is dead and therefore unusable. This is the case after
* fatal errors such as out-of-memory situations.
*
* @return bool
*/
public function isDead(): bool
{
}
/**
* Check if this isolate is in use.
* True if at least one thread Enter'ed this isolate.
*
* @return bool
*/
public function isInUse(): bool
{
}
/**
* Tells V8 to capture current stack trace when uncaught exception occurs
* and report it to the message listeners. The option is off by default.
*
* @param bool $capture
* @param int $frame_limit
*/
public function setCaptureStackTraceForUncaughtExceptions(bool $capture, int $frame_limit = 10)
{
}
}