1959ffdf65f280ee90b7944a8dd610564e7f99e69Stephen Kyle/*
2959ffdf65f280ee90b7944a8dd610564e7f99e69Stephen Kyle * Copyright (C) 2014 The Android Open Source Project
3959ffdf65f280ee90b7944a8dd610564e7f99e69Stephen Kyle *
4959ffdf65f280ee90b7944a8dd610564e7f99e69Stephen Kyle * Licensed under the Apache License, Version 2.0 (the "License");
5959ffdf65f280ee90b7944a8dd610564e7f99e69Stephen Kyle * you may not use this file except in compliance with the License.
6959ffdf65f280ee90b7944a8dd610564e7f99e69Stephen Kyle * You may obtain a copy of the License at
7959ffdf65f280ee90b7944a8dd610564e7f99e69Stephen Kyle *
8959ffdf65f280ee90b7944a8dd610564e7f99e69Stephen Kyle *      http://www.apache.org/licenses/LICENSE-2.0
9959ffdf65f280ee90b7944a8dd610564e7f99e69Stephen Kyle *
10959ffdf65f280ee90b7944a8dd610564e7f99e69Stephen Kyle * Unless required by applicable law or agreed to in writing, software
11959ffdf65f280ee90b7944a8dd610564e7f99e69Stephen Kyle * distributed under the License is distributed on an "AS IS" BASIS,
12959ffdf65f280ee90b7944a8dd610564e7f99e69Stephen Kyle * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13959ffdf65f280ee90b7944a8dd610564e7f99e69Stephen Kyle * See the License for the specific language governing permissions and
14959ffdf65f280ee90b7944a8dd610564e7f99e69Stephen Kyle * limitations under the License.
15959ffdf65f280ee90b7944a8dd610564e7f99e69Stephen Kyle */
16959ffdf65f280ee90b7944a8dd610564e7f99e69Stephen Kyle
17959ffdf65f280ee90b7944a8dd610564e7f99e69Stephen Kylepackage dexfuzz.executors;
18959ffdf65f280ee90b7944a8dd610564e7f99e69Stephen Kyle
19807f17831e2749d5765599df1c9fbc58af3c6c7cStephen Kyleimport dexfuzz.Options;
20959ffdf65f280ee90b7944a8dd610564e7f99e69Stephen Kyleimport dexfuzz.listeners.BaseListener;
21959ffdf65f280ee90b7944a8dd610564e7f99e69Stephen Kyle
22959ffdf65f280ee90b7944a8dd610564e7f99e69Stephen Kylepublic class X86OptimizingBackendExecutor extends Executor {
23959ffdf65f280ee90b7944a8dd610564e7f99e69Stephen Kyle
24959ffdf65f280ee90b7944a8dd610564e7f99e69Stephen Kyle  public X86OptimizingBackendExecutor(BaseListener listener, Device device) {
2583d3b79af2b607d2a1991f7438196263e7ea68efWojciech Staszkiewicz    super("x86 Optimizing Backend", 5, listener, Architecture.X86, device,
2683d3b79af2b607d2a1991f7438196263e7ea68efWojciech Staszkiewicz        /*needsCleanCodeCache*/ true, /*isBisectable*/ true);
27959ffdf65f280ee90b7944a8dd610564e7f99e69Stephen Kyle  }
28959ffdf65f280ee90b7944a8dd610564e7f99e69Stephen Kyle
29959ffdf65f280ee90b7944a8dd610564e7f99e69Stephen Kyle  @Override
3083d3b79af2b607d2a1991f7438196263e7ea68efWojciech Staszkiewicz  protected String constructCommand(String programName) {
31959ffdf65f280ee90b7944a8dd610564e7f99e69Stephen Kyle    StringBuilder commandBuilder = new StringBuilder();
32959ffdf65f280ee90b7944a8dd610564e7f99e69Stephen Kyle    commandBuilder.append("dalvikvm32 -Xcompiler-option --compiler-backend=Optimizing ");
332e44560338780dd1877f7cf8ac18e67a50ef0b2dBranislav Rankov    // The -Xno-dex-file-fallback option ensures that the execution does not default to
342e44560338780dd1877f7cf8ac18e67a50ef0b2dBranislav Rankov    // interpreter if compilations fails.
352e44560338780dd1877f7cf8ac18e67a50ef0b2dBranislav Rankov    commandBuilder.append("-Xno-dex-file-fallback ");
36807f17831e2749d5765599df1c9fbc58af3c6c7cStephen Kyle    if (Options.executeOnHost) {
37807f17831e2749d5765599df1c9fbc58af3c6c7cStephen Kyle      commandBuilder.append(device.getHostExecutionFlags()).append(" ");
38807f17831e2749d5765599df1c9fbc58af3c6c7cStephen Kyle    }
39959ffdf65f280ee90b7944a8dd610564e7f99e69Stephen Kyle    commandBuilder.append("-cp ").append(testLocation).append("/").append(programName).append(" ");
40959ffdf65f280ee90b7944a8dd610564e7f99e69Stephen Kyle    commandBuilder.append(executeClass);
4183d3b79af2b607d2a1991f7438196263e7ea68efWojciech Staszkiewicz    return commandBuilder.toString();
42959ffdf65f280ee90b7944a8dd610564e7f99e69Stephen Kyle  }
43959ffdf65f280ee90b7944a8dd610564e7f99e69Stephen Kyle}
44