Exemplo n.º 1
0
/*
 * Store a value known to be not null in a local variable.
 */
static void _ILJitLocalStoreNotNullValue(ILJITCoder *coder,
										 ILUInt32 paramNum,
										 ILJitValue value)
{
	ILJitLocalSlot *slot = _ILJitLocalGet(coder, paramNum);

	jit_insn_store(coder->jitFunction, slot->value,
				   _ILJitValueConvertImplicit(coder->jitFunction,
											  value,
											  jit_value_get_type(slot->value)));

	slot->flags |= (_IL_JIT_VALUE_INITIALIZED | _IL_JIT_VALUE_NULLCHECKED);
}
Exemplo n.º 2
0
/*
 * Store a value in a parameter.
 */
static void _ILJitParamStoreValue(ILJITCoder *coder, ILUInt32 paramNum,
													 ILJitValue value)
{
	ILJitLocalSlot *slot = _ILJitParamGet(coder, paramNum);

#ifdef	_IL_JIT_ENABLE_INLINE
	if(slot->flags & _IL_JIT_VALUE_PROTECT)
	{
		if(!(_ILJitLocalSlotNewValue(coder, slot)))
		{
			return;
		}
	}
#endif
	jit_insn_store(coder->jitFunction, slot->value,
				   _ILJitValueConvertImplicit(coder->jitFunction,
											  value,
											  jit_value_get_type(slot->value)));

	slot->flags &= ~_IL_JIT_VALUE_NULLCHECKED;
}
Exemplo n.º 3
0
/*
 * Inline function to create a new string with the given length 
 */
static int _ILJitSystemStringNew(ILJITCoder *jitCoder,
								 ILMethod *method,
								 ILCoderMethodInfo *methodInfo,
								 ILJitStackItem *args,
								 ILInt32 numArgs)
{
	ILJitFunction jitFunction = ILJitFunctionFromILMethod(method);
	ILClass *stringClass = ILMethod_Owner(method);
	ILJitValue newString;
	ILJitValue callArgs[2];

	if(!jitFunction)
	{
		/* We need to layout the class first. */
		if(!_LayoutClass(ILExecThreadCurrent(), stringClass))
		{
			return 0;
		}
		if(!(jitFunction = ILJitFunctionFromILMethod(method)))
		{
			return 0;
		}
	}

#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS) && defined(_IL_JIT_ENABLE_DEBUG)
	if(jitCoder->flags & IL_CODER_FLAG_STATS)
	{
		ILMutexLock(globalTraceMutex);
		fprintf(stdout, "Inline System.String::NewString\n");
		ILMutexUnlock(globalTraceMutex);
	}
#endif

	/* We call the alloc functions. */
	/* They thow an out of memory exception so we don't need to care. */
	callArgs[0] = jit_value_create_nint_constant(jitCoder->jitFunction,
												 _IL_JIT_TYPE_VPTR,
												 (jit_nint)stringClass);
	if(!callArgs[0])
	{
		return 0;
	}
	callArgs[1] = _ILJitValueConvertImplicit(jitCoder->jitFunction,
						 					 _ILJitStackItemValue(args[0]),
											 _IL_JIT_TYPE_UINT32);
	if(!callArgs[1])
	{
		return 0;
	}
	newString = jit_insn_call_native(jitCoder->jitFunction,
									 "_ILJitStringAlloc",
									 _ILJitStringAlloc,
									 _ILJitSignature_ILJitStringAlloc,
				 					 callArgs, 2, 0);
	if(!newString)
	{
		return 0;
	}

	_ILJitStackPushValue(jitCoder, newString);
	return 1;
}