1 : // Copyright 2012 Google Inc. All Rights Reserved.
2 : //
3 : // Licensed under the Apache License, Version 2.0 (the "License");
4 : // you may not use this file except in compliance with the License.
5 : // You may obtain a copy of the License at
6 : //
7 : // http://www.apache.org/licenses/LICENSE-2.0
8 : //
9 : // Unless required by applicable law or agreed to in writing, software
10 : // distributed under the License is distributed on an "AS IS" BASIS,
11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : // See the License for the specific language governing permissions and
13 : // limitations under the License.
14 :
15 : #ifndef SYZYGY_REORDER_RANDOM_ORDER_GENERATOR_H_
16 : #define SYZYGY_REORDER_RANDOM_ORDER_GENERATOR_H_
17 :
18 : #include "syzygy/reorder/reorderer.h"
19 :
20 m : namespace reorder {
21 :
22 : // Orders blocks within sections using a pseudo-random shuffle.
23 m : class RandomOrderGenerator : public Reorderer::OrderGenerator {
24 m : public:
25 m : explicit RandomOrderGenerator(int seed);
26 m : virtual ~RandomOrderGenerator();
27 :
28 : // OrderGenerator implementation.
29 m : virtual bool OnCodeBlockEntry(const BlockGraph::Block* block,
30 m : RelativeAddress address,
31 m : uint32 process_id,
32 m : uint32 thread_id,
33 m : const UniqueTime& time) override;
34 m : virtual bool CalculateReordering(const PEFile& pe_file,
35 m : const ImageLayout& image,
36 m : bool reorder_code,
37 m : bool reorder_data,
38 m : Order* order) override;
39 :
40 m : private:
41 m : const uint32 seed_;
42 m : };
43 :
44 m : } // namespace reorder
45 :
46 : #endif // SYZYGY_REORDER_RANDOM_ORDER_GENERATOR_H_
|