Skip to content

Commit 4cc856b

Browse files
committed
fix for Guard Transfer in OOP JIT
Guard transfer is going through IDL/RPC in oop jit
1 parent 4b8a9e4 commit 4cc856b

File tree

2 files changed

+45
-59
lines changed

2 files changed

+45
-59
lines changed

lib/Backend/Encoder.cpp

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -427,61 +427,64 @@ Encoder::Encode()
427427
// point to register each guard for invalidation.
428428
if (this->m_func->propertyGuardsByPropertyId != nullptr)
429429
{
430-
Assert(!isSimpleJit);
430+
if (!this->m_func->IsOOPJIT())
431+
{
432+
Assert(!isSimpleJit);
431433

432-
AssertMsg(!(PHASE_OFF(Js::ObjTypeSpecPhase, this->m_func) && PHASE_OFF(Js::FixedMethodsPhase, this->m_func)),
433-
"Why do we have type guards if we don't do object type spec or fixed methods?");
434+
AssertMsg(!(PHASE_OFF(Js::ObjTypeSpecPhase, this->m_func) && PHASE_OFF(Js::FixedMethodsPhase, this->m_func)),
435+
"Why do we have type guards if we don't do object type spec or fixed methods?");
434436

435-
int propertyCount = this->m_func->propertyGuardsByPropertyId->Count();
436-
Assert(propertyCount > 0);
437+
int propertyCount = this->m_func->propertyGuardsByPropertyId->Count();
438+
Assert(propertyCount > 0);
437439

438440
#if DBG
439-
int totalGuardCount = (this->m_func->singleTypeGuards != nullptr ? this->m_func->singleTypeGuards->Count() : 0)
440-
+ (this->m_func->equivalentTypeGuards != nullptr ? this->m_func->equivalentTypeGuards->Count() : 0);
441-
Assert(totalGuardCount > 0);
442-
Assert(totalGuardCount == this->m_func->indexedPropertyGuardCount);
441+
int totalGuardCount = (this->m_func->singleTypeGuards != nullptr ? this->m_func->singleTypeGuards->Count() : 0)
442+
+ (this->m_func->equivalentTypeGuards != nullptr ? this->m_func->equivalentTypeGuards->Count() : 0);
443+
Assert(totalGuardCount > 0);
444+
Assert(totalGuardCount == this->m_func->indexedPropertyGuardCount);
443445
#endif
444446

445-
int guardSlotCount = 0;
446-
this->m_func->propertyGuardsByPropertyId->Map([&guardSlotCount](Js::PropertyId propertyId, Func::IndexedPropertyGuardSet* set) -> void
447-
{
448-
guardSlotCount += set->Count();
449-
});
447+
int guardSlotCount = 0;
448+
this->m_func->propertyGuardsByPropertyId->Map([&guardSlotCount](Js::PropertyId propertyId, Func::IndexedPropertyGuardSet* set) -> void
449+
{
450+
guardSlotCount += set->Count();
451+
});
450452

451-
size_t typeGuardTransferSize = // Reserve enough room for:
452-
propertyCount * sizeof(Js::TypeGuardTransferEntry) + // each propertyId,
453-
propertyCount * sizeof(Js::JitIndexedPropertyGuard*) + // terminating nullptr guard for each propertyId,
454-
guardSlotCount * sizeof(Js::JitIndexedPropertyGuard*); // a pointer for each guard we counted above.
453+
size_t typeGuardTransferSize = // Reserve enough room for:
454+
propertyCount * sizeof(Js::TypeGuardTransferEntry) + // each propertyId,
455+
propertyCount * sizeof(Js::JitIndexedPropertyGuard*) + // terminating nullptr guard for each propertyId,
456+
guardSlotCount * sizeof(Js::JitIndexedPropertyGuard*); // a pointer for each guard we counted above.
455457

456-
// The extra room for sizeof(Js::TypePropertyGuardEntry) allocated by HeapNewPlus will be used for the terminating invalid propertyId.
457-
// Review (jedmiad): Skip zeroing? This is heap allocated so there shouldn't be any false recycler references.
458-
Js::TypeGuardTransferEntry* typeGuardTransferRecord = NativeCodeDataNewPlusZ(typeGuardTransferSize, m_func->GetNativeCodeDataAllocator(), Js::TypeGuardTransferEntry);
458+
// The extra room for sizeof(Js::TypePropertyGuardEntry) allocated by HeapNewPlus will be used for the terminating invalid propertyId.
459+
// Review (jedmiad): Skip zeroing? This is heap allocated so there shouldn't be any false recycler references.
460+
Js::TypeGuardTransferEntry* typeGuardTransferRecord = NativeCodeDataNewPlusZ(typeGuardTransferSize, m_func->GetNativeCodeDataAllocator(), Js::TypeGuardTransferEntry);
459461

460-
Func* func = this->m_func;
462+
Func* func = this->m_func;
461463

462-
Js::TypeGuardTransferEntry* dstEntry = typeGuardTransferRecord;
463-
this->m_func->propertyGuardsByPropertyId->Map([func, &dstEntry](Js::PropertyId propertyId, Func::IndexedPropertyGuardSet* srcSet) -> void
464-
{
465-
dstEntry->propertyId = propertyId;
464+
Js::TypeGuardTransferEntry* dstEntry = typeGuardTransferRecord;
465+
this->m_func->propertyGuardsByPropertyId->Map([func, &dstEntry](Js::PropertyId propertyId, Func::IndexedPropertyGuardSet* srcSet) -> void
466+
{
467+
dstEntry->propertyId = propertyId;
466468

467-
int guardIndex = 0;
469+
int guardIndex = 0;
468470

469-
srcSet->Map([dstEntry, &guardIndex](Js::JitIndexedPropertyGuard* guard) -> void
470-
{
471-
dstEntry->guards[guardIndex++] = guard;
472-
});
471+
srcSet->Map([dstEntry, &guardIndex](Js::JitIndexedPropertyGuard* guard) -> void
472+
{
473+
dstEntry->guards[guardIndex++] = guard;
474+
});
473475

474-
dstEntry->guards[guardIndex++] = nullptr;
475-
dstEntry = reinterpret_cast<Js::TypeGuardTransferEntry*>(&dstEntry->guards[guardIndex]);
476-
});
477-
dstEntry->propertyId = Js::Constants::NoProperty;
478-
dstEntry++;
476+
dstEntry->guards[guardIndex++] = nullptr;
477+
dstEntry = reinterpret_cast<Js::TypeGuardTransferEntry*>(&dstEntry->guards[guardIndex]);
478+
});
479+
dstEntry->propertyId = Js::Constants::NoProperty;
480+
dstEntry++;
479481

480-
Assert(reinterpret_cast<char*>(dstEntry) <= reinterpret_cast<char*>(typeGuardTransferRecord) + typeGuardTransferSize + sizeof(Js::TypeGuardTransferEntry));
482+
Assert(reinterpret_cast<char*>(dstEntry) <= reinterpret_cast<char*>(typeGuardTransferRecord) + typeGuardTransferSize + sizeof(Js::TypeGuardTransferEntry));
481483

482-
//TODO: OOP JIT need a way to pass back the jitTransferData and in main process it need to amend the reference to typeGuardTransferRecord
483-
// or just have a allocation offset to locate the typeGuardTransferRecord
484-
//entryPointInfo->RecordTypeGuards(this->m_func->indexedPropertyGuardCount, typeGuardTransferRecord, typeGuardTransferSize);
484+
//TODO: OOP JIT need a way to pass back the jitTransferData and in main process it need to amend the reference to typeGuardTransferRecord
485+
// or just have a allocation offset to locate the typeGuardTransferRecord
486+
entryPointInfo->RecordTypeGuards(this->m_func->indexedPropertyGuardCount, typeGuardTransferRecord, typeGuardTransferSize);
487+
}
485488
}
486489

487490
// Save all constructor caches on the JIT transfer data in a map keyed by property ID. We will use this map when installing the entry

lib/Runtime/Base/FunctionBody.h

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -136,25 +136,8 @@ namespace Js
136136

137137
void Fixup(NativeCodeData::DataChunk* chunkList)
138138
{
139-
NativeCodeData::DataChunk* chunk = NativeCodeData::GetDataChunk(this);
140-
unsigned int pointerCount = chunk->len / sizeof(void*);
141-
void** pointers = (void**)chunk;
142-
bool isPropertyId = true;
143-
for (unsigned int i = 0; i < pointerCount; i++)
144-
{
145-
if (isPropertyId)
146-
{
147-
continue;
148-
}
149-
150-
if (pointers[i] == nullptr) // end of one entry
151-
{
152-
isPropertyId = true;
153-
continue;
154-
}
155-
156-
NativeCodeData::AddFixupEntry(pointers[i], &pointers[i], pointers, chunkList);
157-
}
139+
// OOP JIT does not use this data structure to transfer the Guards
140+
Assert(false);
158141
}
159142
};
160143

0 commit comments

Comments
 (0)