ember-source 5.12.0-beta.2 → 5.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build-metadata.json +3 -3
- package/dist/ember-template-compiler.js +4200 -6302
- package/dist/ember-testing.js +1 -1
- package/dist/ember.debug.js +4040 -8666
- package/dist/ember.prod.js +3734 -8082
- package/dist/packages/@glimmer/debug/index.js +87 -1440
- package/dist/packages/@glimmer/destroyable/index.js +59 -113
- package/dist/packages/@glimmer/encoder/index.js +4 -11
- package/dist/packages/@glimmer/global-context/index.js +40 -144
- package/dist/packages/@glimmer/manager/index.js +191 -312
- package/dist/packages/@glimmer/node/index.js +34 -76
- package/dist/packages/@glimmer/opcode-compiler/index.js +794 -1422
- package/dist/packages/@glimmer/owner/index.js +2 -1
- package/dist/packages/@glimmer/program/index.js +105 -192
- package/dist/packages/@glimmer/reference/index.js +109 -237
- package/dist/packages/@glimmer/runtime/index.js +1939 -3715
- package/dist/packages/@glimmer/util/index.js +114 -241
- package/dist/packages/@glimmer/validator/index.js +203 -409
- package/dist/packages/@glimmer/vm/index.js +163 -176
- package/dist/packages/@glimmer/wire-format/index.js +70 -71
- package/dist/packages/ember/version.js +1 -1
- package/docs/data.json +1 -1
- package/package.json +22 -25
|
@@ -7,40 +7,31 @@ import { SexpOpcodes as opcodes } from '../wire-format/index.js';
|
|
|
7
7
|
/**
|
|
8
8
|
* Default component template, which is a plain yield
|
|
9
9
|
*/
|
|
10
|
-
const DEFAULT_TEMPLATE_BLOCK = [[[opcodes.Yield, 1, null]], [
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
const DEFAULT_TEMPLATE_BLOCK = [[[opcodes.Yield, 1, null]], ["&default"], !1, []],
|
|
11
|
+
DEFAULT_TEMPLATE = {
|
|
12
|
+
// random uuid
|
|
13
|
+
id: "1b32f5c2-7623-43d6-a0ad-9672898920a1",
|
|
14
|
+
moduleName: "__default__.hbs",
|
|
15
|
+
block: JSON.stringify(DEFAULT_TEMPLATE_BLOCK),
|
|
16
|
+
scope: null,
|
|
17
|
+
isStrictMode: !0
|
|
18
|
+
},
|
|
19
|
+
WELL_KNOWN_EMPTY_ARRAY = Object.freeze([]),
|
|
20
|
+
STARTER_CONSTANTS = constants(WELL_KNOWN_EMPTY_ARRAY),
|
|
21
|
+
WELL_KNOWN_EMPTY_ARRAY_POSITION = STARTER_CONSTANTS.indexOf(WELL_KNOWN_EMPTY_ARRAY);
|
|
22
22
|
class CompileTimeConstantImpl {
|
|
23
23
|
// `0` means NULL
|
|
24
|
-
|
|
25
24
|
values = STARTER_CONSTANTS.slice();
|
|
26
25
|
indexMap = new Map(this.values.map((value, index) => [value, index]));
|
|
27
26
|
value(value) {
|
|
28
|
-
let indexMap = this.indexMap
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
index = this.values.push(value) - 1;
|
|
32
|
-
indexMap.set(value, index);
|
|
33
|
-
}
|
|
34
|
-
return index;
|
|
27
|
+
let indexMap = this.indexMap,
|
|
28
|
+
index = indexMap.get(value);
|
|
29
|
+
return void 0 === index && (index = this.values.push(value) - 1, indexMap.set(value, index)), index;
|
|
35
30
|
}
|
|
36
31
|
array(values) {
|
|
37
|
-
if (values.length
|
|
38
|
-
return WELL_KNOWN_EMPTY_ARRAY_POSITION;
|
|
39
|
-
}
|
|
32
|
+
if (0 === values.length) return WELL_KNOWN_EMPTY_ARRAY_POSITION;
|
|
40
33
|
let handles = new Array(values.length);
|
|
41
|
-
for (let i = 0; i < values.length; i++)
|
|
42
|
-
handles[i] = this.value(values[i]);
|
|
43
|
-
}
|
|
34
|
+
for (let i = 0; i < values.length; i++) handles[i] = this.value(values[i]);
|
|
44
35
|
return this.value(handles);
|
|
45
36
|
}
|
|
46
37
|
toPool() {
|
|
@@ -56,11 +47,9 @@ class RuntimeConstantsImpl {
|
|
|
56
47
|
return this.values[handle];
|
|
57
48
|
}
|
|
58
49
|
getArray(value) {
|
|
59
|
-
let handles = this.getValue(value)
|
|
60
|
-
|
|
61
|
-
for (const [i, n] of enumerate(handles))
|
|
62
|
-
reified[i] = this.getValue(n);
|
|
63
|
-
}
|
|
50
|
+
let handles = this.getValue(value),
|
|
51
|
+
reified = new Array(handles.length);
|
|
52
|
+
for (const [i, n] of enumerate(handles)) reified[i] = this.getValue(n);
|
|
64
53
|
return reified;
|
|
65
54
|
}
|
|
66
55
|
}
|
|
@@ -69,7 +58,6 @@ class ConstantsImpl extends CompileTimeConstantImpl {
|
|
|
69
58
|
[WELL_KNOWN_EMPTY_ARRAY_POSITION]: WELL_KNOWN_EMPTY_ARRAY
|
|
70
59
|
};
|
|
71
60
|
defaultTemplate = templateFactory(DEFAULT_TEMPLATE)();
|
|
72
|
-
|
|
73
61
|
// Used for tests and debugging purposes, and to be able to analyze large apps
|
|
74
62
|
// This is why it's enabled even in production
|
|
75
63
|
helperDefinitionCount = 0;
|
|
@@ -82,121 +70,83 @@ class ConstantsImpl extends CompileTimeConstantImpl {
|
|
|
82
70
|
// TODO: Add a way to expose resolved name for debugging
|
|
83
71
|
_resolvedName = null, isOptional) {
|
|
84
72
|
let handle = this.helperDefinitionCache.get(definitionState);
|
|
85
|
-
if (
|
|
73
|
+
if (void 0 === handle) {
|
|
86
74
|
let managerOrHelper = getInternalHelperManager(definitionState, isOptional);
|
|
87
|
-
if (
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
debugAssert(managerOrHelper, 'BUG: expected manager or helper');
|
|
92
|
-
let helper = typeof managerOrHelper === 'function' ? managerOrHelper : managerOrHelper.getHelper(definitionState);
|
|
93
|
-
handle = this.value(helper);
|
|
94
|
-
this.helperDefinitionCache.set(definitionState, handle);
|
|
95
|
-
this.helperDefinitionCount++;
|
|
75
|
+
if (null === managerOrHelper) return this.helperDefinitionCache.set(definitionState, null), null;
|
|
76
|
+
debugAssert(managerOrHelper, "BUG: expected manager or helper");
|
|
77
|
+
let helper = "function" == typeof managerOrHelper ? managerOrHelper : managerOrHelper.getHelper(definitionState);
|
|
78
|
+
handle = this.value(helper), this.helperDefinitionCache.set(definitionState, handle), this.helperDefinitionCount++;
|
|
96
79
|
}
|
|
97
80
|
return handle;
|
|
98
81
|
}
|
|
99
82
|
modifier(definitionState, resolvedName = null, isOptional) {
|
|
100
83
|
let handle = this.modifierDefinitionCache.get(definitionState);
|
|
101
|
-
if (
|
|
84
|
+
if (void 0 === handle) {
|
|
102
85
|
let manager = getInternalModifierManager(definitionState, isOptional);
|
|
103
|
-
if (
|
|
104
|
-
this.modifierDefinitionCache.set(definitionState, null);
|
|
105
|
-
return null;
|
|
106
|
-
}
|
|
86
|
+
if (null === manager) return this.modifierDefinitionCache.set(definitionState, null), null;
|
|
107
87
|
let definition = {
|
|
108
|
-
resolvedName,
|
|
109
|
-
manager,
|
|
88
|
+
resolvedName: resolvedName,
|
|
89
|
+
manager: manager,
|
|
110
90
|
state: definitionState
|
|
111
91
|
};
|
|
112
|
-
handle = this.value(definition)
|
|
113
|
-
this.modifierDefinitionCache.set(definitionState, handle);
|
|
114
|
-
this.modifierDefinitionCount++;
|
|
92
|
+
handle = this.value(definition), this.modifierDefinitionCache.set(definitionState, handle), this.modifierDefinitionCount++;
|
|
115
93
|
}
|
|
116
94
|
return handle;
|
|
117
95
|
}
|
|
118
96
|
component(definitionState, owner, isOptional) {
|
|
119
97
|
let definition = this.componentDefinitionCache.get(definitionState);
|
|
120
|
-
if (
|
|
98
|
+
if (void 0 === definition) {
|
|
121
99
|
let manager = getInternalComponentManager(definitionState, isOptional);
|
|
122
|
-
if (
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
let compilable = null;
|
|
130
|
-
let template;
|
|
131
|
-
if (!managerHasCapability(manager, capabilities, InternalComponentCapabilities.dynamicLayout)) {
|
|
132
|
-
template = templateFactory?.(owner) ?? this.defaultTemplate;
|
|
133
|
-
} else {
|
|
134
|
-
template = templateFactory?.(owner);
|
|
135
|
-
}
|
|
136
|
-
if (template !== undefined) {
|
|
137
|
-
template = unwrapTemplate(template);
|
|
138
|
-
compilable = managerHasCapability(manager, capabilities, InternalComponentCapabilities.wrapped) ? template.asWrappedLayout() : template.asLayout();
|
|
139
|
-
}
|
|
140
|
-
definition = {
|
|
100
|
+
if (null === manager) return this.componentDefinitionCache.set(definitionState, null), null;
|
|
101
|
+
debugAssert(manager, "BUG: expected manager");
|
|
102
|
+
let template,
|
|
103
|
+
capabilities = capabilityFlagsFrom(manager.getCapabilities(definitionState)),
|
|
104
|
+
templateFactory = getComponentTemplate(definitionState),
|
|
105
|
+
compilable = null;
|
|
106
|
+
template = managerHasCapability(manager, capabilities, InternalComponentCapabilities.dynamicLayout) ? templateFactory?.(owner) : templateFactory?.(owner) ?? this.defaultTemplate, void 0 !== template && (template = unwrapTemplate(template), compilable = managerHasCapability(manager, capabilities, InternalComponentCapabilities.wrapped) ? template.asWrappedLayout() : template.asLayout()), definition = {
|
|
141
107
|
resolvedName: null,
|
|
142
108
|
handle: -1,
|
|
143
109
|
// replaced momentarily
|
|
144
|
-
manager,
|
|
145
|
-
capabilities,
|
|
110
|
+
manager: manager,
|
|
111
|
+
capabilities: capabilities,
|
|
146
112
|
state: definitionState,
|
|
147
|
-
compilable
|
|
148
|
-
}
|
|
149
|
-
definition.handle = this.value(definition);
|
|
150
|
-
this.componentDefinitionCache.set(definitionState, definition);
|
|
151
|
-
this.componentDefinitionCount++;
|
|
113
|
+
compilable: compilable
|
|
114
|
+
}, definition.handle = this.value(definition), this.componentDefinitionCache.set(definitionState, definition), this.componentDefinitionCount++;
|
|
152
115
|
}
|
|
153
116
|
return definition;
|
|
154
117
|
}
|
|
155
118
|
resolvedComponent(resolvedDefinition, resolvedName) {
|
|
156
119
|
let definition = this.componentDefinitionCache.get(resolvedDefinition);
|
|
157
|
-
if (
|
|
120
|
+
if (void 0 === definition) {
|
|
158
121
|
let {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
if (template !== null) {
|
|
169
|
-
template = unwrapTemplate(template);
|
|
170
|
-
compilable = managerHasCapability(manager, capabilities, InternalComponentCapabilities.wrapped) ? template.asWrappedLayout() : template.asLayout();
|
|
171
|
-
}
|
|
172
|
-
definition = {
|
|
173
|
-
resolvedName,
|
|
122
|
+
manager: manager,
|
|
123
|
+
state: state,
|
|
124
|
+
template: template
|
|
125
|
+
} = resolvedDefinition,
|
|
126
|
+
capabilities = capabilityFlagsFrom(manager.getCapabilities(resolvedDefinition)),
|
|
127
|
+
compilable = null;
|
|
128
|
+
managerHasCapability(manager, capabilities, InternalComponentCapabilities.dynamicLayout) || (template = template ?? this.defaultTemplate), null !== template && (template = unwrapTemplate(template), compilable = managerHasCapability(manager, capabilities, InternalComponentCapabilities.wrapped) ? template.asWrappedLayout() : template.asLayout()), definition = {
|
|
129
|
+
resolvedName: resolvedName,
|
|
174
130
|
handle: -1,
|
|
175
131
|
// replaced momentarily
|
|
176
|
-
manager,
|
|
177
|
-
capabilities,
|
|
178
|
-
state,
|
|
179
|
-
compilable
|
|
180
|
-
}
|
|
181
|
-
definition.handle = this.value(definition);
|
|
182
|
-
this.componentDefinitionCache.set(resolvedDefinition, definition);
|
|
183
|
-
this.componentDefinitionCount++;
|
|
132
|
+
manager: manager,
|
|
133
|
+
capabilities: capabilities,
|
|
134
|
+
state: state,
|
|
135
|
+
compilable: compilable
|
|
136
|
+
}, definition.handle = this.value(definition), this.componentDefinitionCache.set(resolvedDefinition, definition), this.componentDefinitionCount++;
|
|
184
137
|
}
|
|
185
|
-
return expect(definition,
|
|
138
|
+
return expect(definition, "BUG: resolved component definitions cannot be null");
|
|
186
139
|
}
|
|
187
140
|
getValue(index) {
|
|
188
|
-
debugAssert(index >= 0, `cannot get value for handle: ${index}`);
|
|
189
|
-
return this.values[index];
|
|
141
|
+
return debugAssert(index >= 0, `cannot get value for handle: ${index}`), this.values[index];
|
|
190
142
|
}
|
|
191
143
|
getArray(index) {
|
|
192
|
-
let reifiedArrs = this.reifiedArrs
|
|
193
|
-
|
|
194
|
-
if (
|
|
144
|
+
let reifiedArrs = this.reifiedArrs,
|
|
145
|
+
reified = reifiedArrs[index];
|
|
146
|
+
if (void 0 === reified) {
|
|
195
147
|
let names = this.getValue(index);
|
|
196
148
|
reified = new Array(names.length);
|
|
197
|
-
for (const [i, name] of enumerate(names))
|
|
198
|
-
reified[i] = this.getValue(name);
|
|
199
|
-
}
|
|
149
|
+
for (const [i, name] of enumerate(names)) reified[i] = this.getValue(name);
|
|
200
150
|
reifiedArrs[index] = reified;
|
|
201
151
|
}
|
|
202
152
|
return reified;
|
|
@@ -208,12 +158,10 @@ class RuntimeOpImpl {
|
|
|
208
158
|
this.heap = heap;
|
|
209
159
|
}
|
|
210
160
|
get size() {
|
|
211
|
-
|
|
212
|
-
return ((rawType & OPERAND_LEN_MASK) >> ARG_SHIFT) + 1;
|
|
161
|
+
return 1 + ((this.heap.getbyaddr(this.offset) & OPERAND_LEN_MASK) >> ARG_SHIFT);
|
|
213
162
|
}
|
|
214
163
|
get isMachine() {
|
|
215
|
-
|
|
216
|
-
return rawType & MACHINE_MASK ? 1 : 0;
|
|
164
|
+
return this.heap.getbyaddr(this.offset) & MACHINE_MASK ? 1 : 0;
|
|
217
165
|
}
|
|
218
166
|
get type() {
|
|
219
167
|
return this.heap.getbyaddr(this.offset) & TYPE_MASK;
|
|
@@ -228,26 +176,19 @@ class RuntimeOpImpl {
|
|
|
228
176
|
return this.heap.getbyaddr(this.offset + 3);
|
|
229
177
|
}
|
|
230
178
|
}
|
|
231
|
-
var TableSlotState =
|
|
232
|
-
TableSlotState[TableSlotState
|
|
233
|
-
TableSlotState[TableSlotState["Freed"] = 1] = "Freed";
|
|
234
|
-
TableSlotState[TableSlotState["Purged"] = 2] = "Purged";
|
|
235
|
-
TableSlotState[TableSlotState["Pointer"] = 3] = "Pointer";
|
|
236
|
-
return TableSlotState;
|
|
179
|
+
var TableSlotState = function (TableSlotState) {
|
|
180
|
+
return TableSlotState[TableSlotState.Allocated = 0] = "Allocated", TableSlotState[TableSlotState.Freed = 1] = "Freed", TableSlotState[TableSlotState.Purged = 2] = "Purged", TableSlotState[TableSlotState.Pointer = 3] = "Pointer", TableSlotState;
|
|
237
181
|
}(TableSlotState || {});
|
|
238
|
-
const PAGE_SIZE = 0x100000;
|
|
239
182
|
class RuntimeHeapImpl {
|
|
240
183
|
heap;
|
|
241
184
|
table;
|
|
242
185
|
constructor(serializedHeap) {
|
|
243
186
|
let {
|
|
244
|
-
buffer,
|
|
245
|
-
table
|
|
187
|
+
buffer: buffer,
|
|
188
|
+
table: table
|
|
246
189
|
} = serializedHeap;
|
|
247
|
-
this.heap = new Int32Array(buffer);
|
|
248
|
-
this.table = table;
|
|
190
|
+
this.heap = new Int32Array(buffer), this.table = table;
|
|
249
191
|
}
|
|
250
|
-
|
|
251
192
|
// It is illegal to close over this address, as compaction
|
|
252
193
|
// may move it. However, it is legal to use this address
|
|
253
194
|
// multiple times between compactions.
|
|
@@ -255,10 +196,10 @@ class RuntimeHeapImpl {
|
|
|
255
196
|
return unwrap(this.table[handle]);
|
|
256
197
|
}
|
|
257
198
|
getbyaddr(address) {
|
|
258
|
-
return expect(this.heap[address],
|
|
199
|
+
return expect(this.heap[address], "Access memory out of bounds of the heap");
|
|
259
200
|
}
|
|
260
201
|
sizeof(handle) {
|
|
261
|
-
return
|
|
202
|
+
return this.table, -1;
|
|
262
203
|
}
|
|
263
204
|
}
|
|
264
205
|
function hydrateHeap(serializedHeap) {
|
|
@@ -292,13 +233,10 @@ class HeapImpl {
|
|
|
292
233
|
handleState;
|
|
293
234
|
handle = 0;
|
|
294
235
|
constructor() {
|
|
295
|
-
this.heap = new Int32Array(
|
|
296
|
-
this.handleTable = [];
|
|
297
|
-
this.handleState = [];
|
|
236
|
+
this.heap = new Int32Array(1048576), this.handleTable = [], this.handleState = [];
|
|
298
237
|
}
|
|
299
238
|
pushRaw(value) {
|
|
300
|
-
this.sizeCheck();
|
|
301
|
-
this.heap[this.offset++] = value;
|
|
239
|
+
this.sizeCheck(), this.heap[this.offset++] = value;
|
|
302
240
|
}
|
|
303
241
|
pushOp(item) {
|
|
304
242
|
this.pushRaw(item);
|
|
@@ -308,12 +246,11 @@ class HeapImpl {
|
|
|
308
246
|
}
|
|
309
247
|
sizeCheck() {
|
|
310
248
|
let {
|
|
311
|
-
heap
|
|
249
|
+
heap: heap
|
|
312
250
|
} = this;
|
|
313
251
|
if (this.offset === this.heap.length) {
|
|
314
|
-
let newHeap = new Int32Array(heap.length +
|
|
315
|
-
newHeap.set(heap, 0);
|
|
316
|
-
this.heap = newHeap;
|
|
252
|
+
let newHeap = new Int32Array(heap.length + 1048576);
|
|
253
|
+
newHeap.set(heap, 0), this.heap = newHeap;
|
|
317
254
|
}
|
|
318
255
|
}
|
|
319
256
|
getbyaddr(address) {
|
|
@@ -324,14 +261,12 @@ class HeapImpl {
|
|
|
324
261
|
}
|
|
325
262
|
malloc() {
|
|
326
263
|
// push offset, info, size
|
|
327
|
-
this.handleTable.push(this.offset);
|
|
328
|
-
return this.handleTable.length - 1;
|
|
264
|
+
return this.handleTable.push(this.offset), this.handleTable.length - 1;
|
|
329
265
|
}
|
|
330
266
|
finishMalloc(handle) {}
|
|
331
267
|
size() {
|
|
332
268
|
return this.offset;
|
|
333
269
|
}
|
|
334
|
-
|
|
335
270
|
// It is illegal to close over this address, as compaction
|
|
336
271
|
// may move it. However, it is legal to use this address
|
|
337
272
|
// multiple times between compactions.
|
|
@@ -339,52 +274,48 @@ class HeapImpl {
|
|
|
339
274
|
return unwrap(this.handleTable[handle]);
|
|
340
275
|
}
|
|
341
276
|
sizeof(handle) {
|
|
342
|
-
return
|
|
277
|
+
return this.handleTable, -1;
|
|
343
278
|
}
|
|
344
279
|
free(handle) {
|
|
345
280
|
this.handleState[handle] = TableSlotState.Freed;
|
|
346
281
|
}
|
|
347
|
-
|
|
348
282
|
/**
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
283
|
+
* The heap uses the [Mark-Compact Algorithm](https://en.wikipedia.org/wiki/Mark-compact_algorithm) to shift
|
|
284
|
+
* reachable memory to the bottom of the heap and freeable
|
|
285
|
+
* memory to the top of the heap. When we have shifted all
|
|
286
|
+
* the reachable memory to the top of the heap, we move the
|
|
287
|
+
* offset to the next free position.
|
|
288
|
+
*/
|
|
355
289
|
compact() {
|
|
356
|
-
let compactedSize = 0
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
290
|
+
let compactedSize = 0,
|
|
291
|
+
{
|
|
292
|
+
handleTable: handleTable,
|
|
293
|
+
handleState: handleState,
|
|
294
|
+
heap: heap
|
|
295
|
+
} = this;
|
|
362
296
|
for (let i = 0; i < length; i++) {
|
|
363
|
-
let offset = unwrap(handleTable[i])
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
if (state
|
|
367
|
-
continue;
|
|
368
|
-
} else if (state === TableSlotState.Freed) {
|
|
297
|
+
let offset = unwrap(handleTable[i]),
|
|
298
|
+
size = unwrap(handleTable[i + 1]) - unwrap(offset),
|
|
299
|
+
state = handleState[i];
|
|
300
|
+
if (state !== TableSlotState.Purged) if (state === TableSlotState.Freed)
|
|
369
301
|
// transition to "already freed" aka "purged"
|
|
370
302
|
// a good improvement would be to reuse
|
|
371
303
|
// these slots
|
|
372
|
-
handleState[i] = TableSlotState.Purged;
|
|
373
|
-
|
|
374
|
-
} else if (state === TableSlotState.Allocated) {
|
|
375
|
-
for (let j = offset; j <= i + size; j++) {
|
|
376
|
-
heap[j - compactedSize] = unwrap(heap[j]);
|
|
377
|
-
}
|
|
304
|
+
handleState[i] = TableSlotState.Purged, compactedSize += size;else if (state === TableSlotState.Allocated) {
|
|
305
|
+
for (let j = offset; j <= i + size; j++) heap[j - compactedSize] = unwrap(heap[j]);
|
|
378
306
|
handleTable[i] = offset - compactedSize;
|
|
379
|
-
} else
|
|
380
|
-
handleTable[i] = offset - compactedSize;
|
|
381
|
-
}
|
|
307
|
+
} else state === TableSlotState.Pointer && (handleTable[i] = offset - compactedSize);
|
|
382
308
|
}
|
|
383
309
|
this.offset = this.offset - compactedSize;
|
|
384
310
|
}
|
|
385
311
|
capture(offset = this.offset) {
|
|
386
312
|
// Only called in eager mode
|
|
387
|
-
let buffer =
|
|
313
|
+
let buffer = function (arr, start, end) {
|
|
314
|
+
if (void 0 !== arr.slice) return arr.slice(start, end);
|
|
315
|
+
let ret = new Int32Array(end);
|
|
316
|
+
for (; start < end; start++) ret[start] = unwrap(arr[start]);
|
|
317
|
+
return ret;
|
|
318
|
+
}(this.heap, 0, offset).buffer;
|
|
388
319
|
return {
|
|
389
320
|
handle: this.handle,
|
|
390
321
|
table: this.handleTable,
|
|
@@ -395,28 +326,10 @@ class HeapImpl {
|
|
|
395
326
|
class RuntimeProgramImpl {
|
|
396
327
|
_opcode;
|
|
397
328
|
constructor(constants, heap) {
|
|
398
|
-
this.constants = constants;
|
|
399
|
-
this.heap = heap;
|
|
400
|
-
this._opcode = new RuntimeOpImpl(this.heap);
|
|
329
|
+
this.constants = constants, this.heap = heap, this._opcode = new RuntimeOpImpl(this.heap);
|
|
401
330
|
}
|
|
402
331
|
opcode(offset) {
|
|
403
|
-
this._opcode.offset = offset;
|
|
404
|
-
return this._opcode;
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
function slice(arr, start, end) {
|
|
408
|
-
if (arr.slice !== undefined) {
|
|
409
|
-
return arr.slice(start, end);
|
|
410
|
-
}
|
|
411
|
-
let ret = new Int32Array(end);
|
|
412
|
-
for (; start < end; start++) {
|
|
413
|
-
ret[start] = unwrap(arr[start]);
|
|
414
|
-
}
|
|
415
|
-
return ret;
|
|
416
|
-
}
|
|
417
|
-
function sizeof(table, handle) {
|
|
418
|
-
{
|
|
419
|
-
return -1;
|
|
332
|
+
return this._opcode.offset = offset, this._opcode;
|
|
420
333
|
}
|
|
421
334
|
}
|
|
422
335
|
function artifacts() {
|