Global Metrics

path: .metrics.loc.ploc
old: 23.0
new: 102.0

path: .metrics.loc.blank
old: 8.0
new: 29.0

path: .metrics.loc.sloc
old: 70.0
new: 140.0

path: .metrics.loc.cloc
old: 39.0
new: 9.0

path: .metrics.loc.lloc
old: 1.0
new: 69.0

path: .metrics.mi.mi_sei
old: 72.00285324462959
new: 6.924886710713846

path: .metrics.mi.mi_original
old: 69.88083732539121
new: 42.24161540621442

path: .metrics.mi.mi_visual_studio
old: 40.86598673999486
new: 24.70269906796165

path: .metrics.nargs.sum
old: 1.0
new: 4.0

path: .metrics.nargs.average
old: 1.0
new: 4.0

path: .metrics.nexits.sum
old: 1.0
new: 2.0

path: .metrics.nexits.average
old: 1.0
new: 2.0

path: .metrics.halstead.level
old: 0.21
new: 0.028035804762709005

path: .metrics.halstead.bugs
old: 0.042847957320149246
new: 0.8899193190356567

path: .metrics.halstead.length
old: 63.0
new: 566.0

path: .metrics.halstead.effort
old: 1457.3942985382716
new: 137945.5942410247

path: .metrics.halstead.volume
old: 306.05280269303705
new: 3867.415748017243

path: .metrics.halstead.estimated_program_length
old: 116.23866587835396
new: 682.7083584237879

path: .metrics.halstead.N2
old: 25.0
new: 191.0

path: .metrics.halstead.n1
old: 8.0
new: 31.0

path: .metrics.halstead.purity_ratio
old: 1.845058188545301
new: 1.206198513116233

path: .metrics.halstead.difficulty
old: 4.761904761904762
new: 35.66867469879518

path: .metrics.halstead.N1
old: 38.0
new: 375.0

path: .metrics.halstead.time
old: 80.96634991879287
new: 7663.644124501372

path: .metrics.halstead.vocabulary
old: 29.0
new: 114.0

path: .metrics.halstead.n2
old: 21.0
new: 83.0

path: .metrics.cyclomatic.average
old: 5.5
new: 8.333333333333334

path: .metrics.cyclomatic.sum
old: 11.0
new: 25.0

path: .metrics.cognitive.sum
old: 8.0
new: 22.0

path: .metrics.cognitive.average
old: 8.0
new: 22.0

Spaces Data

Minimal test - lines (17, 114)

path: .spaces[0].metrics.cognitive.sum
old: 0.0
new: 22.0

path: .spaces[0].metrics.cognitive.average
old: 0.0
new: 22.0

path: .spaces[0].metrics.nargs.average
old: 1.0
new: 4.0

path: .spaces[0].metrics.nargs.sum
old: 1.0
new: 4.0

path: .spaces[0].metrics.halstead.purity_ratio
old: 2.1788489416040897
new: 1.1149857797794371

path: .spaces[0].metrics.halstead.n2
old: 4.0
new: 73.0

path: .spaces[0].metrics.halstead.difficulty
old: 2.5
new: 37.157534246575345

path: .spaces[0].metrics.halstead.effort
old: 71.32331253245202
new: 135191.69733361012

path: .spaces[0].metrics.halstead.time
old: 3.96240625180289
new: 7510.649851867229

path: .spaces[0].metrics.halstead.length
old: 9.0
new: 543.0

path: .spaces[0].metrics.halstead.estimated_program_length
old: 19.60964047443681
new: 605.4372784202344

path: .spaces[0].metrics.halstead.n1
old: 5.0
new: 31.0

path: .spaces[0].metrics.halstead.N1
old: 5.0
new: 368.0

path: .spaces[0].metrics.halstead.vocabulary
old: 9.0
new: 104.0

path: .spaces[0].metrics.halstead.bugs
old: 0.005732795045386515
new: 0.8780355345474504

path: .spaces[0].metrics.halstead.volume
old: 28.52932501298081
new: 3638.338766950613

path: .spaces[0].metrics.halstead.N2
old: 4.0
new: 175.0

path: .spaces[0].metrics.halstead.level
old: 0.4
new: 0.02691244239631336

path: .spaces[0].metrics.nexits.average
old: 1.0
new: 2.0

path: .spaces[0].metrics.nexits.sum
old: 1.0
new: 2.0

path: .spaces[0].metrics.loc.blank
old: 0.0
new: 9.0

path: .spaces[0].metrics.loc.sloc
old: 4.0
new: 98.0

path: .spaces[0].metrics.loc.lloc
old: 1.0
new: 69.0

path: .spaces[0].metrics.loc.ploc
old: 4.0
new: 86.0

path: .spaces[0].metrics.loc.cloc
old: 0.0
new: 3.0

path: .spaces[0].metrics.cyclomatic.sum
old: 1.0
new: 24.0

path: .spaces[0].metrics.cyclomatic.average
old: 1.0
new: 12.0

path: .spaces[0].metrics.mi.mi_sei
old: 113.23125671373975
new: 10.197843534918102

path: .spaces[0].metrics.mi.mi_visual_studio
old: 76.54221188196857
new: 28.40190525265116

path: .spaces[0].metrics.mi.mi_original
old: 130.88718231816625
new: 48.56725798203348

Code

PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex,
  uint32_t* args, uint32_t* floatargs)
{

  typedef struct {
    uint32_t hi;
    uint32_t lo;
  } DU;


  nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
  const nsXPTMethodInfo* info;
  int32_t regwords = 1; /* self pointer is not in the variant records */
  uint8_t paramCount;
  uint8_t i;

  NS_ASSERTION(self,"no self");

  self->mEntry->GetMethodInfo(uint16_t(methodIndex), &info);
  NS_ASSERTION(info,"no method info");
  if (!info)
    return NS_ERROR_UNEXPECTED;

  paramCount = info->GetParamCount();

  const uint8_t indexOfJSContext = info->IndexOfJSContext();

  for(i = 0; i < paramCount; ++i, --args)
  {
    const nsXPTParamInfo& param = info->GetParam(i);
    const nsXPTType& type = param.GetType();
    nsXPTCMiniVariant* dp = ¶mBuffer[i];

    MOZ_CRASH("NYI: support implicit JSContext*, bug 1475699");

    if(param.IsOut() || !type.IsArithmetic())
    {
      dp->val.p = (void*) *args;
      ++regwords;
      continue;
    }
    switch(type)
    {
    case nsXPTType::T_I8     : dp->val.i8  = *((int32_t*) args); break;
    case nsXPTType::T_I16    : dp->val.i16 = *((int32_t*) args); break;
    case nsXPTType::T_I32    : dp->val.i32 = *((int32_t*) args); break;
    case nsXPTType::T_DOUBLE :
                               if (regwords & 1)
                               {
                                 ++regwords; /* align on double word */
                                 --args;
                               }
                               if (regwords == 0 || regwords == 2)
                               {
                                 dp->val.d=*((double*) (floatargs + regwords));
                                 --args;
                               }
                               else
                               {
                                 dp->val.d = *((double*) --args);
                               }
                               regwords += 2;
                               continue;
    case nsXPTType::T_U64    :
    case nsXPTType::T_I64    :
                               if (regwords & 1)
                               {
                                 ++regwords; /* align on double word */
                                 --args;
                               }
                               ((DU *)dp)->lo = *((uint32_t*) args);
                               ((DU *)dp)->hi = *((uint32_t*) --args);
                               regwords += 2;
                               continue;
    case nsXPTType::T_FLOAT  :
                               if (regwords >= 4)
                                 dp->val.f = *((float*) args);
                               else
                                 dp->val.f = *((float*) floatargs+4+regwords);
                               break;
    case nsXPTType::T_U8     : dp->val.u8  = *((uint32_t*) args); break;
    case nsXPTType::T_U16    : dp->val.u16 = *((uint32_t*) args); break;
    case nsXPTType::T_U32    : dp->val.u32 = *((uint32_t*) args); break;
    case nsXPTType::T_BOOL   : dp->val.b   = *((uint32_t*) args); break;
    case nsXPTType::T_CHAR   : dp->val.c   = *((uint32_t*) args); break;
    case nsXPTType::T_WCHAR  : dp->val.wc  = *((int32_t*)  args); break;
    default:
      NS_ERROR("bad type");
      break;
    }
    ++regwords;
  }

  nsresult result = self->mOuter->CallMethod((uint16_t) methodIndex, info,
                                             paramBuffer);

  return result;
}