001/* 002 * This file is part of the Jikes RVM project (http://jikesrvm.org). 003 * 004 * This file is licensed to You under the Eclipse Public License (EPL); 005 * You may not use this file except in compliance with the License. You 006 * may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/eclipse-1.0.php 009 * 010 * See the COPYRIGHT.txt file distributed with this work for information 011 * regarding copyright ownership. 012 */ 013package org.jikesrvm.ia32; 014 015import static org.jikesrvm.ia32.BaselineConstants.STACKFRAME_FIRST_PARAMETER_OFFSET; 016import static org.jikesrvm.ia32.RegisterConstants.NUM_PARAMETER_GPRS; 017 018import org.jikesrvm.VM; 019import org.jikesrvm.runtime.Magic; 020import org.vmmagic.pragma.NoInline; 021import org.vmmagic.pragma.Uninterruptible; 022import org.vmmagic.unboxed.Address; 023 024/** 025 * Machine specific helper functions for dynamic linking. 026 */ 027@Uninterruptible 028public abstract class DynamicLinkerHelper { 029 030 /** 031 * Reach up two stack frames into a frame that is compiled 032 * with the DynamicBridge register protocol and grab 033 * the receiver object of the invoke (ie the first param). 034 * NOTE: assumes that caller has disabled GC. 035 * 036 * @return the receiver object for the method invocation 037 */ 038 @NoInline 039 public static Object getReceiverObject() { 040 Address callingFrame = Magic.getCallerFramePointer(Magic.getFramePointer()); 041 callingFrame = Magic.getCallerFramePointer(callingFrame); 042 Address location = Address.zero(); 043 if (0 < NUM_PARAMETER_GPRS) { 044 location = callingFrame.plus(STACKFRAME_FIRST_PARAMETER_OFFSET).loadAddress(); 045 046 } else { 047 VM.sysFail("DynamicLinerHelper: assumes at least one param passed in registers"); 048 } 049 return Magic.addressAsObject(location); 050 } 051}