当前位置: 首页>>代码示例>>C++>>正文


C++ OwningPtr::stop方法代码示例

本文整理汇总了C++中OwningPtr::stop方法的典型用法代码示例。如果您正苦于以下问题:C++ OwningPtr::stop方法的具体用法?C++ OwningPtr::stop怎么用?C++ OwningPtr::stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OwningPtr的用法示例。


在下文中一共展示了OwningPtr::stop方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main


//.........这里部分代码省略.........
        Function *Fn = &*I;
        if (Fn != EntryFn && !Fn->isDeclaration())
          EE->getPointerToFunction(Fn);
      }
    }

    // Trigger compilation separately so code regions that need to be
    // invalidated will be known.
    (void)EE->getPointerToFunction(EntryFn);
    // Clear instruction cache before code will be executed.
    if (RTDyldMM)
      static_cast<SectionMemoryManager*>(RTDyldMM)->invalidateInstructionCache();

    // Run main.
    Result = EE->runFunctionAsMain(EntryFn, InputArgv, envp);

    // Run static destructors.
    EE->runStaticConstructorsDestructors(true);

    // If the program didn't call exit explicitly, we should call it now.
    // This ensures that any atexit handlers get called correctly.
    if (Function *ExitF = dyn_cast<Function>(Exit)) {
      std::vector<GenericValue> Args;
      GenericValue ResultGV;
      ResultGV.IntVal = APInt(32, Result);
      Args.push_back(ResultGV);
      EE->runFunction(ExitF, Args);
      errs() << "ERROR: exit(" << Result << ") returned!\n";
      abort();
    } else {
      errs() << "ERROR: exit defined with wrong prototype!\n";
      abort();
    }
  } else {
    // else == "if (RemoteMCJIT)"

    // Remote target MCJIT doesn't (yet) support static constructors. No reason
    // it couldn't. This is a limitation of the LLI implemantation, not the
    // MCJIT itself. FIXME.
    //
    RemoteMemoryManager *MM = static_cast<RemoteMemoryManager*>(RTDyldMM);
    // Everything is prepared now, so lay out our program for the target
    // address space, assign the section addresses to resolve any relocations,
    // and send it to the target.

    OwningPtr<RemoteTarget> Target;
    if (!ChildExecPath.empty()) { // Remote execution on a child process
      if (!RemoteTarget::hostSupportsExternalRemoteTarget()) {
        errs() << "Warning: host does not support external remote targets.\n"
               << "  Defaulting to simulated remote execution\n";
        Target.reset(RemoteTarget::createRemoteTarget());
      } else {
        if (!sys::fs::can_execute(ChildExecPath)) {
          errs() << "Unable to find usable child executable: '" << ChildExecPath
                 << "'\n";
          return -1;
        }
        Target.reset(RemoteTarget::createExternalRemoteTarget(ChildExecPath));
      }
    } else {
      // No child process name provided, use simulated remote execution.
      Target.reset(RemoteTarget::createRemoteTarget());
    }

    // Give the memory manager a pointer to our remote target interface object.
    MM->setRemoteTarget(Target.get());

    // Create the remote target.
    if (!Target->create()) {
      errs() << "ERROR: " << Target->getErrorMsg() << "\n";
      return EXIT_FAILURE;
    }

    // Since we're executing in a (at least simulated) remote address space,
    // we can't use the ExecutionEngine::runFunctionAsMain(). We have to
    // grab the function address directly here and tell the remote target
    // to execute the function.
    //
    // Our memory manager will map generated code into the remote address
    // space as it is loaded and copy the bits over during the finalizeMemory
    // operation.
    //
    // FIXME: argv and envp handling.
    uint64_t Entry = EE->getFunctionAddress(EntryFn->getName().str());

    DEBUG(dbgs() << "Executing '" << EntryFn->getName() << "' at 0x"
                 << format("%llx", Entry) << "\n");

    if (!Target->executeCode(Entry, Result))
      errs() << "ERROR: " << Target->getErrorMsg() << "\n";

    // Like static constructors, the remote target MCJIT support doesn't handle
    // this yet. It could. FIXME.

    // Stop the remote target
    Target->stop();
  }

  return Result;
}
开发者ID:big-tool-brewery,项目名称:llvm,代码行数:101,代码来源:lli.cpp


注:本文中的OwningPtr::stop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。