You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
714 B
41 lines
714 B
/*
|
|
* Copyright (c) 2018-present, Facebook, Inc.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
class HoistNoIndirectMod {
|
|
|
|
int id = 0;
|
|
|
|
public int increment() {
|
|
id = calcNext();
|
|
return id;
|
|
}
|
|
|
|
public int calcNext() {
|
|
return (id + 1);
|
|
}
|
|
|
|
public int calcSame() {
|
|
return id;
|
|
}
|
|
|
|
public int increment_dont_hoist_FP(int n) {
|
|
for (int i = 0; i < n; i++) {
|
|
id = calcNext(); // shouldn't be hoisted
|
|
}
|
|
return id;
|
|
}
|
|
|
|
public int modify_and_increment_dont_hoist_FP(int n) {
|
|
int p = 0;
|
|
for (int i = 0; i < n; i++) {
|
|
p += calcNext();
|
|
id = i;
|
|
}
|
|
return p;
|
|
}
|
|
}
|