# HG changeset patch # User goetz # Date 1487228826 -3600 # Node ID 12b2ef172230eae018ad30216e7d0b241dcb82d3 # Parent 457394dc689cad54e6d8cc3c16093eb0210b3b28 8028471: PPC64 (part 215): opto: Extend ImplicitNullCheck optimization. Summary: Other parts of this change came with "8165807: PPC64: Backport PPC64 port to OpenJDK 7" Reviewed-by: andrew diff -r 457394dc689c -r 12b2ef172230 src/os/bsd/vm/os_bsd.hpp --- a/src/os/bsd/vm/os_bsd.hpp Tue Feb 07 01:26:24 2017 +0000 +++ b/src/os/bsd/vm/os_bsd.hpp Thu Feb 16 08:07:06 2017 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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 @@ -27,6 +27,9 @@ // Bsd_OS defines the interface to Bsd operating systems +// Information about the protection of the page at address '0' on this os. +static bool zero_page_read_protected() { return true; } + /* pthread_getattr_np comes with BsdThreads-0.9-7 on RedHat 7.1 */ typedef int (*pthread_getattr_func_type) (pthread_t, pthread_attr_t *); diff -r 457394dc689c -r 12b2ef172230 src/share/vm/opto/lcm.cpp --- a/src/share/vm/opto/lcm.cpp Tue Feb 07 01:26:24 2017 +0000 +++ b/src/share/vm/opto/lcm.cpp Thu Feb 16 08:07:06 2017 +0100 @@ -57,25 +57,40 @@ // Check whether val is not-null-decoded compressed oop, // i.e. will grab into the base of the heap if it represents NULL. static bool accesses_heap_base_zone(Node *val) { - if (UseCompressedOops && Universe::narrow_oop_base() > 0) { + if (Universe::narrow_oop_base() > 0) { // Implies UseCompressedOops. if (val && val->is_Mach()) { - if (val->as_Mach()->ideal_Opcode() == Op_DecodeN) { - // This assumes all Decodes with TypePtr::NotNull are matched to nodes that - // decode NULL to point to the heap base (Decode_NN). - if (val->bottom_type()->is_oopptr()->ptr() == TypePtr::NotNull) { - return true; - } + if (val->as_Mach()->ideal_Opcode() == Op_DecodeN) { + // This assumes all Decodes with TypePtr::NotNull are matched to nodes that + // decode NULL to point to the heap base (Decode_NN). + if (val->bottom_type()->is_oopptr()->ptr() == TypePtr::NotNull) { + return true; } - // Must recognize load operation with Decode matched in memory operand. - // We should not reach here, as os::zero_page_read_protected() - // returns true everywhere exept for AIX. On AIX, no such memory operands - // exist. - NOT_AIX(Unimplemented()); } + // Must recognize load operation with Decode matched in memory operand. + // We should not reach here exept for PPC/AIX, as os::zero_page_read_protected() + // returns true everywhere else. On PPC, no such memory operands + // exist, therefore we did not yet implement a check for such operands. + NOT_AIX(Unimplemented()); + } } return false; } +static bool needs_explicit_null_check_for_read(Node *val) { + // On some OSes (AIX) the page at address 0 is only write protected. + // If so, only Store operations will trap. + if (os::zero_page_read_protected()) { + return false; // Implicit null check will work. + } + // Also a read accessing the base of a heap-based compressed heap will trap. + if (accesses_heap_base_zone(val) && // Hits the base zone page. + Universe::narrow_oop_use_implicit_null_checks()) { // Base zone page is protected. + return false; + } + + return true; +} + //------------------------------implicit_null_check---------------------------- // Detect implicit-null-check opportunities. Basically, find NULL checks // with suitable memory ops nearby. Use the memory op to do the NULL check. @@ -233,14 +248,8 @@ // On some OSes (AIX) the page at address 0 is only write protected. // If so, only Store operations will trap. // But a read accessing the base of a heap-based compressed heap will trap. - if (!was_store && !os::zero_page_read_protected()) { - if (!(accesses_heap_base_zone(val) && // Hits the base zone page. - Universe::narrow_oop_use_implicit_null_checks())) { // Page is protected. - continue; - } else { - tty->print("Found load accessing heap base on AIX\n"); - Unimplemented(); - } + if (!was_store && needs_explicit_null_check_for_read(val)) { + continue; } // check if the offset is not too high for implicit exception