8254882: ZGC: Use static_assert instead of guarantee

Reviewed-by: kbarrett, tschatzl
This commit is contained in:
Per Liden 2020-10-19 07:35:36 +00:00
parent 8edc2f05b5
commit a1a3e9def7
3 changed files with 13 additions and 13 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -60,9 +60,9 @@ class ZBitField : public AllStatic {
private:
static const int ContainerBits = sizeof(ContainerType) * BitsPerByte;
STATIC_ASSERT(FieldBits < ContainerBits);
STATIC_ASSERT(FieldShift + FieldBits <= ContainerBits);
STATIC_ASSERT(ValueShift + FieldBits <= ContainerBits);
static_assert(FieldBits < ContainerBits, "Field too large");
static_assert(FieldShift + FieldBits <= ContainerBits, "Field too large");
static_assert(ValueShift + FieldBits <= ContainerBits, "Field too large");
static const ContainerType FieldMask = (((ContainerType)1 << FieldBits) - 1);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -66,10 +66,13 @@ public:
T* pop();
};
typedef ZStack<ZMarkStackEntry, ZMarkStackSlots> ZMarkStack;
typedef ZStackList<ZMarkStack> ZMarkStackList;
typedef ZStack<ZMarkStack*, ZMarkStackMagazineSlots> ZMarkStackMagazine;
typedef ZStackList<ZMarkStackMagazine> ZMarkStackMagazineList;
using ZMarkStack = ZStack<ZMarkStackEntry, ZMarkStackSlots>;
using ZMarkStackList = ZStackList<ZMarkStack>;
using ZMarkStackMagazine = ZStack<ZMarkStack*, ZMarkStackMagazineSlots>;
using ZMarkStackMagazineList = ZStackList<ZMarkStackMagazine>;
static_assert(sizeof(ZMarkStack) == ZMarkStackSize, "ZMarkStack size mismatch");
static_assert(sizeof(ZMarkStackMagazine) <= ZMarkStackSize, "ZMarkStackMagazine size too large");
class ZMarkStripe {
private:

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -128,9 +128,6 @@ uintptr_t ZMarkStackSpace::alloc(size_t size) {
ZMarkStackAllocator::ZMarkStackAllocator() :
_freelist(),
_space() {
guarantee(sizeof(ZMarkStack) == ZMarkStackSize, "Size mismatch");
guarantee(sizeof(ZMarkStackMagazine) <= ZMarkStackSize, "Size mismatch");
// Prime free list to avoid an immediate space
// expansion when marking starts.
if (_space.is_initialized()) {