< prev index next >

src/hotspot/share/asm/assembler.cpp

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, 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
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -28,10 +28,14 @@
 #include "asm/macroAssembler.inline.hpp"
 #include "runtime/atomic.hpp"
 #include "runtime/icache.hpp"
 #include "runtime/os.hpp"
 #include "runtime/thread.hpp"
+#include "utilities/macros.hpp"
+#if INCLUDE_SHENANDOAHGC
+#include "gc/shenandoah/shenandoahBarrierSetAssembler.hpp"
+#endif
 
 
 // Implementation of AbstractAssembler
 //
 // The AbstractAssembler is generating code into a CodeBuffer. To make code generation faster,

@@ -298,20 +302,42 @@
 }
 
 bool MacroAssembler::needs_explicit_null_check(intptr_t offset) {
   // Exception handler checks the nmethod's implicit null checks table
   // only when this method returns false.
+#ifdef AARCH64
+  // AArch64 addresses passed from the signal handler may have
+  // their top 8 bits zeroed. That affects the case where
+  // Shenandoah tries to load a Brooks pointer via a null oop.
+  const uintptr_t address_bits = (uintptr_t)0xfffffffffffful;
+#else
+  const uintptr_t address_bits = ~(uintptr_t)0;
+#endif
 #ifdef _LP64
   if (UseCompressedOops && Universe::narrow_oop_base() != NULL) {
     assert (Universe::heap() != NULL, "java heap should be initialized");
     // The first page after heap_base is unmapped and
     // the 'offset' is equal to [heap_base + offset] for
     // narrow oop implicit null checks.
     uintptr_t base = (uintptr_t)Universe::narrow_oop_base();
-    if ((uintptr_t)offset >= base) {
+    int adj = 0;
+#if INCLUDE_SHENANDOAHGC
+    if (UseShenandoahGC) {
+      adj = ShenandoahBrooksPointer::byte_offset();
+      assert(adj < 0, "no need for positive adjustments");
+    }
+#endif
+    if ((uintptr_t)((offset - adj) & address_bits) >= base) {
       // Normalize offset for the next check.
       offset = (intptr_t)(pointer_delta((void*)offset, (void*)base, 1));
     }
   }
 #endif
+
+#if INCLUDE_SHENANDOAHGC
+  if (UseShenandoahGC && ((offset & address_bits) == (ShenandoahBrooksPointer::byte_offset() & address_bits))) {
+    return false;
+  }
+#endif
+
   return offset < 0 || os::vm_page_size() <= offset;
 }
< prev index next >