|
1 | 1 | /*
|
2 |
| - * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 1997, 2020, 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
|
@@ -53,10 +53,6 @@ class NativeMovConstReg;
|
53 | 53 | // RelocIterator
|
54 | 54 | // A StackObj which iterates over the relocations associated with
|
55 | 55 | // a range of code addresses. Can be used to operate a copy of code.
|
56 |
| -// BoundRelocation |
57 |
| -// An _internal_ type shared by packers and unpackers of relocations. |
58 |
| -// It pastes together a RelocationHolder with some pointers into |
59 |
| -// code and relocInfo streams. |
60 | 56 |
|
61 | 57 |
|
62 | 58 | // Notes on relocType:
|
@@ -275,27 +271,26 @@ class relocInfo {
|
275 | 271 | type_mask = 15 // A mask which selects only the above values
|
276 | 272 | };
|
277 | 273 |
|
278 |
| - protected: |
| 274 | + private: |
279 | 275 | unsigned short _value;
|
280 | 276 |
|
281 |
| - enum RawBitsToken { RAW_BITS }; |
282 |
| - relocInfo(relocType type, RawBitsToken ignore, int bits) |
| 277 | + static const enum class RawBitsToken {} RAW_BITS{}; |
| 278 | + |
| 279 | + relocInfo(relocType type, RawBitsToken, int bits) |
283 | 280 | : _value((type << nontype_width) + bits) { }
|
284 | 281 |
|
285 |
| - relocInfo(relocType type, RawBitsToken ignore, int off, int f) |
286 |
| - : _value((type << nontype_width) + (off / (unsigned)offset_unit) + (f << offset_width)) { } |
| 282 | + static relocType check_relocType(relocType type) NOT_DEBUG({ return type; }); |
| 283 | + |
| 284 | + static void check_offset_and_format(int offset, int format) NOT_DEBUG_RETURN; |
| 285 | + |
| 286 | + static int compute_bits(int offset, int format) { |
| 287 | + check_offset_and_format(offset, format); |
| 288 | + return (offset / offset_unit) + (format << offset_width); |
| 289 | + } |
287 | 290 |
|
288 | 291 | public:
|
289 |
| - // constructor |
290 | 292 | relocInfo(relocType type, int offset, int format = 0)
|
291 |
| -#ifndef ASSERT |
292 |
| - { |
293 |
| - (*this) = relocInfo(type, RAW_BITS, offset, format); |
294 |
| - } |
295 |
| -#else |
296 |
| - // Put a bunch of assertions out-of-line. |
297 |
| - ; |
298 |
| -#endif |
| 293 | + : relocInfo(check_relocType(type), RAW_BITS, compute_bits(offset, format)) {} |
299 | 294 |
|
300 | 295 | #define APPLY_TO_RELOCATIONS(visitor) \
|
301 | 296 | visitor(oop) \
|
@@ -376,7 +371,7 @@ class relocInfo {
|
376 | 371 |
|
377 | 372 | inline friend relocInfo prefix_relocInfo(int datalen);
|
378 | 373 |
|
379 |
| - protected: |
| 374 | + private: |
380 | 375 | // an immediate relocInfo optimizes a prefix with one 10-bit unsigned value
|
381 | 376 | static relocInfo immediate_relocInfo(int data0) {
|
382 | 377 | assert(fits_into_immediate(data0), "data0 in limits");
|
@@ -492,8 +487,8 @@ class RelocationHolder {
|
492 | 487 | };
|
493 | 488 |
|
494 | 489 | // A RelocIterator iterates through the relocation information of a CodeBlob.
|
495 |
| -// It is a variable BoundRelocation which is able to take on successive |
496 |
| -// values as it is advanced through a code stream. |
| 490 | +// It provides access to successive relocations as it is advanced through a |
| 491 | +// code stream. |
497 | 492 | // Usage:
|
498 | 493 | // RelocIterator iter(nm);
|
499 | 494 | // while (iter.next()) {
|
|
0 commit comments