[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-smalltalk] [PATCH] gst-profile
From: |
Derek Zhou |
Subject: |
Re: [Help-smalltalk] [PATCH] gst-profile |
Date: |
Sat, 28 Feb 2009 01:45:26 -0800 |
User-agent: |
KMail/1.9.9 |
On Thursday 26 February 2009 11:35:58 pm Paolo Bonzini wrote:
> Do you have a simple example (I can use delta to minimize it, send it
> offlist if there are privacy problems of any kind).
>
> Paolo
>
Update the patch try to cover more bases. The idea is to make sure when
_gst_record_profile is called the VM is in a self-consistant state so if GC
is triggered it won't mess up the memory.
Derek
--- orig/libgst/interp-bc.inl
+++ mod/libgst/interp-bc.inl
@@ -160,15 +160,15 @@
#define GET_CONTEXT_IP(ctx) TO_INT((ctx)->ipOffset)
#define SET_THIS_METHOD(method, ipOffset) do { \
- gst_compiled_method _method; \
- if UNCOMMON (_gst_raw_profile) \
- _gst_record_profile (method, ipOffset); \
- _method = (gst_compiled_method) \
+ OOP old_method_oop = _gst_this_method; \
+ gst_compiled_method _method = (gst_compiled_method) \
OOP_TO_OBJ (_gst_this_method = (method)); \
\
method_base = _method->bytecodes; \
- _gst_literals = OOP_TO_OBJ (_method->literals)->data;
\
+ _gst_literals = OOP_TO_OBJ (_method->literals)->data; \
ip = method_base + (ipOffset); \
+ if UNCOMMON (_gst_raw_profile) \
+ _gst_record_profile (old_method_oop, method, ipOffset); \
} while(0)
@@ -304,11 +304,11 @@
newContext = activate_new_context (header.stack_depth, sendArgs);
newContext->flags = MCF_IS_METHOD_CONTEXT;
- SET_THIS_METHOD (methodOOP, 0);
- _gst_self = receiver;
-
/* push args and temps, set sp and _gst_temporaries */
prepare_context ((gst_context_part) newContext, sendArgs, header.numTemps);
+ _gst_self = receiver;
+ SET_THIS_METHOD (methodOOP, 0);
+
}
void
@@ -391,11 +391,11 @@
/* prepare new state */
newContext = activate_new_context (header.stack_depth, sendArgs);
newContext->flags = MCF_IS_METHOD_CONTEXT;
- SET_THIS_METHOD (methodOOP, 0);
- _gst_self = receiver;
-
/* push args and temps, set sp and _gst_temporaries */
prepare_context ((gst_context_part) newContext, sendArgs, header.numTemps);
+ _gst_self = receiver;
+ SET_THIS_METHOD (methodOOP, 0);
+
}
@@ -427,11 +427,11 @@
(gst_block_context) activate_new_context (header.depth, numArgs);
closure = (gst_block_closure) OOP_TO_OBJ (closureOOP);
blockContext->outerContext = closure->outerContext;
+ /* push args and temps */
+ prepare_context ((gst_context_part) blockContext, numArgs, header.numTemps);
_gst_self = closure->receiver;
SET_THIS_METHOD (closure->block, 0);
- /* push args and temps */
- prepare_context ((gst_context_part) blockContext, numArgs, header.numTemps);
return (false);
}
--- orig/libgst/dict.h
+++ mod/libgst/dict.h
@@ -665,7 +665,7 @@
ATTRIBUTE_HIDDEN;
/* Entry point for the profiler. */
-extern void _gst_record_profile (OOP newMethod, int ipOffset)
+extern void _gst_record_profile (OOP oldMethod, OOP newMethod, int ipOffset)
ATTRIBUTE_HIDDEN;
#endif /* GST_DICT_H */
--- orig/libgst/dict.c
+++ mod/libgst/dict.c
@@ -2197,14 +2197,14 @@
is the accumulative cost for this method. */
void
-_gst_record_profile (OOP newMethod, int ipOffset)
+_gst_record_profile (OOP oldMethod, OOP newMethod, int ipOffset)
{
OOP profile = _gst_identity_dictionary_at (_gst_raw_profile,
- _gst_this_method);
+ oldMethod);
if UNCOMMON (IS_NIL (profile))
{
profile = identity_dictionary_new (_gst_identity_dictionary_class, 6);
- _gst_identity_dictionary_at_put (_gst_raw_profile, _gst_this_method,
+ _gst_identity_dictionary_at_put (_gst_raw_profile, oldMethod,
profile);
}
--- orig/libgst/interp.c
+++ mod/libgst/interp.c
@@ -1342,8 +1342,8 @@
_gst_this_context_oop = oop;
thisContext = (gst_method_context) OOP_TO_OBJ (oop);
- SET_THIS_METHOD (thisContext->method, GET_CONTEXT_IP (thisContext));
sp = thisContext->contextStack + TO_INT (thisContext->spOffset);
+ SET_THIS_METHOD (thisContext->method, GET_CONTEXT_IP (thisContext));
#if ENABLE_JIT_TRANSLATION
ip = TO_INT (thisContext->ipOffset);
--- orig/libgst/prims.def
+++ mod/libgst/prims.def
@@ -5942,7 +5942,7 @@
OOP oop1 = POP_OOP ();
if (_gst_raw_profile)
{
- _gst_record_profile (NULL, -1);
+ _gst_record_profile (_gst_this_method, NULL, -1);
SET_STACKTOP (_gst_raw_profile);
_gst_unregister_oop (_gst_raw_profile);
}