MCPcopy Create free account
hub / github.com/anjo76/angelscript / JITCompile

Method JITCompile

sdk/angelscript/source/as_scriptfunction.cpp:1589–1650  ·  view source on GitHub ↗

internal

Source from the content-addressed store, hash-verified

1587
1588// internal
1589void asCScriptFunction::JITCompile()
1590{
1591 if( funcType != asFUNC_SCRIPT )
1592 return;
1593
1594 asASSERT( scriptData );
1595
1596 if( !engine->jitCompiler )
1597 return;
1598
1599 // Make sure the function has been compiled with JitEntry instructions
1600 // For functions that has JitEntry this will be a quick test
1601 asUINT length;
1602 asDWORD *byteCode = GetByteCode(&length);
1603 asDWORD *end = byteCode + length;
1604 bool foundJitEntry = false;
1605 while( byteCode < end )
1606 {
1607 // Determine the instruction
1608 asEBCInstr op = asEBCInstr(*(asBYTE*)byteCode);
1609 if( op == asBC_JitEntry )
1610 {
1611 foundJitEntry = true;
1612 break;
1613 }
1614
1615 // Move to next instruction
1616 byteCode += asBCTypeSize[asBCInfo[op].type];
1617 }
1618
1619 if( !foundJitEntry )
1620 {
1621 asCString msg;
1622 msg.Format(TXT_NO_JIT_IN_FUNC_s, GetDeclaration());
1623 engine->WriteMessage("", 0, 0, asMSGTYPE_WARNING, msg.AddressOf());
1624 }
1625
1626 // Release the previous function, if any
1627 if( scriptData->jitFunction )
1628 {
1629 if (engine->ep.jitInterfaceVersion == 1)
1630 static_cast<asIJITCompiler*>(engine->jitCompiler)->ReleaseJITFunction(scriptData->jitFunction);
1631 else if (engine->ep.jitInterfaceVersion == 2)
1632 static_cast<asIJITCompilerV2*>(engine->jitCompiler)->CleanFunction(this, scriptData->jitFunction);
1633 scriptData->jitFunction = 0;
1634 }
1635
1636 if (engine->ep.jitInterfaceVersion == 1)
1637 {
1638 // Compile for native system. If the JIT compiler decides to compile the function it
1639 // must do so now, as it is not allowed to do it later.
1640 int r = static_cast<asIJITCompiler*>(engine->jitCompiler)->CompileFunction(this, &scriptData->jitFunction);
1641 if (r < 0)
1642 asASSERT(scriptData->jitFunction == 0);
1643 }
1644 else if (engine->ep.jitInterfaceVersion == 2)
1645 {
1646 // Notify the JIT compiler about the new function, it may do JIT compilation now, or later, or not at all.

Callers

nothing calls this directly

Calls 8

WriteMessageMethod · 0.80
ReleaseJITFunctionMethod · 0.80
CleanFunctionMethod · 0.80
NewFunctionMethod · 0.80
asEBCInstrEnum · 0.50
FormatMethod · 0.45
AddressOfMethod · 0.45
CompileFunctionMethod · 0.45

Tested by

no test coverage detected