X hits on this document

PDF document

Program Transformations for Light-Weight CPU Accounting and Control in the Java Virtual Machine A ... - page 23 / 40

108 views

0 shares

0 downloads

0 comments

23 / 40

23

The SPP scheme should then have an overhead between those two settings, preferably closer to the lowest values.

6.2. Static Path Prediction

The goal of the scheme we call Static Path Prediction (SPP) is to identify sequences of accounting blocks to be conceptually merged into execution paths that can be accounted just once. Recall that paths diverge at each accounting block that ends with a conditional branch (i.e. essentially if instructions at the Java source code level). The con- crete idea of SPP is to initially update the consumption with the entire cost of the predicted path. Hence, whenever a branch does not take the direction that was predicted during the rewriting (thus we have a miss of the prediction), the predicted path is left, and a corresponding correction must be made to the CPU account, subtracting the unused part of the exited path, and adding the cost of the new path that is then started.

6.2.1. SPP Rewriting Example

if (h(x)) {

-->

if (h(x)) {

i(x);

i(x);

Figure 12. Example of Simple, SPP-optimized transformation scheme.

void f(int x) {

g(); while (x > 0) {

void f(int x) { ThreadCPUAccount cpu; cpu = ThreadCPUAccount.getCurrentAccount(); cpu.consumption += ...; if (cpu.consumption >= 0) cpu.triggerConsume(); g(); Start: cpu.consumption += ...; if (cpu.consumption >= 0) cpu.triggerConsume(); if (x > 0) {

}

}

}

}

  • --

    x;

} else { cpu.consumption -= } --x; goto Start; } cpu.consumption -= ...;

...; // misprediction

// misprediction

Figure 12 shows an example of the proposed transformation scheme, as an improvement on top of the Simple rewriting. Compared to the transformation of Figure 4, which illustrates the unoptimized Simple scheme, we can see that there are two fewer modifications of the consumption variable inside the loop, and that at some places, the

Document info
Document views108
Page views108
Page last viewedFri Dec 09 04:56:50 UTC 2016
Pages40
Paragraphs801
Words13591

Comments