Re: Why does std::stack::pop() not throw an exception if the stack is empty?
On Feb 6, 12:21 am, Joshua Maurice <joshuamaur...@gmail.com> wrote:
On Feb 5, 10:27 pm, Andre Kaufmann <akfmn...@t-online.de> wrote:
On 05.02.2011 22:52, Joshua Maurice wrote:
[...]
I've logged in remotely at work and the results are as I had suspected.
The same results (performance of x64 exception code == performance x64
no exception code), besides some slight differences in the test "Virtual
Exception". After I've changed the code slightly, to force the optimizer
to generate (significant) code, I've got the same results.
>[...]
Interesting. I'll get the assembly for my tests and post it. I wonder
if I'm measuring random noise or something for my windowws AMD 64
test.
The generated assembly code of the small test program is the same as
under VS2010.
I wonder why you got different results, your settings are correct and
the compiler version is sufficient too. Curious.
Also, your deduction is correct that I am using visual studios 2008. I
should have mentioned that. I wonder if 2010 makes a difference.
That'll likely have to wait until Monday or Tuesday though.
I used VS2008 SP1 for the tests, but I don't think that matters anyways.
Dunno. I'll look at the generated assembly when I get back to work.
Close to the release now. I just got some time. I reran the tests, and
I still got similar results.
???>test_solution.exe 50000 -10
Virtual Exception : 8.255
Inlineable Global Return Code : 1.686
Inlineable Member Return Code : 1.661
Manually Inlined Optimized Return Code : 1.721
Virtual Return Code Fake Try : 9.104
Virtual Return Code : 6.736
Manually Inlined Return Code : 1.686
???>test_solution.exe 50000 -10
Manually Inlined Optimized Return Code : 1.645
Inlineable Member Return Code : 1.667
Inlineable Global Return Code : 1.717
Virtual Return Code : 6.574
Manually Inlined Return Code : 1.62
Virtual Exception : 8.2
Virtual Return Code Fake Try : 9.113
???>test_solution.exe 50000 -10
Inlineable Global Return Code : 1.717
Inlineable Member Return Code : 1.658
Virtual Return Code Fake Try : 9.137
Virtual Return Code : 6.544
Virtual Exception : 8.228
Manually Inlined Optimized Return Code : 1.702
Manually Inlined Return Code : 1.695
Here's the disassembly output from the visual studios debugger. I'm
not sure what all of that means. I can barely follow it even with
googling some of the opcodes. I ask you to please make sense of it.
void testVirtualException(TestInterface *& x, int loopIterations, int
failIfEqualsNumber)
{ for (int i=0; i<loopIterations; ++i)
000000013FBE1780 mov dword ptr [rsp+18h],r8d
000000013FBE1785 mov dword ptr [rsp+10h],edx
000000013FBE1789 mov qword ptr [rsp+8],rcx
000000013FBE178E push rbx
000000013FBE178F push rsi
000000013FBE1790 push rdi
000000013FBE1791 push r12
000000013FBE1793 push r13
000000013FBE1795 sub rsp,30h
000000013FBE1799 mov qword ptr [rsp+28h],0FFFFFFFFFFFFFFFEh
000000013FBE17A2 mov r12d,r8d
000000013FBE17A5 mov esi,edx
000000013FBE17A7 mov r13,rcx
000000013FBE17AA xor edi,edi
000000013FBE17AC mov dword ptr [i],edi
000000013FBE17B0 cmp edi,esi
000000013FBE17B2 jge $LN15+26h (13FBE1800h)
void testVirtualReturnCode(TestInterface *& x, int loopIterations, int
failIfEqualsNumber)
{ for (int i=0; i<loopIterations; ++i)
000000013F6B16D0 test edx,edx
000000013F6B16D2 jle testVirtualReturnCode+0A6h (13F6B1776h)
000000013F6B16D8 push rbp
000000013F6B16D9 push rsi
000000013F6B16DA push rdi
000000013F6B16DB sub rsp,20h
000000013F6B16DF mov qword ptr [x],rbx
000000013F6B16E4 mov qword ptr [loopIterations],r12
000000013F6B16E9 mov qword ptr [failIfEqualsNumber],r13
000000013F6B16EE lea r13,[TestImpl2::`vftable' (13F6B4698h)]
000000013F6B16F5 mov edi,edx
000000013F6B16F7 mov rsi,rcx
000000013F6B16FA xor ebp,ebp
000000013F6B16FC lea r12d,[r8+6]
{ for (int j=0; j<loopIterations; ++j)
000000013F6B1700 xor ebx,ebx
{ for (int j=0; j<loopIterations; ++j)
{ try
{ if (Failure == x->virtualReturnCode(i, j, failIfEqualsNumber+5))
{ cout << "virtual return code with fake try, returned failure" <<
endl;
x = new TestImpl2();
}
} catch (...)
{ cout << "ERROR impossible exception caught" << endl;
x = new TestImpl2();
}
}
}
}
void testVirtualReturnCodeFakeTry(TestInterface *& x, int
loopIterations, int failIfEqualsNumber)
{ for (int i=0; i<loopIterations; ++i)
000000013F6B15D0 mov dword ptr [rsp+18h],r8d
000000013F6B15D5 mov dword ptr [rsp+10h],edx
000000013F6B15D9 mov qword ptr [rsp+8],rcx
000000013F6B15DE push rbx
000000013F6B15DF push rsi
000000013F6B15E0 push rdi
000000013F6B15E1 push r12
000000013F6B15E3 push r13
000000013F6B15E5 push r14
000000013F6B15E7 sub rsp,38h
000000013F6B15EB mov qword ptr [rsp+28h],0FFFFFFFFFFFFFFFEh
000000013F6B15F4 mov r14d,r8d
000000013F6B15F7 mov r12d,edx
000000013F6B15FA mov r13,rcx
000000013F6B15FD xor esi,esi
000000013F6B15FF mov dword ptr [i],esi
000000013F6B1603 lea rdi,[TestImpl2::`vftable' (13F6B4698h)]
000000013F6B160A nop word ptr [rax+rax]
000000013F6B1610 cmp esi,r12d
000000013F6B1613 jge $LN18+3Dh (13F6B16BFh)
{ cout << "inlineable member return code, vector size comparison true"
<< endl;
x = new TestImpl2();
}
}
And ack. Remind me to copy the full disassembly next time. Forgot to,
and I don't have access to that computer for a while now.