Fix seed bug for generating object ids for put (#120)

* fix seed bug for generating object ids for put

* fix clang-format
This commit is contained in:
Philipp Moritz
2016-12-13 00:54:38 -08:00
committed by Robert Nishihara
parent 24d2b42d86
commit 2152cd9f31
8 changed files with 53 additions and 10 deletions
+16 -2
View File
@@ -112,7 +112,10 @@ task_id compute_task_id(task_spec *spec) {
return task_id;
}
object_id compute_return_id(task_id task_id, int64_t return_index) {
object_id task_compute_return_id(task_id task_id, int64_t return_index) {
/* Here, return_indices need to be >= 0, so we can use negative
* indices for put. */
DCHECK(return_index >= 0);
/* TODO(rkn): This line requires object and task IDs to be the same size. */
object_id return_id = task_id;
int64_t *first_bytes = (int64_t *) &return_id;
@@ -122,6 +125,17 @@ object_id compute_return_id(task_id task_id, int64_t return_index) {
return return_id;
}
object_id task_compute_put_id(task_id task_id, int64_t put_index) {
DCHECK(put_index >= 0);
/* TODO(pcm): This line requires object and task IDs to be the same size. */
object_id put_id = task_id;
int64_t *first_bytes = (int64_t *) &put_id;
/* XOR the first bytes of the object ID with the return index. We add one so
* the first return ID is not the same as the task ID. */
*first_bytes = *first_bytes ^ (-put_index - 1);
return put_id;
}
task_spec *start_construct_task_spec(task_id parent_task_id,
int64_t parent_counter,
function_id function_id,
@@ -151,7 +165,7 @@ void finish_construct_task_spec(task_spec *spec) {
spec->task_id = compute_task_id(spec);
/* Set the object IDs for the return values. */
for (int64_t i = 0; i < spec->num_returns; ++i) {
*task_return_ptr(spec, i) = compute_return_id(spec->task_id, i);
*task_return_ptr(spec, i) = task_compute_return_id(spec->task_id, i);
}
}