Esempio n. 1
0
    void GenerateCode(JSFunctionCode funcCode, ILGen.BaseILGenerator ilGen, bool enableSpeculation)
    {
      var cgInfo = new CodeGenerationInfo(this, funcCode, ilGen);

      ///This is where we are giong to make different decistions aboud different Phases and passes

      if (JSRuntime.Instance.Configuration.EnableLightCompiler)
      {
        CodeGeneratorLight.Execute(cgInfo);
      }
      else
      {
        if (JSRuntime.Instance.Configuration.EnableFunctionInlining)
          FunctionInliner.Execute(cgInfo);
        if (EnableTypeInference)
          TypeInferer.Execute(cgInfo);

        if (enableSpeculation && !IsBlackListed)
        {
          CodeGen.CodeGeneratorWithInlineCache.Execute(this);
          try {
              CodeGeneratorWithSpecialization.Execute(cgInfo);
          }
          catch(JSDeoptFailedException e) {
              IsBlackListed = true;
	            ilGen = CreateStub(funcCode, false);
	            cgInfo = new CodeGenerationInfo(this, funcCode, ilGen);
              funcCode.Profiler = null;
              if (EnableTypeInference)
                  TypeInferer.Execute(cgInfo);
	      CodeGenerator.Execute(cgInfo);
          }
        }
        else
        {
          if (this.EnableProfiling && !IsBlackListed)
            CodeGeneratorWithProfiling.Execute(cgInfo);
          else
            CodeGenerator.Execute(cgInfo);
        }
        var method = ilGen.EndJittedMethod(this, funcCode);
        if (enableSpeculation && !IsBlackListed)
          funcCode.SpecializedMethod = method;
        else
          funcCode.GenericMethod = method;
      }
    }