rusty_v8 icon indicating copy to clipboard operation
rusty_v8 copied to clipboard

feat(isolate): guarantee OwnedIsolate layout

Open tristan-f-r opened this issue 1 year ago • 6 comments

uses repr(transparent) to ensure OwnedIsolate is a genuine wrapper.

tristan-f-r avatar Oct 13 '24 07:10 tristan-f-r

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Oct 13 '24 07:10 CLAassistant

This just contains a pointer to the isolate, why does it need a repr?

devsnek avatar Oct 13 '24 07:10 devsnek

@devsnek In Deno, we do *mut OwnedIsolate as *mut Isolate in some places

littledivy avatar Oct 13 '24 07:10 littledivy

@littledivy that's not correct. OwnedIsolate implements deref to Isolate methods, which could then be casted from references to pointers without the type cast.

devsnek avatar Oct 13 '24 08:10 devsnek

Oh you are right, we do &mut owned_isolate as *mut Isolate which does derefmut

littledivy avatar Oct 13 '24 08:10 littledivy

I made the same assumption as @littledivy did earlier - I didn't notice this was guaranteed in DerefMut.

tristan-f-r avatar Oct 13 '24 16:10 tristan-f-r