changeset 10446:f96580a236c0

8149973: Optimize object alignment check in debug builds. Reviewed-by: coleenp, tschatzl
author ddmitriev
date Mon, 07 Mar 2016 10:36:50 +0300
parents 57175b61dac3
children 1bff1b586886 143691dafa25 a6ba2cec1af1 b9719c517370
files src/share/vm/gc/g1/g1OopClosures.inline.hpp src/share/vm/gc/g1/g1RemSet.inline.hpp src/share/vm/oops/oop.inline.hpp
diffstat 3 files changed, 4 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/gc/g1/g1OopClosures.inline.hpp	Sun Mar 06 19:07:57 2016 -0500
+++ b/src/share/vm/gc/g1/g1OopClosures.inline.hpp	Mon Mar 07 10:36:50 2016 +0300
@@ -171,14 +171,7 @@
 #ifdef ASSERT
   // can't do because of races
   // assert(obj == NULL || obj->is_oop(), "expected an oop");
-
-  // Do the safe subset of is_oop
-#ifdef CHECK_UNHANDLED_OOPS
-  oopDesc* o = obj.obj();
-#else
-  oopDesc* o = obj;
-#endif // CHECK_UNHANDLED_OOPS
-  assert((intptr_t)o % MinObjAlignmentInBytes == 0, "not oop aligned");
+  assert(check_obj_alignment(obj), "not oop aligned");
   assert(_g1->is_in_reserved(obj), "must be in heap");
 #endif // ASSERT
 
--- a/src/share/vm/gc/g1/g1RemSet.inline.hpp	Sun Mar 06 19:07:57 2016 -0500
+++ b/src/share/vm/gc/g1/g1RemSet.inline.hpp	Mon Mar 07 10:36:50 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, 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
@@ -44,14 +44,7 @@
 #ifdef ASSERT
   // can't do because of races
   // assert(obj == NULL || obj->is_oop(), "expected an oop");
-
-  // Do the safe subset of is_oop
-#ifdef CHECK_UNHANDLED_OOPS
-  oopDesc* o = obj.obj();
-#else
-  oopDesc* o = obj;
-#endif // CHECK_UNHANDLED_OOPS
-  assert((intptr_t)o % MinObjAlignmentInBytes == 0, "not oop aligned");
+  assert(check_obj_alignment(obj), "not oop aligned");
   assert(_g1->is_in_reserved(obj), "must be in heap");
 #endif // ASSERT
 
--- a/src/share/vm/oops/oop.inline.hpp	Sun Mar 06 19:07:57 2016 -0500
+++ b/src/share/vm/oops/oop.inline.hpp	Mon Mar 07 10:36:50 2016 +0300
@@ -295,7 +295,7 @@
 // in inner GC loops so these are separated.
 
 inline bool check_obj_alignment(oop obj) {
-  return cast_from_oop<intptr_t>(obj) % MinObjAlignmentInBytes == 0;
+  return (cast_from_oop<intptr_t>(obj) & MinObjAlignmentInBytesMask) == 0;
 }
 
 oop oopDesc::decode_heap_oop_not_null(narrowOop v) {