• Home
    • View
    • Login
    This page
    • Normal
    • Export PDF
    • Page Information

    Loading...
  1. Dashboard
  2. Undefined Space
  3. HotSpot
  4. StyleGuide

Page History

Versions Compared

Old Version 4

changes.mady.by.user J. Duke

Saved on Nov 22, 2012

compared with

New Version 5

changes.mady.by.user J. Duke

Saved on Nov 22, 2012

  • Previous Change: Difference between versions 3 and 4
  • Next Change: Difference between versions 5 and 6
  • View Page History

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Clearly comment subtle fixes.
  • Clearly comment tricky classes and functions.
  • If you have to choose between commenting code and writing wiki content, comment the code. Link from the wiki to the source file if it makes sense.
  • Include the seven-digit bug numbers.
  • Personal names are discouraged in the source code, which is a team product.

Macros

  • You can almost always use an inline function or class instead of a macro. Use a macro only when you really need it.
  • Templates may be preferable to multi-line macros. (There may be subtle performance effects with templates on some platforms; revert to macros if absolutely necessary.)
  • For build features such as PRODUCT, use #ifdef PRODUCT for multiple-line inclusions or exclusions.
  • For short inclusions or exclusions based on build features, use macros like PRODUCT_ONLY and NOT_PRODUCT. But avoid using them with multiple-line arguments, since debuggers do not handle that well.
  • Use CATCH, THROW, etc. for HotSpot-specific exception processing.

Grouping

  • Group related code together, so readers can concentrate on one section of one file.
  • Avoid making functions too large, more than a screenful of text; split out chunks of logic into file-local classes or static functions if needed.
  • If a class FooBar is going to be used in more than one place, put it a file named fooBar.hpp and fooBar.cpp. If the class is a sidekick to a more important class BazBat, it can go in bazBat.hpp.
  • Put a member function FooBar::bang into the same file that defined FooBar, or its associated *.cpp file.

...

  • Conform new code to style conventions. Avoid unnecessary "esthetic" variations, which are distracting.
  • Use the C++ RAII design pattern to manage bracketed critical sections. See class ResourceMark for an example.
  • +Verbose is used to provide additional output for another flag, but does not enable output by itself.
  • Do not use ints or pointers as booleans with &&, ||, if, while. Instead, compare explicitly != 0 or != NULL, etc. (See #8 above.)
  • Use functions from globalDefinitions.hpp when performing bitwise operations on integers. Do not code directly as C operators, unless they are extremely simple. (Examples: round_to, is_power_of_2, exact_log2.)
  • More suggestions on factoring.

...

Overview
Content Tools
ThemeBuilder

Terms of Use
• License: GPLv2
• Privacy • Trademarks • Contact Us

Powered by a free Atlassian Confluence Open Source Project License granted to https://www.atlassian.com/software/views/opensource-community-additional-license-offer. Evaluate Confluence today.

  • Kolekti ThemeBuilder Powered by Atlassian Confluence 8.5.21
  • Kolekti ThemeBuilder printed.by.atlassian.confluence
  • Report a bug
  • Atlassian News
Atlassian
Kolekti ThemeBuilder EngineAtlassian Confluence
{"serverDuration": 331, "requestCorrelationId": "ca2bcef3b8072fbd"}