Skip to content
Permalink
Browse files
[libpas] Update macOS build to c++20 and add bmalloc api test cases
https://bugs.webkit.org/show_bug.cgi?id=239105

Reviewed by Yusuke Suzuki and Yusuke Suzuki.

Fix the macOS build, which could fail depending on the SDK.
Also, add several basic bmalloc api tests.

* Source/bmalloc/libpas/CMakeLists.txt:
* Source/bmalloc/libpas/libpas.xcodeproj/project.pbxproj:
* Source/bmalloc/libpas/src/test/BmallocTests.cpp: Added.
(std::testBmallocAllocate):
(std::testBmallocDeallocate):
(addBmallocTests):
* Source/bmalloc/libpas/src/test/PGMTests.cpp:
* Source/bmalloc/libpas/src/test/TestHarness.cpp:
(main):

Canonical link: https://commits.webkit.org/249568@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@292784 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
stwrt committed Apr 12, 2022
1 parent 594e84b commit 4888b2f18c113ceee22c5ef94903909b500b44d7
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 18 deletions.
@@ -1,3 +1,23 @@
2022-04-12 Brandon Stewart <brandonstewart@apple.com>

[libpas] Update macOS build to c++20 and add bmalloc api test cases
https://bugs.webkit.org/show_bug.cgi?id=239105

Reviewed by Yusuke Suzuki and Yusuke Suzuki.

Update libpas build config to c++20.
Add several basic bmalloc api tests.

* libpas/CMakeLists.txt:
* libpas/libpas.xcodeproj/project.pbxproj:
* libpas/src/test/BmallocTests.cpp: Added.
(std::testBmallocAllocate):
(std::testBmallocDeallocate):
(addBmallocTests):
* libpas/src/test/PGMTests.cpp:
* libpas/src/test/TestHarness.cpp:
(main):

2022-04-08 Elliott Williams <emw@apple.com>

[Xcode] Avoid targeting 32-bit iOS and Mac architectures
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.21)

project(libpas)

set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to be used")
set(CMAKE_CXX_STANDARD 20 CACHE STRING "C++ standard to be used")
add_compile_options(-Wall -Werror)

# Get sources
@@ -549,6 +549,7 @@
2B2A58992742D803005EE07C /* pas_probabilistic_guard_malloc_allocator.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B2A58972742D802005EE07C /* pas_probabilistic_guard_malloc_allocator.h */; };
2B2A589A2742D803005EE07C /* pas_probabilistic_guard_malloc_allocator.c in Sources */ = {isa = PBXBuildFile; fileRef = 2B2A58982742D802005EE07C /* pas_probabilistic_guard_malloc_allocator.c */; };
2B2A589C2742D815005EE07C /* PGMTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B2A589B2742D815005EE07C /* PGMTests.cpp */; };
2B6055E42805368B00C8BDAC /* BmallocTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B6055E32805368B00C8BDAC /* BmallocTests.cpp */; };
2C11E88E2728A783002162D0 /* bmalloc_type.h in Headers */ = {isa = PBXBuildFile; fileRef = 2C11E88C2728A783002162D0 /* bmalloc_type.h */; };
2C11E88F2728A783002162D0 /* pas_simple_type.c in Sources */ = {isa = PBXBuildFile; fileRef = 2C11E88D2728A783002162D0 /* pas_simple_type.c */; };
2C11E8912728A893002162D0 /* bmalloc_type.c in Sources */ = {isa = PBXBuildFile; fileRef = 2C11E8902728A893002162D0 /* bmalloc_type.c */; };
@@ -1249,6 +1250,7 @@
2B2A58972742D802005EE07C /* pas_probabilistic_guard_malloc_allocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pas_probabilistic_guard_malloc_allocator.h; sourceTree = "<group>"; };
2B2A58982742D802005EE07C /* pas_probabilistic_guard_malloc_allocator.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pas_probabilistic_guard_malloc_allocator.c; sourceTree = "<group>"; };
2B2A589B2742D815005EE07C /* PGMTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PGMTests.cpp; sourceTree = "<group>"; };
2B6055E32805368B00C8BDAC /* BmallocTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BmallocTests.cpp; sourceTree = "<group>"; };
2C11E88C2728A783002162D0 /* bmalloc_type.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bmalloc_type.h; sourceTree = "<group>"; };
2C11E88D2728A783002162D0 /* pas_simple_type.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pas_simple_type.c; sourceTree = "<group>"; };
2C11E8902728A893002162D0 /* bmalloc_type.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bmalloc_type.c; sourceTree = "<group>"; };
@@ -1383,6 +1385,7 @@
0FDEA45D228B651B0085E340 /* BitfieldVectorTests.cpp */,
2CE2AE34275A953E00D02BBC /* BitfitTests.cpp */,
0F53181022C954ED003F7B6A /* BitvectorTests.cpp */,
2B6055E32805368B00C8BDAC /* BmallocTests.cpp */,
0F31A66723E8B336002C0CA3 /* CartesianTreeTests.cpp */,
0FC682362129D4EB003C6A13 /* CoalignTests.cpp */,
2C48132C273F4159006CAB55 /* ExpendableMemoryTests.cpp */,
@@ -2639,6 +2642,7 @@
0FDEA461228B651B0085E340 /* BitfieldVectorTests.cpp in Sources */,
2CE2AE35275A953E00D02BBC /* BitfitTests.cpp in Sources */,
0F53181122C954ED003F7B6A /* BitvectorTests.cpp in Sources */,
2B6055E42805368B00C8BDAC /* BmallocTests.cpp in Sources */,
0F31A66823E8B336002C0CA3 /* CartesianTreeTests.cpp in Sources */,
0FC682382129D4EE003C6A13 /* CoalignTests.cpp in Sources */,
2C48132D273F4159006CAB55 /* ExpendableMemoryTests.cpp in Sources */,
@@ -2924,7 +2928,7 @@
0F443B3C23416A7C00BE50D1 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CODE_SIGN_STYLE = Automatic;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
@@ -2944,7 +2948,7 @@
0F443B3D23416A7C00BE50D1 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CODE_SIGN_STYLE = Automatic;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
@@ -2960,7 +2964,7 @@
0F443B4C2341761500BE50D1 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CLANG_ENABLE_MODULES = NO;
CLANG_ENABLE_MODULE_DEBUGGING = NO;
CODE_SIGN_STYLE = Automatic;
@@ -2982,7 +2986,7 @@
0F443B4D2341761500BE50D1 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CLANG_ENABLE_MODULES = NO;
CLANG_ENABLE_MODULE_DEBUGGING = NO;
CODE_SIGN_STYLE = Automatic;
@@ -3000,7 +3004,7 @@
0F8A803925EECBAF00790B4A /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CLANG_ENABLE_MODULES = NO;
CLANG_ENABLE_MODULE_DEBUGGING = NO;
CODE_SIGN_STYLE = Automatic;
@@ -3022,7 +3026,7 @@
0F8A803A25EECBAF00790B4A /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CLANG_ENABLE_MODULES = NO;
CLANG_ENABLE_MODULE_DEBUGGING = NO;
CODE_SIGN_STYLE = Automatic;
@@ -3040,7 +3044,7 @@
0F8A809525F6A44F00790B4A /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CLANG_ENABLE_MODULES = NO;
CLANG_ENABLE_MODULE_DEBUGGING = NO;
CODE_SIGN_STYLE = Automatic;
@@ -3062,7 +3066,7 @@
0F8A809625F6A44F00790B4A /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CLANG_ENABLE_MODULES = NO;
CLANG_ENABLE_MODULE_DEBUGGING = NO;
CODE_SIGN_STYLE = Automatic;
@@ -3080,6 +3084,7 @@
0F8A80C025F6A48700790B4A /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CODE_SIGN_STYLE = Automatic;
PRODUCT_NAME = "$(TARGET_NAME)";
};
@@ -3088,6 +3093,7 @@
0F8A80C125F6A48700790B4A /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CODE_SIGN_STYLE = Automatic;
PRODUCT_NAME = "$(TARGET_NAME)";
};
@@ -3096,6 +3102,7 @@
0F8A80DF25F6A6E700790B4A /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CODE_SIGN_STYLE = Automatic;
PRODUCT_NAME = "$(TARGET_NAME)";
};
@@ -3104,6 +3111,7 @@
0F8A80E025F6A6E700790B4A /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CODE_SIGN_STYLE = Automatic;
PRODUCT_NAME = "$(TARGET_NAME)";
};
@@ -3112,7 +3120,7 @@
0FBAE681248EC1C000311E6F /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CLANG_ENABLE_MODULES = NO;
CLANG_ENABLE_MODULE_DEBUGGING = NO;
CODE_SIGN_STYLE = Automatic;
@@ -3129,7 +3137,7 @@
0FBAE682248EC1C000311E6F /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CLANG_ENABLE_MODULES = NO;
CLANG_ENABLE_MODULE_DEBUGGING = NO;
CODE_SIGN_STYLE = Automatic;
@@ -3141,7 +3149,7 @@
0FC681E0210FAC4B003C6A13 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CLANG_ENABLE_MODULES = NO;
CLANG_ENABLE_MODULE_DEBUGGING = NO;
CODE_SIGN_STYLE = Automatic;
@@ -3158,7 +3166,7 @@
0FC681E1210FAC4B003C6A13 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CLANG_ENABLE_MODULES = NO;
CLANG_ENABLE_MODULE_DEBUGGING = NO;
CODE_SIGN_STYLE = Automatic;
@@ -3170,7 +3178,7 @@
0FDEA5DB2295FC8E0085E340 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CLANG_ENABLE_MODULES = NO;
CLANG_ENABLE_MODULE_DEBUGGING = NO;
CLANG_WARN_ASSIGN_ENUM = YES;
@@ -3207,7 +3215,7 @@
0FDEA5DC2295FC8E0085E340 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CLANG_ENABLE_MODULES = NO;
CLANG_ENABLE_MODULE_DEBUGGING = NO;
CLANG_WARN_ASSIGN_ENUM = YES;
@@ -3240,7 +3248,7 @@
0FF08F5222A86C9A00386575 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CLANG_ENABLE_MODULES = NO;
CLANG_ENABLE_MODULE_DEBUGGING = NO;
CODE_SIGN_STYLE = Automatic;
@@ -3262,7 +3270,7 @@
0FF08F5322A86C9A00386575 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CLANG_ENABLE_MODULES = NO;
CLANG_ENABLE_MODULE_DEBUGGING = NO;
CODE_SIGN_STYLE = Automatic;
@@ -0,0 +1,54 @@
/*
* Copyright (c) 2022 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "TestHarness.h"
#include "bmalloc_heap.h"

#include <cstdlib>

using namespace std;

namespace {

void testBmallocAllocate()
{
void* mem = bmalloc_try_allocate(100);
CHECK(mem);
}

void testBmallocDeallocate()
{
void* mem = bmalloc_try_allocate(100);
CHECK(mem);
bmalloc_deallocate(mem);
}

} // anonymous namespace

void addBmallocTests()
{
ADD_TEST(testBmallocAllocate());
ADD_TEST(testBmallocDeallocate());
}
@@ -33,7 +33,6 @@
#include "iso_heap_config.h"
#include "pas_heap_ref_kind.h"


using namespace std;

namespace {
@@ -353,6 +353,7 @@ int resultPipe[2];
void addBitfieldVectorTests();
void addBitfitTests();
void addBitvectorTests();
void addBmallocTests();
void addCartesianTreeTests();
void addCoalignTests();
void addExpendableMemoryTests();
@@ -721,6 +722,7 @@ int main(int argc, char** argv)
ADD_SUITE(BitfieldVector);
ADD_SUITE(Bitfit);
ADD_SUITE(Bitvector);
ADD_SUITE(Bmalloc);
ADD_SUITE(CartesianTree);
ADD_SUITE(Coalign);
ADD_SUITE(ExpendableMemory);

0 comments on commit 4888b2f

Please sign in to comment.