Bug 213757 - [Win] Stub out bmalloc implementation
Summary: [Win] Stub out bmalloc implementation
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: bmalloc (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-06-29 15:28 PDT by Don Olmstead
Modified: 2020-06-30 14:17 PDT (History)
10 users (show)

See Also:


Attachments
WIP Patch (23.32 KB, patch)
2020-06-29 16:37 PDT, Don Olmstead
no flags Details | Formatted Diff | Diff
WIP Patch (25.15 KB, patch)
2020-06-29 16:42 PDT, Don Olmstead
no flags Details | Formatted Diff | Diff
WIP Patch (25.14 KB, patch)
2020-06-29 16:59 PDT, Don Olmstead
no flags Details | Formatted Diff | Diff
xcode (10.23 KB, patch)
2020-06-29 18:09 PDT, Don Olmstead
no flags Details | Formatted Diff | Diff
Patch (39.23 KB, patch)
2020-06-29 18:18 PDT, Don Olmstead
ysuzuki: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Don Olmstead 2020-06-29 15:28:06 PDT
Prepare bmalloc to be cross platform
Comment 1 Don Olmstead 2020-06-29 16:37:28 PDT Comment hidden (obsolete)
Comment 2 Don Olmstead 2020-06-29 16:42:12 PDT Comment hidden (obsolete)
Comment 3 Don Olmstead 2020-06-29 16:59:07 PDT Comment hidden (obsolete)
Comment 4 Don Olmstead 2020-06-29 18:09:55 PDT Comment hidden (obsolete)
Comment 5 Don Olmstead 2020-06-29 18:18:13 PDT
Created attachment 403150 [details]
Patch
Comment 6 Yusuke Suzuki 2020-06-30 14:09:51 PDT
Comment on attachment 403150 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=403150&action=review

r=me, but I think we should get Geoff's review too.

> Source/bmalloc/ChangeLog:13
> +        Add stubs for an implementation of bmalloc on Windows. Split the CryptoRandom
> +        implementation into a Unix and Windows definition. Add a small abstraction around
> +        threads to allow a Windows definition. Add the Builtins.h file which will contain
> +        any GCC compatible __builtin implementations on Windows.
> +
> +        The actual implementations will be coming in subsequent patches.

It is not enabled in Windows yet, right? Then, it is OK.

> Source/bmalloc/bmalloc/BAssert.h:70
> +    *(int *)(uintptr_t)0xbbadbeef = 0; \

Let's remove this change.

> Source/bmalloc/bmalloc/Builtins.h:41
> +{
> +    return 0;
> +}
> +
> +BINLINE int __builtin_usub_overflow(unsigned int a, unsigned int b, unsigned int *res)
> +{
> +    return 0;
> +}

Can you add FIXME?

> Source/bmalloc/bmalloc/DebugHeap.cpp:112
> +#if BOS(WINDOWS)
> +    result = _aligned_malloc(size, alignment);
> +    RELEASE_BASSERT(action == FailureAction::ReturnNull || result);
> +#else
>      if (posix_memalign(&result, alignment, size))
>          RELEASE_BASSERT(action == FailureAction::ReturnNull || result);
> +#endif

We should have FIXME to call _aligned_free since Windows requires paired calls of this instead of using free.

> Source/bmalloc/bmalloc/IsoTLS.cpp:38
> +#if BOS(WINDOWS)
> +#define strcasecmp _stricmp
> +#else
>  #include <stdio.h>
> +#endif

I think we can include `stdio.h` regardless of whether this is Windows or not.

> Source/bmalloc/bmalloc/VMAllocate.h:65
> +        // @TODO

Can you put FIXME comment with bugzilla URL about cache size retrieval?

> Source/bmalloc/bmalloc/VMAllocate.h:135
> +    // @TODO

Can you add FIXME comment with bugzilla URL about it?

> Source/bmalloc/bmalloc/VMAllocate.h:156
> +    // @TODO

Ditto.

> Source/bmalloc/bmalloc/VMAllocate.h:166
> +    // @TODO

Ditto.

> Source/bmalloc/bmalloc/VMAllocate.h:176
> +    // @TODO

Ditto.

> Source/bmalloc/bmalloc/VMAllocate.h:231
> +    // @TODO

Ditto.

> Source/bmalloc/bmalloc/VMAllocate.h:246
> +    // @TODO

Ditto.

> Source/bmalloc/bmalloc/win/CryptoRandomWin.cpp:31
> +{

Can you add a comment with FIXME?
Comment 7 Geoffrey Garen 2020-06-30 14:15:32 PDT
Comment on attachment 403150 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=403150&action=review

> Source/bmalloc/bmalloc/DebugHeap.cpp:108
> +#if BOS(WINDOWS)
> +    result = _aligned_malloc(size, alignment);
> +    RELEASE_BASSERT(action == FailureAction::ReturnNull || result);

This is incorrect because it does not pair with _aligned_free.

I think Windows just shouldn't use the debug heap.
Comment 8 Geoffrey Garen 2020-06-30 14:17:22 PDT
Generally, I don't love the idea of landing non-functional pieces of a port without testing. Is there a way to do this development locally or on a branch until it's more complete? Alternatively, do you have a complete patch that you can post for reference?