void getFunctionEntrypoint(JSGlobalData& globalData, CodeSpecializationKind kind, JITCode& jitCode, MacroAssemblerCodePtr& arityCheck) { if (!globalData.canUseJIT()) { if (kind == CodeForCall) { jitCode = JITCode::HostFunction(MacroAssemblerCodeRef::createSelfManagedCodeRef(MacroAssemblerCodePtr(bitwise_cast<void*>(&llint_function_for_call_prologue)))); arityCheck = MacroAssemblerCodePtr(bitwise_cast<void*>(&llint_function_for_call_arity_check)); return; } ASSERT(kind == CodeForConstruct); jitCode = JITCode::HostFunction(MacroAssemblerCodeRef::createSelfManagedCodeRef(MacroAssemblerCodePtr(bitwise_cast<void*>(&llint_function_for_construct_prologue)))); arityCheck = MacroAssemblerCodePtr(bitwise_cast<void*>(&llint_function_for_construct_arity_check)); return; } if (kind == CodeForCall) { jitCode = JITCode(globalData.getCTIStub(functionForCallEntryThunkGenerator), JITCode::InterpreterThunk); arityCheck = globalData.getCTIStub(functionForCallArityCheckThunkGenerator).code(); return; } ASSERT(kind == CodeForConstruct); jitCode = JITCode(globalData.getCTIStub(functionForConstructEntryThunkGenerator), JITCode::InterpreterThunk); arityCheck = globalData.getCTIStub(functionForConstructArityCheckThunkGenerator).code(); }
JSObject* FunctionExecutable::compileForCallInternal(ExecState* exec, ScopeChainNode* scopeChainNode, JITCode::JITType jitType) { #if !ENABLE(JIT) UNUSED_PARAM(jitType); #endif ASSERT((jitType == JITCode::bottomTierJIT()) == !m_codeBlockForCall); JSObject* exception; OwnPtr<FunctionCodeBlock> newCodeBlock = produceCodeBlockFor(exec, scopeChainNode, !!m_codeBlockForCall ? OptimizingCompilation : FirstCompilation, CodeForCall, exception); if (!newCodeBlock) return exception; newCodeBlock->setAlternative(static_pointer_cast<CodeBlock>(m_codeBlockForCall.release())); m_codeBlockForCall = newCodeBlock.release(); m_numParametersForCall = m_codeBlockForCall->m_numParameters; ASSERT(m_numParametersForCall); m_numCapturedVariables = m_codeBlockForCall->m_numCapturedVars; m_symbolTable = m_codeBlockForCall->sharedSymbolTable(); #if ENABLE(JIT) JSGlobalData* globalData = scopeChainNode->globalData; if (globalData->canUseJIT()) { bool dfgCompiled = false; if (jitType == JITCode::DFGJIT) dfgCompiled = DFG::tryCompileFunction(exec, m_codeBlockForCall.get(), m_jitCodeForCall, m_jitCodeForCallWithArityCheck); if (dfgCompiled) { if (m_codeBlockForCall->alternative()) m_codeBlockForCall->alternative()->unlinkIncomingCalls(); } else { if (m_codeBlockForCall->alternative()) { m_codeBlockForCall = static_pointer_cast<FunctionCodeBlock>(m_codeBlockForCall->releaseAlternative()); m_symbolTable = m_codeBlockForCall->sharedSymbolTable(); return 0; } m_jitCodeForCall = JIT::compile(globalData, m_codeBlockForCall.get(), &m_jitCodeForCallWithArityCheck); } #if !ENABLE(OPCODE_SAMPLING) if (!BytecodeGenerator::dumpsGeneratedCode()) m_codeBlockForCall->discardBytecode(); #endif m_codeBlockForCall->setJITCode(m_jitCodeForCall, m_jitCodeForCallWithArityCheck); } #endif #if ENABLE(JIT) #if ENABLE(INTERPRETER) if (!m_jitCodeForCall) Heap::heap(this)->reportExtraMemoryCost(sizeof(*m_codeBlockForCall)); else #endif Heap::heap(this)->reportExtraMemoryCost(sizeof(*m_codeBlockForCall) + m_jitCodeForCall.size()); #else Heap::heap(this)->reportExtraMemoryCost(sizeof(*m_codeBlockForCall)); #endif return 0; }
void getProgramEntrypoint(JSGlobalData& globalData, JITCode& jitCode) { if (!globalData.canUseJIT()) { jitCode = JITCode::HostFunction(MacroAssemblerCodeRef::createSelfManagedCodeRef(MacroAssemblerCodePtr(bitwise_cast<void*>(&llint_program_prologue)))); return; } jitCode = JITCode(globalData.getCTIStub(programEntryThunkGenerator), JITCode::InterpreterThunk); }
static bool runWithScripts(GlobalObject* globalObject, const Vector<Script>& scripts, bool dump) { UString script; UString fileName; Vector<char> scriptBuffer; if (dump) BytecodeGenerator::setDumpsGeneratedCode(true); JSGlobalData* globalData = globalObject->globalData(); #if ENABLE(SAMPLING_FLAGS) SamplingFlags::start(); #endif bool success = true; for (size_t i = 0; i < scripts.size(); i++) { if (scripts[i].isFile) { fileName = scripts[i].argument; if (!fillBufferWithContentsOfFile(fileName, scriptBuffer)) return false; // fail early so we can catch missing files script = scriptBuffer.data(); } else { script = scripts[i].argument; fileName = "[Command Line]"; } globalData->startSampling(); Completion completion = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(script, fileName)); success = success && completion.complType() != Throw; if (dump) { if (completion.complType() == Throw) printf("Exception: %s\n", completion.value().toString(globalObject->globalExec()).ascii()); else printf("End: %s\n", completion.value().toString(globalObject->globalExec()).ascii()); } globalData->stopSampling(); globalObject->globalExec()->clearException(); } #if ENABLE(SAMPLING_FLAGS) SamplingFlags::stop(); #endif globalData->dumpSampleData(globalObject->globalExec()); #if ENABLE(SAMPLING_COUNTERS) AbstractSamplingCounter::dump(); #endif return success; }
DynamicGlobalObjectScope::DynamicGlobalObjectScope(JSGlobalData& globalData, JSGlobalObject* dynamicGlobalObject) : m_dynamicGlobalObjectSlot(globalData.dynamicGlobalObject) , m_savedDynamicGlobalObject(m_dynamicGlobalObjectSlot) { if (!m_dynamicGlobalObjectSlot) { #if ENABLE(ASSEMBLER) if (ExecutableAllocator::underMemoryPressure()) globalData.recompileAllJSFunctions(); #endif m_dynamicGlobalObjectSlot = dynamicGlobalObject; // Reset the date cache between JS invocations to force the VM // to observe time zone changes. globalData.resetDateCache(); } }
void JSFloat64Array::finishCreation(JSGlobalData& globalData) { Base::finishCreation(globalData); TypedArrayDescriptor descriptor(&JSFloat64Array::s_info, OBJECT_OFFSETOF(JSFloat64Array, m_storage), OBJECT_OFFSETOF(JSFloat64Array, m_storageLength)); globalData.registerTypedArrayDescriptor(impl(), descriptor); m_storage = impl()->data(); m_storageLength = impl()->length(); ASSERT(inherits(&s_info)); }
AbstractPC::AbstractPC(JSGlobalData& globalData, ExecState* exec) { UNUSED_PARAM(globalData); UNUSED_PARAM(exec); #if ENABLE(JIT) if (globalData.canUseJIT()) { m_pointer = exec->returnPC().value(); m_mode = JIT; return; } #endif }
void releaseExecutableMemory(JSGlobalData& globalData) { globalData.releaseExecutableMemory(); }