Mercurial > hg > graal-jvmci-8
comparison src/share/vm/utilities/globalDefinitions.hpp @ 1665:a93a9eda13f7
6962947: shared TaskQueue statistics
Reviewed-by: tonyp, ysr
author | jcoomes |
---|---|
date | Fri, 16 Jul 2010 21:33:21 -0700 |
parents | e9ff18c4ace7 |
children | d6f45b55c972 |
comparison
equal
deleted
inserted
replaced
1657:1a1ce2076047 | 1665:a93a9eda13f7 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
343 | 343 |
344 inline intptr_t align_object_offset(intptr_t offset) { | 344 inline intptr_t align_object_offset(intptr_t offset) { |
345 return align_size_up(offset, HeapWordsPerLong); | 345 return align_size_up(offset, HeapWordsPerLong); |
346 } | 346 } |
347 | 347 |
348 // The expected size in bytes of a cache line, used to pad data structures. | |
349 #define DEFAULT_CACHE_LINE_SIZE 64 | |
350 | |
351 // Bytes needed to pad type to avoid cache-line sharing; alignment should be the | |
352 // expected cache line size (a power of two). The first addend avoids sharing | |
353 // when the start address is not a multiple of alignment; the second maintains | |
354 // alignment of starting addresses that happen to be a multiple. | |
355 #define PADDING_SIZE(type, alignment) \ | |
356 ((alignment) + align_size_up_(sizeof(type), alignment)) | |
357 | |
358 // Templates to create a subclass padded to avoid cache line sharing. These are | |
359 // effective only when applied to derived-most (leaf) classes. | |
360 | |
361 // When no args are passed to the base ctor. | |
362 template <class T, size_t alignment = DEFAULT_CACHE_LINE_SIZE> | |
363 class Padded: public T { | |
364 private: | |
365 char _pad_buf_[PADDING_SIZE(T, alignment)]; | |
366 }; | |
367 | |
368 // When either 0 or 1 args may be passed to the base ctor. | |
369 template <class T, typename Arg1T, size_t alignment = DEFAULT_CACHE_LINE_SIZE> | |
370 class Padded01: public T { | |
371 public: | |
372 Padded01(): T() { } | |
373 Padded01(Arg1T arg1): T(arg1) { } | |
374 private: | |
375 char _pad_buf_[PADDING_SIZE(T, alignment)]; | |
376 }; | |
348 | 377 |
349 //---------------------------------------------------------------------------------------------------- | 378 //---------------------------------------------------------------------------------------------------- |
350 // Utility macros for compilers | 379 // Utility macros for compilers |
351 // used to silence compiler warnings | 380 // used to silence compiler warnings |
352 | 381 |