Elyès Jouini
email: jouini@ceremade.dauphine.fr

Clotilde Napp
email: clotilde.napp@dauphine.fr

Gurus and beliefs manipulation

We analyze a model with two types of agents: standard agents and gurus, i.e. agents who have the ability to in ‡uence the other investors. Gurus announce their beliefs and act accordingly. Each investor has a preferred guru and follows his recommendations. Prices are determined through a classical Walras mechanism. Gurus are strategic: they take into account the impact of their announced beliefs on the other agents, hence on prices. At the Nash equilibrium, this leads to beliefs heterogeneity, to a positive correlation between optimism and risk aversion and to higher risk premia. The impact is stronger on the riskier assets.

Introduction

In the classical …nancial economics theory, decision makers are assumed to have homogenous and rational expectations. This assumption has been the basis for many developments in …nance. Among these developments, the portfolio selection model (Markowitz, 1952) and the Capital Asset Pricing Model (CAPM, [START_REF] Sharpe | Capital Asset Prices: A Theory of Market Equilibrium Under Conditions of Risk[END_REF][START_REF] Lintner | The valuation of risky assets and the selection of risky investments in stock portfolios and capital budgets[END_REF]) play an important role. Given their simplicity and empirical tractability, these models and their subsequent extensions have become a signi…cant cornerstone of theoretical and applied economics from insurance and …nancial theory to the theory of the …rm.

However, the last 30 years have seen an accumulation of empirical tests that invalidate the theoretical conclusions of these models based on the assumption of homogeneous and objective beliefs. Furthermore, it su¢ ces to observe the heterogeneity of analysts or professional forecasters forecasts or more generally of experts opinions to realize that this assumption is not realistic. In this paper, our aim is to analyze to what extent this heterogeneity may be generated by the presence of gurus that act strategically. We consider a model with two types of agents: "standard" investors and gurus (in ‡uential investors, newsletters writers,...). Like in Benabou-Laroque (2001), the "guru" we have in mind "issues forecasts but is also in the business of trading, for his own account or some investment …rm." In our model, gurus announce their beliefs and each investor adopts the announced belief of one guru. This corresponds to the …ndings of [START_REF] Fisher | Investor Sentiment and Stock Returns[END_REF] where it appears that "there is a positive relationship between changes in the sentiment of individual investors and that of newsletter writers". The gurus choose their "beliefs" strategically taking into account the impact of their announced beliefs on other agents hence on prices.

The following example quoted by [START_REF] Benabou | Using Privileged Information to Manipulate Markets: Insiders, Gurus, and Credibility[END_REF]) "provides the most dramatic illustration of prices reacting to someone's announcement".

In the nervous market of 1987, Mr Prechter has emerged as both prophet and deity, an adviser whose advice reaches so many investors that he tends to pull the market the way he has predicted it will move [International Herald Tribune, October 3, 1987] For credibility reasons gurus act according to their announced beliefs. These strategic beliefs are not true beliefs from the gurus point of view, however they correspond to what the investors truly believe, moreover they are interpreted as gurus' beliefs by econometricians who observe portfolio choices.

We tackle the following issues. Do gurus have incentives to announce beliefs other than their true beliefs? How are investors'beliefs a¤ected by the strategic interaction between gurus? Do the resulting beliefs exhibit optimism? pessimism? How are these possible biases related to the agents preferences? What is the impact of these beliefs on individual decisions? What is the impact of these beliefs on equilibrium characteristics such as prices and risk premium?

Our …ndings are the following. A strategic behavior leads to beliefs subjectivity and heterogeneity among the gurus even when gurus'initial beliefs coincide with the objective belief.

Optimism as well as pessimism can both emerge. The intuition is as follows. Consider a model with two gurus. For the more risk tolerant guru, his demand in the risky asset is positive, so that his expected utility from trade is decreasing in the price of the risky asset. The choice of a pessimistic belief is associated with a lower demand, hence to a lower price, and the optimal belief balances this bene…t of pessimism against the costs of worse decision making. The converse reasoning applies to the risk averse guru, who, at the equilibrium, has a negative demand in the risky asset and bene…ts from optimism. Depending on their levels of risk aversion, the agents adopt the beliefs of one of the gurus and we …nd a positive correlation across the agents between pessimism and risk tolerance.

Second, the representative agent belief, or the consensus belief, which is given by the average of the individual beliefs weighted by the risk tolerance, is pessimistic. Intuitively, the more risk tolerant agents make the market, and the consensus belief re ‡ects the characteristics of the more risk tolerant. Since we have just seen that the more risk tolerant are pessimistic, it is consistent to obtain a pessimistic consensus belief. Such a pessimistic bias is also obtained in empirical studies in a purely behavioral setting [START_REF] Ben Mansour | Is There a "Pessimistic"Bias in Individual Beliefs? Evidence from a Simple Survey[END_REF], in a decision theory framework [START_REF] Wakker | Testing and Characterizing Properties of Nonadditive Measures through Violations of the Sure-Thing Principle[END_REF] or in a market framework [START_REF] Giordani | Is there evidence of pessimism and doubt in subjective distributions? Implications for the risk premium puzzle[END_REF]. In particular, as underlined by [START_REF] Shefrin | A Behavioral Approach to Asset Pricing[END_REF] based on Wall $treet Week data "between 1983 and 2002, professional investors were unduly pessimistic, underestimating market returns".

As a consequence of the pessimistic bias at the aggregate level, the risk premium is greater than in the standard rational expectations equilibrium. The fact that a pessimistic bias and a positive correlation between risk tolerance and pessimism lead to an increase of the market price of risk has been underlined by [START_REF] Abel | Asset prices under heterogeneous beliefs: implications for the equity premium[END_REF], [START_REF] Calvet | Aggregation of heterogeneous beliefs and asset pricing in complete …nancial markets[END_REF], [START_REF] Detemple | Intertemporal asset pricing with heterogeneous beliefs[END_REF], [START_REF] Gollier | Who should we believe ? Collective risk taking with heterogeneous beliefs[END_REF] and Jouini-Napp (2006); in their models, beliefs are exogenously given. This increase of the risk premium is interesting in light of the risk-premium puzzle on …nancial markets.

The paper is organized as follows. Section 2 presents the main model and the results.

Section 3 provides three main extensions (considering private information, more than 2 assets, more than 2 gurus). Section 4 concludes. All proofs are provided in the Appendix.

The model and the results

We consider a model with a continuum of agents. Among these agents, there are 2 in ‡uential investors who have a wide audience. We do not assume that they have the capacity to move the markets by their own trades but only that they have, through their wide audience, the ability to largely in ‡uence the other investors. We will call them gurus and denote them by Guru j; j = 1; 2:

Gurus announce their beliefs and act accordingly in order to maintain their credibility. The announced beliefs are based on strategic considerations 1 .

The other agents in the economy believe that gurus are well informed or have speci…c ability to predict market movements. At a given date each agent has a preferred guru and adopts his beliefs. There are then 2 groups of agents: the agents in Group j (G j ) follow Guru j, j = 1; 2:

The gurus'game

We focus on a single period and consumption takes place at the end of the period. There is a single risky asset in the economy, whose payo¤ at the end of the period is denoted by e

x: We let p denote the unit price of the risky asset, which means that agents can sell their property rights on the risky asset against the delivery of the sure quantity p at the end of the period.

We assume that there is one unit of the risky asset in the economy and that it is uniformly distributed among the agents. As in the standard portfolio problem, agents determine the optimal composition of their portfolio, in other words their optimal exposure to the risk. The di¤erence with the standard model stems from the fact that agents adopt the beliefs of one of the two gurus and that the gurus take into account their impact as well as the impact of their followers on prices and can manipulate their beliefs to take advantage of this impact. For example, a guru, who is risk tolerant, hence willing to be quite highly exposed to the risk, or equivalently interested in buying a high quantity of the risky asset, could announce a more pessimistic belief and act as if he believed that the asset was less interesting (or as if he were less interested in buying the asset) in order to bene…t from a lower price.

We assume that agents have CARA utility functions for consumption, more precisely,

u i (c) = exp c i
where i > 0 denotes the degree of risk tolerance of agent i for i 2 [0; 1] and where i ! i is measurable. We denote by 1 = R G 1 i di and by 2 = R G 2 i di the aggregate risk tolerance in G 1 and G 2 . We have 1 + 2 = where is the aggregate risk tolerance in the economy 2 . Moreover, we assume that e x is normally distributed, with mean and variance 2 .

We assume that the gurus also have CARA utility functions, u j (c) = exp c j where j > 0 denotes the degree of risk tolerance of Guru j for j = 1; 2. Both gurus observe : However, Guru j announces a belief j and this belief is adopted by all the agents in G j : The belief j is then chosen strategically. For credibility reasons, gurus act according to their announced beliefs.

A possible justi…cation for such a behavior is that agents can observe gurus'portfolios and may eliminate a guru whose portfolio choices are not consistent with his announced forecasts.

As already noticed, the announced belief is not a true belief for the guru but it will be considered as such by an observer/econometrician who analyzes gurus portfolio choices. It is also a true belief for the other agents since they sincerely trust one of the gurus and adopt his announced belief as their own true belief.

For given announced beliefs ( 1 ; 2 ); the optimal demand i (p) of the risky asset that agent i will retain given price p maximizes the expected utility from trade

E i exp p + i (e x p)
i where E i corresponds to the expectation operator associated to agent i belief. If agent i adopts the belief of Guru j then the optimal demand is given by i

(p) = i j p 2 :
The total demand of Group j is given by

G j (p) = j j p 2 ;
and corresponds to the demand of a representative agent for Group j with belief j and risk tolerance j : As underlined, all the agents, including the Gurus, are in…nitesimal and the 2 A model with a continuum of agents permits to approximate models with a large number of agents. Furthermore, all pairs ( 1; 2) with 1 + 2 = are possible in such a model. The analysis would be essentially the same in a model with a …nite number of agents except that we should choose the 0 i s on a grid.

individual demands also are in…nitesimal. For a given price, the total demand of risky asset in the economy is then the sum of the total demands of Group 1 and of Group 2. The equilibrium price p( 1 ; 2 ) is then determined by the condition

1 1 p 2 + 2 2 p 2 = 1; (1)
and given by

p( 1 ; 2 ) = 1 1 + 2 2 2 : (2)
Moreover, replacing p by its expression in G j (p) we obtain that the aggregate optimal demand at the equilibrium for Group 1 (Group 2) are given by

G 1 = 1 1 + 2 1 2 2 G 2 = 2 1 + 1 2 1 2
and the part of the risk borne by Group j depends upon both his level of risk tolerance and his belief: Letting RP (resp. RP stdd ) denote the risk premium p in this setting (resp. in the standard setting where all beliefs coincide with the objective belief ) we obtain

RP ( 1 ; 2 ; 1 ; 2 ) = 2 + 1 1 + 2 2 = RP stdd + 1 1 + 2 2 (3)
which means that the risk premium in an economy with heterogeneous subjective beliefs is higher than in the standard rational expectations setting if and only if the belief of the representative agent, which is the risk tolerance weighted average of the individual beliefs, is pessimistic, where pessimistic is meant in the sense that the mean of the risky asset's payo¤ is underestimated. In such a setting, it is particularly interesting to explore when and why the representative agent is pessimistic. In the present paper, the individual beliefs result from the gurus beliefs which are determined endogenously. We shall then analyze their properties, especially in terms of pessimism, correlation between pessimism and risk tolerance and impact on the risk premium.

The demand of Guru j is determined, as usual, by his own level of risk tolerance j and by his announced belief j : Recall that gurus act according to their announced beliefs in order to maintain their credibility. The demand of Guru j is given by

j (p; j ) = j j p 2 : (4)
The utility level of Guru j is given by

U j ( 1 ; 2 ) = E u j p( 1 ; 2 ) + (x p( 1 ; 2 )) j (p( 1 ; 2 ); j ) = E exp 1 j p( 1 ; 2 ) + (x p( 1 ; 2 )) j (p( 1 ;
2 ); j ) :

Guru j acts strategically and chooses b j that maximizes his utility level

U j b i ; j = E exp 1 j p(b i ; j ) + (x p(b i ; j )) j (p(b i ; j ); j )
where b i denotes the strategy of Guru i and is taken as given. We emphasize that the choice of the belief c j is strategic: the guru believes that the mean of e x is but he behaves as if he truly believed that it is c j in order to take advantage of his impact (through his in ‡uence on other agents beliefs) on prices and to maximize his utility from pro…ts.

The gurus then play a game de…ned by payo¤ functions U j ; j = 1; 2 and their strategic variable is their belief j : The parameters of this game are ( 1 ; 2 ) and we denote it by

( 1 ; 2 ) :
De…nition 1 An equilibrium with strategic beliefs manipulation is a Nash equilibrium of the game ( 1 ; 2 ) ; i.e. a pair of strategies M = (b 1 ( 1 ; 2 ) ; b 2 ( 1 ; 2 )) for the gurus such that for any other pair of strategies M 0 di¤ ering only in the j-th component, for j = 1; 2; the strategy M yields a utility level no less than M 0 :

E u j p (M ) + (e x p (M )) j (M ) E u j p M 0 + e x p M 0 j M 0 :
Note that the risk tolerance levels involved in the price formula [START_REF] Abel | Asset prices under heterogeneous beliefs: implications for the equity premium[END_REF] are not those of the gurus but those of their respective groups. In particular, we may have 1 > 2 with 1 < 2 , i.e. the more risk tolerant guru may have a lower weight in the price formula than the other guru (or equivalently the risk tolerance level of his group is lower than the risk tolerance level of the other group). The payo¤ function then involves two di¤erent levels of risk tolerance, the individual level of risk tolerance of the guru under consideration through the form of the utility function and the level of risk tolerance of the group associated with that guru through the price formula. Our game is then di¤erent from an imperfect competition game where each agent would take into account his own direct impact on equilibrium prices in order to determine his optimal strategy (as in e.g. [START_REF] Jouini | Evolutionary strategic beliefs[END_REF].

Proposition 1 If the weight (or the risk tolerance level) of Group i is given by i ; the model admits a unique equilibrium with strategic beliefs manipulation, i.e. the game

( 1 ; 2 ) has a unique Nash equilibrium (b 1 ( 1 ; 2 ) ; b 2 ( 1 ; 2 )) with b 1 = + 1 2 1 2 2 + 2 2 1 + 2 2 1 2 1 2 1 2 2 2 ;
(5)

b 2 = + 1 2 1 2 2 + 2 2 1 + 2 1 1 2 1 2 1 2 1 2 : (6)

The groups'dynamics

We have so far considered the parameters i = R G i i di, i = 1; 2; as given. Let us now analyze how agents may choose their respective groups. We may imagine that the agents play several times the same game with possibly di¤erent values for at each step. After each step, the agents observe market realizations and compare them with gurus' predictions. They evaluate the performance of each guru and their probability of choosing a given guru for the next step is then related to the latter's success 3 . More generally, the performance evaluation of each guru by a given agent may be based on agent's own experience with this guru. In particular, agents may move from one guru to another based upon their initial priors, their own experience, their past choices and the observed realizations. In such a setting the choice of a guru is an individual decision and the switches from one guru to another do not necessarily occur at the same time for all agents. We may also imagine that gurus are ranked by independent agencies on the basis of the accuracy of their predictions and that the agents base their choice of a speci…c guru upon these rankings.

Whatever the dynamics is, the steady states should respect the following natural condition

jb i ( 1 ; 2 ) j = b j ( 1 ; 2 )
that re ‡ects the fact that in the long run gurus'predictions should have the same level of accuracy. Let us denote by

D = f( 1 ; 2 ) 2 R + R + : 1 + 2 = g.
De…nition An equilibrium for the groups' dynamics is an element

( 1 ; 2 ) of D such that jb 1 ( 1 ; 2 ) j = jb 2 ( 1 ; 2 ) j : Such an equilibrium ( 1 ; 2 ) is said to be stable if, in a neighborhood of ( 1 ; 2 ) ; we have jb 1 ( 1 ; 2 ) j < jb 2 ( 1 ; 2 ) j for 1 < 1 and jb 1 ( 1 ; 2 ) j > jb 2 ( 1 ; 2 ) j for 1 > 1 .
It is said to be globally stable if this property is satis…ed on the whole domain D.

The stability concept introduced in the previous de…nition is fairly natural. When the size of one of the two groups, let us say Group 1, is slightly modi…ed towards an increase, the relative accuracy of Guru 2 (resp. 1) increases leading to a migration of agents from Group 1 to Group 2.

Proposition 2 Let us assume that one guru is more risk tolerant than the average of the agents while the other guru is less risk tolerant than the average, i.e. 1 > > 2 : Then 1. There exists a unique equilibrium ( 1 ; 2 ) for the groups' dynamics. It is given as the unique solution 1 of

3 1 ( 1 2 ) 3 2 1 ( 1 2 ) + 2 1 ( 2 ) = 0: (7)
2. The equilibrium ( 1 ; 2 ) is globally stable.

3. At the equilibrium ( 1 ; 2 ), the utility level of a given agent is not a¤ ected by the choice of a speci…c guru.

4. If the gurus are on average as risk tolerant as the whole population, i.e. = 1 + 2 2 ; then 1 > 2 , the representative agent belief is pessimistic, i.e.

1 b 1 ( 1 ; 2 )+ 2 b 2 ( 1 ; 2 ) < ;
and the risk premium is increased, i.e. RP (b

1 ( 1 ; 2 ) ; b 2 ( 1 ; 2 ) ; 1 ; 2 ) > RP stdd : 5. If = 1 + 2 2
and if the two groups have the same number of agents, i.e.

R G 1 di = R G 2 di = 1 2
, then there is a positive correlation between pessimism and risk tolerance among the whole population.

The …rst assertion means that there is a unique distribution of risk tolerance among Group 1 and Group 2 for which the associated Nash equilibrium satis…es jb 1 j = jb 2 j leading to the same level of accuracy for both gurus. The second assertion means that for any initial distribution of risk tolerance among the two groups, any dynamics that favors the most accurate guru converges to the distribution ( 1 ; 2 ). The third assertion provides an additional stability result. Our initial stability concept is only based on the level of accuracy of gurus'predictions.

However, even if agents take their utility level into account in the choice of their guru, they will be indi¤erent between Guru 1 and Guru 2. The fourth assertion means that the more risk tolerant group is the group of the more risk tolerant guru and also the most pessimistic one when the gurus are on average as risk tolerant as the whole population. Since each group behaves like a representative agent whose risk tolerance is given by the total risk tolerance within the group it is natural to obtain that the more (less) risk tolerant group is in line with the more (less) risk tolerant guru. This in turn implies that the representative agent is pessimistic and the risk premium is increased. The condition introduced in 5. about the relative sizes of the groups is natural. Indeed, when agents are indi¤erent between Guru 1 and Guru 2 from both accuracy and utility point of views (as seen in 2. and 3.), there is no speci…c reason to choose one guru rather than the other one. If agents choose each of the two gurus with a probability 1 2 , then the two groups are of equal size, i.e.

R G 1 di = R G 2 di = 1 2 .
We then obtain a positive correlation between pessimism and risk tolerance among the whole population as in Ben Mansour et al.

(2006).

To conclude and roughly speaking, at a steady state and if the two gurus are on average as risk tolerant as the whole population, then the more risk tolerant guru is pessimistic, the less risk tolerant guru is optimistic and there is a positive correlation between pessimism and risk tolerance among the whole population. This implies that the strategic behavior leads to a higher risk premium.

Extensions

The model with private information

In the previous section, we assumed that the gurus observe the objective belief. Let us consider the situation where the two gurus have di¤erent initial beliefs: We assume that Guru i has an initial belief i and distorts it strategically. As previously, he acts as if he had a belief b i that is strategically determined by the maximization of the utility level

U i i ; c j = E i exp 1 j p( i ; c j ) + (x p( i ; c j )) i (p( i ; c j ); i )
where the equilibrium price p and Guru i's demand i are given by Equations ( 2) and ( 4) and where E i is the expectation operator associated to the prior of Guru i: The gurus play then a game de…ned by payo¤ functions U i ; i = 1; 2 and their strategic variable is their belief i : The parameters of this game are ( 1 ; 2 ; 1 ; 2 ) and we denote it by ( 1 ; 2 ; 1 ; 2 ) :

Proposition 3 If Guru i has an initial belief i and Group i has a weight (or a level of risk tolerance) i then the model admits a unique equilibrium with strategic beliefs manipulation, i.e. the game ( 1 ; 2 ; 1 ; 2 ) has a unique Nash equilibrium (b 1 ; b 2 ) with

c 1 = 1 2 1 2 1 2 ( 1 + 2 ) 2 1 2 + 2 2 2 1 2 + 2 1 2 2 2 1 + 2 1 2 2 + 2 2 2 1 1 2 2 c 2 = 1 2 1 2 1 2 ( 1 + 2 ) 2 1 2 + 2 2 1 1 2 + 2 1 2 2 1 2 + 2 1 2 2 + 2 2 2 1 1 2 1 ;
and the equilibrium price is given by

p(c 1 ; c 2 ) = 1 2 1 2 1 2 ( 1 + 2 ) 1 2 1 2 1 2 1 2 2 + 2 2 1 1 2 1 2 1 2 2 (8)
When the di¤erent initial beliefs correspond to di¤erences of opinions, then there is no relevant informational content in the equilibrium price. However, if the di¤erent initial beliefs result from di¤erent signals received by the agents, then the equilibrium price transmits relevant information and the right concept to use is the concept of rational expectations equilibrium.

Let us assume that the agents have the same initial prior x N ; 2 and that Guru i; for i = 1; 2; observes a signal ỹi = x + "i where "1 and "2 are independent and follow the same distribution N 0; 2 " : Guru i's belief after the observation of a given realization y i is then given by N i ; 2 with i = + (y i )

2 2 " + 2 and 2 = 2 2 " 2 " + 2 :
In such a model with private information a rational expectations equilibrium with strategic beliefs manipulation is de…ned by a pair of announced beliefs (b 1 (y 1 ; y 2 ) ; b 2 (y 1 ; y 2 )) and by a price functional P (y 1 ; y 2 ) such that P (y 1 ; y 2 ) = 1 b 1 (y 1 ;y 2 )+ 2 b 2 (y 1 ;y 2 ) 2 (i.e. the markets clear when Group 1 follows the announced belief of Guru 1 and Group 2 follows the announced belief of Guru 2) and the belief b i (y 1 ; y 2 ) of Guru i maximizes his expected utility

U i i ; c j = E exp 1 i p( i ; c j ) + (x p( i ; c j )) i (p( i ; c j ); i ) y i; P (y 1 ; y 2 )
where the price functional p( i ; j ) is de…ned by Equation 4(2), where the belief of Guru j is considered as given and where the expectation is conditional to the private information of Guru i and to the public information conveyed by prices.

Following Equation ( 8), when the agents only take into account their private information, the equilibrium price is given by

p(c 1 ; c 2 ) = 1 2 1 2 ( + ( y ) 2 2 " + 2 ) 1 2 1 2 1 2 1 2 2 + 2 2 1 1 2 1 2 1 2 2 (9)
where y = y 1 +y 2 2

is the average signal.

The equilibrium price is then fully revealing and each agent is able to infer the average signal from price observation. Since the average signal is a su¢ cient statistics of all the agents' available information, then the agents share the same belief about x after the observation of the equilibrium price and it is given by N ; 2 where = + ( y )

2 1 2 2 " + 2 and 2 = 2 2 " 2 " +2 2 :
Everything works as if both agents had observed a same signal y = y 1 +y 2 2 which variance is given by 2 " 2 : As usual, it is easy to check that the fully revealing rational expectations equilibrium corresponds to a standard equilibrium where the agents would share their information before trading. All the information contained in the price is then already used by the agents when they choose their strategic belief.

Proposition 4 If Guru i receives a private signal ỹi = x + "i where "1 and "2 are independent and follow the same distribution N 0; 2 " and if Group i has a weight i then ((b 1 (y 1 ; y 2 ) ; b 2 (y 1 ; y 2 ) ; p (y 1 ; y 2 ))

de…ned by b 1 (y 1 ; y 2 ) = + ( y 1 + y 2 2 ) 2 1 2 2 " + 2 + 1 2 1 2 2 + 2 2 1 + 2 2 1 2 1 2 1 2 2 2 2 " 2 " + 2 2 ; b 2 (y 1 ; y 2 ) = + ( y 1 + y 2 2 ) 2 1 2 2 " + 2 + 1 2 1 2 2 + 2 2 1 + 2 1 1 2 1 2 1 2 1 2 2 " 2 " + 2 2 ; p (y 1 ; y 2 ) = 1 2 1 2 ( + ( y 1 +y 2 2 ) 2 1 2 2 " + 2 ) 1 2 1 2 1 2 1 2 2 + 2 2 1 1 2 1 2 1 2 2 2 " 2 " + 2 2
is a rational expectations equilibrium with strategic beliefs manipulations.

To sum up, when the agents beliefs result from the observation of signals that are correlated with x; the resulting rational expectations equilibrium with strategic beliefs manipulation has the same characteristics as the equilibrium with strategic beliefs manipulation when the agents have the same initial belief N ; 2 :

On average over all possible signals, the average beliefs and price correspond to the equilibrium with strategic beliefs manipulation analyzed in the previous section when the distribution of x is assumed to be N ( ; 2 ): Hence, modulo a modi…cation of the variance of x, the results provided in Proposition 1 can be seen as corresponding to the average situation in a model with rational expectations and strategic behavior.

The model with two risky assets

The model is essentially the same as in Section 2 except that we now suppose that there are two risky assets in the economy, whose associated payo¤s at the end of the period are respectively denoted by e

x and e y: We let p (resp. q) denote the price of e x (resp. e y) and we assume that e

x and e y are normally distributed, more precisely e x N ; 2 and e y N ; $ 2 . We let denote the correlation between e x and e y; i.e., The de…nition and the notations are straightforward generalizations of those introduced in Section 2.

Proposition 5 1. For given 1 and 2 ; there exists a unique equilibrium with strategic beliefs manipulation ((b i ; b i ) ; i = 1; 2) where

b i ( 1 ; 2 ) = + 1 2 1 2 2 + 2 2 1 + 2 1 2 1 i 1 2 1 2 1 2 1 2 i 2 + $ b i ( 1 ; 2 ) = + 1 2 1 2 2 + 2 2 1 + 2 1 2 1 i 1 2 1 2 1 2 1 2 i $ 2 + $
M i ( 1 ; 2 ) = M + 1 2 1 2 2 + 2 2 1 + 2 1 2 1 i 1 2 1 2 1 2 1 2 i 2 M
where 2 M = $ 2 + 2 $ + 2 :

2. We have

b 1 b 2 b 1 b 2 = b 1 b 1 = 2 + $ $ 2 + $
and beliefs dispersion is larger for the asset that has higher variance.

3. The equilibrium risk premia for the …rst and the second asset as well as for the market portfolio are given by p = 1 2

1 2 2 1 2 2 2 1 2 1 1 2 2 + $ ; q = 1 2 1 2 2 1 2 2 2 1 2 1 1 2 $ 2 + $ ; M (p + q) = 1 2 1 2 2 1 2 2 2 1 2 1 1 2 2 M :
4. There exists a unique equilibrium ( 1 ; 2 ) for the groups'dynamics. It is given by Equation [START_REF] Calvet | Aggregation of heterogeneous beliefs and asset pricing in complete …nancial markets[END_REF], as in the one asset framework.

5. If the gurus are on average as risk tolerant as the whole population, i.e. = 1 + 2 2 ; then 1 > 2 and the market risk premium is increased

In fact, in the two assets framework everything works as in a one asset framework where the unique asset is the market portfolio whose average payo¤ is given by M = + and whose variance is given by 2 M = $ 2 + 2 $ + 2 . This means that the more risk tolerant (risk averse) group is pessimistic (resp. optimistic) at the aggregate level and the consensus belief is pessimistic at the aggregate level. The formulas for individual assets that are provided in the proposition are similar to those obtained in the one asset framework. However, for each asset, the variance term in the one-asset formula is replaced by the covariance of the considered asset payo¤s with the market portfolio payo¤s. Recall that in the Walrasian setting (CAPM setting), the equilibrium price for a given asset depends on the covariance of the payo¤s of this asset with the payo¤s of the market portfolio and not on the total variance of the asset payo¤s. Since the gurus modify their beliefs in order to manipulate the prices, it is natural to obtain optimal beliefs that depend on the covariance with the market portfolio and not on the total variance.

The aggregate level properties (pessimism, correlation between pessimism and risk tolerance,...)

are then retrieved at the individual assets level as far as these assets are positively correlated with the market portfolio.

It is interesting to note that these e¤ects are more pronounced for the riskier asset. Intuitively, since the gurus di¤er by their level of risk tolerance, more risk leads to more beliefs dispersion and hence to a more pronounced impact on the market for the riskier asset.

The model with more than 2 gurus

We assumed so far that there are only 2 gurus in the economy. This is a natural assumption when we only have one asset. Indeed, even if there are more than 2 gurus the condition that all gurus have the same level of prediction accuracy or that all beliefs are at the same distance of the objective belief implies that they will cluster in 2 groups with beliefs that are symmetric with respect to the objective belief: an optimistic one and a pessimistic one. When there are at least 2 assets, the situation is di¤erent. Let us illustrate this point in the 2 asset framework:

the condition that all gurus have beliefs ( i ; i ) that are at the same distance of the objective belief ( ; ) only imposes that all the ( i ; i ) are on a same circle centered on ( ; ) :

In the next, we fully analyze the 2 asset and 3 guru framework.

With the same notations as above, solving for the Nash equilibrium leads to i = 1 2

1 2 2 3 + 1 3 2 2 + 2 3 2 1 1 2 3 ( 1 2 + 1 3 + 2 3 ) + 2 i 1 1 2 + 1 3 + 2 3 i 2 + $ ; i = 1 2
1 2 2 3 + 1 3 2 2 + 2 3 2 1 1 2 3 ( 1 2 + 1 3 + 2 3 ) + 2 i 1 1 2 + 1 3 + 2 3 i $ 2 + $ :
In particular, for i = 1; 2; 3; we have

i i = 2 + $ $ 2 + $
and all the vectors ( i ; i ) are then proportional. Imposing that all the gurus have the same level of prediction accuracy (or that all beliefs are at the same distance of the objective beliefs) leads then to a situation where at least two gurus have exactly the same beliefs. Therefore, the 3 guru framework can be reduced to a 2 gurus framework. The same result can be obtained for N gurus.

Conclusion

When market opinions are driven by gurus and when these gurus act strategically, this leads to heterogeneous and antagonistic beliefs. The agents cluster in two groups (even if there are more than two gurus). The beliefs of the more risk averse group exhibit optimism while the beliefs of the more risk tolerant group exhibit pessimism. As a consequence, there is a positive correlation between pessimism and risk tolerance and the representative agent belief exhibits pessimism.

This induced pessimism of the representative agent is interesting in light of the risk premium puzzle. It is interesting to notice that the di¤erent e¤ects we exhibit (beliefs heterogeneity, representative agent pessimism, impact on the risk premium) are more pronounced for riskier assets.

This work suggests further investigation. It would be useful to analyze how our results can be transposed in a dynamic setting where agents then have dynamic strategies. We focused on a steady state but it would be interesting to analyze how the gurus dynamically interact, how their reputation evolves through time and how they converge to the steady state. (2 1 2 1 2 ) + 1 2 2 1 = 0: The discriminant associated to this polynomial equation in 2 1 is given by 4 1 2 ( 2 ) ( 1 ) which is negative.

Using Equations ( 5) and ( 6), the condition 1 = 2 is equivalent to

H( 1 ) 2 3 1 ( 1 2 ) 3
under the assumption 1 > > 2 ; we already proved that H(0) > 0 and H( ) < 0 and that H admits only one root on [0; ]. Let us denote by H this root. Second, we prove that G has only one root on [0; ] : Indeed, the sum of its roots is equal to 2 and we have G(0) > 0 and G( ) < 0: Let us denote by G this root. Third, we have K(0) > 0 and K( ) < 0 and it is easy to see that K has a unique root on [0; ] : Let us denote by K this root. We can easily check that H( G ) > 0 which gives us G < H : With similar arguments we can prove that H < K : Finally, we can easily show that we always have 2 > 1 :

We sum up these results in the following table where i is the symmetric of i with respect to ; i.e. i = 2 i :

0; G G ; H H ; K K ; G 1 > 1 < 1 < 1 < H 1 + 2 > 2 1 + 2 > 2 1 + 2 < 2 1 + 2 < 2 K 2 > 2 > 2 > 2 < ( ; 1 ; 2 ) < 1 < 2 1 < < 1 < 2 1 < 2 < < 2 1 < 2 < _ 1 _ 1 > 0 _ 1 > 0 _ 1 < 0 _ 1 < 0
By de…nition, we have 1 = H : Consequently, we have _ 1 > 0 for 1 < 1 and _ 1 < 0 for 1 > 1 :

: In particular, we have 1 > 2 . Let us prove that Group 1 is more pessimistic than Group 2 or equivalently that b 1 < 0: We have then to prove that G H < 0: This results directly from the table above: Group 1 and Guru 1 are then more pessimistic then Group 2 and Guru 2. Pessimism and risk tolerance are then positively correlated at the gurus level.

5. If the two groups are of equal size, the average belief is then the objective belief. The average risk tolerance in Group 1 (resp. Group 2) is then equal to 2 1 (resp. 2 2 ) and the covariance between optimism and risk tolerance is then given by ( 1 2 ) (b 1 ) < 0:

Proof of Proposition 3 When Guru 1 has an initial belief 1 and Guru 2 has an initial belief the belief b 1 being given and where p( 1 ; 2 ) = 1 1 + 2 2 2 (market clearing condition).

The …rst order conditions dA

  ;e y) $ : We also denote by ~ M e x + e y the market portfolio payo¤s. We assume that each guru can choose a belief, i.e. a pair (b i ; b i ) that maximizes his utility from trade and as previously we look for an equilibrium with strategic beliefs manipulation. The belief of agent i with respect to the average market portfolio payo¤ is denoted by b M i b i + b i :

and the associated average market portfolio payo¤ s b

1 = 2 leads to 2

 2

2 ;A 1 ( 1 ; b 2 ) = 1 1 p( 1 ; b 2 ) 2 ( 1 p( 1 ; b 2 )) + p( 1 ;the belief b 2 being given and such that b 2 maximizes A 2 (b 1 ; 2 ) = 2 2 p(b 1 ; 2 ) 2 ( 2

 21111211212122222 they announce beliefs (b 1 ; b 2 ) such that b 1 maximizes p(b 1 ; 2 )) + p(b 1 ;

1

 1

d 1 (b 1 ; b 2 ) = dA 2 d 2 (b 1 ;

 11221 b 2 ) = 0 can be rewritten as follows

We shall see in Section 3 that the announced beliefs may also be based on private information.

As in[START_REF] Föllmer | Equilibria in Financial Markets with Heterogeneous Agents: A Probabilistic Perspective[END_REF] the agents learn on gurus' ability and construct choice functions based on this learning. There is a substantial literature on such adaptative learning rules which are associated with "discrete choice" models; see e.g.,[START_REF] Anderson | Discrete choice theory of product di¤erentiation[END_REF]. Di¤erent forms of these rules have been used and accounts are given in[START_REF] Weisbuch | A formal approach to market organization: choice functions, mean …eld approximations and maximum entropy principle[END_REF] andBrock and Durlauf (2001a, 2001b).

Remark that, by construction, we have at the equilibrium P (y1; y2) = p(b 1 (y1; y2); b 2 (y1; y2)):

Appendix Proofs

Proof of Proposition 1 Guru 1 choses the belief b 1 that maximizes

where p( 1 ; 2 ) = 1 1 + 2 2 1 + 2 2 1 + 2 and where b 2 is considered as given. Symmetrically, Guru 2 choses the belief b 1 that maximizes

where b 1 is considered as given. Solving for dA 1

(5) and [START_REF] Brock | Interaction-based models[END_REF].

Proof of Proposition 2

1. Let us assume that j 1 j = j 2 j : This leads to

There is no solution associated to 1 = 2 : Indeed, using Equations ( 5) and ( 6), the condition

1 and solving this system for (b 1 ; b 2 ) gives the result.

Proof of Proposition 4 It su¢ ces to check that ((b 1 (y 1 ; y 2 ) ; b 2 (y 1 ; y 2 ) ; P (y 1 ; y 2 )) is a rational expectation equilibrium with strategic beliefs manipulation. Remark that P (y 1 ; y 2 ) satisfes the condition P (y 1 ; y 2 ) = 1 b 1 (y 1 ;y 2 )+ 2 b 1 (y 1 ;y 2 ) 2 and P (y 1 ; y 2 ) is then the equilibrium price when Guru 1 announces b 1 (y 1 ; y 2 ) and Guru 2 announces b 2 (y 1 ; y 2 ) : Since P (y 1 ; y 2 ) reveals

and since y 1 +y 2 2 is a su¢ cient statistics of all available information, everything works as if each agent would take expectations that are conditional to y 1 +y 2 2 : They would share then the same belief N ; 2 with = + ( y )

" + 2 and 2 = 2 2 " 2 " +2 2 : Their announced beliefs would then be determined by Equations ( 5) and ( 6) replacing ( ; 2 ) by ; 2 .

Proof of Proposition 5 When there are 2 assets and when Guru 1 announces ( 1 ; 1 ) and Guru 2 announces ( 2 ; 2 ) the optimal demands of Group i in asset 1 and in asset 2 are respectively given by

and by the market clearing condition, the equilibrium prices are given by

The optimal demands i and i of Guru i in asset 1 and in asset 2 are respectively given by

) :

Guru i maximizes then

with respect to ( i ; i ) the belief of the other guru being given. The …rst order conditions

= dA 2 d 2 = 0 can be rewritten as follows

(2 2 + 1 ) 1 2 :

Solving for ( i ; i ) gives 1. and 2. and 3.

Since we have

; the condition ( 1

be rewritten as follows j 1 j = j 2 j leading to the same equations as in Proposition 2. This proves 4. and 5.


David Röthlisberger

Marcus Denker

Éric Tanter

Unanticipated Partial Behavioral Reflection ⋆

Dynamic, unanticipated adaptation of running systems is of interest in a variety of situations, ranging from functional upgrades to onthe-fly debugging or monitoring of critical applications. In this paper we study a particular form of computational reflection, called unanticipated partial behavioral reflection, which is particularly well-suited for unanticipated adaptation of real-world systems. Our proposal combines the dynamicity of unanticipated reflection, i.e., reflection that does not require preparation of the code of any sort, and the selectivity and efficiency of partial behavioral reflection. First, we propose unanticipated partial behavioral reflection which enables the developer to precisely select the required reifications, to flexibly engineer the metalevel and to introduce the meta behavior dynamically. Second, we present a system supporting unanticipated partial behavioral reflection in Squeak Smalltalk, called Geppetto, and illustrate its use with a concrete example of a Seaside web application. Benchmarks validate the applicability of our proposal as an extension to the standard reflective abilities of Smalltalk.

Introduction

Dynamic adaptation of a running application makes it possible to apply changes to either the structure or execution of the application, without having to shut it down. This ability is interesting for several kinds of systems, e.g., contextaware applications, long-running systems that cannot afford to be halted, or for monitoring and debugging systems on-the-fly. Adaptation can be considered a priori by adopting adequate design patterns such as the strategy pattern [START_REF] Gamma | Design patterns: Abstraction and reuse of object-oriented design[END_REF], but such anticipation is not always possible nor is it desirable: potentially many parts of an application may have to be updated at some point. This is an area in which metaobject protocols, by providing implicit reification of some parts of an application [START_REF] Rao | Implementational reflection in Silica[END_REF], are very useful [START_REF] Kiczales | Metaobject protocols: Why we want them and what else they can do[END_REF][START_REF] Redmond | Supporting unanticipated dynamic adaptation of application behaviour[END_REF][START_REF] Tarr | Workshop on aspects and dimensions of concern: Requirements on, and challenge problems for, advanced separation of concerns[END_REF].

Reflection in programming languages is a paradigm that supports computations about computations, so-called metacomputations. Metacomputations and base computations are arranged in two different levels: the metalevel and the base level [START_REF] Smith | Reflection and semantics in a procedural language[END_REF][START_REF] Ferber | Computational reflection in class-based object-oriented languages[END_REF]. Because these levels are causally connected any modification to the metalevel representation affects any further computations on the base level [START_REF] Maes | Computational Reflection[END_REF]. In object-oriented reflective systems, the metalevel is formed in terms of metaobjects: a metaobject acts on reifications of program elements (execution or structure). If reifications of the structure of the program are accessed, then we talk about structural reflection; if reifications deal with the execution of the program, then we are referring to behavioral reflection.

This paper is concerned with a particular form of behavioral reflection, since Smalltalk already supports powerful structural reflective mechanisms. Following the work of McAffer on metalevel engineering [START_REF] Mcaffer | Engineering the meta level[END_REF], we adopt an operational decomposition of the metalevel: reifications represent occurrences of operations denoting the activity of the base program execution. Examples of operations are message sending, method execution, and variable accesses. An occurrence of an operation is a particular event (e.g., a particular sending of a message).

We focus on two particular enhancements of behavioral reflection that make it more appropriate in real-world systems. First, unanticipated behavioral reflection (UBR) enables the deployment of metaobjects affecting the behavior of a program while it is already running. This makes it possible to fully support unanticipated software adaptation [START_REF] Redmond | Supporting unanticipated dynamic adaptation of application behaviour[END_REF]. Second, an admitted issue of behavioral reflection is its overhead in terms of efficiency: jumping to the metalevel at runtime -reifying current computation and letting a metaobject perform some metalevel behavior -is powerful but costly. Partial behavioral reflection (PBR) has been proposed to overcome this issue, by letting users precisely select what needs to be reified, and when [START_REF] Tanter | Partial behavioral reflection: Spatial and temporal selection of reification[END_REF]. Furthermore, PBR allows for flexible engineering of the metalevel, making it possible to design a concern-based metalevel decomposition (i.e., where one metaobject is in charge of one concern in the base application) rather than the typical entity-based metalevel decomposition (e.g., one metaobject per object, or one metaobject per class). Hence it is possible to reuse or compose metaobjects of different concerns which greatly eases the engineering of the metalevel [START_REF] Mcaffer | Engineering the meta level[END_REF][START_REF] Tanter | Partial behavioral reflection: Spatial and temporal selection of reification[END_REF].

In this paper we propose unanticipated partial behavioral reflection (UPBR) which allows us to insert reflective behavior at runtime into a system (the "unanticipated" in this definition). The reifications are precisely selectable in spatial (which occurrences of which operations) and temporal (when those occurrences are reified) dimensions (the "partial" in UPBR). The metalevel behavior is flexibly engineered by means of fine-grained protocols and selection possibilities that supports gathering of heterogeneous execution points (i.e., occurrences of different operations in different classes and methods).

The contributions of this paper are (a) a motivation for the need of unanticipated partial behavioral reflection (UPBR), (b) an implementation of UPBR in Squeak Smalltalk, called Geppetto, (c) an illustration of the use of UPBR in the detection and resolution of a performance bottleneck in an application, without the need to actually stop the application. This is unique because the existing proposals of UBR do not fully support PBR, and reciprocally, the existing systems that truly support PBR are not able to provide full UBR.

The paper is organized as follows: in the next section we describe a running example that serves as the baseline for our motivation and illustration of our proposal. Section 3 then discusses existing reflective support in Smalltalk, as well as the MetaclassTalk extension, followed by an overview of proposals for UBR (Iguana/J) and PBR (Reflex). In Section 4 we describe how we establish an efficient and expressive approach for UPBR in Smalltalk using runtime bytecode manipulation [START_REF] Denker | Runtime bytecode transformation for Smalltalk[END_REF]. Section 4.3 is then dedicated to a description of how to use Geppetto, the framework providing UPBR in Smalltalk, by solving our running example. We describe the design of Geppetto in more detail in Section 5. Section 6 discusses some implementation issues and in Section 7 we report on some benchmarks validating the applicability of Geppetto. Section 8 concludes and highlights directions for future work.

Running Example

Let us consider a collaborative website (a Wiki), implemented using the Seaside web framework [START_REF] Ducasse | Seaside -a multiple control flow web application framework[END_REF]. When under high load, the system suffers from a performance problem. Suppose users are reporting unacceptable response times. As providers of the system, our goal is to find the source of this performance problem and then fix it. First, we want to get some knowledge about possible bottlenecks by determining which methods consume the most execution time. A simple profiler shall be applied to our Wiki application, but it is not possible to shutdown the server to install this profiler. During the profiling our users should still be able to use the Wiki system as usual. Furthermore, once all the necessary information is gathered, the profiler should be removed entirely from the system, again without being forced to halt the Wiki. We have also the strict requirement to profile the application in its natural environment and context, because unfortunately the performance bottleneck does not seem to occur in a test installation.

To profile method execution we use simple reflective functionalities. We just need to know the name and arguments of the method being executed, the time when this execution started and the time when it finished to gather statistical data showing which methods consume the most execution time. During the analysis of the execution time of the different methods we see that some very slow methods can be optimized by using a simple caching mechanism. We then decide to dynamically introduce a cache for these expensive calculations in order to solve our performance problem.

As we see in this simple but realistic example, the ability to use reflection is of wide interest for systems that cannot be halted but nonetheless require reflective behavior temporarily or permanently. Furthermore, this example proves that an approach to reflection has to fulfill two important requirements to be applicable in such a situation: first, the reflective architecture has to allow unanticipated installation and removal of reflective behavior into an application at runtime. A web application or any other server-based application can often not be stopped and restarted to install new functionality. Moreover, the use of reflection cannot be anticipated before the application is started, hence a preparation of the application to support the reflective behavior that we may want to use later is not a valid alternative here. So the reflective mechanisms have to be inserted in an unanticipated manner. Second, in order to be able to use reflection in a durable manner (e.g., for caching) in a real-world situation, the reflective architecture has to be efficient. This motivates the need for partial reflection allowing the programmer to precisely choose the places where reflection is really required and hence minimizing the costs for reflection by reducing the amount of costly reifications occurring at runtime. So to sum up, this example requires unanticipated partial behavioral reflection to be solved.

Related Work and Motivation

As discussed earlier, changing behavior reflectively at runtime is of great interest for all applications and systems that need to run continuously without interruption, such as servers which provide mission-critical applications. It should be possible to analyze and change the behavior of such a system without the need of stopping and restarting it.

We choose the Smalltalk [START_REF] Goldberg | Smalltalk 80: the Language and its Implementation[END_REF] dialect Squeak [START_REF] Ingalls | Back to the future: The story of Squeak, A practical Smalltalk written in itself[END_REF] to implement a dynamic approach to reflection which supports unanticipated partial behavioral reflection (UPBR), because Squeak represents a powerful and extensible environment, wellsuited to implement and explore the possibilities of UPBR. Before presenting our proposal, we discuss the current situation of reflective support in standard Smalltalk-80 as well as in the MetaclassTalk extension. We also discuss very related proposals formulated in the Java context, both for unanticipated behavioral reflection and for partial behavioral reflection.

Reflection in Smalltalk-80

Smalltalk is one of the first object-oriented programming languages providing advanced reflective support [START_REF] Rivard | Smalltalk: a reflective language[END_REF]. The Smalltalk approach to reflection is based on the metaclass model and is thus inherently structural [START_REF] Ferber | Computational reflection in class-based object-oriented languages[END_REF]. A metaclass is a class whose instances are classes, hence a metaclass is the metaobject of a class and describes its structure and behavior. In Smalltalk, message lookup and execution are not defined as part of the metaclass however. Instead they are hard-coded in the virtual machine. It is thus not possible to override in a sub-metaclass the method which defines message execution semantics. While not providing a direct model for behavioral reflection, we can nevertheless change the behavior using the message-passing control techniques presented in [START_REF] Ducasse | Evaluating message passing control techniques in Smalltalk[END_REF], or method wrappers [START_REF] Brant | Wrappers to the rescue[END_REF]. Also, the Smalltalk metamodel does not support the reification of variable accesses, so the expressiveness of behavioral reflection in current Smalltalk is limited.

Although reflection in Smalltalk can inherently be used in an unanticipated manner, the existing ad hoc support for behavioral reflection in Smalltalk is not efficient and does not support fine-grained selection of reification as advocated by partial behavioral reflection (PBR) [START_REF] Tanter | Partial behavioral reflection: Spatial and temporal selection of reification[END_REF]. For both reasons (limited expressiveness and lack of partiality), we have to extend the current reflective facilities of Smalltalk: this is precisely the aim of this paper.

Extended Behavioral Reflection in Smalltalk: MetaclassTalk

MetaclassTalk [START_REF] Bouraqadi | Un MOP Smalltalk pour l'étude de la composition et de la compatibilité des métaclasses[END_REF][START_REF] Bouraqadi | Safe metaclass composition using mixin-based inheritance[END_REF][START_REF] Bouraqadi | Towards unified aspect-oriented programming[END_REF] extends the Smalltalk model of metaclasses by actually having metaclasses effectively define the semantics of message lookup and instance variable access. Instead of being hard-coded in the virtual machine, occurrences of these operations are interpreted by the metaclass of the class of the currently-executing instance. A major drawback of this model is that reflection is only controlled at class boundaries, not at the level of methods or operation occurrences. This way MetaclassTalk confines the granularity of selection of behavioral elements towards purely structural elements. As Ferber says in [START_REF] Ferber | Computational reflection in class-based object-oriented languages[END_REF]: "metaclasses are not meta in the computational sense, although they are meta in the structural sense".

Besides the lack of fine-grained selection, MetaclassTalk does not allow for any control of the protocol between the base and the metalevel: it is fixed and standardized. It is not possible to control precisely which pieces of information are reified: MetaclassTalk always reifies everything (e.g., sender, receiver and arguments in case of a message send). Recent implementations of the Meta-classTalk model limit the number of effective reifications by only calling the metaclass methods if the metaclass indeed provides changed behavior. But even then, once a metaclass defines a custom semantics for an operation, all occurrences of that operation in all instances of the the class are reified. Hence Meta-classTalk provides a less ad-hoc means of doing behavioral reflection than in standard Smalltalk-80, but with a very limited support for partial behavioral reflection.

Unanticipated Behavioral Reflection: Iguana/J

Iguana/J is a reflective architecture for Java [START_REF] Redmond | Supporting unanticipated dynamic adaptation of application behaviour[END_REF] that supports unanticipated behavioral reflection, and a limited form of partial behavioral reflection.

With respect to unanticipated adaptation, with Iguana/J it is possible to adapt Java applications at runtime without being forced to shut them down and without having to prepare them before their startup for the use of reflection. However to bring unanticipated adaptation to Java, Iguana/J is implemented via a native dynamic library integrated very closely with the Java virtual machine via the Just-In-Time (JIT) compiler interface [START_REF] Redmond | Supporting unanticipated dynamic adaptation of application behaviour[END_REF]. This means that the Iguana architecture is not portable between different virtual machine implementations: e.g., the JIT interface is not supported anymore on the modern HotSpot Java virtual machine. Conversely, we aim at providing UPBR for Smalltalk in a portable manner, in order to widen the applicability of our proposal.

With respect to partiality, Iguana/J supports fine-grained metaobject protocols (MOPs), offering the possibility to specify which operations should be reified. However, precise operation occurrences of interest cannot be discriminated, nor can the actual communication protocol between the base and metalevels be specified. This can have unfortunate impact on performance, since a completely reified occurrence is typically around 24 times slower than a non-reified one [START_REF] Redmond | Supporting unanticipated dynamic adaptation of application behaviour[END_REF].

Partial Behavioral Reflection: Reflex

A full-fledged model of partial behavioral reflection was presented in [START_REF] Tanter | Partial behavioral reflection: Spatial and temporal selection of reification[END_REF]. This model is implemented in Reflex, for the Java environment.

Reflex fully supports partial behavioral reflection: it is possible to select exactly which operation occurrences are of interest, as well as when they are of interest. These spatial and temporal selection possibilities are of great advantage to limit costly reification. Furthermore, the exact communication protocol between the base and metalevel is completely configurable: which method to call on the metaobject, pieces of information to reify, etc. The model of links adopted by Reflex, which consists of an explicit binding of a cut (set of operation occurrences) and an action (metaobject), also gives total control over the decomposition of the metalevel: a given metaobject can control a few occurrences of an operation in some objects as well as some occurrences of other operations in possibly different objects. Hence metalevel engineering is highly flexible, which makes it possible to directly support a concern-based metalevel decomposition, and this is precisely what is required to support aspect-oriented programming [START_REF] Tanter | Partial behavioral reflection: Spatial and temporal selection of reification[END_REF][START_REF] Tanter | A versatile kernel for multi-language AOP[END_REF].

The limitation of Reflex however lies in its implementation context: being a portable Java extension, Reflex works by transforming bytecode. Hence, although reflective behavior occurs at runtime, reflective needs have to be anticipated at load time. This means that Reflex does not allow a programmer to insert new reflective behavior affecting already-loaded classes into a running application. Instead, the programmer is forced to stop the application, define the reflective functionality required and to reload the application to insert this metabehavior. Links can be deactivated at runtime, but at a certain residual cost, because the bottom line in Java is that class definitions cannot be changed once loaded.

Motivation

As we have seen in this section, although unanticipated partial behavioral reflection is highly attractive, no current proposals provide it. Smalltalk-80 is not well-suited for behavioral reflection, MetaclassTalk provides only a limited possibility of metalevel engineering, Iguana/J has limited partiality and implementation limitations, and Reflex has limited dynamicity. Our proposal, a reflective extension of Squeak supporting UPBR called Geppetto, implements the UBR features of Iguana/J and the PBR features of Reflex to form a powerful, open framework for UPBR which extends, enhances and completes the reflective model of Smalltalk in a useful and efficient way.

Unanticipated Partial Behavioral Reflection for Smalltalk

We first overview the model of partial behavioral reflection adopted by Geppetto, then discuss how we use bytecode manipulation to achieve unantici-pation, and then show how partial behavioral reflection can help to solve the problem introduced in Section 2.

Partial Behavioral Reflection in a Nutshell

Geppetto adopts the model of partial behavioral reflection (PBR) presented in [START_REF] Tanter | Partial behavioral reflection: Spatial and temporal selection of reification[END_REF], which we hereby briefly summarize. This model consists of explicit links binding hooksets to metaobjects (Figure 1). A hookset identifies a set of related operation occurrences of interest, at the base level. A metaobject is a standard object that is delegated control over a partial reification of an operation occurrence at runtime. A link specifies the causal connection between a hookset (base level) and a metaobject (metalevel). When occurrences of operations are matched by its hookset, the link invokes a method on the associated metaobject, passing it pieces of reified information. Exactly which method is called, and which pieces of information are passed, is specified in the link itself. So, the link specifies the expected metaobject protocol, and the metaobject can be any object fulfilling this protocol.

Several other attributes further characterize a link, such as the control that is given to the metaobject (i.e., that of acting before, after, or around the intercepted operation occurrence). A dynamically-evaluated activation condition can also be attached to the link, in order to determine if a link applies or not depending on any dynamically-computable criteria (e.g., the amount of free memory or the precise class of the currently-executing object).

As mentioned earlier, PBR achieves two main goals: (1) highly-selective reification, both spatial (which occurrences of which operation) and temporal (thanks to activation conditions), and (2) flexible metalevel engineering thanks to fine-grained protocol specification and the fact that a hookset can gather heterogeneous execution points (i.e., occurrences of different operations in different entities).

The following short example illustrates the above definitions. Recall the slow collaborative website mentioned in section 2. To profile this application we introduce dynamically a profiler analyzing the method #toughWork which we suspect of being responsible for the performance issues. First, we select this method by defining a hookset. This hookset also selects the operation to be reified, in this case the evaluation of the method #toughWork: toughWorks := Hookset inClass: 'WikiCore' inMethod: #toughWork. toughWorks operation: MethodEval.

Second, we specify the link which bridges the gap between the base level (i.e., method #toughWork) and the metalevel (i.e., the metaobject, an instance of class Profiler). The link also describes the call to the metaobject, i.e., which method to invoke on the metaobject, specified by passing a metalevel selector.

cache := Link id: #cache hookset: toughWorks metaobject: Profiler new. cache control: Control around. cache metalevelSelector: #profile:. After having installed this link by executing cache install the method #profile: of the metaobject will be executed on every call to method #toughWork of class WikiCore. The developer can provide an arbitrarily complex implementation of the profiler metaobject. See section 4.3 for a more elaborated version of this profiling example.

Bytecode Manipulation for Unanticipated Behavioral Reflection in Smalltalk

To enable unanticipated partial behavioral reflection in Squeak, the first step is to realize the model for partial reflection as described above. As we have seen in Section 3.1, Smalltalk (and thus Squeak) does not support behavioral reflection properly. To introduce behavioral reflection in a system that does not support it, we can either modify the interpreter (or virtual machine) or transform the code of programs. Modifying the interpreter necessarily sacrifices portability, unless the standard interpreter is actually provided as a sufficiently-open implementation. As Squeak is not implemented using an open interpreter, we use the program transformation approach. We can operate either on source code or on bytecode, but the important thing is, transformation should possibly be done while the program is running. The most appropriate way is arguably to work on bytecode, because it does not require the source code to be present. Squeak by itself does not however support runtime bytecode manipulation appropriately. Fortunately, most of the authors have been involved in ByteSurgeon, a system for runtime bytecode manipulation in Squeak [START_REF] Denker | Runtime bytecode transformation for Smalltalk[END_REF].

Following the principles of the implementation of Reflex for Java, we can therefore introduce reflective abilities via insertion of hooks into bytecode. But as opposed to Reflex, in Squeak this can be done at runtime. Since Smalltalk fully supports structural reflection at runtime, and ByteSurgeon extends these structural abilities with method body transformation, we can dynamically introduce selective reflective abilities in running programs.

Solving the Running Example with Geppetto

To illustrate the use of Geppetto, we now explain how to solve the problem introduced in Section 2. In order to find out where the performance issue comes from, we start by elaborating a metaobject protocol to profile the Wiki application. Once we identified the expensive methods that can be cached, we introduce a caching mechanism with Geppetto.

Profiling MOP Defining and introducing dynamically reflective behavior into an application consists of three steps: first, the specification of the places where metabehavior is required (e.g., in which classes and methods, for which objects) by configuring a hookset. Second, the definition of the metaobject protocol (e.g., which data is passed to which metaobject) by setting up one or more links. Third and finally, the installation of the defined reflective functionality.

For profiling method execution times of our Wiki application, we need to define a link, binding the appropriate hookset to a Profiler metaobject. The hookset consists of all method evalution occurrences in all classes of the Wiki application. Hence the hookset is defined as follows:

allExecs := Hookset new. allExecs inPackage: 'Wiki'; operation: MethodEval.

All classes of the Wiki package are of interest, and any occurrences of a method evaluation as well. Now we have to specify which method of the metaobject has to be called, and when. In order to be able to determine the execution time of a method, the profiler acts around method evaluations, recording the time at which execution starts and ends, and computing the execution time. The link, called profiler, know the metaobject to invoke, an instance of class Profiler: profile := Link id: #profiler hookset: allExecs metaobject: Profiler new. profile control: Control around.

The profiler therefore needs to receive as parameters the selector being called, the currently-executing instance, and the arguments. Its method to call is thus profileMethod:in:withArguments:. This protocol is described by sending the following message to the profile link: The class Parameter is used to describe exactly which information should be reified and how it is passed to the meta level. See Section 5 for more information.

Profiler is a conventional Smalltalk class, whose instances are in charge of handling the task of profiling. For the sake of conciseness, we do not explain the implementation of such a profiler. Finally, to effectively install the link, we just need to execute: profile install.

and Geppetto inserts all required hooks. From now on, all method executions in the Wiki application get reified and the Profiler metaobject starts gathering data.

Now suppose that based on the gathered data, we determine that a particular method is indeed taking much time: #toughWork: of our Wiki Worker objects. It fortunately happens that this method can seemingly benefit from a simple caching mechanism. We can now completely remove the profiling functionality from the Wiki, going back to normal execution, without reification at all. This is achieve by simply executing: profile uninstall.

Geppetto then dynamically removes all hooks from the application code, hence further execution is not subject to any extra slowdown at all.

Caching MOP We now explain how the caching functionality is dynamically added with Geppetto. First, we define the hookset, and then the link: The sole piece of information that is reified is the first argument passed to the #toughWork: method, denoted with Parameter arg1. Cache is a Smalltalk class whose instances manage caching (based on single parameter values). In the #cacheFor: method, we first check if the cache contains a value for the passed argument. If so, this value is returned by the metaobject. Else, the metaobject proceeds with the replaced operation of the base level, takes the result answered by this operation via #proceed and returns this value after having stored it into the cache: In order to be able the to proceed with the original operation the class of the metaobject has to inherit from the generic class ProceedMO. Every instance of subclasses of ProceedMO is allowed to proceed with the replaced operations. Installing the cache is simply done by executing cache install. Geppetto inserts the necessary hooks in the code, and from then on, all evaluations of the #toughWork: method are optimized by caching.

Although this example is pretty straightforward, it illustrates well the point of UPBR: one can easily add reflective features at runtime, with the possibility to completely remove them at any time. This fosters incremental and prototypical resolution of problems such as the one we have illustrated. For instance, if it turns out that the introduced caching is not effective enough, it can be uninstalled, and a more elaborate caching can be devised.

Geppetto Design

Geppetto instantiates the model of partial behavioral reflection previously presented, as summarized on Figure 2. A link binds a hookset to a metaobject, and is characterized by several attributes. A hookset specifies the operation it matches occurrences of, which can be either MethodEval, MsgSend, InstVarAccess or TempAccess. Hooksets can also be composed as will be explained later.

Spatial selection of operation occurrences in Geppetto can be done in a number of ways, as illustrated on Figure 1. Eventually, occurrences are selected within method bodies (or boundaries), by applying an operation selector, i.e., a predicate that can programmatically determine whether a particular occurrence is of interest or not. Coarser levels of selection are provided to speedup the selection process. First of all, one can eagerly specify the operation of which occurrences may be of interest. Furthermore, one can restrict a hookset to a given package, to a set of classes (using a class selector), and/or to a set of methods (using a method selector). Convenience methods are provided when an enumerative style of specification is preferred.

Thus far, hooksets are operation-specific. Like in Reflex, Geppetto supports hookset composition, so a hookset can match occurrences of different operations. Hooksets can be composed using union, intersection, and difference. If some hooks of different hooksets conflict with each other, e.g., more than one hookset affects a particular occurrence of a message send in a given method, then these hooks are automatically composed by Geppetto. In a composed hook every single hook is executed in sequence in the order of their installation time. See Section 6.3 for details about hook composition.

A Link object is created by giving an identifier, the hookset, and by specifying how the metaobject instance(s) are to be obtained. The block given for the metaobject creator is evaluated to bootstrap metaobject references. As a shortcut, one can directly give a metaobject instance, instead of a block; the given instance will then be shared among entities affected by the link.

A link is further characterized by several attributes:

Control defines when the metaobject associated to the link is given control over an operation occurrence: it can be either Before, After, BeforeAfter or Around. BeforeAfter means that the metaobject is called before and after the original operation, whereas Around replaces the operation. The replaced operation then can be executed by calling proceed, if the metaobject is an instance of a subclass of ProceedMO. -Scope determines the association scheme of a metaobject with respect to base entities. For instance, if the link has object scope, then each instance affected by the link has a dedicated metaobject for the link. The scope can also be class (one metaobject per class), or global (a unique metaobject for the link). -an ActivationCondition is a dynamically-evaluated predicate that determines if a link is active (that is, whether reification and delegation to the metaobject effectively occurs). A typical usage of an activation condition is to obtain object-level reifications: the condition can be used as a discriminator of instances that are affected or not by the considered link. -a CallDescriptor defines the communication protocol with the metaobject. A call descriptor embeds the selector of the message to be sent, the parameters to pass as well as how they are passed (i.e., as plain method arguments, packed into an array, or embedded in a wrapper object). Finally, for a link to be effective, it has to be dynamically installed by sending the install message to it. At any time, a link can be uninstalled via uninstall. Links have identifiers, which can be used to retrieve them from a global repository at any time (Link get: #linkID).

Implementation Issues

In this section we explain a crucial part of the implementation of Geppetto: the installation of hooks into the bytecode. As explained earlier, we have to dynamically install hooks at runtime to be able to apply reflection in an unanticipated manner into a running system. Therefore, we require a means to manipulate at runtime. For that purpose we use ByteSurgeon, a framework for runtime manipulation of bytecode in Squeak [START_REF] Denker | Runtime bytecode transformation for Smalltalk[END_REF]. Using this tool we do not have to work directly with bytecode. Instead we write our hooks in normal Smalltalk which we then pass to ByteSurgeon. Internally, ByteSurgeon will compile our code to bytecode and insert the resulting bytecode into compiled methods.

Adapting Method Binaries

To adapt the binary code of method, we first select the method in which we want to change the bytecode (recall that a method is defined as the combination of a class and a selector, e.g., WikiPage>>#document). Second, we instrument this method with one of the instrumentation methods added by ByteSurgeon to compiled methods, e.g., #instrumentSends: or #instrumentInstVars:, to access all the specific operations in a method, i.e., message sends or instance variables accesses, respectively. These instrumentation methods expect a block as single argument. In this block we have access to a block argument which denotes the current operation occurrence object. For a message send we get access to an instance of IRSend (this is part of the intermediate representation on which ByteSurgeon is based [START_REF] Denker | Runtime bytecode transformation for Smalltalk[END_REF]). Below is a short example showing how ByteSurgeon can be used to insert a simple piece of Smalltalk code into the method #document of class WikiPage: In this example we replace every send of the #size message occurring in the method #document of class WikiPage to simply return the constant 7. This example shows how to access different operations in a method (operation selection, i.e., message sending) and how to select different operation occurrences (intra-operation selection; i.e., message sends invoking #size) in a method.

During the instrumentation of a method the defined block is evaluated for every such operation in that method. To do intra-operation selection it is enough to specify a condition in the block, such as asking if the selector of an IRSend is of interest. Only if this condition is met the corresponding operation occurrence is adapted, either by replacing it or by inserting code before or after it. The code to be inserted is written as normal Smalltalk code directly in a string. In this string we can refer to dynamic information by using meta variables, such as <meta: #receiver> or <meta: #arguments> to reference respectively the receiver or the arguments of a method (more in [START_REF] Denker | Runtime bytecode transformation for Smalltalk[END_REF]).

Structure of a Hook

In Geppetto, hooks are inserted in bytecode to provoke reification and delegation at runtime, where and when needed. The execution of a hook is a three-step process:

-Checking if the link is active for the currently-executing object; -Reifying dynamic information and packing this information as specified by call descriptor of the link; Performing the actual delegation to the metaobject, by sending the message specified in the call descriptor, with the corresponding reified information.

When a link has to be installed, Geppetto evaluates the static selectors (package, class, method, etc.) and then generates an appropriate string of Smalltalk code based on the specification of the call descriptor of the link. This string is compiled and inserted by ByteSurgeon. For instance, for the cache link of Section 4.3, the generated Smalltalk code is: First, the activation condition is checked. Note that the link itself is available as a meta variable for ByteSurgeon. If the link is active for the currentlyexecuting object, then delegation occurs: the metaobject is retrieved from the link, and the cacheFor: message is sent with first argument as parameter.

The exact string generated depends on the call descriptor defining the message name, parameters, and passing mode. For instance if the passing mode is by array, it is necessary to first build up the array explicitly in the hook. The generated code also depends on the scope of the link (e.g., if the link has object scope, then retrieving the metaobject requires passing the currently-executing object).

Hook Composition

If more than one hookset is installed in a given application, some hooks of different hooksets may conflict with each other, for instance if two hooksets affect the same message send of a given method. Geppetto is capable of detecting and also solving such a conflict automatically at runtime during the installation every new link. Detecting a hook conflict is a two-fold process: First, Geppetto determines for every link being installed, if another link also manipulates a given method, i.e., if metalevel behavior is already installed in this method. Geppetto holds a global repository containing all installed links with a list of the affected classes and methods for each link. Querying this repository results in a collection of links affecting a given method. Second, Geppetto analyzes every instruction of a method to find out where exactly in the method body more than one link does install a hook. Concretely, the hook installer iterates over every instruction of such a method and tests for every conflicting link if it manipulates the current instruction. The following code illustrates this: As soon as the hook installer has detected all the instructions conflicting with already installed links as described above, it solves the conflict by collecting first all the hooks manipulating a given instruction. Second, all these collected hooks are installed in sequence before, after or instead of the original instruction, depending on the control attribute specified in the link. The order in the sequence is determined by the installation time of the conflicting links, the first installed link will be installed first.

Note that there is not always a conflict when two links manipulate the same instruction of a method. If one link e.g., executes metalevel behavior before the original instruction and the second one afterwards then these links do not conflict at this instruction. Hence the conflict detection algorithm has to take into account the controls of the links.

Finally, note that Geppetto adopts a simple automatic composition strategy; future work may include considering more advanced link composition strategies as supported by Reflex [START_REF] Tanter | Aspects of composition in the Reflex AOP kernel[END_REF].

Evaluation

We now report on preliminary micro-benchmarks that validate the performance of Geppetto by comparing it with other reflective frameworks and architectures. We measure the slowdown of a fully reified message send over a non-reified message send. In Table 3 we compare the reflective systems Iguana/J [START_REF] Redmond | Supporting unanticipated dynamic adaptation of application behaviour[END_REF], and MetaclassTalk [START_REF] Bouraqadi | Concern oriented programming using reflection[END_REF] to Geppetto. The measurement for Iguana/J was taken from [START_REF] Redmond | Supporting unanticipated dynamic adaptation of application behaviour[END_REF]. For MetaclassTalk and Geppetto, we performed the benchmarks on a Windows PC with an Intel Pentium 4 CPU 3.4 GHz and 3 GB RAM. The version of MetaclassTalk used was v0.3beta, Geppetto was running in Squeak 3.9. For a more detailed explanation and the source code of the benchmark, see [START_REF] Röthlisberger | Geppetto: Enhancing Smalltalk's reflective capabilities with unanticipated reflection[END_REF].

We are comparing systems to Geppetto that do not provide partial reflection. As mentioned earlier, the real performance gain of partial reflection comes from the fact that we are able to exactly control what to reify and thus are able to minimize the reification costs. This benchmark does not cover this use but lets Geppetto reify every information about a message send to be comparable with the other systems. The benchmark will thus only give an impression of the worst case, i.e., when Geppetto is doing full reification of a message send.

System

slowdown factor Geppetto 10.85 Iguana/J 24 MetaclassTalk 20

Table 3. Slowdowns of different reflective systems for the reification of message sends.

Because Iguana/J is using Java, we cannot do a direct time comparison with Geppetto. So we did such a comparison with MetaclassTalk, since both Geppetto and MetaclassTalk are running in the same environment. We implemented for the operations message sending and instance variable access the same metaobject protocol and the same behavior at the metalevel in both proposals to be able to compare the resulting execution time. The measured execution time includes the reification as well as the processing of the metalevel behavior. For message sending we reify the receiver, the selector and the arguments, for instance variable access the name of the variable and its value. Table 4 presents the results of this benchmark. For both operations, message send and instance variable access, we reified almost every possible information in Geppetto to get a reliable comparison with MetaclassTalk which does not support to control which information shall be reified, as described in Section 3.2. Hence Geppetto, supporting partial reification of information, will perform even better than the 2-to-3 times speedup against MetaclassTalk in cases where not every information about an operation occurrence is required.

To explain why Geppetto is so much faster than MetaclassTalk we have to understand that MetaclassTalk wraps every method (using MethodWrappers [START_REF] Brant | Wrappers to the rescue[END_REF]) by default to allow message receive to be reified even when called from a class not under the control of MetaclassTalk. Geppetto on the other hand does not try to provide reified massage reception in this case, as we requested only a reification of message sending. These preliminary benchmarks tend to validate that the applied model for partial behavioral reflection is efficient compared to other models. Hence the combination of PBR and UBR is indeed fruitful and successful, because UPBR enables us to use unanticipated reflection in an efficient and effective manner.

Conclusion and Future Work

In this paper, we have motivated a particular form of computational reflection, called unanticipated partial behavioral reflection, which is particularly wellsuited for unanticipated adaptation of real-world systems. Our proposal combines the dynamicity of unanticipated reflection, i.e., reflection that does not require preparation of the code of any sort, and the selectivity, efficiency and flexibility of partial behavioral reflection. We have presented a system for unanticipated partial behavioral reflection in Squeak , called Geppetto, illustrated its use with a concrete example of a Seaside web application. Preliminary benchmarks validate the applicability of our proposal as an extension to the standard reflective abilities of Smalltalk.

In the future, we plan to work mainly in two directions: the first is to improve Geppetto itself, the second consists of using it in a number of projects. As far as improvements to Geppetto itself are concerned, we plan to explore advanced scoping for reifications (control-flow based, and more generally, contextual) to give the metaprogrammer even more means to control where and when reification should occur. Another track is to redesign the backend of Geppetto: we decided to use bytecode transformation as we could leverage the fast and easy to use ByteSurgeon framework. But bytecode is a very low-level representation means to trade performance with expressiveness. We plan to extend the Smalltalk structural meta model to provide a high-level model of sub-method structure and explore its use for Geppetto. We are currently working on a number of projects that could benefit from Geppetto. We have experimented with back-in-time debugging [START_REF] Lewis | Debugging backwards in time[END_REF], but the prototype directly uses ByteSurgeon for now; we plan to explore how Geppetto can be used instead. Another interesting possibility is to use Geppetto as the basis for dynamic analysis [START_REF] Denker | Higher abstractions for dynamic analysis[END_REF].

Finally, we plan to explore dynamic aspects for Smalltalk with Geppetto. Because as argued in the body of work on versatile kernels for AOP [START_REF] Tanter | A versatile kernel for multi-language AOP[END_REF][START_REF] Tanter | Motivation and requirements for a versatile AOP kernel[END_REF], the flexible model of partial behavioral reflection on which both Reflex and Geppetto are based is particularly well-suited to serve as an underlying infrastructure for AOP. This would then allow Geppetto to provide more elaborate AOP features than what the other known dynamic AOP systems for Smalltalk [START_REF] Bergel | FacetS: First class entities for an open dynamic AOP language[END_REF][START_REF] Hirschfeld | AspectS -aspect-oriented programming with Squeak[END_REF] do at present.

Fig. 1 .

 1 Fig. 1. Links are explicit entities bindings hooksets (at the base level) to metaobjects, possibly subject to activation conditions.

  profile metalevelSelector: #profileMethod:in:withArguments: parameters: {Parameter selector. Parameter self. Parameter arguments.} passingMode: PassingMode plain.

  toughWorks := Hookset new. toughWorks inClass: Worker; inMethod: #toughWork:; operation: MethodEval. cache := Link id: #cache hookset: toughWorks metaobject: Cache new. cache control: Control around. cache metalevelSelector: #cacheFor: parameters: {Parameter arg1} passingMode: PassingMode plain.

  cacheFor: arg | result | (self cacheContains: arg) ifTrue: [ˆself cacheAt: arg]. result := self proceed. self cacheAt: arg put: result. ˆresult

Fig. 2 .

 2 Fig. 2. Class diagram of Geppetto design

  link := Link id: #profiler hookset: hs metaobjectCreator: [ Profiler new ]

(

  WikiPage>>#document) instrumentSends: [:send | send selector = #size ifTrue: [ send replace: '7']]

(

  <meta: #link> isActiveFor: self) ifTrue: [ <meta: #link> metaobject cacheFor: <meta: #arg1> ].

  conflictingLinks do: [:eachLink | (method ir allInstructionsMatching: eachLink hookset operationSelector) do: [:instr | "this instruction is manipulated by the given link" self addLinkToRepository: eachLink forInstr: instr. ].

Table 1 .

 1 Spatial Selection in Geppetto

	Selection Level	Example
	Package	hookset inPackage: 'Wiki'
	Class	hookset classSelector: [:class |class superclass = MyClass]
		hookset inClasses: { MyClass. YourClass. }
	Method	hookset methodSelector: [:meth |meth selector = #hello]
		hookset inMethods: { #hello. #bye. }
	Operation	hookset operation: MsgSend
	Operation Occurrence hookset operationSelector: [:send | send selector = #size]

Table 2 .

 2 Table 2 lists all possible parameters depending on the reified operation. Supported reified information

	Operation	Reified Data Description
	All Operations	context	execution context
		self	the object
		control	before, after or replace
	Message Send/	arguments	arguments as an array
	Method Evaluation argX	X th argument
		sender	sender object
		senderSelector sender selector
		receiver	receiver object
		selector	selector of method
		result	returned result (after only)
	Temp/InstVar Access name	name of variable
		offset	offset of variable
		value	value of variable
		newvalue	new value (write only)

Table 4 .

 4 Speedup of Geppetto over MetaclassTalk for reified message send and instance variable read access.

		MetaclassTalk (ms) Geppetto (ms) Speedup
	message send	108	46	2.3x
	instance variable read	272	92	2.9x

Acknowledgments. We acknowledge the financial support of the Swiss National Science Foundation for the projects "A Unified Approach to Composition and Extensibility" (SNF Project No. 200020-105091/1, Oct. 2004 -Sept. 2006) and "Analyzing, capturing and taming software change" (SNF Project No. 200020-113342, Oct. 2006 -Sept. 2008). É. Tanter is partially financed by the Millennium Nucleus Center for Web Research, Grant P04-067-F, Mideplan, Chile.