Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8200113

Make Access load proxys smarter

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 11
    • None
    • hotspot
    • None
    • gc
    • b10

      Access returns the result of loads through load proxy objects that implicity convert themselves to a template inferred type. This is a metaprogramming technique used to infer return types in C++.

      However, I have heard requests that it would be great if it could be a bit smarter and do more than just be assigned to a type.

      Example use cases that do not work today without workarounds:

        oop val = ...;
        narrowOop narrow = 0u;
        oop *oop_val = &val;
        narrowOop *narrow_val = &narrow;
        HeapWord *heap_word_val = reinterpret_cast<HeapWord*>(oop_val);

        if (val == HeapAccess<>::oop_load_at(val, 16)) {}
        if (HeapAccess<>::oop_load_at(val, 16) == val) {}
        if (val != HeapAccess<>::oop_load_at(val, 16)) {}
        if (HeapAccess<>::oop_load_at(val, 16) != val) {}

        if (HeapAccess<>::oop_load(oop_val) != val) {}
        if (HeapAccess<>::oop_load(heap_word_val) != val) {}
        if (RawAccess<>::oop_load(narrow_val) != narrow) {}

        if (HeapAccess<>::oop_load(oop_val) == val) {}
        if (HeapAccess<>::oop_load(heap_word_val) == val) {}
        if (RawAccess<>::oop_load(narrow_val) == narrow) {}

        if (val != HeapAccess<>::oop_load(oop_val)) {}
        if (val != HeapAccess<>::oop_load(heap_word_val)) {}
        if (narrow != RawAccess<>::oop_load(narrow_val)) {}

        if (val == HeapAccess<>::oop_load(oop_val)) {}
        if (val == HeapAccess<>::oop_load(heap_word_val)) {}
        if (narrow == RawAccess<>::oop_load(narrow_val)) {}

        if ((oop)HeapAccess<>::oop_load(oop_val) == NULL) {}

        oop tmp = true ? HeapAccess<>::oop_load(oop_val) : val;

            eosterlund Erik Ă–sterlund
            eosterlund Erik Ă–sterlund
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: