forked from openjdk/jdk
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
194 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright Amazon.com Inc. 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. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
* | ||
*/ | ||
|
||
#include "precompiled.hpp" | ||
#include "oops/klassMode.hpp" | ||
|
||
KlassMode::Mode KlassMode::_klass_mode = KlassMode::Undefined; | ||
|
||
void KlassMode::init_klass_mode() { | ||
assert(_klass_mode == Undefined, "KlassMode initialized twice"); | ||
if (UseCompactObjectHeaders) { | ||
_klass_mode = Compact; | ||
} else if (UseCompressedClassPointers) { | ||
_klass_mode = Compressed; | ||
} else { | ||
_klass_mode = Uncompressed; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Copyright Amazon.com Inc. 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. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
* | ||
*/ | ||
|
||
#ifndef SHARE_OOPS_KLASSMODE_HPP | ||
#define SHARE_OOPS_KLASSMODE_HPP | ||
|
||
/* | ||
* This class helps to avoid loading more than one flag when | ||
* accessing the Klass* in oopDesc::klass(). This is important | ||
* on some performance critical paths where the Klass* is | ||
* accessed frequently, especially by GC oop iterators. | ||
* | ||
* Instead of doing: | ||
* if (UseCompactObjectHeaders) { // Load first flag | ||
* .. | ||
* } else if (UseCompressedClassPointers) { // Load second flag | ||
* .. | ||
* } else { | ||
* .. | ||
* } | ||
* | ||
* we can do: | ||
* switch (KlassMode::klass_mode()) { | ||
* case Compact: | ||
* .. | ||
* case Compressed: | ||
* .. | ||
* case Uncompressed: | ||
* .. | ||
* } | ||
*/ | ||
class KlassMode { | ||
public: | ||
enum Mode { | ||
// +UseCompactObjectHeaders (implies +UseCompressedClassPointers) | ||
Compact, | ||
// +UseCompressedClassPointers (-UseCompactObjectHeaders) | ||
Compressed, | ||
// -UseCompressedClassPointers (-UseCompactObjectHeaders) | ||
Uncompressed, | ||
// Not yet initialized | ||
Undefined | ||
}; | ||
|
||
private: | ||
static Mode _klass_mode; | ||
|
||
public: | ||
static void init_klass_mode(); | ||
static inline Mode klass_mode(); | ||
}; | ||
|
||
#endif // SHARE_OOPS_KLASSMODE_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright Amazon.com Inc. 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. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
* | ||
*/ | ||
|
||
#ifndef SHARE_OOPS_KLASSMODE_INLINE_HPP | ||
#define SHARE_OOPS_KLASSMODE_INLINE_HPP | ||
|
||
#include "oops/klassMode.hpp" | ||
|
||
inline KlassMode::Mode KlassMode::klass_mode() { | ||
#ifdef ASSERT | ||
assert(_klass_mode != Undefined, "KlassMode not yet initialized"); | ||
if (UseCompactObjectHeaders) { | ||
assert(_klass_mode == Compact, "Klass mode does not match flags"); | ||
} else if (UseCompressedClassPointers) { | ||
assert(_klass_mode == Compressed, "Klass mode does not match flags"); | ||
} else { | ||
assert(_klass_mode == Uncompressed, "Klass mode does not match flags"); | ||
} | ||
#endif | ||
#ifdef _LP64 | ||
return _klass_mode; | ||
#else | ||
return Uncompressed; | ||
#endif | ||
} | ||
|
||
#endif // SHARE_OOPS_KLASSMODE_INLINE_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters