本文整理汇总了C++中CodeBlock类的典型用法代码示例。如果您正苦于以下问题:C++ CodeBlock类的具体用法?C++ CodeBlock怎么用?C++ CodeBlock使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CodeBlock类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
CodeBlock * CodeBlockManager::buildCodeBlockAt(MemlocData * growFrom)
{
MemlocData * current_start = growFrom;
MemlocData * current_start_prev = growFrom;
MemlocData * current_end = growFrom;
MemlocData * current_end_next = growFrom;
if (!dynamic_cast<Instruction *>(growFrom))
return NULL;
// while we're not at the beginning of the memory segment,
// and while we don't have any code xrefs to this location,
// we need to continue to loop
// We may break out of the loop if the insn before has an xref from that is code
while ((current_start_prev = dynamic_cast<Instruction *>(current_start->getPreviousContiguous())) &&
!hasNonLinkCodeXref(current_start->begin_xref_to(), current_start->end_xref_to()) &&
!hasNonLinkCodeXref(current_start_prev->begin_xref_from(), current_start->begin_xref_from())
)
current_start = current_start_prev;
while ((current_end_next = dynamic_cast<Instruction *>(current_end->getNextContiguous())) &&
!hasNonLinkCodeXref(current_end_next->begin_xref_to(), current_end_next->end_xref_to()) &&
!hasNonLinkCodeXref(current_end->begin_xref_from(), current_end->begin_xref_from())
)
current_end = current_end_next;
CodeBlock * cb = new CodeBlock(m_trace, current_start->get_addr(), current_end->get_addr());
m_blocks[cb->getStart()] = cb;
return cb;
}
示例2: dataLog
void CodeBlockSet::deleteUnmarkedAndUnreferenced()
{
// This needs to be a fixpoint because code blocks that are unmarked may
// refer to each other. For example, a DFG code block that is owned by
// the GC may refer to an FTL for-entry code block that is also owned by
// the GC.
Vector<CodeBlock*, 16> toRemove;
if (verbose)
dataLog("Fixpointing over unmarked, set size = ", m_set.size(), "...\n");
for (;;) {
HashSet<CodeBlock*>::iterator iter = m_set.begin();
HashSet<CodeBlock*>::iterator end = m_set.end();
for (; iter != end; ++iter) {
CodeBlock* codeBlock = *iter;
if (!codeBlock->hasOneRef())
continue;
if (codeBlock->m_mayBeExecuting)
continue;
codeBlock->deref();
toRemove.append(codeBlock);
}
if (verbose)
dataLog(" Removing ", toRemove.size(), " blocks.\n");
if (toRemove.isEmpty())
break;
for (unsigned i = toRemove.size(); i--;)
m_set.remove(toRemove[i]);
toRemove.resize(0);
}
}
示例3: operationCreateClonedArgumentsDuringExit
JSCell* JIT_OPERATION operationCreateClonedArgumentsDuringExit(ExecState* exec, InlineCallFrame* inlineCallFrame, JSFunction* callee, int32_t argumentCount)
{
VM& vm = exec->vm();
NativeCallFrameTracer target(&vm, exec);
DeferGCForAWhile deferGC(vm.heap);
CodeBlock* codeBlock;
if (inlineCallFrame)
codeBlock = baselineCodeBlockForInlineCallFrame(inlineCallFrame);
else
codeBlock = exec->codeBlock();
unsigned length = argumentCount - 1;
ClonedArguments* result = ClonedArguments::createEmpty(
vm, codeBlock->globalObject()->outOfBandArgumentsStructure(), callee);
Register* arguments =
exec->registers() + (inlineCallFrame ? inlineCallFrame->stackOffset : 0) +
CallFrame::argumentOffset(0);
for (unsigned i = length; i--;)
result->putDirectIndex(exec, i, arguments[i].jsValue());
result->putDirect(vm, vm.propertyNames->length, jsNumber(length));
return result;
}
示例4: computeKills
void BytecodeLivenessAnalysis::computeKills(BytecodeKills& result)
{
FastBitVector out;
CodeBlock* codeBlock = m_graph.codeBlock();
result.m_codeBlock = codeBlock;
result.m_killSets = std::make_unique<BytecodeKills::KillSet[]>(codeBlock->instructions().size());
for (std::unique_ptr<BytecodeBasicBlock>& block : m_graph.basicBlocksInReverseOrder()) {
if (block->isEntryBlock() || block->isExitBlock())
continue;
out = block->out();
for (unsigned i = block->offsets().size(); i--;) {
unsigned bytecodeOffset = block->offsets()[i];
stepOverInstruction(
m_graph, bytecodeOffset, out,
[&] (unsigned index) {
// This is for uses.
if (out.get(index))
return;
result.m_killSets[bytecodeOffset].add(index);
out.set(index);
},
[&] (unsigned index) {
// This is for defs.
out.clear(index);
});
}
}
}
示例5: align
void align(CodeBlock& cb, Alignment alignment, AlignContext context,
bool fixups /* = false */) {
vixl::MacroAssembler a { cb };
switch (alignment) {
case Alignment::CacheLine:
case Alignment::CacheLineRoundUp:
case Alignment::JmpTarget:
break;
case Alignment::SmashCmpq:
case Alignment::SmashMovq:
case Alignment::SmashJmp:
// Smashable movs and jmps are two instructions plus inline 64-bit data,
// so they need to be 8-byte aligned.
if (!cb.isFrontierAligned(8)) a.Nop();
break;
case Alignment::SmashCall:
// Smashable call is 8 instructions plus inline 64-bit data, so it must
// be 8 byte aligned.
if (!cb.isFrontierAligned(8)) a.Nop();
break;
case Alignment::SmashJcc:
case Alignment::SmashJccAndJmp:
// Other smashable control flow instructions are three instructions plus
// inline 64-bit data, so it needs to be one instruction off from 8-byte
// alignment.
if (cb.isFrontierAligned(8)) a.Nop();
break;
}
}
示例6: fixupPCforExceptionIfNeeded
static void fixupPCforExceptionIfNeeded(ExecState* exec)
{
CodeBlock* codeBlock = exec->codeBlock();
ASSERT(!!codeBlock);
Instruction* pc = exec->currentVPC();
exec->setCurrentVPC(codeBlock->adjustPCIfAtCallSite(pc));
}
示例7: appendSourceToError
static void appendSourceToError(CallFrame* callFrame, ErrorInstance* exception, unsigned bytecodeOffset)
{
ErrorInstance::SourceAppender appender = exception->sourceAppender();
exception->clearSourceAppender();
RuntimeType type = exception->runtimeTypeForCause();
exception->clearRuntimeTypeForCause();
if (!callFrame->codeBlock()->hasExpressionInfo())
return;
int startOffset = 0;
int endOffset = 0;
int divotPoint = 0;
unsigned line = 0;
unsigned column = 0;
CodeBlock* codeBlock;
CodeOrigin codeOrigin = callFrame->codeOrigin();
if (codeOrigin && codeOrigin.inlineCallFrame)
codeBlock = baselineCodeBlockForInlineCallFrame(codeOrigin.inlineCallFrame);
else
codeBlock = callFrame->codeBlock();
codeBlock->expressionRangeForBytecodeOffset(bytecodeOffset, divotPoint, startOffset, endOffset, line, column);
int expressionStart = divotPoint - startOffset;
int expressionStop = divotPoint + endOffset;
StringView sourceString = codeBlock->source()->source();
if (!expressionStop || expressionStart > static_cast<int>(sourceString.length()))
return;
VM* vm = &callFrame->vm();
JSValue jsMessage = exception->getDirect(*vm, vm->propertyNames->message);
if (!jsMessage || !jsMessage.isString())
return;
String message = asString(jsMessage)->value(callFrame);
if (expressionStart < expressionStop)
message = appender(message, codeBlock->source()->getRange(expressionStart, expressionStop).toString(), type, ErrorInstance::FoundExactSource);
else {
// No range information, so give a few characters of context.
int dataLength = sourceString.length();
int start = expressionStart;
int stop = expressionStart;
// Get up to 20 characters of context to the left and right of the divot, clamping to the line.
// Then strip whitespace.
while (start > 0 && (expressionStart - start < 20) && sourceString[start - 1] != '\n')
start--;
while (start < (expressionStart - 1) && isStrWhiteSpace(sourceString[start]))
start++;
while (stop < dataLength && (stop - expressionStart < 20) && sourceString[stop] != '\n')
stop++;
while (stop > expressionStart && isStrWhiteSpace(sourceString[stop - 1]))
stop--;
message = appender(message, codeBlock->source()->getRange(start, stop).toString(), type, ErrorInstance::FoundApproximateSource);
}
exception->putDirect(*vm, vm->propertyNames->message, jsString(vm, message));
}
示例8: lexicalEnvironment
JSLexicalEnvironment* CallFrame::lexicalEnvironment() const
{
CodeBlock* codeBlock = this->codeBlock();
RELEASE_ASSERT(codeBlock->needsActivation());
VirtualRegister activationRegister = codeBlock->activationRegister();
return registers()[activationRegister.offset()].Register::lexicalEnvironment();
}
示例9: setActivation
void CallFrame::setActivation(JSLexicalEnvironment* lexicalEnvironment)
{
CodeBlock* codeBlock = this->codeBlock();
RELEASE_ASSERT(codeBlock->needsActivation());
VirtualRegister activationRegister = codeBlock->activationRegister();
registers()[activationRegister.offset()] = lexicalEnvironment;
}
示例10: relocateStubs
void relocateStubs(TransLoc& loc, TCA frozenStart, TCA frozenEnd,
RelocationInfo& rel, CodeCache::View cache,
CGMeta& fixups) {
auto const stubSize = svcreq::stub_size();
for (auto addr : fixups.reusedStubs) {
if (!loc.contains(addr)) continue;
always_assert(frozenStart <= addr);
CodeBlock dest;
dest.init(cache.frozen().frontier(), stubSize, "New Stub");
x64::relocate(rel, dest, addr, addr + stubSize, fixups, nullptr);
cache.frozen().skip(stubSize);
if (addr != frozenStart) {
rel.recordRange(frozenStart, addr, frozenStart, addr);
}
frozenStart = addr + stubSize;
}
if (frozenStart != frozenEnd) {
rel.recordRange(frozenStart, frozenEnd, frozenStart, frozenEnd);
}
x64::adjustForRelocation(rel);
x64::adjustMetaDataForRelocation(rel, nullptr, fixups);
x64::adjustCodeForRelocation(rel, fixups);
}
示例11: recordGdbTranslation
void recordGdbTranslation(SrcKey sk, const Func* srcFunc, const CodeBlock& cb,
const TCA start, const TCA end, bool exit,
bool inPrologue) {
assertx(cb.contains(start) && cb.contains(end));
if (start != end) {
assertOwnsCodeLock();
if (!RuntimeOption::EvalJitNoGdb) {
Debug::DebugInfo::Get()->recordTracelet(
Debug::TCRange(start, end, &cb == &code().cold()),
srcFunc,
srcFunc->unit() ? srcFunc->unit()->at(sk.offset()) : nullptr,
exit, inPrologue
);
}
if (RuntimeOption::EvalPerfPidMap) {
Debug::DebugInfo::Get()->recordPerfMap(
Debug::TCRange(start, end, &cb == &code().cold()),
sk,
srcFunc,
exit,
inPrologue
);
}
}
}
示例12: functionPrintByteCodeFor
static EncodedJSValue JSC_HOST_CALL functionPrintByteCodeFor(ExecState* exec)
{
CodeBlock* codeBlock = codeBlockFromArg(exec);
if (codeBlock)
codeBlock->dumpBytecode();
return JSValue::encode(jsUndefined());
}
示例13: emitCheckSurpriseFlagsEnter
void emitCheckSurpriseFlagsEnter(CodeBlock& mainCode, CodeBlock& stubsCode,
bool inTracelet, FixupMap& fixupMap,
Fixup fixup) {
Asm a { mainCode };
Asm astubs { stubsCode };
emitTestSurpriseFlags(a);
a. jnz (stubsCode.frontier());
astubs. movq (rVmFp, argNumToRegName[0]);
if (false) { // typecheck
const ActRec* ar = nullptr;
functionEnterHelper(ar);
}
emitCall(astubs, (TCA)&functionEnterHelper);
if (inTracelet) {
fixupMap.recordSyncPoint(stubsCode.frontier(),
fixup.m_pcOffset, fixup.m_spOffset);
} else {
// If we're being called while generating a func prologue, we
// have to record the fixup directly in the fixup map instead of
// going through the pending fixup path like normal.
fixupMap.recordFixup(stubsCode.frontier(), fixup);
}
astubs. jmp (mainCode.frontier());
}
示例14: adjustAndJumpToTarget
void adjustAndJumpToTarget(CCallHelpers& jit, const OSRExitBase& exit)
{
#if ENABLE(GGC)
jit.move(AssemblyHelpers::TrustedImmPtr(jit.codeBlock()->ownerExecutable()), GPRInfo::nonArgGPR0);
osrWriteBarrier(jit, GPRInfo::nonArgGPR0, GPRInfo::nonArgGPR1);
InlineCallFrameSet* inlineCallFrames = jit.codeBlock()->jitCode()->dfgCommon()->inlineCallFrames.get();
if (inlineCallFrames) {
for (InlineCallFrame* inlineCallFrame : *inlineCallFrames) {
ScriptExecutable* ownerExecutable = inlineCallFrame->executable.get();
jit.move(AssemblyHelpers::TrustedImmPtr(ownerExecutable), GPRInfo::nonArgGPR0);
osrWriteBarrier(jit, GPRInfo::nonArgGPR0, GPRInfo::nonArgGPR1);
}
}
#endif
if (exit.m_codeOrigin.inlineCallFrame)
jit.addPtr(AssemblyHelpers::TrustedImm32(exit.m_codeOrigin.inlineCallFrame->stackOffset * sizeof(EncodedJSValue)), GPRInfo::callFrameRegister);
CodeBlock* baselineCodeBlock = jit.baselineCodeBlockFor(exit.m_codeOrigin);
Vector<BytecodeAndMachineOffset>& decodedCodeMap = jit.decodedCodeMapFor(baselineCodeBlock);
BytecodeAndMachineOffset* mapping = binarySearch<BytecodeAndMachineOffset, unsigned>(decodedCodeMap, decodedCodeMap.size(), exit.m_codeOrigin.bytecodeIndex, BytecodeAndMachineOffset::getBytecodeIndex);
ASSERT(mapping);
ASSERT(mapping->m_bytecodeIndex == exit.m_codeOrigin.bytecodeIndex);
void* jumpTarget = baselineCodeBlock->jitCode()->executableAddressAtOffset(mapping->m_machineCodeOffset);
jit.addPtr(AssemblyHelpers::TrustedImm32(JIT::stackPointerOffsetFor(baselineCodeBlock) * sizeof(Register)), GPRInfo::callFrameRegister, AssemblyHelpers::stackPointerRegister);
jit.jitAssertTagsInPlace();
jit.move(AssemblyHelpers::TrustedImmPtr(jumpTarget), GPRInfo::regT2);
jit.jump(GPRInfo::regT2);
}
示例15: uncheckedActivation
JSValue CallFrame::uncheckedActivation() const
{
CodeBlock* codeBlock = this->codeBlock();
RELEASE_ASSERT(codeBlock->needsActivation());
VirtualRegister activationRegister = codeBlock->activationRegister();
return registers()[activationRegister.offset()].jsValue();
}