Hi,
I'm working on a tool that trace the excecution of the block (I need to know all the objects and methods touched by the block and the methodes inside these methods). With something like this : [ blablabla ] trace. So I want to mark the context with a flag to know if the current context is traced or not and in the method send_message I simply look at the flag in the current context and store the result or not. I've looked at the VM code and it seems that the contexts are allocated with the method alloc_stack_context. So in this method I initialise the trace variable with 0. But when I'm in the new primitive VMpr_BlockClosure_trace the value of the trace variable of the parent context is not 0. Are there others place where the context are initialized ? Cheers, Gwenael _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk |
> I'm working on a tool that trace the excecution of the block (I need to know > all the objects and methods touched by the block and the methodes inside these > methods). With something like this : > > [ blablabla ] trace. > > So I want to mark the context with a flag to know if the current context is > traced or not and in the method send_message I simply look at the flag in the > current context and store the result or not. > > I've looked at the VM code and it seems that the contexts are allocated with > the method alloc_stack_context. So in this method I initialise the trace > variable with 0. Have you checked that using DebugTools is too slow? Initialization of the new context is done in activate_new_context, that's probably a better place. Also, alternatively you can use the checks that are already in place for the profiler, so that you don't introduce more ifs on a very hpt path. Alternatively, what about instrumenting the methods and replacing them dynamically? That is, rewrite something like: self abc. self def: 3. to Tracer current on: self perform: #abc. Tracer current on: self perform: #def: with: 3. Inside the tracer object, you keep a mapping between untraced methods and traced methods, and do something like: on: receiver perform: aSymbol | method | "Make this a primitive if it is too slow." method := receiver class lookupSelector: aSymbol. method isNil ifTrue: [ ... handle doesNotUnderstand ... ]. self on: receiver trace: method. ^receiver perform: (self tracingMethodAt: method) Right now there is no instruction stream class (it's all in STCompiler in the Parser package), but maybe you have already written one? :-) Paolo _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk |
In reply to this post by MrGwen
On Monday 20 April 2009 11:42:31 you wrote:
> > I'm working on a tool that trace the excecution of the block (I need to > > know all the objects and methods touched by the block and the methodes > > inside these methods). With something like this : > > > > [ blablabla ] trace. > > > > So I want to mark the context with a flag to know if the current context > > is traced or not and in the method send_message I simply look at the flag > > in the current context and store the result or not. > > > > I've looked at the VM code and it seems that the contexts are allocated > > with the method alloc_stack_context. So in this method I initialise the > > trace variable with 0. > > Have you checked that using DebugTools is too slow? > > Initialization of the new context is done in activate_new_context, > that's probably a better place. > > Also, alternatively you can use the checks that are already in place for > the profiler, so that you don't introduce more ifs on a very hpt path. > > Alternatively, what about instrumenting the methods and replacing them > dynamically? That is, rewrite something like: > > self abc. > self def: 3. > to > > Tracer current on: self perform: #abc. > Tracer current on: self perform: #def: with: 3. > > Inside the tracer object, you keep a mapping between untraced methods > and traced methods, and do something like: > > on: receiver perform: aSymbol > > | method | > > "Make this a primitive if it is too slow." > method := receiver class lookupSelector: aSymbol. > method isNil ifTrue: [ ... handle doesNotUnderstand ... ]. > self on: receiver trace: method. > ^receiver perform: (self tracingMethodAt: method) > > Right now there is no instruction stream class (it's all in STCompiler > in the Parser package), but maybe you have already written one? :-) I've one ;) > > Paolo Thanks for your answser :) This is strange in the activate_new_context method I've done this : newContext = alloc_stack_context (size); newContext->traced = 0; fprintf (stderr, "traced value : %d\n", newContext->traced); fprintf (stderr, "parent value : %d\n", ((gst_method_context) OOP_TO_OBJ (_gst_this_context_oop))->traced); And if the traced value for the parent context is not nil any idea of the problem ? Gwenael _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk |
In reply to this post by Paolo Bonzini-2
> Thanks for your answser :) > > This is strange in the activate_new_context method I've done this : > > newContext = alloc_stack_context (size); > > newContext->traced = 0; You definitely want FROM_INT (0) or _gst_nil_oop here, or expect crashes at the next GC. > fprintf (stderr, "traced value : %d\n", newContext->traced); > fprintf (stderr, "parent value : %d\n", ((gst_method_context) OOP_TO_OBJ > (_gst_this_context_oop))->traced); > > And if the traced value for the parent context is not nil any idea of the > problem ? nil is not zero, it is _gst_nil_oop (usually an hex value ending with 0x...800). Look at all callers of alloc_stack_context, in particular _gst_prepare_execution_environment. But, adding new instance variables to contexts is a no-no. :-) By the way, with your GSOC application having been accepted "with very high probability", I would like you to publish your code somewhere as soon as possible. I don't care in what state it is, don't be afraid of that. Paolo _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk |
On Monday 20 April 2009 12:33:20 you wrote:
> > Thanks for your answser :) > > > > This is strange in the activate_new_context method I've done this : > > > > newContext = alloc_stack_context (size); > > > > newContext->traced = 0; > > You definitely want FROM_INT (0) or _gst_nil_oop here, or expect crashes > at the next GC. > > > fprintf (stderr, "traced value : %d\n", newContext->traced); > > fprintf (stderr, "parent value : %d\n", ((gst_method_context) > > OOP_TO_OBJ (_gst_this_context_oop))->traced); > > > > And if the traced value for the parent context is not nil any idea of the > > problem ? > > nil is not zero, it is _gst_nil_oop (usually an hex value ending with > 0x...800). > > Look at all callers of alloc_stack_context, in particular > _gst_prepare_execution_environment. But, adding new instance variables > to contexts is a no-no. :-) > > By the way, with your GSOC application having been accepted "with very > high probability", I would like you to publish your code somewhere as > soon as possible. I don't care in what state it is, don't be afraid of > that. > Great It's fantastic :D, the code is there : http://bioskop.fr/svn/gst/GtkLauncher/ > Paolo _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk |
In reply to this post by Paolo Bonzini-2
On Monday 20 April 2009 12:33:20 you wrote:
> > Thanks for your answser :) > > > > This is strange in the activate_new_context method I've done this : > > > > newContext = alloc_stack_context (size); > > > > newContext->traced = 0; > > You definitely want FROM_INT (0) or _gst_nil_oop here, or expect crashes > at the next GC. > > > fprintf (stderr, "traced value : %d\n", newContext->traced); > > fprintf (stderr, "parent value : %d\n", ((gst_method_context) > > OOP_TO_OBJ (_gst_this_context_oop))->traced); > > > > And if the traced value for the parent context is not nil any idea of the > > problem ? > > nil is not zero, it is _gst_nil_oop (usually an hex value ending with > 0x...800). > > Look at all callers of alloc_stack_context, in particular > _gst_prepare_execution_environment. But, adding new instance variables > to contexts is a no-no. :-) > > By the way, with your GSOC application having been accepted "with very > high probability", I would like you to publish your code somewhere as > soon as possible. I don't care in what state it is, don't be afraid of > that. > > Paolo Is it possible to send a message to an object inside the methodsend_block_value ? _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk |
On Monday 20 April 2009 15:06:47 you wrote:
> On Monday 20 April 2009 12:33:20 you wrote: > > > Thanks for your answser :) > > > > > > This is strange in the activate_new_context method I've done this : > > > > > > newContext = alloc_stack_context (size); > > > > > > newContext->traced = 0; > > > > You definitely want FROM_INT (0) or _gst_nil_oop here, or expect crashes > > at the next GC. > > > > > fprintf (stderr, "traced value : %d\n", newContext->traced); > > > fprintf (stderr, "parent value : %d\n", ((gst_method_context) > > > OOP_TO_OBJ (_gst_this_context_oop))->traced); > > > > > > And if the traced value for the parent context is not nil any idea of > > > the problem ? > > > > nil is not zero, it is _gst_nil_oop (usually an hex value ending with > > 0x...800). > > > > Look at all callers of alloc_stack_context, in particular > > _gst_prepare_execution_environment. But, adding new instance variables > > to contexts is a no-no. :-) > > > > By the way, with your GSOC application having been accepted "with very > > high probability", I would like you to publish your code somewhere as > > soon as possible. I don't care in what state it is, don't be afraid of > > that. > > > > Paolo > > Is it possible to send a message to an object inside the > methodsend_block_value ? Instead of adding a new variable maybe I can reuse native_ip in the context structure ? Gwenael Casaccio _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk |
>> Is it possible to send a message to an object inside the
>> methodsend_block_value ? My naive answer would be, send_block_value is for blocks and send_message_internal is for methods. But without describing exactly what you're doing, we may just be running in circles. Everything is possible, but hear me when I said "no additional if's in the hot paths". I allowed Derek's profiler if because you can always change an "if (profiler)" to "if (some_weird_functionality) { if (profiler) ... }". > Instead of adding a new variable maybe I can reuse native_ip in the context > structure ? That would break the JIT, that I still dream about fixing one day. Paolo _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk |
Free forum by Nabble | Edit this page |