forked from tc39/proposal-shadowrealm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.emu
532 lines (462 loc) · 25.1 KB
/
index.emu
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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
<!doctype html>
<meta charset="utf8">
<link href="ecmarkup.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/github.min.css">
<script src="ecmarkup.js"></script>
<pre class=metadata>
title: ECMAScript Realms Spec Proposal
stage: 0
contributors: Dave Herman, Caridy Patiño
status: draft
copyright: false
location: https://rawgit.com/caridy/proposal-realms/master/index.html
</pre>
<emu-table id="table-1" caption="Well-known Intrinsic Objects">
<table>
<tbody>
<tr>
<th>Intrinsic Name</th>
<th>Global Name</th>
<th>ECMAScript Language Association</th>
</tr>
<tr>
<td>%Realm%</td>
<td><code>Realm</code></td>
<td>…</td>
</tr>
<tr>
<td>%RealmPrototype%</td>
<td><code>Realm.prototype</code></td>
<td>…</td>
</tr>
</tbody>
</table>
</emu-table>
<!-- es6num="8.2" -->
<emu-clause id="sec-code-realms">
<h1>Realms</h1>
<emu-table id="table-21" caption="Realm Record Fields">
<table>
<tbody>
<tr>
<th>Field Name</th>
<th>Value</th>
<th>Meaning</th>
</tr>
<tr>
<td>[[HostDefined]]</td>
<td>...</td>
<td>...</td>
</tr>
<tr>
<td>[[EvalHook]]</td>
<td>A function object or *undefined*</td>
<td>The function that is used as the eval hook. If [[EvalHook]] is undefined, the hook invoker will carry on the default behavior.</td>
</tr>
<tr>
<td>[[IsDirectEvalHook]]</td>
<td>A function object or *undefined*</td>
<td>The function that is used as the direct eval check hook. If [[IsDirectEvalHook]] is undefined, the hook invoker will carry on the default behavior.</td>
</tr>
<tr>
<td>[[ImportHook]]</td>
<td>A function object or *undefined*</td>
<td>The function that is used as the import hook. If [[ImportHook]] is undefined, the hook invoker will carry on the default behavior.</td>
</tr>
<tr>
<td>[[ImportMetaHook]]</td>
<td>A function object or *undefined*</td>
<td>The function that is used as the import.meta hook. If [[ImportMetaHook]] is undefined, the hook invoker will carry on the default behavior.</td>
</tr>
</tbody>
</table>
</emu-table>
<emu-clause id="sec-invokeisdirectevalhook" aoid="InvokeIsDirectEvalHook">
<h1>InvokeIsDirectEvalHook(_realmRec_, _func_)</h1>
<p>The abstract operation InvokeIsDirectEvalHook with arguments _realmRec_ and _func_ performs the following steps:</p>
<emu-alg>
1. Assert: realm is a Realm Record.
1. Let _fn_ be _realmRec_.[[IsDirectEvalHook]].
1. If _fn_ is *undefined*, return SameValue(_func_, %eval%).
1. Assert: IsCallable(_fn_) is *true*.
1. Let _result_ be ToBoolean( ? Call(_fn_, *undefined*, « _func_ »)).
1. Return _result_.
</emu-alg>
</emu-clause>
<emu-clause id="sec-invokedirectevalhook" aoid="InvokeDirectEvalHook">
<h1>InvokeDirectEvalHook ( _realmRec_, _x_ )</h1>
<p>The abstract operation InvokeDirectEvalHook with arguments _realmRec_ and _x_ performs the following steps:</p>
<emu-alg>
1. Assert: realm is a Realm Record.
1. Let _fn_ be _realmRec_.[[EvalHook]].
1. If _fn_ is *undefined*, return _x_.
1. Assert: IsCallable(_fn_) is *true*.
1. Return ? Call(_fn_, *undefined*, « _x_ »).
</emu-alg>
</emu-clause>
<emu-clause id="sec-invokeimporthook" aoid="InvokeImportHook">
<h1>InvokeImportHook ( _realmRec_, _referencingScriptOrModule_, _specifierString_, _promiseCapability_ )</h1>
<p>The abstract operation InvokeImportHook with arguments _realmRec_, _referencingScriptOrModule_, _specifier_ and _promiseCapability_ performs the following steps:</p>
<emu-alg>
1. Assert: _realmRec_ is a Realm Record.
1. Assert: Type(_specifierString_) is String.
1. Assert: _referencingScriptOrModule_ is a Script Record or Module Record (i.e. is not null).
1. Assert: _resultCapability_ is a PromiseCapability Record.
1. Let _fn_ be _realmRec_.[[ImportHook]].
1. If _fn_ is *undefined*, then
1. Perform ! HostImportModuleDynamically(_referencingScriptOrModule_, _specifierString_, _promiseCapability_).
1. Assert: IsCallable(_fn_) is *true*.
1. If _referencingScriptOrModule_ is a Module Record, then
1. Assert: ModuleEvaluation has already been invoked on _referencingScriptOrModule_ and successfully completed.
1. Let _referrer_ be GetModuleNamespace(_referencingScriptOrModule_).
1. IfAbruptRejectPromise(_referrer_, _promiseCapability_).
1. Else,
1. Let _referrer_ be *null*.
1. Let _value_ be Call(_fn_, *undefined*, « _referrer_, _specifier_ »).
1. IfAbruptRejectPromise(_value_, _promiseCapability_).
1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, « _value_ »).
</emu-alg>
</emu-clause>
</emu-clause>
<!-- es6num="15.2.1.16.1" -->
<emu-clause id="sec-parsemodule" aoid="ParseModule">
<h1>ParseModule ( _sourceText_, _realm_, _hostDefined_ )</h1>
<emu-alg>
1. ...
1. Let _exportEntries_ be ExportEntries of _body_.
1. <ins>Let _resolvedModules_ be a new empty List</ins>.
1. For each ExportEntry Record _ee_ in _exportEntries_, do
1. ...
1. Return Source Text Module Record {[[Realm]]: _realm_, [[Environment]]: *undefined*, [[HostDefined]]: _hostDefined_, [[Namespace]]: *undefined*, [[Evaluated]]: *false*, [[ECMAScriptCode]]: _body_, [[RequestedModules]]: _requestedModules_, [[ImportEntries]]: _importEntries_, [[LocalExportEntries]]: _localExportEntries_, [[StarExportEntries]]: _starExportEntries_, [[IndirectExportEntries]]: _indirectExportEntries_<ins>, [[ResolvedModules]]: _resolvedModules_</ins>}.
</emu-alg>
</emu-clause>
<emu-clause id="sec-resolvemodule" aoid="ResolveModule">
<h1>ResolveModule ( _referencingModule_, _specifier_ )</h1>
<p>The abstract operation ResolveModule with arguments _referencingModule_ and _specifier_ resolves the concrete Module Record subclass instance that corresponds to the ModuleSpecifier String, _specifier_, occurring within the context of the module represented by the Source Text Module Record _referencingModule_. ResolveModule performs the following steps:</p>
<emu-alg>
1. Assert: _referencingModule_ is a Source Text Module Record.
1. Assert: Type(_specifier_) is String.
1. Let _resolvedModules_ be _referencingModule_.[[ResolvedModules]].
1. Repeat for each Record {[[Key]], [[Value]]} _p_ that is an element of _requiredModule_,
1. If _p_.[[Key]] is is equal _specifier_, then
1. Return _p_.[[Value]].
1. Let _requiredModule_ be ? HostResolveImportedModule(_referencingModule_, _specifier_).
1. Append _requiredModule_ as the last element of _resolvedModules_.
1. Return _requiredModule_.
</emu-clause>
<!-- es6num="15.2.1.16.5" -->
<emu-clause id="sec-moduleevaluation">
<h1>ModuleEvaluation( ) Concrete Method</h1>
<emu-alg>
1. ...
6. For each String _required_ that is an element of _module_.[[RequestedModules]], do
1. Let _requiredModule_ be ! <del>HostResolveImportedModule</del><ins>ResolveModule</ins>(_module_, _required_).
1. ...
1. ...
</emu-alg>
</emu-clause>
<!-- es6num="15.2.1.16.2" -->
<emu-clause id="sec-getexportednames">
<h1>GetExportedNames( _exportStarSet_ ) Concrete Method</h1>
<emu-alg>
1. ...
14. Let _requestedModule_ be ? <del>HostResolveImportedModule</del><ins>ResolveModule</ins>(_module_, _e_.[[ModuleRequest]]).
1. ...
</emu-alg>
</emu-clause>
<!-- es6num="15.2.1.16.3" -->
<emu-clause id="sec-resolveexport">
<h1>ResolveExport( _exportName_, _resolveSet_ ) Concrete Method</h1>
<emu-alg>
1. ...
4. For each ExportEntry Record _e_ in _module_.[[IndirectExportEntries]], do
1. If SameValue(_exportName_, _e_.[[ExportName]]) is *true*, then
1. Assert: _module_ imports a specific binding for this export.
1. Let _importedModule_ be ? <del>HostResolveImportedModule</del><ins>ResolveModule</ins>(_module_, _e_.[[ModuleRequest]]).
1. ...
1. ...
7. For each ExportEntry Record _e_ in _module_.[[StarExportEntries]], do
1. Let _importedModule_ be ? <del>HostResolveImportedModule</del><ins>ResolveModule</ins>(_module_, _e_.[[ModuleRequest]]).
...
1. ...
</emu-alg>
</emu-clause>
<!-- es6num="15.2.1.16.4" -->
<emu-clause id="sec-moduledeclarationinstantiation">
<h1>ModuleDeclarationInstantiation( ) Concrete Method</h1>
<emu-alg>
1. ...
8. For each String _required_ that is an element of _module_.[[RequestedModules]], do
1. NOTE: Before instantiating a module, all of the modules it requested must be available. An implementation may perform this test at any time prior to this point.
1. Let _requiredModule_ be ? <del>HostResolveImportedModule</del><ins>ResolveModule</ins>(_module_, _required_).
1. ...
1. ...
12. For each ImportEntry Record _in_ in _module_.[[ImportEntries]], do
1. Let _importedModule_ be ! <del>HostResolveImportedModule</del><ins>ResolveModule</ins>(_module_, _in_.[[ModuleRequest]]).
1. NOTE: The above call cannot fail because imported module requests are a subset of _module_.[[RequestedModules]], and these have been resolved earlier in this algorithm.
1. ...
1. ...
</emu-alg>
</emu-clause>
<!-- es6num="18.2.1.1" -->
<emu-clause id="sec-performeval" aoid="PerformEval">
<h1>Runtime Semantics: PerformEval( _x_, _evalRealm_, _strictCaller_, _direct_ )</h1>
<p>The abstract operation PerformEval with arguments _x_, _evalRealm_, _strictCaller_, and _direct_ performs the following steps:</p>
<emu-alg>
1. Assert: If _direct_ is *false*, then _strictCaller_ is also *false*.
1. <ins>If _direct_ is *true*, then</ins>
1. <ins>Let _x_ be ? InvokeDirectEvalHook(_x_, _evalRealm_).</ins>
1. If Type(_x_) is not String, return _x_.
1. ...
</emu-alg>
</emu-clause>
<!-- es6num="12.3.4.1" -->
<emu-clause id="sec-function-calls-runtime-semantics-evaluation">
<h1>Runtime Semantics: Evaluation</h1>
<emu-grammar>CallExpression : CoverCallExpressionAndAsyncArrowHead</emu-grammar>
<emu-alg>
1. Let _expr_ be CoveredCallExpression of |CoverCallExpressionAndAsyncArrowHead|.
1. Let _memberExpr_ be the |MemberExpression| of _expr_.
1. Let _arguments_ be the |Arguments| of _expr_.
1. Let _ref_ be the result of evaluating _memberExpr_.
1. Let _func_ be ? GetValue(_ref_).
1. If Type(_ref_) is Reference and IsPropertyReference(_ref_) is *false* and GetReferencedName(_ref_) is `"eval"`, then
1. <ins>Let _evalRealm_ be the current Realm Record</ins>.
1. <ins>Let _isDirectEval_ be ? InvokeIsDirectEvalHook(_evalRealm_, _func_)</ins>.
1. If <ins>_isDirectEval_</ins><del>SameValue(_func_, %eval%)</del> is *true*, then
1. Let _argList_ be ? ArgumentListEvaluation(_arguments_).
1. If _argList_ has no elements, return *undefined*.
1. Let _evalText_ be the first element of _argList_.
1. If the source code matching this |CallExpression| is strict mode code, let _strictCaller_ be *true*. Otherwise let _strictCaller_ be *false*.
1. <del>Let _evalRealm_ be the current Realm Record</del>.
1. Perform ? HostEnsureCanCompileStrings(_evalRealm_, _evalRealm_).
1. Return ? PerformEval(_evalText_, _evalRealm_, _strictCaller_, *true*).
1. ...
</emu-alg>
...
</emu-clause>
<emu-clause id="sec-import-call-runtime-semantics-evaluation">
<h1>Runtime Semantics: Evaluation</h1>
<emu-grammar>ImportCall : `import` `(` AssignmentExpression `)`</emu-grammar>
<emu-alg>
1. Let _referencingScriptOrModule_ be ! GetActiveScriptOrModule().
1. Assert: _referencingScriptOrModule_ is a Script Record or Module Record (i.e. is not *null*).
1. Let _argRef_ be the result of evaluating |AssignmentExpression|.
1. Let _specifier_ be ? GetValue(_argRef_).
1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%).
1. Let _specifierString_ be ToString(_specifier_).
1. IfAbruptRejectPromise(_specifierString_, _promiseCapability_).
1. <ins>Let _ctx_ be the running execution context</ins>.
1. <ins>Let _currentRealm_ be ctx's Realm</ins>.
1. <ins>Perform ! InvokeImportHook(_currentRealm_, _referencingScriptOrModule_, _specifierString_, _promiseCapability_)</ins>.
1. <del>Perform ! HostImportModuleDynamically(_referencingScriptOrModule_, _specifierString_, _promiseCapability_)</del>.
1. Return _promiseCapability_.[[Promise]].
</emu-alg>
</emu-clause>
<emu-clause id="sec-realm-objects">
<h1>Realm Objects</h1>
<emu-clause id="sec-realm-abstract-operations">
<h1>Realm Abstract Operations</h1>
<emu-clause id="sec-create-realm-rec">
<h1>CreateRealmRec ( _intrinsics_ )</h1>
<emu-alg>
1. Let _realmRec_ be a new Realm Record.
1. If _intrinsics_ is *undefined*, then
1. Perform CreateIntrinsics(realmRec).
1. Else
1. Assert: In this case, _intrinsics_ must be a Record with field names listed in column one of Table 7.
1. Set _realmRec_.[[Intrinsics]] to _intrinsics_.
1. Set _realmRec_.[[GlobalObject]] to *undefined*.
1. Set _realmRec_.[[GlobalEnv]] to *undefined*.
1. Set _realmRec_.[[TemplateMap]] to a new empty List.
1. Return _realmRec_.
</emu-alg>
</emu-clause>
</emu-clause>
<emu-clause id="sec-realm-built-in-function-objects">
<h1>Built-in Function Objects</h1>
<emu-clause id="sec-realm-default-import-hook-functions">
<h1>Realm Default Import Hook Functions</h1>
<p>A Realm default import hook function is an anonymous built-in function.</p>
<p>When a Realm default import hook function is called with arguments _referrer_ and _specifier_, the following steps are taken:</p>
<emu-alg>
1. Throw a new *TypeError*.
</emu-alg>
<emu-note>
By default, newly created realms do not expose host specific behavior when evaluating _import()_ calls.
</emu-note>
</emu-clause>
</emu-clause>
<emu-clause id="sec-the-realm-constructor">
<h1>The Realm Constructor</h1>
<p>
The Ream constructor is the %Realm% intrinsic object and the initial value of the *Realm* property of the global object. When called as a constructor it creates and initializes a new Realm object. Realm is not intended to be called as a function and will throw an exception when called in that manner.
</p>
<p>
The Realm constructor is designed to be subclassable. It may be used as the value in an extends clause of a class definition. Subclass constructors that intend to inherit the specified Realm behaviour must include a super call to the Realm constructor to create and initialize the subclass instance with the internal state necessary to support the Realm.prototype built-in methods.
</p>
<emu-clause id="sec-realm" aoid="Realm">
<h1>Realm ([ _options_ ])</h1>
When Realm is called with argument _option_ performs the following steps:
<emu-alg>
1. If NewTarget is *undefined*, throw a *TypeError* exception.
1. Let _O_ be ? OrdinaryCreateFromConstructor(NewTarget, "%RealmPrototype%", « [[Realm]] »).
1. If _options_ is not *undefined*, then
1. Let _parentRealm_ be the current Realm Record.
1. Let _opts_ be ? ToObject(_options_).
1. Let _importHook_ be ? Get(_opts_, "importHook").
1. If _importHook_ is equal `"inherit"`, then
1. Set _importHook_ to _parentRealm_.[[ImportHook]].
1. Else if _importHook_ is not *undefined* and IsCallable(_importHook_) is *false*, throw a TypeError exception.
1. Let _importMetaHook_ be ? Get(_opts_, "importMetaHook").
1. If _importMetaHook_ is equal `"inherit"`, then
1. Set _importMetaHook_ to _parentRealm_.[[ImportMetaHook]].
1. Else if _importMetaHook_ is not *undefined* and IsCallable(_importMetaHook_) is *false*, throw a TypeError exception.
1. Let _evalHook_ be ? Get(_opts_, "evalHook").
1. If _evalHook_ is equal `"inherit"`, then
1. Set _evalHook_ to _parentRealm_.[[EvalHook]].
1. Else if _evalHook_ is not *undefined* and IsCallable(_evalHook_) is *false*, throw a TypeError exception.
1. Let _isDirectEvalHook_ be ? Get(_opts_, "isDirectEvalHook").
1. If _isDirectEvalHook_ is equal `"inherit"`, then
1. Set _isDirectEvalHook_ to _parentRealm_.[[IsDirectEvalHook]].
1. Else if _isDirectEvalHook_ is not *undefined* and IsCallable(_isDirectEvalHook_) is *false*, throw a TypeError exception.
1. Let _intrinsics_ be ? Get(_opts_, "intrinsics").
1. If _intrinsics_ is equal `"inherit"`, then
1. Set _intrinsics_ to _parentRealm_.[[Intrinsics]].
1. Else if _intrinsics_ is not *undefined*, throw a TypeError exception.
1. Let _thisValue_ be ? Get(_opts_, "thisValue").
1. If _thisValue_ is not *undefined* and Type(_thisValue_) is not Object, throw a TypeError exception.
1. Let _realmRec_ be CreateRealmRec(_intrinsics_).
1. Set _O_.[[Realm]] to _realmRec_.
1. Perform ? SetRealmGlobalObject(_realmRec_, *undefined*, _thisValue_).
1. If _importHook_ is *undefined*, then
1. Let _importHook_ be a new built-in function object as defined in <emu-xref href="#sec-realm-default-import-hook-functions"></emu-xref>.
1. Set _realmRec_.[[ImportHook]] to _importHook_.
1. If _evalHook_ is not *undefined*, then
1. Set _realmRec_.[[EvalHook]] to _evalHook_.
1. If _isDirectEvalHook_ is not *undefined*, then
1. Set _realmRec_.[[IsDirectEvalHook]] to _isDirectEvalHook_.
1. Let _init_ be ? GetMethod(_O_, *"init"*).
1. If IsCallable(_init_) is not *true*, throw a *TypeError* exception.
1. Perform ? Call(_init_, _O_).
1. Return _O_.
</emu-alg>
</emu-clause>
</emu-clause>
<emu-clause id="sec-properties-of-the-realm-constructor">
<h1>Properties of the Realm Constructor</h1>
The value of the [[Prototype]] internal slot of the *Realm* constructor is the intrinsic object %FunctionPrototype%.
</emu-clause>
<emu-clause id="sec-properties-of-the-realm-prototype-object">
<h1>Properties of the Realm Prototype Object</h1>
<emu-clause id="sec-realm.prototype.init">
<h1>Realm.prototype.init ()</h1>
<emu-alg>
1. Let _O_ be *this* value.
1. If Type(_O_) is not Object, throw a *TypeError* exception.
1. If _O_ does not have an [[Realm]] internal slot, throw a *TypeError* exception.
1. Perform ? SetDefaultGlobalBindings(_O_.[[Realm]]).
</emu-alg>
<emu-note>
Extensible web: This is the dynamic way to define globals in a new realm.
</emu-note>
</emu-clause>
<emu-clause id="sec-realm.prototype.eval">
<h1>Realm.prototype.eval ( _x_ )</h1>
Synchronously execute a top-level script. The _x_ is interpreted as a Script and evaluated with this bound to the realm's global object.
<emu-alg>
1. Let _O_ be *this* value.
1. If Type(_O_) is not Object, throw a *TypeError* exception.
1. If _O_ does not have an [[Realm]] internal slot, throw a *TypeError* exception.
1. Let _evalRealm_ be _O_.[[Realm]].
1. Perform ? HostEnsureCanCompileStrings(the current Realm Record, _evalRealm_).
1. Return ? PerformEval(_x_, _evalRealm_, *false*, *false*).
</emu-alg>
<emu-note>
Extensible web: This is the dynamic equivalent of a <script> in HTML.
</emu-note>
</emu-clause>
<emu-clause id="sec-realm.prototype.global">
<h1>get Realm.prototype.global</h1>
Realm.prototype.global is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps:
<emu-alg>
1. Let _O_ be *this* value.
1. If Type(_O_) is not Object, throw a *TypeError* exception.
1. If _O_ does not have an [[Realm]] internal slot, throw a *TypeError* exception.
1. Return _O_.[[Realm]].[[GlobalObject]].
</emu-alg>
</emu-clause>
<emu-clause id="sec-realm.prototype.thisValue">
<h1>get Realm.prototype.thisValue</h1>
Realm.prototype.thisValue is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps:
<emu-alg>
1. Let _O_ be *this* value.
1. If Type(_O_) is not Object, throw a *TypeError* exception.
1. If _O_ does not have an [[Realm]] internal slot, throw a *TypeError* exception.
1. Let _envRec_ be _O_.[[Realm]].[[GlobalEnv]].
1. Return _envRec_.[[GlobalThisValue]].
</emu-alg>
</emu-clause>
<emu-clause id="sec-realm.prototype.stdlib">
<h1>get Realm.prototype.stdlib</h1>
Realm.prototype.stdlib is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps:
<emu-alg>
1. Let _O_ be *this* value.
1. If Type(_O_) is not Object, throw a *TypeError* exception.
1. If _O_ does not have an [[Realm]] internal slot, throw a *TypeError* exception.
1. Let _realmRec_ be _O_.[[Realm]].
1. Let global be realmRec.[[GlobalObject]].
1. Let _stdlib_ be ObjectCreate(%ObjectPrototype%).
1. For each property of the Global Object specified in clause <emu-xref href="#sec-global-object"></emu-xref> that correspond to an intrinsic object, do:
1. Let _name_ be the String value of the property name.
1. Let _value_ be the corresponding value of the intrinsic object from record _realmRec_.[[Intrinsics]].
1. Let _descObj_ be ObjectCreate(%ObjectPrototype%).
1. Perform ? DefinePropertyOrThrow(_descObj_, *"value"*, PropertyDescriptor{[[Value]]: _value_, [[Writable]]: *true*, [[Enumerable]]: *true*, [[Configurable]]: *true*}).
1. Perform ? DefinePropertyOrThrow(_stdlib_, _name_, PropertyDescriptor{[[Value]]: _descObj_, [[Writable]]: *true*, [[Enumerable]]: *true*, [[Configurable]]: *true*}).
1. Return _stdlib_.
</emu-alg>
</emu-clause>
<emu-clause id="sec-realm.prototype.intrinsics">
<h1>get Realm.prototype.intrinsics</h1>
Realm.prototype.intrinsics is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps:
<emu-alg>
1. Let _O_ be *this* value.
1. If Type(_O_) is not Object, throw a *TypeError* exception.
1. If _O_ does not have an [[Realm]] internal slot, throw a *TypeError* exception.
1. Let _realmRec_ be _O_.[[Realm]].
1. Let _intrinsics_ be ObjectCreate(%ObjectPrototype%).
1. For each intrinsic name listed in <emu-xref href="#table-7"></emu-xref>, do:
1. Let _intrinsicName_ be the String value in column one of the table.
1. Let _name_ be the String value of _intrinsicName_ without the *%* symbols.
1. Let _value_ be the value of the field name _intrisicName_ from record _realmRec_.[[Intrinsics]].
1. Perform ? DefinePropertyOrThrow(_intrinsics_, _name_, PropertyDescriptor{[[Value]]: _value_, [[Writable]]: *true*, [[Enumerable]]: *true*, [[Configurable]]: *true*}).
1. Return _intrinsics_.
</emu-alg>
</emu-clause>
<emu-clause id="sec-realm.prototype-@@tostringtag">
<h1>Realm.prototype [ @@toStringTag ]</h1>
The initial value of the @@toStringTag property is the String value "Realm".
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
</emu-clause>
</emu-clause>
<emu-clause id="sec-properties-of-realm-instances">
<h1>Properties of Realm Instances</h1>
Realm instances are ordinary objects that inherit properties from the Realm prototype object (the intrinsic, %RealmPrototype%). Realm instances are initially created with the internal slots described in <emu-xref href="#table-3"></emu-xref>.
<emu-table id="table-3" caption="Internal Slots of Realm Instances">
<table>
<tbody>
<tr>
<th>Internal Slot</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>[[Realm]]</td>
<td>Realm Record</td>
<td>The Realm Record for the initial execution context.</td>
</tr>
</tbody>
</table>
</emu-table>
</emu-clause>
</emu-clause>