@@ -239,11 +239,13 @@ Encoder::Encode()
239239 }
240240 }
241241#endif
242+ #if 0 // TODO: michhol OOP JIT, understand this code
242243 for (int32 i = 0; i < m_pragmaInstrToRecordMap->Count(); i ++)
243244 {
244245 IR::PragmaInstr *inst = m_pragmaInstrToRecordMap->Item(i);
245246 inst->RecordThrowMap(iter, inst->m_offsetInBuffer);
246247 }
248+ #endif
247249
248250 JITTimeWorkItem * workItem = m_func->GetWorkItem ();
249251
@@ -271,33 +273,38 @@ Encoder::Encode()
271273
272274 TryCopyAndAddRelocRecordsForSwitchJumpTableEntries (m_encodeBuffer, codeSize, jumpTableListForSwitchStatement, totalJmpTableSizeInBytes);
273275
274- workItem->RecordNativeCodeSize (m_func, (DWORD)codeSize, pdataCount, xdataSize);
276+ EmitBufferAllocation * alloc = m_func->GetJITOutput ()->RecordNativeCodeSize (m_func, (DWORD)codeSize, pdataCount, xdataSize);
277+
278+ if (!alloc->inPrereservedRegion )
279+ {
280+ m_func->GetThreadContextInfo ()->ResetIsAllJITCodeInPreReservedRegion ();
281+ }
275282
276283 this ->m_bailoutRecordMap ->MapAddress ([=](int index, LazyBailOutRecord* record)
277284 {
278285 this ->m_encoderMD .AddLabelReloc ((BYTE*)&record->instructionPointer );
279286 });
280287
281288 // Relocs
282- m_encoderMD.ApplyRelocs ((size_t ) workItem->GetCodeAddress ());
283-
284- workItem->RecordNativeCode (m_func, m_encodeBuffer);
289+ m_encoderMD.ApplyRelocs ((size_t )alloc->allocation ->address );
285290
286- m_func->GetScriptContext ()->GetThreadContext ()-> SetValidCallTargetForCFG ((PVOID) workItem-> GetCodeAddress () );
291+ m_func->GetJITOutput ()->RecordNativeCode (m_func, m_encodeBuffer, alloc );
287292
288293#ifdef _M_X64
289294 m_func->m_prologEncoder .FinalizeUnwindInfo ();
290- workItem->RecordUnwindInfo (0 , m_func->m_prologEncoder .GetUnwindInfo (), m_func->m_prologEncoder .SizeOfUnwindInfo ());
295+ m_func->GetJITOutput ()->RecordUnwindInfo (
296+ 0 ,
297+ m_func->m_prologEncoder .GetUnwindInfo (),
298+ m_func->m_prologEncoder .SizeOfUnwindInfo (),
299+ alloc->allocation ->xdata .address ,
300+ m_func->GetThreadContextInfo ()->GetProcessHandle ());
291301#elif _M_ARM
292302 m_func->m_unwindInfo .EmitUnwindInfo (workItem);
293303 workItem->SetCodeAddress (workItem->GetCodeAddress () | 0x1 ); // Set thumb mode
294304#endif
295305
296- Js::EntryPointInfo* entryPointInfo = this -> m_func -> m_workItem -> GetEntryPoint () ;
306+ Js::EntryPointInfo* entryPointInfo = nullptr ;
297307 const bool isSimpleJit = m_func->IsSimpleJit ();
298- Assert (
299- isSimpleJit ||
300- entryPointInfo->GetJitTransferData () != nullptr && !entryPointInfo->GetJitTransferData ()->GetIsReady ());
301308
302309 if (this ->m_inlineeFrameMap ->Count () > 0 &&
303310 !(this ->m_inlineeFrameMap ->Count () == 1 && this ->m_inlineeFrameMap ->Item (0 ).record == nullptr ))
@@ -477,13 +484,7 @@ Encoder::Encode()
477484
478485 entryPointInfo->RecordCtorCacheGuards (ctorCachesTransferRecord, ctorCachesTransferSize);
479486 }
480-
481- if (!isSimpleJit)
482- {
483- entryPointInfo->GetJitTransferData ()->SetIsReady ();
484- }
485-
486- workItem->FinalizeNativeCode (m_func);
487+ m_func->GetJITOutput ()->FinalizeNativeCode (m_func, alloc);
487488
488489 END_CODEGEN_PHASE (m_func, Js::EmitterPhase);
489490
@@ -503,9 +504,9 @@ Encoder::Encode()
503504 __analysis_assume (m_instrNumber < instrCount);
504505 instr->DumpGlobOptInstrString ();
505506#ifdef _WIN64
506- Output::Print (L" %12IX " , m_offsetBuffer[m_instrNumber++] + (BYTE *)workItem ->GetCodeAddress ());
507+ Output::Print (L" %12IX " , m_offsetBuffer[m_instrNumber++] + (BYTE *)m_func-> GetJITOutput () ->GetCodeAddress ());
507508#else
508- Output::Print (L" %8IX " , m_offsetBuffer[m_instrNumber++] + (BYTE *)workItem ->GetCodeAddress ());
509+ Output::Print (L" %8IX " , m_offsetBuffer[m_instrNumber++] + (BYTE *)m_func-> GetJITOutput () ->GetCodeAddress ());
509510#endif
510511 instr->Dump ();
511512 } NEXT_INSTR_IN_FUNC;
@@ -518,7 +519,7 @@ Encoder::Encode()
518519 {
519520 workItem->DumpNativeOffsetMaps ();
520521 workItem->DumpNativeThrowSpanSequence ();
521- this ->DumpInlineeFrameMap (workItem ->GetCodeAddress ());
522+ this ->DumpInlineeFrameMap (m_func-> GetJITOutput () ->GetCodeAddress ());
522523 Output::Flush ();
523524 }
524525#endif
0 commit comments