You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: compilation.rs
    path of file: ./repos/rspack/crates/rspack_core/src/compiler
    
    the code of the file until where you have to start completion: use std::{
  collections::{hash_map, VecDeque},
  fmt::Debug,
  hash::{BuildHasherDefault, Hash},
  path::PathBuf,
  sync::Arc,
};

use dashmap::DashSet;
use indexmap::{IndexMap, IndexSet};
use itertools::Itertools;
use rayon::prelude::*;
use rspack_error::{error, Diagnostic, Result, Severity, TWithDiagnosticArray};
use rspack_futures::FuturesResults;
use rspack_hash::{RspackHash, RspackHashDigest};
use rspack_hook::AsyncSeriesHook;
use rspack_identifier::{Identifiable, IdentifierMap, IdentifierSet};
use rspack_sources::{BoxSource, CachedSource, OriginalSource, SourceExt};
use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet, FxHasher};
use swc_core::ecma::ast::ModuleItem;
use tracing::instrument;

use super::{
  hmr::CompilationRecords,
  make::{update_module_graph, MakeParam},
};
use crate::tree_shaking::visitor::OptimizeAnalyzeResult;
use crate::{
  build_chunk_graph::build_chunk_graph,
  cache::{use_code_splitting_cache, Cache, CodeSplittingCache},
  get_chunk_from_ukey, get_mut_chunk_from_ukey, is_source_equal, prepare_get_exports_type,
  tree_shaking::{optimizer, visitor::SymbolRef, BailoutFlag, OptimizeDependencyResult},
  AddQueueHandler, AdditionalChunkRuntimeRequirementsArgs, AdditionalModuleRequirementsArgs,
  BoxDependency, BoxModule, BuildQueueHandler, BuildTimeExecutionQueueH
    
  fn code_generation(&mut self) -> Result<()> {
    let logger = self.get_logger("rspack.Compilation");
    let mut codegen_cache_counter = match self.options.cache {
      CacheOptions::Disabled => None,
      _ => Some(logger.cache("module code generation cache")),
    };

    fn run_iteration(
      compilation: &mut Compilation,
      codegen_cache_counter: &mut Option<CacheCount>,
      filter_op: impl Fn(&(&ModuleIdentifier, &Box<dyn Module>)) -> bool + Sync + Send,
    ) -> Result<()> {
      // If the runtime optimization is not opt out, a module codegen should be executed for each runtime.
      // Else, share same codegen result for all runtimes.
      let used_exports_optimization = compilation.options.is_new_tree_shaking()
        && compilation.options.optimization.used_exports.is_true();
      let results = compilation.code_generation_modules(
        codegen_cache_counter,
        used_exports_optimization,
        compilation
          .module_graph
          .modules()
          .iter()
          .filter(filter_op)
          .map(|(id, _)| *id)
          .collect::<Vec<_>>()
          .into_par_iter(),
      )?;

      results.iter().for_each(|module_identifier| {
        compilation
          .code_generated_modules
          .insert(*module_identifier);
      });

      Ok(())
    }

    // FIXME:
    // Webpack may modify the moduleGraph in module.getExportsType()
    // and it is widely called after compilation.finish()
    // so add this method to trigger moduleGraph modification and
    // then make sure that moduleGraph is immutable
    prepare_get_exports_type(&mut self.module_graph);

    run_iteration(self, &mut codegen_cache_counter, |(_, module)| {
      module.get_code_generation_dependencies().is_none()
    })?;

    run_iteration(self, &mut codegen_cache_counter, |(_, module)| {
      module.get_code_generation_dependencies().is_some()
    })?;

    if let Some(counter) = codegen_cache_counter {
      logger.cache_end(counter);
    }

    Ok(())
  }