All pastes #36478 Raw Edit

Untitled

public text v1 · immutable
#36478 ·published 2006-01-11 14:34 UTC
rendered paste body
/*
 * jitc_obj.c - Coder implementation for JIT object operations.
 *
 * Copyright (C) 2001  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifdef IL_JITC_CODE

static void JITCoder_CastClass(ILCoder *coder, ILClass *classInfo,
							   int throwException)
{
}

static void JITCoder_LoadField(ILCoder *coder, ILEngineType ptrType,
							   ILType *objectType, ILField *field,
							   ILType *fieldType)
{
	ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
	ILJitType   jitType;
	ILJitValue  base;
	ILJitValue  temp;

	jitType = _ILJitGetReturnType(fieldType, jitCoder->process);

	/*
	 * Do the verification early.
	 */
	jit_insn_check_null(jitCoder->jitFunction, 
				jitCoder->jitStack[jitCoder->stackTop - 1]);
	base = jitCoder->jitStack[jitCoder->stackTop - 1];

	temp = jit_insn_load_relative(jitCoder->jitFunction, base,
						field->offset, jitType);
	jitCoder->jitStack[jitCoder->stackTop - 1] =
			_ILJitValueConvertToStackType(jitCoder->jitFunction, temp);
}

static void JITCoder_LoadThisField(ILCoder *coder, ILField *field,
							   	   ILType *fieldType)
{
}

static void JITCoder_LoadStaticField(ILCoder *coder, ILField *field,
							         ILType *fieldType)
{
}

static void JITCoder_LoadFieldAddr(ILCoder *coder, ILEngineType ptrType,
							       ILType *objectType, ILField *field,
							       ILType *fieldType)
{
	ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
	ILJitValue  base;
	ILJitValue  offset;

	/*
	 * Do the verification early.
	 */
	jit_insn_check_null(jitCoder->jitFunction, 
				jitCoder->jitStack[jitCoder->stackTop - 1]);

	base = jitCoder->jitStack[jitCoder->stackTop - 1];

	jitCoder->jitStack[jitCoder->stackTop - 1] = 
			jit_insn_add_relative(jitCoder->jitFunction, base, (jit_nint)field->offset);

}

static void JITCoder_LoadStaticFieldAddr(ILCoder *coder, ILField *field,
					 ILType *fieldType)
{
}

static void JITCoder_StoreField(ILCoder *coder, ILEngineType ptrType,
							    ILType *objectType, ILField *field,
							    ILType *fieldType, ILEngineType valueType)
{
	ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
	ILJitValue  base;
	ILJitValue  value;
	ILJitValue  value2;
	ILJitType   jitType;

	/*
	 * Do the verification early.
	 */
	jit_insn_check_null(jitCoder->jitFunction, 
				jitCoder->jitStack[jitCoder->stackTop - 2]);
	base = jitCoder->jitStack[jitCoder->stackTop - 2];
	value = jitCoder->jitStack[jitCoder->stackTop - 1];

	jitType = _ILJitGetReturnType(fieldType, jitCoder->process);
	value2 = jit_insn_convert(jitCoder->jitFunction, value, jitType, 0);

	jit_insn_store_relative(jitCoder->jitFunction, base,
						field->offset, value2);
	JITC_ADJUST(jitCoder, -1);

}

static void JITCoder_StoreStaticField(ILCoder *coder, ILField *field,
				      ILType *fieldType, ILEngineType valueType)
{
}

static void JITCoder_SizeOf(ILCoder *coder, ILType *type);
static void JITCoder_CopyBlock(ILCoder *coder, ILEngineType destPtrType,
							   ILEngineType srcPtrType);

static void JITCoder_CopyObject(ILCoder *coder, ILEngineType destPtrType,
					    ILEngineType srcPtrType, ILClass *classInfo)
{
	/*
	 * Is it bad manners to call JITCoder_Sizeof, JITCoder_CopyBlock in here?
	 */
	JITCoder_SizeOf(coder, ILClassGetSynType(classInfo));

	/*
	 * JITCoder_Sizeof pushes the size on stackTop. And, the stack is exactly
	 * how CopyBlock wants it.
	 */
	JITCoder_CopyBlock(coder, destPtrType, srcPtrType);

}

static void JITCoder_CopyBlock(ILCoder *coder, ILEngineType destPtrType,
							   ILEngineType srcPtrType)
{
	ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
	ILJitValue  src;
	ILJitValue  dest;
	ILJitValue  size;
	
	/*
	 * Do the verification early.
	 */
	jit_insn_check_null(jitCoder->jitFunction, 
				jitCoder->jitStack[jitCoder->stackTop - 2]);
	jit_insn_check_null(jitCoder->jitFunction, 
				jitCoder->jitStack[jitCoder->stackTop - 3]);

	src = jitCoder->jitStack[jitCoder->stackTop - 2];
	dest = jitCoder->jitStack[jitCoder->stackTop - 3];

	size = jitCoder->jitStack[jitCoder->stackTop - 1];

	jit_insn_memcpy(jitCoder->jitFunction, dest, src, size);

	JITC_ADJUST(jitCoder, -3);
}

static void JITCoder_InitBlock(ILCoder *coder, ILEngineType ptrType);

static void JITCoder_InitObject(ILCoder *coder, ILEngineType ptrType,
				ILClass *classInfo)
{
	/*
	 * Similar to CopyObject
	 */
	JITCoder_SizeOf(coder, ILClassGetSynType(classInfo));

	/*
	 * JITCoder_Sizeof pushes the size on stackTop. And, the stack
	 * is exactly how InitBlock wants it.
	 */
	JITCoder_InitBlock(coder, ptrType);
}

static void JITCoder_InitBlock(ILCoder *coder, ILEngineType ptrType)
{
	ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
	ILJitValue  dest;
	ILJitValue  size;
	ILJitValue  value;
	
	/*
	 * Do the verification early.
	 */
	jit_insn_check_null(jitCoder->jitFunction,
				jitCoder->jitStack[jitCoder->stackTop - 3]);

	size = jitCoder->jitStack[jitCoder->stackTop - 1];
	value = jitCoder->jitStack[jitCoder->stackTop - 2];
	dest = jitCoder->jitStack[jitCoder->stackTop - 3];

	jit_insn_memset(jitCoder->jitFunction, dest, value, size);

	JITC_ADJUST(jitCoder, -3);
}

static void JITCoder_Box(ILCoder *coder, ILClass *boxClass,
					     ILEngineType valueType, ILUInt32 size)
{
}

static void JITCoder_BoxSmaller(ILCoder *coder, ILClass *boxClass,
					   		    ILEngineType valueType, ILType *smallerType)
{
}

static void JITCoder_Unbox(ILCoder *coder, ILClass *boxClass)
{
}

static void JITCoder_MakeTypedRef(ILCoder *coder, ILClass *classInfo)
{
}

static void JITCoder_RefAnyVal(ILCoder *coder, ILClass *classInfo)
{
}

static void JITCoder_RefAnyType(ILCoder *coder)
{
}

static void JITCoder_PushToken(ILCoder *coder, ILProgramItem *item)
{
}

static void JITCoder_SizeOf(ILCoder *coder, ILType *type)
{
}

static void JITCoder_ArgList(ILCoder *coder)
{
}

#endif	/* IL_JITC_CODE */