2 * Copyright (C) 2014, United States Government, as represented by the
3 * Administrator of the National Aeronautics and Space Administration.
6 * The Java Pathfinder core (jpf-core) platform is licensed under the
7 * Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0.
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 package gov.nasa.jpf.vm.bytecode;
21 import gov.nasa.jpf.JPFException;
22 import gov.nasa.jpf.vm.ElementInfo;
23 import gov.nasa.jpf.vm.Instruction;
24 import gov.nasa.jpf.vm.MethodInfo;
25 import gov.nasa.jpf.vm.Scheduler;
26 import gov.nasa.jpf.vm.ThreadInfo;
29 * abstract base for InvokeInstructions
31 public abstract class InvokeInstruction extends Instruction {
33 public abstract MethodInfo getInvokedMethod();
35 public abstract String getInvokedMethodName();
36 public abstract String getInvokedMethodSignature();
37 public abstract String getInvokedMethodClassName();
40 * this does the lock registration/acquisition and respective transition break
41 * return true if the caller has to re-execute
43 protected boolean reschedulesLockAcquisition (ThreadInfo ti, ElementInfo ei){
44 Scheduler scheduler = ti.getScheduler();
45 ei = ei.getModifiableInstance();
47 if (!ti.isLockOwner(ei)){ // we only need to register, block and/or reschedule if this is not a recursive lock
49 // record that this thread would lock the object upon next execution if we break the transition
50 // (note this doesn't re-add if already registered)
51 ei.registerLockContender(ti);
52 if (scheduler.setsLockAcquisitionCG(ti, ei)) { // optional scheduling point
56 } else { // we need to block
57 ei.block(ti); // this means we only re-execute once we can acquire the lock
58 if (scheduler.setsBlockedThreadCG(ti, ei)){ // mandatory scheduling point
61 throw new JPFException("blocking synchronized call without transition break");
65 // locking will be done by ti.enter()