<commit_before>/******************************************************************************
 *  Copyright (c) 2008 - 2010 IBM Corporation and others.
 *  All rights reserved. This program and the accompanying materials
 *  are made available under the terms of the Eclipse Public License v1.0
 *  which accompanies this distribution, and is available at
 *  http://www.eclipse.org/legal/epl-v10.html
 * 
 *  Contributors:
 *    <NAME>, IBM Research - Initial Implementation
 *    <NAME>, IBM Research - Initial Implementation
 *    <NAME>, <NAME> - Port to x86 Multi-Core Systems
 ******************************************************************************/


class Chunk
# if !Work_Around_Extra_Words_In_Classes
: public Word_Containing_Object_Type
# endif

{
  # if Work_Around_Extra_Words_In_Classes
  WORD_CONTAINING_OBJECT_TYPE_MEMBERS
    # define chunk_header (*(oop_int_t*)this)
  # else
    oop_int_t chunk_header;
  # endif

 public:
  Object* object_from_chunk() {
    // "Compute the oop of this chunk by adding its extra header bytes."
    return (Object*) & ((char*)this)[extra_header_bytes()];
  }

  Object* object_from_chunk_without_preheader() {
    // "Compute the oop of this chunk by adding its extra header bytes."
    return (Object*) & ((char*)this)[extra_header_bytes_without_preheader()];
  }

  void make_free_object(oop_int_t bytes_including_header, int id);
};
<commit_msg>Fix for Chunk::object_from_chunk to first skip over the preheader to determine object position<commit_after>/******************************************************************************
 *  Copyright (c) 2008 - 2010 IBM Corporation and others.
 *  All rights reserved. This program and the accompanying materials
 *  are made available under the terms of the Eclipse Public License v1.0
 *  which accompanies this distribution, and is available at
 *  http://www.eclipse.org/legal/epl-v10.html
 * 
 *  Contributors:
 *    <NAME>, IBM Research - Initial Implementation
 *    <NAME>, IBM Research - Initial Implementation
 *    <NAME>, Vrije Univers<NAME> - Port to x86 Multi-Core Systems
 ******************************************************************************/


/*
 A chunk is the unit used by the memory system, the heap to manage the memory.
 
 TODO: add information whether empty chunks are somehow abused to store data.
       and how it is encoded.
 */

class Chunk
# if !Work_Around_Extra_Words_In_Classes
: public Word_Containing_Object_Type
# endif

{
  # if Work_Around_Extra_Words_In_Classes
  WORD_CONTAINING_OBJECT_TYPE_MEMBERS
    # define chunk_header (*(oop_int_t*)this)
  # else
    oop_int_t chunk_header;
  # endif

 public:
  
  /**
   * Determine the start of the object, i.e., the position of the base header.
   *
   * See object.h for details.
   */
  Object* object_from_chunk() {
    Word_Containing_Object_Type* const after_preheader =
          (Word_Containing_Object_Type*)((char*) this + preheader_byte_size);
    
    
    return (Object*) & ((char*)after_preheader)[after_preheader->extra_header_bytes_without_preheader()];
  }

  /**
   * Determine the start of the object, i.e., the position of the base header.
   *
   * REMARK: this is used for chunks read from a standard image.
   *         In such a case, the chunks do NOT contain a preheader.
   *
   * See object.h for details.
   */
  Object* object_from_chunk_without_preheader() {
    // "Compute the oop of this chunk by adding its extra header bytes."
    return (Object*) & ((char*)this)[extra_header_bytes_without_preheader()];
  }

  void make_free_object(oop_int_t bytes_including_header, int id);
};

{'fraction_non_alphanumeric': 0.1671270718232044, 'fraction_numerical': 0.0077348066298342545, 'mean_word_length': 4.136170212765958, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1514172', 'n_tokens_mistral': 1075, 'n_tokens_neox': 1005, 'n_words': 324}