Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

delphi - When is space allocated for local variables? -


example

function test: boolean; var   a, b, c: integer; begin   ... end; 

when program containing such code executed, a, b, , c allocated each time test called, or allocated once somewhere in initialization phase of execution? ask because such information not available in debugger.

here more exact version.

local variables allocated:

  • usually on stack;
  • in registers if optimizer can use it: instance, simple method loop , var i: integer declared local variable allocate i cpu register, better speed.

how stack allocated?

on both x86 , x64 scheme, compiler has same process:

  • it first computes space needed, @ compile time;
  • it generates code reserve space on stack (e.g. mov ebp,esp; sub esp,16);
  • it generates code initialize reference-counted variables allocated on stack (e.g. string) - other kind of variables (like integer) have no default value, , can random content on stack;
  • it generates hidden try..finally block if there reference-counted variables;
  • it generates code internal of function/method;
  • now here finally part of function/method: generates code free reference-counted variables;
  • it generates code release space on stack (e.g. mov esp,ebp);
  • it generates code return caller function.

most of time, "stack frame" (pointed register ebp) created: used access directly variables allocated on stack.

there specific handling of result variable of function: sometimes, cpu/fpu register, sometimes, variable initialized caller, , passed additional parameter.

on x64, bit more complicated, since exceptions not handled same, , registers need have space allocated on stack, if there inner call.

on mac os, there alignment issues.

all stack allocation / initialization process reason why small functions/methods, declaring them inline make code faster execute: stack handling slow, if process within function simple.

for more details, see official delphi documentation.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -