blob: bfae8a180def36e35fb7bb50262e074c597758c2 [file] [log] [blame]
Calin Juravle36eb3132017-01-13 16:32:38 -08001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ART_RUNTIME_DEXOPT_TEST_H_
18#define ART_RUNTIME_DEXOPT_TEST_H_
19
20#include <string>
21#include <vector>
22
23#include "dex2oat_environment_test.h"
24
25namespace art {
26
27class DexoptTest : public Dex2oatEnvironmentTest {
28 public:
Roland Levillainf73caca2018-08-24 17:19:07 +010029 void SetUp() override;
Calin Juravle36eb3132017-01-13 16:32:38 -080030
Yi Kong39402542019-03-24 02:47:16 -070031 void PreRuntimeCreate() override;
Calin Juravle36eb3132017-01-13 16:32:38 -080032
Roland Levillainf73caca2018-08-24 17:19:07 +010033 void PostRuntimeCreate() override;
Calin Juravle36eb3132017-01-13 16:32:38 -080034
35 // Generate an oat file for the purposes of test.
36 // The oat file will be generated for dex_location in the given oat_location
37 // with the following configuration:
38 // filter - controls the compilation filter
Calin Juravle36eb3132017-01-13 16:32:38 -080039 // with_alternate_image - if true, the oat file will be generated with an
40 // image checksum different than the current image checksum.
41 void GenerateOatForTest(const std::string& dex_location,
42 const std::string& oat_location,
43 CompilerFilter::Filter filter,
Calin Juravle5f9a8012018-02-12 20:27:46 -080044 bool with_alternate_image,
Nicolas Geoffray35de14b2019-01-10 13:10:36 +000045 const char* compilation_reason = nullptr,
46 const std::vector<std::string>& extra_args = {});
Calin Juravle36eb3132017-01-13 16:32:38 -080047
Vladimir Markoe0669322018-09-03 15:44:54 +010048 // Generate an odex file for the purposes of test.
Calin Juravle36eb3132017-01-13 16:32:38 -080049 void GenerateOdexForTest(const std::string& dex_location,
50 const std::string& odex_location,
Vladimir Markoe0669322018-09-03 15:44:54 +010051 CompilerFilter::Filter filter,
Nicolas Geoffray35de14b2019-01-10 13:10:36 +000052 const char* compilation_reason = nullptr,
53 const std::vector<std::string>& extra_args = {});
Calin Juravle36eb3132017-01-13 16:32:38 -080054
55 // Generate an oat file for the given dex location in its oat location (under
56 // the dalvik cache).
57 void GenerateOatForTest(const char* dex_location,
58 CompilerFilter::Filter filter,
Calin Juravle36eb3132017-01-13 16:32:38 -080059 bool with_alternate_image);
60
61 // Generate a standard oat file in the oat location.
62 void GenerateOatForTest(const char* dex_location, CompilerFilter::Filter filter);
63
Vladimir Markob9c29f62019-03-20 14:22:51 +000064 bool Dex2Oat(const std::vector<std::string>& args, std::string* error_msg);
Nicolas Geoffray3d8a78a2018-08-29 21:10:16 +000065
Calin Juravle36eb3132017-01-13 16:32:38 -080066 private:
Calin Juravle36eb3132017-01-13 16:32:38 -080067 // Reserve memory around where the image will be loaded so other memory
68 // won't conflict when it comes time to load the image.
69 // This can be called with an already loaded image to reserve the space
70 // around it.
71 void ReserveImageSpace();
72
73 // Reserve a chunk of memory for the image space in the given range.
74 // Only has effect for chunks with a positive number of bytes.
75 void ReserveImageSpaceChunk(uintptr_t start, uintptr_t end);
76
77 // Unreserve any memory reserved by ReserveImageSpace. This should be called
78 // before the image is loaded.
79 void UnreserveImageSpace();
80
Vladimir Markoc34bebf2018-08-16 16:12:49 +010081 std::vector<MemMap> image_reservation_;
Calin Juravle36eb3132017-01-13 16:32:38 -080082};
83
84} // namespace art
85
86#endif // ART_RUNTIME_DEXOPT_TEST_H_