mirror of
https://github.com/corda/corda.git
synced 2025-01-03 19:54:13 +00:00
move bitmap helper functions to common.h; preserve callee-saved registers in vmInvoke()
This commit is contained in:
parent
201a658941
commit
3e1dbab0f0
18
src/common.h
18
src/common.h
@ -127,6 +127,24 @@ indexOf(unsigned word, unsigned bit)
|
||||
return (word * BitsPerWord) + bit;
|
||||
}
|
||||
|
||||
inline void
|
||||
markBit(uintptr_t* map, unsigned i)
|
||||
{
|
||||
map[wordOf(i)] |= static_cast<uintptr_t>(1) << bitOf(i);
|
||||
}
|
||||
|
||||
inline void
|
||||
clearBit(uintptr_t* map, unsigned i)
|
||||
{
|
||||
map[wordOf(i)] &= ~(static_cast<uintptr_t>(1) << bitOf(i));
|
||||
}
|
||||
|
||||
inline unsigned
|
||||
getBit(uintptr_t* map, unsigned i)
|
||||
{
|
||||
return map[wordOf(i)] & (static_cast<uintptr_t>(1) << bitOf(i));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T&
|
||||
cast(void* p, unsigned offset)
|
||||
|
@ -9,12 +9,16 @@ vmInvoke:
|
||||
pushq %rbp
|
||||
movq %rsp,%rbp
|
||||
|
||||
// rbx is a callee-saved register (so are r12-r15, but we don't use those)
|
||||
pushq %rbx
|
||||
|
||||
// %rdi: function
|
||||
// %rsi: stack
|
||||
// %rdx: stackSize
|
||||
// %rcx: returnType
|
||||
|
||||
// reserve space for arguments
|
||||
pushq %rdx
|
||||
subq %rdx,%rsp
|
||||
|
||||
// copy memory arguments into place
|
||||
@ -36,7 +40,12 @@ test:
|
||||
|
||||
// call function
|
||||
call *%rdi
|
||||
|
||||
// pop arguments
|
||||
addq -16(%rbp),%rsp
|
||||
addq $8,%rsp
|
||||
|
||||
popq %rbx
|
||||
movq %rbp,%rsp
|
||||
popq %rbp
|
||||
ret
|
||||
@ -54,15 +63,18 @@ vmInvoke:
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
|
||||
// ebx, esi and edi are callee-saved registers
|
||||
pushl %ebx
|
||||
pushl %esi
|
||||
pushl %edi
|
||||
|
||||
// 8(%ebp): function
|
||||
// 12(%ebp): stack
|
||||
// 16(%ebp): stackSize
|
||||
// 20(%ebp): returnType
|
||||
|
||||
// reserve space for arguments
|
||||
movl 16(%ebp),%ecx
|
||||
|
||||
subl %ecx,%esp
|
||||
subl 16(%ebp),%esp
|
||||
|
||||
// copy arguments into place
|
||||
movl $0,%ecx
|
||||
@ -84,6 +96,9 @@ test:
|
||||
// call function
|
||||
call *8(%ebp)
|
||||
|
||||
// pop arguments
|
||||
addl 16(%ebp),%esp
|
||||
|
||||
// handle return value based on expected type
|
||||
movl 20(%ebp),%ecx
|
||||
|
||||
@ -101,6 +116,9 @@ int32:
|
||||
movl $0,%edx
|
||||
|
||||
exit:
|
||||
popl %edi
|
||||
popl %esi
|
||||
popl %ebx
|
||||
movl %ebp,%esp
|
||||
popl %ebp
|
||||
ret
|
||||
|
@ -28,24 +28,6 @@ const unsigned FrameFootprint = BytesPerWord * 3;
|
||||
|
||||
class ArgumentList;
|
||||
|
||||
inline void
|
||||
markBit(uintptr_t* map, unsigned i)
|
||||
{
|
||||
map[wordOf(i)] |= static_cast<uintptr_t>(1) << bitOf(i);
|
||||
}
|
||||
|
||||
inline void
|
||||
clearBit(uintptr_t* map, unsigned i)
|
||||
{
|
||||
map[wordOf(i)] &= ~(static_cast<uintptr_t>(1) << bitOf(i));
|
||||
}
|
||||
|
||||
inline unsigned
|
||||
getBit(uintptr_t* map, unsigned i)
|
||||
{
|
||||
return map[wordOf(i)] & (static_cast<uintptr_t>(1) << bitOf(i));
|
||||
}
|
||||
|
||||
class Buffer {
|
||||
public:
|
||||
Buffer(System* s, unsigned minimumCapacity):
|
||||
@ -318,8 +300,8 @@ class StackMapper {
|
||||
|
||||
unsigned i = index[ip];
|
||||
while (true) {
|
||||
fprintf(stderr, "event %d; ip %d; sp %d; local size %d; map size %d\n",
|
||||
log.get(i), ip, sp, localSize(), mapSize());
|
||||
// fprintf(stderr, "event %d; ip %d; sp %d; local size %d; map size %d\n",
|
||||
// log.get(i), ip, sp, localSize(), mapSize());
|
||||
|
||||
switch (log.get(i++)) {
|
||||
case Call: {
|
||||
|
@ -206,13 +206,13 @@ class Segment {
|
||||
void clearBit(unsigned i) {
|
||||
assert(segment->context, wordOf(i) < size());
|
||||
|
||||
data()[wordOf(i)] &= ~(static_cast<uintptr_t>(1) << bitOf(i));
|
||||
vm::clearBit(data(), i);
|
||||
}
|
||||
|
||||
void setBit(unsigned i) {
|
||||
assert(segment->context, wordOf(i) < size());
|
||||
|
||||
data()[wordOf(i)] |= static_cast<uintptr_t>(1) << bitOf(i);
|
||||
vm::markBit(data(), i);
|
||||
}
|
||||
|
||||
void clearOnlyIndex(unsigned index) {
|
||||
@ -738,9 +738,9 @@ bitsetSet(uintptr_t* p, unsigned i, bool v)
|
||||
}
|
||||
|
||||
if (v) {
|
||||
p[wordOf(i)] |= static_cast<uintptr_t>(1) << bitOf(i);
|
||||
markBit(p, i);
|
||||
} else {
|
||||
p[wordOf(i)] &= ~(static_cast<uintptr_t>(1) << bitOf(i));
|
||||
clearBit(p, i);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user