当前位置: 首页>>代码示例>>C++>>正文


C++ CollectedHeap::reserved_region方法代码示例

本文整理汇总了C++中CollectedHeap::reserved_region方法的典型用法代码示例。如果您正苦于以下问题:C++ CollectedHeap::reserved_region方法的具体用法?C++ CollectedHeap::reserved_region怎么用?C++ CollectedHeap::reserved_region使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CollectedHeap的用法示例。


在下文中一共展示了CollectedHeap::reserved_region方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

TEST_VM(CollectedHeap, is_in) {
  CollectedHeap* heap = Universe::heap();

  uintptr_t epsilon = (uintptr_t) MinObjAlignment;
  uintptr_t heap_start = (uintptr_t) heap->reserved_region().start();
  uintptr_t heap_end = (uintptr_t) heap->reserved_region().end();

  // Test that NULL is not in the heap.
  ASSERT_FALSE(heap->is_in(NULL)) << "NULL is unexpectedly in the heap";

  // Test that a pointer to before the heap start is reported as outside the heap.
  ASSERT_GE(heap_start, ((uintptr_t) NULL + epsilon))
          << "Sanity check - heap should not start at 0";

  void* before_heap = (void*) (heap_start - epsilon);
  ASSERT_FALSE(heap->is_in(before_heap)) << "before_heap: " << p2i(before_heap)
          << " is unexpectedly in the heap";

  // Test that a pointer to after the heap end is reported as outside the heap.
  ASSERT_LE(heap_end, ((uintptr_t)-1 - epsilon))
          << "Sanity check - heap should not end at the end of address space";

  void* after_heap = (void*) (heap_end + epsilon);
  ASSERT_FALSE(heap->is_in(after_heap)) << "after_heap: " << p2i(after_heap)
          << " is unexpectedly in the heap";
}
开发者ID:,项目名称:,代码行数:26,代码来源:


注:本文中的CollectedHeap::reserved_region方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。