Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ClearScript/V8/SplitProxy/IV8SplitProxyNative.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ internal interface IV8SplitProxyNative
#region V8 isolate methods

V8Isolate.Handle V8Isolate_Create(string name, int maxNewSpaceSize, int maxOldSpaceSize, double heapExpansionMultiplier, ulong maxArrayBufferAllocation, V8RuntimeFlags flags, int debugPort);
V8Context.Handle V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, V8ScriptEngineFlags flags, int debugPort);
V8Context.Handle V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, V8ScriptEngineFlags flags, int debugPort, IntPtr pPromiseRejectionCallback);
UIntPtr V8Isolate_GetMaxHeapSize(V8Isolate.Handle hIsolate);
void V8Isolate_SetMaxHeapSize(V8Isolate.Handle hIsolate, UIntPtr size);
double V8Isolate_GetHeapSizeSampleInterval(V8Isolate.Handle hIsolate);
Expand Down
10 changes: 8 additions & 2 deletions ClearScript/V8/SplitProxy/V8ContextProxyImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@ internal sealed class V8ContextProxyImpl : V8ContextProxy

private V8Context.Handle Handle => (V8Context.Handle)holder.Handle;

public V8ContextProxyImpl(V8IsolateProxy isolateProxy, string name, V8ScriptEngineFlags flags, int debugPort)
public V8ContextProxyImpl(V8IsolateProxy isolateProxy, string name, V8ScriptEngineFlags flags, int debugPort, Action<V8PromiseRejectionOperation, object, object> promiseRejectionCallback)
{
holder = new V8EntityHolder("V8 script engine", () => ((V8IsolateProxyImpl)isolateProxy).CreateContext(name, flags, debugPort));
holder = new V8EntityHolder("V8 script engine", () =>
{
using (var callbackScope = V8ProxyHelpers.CreateAddRefHostObjectScope(promiseRejectionCallback))
{
return ((V8IsolateProxyImpl)isolateProxy).CreateContext(name, flags, debugPort, callbackScope.Value);
}
});
}

#region V8ContextProxy overrides
Expand Down
4 changes: 2 additions & 2 deletions ClearScript/V8/SplitProxy/V8IsolateProxyImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public V8IsolateProxyImpl(string name, V8RuntimeConstraints constraints, V8Runti
));
}

public V8Context.Handle CreateContext(string name, V8ScriptEngineFlags flags, int debugPort)
public V8Context.Handle CreateContext(string name, V8ScriptEngineFlags flags, int debugPort, IntPtr pPromiseRejectionCallback)
{
return V8SplitProxyNative.Invoke(static (instance, ctx) => instance.V8Isolate_CreateContext(ctx.Handle, ctx.name, ctx.flags, ctx.debugPort), (Handle, name, flags, debugPort));
return V8SplitProxyNative.Invoke(static (instance, ctx) => instance.V8Isolate_CreateContext(ctx.Handle, ctx.name, ctx.flags, ctx.debugPort, ctx.pPromiseRejectionCallback), (Handle, name, flags, debugPort, pPromiseRejectionCallback));
}

#region V8IsolateProxy overrides
Expand Down
18 changes: 18 additions & 0 deletions ClearScript/V8/SplitProxy/V8SplitProxyManaged.cs
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,14 @@ private delegate void RawQueueNativeCallback(
[In] NativeCallback.Handle hCallback
);

[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate void RawNotifyPromiseRejection(
[In] IntPtr pCallback,
[In] int operation,
[In] V8Value.Ptr pPromise,
[In] V8Value.Ptr pReason
);

[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate IntPtr RawCreateNativeCallbackTimer(
[In] int dueTime,
Expand Down Expand Up @@ -566,6 +574,7 @@ private static void CreateMethodTable()
GetMethodPair<RawAsyncDisposeFastHostObject>(AsyncDisposeFastHostObject),

GetMethodPair<RawQueueNativeCallback>(QueueNativeCallback),
GetMethodPair<RawNotifyPromiseRejection>(NotifyPromiseRejection),
GetMethodPair<RawCreateNativeCallbackTimer>(CreateNativeCallbackTimer),
GetMethodPair<RawChangeNativeCallbackTimer>(ChangeNativeCallbackTimer),
GetMethodPair<RawDestroyNativeCallbackTimer>(DestroyNativeCallbackTimer),
Expand Down Expand Up @@ -1170,6 +1179,15 @@ private static void QueueNativeCallback(NativeCallback.Handle hCallback)
MiscHelpers.QueueNativeCallback(new NativeCallbackImpl(hCallback));
}

private static void NotifyPromiseRejection(IntPtr pCallback, int operation, V8Value.Ptr pPromise, V8Value.Ptr pReason)
{
MiscHelpers.Try(() => V8ProxyHelpers.GetHostObject<Action<V8PromiseRejectionOperation, object, object>>(pCallback)(
(V8PromiseRejectionOperation)operation,
V8Value.Get(pPromise),
V8Value.Get(pReason)
));
}

private static IntPtr CreateNativeCallbackTimer(int dueTime, int period, NativeCallback.Handle hCallback)
{
return V8ProxyHelpers.AddRefHostObject(new NativeCallbackTimer(dueTime, period, new NativeCallbackImpl(hCallback)));
Expand Down
7 changes: 4 additions & 3 deletions ClearScript/V8/SplitProxy/V8SplitProxyNative.Common.tt
Original file line number Diff line number Diff line change
Expand Up @@ -476,11 +476,11 @@ namespace Microsoft.ClearScript.V8.SplitProxy
}
}

V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, V8ScriptEngineFlags flags, int debugPort)
V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, V8ScriptEngineFlags flags, int debugPort, IntPtr pPromiseRejectionCallback)
{
using (var nameScope = StdString.CreateScope(name))
{
return V8Isolate_CreateContext(hIsolate, nameScope.Value, flags, debugPort);
return V8Isolate_CreateContext(hIsolate, nameScope.Value, flags, debugPort, pPromiseRejectionCallback);
}
}

Expand Down Expand Up @@ -1620,7 +1620,8 @@ namespace Microsoft.ClearScript.V8.SplitProxy
[In] V8Isolate.Handle hIsolate,
[In] StdString.Ptr pName,
[In] V8ScriptEngineFlags flags,
[In] int debugPort
[In] int debugPort,
[In] IntPtr pPromiseRejectionCallback
);

[DllImport("<#= fileName #>", CallingConvention = CallingConvention.StdCall)]
Expand Down
56 changes: 32 additions & 24 deletions ClearScript/V8/SplitProxy/V8SplitProxyNative.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -518,11 +518,11 @@ V8Isolate.Handle IV8SplitProxyNative.V8Isolate_Create(string name, int maxNewSpa
}
}

V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, V8ScriptEngineFlags flags, int debugPort)
V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, V8ScriptEngineFlags flags, int debugPort, IntPtr pPromiseRejectionCallback)
{
using (var nameScope = StdString.CreateScope(name))
{
return V8Isolate_CreateContext(hIsolate, nameScope.Value, flags, debugPort);
return V8Isolate_CreateContext(hIsolate, nameScope.Value, flags, debugPort, pPromiseRejectionCallback);
}
}

Expand Down Expand Up @@ -1662,7 +1662,8 @@ private static extern V8Context.Handle V8Isolate_CreateContext(
[In] V8Isolate.Handle hIsolate,
[In] StdString.Ptr pName,
[In] V8ScriptEngineFlags flags,
[In] int debugPort
[In] int debugPort,
[In] IntPtr pPromiseRejectionCallback
);

[DllImport("ClearScriptV8.win-x86.dll", CallingConvention = CallingConvention.StdCall)]
Expand Down Expand Up @@ -2725,11 +2726,11 @@ V8Isolate.Handle IV8SplitProxyNative.V8Isolate_Create(string name, int maxNewSpa
}
}

V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, V8ScriptEngineFlags flags, int debugPort)
V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, V8ScriptEngineFlags flags, int debugPort, IntPtr pPromiseRejectionCallback)
{
using (var nameScope = StdString.CreateScope(name))
{
return V8Isolate_CreateContext(hIsolate, nameScope.Value, flags, debugPort);
return V8Isolate_CreateContext(hIsolate, nameScope.Value, flags, debugPort, pPromiseRejectionCallback);
}
}

Expand Down Expand Up @@ -3869,7 +3870,8 @@ private static extern V8Context.Handle V8Isolate_CreateContext(
[In] V8Isolate.Handle hIsolate,
[In] StdString.Ptr pName,
[In] V8ScriptEngineFlags flags,
[In] int debugPort
[In] int debugPort,
[In] IntPtr pPromiseRejectionCallback
);

[DllImport("ClearScriptV8.win-x64.dll", CallingConvention = CallingConvention.StdCall)]
Expand Down Expand Up @@ -4932,11 +4934,11 @@ V8Isolate.Handle IV8SplitProxyNative.V8Isolate_Create(string name, int maxNewSpa
}
}

V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, V8ScriptEngineFlags flags, int debugPort)
V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, V8ScriptEngineFlags flags, int debugPort, IntPtr pPromiseRejectionCallback)
{
using (var nameScope = StdString.CreateScope(name))
{
return V8Isolate_CreateContext(hIsolate, nameScope.Value, flags, debugPort);
return V8Isolate_CreateContext(hIsolate, nameScope.Value, flags, debugPort, pPromiseRejectionCallback);
}
}

Expand Down Expand Up @@ -6076,7 +6078,8 @@ private static extern V8Context.Handle V8Isolate_CreateContext(
[In] V8Isolate.Handle hIsolate,
[In] StdString.Ptr pName,
[In] V8ScriptEngineFlags flags,
[In] int debugPort
[In] int debugPort,
[In] IntPtr pPromiseRejectionCallback
);

[DllImport("ClearScriptV8.win-arm64.dll", CallingConvention = CallingConvention.StdCall)]
Expand Down Expand Up @@ -7139,11 +7142,11 @@ V8Isolate.Handle IV8SplitProxyNative.V8Isolate_Create(string name, int maxNewSpa
}
}

V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, V8ScriptEngineFlags flags, int debugPort)
V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, V8ScriptEngineFlags flags, int debugPort, IntPtr pPromiseRejectionCallback)
{
using (var nameScope = StdString.CreateScope(name))
{
return V8Isolate_CreateContext(hIsolate, nameScope.Value, flags, debugPort);
return V8Isolate_CreateContext(hIsolate, nameScope.Value, flags, debugPort, pPromiseRejectionCallback);
}
}

Expand Down Expand Up @@ -8283,7 +8286,8 @@ private static extern V8Context.Handle V8Isolate_CreateContext(
[In] V8Isolate.Handle hIsolate,
[In] StdString.Ptr pName,
[In] V8ScriptEngineFlags flags,
[In] int debugPort
[In] int debugPort,
[In] IntPtr pPromiseRejectionCallback
);

[DllImport("ClearScriptV8.linux-x64.so", CallingConvention = CallingConvention.StdCall)]
Expand Down Expand Up @@ -9346,11 +9350,11 @@ V8Isolate.Handle IV8SplitProxyNative.V8Isolate_Create(string name, int maxNewSpa
}
}

V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, V8ScriptEngineFlags flags, int debugPort)
V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, V8ScriptEngineFlags flags, int debugPort, IntPtr pPromiseRejectionCallback)
{
using (var nameScope = StdString.CreateScope(name))
{
return V8Isolate_CreateContext(hIsolate, nameScope.Value, flags, debugPort);
return V8Isolate_CreateContext(hIsolate, nameScope.Value, flags, debugPort, pPromiseRejectionCallback);
}
}

Expand Down Expand Up @@ -10490,7 +10494,8 @@ private static extern V8Context.Handle V8Isolate_CreateContext(
[In] V8Isolate.Handle hIsolate,
[In] StdString.Ptr pName,
[In] V8ScriptEngineFlags flags,
[In] int debugPort
[In] int debugPort,
[In] IntPtr pPromiseRejectionCallback
);

[DllImport("ClearScriptV8.linux-arm64.so", CallingConvention = CallingConvention.StdCall)]
Expand Down Expand Up @@ -11553,11 +11558,11 @@ V8Isolate.Handle IV8SplitProxyNative.V8Isolate_Create(string name, int maxNewSpa
}
}

V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, V8ScriptEngineFlags flags, int debugPort)
V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, V8ScriptEngineFlags flags, int debugPort, IntPtr pPromiseRejectionCallback)
{
using (var nameScope = StdString.CreateScope(name))
{
return V8Isolate_CreateContext(hIsolate, nameScope.Value, flags, debugPort);
return V8Isolate_CreateContext(hIsolate, nameScope.Value, flags, debugPort, pPromiseRejectionCallback);
}
}

Expand Down Expand Up @@ -12697,7 +12702,8 @@ private static extern V8Context.Handle V8Isolate_CreateContext(
[In] V8Isolate.Handle hIsolate,
[In] StdString.Ptr pName,
[In] V8ScriptEngineFlags flags,
[In] int debugPort
[In] int debugPort,
[In] IntPtr pPromiseRejectionCallback
);

[DllImport("ClearScriptV8.linux-arm.so", CallingConvention = CallingConvention.StdCall)]
Expand Down Expand Up @@ -13760,11 +13766,11 @@ V8Isolate.Handle IV8SplitProxyNative.V8Isolate_Create(string name, int maxNewSpa
}
}

V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, V8ScriptEngineFlags flags, int debugPort)
V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, V8ScriptEngineFlags flags, int debugPort, IntPtr pPromiseRejectionCallback)
{
using (var nameScope = StdString.CreateScope(name))
{
return V8Isolate_CreateContext(hIsolate, nameScope.Value, flags, debugPort);
return V8Isolate_CreateContext(hIsolate, nameScope.Value, flags, debugPort, pPromiseRejectionCallback);
}
}

Expand Down Expand Up @@ -14904,7 +14910,8 @@ private static extern V8Context.Handle V8Isolate_CreateContext(
[In] V8Isolate.Handle hIsolate,
[In] StdString.Ptr pName,
[In] V8ScriptEngineFlags flags,
[In] int debugPort
[In] int debugPort,
[In] IntPtr pPromiseRejectionCallback
);

[DllImport("ClearScriptV8.osx-x64.dylib", CallingConvention = CallingConvention.StdCall)]
Expand Down Expand Up @@ -15967,11 +15974,11 @@ V8Isolate.Handle IV8SplitProxyNative.V8Isolate_Create(string name, int maxNewSpa
}
}

V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, V8ScriptEngineFlags flags, int debugPort)
V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, V8ScriptEngineFlags flags, int debugPort, IntPtr pPromiseRejectionCallback)
{
using (var nameScope = StdString.CreateScope(name))
{
return V8Isolate_CreateContext(hIsolate, nameScope.Value, flags, debugPort);
return V8Isolate_CreateContext(hIsolate, nameScope.Value, flags, debugPort, pPromiseRejectionCallback);
}
}

Expand Down Expand Up @@ -17111,7 +17118,8 @@ private static extern V8Context.Handle V8Isolate_CreateContext(
[In] V8Isolate.Handle hIsolate,
[In] StdString.Ptr pName,
[In] V8ScriptEngineFlags flags,
[In] int debugPort
[In] int debugPort,
[In] IntPtr pPromiseRejectionCallback
);

[DllImport("ClearScriptV8.osx-arm64.dylib", CallingConvention = CallingConvention.StdCall)]
Expand Down
Loading