1.1 --- a/sourcehook/sourcehook_hookmangen.cpp Thu Nov 01 17:29:39 2007 +0000
1.2 +++ b/sourcehook/sourcehook_hookmangen.cpp Fri Nov 02 00:53:32 2007 +0000
1.3 @@ -147,6 +147,47 @@
1.4 }
1.5 }
1.6
1.7 + void GenContext::BitwiseCopy_Setup()
1.8 + {
1.9 + //cld
1.10 + //push edi
1.11 + //push esi
1.12 +
1.13 + IA32_Cld(&m_HookFunc);
1.14 + IA32_Push_Reg(&m_HookFunc, REG_EDI);
1.15 + IA32_Push_Reg(&m_HookFunc, REG_ESI);
1.16 + }
1.17 +
1.18 + void GenContext::BitwiseCopy_Do(size_t size)
1.19 + {
1.20 + jit_uint32_t dwords = DownCastSize(size) / 4;
1.21 + jit_uint32_t bytes = DownCastSize(size) % 4;
1.22 +
1.23 + //if dwords
1.24 + // mov ecx, <dwords>
1.25 + // rep movsd
1.26 + //if bytes
1.27 + // mov ecx, <bytes>
1.28 + // rep movsb
1.29 + //pop esi
1.30 + //pop edi
1.31 +
1.32 + if (dwords)
1.33 + {
1.34 + IA32_Mov_Reg_Imm32(&m_HookFunc, REG_ECX, dwords);
1.35 + IA32_Rep(&m_HookFunc);
1.36 + IA32_Movsd(&m_HookFunc);
1.37 + }
1.38 + if (bytes)
1.39 + {
1.40 + IA32_Mov_Reg_Imm32(&m_HookFunc, REG_ECX, bytes);
1.41 + IA32_Rep(&m_HookFunc);
1.42 + IA32_Movsb(&m_HookFunc);
1.43 + }
1.44 + IA32_Pop_Reg(&m_HookFunc, REG_ESI);
1.45 + IA32_Pop_Reg(&m_HookFunc, REG_EDI);
1.46 + }
1.47 +
1.48 jit_int32_t GenContext::PushRef(jit_int32_t param_offset, const IntPassInfo &pi)
1.49 {
1.50 // push [ebp+<offset>]
1.51 @@ -262,51 +303,24 @@
1.52 }
1.53 else
1.54 {
1.55 - jit_uint32_t dwords = DownCastSize(pi.size) / 4;
1.56 - jit_uint32_t bytes = DownCastSize(pi.size) % 4;
1.57 -
1.58 // bitwise copy
1.59
1.60 - //cld
1.61 - //push edi
1.62 - //push esi
1.63 +
1.64 + BitwiseCopy_Setup();
1.65 +
1.66 //lea edi, [esp+8]
1.67 //lea esi, [ebp+<offs>]
1.68 - //if dwords
1.69 - // mov ecx, <dwords>
1.70 - // rep movsd
1.71 - //if bytes
1.72 - // mov ecx, <bytes>
1.73 - // rep movsb
1.74 - //pop esi
1.75 - //pop edi
1.76 -
1.77 - IA32_Cld(&m_HookFunc);
1.78 - IA32_Push_Reg(&m_HookFunc, REG_EDI);
1.79 - IA32_Push_Reg(&m_HookFunc, REG_ESI);
1.80 IA32_Lea_Reg_DispRegMultImm8(&m_HookFunc, REG_EDI, REG_NOIDX, REG_ESP, NOSCALE, 8);
1.81 IA32_Lea_DispRegImmAuto(&m_HookFunc, REG_ESI, REG_EBP, param_offset);
1.82 - if (dwords)
1.83 - {
1.84 - IA32_Mov_Reg_Imm32(&m_HookFunc, REG_ECX, dwords);
1.85 - IA32_Rep(&m_HookFunc);
1.86 - IA32_Movsd(&m_HookFunc);
1.87 - }
1.88 - if (bytes)
1.89 - {
1.90 - IA32_Mov_Reg_Imm32(&m_HookFunc, REG_ECX, bytes);
1.91 - IA32_Rep(&m_HookFunc);
1.92 - IA32_Movsb(&m_HookFunc);
1.93 - }
1.94 - IA32_Pop_Reg(&m_HookFunc, REG_ESI);
1.95 - IA32_Pop_Reg(&m_HookFunc, REG_EDI);
1.96 +
1.97 + BitwiseCopy_Do(pi.size);
1.98 }
1.99
1.100 return DownCastSize(pi.size);
1.101 }
1.102
1.103 // May not touch eax!
1.104 - jit_int32_t GenContext::PushParams(jit_int32_t param_base_offset, jit_int32_t save_ret_to)
1.105 + jit_int32_t GenContext::PushParams(jit_int32_t param_base_offset, jit_int32_t save_ret_to, int v_place_for_memret)
1.106 {
1.107 jit_int32_t added_to_stack = 0;
1.108 jit_int32_t ret = 0;
1.109 @@ -354,7 +368,8 @@
1.110 {
1.111 // push address where to save it!
1.112 int reg = NextRegEBX_ECX_EDX();
1.113 - IA32_Lea_DispRegImmAuto(&m_HookFunc, reg, REG_EBP, save_ret_to);
1.114 + IA32_Lea_DispRegImmAuto(&m_HookFunc, reg, REG_EBP,
1.115 + MemRetWithTempObj() ? v_place_for_memret : save_ret_to);
1.116 IA32_Push_Reg(&m_HookFunc, reg);
1.117
1.118 added_to_stack += SIZE_PTR;
1.119 @@ -363,7 +378,7 @@
1.120 return added_to_stack;
1.121 }
1.122
1.123 - void GenContext::SaveRetVal(int v_where)
1.124 + void GenContext::SaveRetVal(int v_where, int v_place_for_memret)
1.125 {
1.126 size_t size = m_Proto.GetRet().size;
1.127 if (size == 0)
1.128 @@ -373,9 +388,65 @@
1.129 }
1.130
1.131 // Memory return:
1.132 - // PushParams already did everything that was neccessary
1.133 if (m_Proto.GetRet().flags & PassInfo::PassFlag_RetMem)
1.134 - return;
1.135 + {
1.136 + if (MemRetWithTempObj())
1.137 + {
1.138 + // *v_where = *v_place_for_memret
1.139 +
1.140 + // if we have an assign operator, use that
1.141 + if (m_Proto.GetRet().pAssignOperator)
1.142 + {
1.143 + // lea edx, [ebp + v_place_for_memret] <-- src addr
1.144 + // lea ecx, [ebp + v_where] <-- dest addr
1.145 + // gcc: push ecx
1.146 + // push edx
1.147 + // call it
1.148 +
1.149 + IA32_Lea_DispRegImmAuto(&m_HookFunc, REG_EDX, REG_EBP, v_place_for_memret);
1.150 + IA32_Lea_DispRegImmAuto(&m_HookFunc, REG_ECX, REG_EBP, v_where);
1.151 +#if SH_COMP == SH_COMP_GCC
1.152 + IA32_Push_Reg(&m_HookFunc, REG_ECX);
1.153 +#endif
1.154 + IA32_Push_Reg(&m_HookFunc, REG_EDX);
1.155 +
1.156 + IA32_Mov_Reg_Imm32(&m_HookFunc, REG_EAX, DownCastPtr(m_Proto.GetRet().pAssignOperator));
1.157 + IA32_Call_Reg(&m_HookFunc, REG_EAX);
1.158 + }
1.159 + else
1.160 + {
1.161 + // bitwise copy
1.162 + BitwiseCopy_Setup();
1.163 +
1.164 + //lea edi, [evp+v_where] <-- destination
1.165 + //lea esi, [ebp+v_place_for_memret] <-- src
1.166 + IA32_Lea_DispRegImmAuto(&m_HookFunc, REG_EDI, REG_EBP, v_where);
1.167 + IA32_Lea_DispRegImmAuto(&m_HookFunc, REG_ESI, REG_EBP, v_place_for_memret);
1.168 +
1.169 + BitwiseCopy_Do(m_Proto.GetRet().size);
1.170 + }
1.171 +
1.172 + // Then: destruct *v_place_for_memret if required
1.173 + if (m_Proto.GetRet().pDtor)
1.174 + {
1.175 + //lea ecx, [ebp+v_place_for_memret]
1.176 + //gcc: push ecx
1.177 + //call it
1.178 +
1.179 + IA32_Lea_DispRegImmAuto(&m_HookFunc, REG_ECX, REG_EBP, v_place_for_memret);
1.180 +#if SH_COMP == SH_COMP_GCC
1.181 + IA32_Push_Reg(&m_HookFunc, REG_ECX);
1.182 +#endif
1.183 + IA32_Mov_Reg_Imm32(&m_HookFunc, REG_EAX, DownCastPtr(m_Proto.GetRet().pDtor));
1.184 + IA32_Call_Reg(&m_HookFunc, REG_EAX);
1.185 + }
1.186 + }
1.187 + else
1.188 + {
1.189 + // Already copied to correct address -> we're done
1.190 + return;
1.191 + }
1.192 + }
1.193
1.194 if (m_Proto.GetRet().type == PassInfo::PassType_Float)
1.195 {
1.196 @@ -436,6 +507,13 @@
1.197 }
1.198 }
1.199
1.200 + bool GenContext::MemRetWithTempObj()
1.201 + {
1.202 + // Memory return AND (has destructor OR has assign operator)
1.203 + return ((m_Proto.GetRet().flags & PassInfo::PassFlag_RetMem)
1.204 + && (m_Proto.GetRet().flags & (PassInfo::PassFlag_ODtor | PassInfo::PassFlag_AssignOp)));
1.205 + }
1.206 +
1.207 void GenContext::ProcessPluginRetVal(int v_cur_res, int v_pContext, int v_plugin_ret)
1.208 {
1.209 // only for non-void functions!
1.210 @@ -500,44 +578,15 @@
1.211 }
1.212 else
1.213 {
1.214 - jit_uint32_t dwords = DownCastSize(m_Proto.GetRet().size) / 4;
1.215 - jit_uint32_t bytes = DownCastSize(m_Proto.GetRet().size) % 4;
1.216 + // bitwise copy
1.217 + BitwiseCopy_Setup();
1.218
1.219 - // bitwise copy
1.220 -
1.221 - //cld
1.222 - //push edi
1.223 - //push esi
1.224 //mov edi, eax <-- destination
1.225 //lea esi, [ebp+v_plugin_ret] <-- src
1.226 - //if dwords
1.227 - // mov ecx, <dwords>
1.228 - // rep movsd
1.229 - //if bytes
1.230 - // mov ecx, <bytes>
1.231 - // rep movsb
1.232 - //pop esi
1.233 - //pop edi
1.234 -
1.235 - IA32_Cld(&m_HookFunc);
1.236 - IA32_Push_Reg(&m_HookFunc, REG_EDI);
1.237 - IA32_Push_Reg(&m_HookFunc, REG_ESI);
1.238 IA32_Mov_Reg_Rm(&m_HookFunc, REG_EDI, REG_EAX, MOD_REG);
1.239 IA32_Lea_DispRegImmAuto(&m_HookFunc, REG_ESI, REG_EBP, v_plugin_ret);
1.240 - if (dwords)
1.241 - {
1.242 - IA32_Mov_Reg_Imm32(&m_HookFunc, REG_ECX, dwords);
1.243 - IA32_Rep(&m_HookFunc);
1.244 - IA32_Movsd(&m_HookFunc);
1.245 - }
1.246 - if (bytes)
1.247 - {
1.248 - IA32_Mov_Reg_Imm32(&m_HookFunc, REG_ECX, bytes);
1.249 - IA32_Rep(&m_HookFunc);
1.250 - IA32_Movsb(&m_HookFunc);
1.251 - }
1.252 - IA32_Pop_Reg(&m_HookFunc, REG_ESI);
1.253 - IA32_Pop_Reg(&m_HookFunc, REG_EDI);
1.254 +
1.255 + BitwiseCopy_Do(m_Proto.GetRet().size);
1.256 }
1.257
1.258 m_HookFunc.end_count(counter);
1.259 @@ -600,7 +649,6 @@
1.260 if (!size)
1.261 return;
1.262
1.263 - // :TODO: assign op support
1.264 // :TODO: memory return support
1.265
1.266 // Get real ret pointer into ecx
1.267 @@ -645,7 +693,7 @@
1.268 if (m_Proto.GetRet().flags & PassInfo::PassFlag_RetMem)
1.269 {
1.270 // *memret_outaddr = plugin_ret
1.271 - if (m_Proto.GetRet().pAssignOperator)
1.272 + if (m_Proto.GetRet().pCopyCtor)
1.273 {
1.274 // mov edx, ecx <-- src ( we set ecx to [ebp+v_retptr] before )
1.275 // msvc: ecx = [ebp + v_memret_outaddr] <-- dest addr
1.276 @@ -662,49 +710,20 @@
1.277 #endif
1.278 IA32_Push_Reg(&m_HookFunc, REG_EDX);
1.279
1.280 - IA32_Mov_Reg_Imm32(&m_HookFunc, REG_EAX, DownCastPtr(m_Proto.GetRet().pAssignOperator));
1.281 + IA32_Mov_Reg_Imm32(&m_HookFunc, REG_EAX, DownCastPtr(m_Proto.GetRet().pCopyCtor));
1.282 IA32_Call_Reg(&m_HookFunc, REG_EAX);
1.283 }
1.284 else
1.285 {
1.286 - jit_uint32_t dwords = DownCastSize(m_Proto.GetRet().size) / 4;
1.287 - jit_uint32_t bytes = DownCastSize(m_Proto.GetRet().size) % 4;
1.288 -
1.289 // bitwise copy
1.290 + BitwiseCopy_Setup();
1.291
1.292 - //cld
1.293 - //push edi
1.294 - //push esi
1.295 //mov edi, [ebp+v_memret_outaddr] <-- destination
1.296 //mov esi, ecx <-- src ( we set ecx to [ebp+v_retptr] before )
1.297 - //if dwords
1.298 - // mov ecx, <dwords>
1.299 - // rep movsd
1.300 - //if bytes
1.301 - // mov ecx, <bytes>
1.302 - // rep movsb
1.303 - //pop esi
1.304 - //pop edi
1.305 -
1.306 - IA32_Cld(&m_HookFunc);
1.307 - IA32_Push_Reg(&m_HookFunc, REG_EDI);
1.308 - IA32_Push_Reg(&m_HookFunc, REG_ESI);
1.309 IA32_Mov_Reg_Rm_DispAuto(&m_HookFunc, REG_EDI, REG_EBP, v_memret_outaddr);
1.310 IA32_Mov_Reg_Rm(&m_HookFunc, REG_ESI, REG_ECX, MOD_REG);
1.311 - if (dwords)
1.312 - {
1.313 - IA32_Mov_Reg_Imm32(&m_HookFunc, REG_ECX, dwords);
1.314 - IA32_Rep(&m_HookFunc);
1.315 - IA32_Movsd(&m_HookFunc);
1.316 - }
1.317 - if (bytes)
1.318 - {
1.319 - IA32_Mov_Reg_Imm32(&m_HookFunc, REG_ECX, bytes);
1.320 - IA32_Rep(&m_HookFunc);
1.321 - IA32_Movsb(&m_HookFunc);
1.322 - }
1.323 - IA32_Pop_Reg(&m_HookFunc, REG_ESI);
1.324 - IA32_Pop_Reg(&m_HookFunc, REG_EDI);
1.325 +
1.326 + BitwiseCopy_Do(m_Proto.GetRet().size);
1.327 }
1.328
1.329 // In both cases: return the pointer in EAX
1.330 @@ -714,7 +733,7 @@
1.331 }
1.332
1.333 void GenContext::GenerateCallHooks(int v_status, int v_prev_res, int v_cur_res, int v_iter,
1.334 - int v_pContext, int base_param_offset, int v_plugin_ret)
1.335 + int v_pContext, int base_param_offset, int v_plugin_ret, int v_place_for_memret)
1.336 {
1.337 jitoffs_t counter, tmppos;
1.338 jitoffs_t counter2, tmppos2;
1.339 @@ -759,7 +778,7 @@
1.340 // eax = [ecx]
1.341 // eax = [eax+2*SIZE_PTR]
1.342 // call eax
1.343 - jit_int32_t gcc_clean_bytes = PushParams(base_param_offset, v_plugin_ret);
1.344 + jit_int32_t gcc_clean_bytes = PushParams(base_param_offset, v_plugin_ret, v_place_for_memret);
1.345
1.346 IA32_Mov_Reg_Rm(&m_HookFunc, REG_ECX, REG_EAX, MOD_REG);
1.347 #if SH_COMP == SH_COMP_GCC
1.348 @@ -769,7 +788,7 @@
1.349 IA32_Mov_Reg_Rm_DispAuto(&m_HookFunc, REG_EAX, REG_EAX, 2*SIZE_PTR);
1.350 IA32_Call_Reg(&m_HookFunc, REG_EAX);
1.351
1.352 - SaveRetVal(v_plugin_ret);
1.353 + SaveRetVal(v_plugin_ret, v_place_for_memret);
1.354
1.355 // cleanup
1.356 #if SH_COMP == SH_COMP_GCC
1.357 @@ -831,8 +850,8 @@
1.358 return acc;
1.359 }
1.360
1.361 - void GenContext::GenerateCallOrig(int v_status, int v_pContext,
1.362 - int param_base_offs, int v_this, int v_vfnptr_origentry, int v_orig_ret, int v_override_ret)
1.363 + void GenContext::GenerateCallOrig(int v_status, int v_pContext, int param_base_offs, int v_this,
1.364 + int v_vfnptr_origentry, int v_orig_ret, int v_override_ret, int v_place_for_memret)
1.365 {
1.366 jitoffs_t counter, tmppos;
1.367 jitoffs_t counter2, tmppos2;
1.368 @@ -885,7 +904,7 @@
1.369 m_HookFunc.start_count(counter2);
1.370
1.371 // push params
1.372 - jit_int32_t gcc_clean_bytes = PushParams(param_base_offs, v_orig_ret);
1.373 + jit_int32_t gcc_clean_bytes = PushParams(param_base_offs, v_orig_ret, v_place_for_memret);
1.374
1.375 // thisptr
1.376 IA32_Mov_Reg_Rm_DispAuto(&m_HookFunc, REG_ECX, REG_EBP, v_this);
1.377 @@ -906,7 +925,7 @@
1.378 #endif
1.379
1.380 // save retval
1.381 - SaveRetVal(v_orig_ret);
1.382 + SaveRetVal(v_orig_ret, v_place_for_memret);
1.383
1.384 // Skip don't call variant
1.385 tmppos3 = IA32_Jump_Imm32(&m_HookFunc, 0);
1.386 @@ -941,44 +960,15 @@
1.387 }
1.388 else
1.389 {
1.390 - jit_uint32_t dwords = DownCastSize(m_Proto.GetRet().size) / 4;
1.391 - jit_uint32_t bytes = DownCastSize(m_Proto.GetRet().size) % 4;
1.392 + // bitwise copy
1.393 + BitwiseCopy_Setup();
1.394
1.395 - // bitwise copy
1.396 -
1.397 - //cld
1.398 - //push edi
1.399 - //push esi
1.400 //lea edi, [ebp+v_orig_ret] <-- destination
1.401 //lea esi, [ebp+v_override_ret] <-- src
1.402 - //if dwords
1.403 - // mov ecx, <dwords>
1.404 - // rep movsd
1.405 - //if bytes
1.406 - // mov ecx, <bytes>
1.407 - // rep movsb
1.408 - //pop esi
1.409 - //pop edi
1.410 -
1.411 - IA32_Cld(&m_HookFunc);
1.412 - IA32_Push_Reg(&m_HookFunc, REG_EDI);
1.413 - IA32_Push_Reg(&m_HookFunc, REG_ESI);
1.414 IA32_Lea_DispRegImmAuto(&m_HookFunc, REG_EDI, REG_EBP, v_orig_ret);
1.415 IA32_Lea_DispRegImmAuto(&m_HookFunc, REG_ESI, REG_EBP, v_override_ret);
1.416 - if (dwords)
1.417 - {
1.418 - IA32_Mov_Reg_Imm32(&m_HookFunc, REG_ECX, dwords);
1.419 - IA32_Rep(&m_HookFunc);
1.420 - IA32_Movsd(&m_HookFunc);
1.421 - }
1.422 - if (bytes)
1.423 - {
1.424 - IA32_Mov_Reg_Imm32(&m_HookFunc, REG_ECX, bytes);
1.425 - IA32_Rep(&m_HookFunc);
1.426 - IA32_Movsb(&m_HookFunc);
1.427 - }
1.428 - IA32_Pop_Reg(&m_HookFunc, REG_ESI);
1.429 - IA32_Pop_Reg(&m_HookFunc, REG_EDI);
1.430 +
1.431 + BitwiseCopy_Do(m_Proto.GetRet().size);
1.432 }
1.433
1.434 // skip don't call label target:
1.435 @@ -1134,6 +1124,10 @@
1.436 // my_rettype plugin_ret ebp - 28 - sizeof(my_rettype)*3 -4
1.437 // == + 3 * sizeof(my_rettype) bytes
1.438
1.439 + // if required:
1.440 + // my_rettype place_for_memret ebp - 28 - sizeof(my_rettype)*4 -4
1.441 +
1.442 +
1.443 const jit_int8_t v_vfnptr_origentry = -4 + addstackoffset;
1.444 const jit_int8_t v_status = -8 + addstackoffset;
1.445 const jit_int8_t v_prev_res = -12 + addstackoffset;
1.446 @@ -1160,10 +1154,13 @@
1.447 jit_int32_t v_override_ret = -28 + addstackoffset - GetStackSize(m_Proto.GetRet()) * 2;
1.448 jit_int32_t v_plugin_ret = -28 + addstackoffset - GetStackSize(m_Proto.GetRet()) * 3;
1.449
1.450 + jit_int32_t v_place_for_memret = -28 + addstackoffset - GetStackSize(m_Proto.GetRet()) * 4;
1.451 +
1.452 // Hash for temporary storage for byval params with copy constructors
1.453 // (param, offset into stack)
1.454 - short usedStackBytes = 3*SIZE_MWORD + 3*SIZE_PTR + // vfnptr_origentry, status, prev_res, cur_res, iter, pContext
1.455 - 3 * GetStackSize(m_Proto.GetRet()) + (m_Proto.GetRet().size == 0 ? 0 : SIZE_PTR) // ret_ptr, orig_ret, override_ret, plugin_ret
1.456 + short usedStackBytes = 3*SIZE_MWORD + 3*SIZE_PTR // vfnptr_origentry, status, prev_res, cur_res, iter, pContext
1.457 + + 3 * GetStackSize(m_Proto.GetRet()) + (m_Proto.GetRet().size == 0 ? 0 : SIZE_PTR) // ret_ptr, orig_ret, override_ret, plugin_ret
1.458 + + (MemRetWithTempObj() ? GetStackSize(m_Proto.GetRet()) : 0)
1.459 - addstackoffset; // msvc: current thisptr
1.460
1.461 IA32_Sub_Rm_Imm32(&m_HookFunc, REG_ESP, usedStackBytes, MOD_REG);
1.462 @@ -1190,6 +1187,8 @@
1.463 IA32_Lea_DispRegImmAuto(&m_HookFunc, REG_ECX, REG_EBP, v_plugin_ret);
1.464 IA32_Mov_Reg_Imm32(&m_HookFunc, REG_EAX, DownCastPtr(m_Proto.GetRet().pNormalCtor));
1.465 IA32_Call_Reg(&m_HookFunc, REG_EAX);
1.466 +
1.467 + // _don't_ call a constructor for v_place_for_memret !
1.468 }
1.469
1.470 // ********************** SetupHookLoop **********************
1.471 @@ -1198,15 +1197,15 @@
1.472
1.473 // ********************** call pre hooks **********************
1.474 GenerateCallHooks(v_status, v_prev_res, v_cur_res, v_iter, v_pContext, param_base_offs,
1.475 - v_plugin_ret);
1.476 + v_plugin_ret, v_place_for_memret);
1.477
1.478 // ********************** call orig func **********************
1.479 GenerateCallOrig(v_status, v_pContext, param_base_offs, v_this, v_vfnptr_origentry, v_orig_ret,
1.480 - v_override_ret);
1.481 + v_override_ret, v_place_for_memret);
1.482
1.483 // ********************** call post hooks **********************
1.484 GenerateCallHooks(v_status, v_prev_res, v_cur_res, v_iter, v_pContext, param_base_offs,
1.485 - v_plugin_ret);
1.486 + v_plugin_ret, v_place_for_memret);
1.487
1.488 // ********************** end context and return **********************
1.489
1.490 @@ -1231,7 +1230,37 @@
1.491
1.492 DoReturn(v_ret_ptr, v_memret_addr);
1.493
1.494 - // !! :TODO: Call destructors of orig_ret/ ...
1.495 + // Call destructors of orig_ret/ ...
1.496 + if(m_Proto.GetRet().pDtor)
1.497 + {
1.498 + // Preserve return value in EAX(:EDX)
1.499 + IA32_Push_Reg(&m_HookFunc, REG_EAX);
1.500 + IA32_Push_Reg(&m_HookFunc, REG_EDX);
1.501 +
1.502 + IA32_Lea_DispRegImmAuto(&m_HookFunc, REG_ECX, REG_EBP, v_plugin_ret);
1.503 +#if SH_COMP == SH_COMP_GCC
1.504 + IA32_Push_Reg(&m_HookFunc, REG_ECX);
1.505 +#endif
1.506 + IA32_Mov_Reg_Imm32(&m_HookFunc, REG_EAX, DownCastPtr(m_Proto.GetRet().pDtor));
1.507 + IA32_Call_Reg(&m_HookFunc, REG_EAX);
1.508 +
1.509 + IA32_Lea_DispRegImmAuto(&m_HookFunc, REG_ECX, REG_EBP, v_override_ret);
1.510 +#if SH_COMP == SH_COMP_GCC
1.511 + IA32_Push_Reg(&m_HookFunc, REG_ECX);
1.512 +#endif
1.513 + IA32_Mov_Reg_Imm32(&m_HookFunc, REG_EAX, DownCastPtr(m_Proto.GetRet().pDtor));
1.514 + IA32_Call_Reg(&m_HookFunc, REG_EAX);
1.515 +
1.516 + IA32_Lea_DispRegImmAuto(&m_HookFunc, REG_ECX, REG_EBP, v_orig_ret);
1.517 +#if SH_COMP == SH_COMP_GCC
1.518 + IA32_Push_Reg(&m_HookFunc, REG_ECX);
1.519 +#endif
1.520 + IA32_Mov_Reg_Imm32(&m_HookFunc, REG_EAX, DownCastPtr(m_Proto.GetRet().pDtor));
1.521 + IA32_Call_Reg(&m_HookFunc, REG_EAX);
1.522 +
1.523 + IA32_Pop_Reg(&m_HookFunc, REG_EDX);
1.524 + IA32_Pop_Reg(&m_HookFunc, REG_EAX);
1.525 + }
1.526
1.527 // epilogue
1.528 IA32_Mov_Reg_Rm(&m_HookFunc, REG_ESP, REG_EBP, MOD_REG);
1.529 @@ -1351,17 +1380,16 @@
1.530 if (pi.type == PassInfo::PassType_Object &&
1.531 (pi.flags & PassInfo::PassFlag_ByVal))
1.532 {
1.533 - if ((pi.flags & PassInfo::PassFlag_CCtor) && !pi.pNormalCtor)
1.534 + if ((pi.flags & PassInfo::PassFlag_CCtor) && !pi.pCopyCtor)
1.535 return false;
1.536
1.537 if ((pi.flags & PassInfo::PassFlag_ODtor) && !pi.pDtor)
1.538 return false;
1.539
1.540 - // only care for assignop and normalctor for return types
1.541 - if (is_ret && (pi.flags & PassInfo::PassFlag_AssignOp) && !pi.pAssignOperator)
1.542 + if ((pi.flags & PassInfo::PassFlag_AssignOp) && !pi.pAssignOperator)
1.543 return false;
1.544
1.545 - if (is_ret && (pi.flags & PassInfo::PassFlag_CCtor) && !pi.pNormalCtor)
1.546 + if ((pi.flags & PassInfo::PassFlag_OCtor) && !pi.pNormalCtor)
1.547 return false;
1.548 }
1.549