-
Notifications
You must be signed in to change notification settings - Fork 160
Expand file tree
/
Copy pathV8SplitProxyNative.Common.tt
More file actions
1964 lines (1607 loc) · 80.7 KB
/
V8SplitProxyNative.Common.tt
File metadata and controls
1964 lines (1607 loc) · 80.7 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
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
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
using System;
using System.Runtime.InteropServices;
namespace Microsoft.ClearScript.V8.SplitProxy
{
internal static partial class V8SplitProxyNative
{
private static IV8SplitProxyNative CreateInstance()
{
<#
foreach (var osPlatform in platforms.Select(testPlatform => testPlatform.Item1).Distinct())
{
#>
if (IsOSPlatform("<#= osPlatform #>"))
{
<#
foreach (var platform in platforms.Where(testPlatform => testPlatform.Item1 == osPlatform))
{
#>
if (IsArchitecture("<#= osPlatform #>", "<#= platform.Item2 #>"))
{
return new <#= $"Impl_{osPlatform}_{platform.Item2}" #>();
}
<#
}
#>
throw new PlatformNotSupportedException("Unsupported process architecture");
}
<#
}
#>
throw new PlatformNotSupportedException("Unsupported operating system");
}
<#
foreach (var platform in platforms)
{
var className = $"Impl_{platform.Item1}_{platform.Item2}";
var fileName = "ClearScriptV8." + platform.Item3;
#>
#region Nested type: <#= className #>
private sealed class <#= className #> : IV8SplitProxyNative
{
public static readonly IV8SplitProxyNative Instance = new <#= className #>();
#region IV8SplitProxyNative implementation
#region initialization
IntPtr IV8SplitProxyNative.V8SplitProxyManaged_SetMethodTable(IntPtr pMethodTable)
{
return V8SplitProxyManaged_SetMethodTable(pMethodTable);
}
void IV8SplitProxyNative.V8Environment_InitializeICU(string dataPath)
{
V8Environment_InitializeICU(dataPath);
}
#endregion
#region StdString methods
StdString.Ptr IV8SplitProxyNative.StdString_New(string value)
{
return StdString_New(value, value.Length);
}
string IV8SplitProxyNative.StdString_GetValue(StdString.Ptr pString)
{
var pValue = StdString_GetValue(pString, out var length);
return Marshal.PtrToStringUni(pValue, length);
}
void IV8SplitProxyNative.StdString_SetValue(StdString.Ptr pString, string value)
{
StdString_SetValue(pString, value, value.Length);
}
void IV8SplitProxyNative.StdString_Delete(StdString.Ptr pString)
{
StdString_Delete(pString);
}
#endregion
#region StdStringArray methods
StdStringArray.Ptr IV8SplitProxyNative.StdStringArray_New(int elementCount)
{
return StdStringArray_New(elementCount);
}
int IV8SplitProxyNative.StdStringArray_GetElementCount(StdStringArray.Ptr pArray)
{
return StdStringArray_GetElementCount(pArray);
}
void IV8SplitProxyNative.StdStringArray_SetElementCount(StdStringArray.Ptr pArray, int elementCount)
{
StdStringArray_SetElementCount(pArray, elementCount);
}
string IV8SplitProxyNative.StdStringArray_GetElement(StdStringArray.Ptr pArray, int index)
{
var pValue = StdStringArray_GetElement(pArray, index, out var length);
return Marshal.PtrToStringUni(pValue, length);
}
void IV8SplitProxyNative.StdStringArray_SetElement(StdStringArray.Ptr pArray, int index, string value)
{
StdStringArray_SetElement(pArray, index, value, value.Length);
}
void IV8SplitProxyNative.StdStringArray_Delete(StdStringArray.Ptr pArray)
{
StdStringArray_Delete(pArray);
}
#endregion
#region StdByteArray methods
StdByteArray.Ptr IV8SplitProxyNative.StdByteArray_New(int elementCount)
{
return StdByteArray_New(elementCount);
}
int IV8SplitProxyNative.StdByteArray_GetElementCount(StdByteArray.Ptr pArray)
{
return StdByteArray_GetElementCount(pArray);
}
void IV8SplitProxyNative.StdByteArray_SetElementCount(StdByteArray.Ptr pArray, int elementCount)
{
StdByteArray_SetElementCount(pArray, elementCount);
}
IntPtr IV8SplitProxyNative.StdByteArray_GetData(StdByteArray.Ptr pArray)
{
return StdByteArray_GetData(pArray);
}
void IV8SplitProxyNative.StdByteArray_Delete(StdByteArray.Ptr pArray)
{
StdByteArray_Delete(pArray);
}
#endregion
#region StdInt32Array methods
StdInt32Array.Ptr IV8SplitProxyNative.StdInt32Array_New(int elementCount)
{
return StdInt32Array_New(elementCount);
}
int IV8SplitProxyNative.StdInt32Array_GetElementCount(StdInt32Array.Ptr pArray)
{
return StdInt32Array_GetElementCount(pArray);
}
void IV8SplitProxyNative.StdInt32Array_SetElementCount(StdInt32Array.Ptr pArray, int elementCount)
{
StdInt32Array_SetElementCount(pArray, elementCount);
}
IntPtr IV8SplitProxyNative.StdInt32Array_GetData(StdInt32Array.Ptr pArray)
{
return StdInt32Array_GetData(pArray);
}
void IV8SplitProxyNative.StdInt32Array_Delete(StdInt32Array.Ptr pArray)
{
StdInt32Array_Delete(pArray);
}
#endregion
#region StdUInt32Array methods
StdUInt32Array.Ptr IV8SplitProxyNative.StdUInt32Array_New(int elementCount)
{
return StdUInt32Array_New(elementCount);
}
int IV8SplitProxyNative.StdUInt32Array_GetElementCount(StdUInt32Array.Ptr pArray)
{
return StdUInt32Array_GetElementCount(pArray);
}
void IV8SplitProxyNative.StdUInt32Array_SetElementCount(StdUInt32Array.Ptr pArray, int elementCount)
{
StdUInt32Array_SetElementCount(pArray, elementCount);
}
IntPtr IV8SplitProxyNative.StdUInt32Array_GetData(StdUInt32Array.Ptr pArray)
{
return StdUInt32Array_GetData(pArray);
}
void IV8SplitProxyNative.StdUInt32Array_Delete(StdUInt32Array.Ptr pArray)
{
StdUInt32Array_Delete(pArray);
}
#endregion
#region StdUInt64Array methods
StdUInt64Array.Ptr IV8SplitProxyNative.StdUInt64Array_New(int elementCount)
{
return StdUInt64Array_New(elementCount);
}
int IV8SplitProxyNative.StdUInt64Array_GetElementCount(StdUInt64Array.Ptr pArray)
{
return StdUInt64Array_GetElementCount(pArray);
}
void IV8SplitProxyNative.StdUInt64Array_SetElementCount(StdUInt64Array.Ptr pArray, int elementCount)
{
StdUInt64Array_SetElementCount(pArray, elementCount);
}
IntPtr IV8SplitProxyNative.StdUInt64Array_GetData(StdUInt64Array.Ptr pArray)
{
return StdUInt64Array_GetData(pArray);
}
void IV8SplitProxyNative.StdUInt64Array_Delete(StdUInt64Array.Ptr pArray)
{
StdUInt64Array_Delete(pArray);
}
#endregion
#region StdPtrArray methods
StdPtrArray.Ptr IV8SplitProxyNative.StdPtrArray_New(int elementCount)
{
return StdPtrArray_New(elementCount);
}
int IV8SplitProxyNative.StdPtrArray_GetElementCount(StdPtrArray.Ptr pArray)
{
return StdPtrArray_GetElementCount(pArray);
}
void IV8SplitProxyNative.StdPtrArray_SetElementCount(StdPtrArray.Ptr pArray, int elementCount)
{
StdPtrArray_SetElementCount(pArray, elementCount);
}
IntPtr IV8SplitProxyNative.StdPtrArray_GetData(StdPtrArray.Ptr pArray)
{
return StdPtrArray_GetData(pArray);
}
void IV8SplitProxyNative.StdPtrArray_Delete(StdPtrArray.Ptr pArray)
{
StdPtrArray_Delete(pArray);
}
#endregion
#region StdV8ValueArray methods
StdV8ValueArray.Ptr IV8SplitProxyNative.StdV8ValueArray_New(int elementCount)
{
return StdV8ValueArray_New(elementCount);
}
int IV8SplitProxyNative.StdV8ValueArray_GetElementCount(StdV8ValueArray.Ptr pArray)
{
return StdV8ValueArray_GetElementCount(pArray);
}
void IV8SplitProxyNative.StdV8ValueArray_SetElementCount(StdV8ValueArray.Ptr pArray, int elementCount)
{
StdV8ValueArray_SetElementCount(pArray, elementCount);
}
V8Value.Ptr IV8SplitProxyNative.StdV8ValueArray_GetData(StdV8ValueArray.Ptr pArray)
{
return StdV8ValueArray_GetData(pArray);
}
void IV8SplitProxyNative.StdV8ValueArray_Delete(StdV8ValueArray.Ptr pArray)
{
StdV8ValueArray_Delete(pArray);
}
#endregion
#region V8Value methods
V8Value.Ptr IV8SplitProxyNative.V8Value_New()
{
return V8Value_New();
}
void IV8SplitProxyNative.V8Value_SetNonexistent(V8Value.Ptr pV8Value)
{
V8Value_SetNonexistent(pV8Value);
}
void IV8SplitProxyNative.V8Value_SetUndefined(V8Value.Ptr pV8Value)
{
V8Value_SetUndefined(pV8Value);
}
void IV8SplitProxyNative.V8Value_SetNull(V8Value.Ptr pV8Value)
{
V8Value_SetNull(pV8Value);
}
void IV8SplitProxyNative.V8Value_SetBoolean(V8Value.Ptr pV8Value, bool value)
{
V8Value_SetBoolean(pV8Value, value);
}
void IV8SplitProxyNative.V8Value_SetNumber(V8Value.Ptr pV8Value, double value)
{
V8Value_SetNumber(pV8Value, value);
}
void IV8SplitProxyNative.V8Value_SetInt32(V8Value.Ptr pV8Value, int value)
{
V8Value_SetInt32(pV8Value, value);
}
void IV8SplitProxyNative.V8Value_SetUInt32(V8Value.Ptr pV8Value, uint value)
{
V8Value_SetUInt32(pV8Value, value);
}
void IV8SplitProxyNative.V8Value_SetString(V8Value.Ptr pV8Value, string value)
{
V8Value_SetString(pV8Value, value, value.Length);
}
void IV8SplitProxyNative.V8Value_SetDateTime(V8Value.Ptr pV8Value, double value)
{
V8Value_SetDateTime(pV8Value, value);
}
void IV8SplitProxyNative.V8Value_SetBigInt(V8Value.Ptr pV8Value, int signBit, byte[] bytes)
{
V8Value_SetBigInt(pV8Value, signBit, bytes, bytes.Length);
}
void IV8SplitProxyNative.V8Value_SetV8Object(V8Value.Ptr pV8Value, V8Object.Handle hObject, V8Value.Subtype subtype)
{
V8Value_SetV8Object(pV8Value, hObject, subtype);
}
void IV8SplitProxyNative.V8Value_SetHostObject(V8Value.Ptr pV8Value, IntPtr pObject)
{
V8Value_SetHostObject(pV8Value, pObject);
}
V8Value.Type IV8SplitProxyNative.V8Value_Decode(V8Value.Ptr pV8Value, out int intValue, out uint uintValue, out double doubleValue, out IntPtr ptrOrHandle)
{
return V8Value_Decode(pV8Value, out intValue, out uintValue, out doubleValue, out ptrOrHandle);
}
void IV8SplitProxyNative.V8Value_Delete(V8Value.Ptr pV8Value)
{
V8Value_Delete(pV8Value);
}
#endregion
#region V8CpuProfile methods
void IV8SplitProxyNative.V8CpuProfile_GetInfo(V8CpuProfile.Ptr pProfile, V8Entity.Handle hEntity, out string name, out ulong startTimestamp, out ulong endTimestamp, out int sampleCount, out V8CpuProfile.Node.Ptr pRootNode)
{
using (var nameScope = StdString.CreateScope())
{
V8CpuProfile_GetInfo(pProfile, hEntity, nameScope.Value, out startTimestamp, out endTimestamp, out sampleCount, out pRootNode);
name = StdString.GetValue(nameScope.Value);
}
}
bool IV8SplitProxyNative.V8CpuProfile_GetSample(V8CpuProfile.Ptr pProfile, int index, out ulong nodeId, out ulong timestamp)
{
return V8CpuProfile_GetSample(pProfile, index, out nodeId, out timestamp);
}
void IV8SplitProxyNative.V8CpuProfileNode_GetInfo(V8CpuProfile.Node.Ptr pNode, V8Entity.Handle hEntity, out ulong nodeId, out long scriptId, out string scriptName, out string functionName, out string bailoutReason, out long lineNumber, out long columnNumber, out ulong hitCount, out uint hitLineCount, out int childCount)
{
using (var scriptNameScope = StdString.CreateScope())
{
using (var functionNameScope = StdString.CreateScope())
{
using (var bailoutReasonScope = StdString.CreateScope())
{
V8CpuProfileNode_GetInfo(pNode, hEntity, out nodeId, out scriptId, scriptNameScope.Value, functionNameScope.Value, bailoutReasonScope.Value, out lineNumber, out columnNumber, out hitCount, out hitLineCount, out childCount);
scriptName = StdString.GetValue(scriptNameScope.Value);
functionName = StdString.GetValue(functionNameScope.Value);
bailoutReason = StdString.GetValue(bailoutReasonScope.Value);
}
}
}
}
bool IV8SplitProxyNative.V8CpuProfileNode_GetHitLines(V8CpuProfile.Node.Ptr pNode, out int[] lineNumbers, out uint[] hitCounts)
{
using (var lineNumbersScope = StdInt32Array.CreateScope())
{
using (var hitCountsScope = StdUInt32Array.CreateScope())
{
var result = V8CpuProfileNode_GetHitLines(pNode, lineNumbersScope.Value, hitCountsScope.Value);
lineNumbers = StdInt32Array.ToArray(lineNumbersScope.Value);
hitCounts = StdUInt32Array.ToArray(hitCountsScope.Value);
return result;
}
}
}
V8CpuProfile.Node.Ptr IV8SplitProxyNative.V8CpuProfileNode_GetChildNode(V8CpuProfile.Node.Ptr pNode, int index)
{
return V8CpuProfileNode_GetChildNode(pNode, index);
}
#endregion
#region V8 isolate methods
V8Isolate.Handle IV8SplitProxyNative.V8Isolate_Create(string name, int maxNewSpaceSize, int maxOldSpaceSize, double heapExpansionMultiplier, ulong maxArrayBufferAllocation, bool enableDebugging, bool enableRemoteDebugging, bool enableDynamicModuleImports, int debugPort)
{
using (var nameScope = StdString.CreateScope(name))
{
return V8Isolate_Create(nameScope.Value, maxNewSpaceSize, maxOldSpaceSize, heapExpansionMultiplier, maxArrayBufferAllocation, enableDebugging, enableRemoteDebugging, enableDynamicModuleImports, debugPort);
}
}
V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, bool enableDebugging, bool enableRemoteDebugging, bool disableGlobalMembers, bool enableDateTimeConversion, bool enableDynamicModuleImports, int debugPort)
{
using (var nameScope = StdString.CreateScope(name))
{
return V8Isolate_CreateContext(hIsolate, nameScope.Value, enableDebugging, enableRemoteDebugging, disableGlobalMembers, enableDateTimeConversion, enableDynamicModuleImports, debugPort);
}
}
UIntPtr IV8SplitProxyNative.V8Isolate_GetMaxHeapSize(V8Isolate.Handle hIsolate)
{
return V8Isolate_GetMaxHeapSize(hIsolate);
}
void IV8SplitProxyNative.V8Isolate_SetMaxHeapSize(V8Isolate.Handle hIsolate, UIntPtr size)
{
V8Isolate_SetMaxHeapSize(hIsolate, size);
}
double IV8SplitProxyNative.V8Isolate_GetHeapSizeSampleInterval(V8Isolate.Handle hIsolate)
{
return V8Isolate_GetHeapSizeSampleInterval(hIsolate);
}
void IV8SplitProxyNative.V8Isolate_SetHeapSizeSampleInterval(V8Isolate.Handle hIsolate, double milliseconds)
{
V8Isolate_SetHeapSizeSampleInterval(hIsolate, milliseconds);
}
UIntPtr IV8SplitProxyNative.V8Isolate_GetMaxStackUsage(V8Isolate.Handle hIsolate)
{
return V8Isolate_GetMaxStackUsage(hIsolate);
}
void IV8SplitProxyNative.V8Isolate_SetMaxStackUsage(V8Isolate.Handle hIsolate, UIntPtr size)
{
V8Isolate_SetMaxStackUsage(hIsolate, size);
}
void IV8SplitProxyNative.V8Isolate_AwaitDebuggerAndPause(V8Isolate.Handle hIsolate)
{
V8Isolate_AwaitDebuggerAndPause(hIsolate);
}
V8Script.Handle IV8SplitProxyNative.V8Isolate_Compile(V8Isolate.Handle hIsolate, string resourceName, string sourceMapUrl, ulong uniqueId, bool isModule, IntPtr pDocumentInfo, string code)
{
using (var resourceNameScope = StdString.CreateScope(resourceName))
{
using (var sourceMapUrlScope = StdString.CreateScope(sourceMapUrl))
{
using (var codeScope = StdString.CreateScope(code))
{
return V8Isolate_Compile(hIsolate, resourceNameScope.Value, sourceMapUrlScope.Value, uniqueId, isModule, pDocumentInfo, codeScope.Value);
}
}
}
}
V8Script.Handle IV8SplitProxyNative.V8Isolate_CompileProducingCache(V8Isolate.Handle hIsolate, string resourceName, string sourceMapUrl, ulong uniqueId, bool isModule, IntPtr pDocumentInfo, string code, V8CacheKind cacheKind, out byte[] cacheBytes)
{
using (var resourceNameScope = StdString.CreateScope(resourceName))
{
using (var sourceMapUrlScope = StdString.CreateScope(sourceMapUrl))
{
using (var codeScope = StdString.CreateScope(code))
{
using (var cacheBytesScope = StdByteArray.CreateScope())
{
var hScript = V8Isolate_CompileProducingCache(hIsolate, resourceNameScope.Value, sourceMapUrlScope.Value, uniqueId, isModule, pDocumentInfo, codeScope.Value, cacheKind, cacheBytesScope.Value);
cacheBytes = StdByteArray.ToArray(cacheBytesScope.Value);
return hScript;
}
}
}
}
}
V8Script.Handle IV8SplitProxyNative.V8Isolate_CompileConsumingCache(V8Isolate.Handle hIsolate, string resourceName, string sourceMapUrl, ulong uniqueId, bool isModule, IntPtr pDocumentInfo, string code, V8CacheKind cacheKind, byte[] cacheBytes, out bool cacheAccepted)
{
using (var resourceNameScope = StdString.CreateScope(resourceName))
{
using (var sourceMapUrlScope = StdString.CreateScope(sourceMapUrl))
{
using (var codeScope = StdString.CreateScope(code))
{
using (var cacheBytesScope = StdByteArray.CreateScope(cacheBytes))
{
return V8Isolate_CompileConsumingCache(hIsolate, resourceNameScope.Value, sourceMapUrlScope.Value, uniqueId, isModule, pDocumentInfo, codeScope.Value, cacheKind, cacheBytesScope.Value, out cacheAccepted);
}
}
}
}
}
void IV8SplitProxyNative.V8Isolate_GetHeapStatistics(V8Isolate.Handle hIsolate, out ulong totalHeapSize, out ulong totalHeapSizeExecutable, out ulong totalPhysicalSize, out ulong usedHeapSize, out ulong heapSizeLimit)
{
V8Isolate_GetHeapStatistics(hIsolate, out totalHeapSize, out totalHeapSizeExecutable, out totalPhysicalSize, out usedHeapSize, out heapSizeLimit);
}
void IV8SplitProxyNative.V8Isolate_GetStatistics(V8Isolate.Handle hIsolate, out ulong scriptCount, out ulong scriptCacheSize, out ulong moduleCount, out ulong[] postedTaskCounts, out ulong[] invokedTaskCounts)
{
using (var postedTaskCountsScope = StdUInt64Array.CreateScope())
{
using (var invokedTaskCountsScope = StdUInt64Array.CreateScope())
{
V8Isolate_GetStatistics(hIsolate, out scriptCount, out scriptCacheSize, out moduleCount, postedTaskCountsScope.Value, invokedTaskCountsScope.Value);
postedTaskCounts = StdUInt64Array.ToArray(postedTaskCountsScope.Value);
invokedTaskCounts = StdUInt64Array.ToArray(invokedTaskCountsScope.Value);
}
}
}
void IV8SplitProxyNative.V8Isolate_CollectGarbage(V8Isolate.Handle hIsolate, bool exhaustive)
{
V8Isolate_CollectGarbage(hIsolate, exhaustive);
}
bool IV8SplitProxyNative.V8Isolate_BeginCpuProfile(V8Isolate.Handle hIsolate, string name, bool recordSamples)
{
using (var nameScope = StdString.CreateScope(name))
{
return V8Isolate_BeginCpuProfile(hIsolate, nameScope.Value, recordSamples);
}
}
void IV8SplitProxyNative.V8Isolate_EndCpuProfile(V8Isolate.Handle hIsolate, string name, IntPtr pAction)
{
using (var nameScope = StdString.CreateScope(name))
{
V8Isolate_EndCpuProfile(hIsolate, nameScope.Value, pAction);
}
}
void IV8SplitProxyNative.V8Isolate_CollectCpuProfileSample(V8Isolate.Handle hIsolate)
{
V8Isolate_CollectCpuProfileSample(hIsolate);
}
uint IV8SplitProxyNative.V8Isolate_GetCpuProfileSampleInterval(V8Isolate.Handle hIsolate)
{
return V8Isolate_GetCpuProfileSampleInterval(hIsolate);
}
void IV8SplitProxyNative.V8Isolate_SetCpuProfileSampleInterval(V8Isolate.Handle hIsolate, uint value)
{
V8Isolate_SetCpuProfileSampleInterval(hIsolate, value);
}
void IV8SplitProxyNative.V8Isolate_WriteHeapSnapshot(V8Isolate.Handle hIsolate, IntPtr pStream)
{
V8Isolate_WriteHeapSnapshot(hIsolate, pStream);
}
#endregion
#region V8 context methods
UIntPtr IV8SplitProxyNative.V8Context_GetMaxIsolateHeapSize(V8Context.Handle hContext)
{
return V8Context_GetMaxIsolateHeapSize(hContext);
}
void IV8SplitProxyNative.V8Context_SetMaxIsolateHeapSize(V8Context.Handle hContext, UIntPtr size)
{
V8Context_SetMaxIsolateHeapSize(hContext, size);
}
double IV8SplitProxyNative.V8Context_GetIsolateHeapSizeSampleInterval(V8Context.Handle hContext)
{
return V8Context_GetIsolateHeapSizeSampleInterval(hContext);
}
void IV8SplitProxyNative.V8Context_SetIsolateHeapSizeSampleInterval(V8Context.Handle hContext, double milliseconds)
{
V8Context_SetIsolateHeapSizeSampleInterval(hContext, milliseconds);
}
UIntPtr IV8SplitProxyNative.V8Context_GetMaxIsolateStackUsage(V8Context.Handle hContext)
{
return V8Context_GetMaxIsolateStackUsage(hContext);
}
void IV8SplitProxyNative.V8Context_SetMaxIsolateStackUsage(V8Context.Handle hContext, UIntPtr size)
{
V8Context_SetMaxIsolateStackUsage(hContext, size);
}
void IV8SplitProxyNative.V8Context_InvokeWithLock(V8Context.Handle hContext, IntPtr pAction)
{
V8Context_InvokeWithLock(hContext, pAction);
}
object IV8SplitProxyNative.V8Context_GetRootItem(V8Context.Handle hContext)
{
using (var itemScope = V8Value.CreateScope())
{
V8Context_GetRootItem(hContext, itemScope.Value);
return V8Value.Get(itemScope.Value);
}
}
void IV8SplitProxyNative.V8Context_AddGlobalItem(V8Context.Handle hContext, string name, object value, bool globalMembers)
{
using (var nameScope = StdString.CreateScope(name))
{
using (var valueScope = V8Value.CreateScope(value))
{
V8Context_AddGlobalItem(hContext, nameScope.Value, valueScope.Value, globalMembers);
}
}
}
void IV8SplitProxyNative.V8Context_AwaitDebuggerAndPause(V8Context.Handle hContext)
{
V8Context_AwaitDebuggerAndPause(hContext);
}
object IV8SplitProxyNative.V8Context_ExecuteCode(V8Context.Handle hContext, string resourceName, string sourceMapUrl, ulong uniqueId, bool isModule, IntPtr pDocumentInfo, string code, bool evaluate)
{
using (var resourceNameScope = StdString.CreateScope(resourceName))
{
using (var sourceMapUrlScope = StdString.CreateScope(sourceMapUrl))
{
using (var codeScope = StdString.CreateScope(code))
{
using (var resultScope = V8Value.CreateScope())
{
V8Context_ExecuteCode(hContext, resourceNameScope.Value, sourceMapUrlScope.Value, uniqueId, isModule, pDocumentInfo, codeScope.Value, evaluate, resultScope.Value);
return V8Value.Get(resultScope.Value);
}
}
}
}
}
V8Script.Handle IV8SplitProxyNative.V8Context_Compile(V8Context.Handle hContext, string resourceName, string sourceMapUrl, ulong uniqueId, bool isModule, IntPtr pDocumentInfo, string code)
{
using (var resourceNameScope = StdString.CreateScope(resourceName))
{
using (var sourceMapUrlScope = StdString.CreateScope(sourceMapUrl))
{
using (var codeScope = StdString.CreateScope(code))
{
return V8Context_Compile(hContext, resourceNameScope.Value, sourceMapUrlScope.Value, uniqueId, isModule, pDocumentInfo, codeScope.Value);
}
}
}
}
V8Script.Handle IV8SplitProxyNative.V8Context_CompileProducingCache(V8Context.Handle hContext, string resourceName, string sourceMapUrl, ulong uniqueId, bool isModule, IntPtr pDocumentInfo, string code, V8CacheKind cacheKind, out byte[] cacheBytes)
{
using (var resourceNameScope = StdString.CreateScope(resourceName))
{
using (var sourceMapUrlScope = StdString.CreateScope(sourceMapUrl))
{
using (var codeScope = StdString.CreateScope(code))
{
using (var cacheBytesScope = StdByteArray.CreateScope())
{
var hScript = V8Context_CompileProducingCache(hContext, resourceNameScope.Value, sourceMapUrlScope.Value, uniqueId, isModule, pDocumentInfo, codeScope.Value, cacheKind, cacheBytesScope.Value);
cacheBytes = StdByteArray.ToArray(cacheBytesScope.Value);
return hScript;
}
}
}
}
}
V8Script.Handle IV8SplitProxyNative.V8Context_CompileConsumingCache(V8Context.Handle hContext, string resourceName, string sourceMapUrl, ulong uniqueId, bool isModule, IntPtr pDocumentInfo, string code, V8CacheKind cacheKind, byte[] cacheBytes, out bool cacheAccepted)
{
using (var resourceNameScope = StdString.CreateScope(resourceName))
{
using (var sourceMapUrlScope = StdString.CreateScope(sourceMapUrl))
{
using (var codeScope = StdString.CreateScope(code))
{
using (var cacheBytesScope = StdByteArray.CreateScope(cacheBytes))
{
return V8Context_CompileConsumingCache(hContext, resourceNameScope.Value, sourceMapUrlScope.Value, uniqueId, isModule, pDocumentInfo, codeScope.Value, cacheKind, cacheBytesScope.Value, out cacheAccepted);
}
}
}
}
}
object IV8SplitProxyNative.V8Context_ExecuteScript(V8Context.Handle hContext, V8Script.Handle hScript, bool evaluate)
{
using (var resultScope = V8Value.CreateScope())
{
V8Context_ExecuteScript(hContext, hScript, evaluate, resultScope.Value);
return V8Value.Get(resultScope.Value);
}
}
void IV8SplitProxyNative.V8Context_Interrupt(V8Context.Handle hContext)
{
V8Context_Interrupt(hContext);
}
void IV8SplitProxyNative.V8Context_GetIsolateHeapStatistics(V8Context.Handle hContext, out ulong totalHeapSize, out ulong totalHeapSizeExecutable, out ulong totalPhysicalSize, out ulong usedHeapSize, out ulong heapSizeLimit)
{
V8Context_GetIsolateHeapStatistics(hContext, out totalHeapSize, out totalHeapSizeExecutable, out totalPhysicalSize, out usedHeapSize, out heapSizeLimit);
}
void IV8SplitProxyNative.V8Context_GetIsolateStatistics(V8Context.Handle hContext, out ulong scriptCount, out ulong scriptCacheSize, out ulong moduleCount, out ulong[] postedTaskCounts, out ulong[] invokedTaskCounts)
{
using (var postedTaskCountsScope = StdUInt64Array.CreateScope())
{
using (var invokedTaskCountsScope = StdUInt64Array.CreateScope())
{
V8Context_GetIsolateStatistics(hContext, out scriptCount, out scriptCacheSize, out moduleCount, postedTaskCountsScope.Value, invokedTaskCountsScope.Value);
postedTaskCounts = StdUInt64Array.ToArray(postedTaskCountsScope.Value);
invokedTaskCounts = StdUInt64Array.ToArray(invokedTaskCountsScope.Value);
}
}
}
void IV8SplitProxyNative.V8Context_GetStatistics(V8Context.Handle hContext, out ulong scriptCount, out ulong moduleCount, out ulong moduleCacheSize)
{
V8Context_GetStatistics(hContext, out scriptCount, out moduleCount, out moduleCacheSize);
}
void IV8SplitProxyNative.V8Context_CollectGarbage(V8Context.Handle hContext, bool exhaustive)
{
V8Context_CollectGarbage(hContext, exhaustive);
}
void IV8SplitProxyNative.V8Context_OnAccessSettingsChanged(V8Context.Handle hContext)
{
V8Context_OnAccessSettingsChanged(hContext);
}
bool IV8SplitProxyNative.V8Context_BeginCpuProfile(V8Context.Handle hContext, string name, bool recordSamples)
{
using (var nameScope = StdString.CreateScope(name))
{
return V8Context_BeginCpuProfile(hContext, nameScope.Value, recordSamples);
}
}
void IV8SplitProxyNative.V8Context_EndCpuProfile(V8Context.Handle hContext, string name, IntPtr pAction)
{
using (var nameScope = StdString.CreateScope(name))
{
V8Context_EndCpuProfile(hContext, nameScope.Value, pAction);
}
}
void IV8SplitProxyNative.V8Context_CollectCpuProfileSample(V8Context.Handle hContext)
{
V8Context_CollectCpuProfileSample(hContext);
}
uint IV8SplitProxyNative.V8Context_GetCpuProfileSampleInterval(V8Context.Handle hContext)
{
return V8Context_GetCpuProfileSampleInterval(hContext);
}
void IV8SplitProxyNative.V8Context_SetCpuProfileSampleInterval(V8Context.Handle hContext, uint value)
{
V8Context_SetCpuProfileSampleInterval(hContext, value);
}
void IV8SplitProxyNative.V8Context_WriteIsolateHeapSnapshot(V8Context.Handle hContext, IntPtr pStream)
{
V8Context_WriteIsolateHeapSnapshot(hContext, pStream);
}
#endregion
#region V8 object methods
object IV8SplitProxyNative.V8Object_GetNamedProperty(V8Object.Handle hObject, string name)
{
using (var nameScope = StdString.CreateScope(name))
{
using (var valueScope = V8Value.CreateScope())
{
V8Object_GetNamedProperty(hObject, nameScope.Value, valueScope.Value);
return V8Value.Get(valueScope.Value);
}
}
}
void IV8SplitProxyNative.V8Object_SetNamedProperty(V8Object.Handle hObject, string name, object value)
{
using (var nameScope = StdString.CreateScope(name))
{
using (var valueScope = V8Value.CreateScope(value))
{
V8Object_SetNamedProperty(hObject, nameScope.Value, valueScope.Value);
}
}
}
bool IV8SplitProxyNative.V8Object_DeleteNamedProperty(V8Object.Handle hObject, string name)
{
using (var nameScope = StdString.CreateScope(name))
{
return V8Object_DeleteNamedProperty(hObject, nameScope.Value);
}
}
string[] IV8SplitProxyNative.V8Object_GetPropertyNames(V8Object.Handle hObject)
{
using (var namesScope = StdStringArray.CreateScope())
{
V8Object_GetPropertyNames(hObject, namesScope.Value);
return StdStringArray.ToArray(namesScope.Value);
}
}
object IV8SplitProxyNative.V8Object_GetIndexedProperty(V8Object.Handle hObject, int index)
{
using (var valueScope = V8Value.CreateScope())
{
V8Object_GetIndexedProperty(hObject, index, valueScope.Value);
return V8Value.Get(valueScope.Value);
}
}
void IV8SplitProxyNative.V8Object_SetIndexedProperty(V8Object.Handle hObject, int index, object value)
{
using (var valueScope = V8Value.CreateScope(value))
{
V8Object_SetIndexedProperty(hObject, index, valueScope.Value);
}
}
bool IV8SplitProxyNative.V8Object_DeleteIndexedProperty(V8Object.Handle hObject, int index)
{
return V8Object_DeleteIndexedProperty(hObject, index);
}
int[] IV8SplitProxyNative.V8Object_GetPropertyIndices(V8Object.Handle hObject)
{
using (var indicesScope = StdInt32Array.CreateScope())
{
V8Object_GetPropertyIndices(hObject, indicesScope.Value);
return StdInt32Array.ToArray(indicesScope.Value);
}
}
object IV8SplitProxyNative.V8Object_Invoke(V8Object.Handle hObject, bool asConstructor, object[] args)
{
using (var argsScope = StdV8ValueArray.CreateScope(args))
{
using (var resultScope = V8Value.CreateScope())
{
V8Object_Invoke(hObject, asConstructor, argsScope.Value, resultScope.Value);
return V8Value.Get(resultScope.Value);
}
}
}
object IV8SplitProxyNative.V8Object_InvokeMethod(V8Object.Handle hObject, string name, object[] args)
{
using (var nameScope = StdString.CreateScope(name))
{
using (var argsScope = StdV8ValueArray.CreateScope(args))
{
using (var resultScope = V8Value.CreateScope())
{
V8Object_InvokeMethod(hObject, nameScope.Value, argsScope.Value, resultScope.Value);
return V8Value.Get(resultScope.Value);
}
}
}
}
void IV8SplitProxyNative.V8Object_GetArrayBufferOrViewInfo(V8Object.Handle hObject, out IV8Object arrayBuffer, out ulong offset, out ulong size, out ulong length)
{
using (var arrayBufferScope = V8Value.CreateScope())
{
V8Object_GetArrayBufferOrViewInfo(hObject, arrayBufferScope.Value, out offset, out size, out length);
arrayBuffer = (IV8Object)V8Value.Get(arrayBufferScope.Value);
}
}
void IV8SplitProxyNative.V8Object_InvokeWithArrayBufferOrViewData(V8Object.Handle hObject, IntPtr pAction)
{
V8Object_InvokeWithArrayBufferOrViewData(hObject, pAction);
}
#endregion
#region V8 debug callback methods
void IV8SplitProxyNative.V8DebugCallback_ConnectClient(V8DebugCallback.Handle hCallback)
{
V8DebugCallback_ConnectClient(hCallback);
}
void IV8SplitProxyNative.V8DebugCallback_SendCommand(V8DebugCallback.Handle hCallback, string command)
{
using (var commandScope = StdString.CreateScope(command))
{
V8DebugCallback_SendCommand(hCallback, commandScope.Value);
}
}
void IV8SplitProxyNative.V8DebugCallback_DisconnectClient(V8DebugCallback.Handle hCallback)
{
V8DebugCallback_DisconnectClient(hCallback);
}
#endregion
#region native callback methods
void IV8SplitProxyNative.NativeCallback_Invoke(NativeCallback.Handle hCallback)
{
NativeCallback_Invoke(hCallback);
}
#endregion
#region V8 entity cleanup
void IV8SplitProxyNative.V8Entity_Release(V8Entity.Handle hEntity)
{
V8Entity_Release(hEntity);
}
void IV8SplitProxyNative.V8Entity_DestroyHandle(V8Entity.Handle hEntity)
{
V8Entity_DestroyHandle(hEntity);
}
#endregion
#region error handling
void IV8SplitProxyNative.HostException_Schedule(string message, object exception)
{
using (var messageScope = StdString.CreateScope(message))
{
using (var exceptionScope = V8Value.CreateScope(exception))
{
HostException_Schedule(messageScope.Value, exceptionScope.Value);
}
}
}
#endregion
#region unit test support
UIntPtr IV8SplitProxyNative.V8UnitTestSupport_GetTextDigest(string value)
{
using (var valueScope = StdString.CreateScope(value))