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

Copy class should use templates

XMLWordPrintable

      Instead of casting things to HeapWord*.
      eg.
      template <typename T> Copy::fill_to_words(T* p, size_t count, const T& value) {
         STATIC_ASSERT(is_aligned(sizeof(T), sizeof(void*));
          call fill_to_words_impl(void*, count, value); // that takes a void* arg
      }

      For example, these aren't HeapWords!
      utilities/copy.hpp: inline static void conjoint_words_to_higher(const HeapWord* from, HeapWord* to, size_t byte_count) {
      opto/node.cpp: Copy::conjoint_words_to_higher((HeapWord*)&_in[_cnt], (HeapWord*)&_in[_cnt+m], ((i-_cnt)*sizeof(Node*)));
      opto/node.cpp: Copy::conjoint_words_to_higher((HeapWord*)&_in[idx], (HeapWord*)&_in[idx+1], ((_cnt-idx-1)*sizeof(Node*)));
      opto/node.cpp: Copy::conjoint_words_to_higher((HeapWord*)&_nodes[i], (HeapWord*)&_nodes[i+1], ((_max-i-1)*sizeof(Node*)));
      opto/block.cpp: Copy::conjoint_words_to_higher((HeapWord*)&_blocks[i], (HeapWord*)&_blocks[i+1], ((_cnt-i-1)*sizeof(Block*)));

            coleenp Coleen Phillimore
            coleenp Coleen Phillimore
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: