-
Notifications
You must be signed in to change notification settings - Fork 564
Cosmetic change to distinguish stack/heap writes and collect stats. #2794
Conversation
@@ -63,7 +63,9 @@ internal class BlockAdapterToFunctionGenerator(val objCExportCodeGenerator: ObjC | |||
) { | |||
val blockPtr = bitcast(pointerType(blockLiteralType), param(0)) | |||
val slot = structGep(blockPtr, 1) | |||
storeAny(kNullObjHeaderPtr, slot) // TODO: can dispose_helper write to the block? | |||
// Although value is actually on the stack, it's not in normal slot area, so we cannot handle it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although value is actually on the stack
AFAIK this is not correct.
@@ -281,9 +281,13 @@ internal class FunctionGenerationContext(val function: LLVMValueRef, | |||
LLVMBuildStore(builder, value, ptr) | |||
} | |||
|
|||
fun storeAny(value: LLVMValueRef, ptr: LLVMValueRef) { | |||
fun storeRef(value: LLVMValueRef, ptr: LLVMValueRef, onStack: Boolean) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I see, most of usages pass boolean literal for onStack
parameter.
Why not add then storeHeapRef
and storeStackRef
to make the code more clear?
@@ -84,7 +86,7 @@ internal class BlockAdapterToFunctionGenerator(val objCExportCodeGenerator: ObjC | |||
// Kotlin reference was `memcpy`ed from src to dst, "revert" this: | |||
storeRefUnsafe(kNullObjHeaderPtr, dstSlot) | |||
// and copy properly: | |||
storeAny(loadSlot(srcSlot, isVar = false), dstSlot) | |||
storeRef(loadSlot(srcSlot, isVar = false), dstSlot, true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a stack slot? I'm not sure it is even located on the stack.
@@ -191,7 +193,9 @@ internal class BlockAdapterToFunctionGenerator(val objCExportCodeGenerator: ObjC | |||
val slot = structGep(blockOnStack, 1) | |||
|
|||
listOf(bitcast(int8TypePtr, isa), flags, reserved, invoke, descriptor).forEachIndexed { index, value -> | |||
storeAny(value, structGep(blockOnStackBase, index)) | |||
// Although value is actually on the stack, it's not in normal slot area, so we cannot handle it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think any of this values is an object reference.
runtime/src/main/cpp/Memory.cpp
Outdated
@@ -606,13 +612,13 @@ template <bool Atomic> | |||
inline void IncrementRC(ContainerHeader* container) { | |||
container->incRefCount<Atomic>(); | |||
container->setColorUnlessGreen(CONTAINER_TAG_GC_BLACK); | |||
UPDATE_ADDREF_STAT(memoryState, container, Atomic); | |||
UPDATE_ADDREF_STAT(memoryState, container, Atomic, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is passing 0
correct?
Stats from ring benchmark execution, just for records:
|
runtime/src/main/cpp/Memory.cpp
Outdated
@@ -883,23 +883,34 @@ void CollectWhite(MemoryState* state, ContainerHeader* start) { | |||
} | |||
#endif | |||
|
|||
ALWAYS_INLINE inline void addRef(ContainerHeader* header) { | |||
inline bool needAtomicAccess(ContainerHeader* container) { | |||
return container->shareable() || isAggregatingFrozenContainer(container); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does || isAggregatingFrozenContainer(container)
have any effect?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, debugging remnant.
No description provided.