Print this page
rev 7151 : 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
Summary: Warning when not checking exceptions from function that require so, also when local refs expand beyond capacity.
Reviewed-by: dsimms

Split Split Close
Expand all
Collapse all
          --- old/hotspot/src/share/vm/memory/guardedMemory.hpp
          +++ new/hotspot/src/share/vm/memory/guardedMemory.hpp
   1    1  /*
   2      - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
        2 + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
   3    3   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4    4   *
   5    5   * This code is free software; you can redistribute it and/or modify it
   6    6   * under the terms of the GNU General Public License version 2 only, as
   7    7   * published by the Free Software Foundation.
   8    8   *
   9    9   * This code is distributed in the hope that it will be useful, but WITHOUT
  10   10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11   11   * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12   12   * version 2 for more details (a copy is included in the LICENSE file that
↓ open down ↓ 215 lines elided ↑ open up ↑
 228  228     * @return the general purpose tag, defaults to NULL.
 229  229     */
 230  230    void* get_tag() const { return get_head_guard()->get_tag(); }
 231  231  
 232  232    /**
 233  233     * Return the size of the user data.
 234  234     *
 235  235     * @return the size of the user data.
 236  236     */
 237  237    size_t get_user_size() const {
 238      -    assert(_base_addr, "Not wrapping any memory");
      238 +    assert(_base_addr != NULL, "Not wrapping any memory");
 239  239      return get_head_guard()->get_user_size();
 240  240    }
 241  241  
 242  242    /**
 243  243     * Return the user data pointer.
 244  244     *
 245  245     * @return the user data pointer.
 246  246     */
 247  247    u_char* get_user_ptr() const {
 248      -    assert(_base_addr, "Not wrapping any memory");
      248 +    assert(_base_addr != NULL, "Not wrapping any memory");
 249  249      return _base_addr + sizeof(GuardHeader);
 250  250    }
 251  251  
 252  252    /**
 253  253     * Release the wrapped pointer for resource freeing.
 254  254     *
 255  255     * Pads the user data with "freeBlockPad", and dis-associates the helper.
 256  256     *
 257  257     * @return the original base pointer used to wrap the data.
 258  258     */
↓ open down ↓ 15 lines elided ↑ open up ↑
 274  274  
 275  275    virtual void print_on(outputStream* st) const;
 276  276  
 277  277   protected:
 278  278    GuardHeader*  get_head_guard() const { return (GuardHeader*) _base_addr; }
 279  279    Guard*        get_tail_guard() const { return (Guard*) (get_user_ptr() + get_user_size()); };
 280  280    void set_user_bytes(u_char ch) {
 281  281      memset(get_user_ptr(), ch, get_user_size());
 282  282    }
 283  283  
 284      -public:
      284 + public:
 285  285    /**
 286  286     * Return the total size required for wrapping the given user size.
 287  287     *
 288  288     * @return the total size required for wrapping the given user size.
 289  289     */
 290  290    static size_t get_total_size(size_t user_size) {
 291  291      size_t total_size = sizeof(GuardHeader) + user_size + sizeof(Guard);
 292  292      assert(total_size > user_size, "Unexpected wrap-around");
 293  293      return total_size;
 294  294    }
↓ open down ↓ 32 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX