Skip to content

Commit

Permalink
Adds nounwind specifier to core helper functions
Browse files Browse the repository at this point in the history
Issue: #17
Issue: #92
  • Loading branch information
0x7CFE committed Jul 17, 2016
1 parent 9d39182 commit 5263fe0
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions include/Core.ll
Original file line number Diff line number Diff line change
Expand Up @@ -153,23 +153,23 @@
;;;;;;;;;;;;;;;;;;;; functions ;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

define i1 @isSmallInteger(%TObject* %value) alwaysinline {
define i1 @isSmallInteger(%TObject* %value) alwaysinline nounwind {
; return reinterpret_cast<int32_t>(value) & 1;

%int = ptrtoint %TObject* %value to i32
%result = trunc i32 %int to i1
ret i1 %result
}

define i32 @getIntegerValue(%TObject* %value) alwaysinline {
define i32 @getIntegerValue(%TObject* %value) alwaysinline nounwind {
; return (int32_t) (value >> 1)

%int = ptrtoint %TObject* %value to i32
%result = ashr i32 %int, 1
ret i32 %result
}

define %TObject* @newInteger(i32 %value) alwaysinline {
define %TObject* @newInteger(i32 %value) alwaysinline nounwind {
; return reinterpret_cast<TObject>( (value << 1) | 1 );

%shled = shl i32 %value, 1
Expand All @@ -178,7 +178,7 @@ define %TObject* @newInteger(i32 %value) alwaysinline {
ret %TObject* %result
}

define i32 @getSlotSize(i32 %fieldsCount) alwaysinline {
define i32 @getSlotSize(i32 %fieldsCount) alwaysinline nounwind {
;sizeof(TObject) + fieldsCount * sizeof(TObject*)

%fieldsSize = mul i32 4, %fieldsCount
Expand All @@ -188,44 +188,44 @@ define i32 @getSlotSize(i32 %fieldsCount) alwaysinline {
}


define i32 @getObjectSize(%TObject* %this) alwaysinline {
define i32 @getObjectSize(%TObject* %this) alwaysinline nounwind {
%1 = getelementptr %TObject* %this, i32 0, i32 0, i32 0
%data = load i32* %1
%result = lshr i32 %data, 2
ret i32 %result
}

define %TObject* @setObjectSize(%TObject* %this, i32 %size) alwaysinline {
define %TObject* @setObjectSize(%TObject* %this, i32 %size) alwaysinline nounwind {
%addr = getelementptr %TObject* %this, i32 0, i32 0, i32 0
%ssize = shl i32 %size, 2
store i32 %ssize, i32* %addr
ret %TObject* %this
}

define i1 @isObjectRelocated(%TObject* %this) alwaysinline {
define i1 @isObjectRelocated(%TObject* %this) alwaysinline nounwind {
%1 = getelementptr %TObject* %this, i32 0, i32 0, i32 0
%data = load i32* %1
%field = and i32 %data, 1
%result = trunc i32 %field to i1
ret i1 %result
}

define i1 @isObjectBinary(%TObject* %this) alwaysinline {
define i1 @isObjectBinary(%TObject* %this) alwaysinline nounwind {
%1 = getelementptr %TObject* %this, i32 0, i32 0, i32 0
%data = load i32* %1
%field = and i32 %data, 2
%result = icmp ne i32 %field, 0
ret i1 %result
}

define %TClass** @getObjectClassPtr(%TObject* %this) alwaysinline {
define %TClass** @getObjectClassPtr(%TObject* %this) alwaysinline nounwind {
%pclass = getelementptr inbounds %TObject* %this, i32 0, i32 1
ret %TClass** %pclass
}

@SmallInt = external global %TClass

define %TClass* @getObjectClass(%TObject* %this) alwaysinline {
define %TClass* @getObjectClass(%TObject* %this) alwaysinline nounwind {
; TODO SmallInt case
%test = call i1 @isSmallInteger(%TObject* %this)
br i1 %test, label %is_smallint, label %is_object
Expand All @@ -237,44 +237,44 @@ is_object:
ret %TClass* %class
}

define %TObject* @setObjectClass(%TObject* %this, %TClass* %class) alwaysinline {
define %TObject* @setObjectClass(%TObject* %this, %TClass* %class) alwaysinline nounwind {
%addr = call %TClass** @getObjectClassPtr(%TObject* %this)
store %TClass* %class, %TClass** %addr
ret %TObject* %this
}

define %TObject** @getObjectFieldPtr(%TObject* %object, i32 %index) alwaysinline {
define %TObject** @getObjectFieldPtr(%TObject* %object, i32 %index) alwaysinline nounwind {
%fields = getelementptr inbounds %TObject* %object, i32 0, i32 2
%fieldPtr = getelementptr inbounds [0 x %TObject*]* %fields, i32 0, i32 %index
ret %TObject** %fieldPtr
}

define %TObject** @getObjectFields(%TObject* %this) alwaysinline {
define %TObject** @getObjectFields(%TObject* %this) alwaysinline nounwind {
%fieldsPtr = call %TObject** @getObjectFieldPtr(%TObject* %this, i32 0)
ret %TObject** %fieldsPtr
}

define %TObject* @getObjectField(%TObject* %object, i32 %index) alwaysinline {
define %TObject* @getObjectField(%TObject* %object, i32 %index) alwaysinline nounwind {
%fieldPtr = call %TObject** @getObjectFieldPtr(%TObject* %object, i32 %index)
%result = load %TObject** %fieldPtr
ret %TObject* %result
}

define %TObject** @setObjectField(%TObject* %object, i32 %index, %TObject* %value) alwaysinline {
define %TObject** @setObjectField(%TObject* %object, i32 %index, %TObject* %value) alwaysinline nounwind {
%fieldPtr = call %TObject** @getObjectFieldPtr(%TObject* %object, i32 %index)
store %TObject* %value, %TObject** %fieldPtr
ret %TObject** %fieldPtr
}

define %TObject* @getArgFromContext(%TContext* %context, i32 %index) alwaysinline {
define %TObject* @getArgFromContext(%TContext* %context, i32 %index) alwaysinline nounwind {
%argsPtr = getelementptr inbounds %TContext* %context, i32 0, i32 2
%args = load %TObjectArray** %argsPtr
%argsObj = bitcast %TObjectArray* %args to %TObject*
%arg = call %TObject* @getObjectField(%TObject* %argsObj, i32 %index)
ret %TObject* %arg
}

define %TObject* @getLiteralFromContext(%TContext* %context, i32 %index) alwaysinline {
define %TObject* @getLiteralFromContext(%TContext* %context, i32 %index) alwaysinline nounwind {
%methodPtr = getelementptr inbounds %TContext* %context, i32 0, i32 1
%method = load %TMethod** %methodPtr
%literalsPtr = getelementptr inbounds %TMethod* %method, i32 0, i32 3
Expand All @@ -284,40 +284,40 @@ define %TObject* @getLiteralFromContext(%TContext* %context, i32 %index) alwaysi
ret %TObject* %literal
}

define %TObject* @getTempsFromContext(%TContext* %context) alwaysinline {
define %TObject* @getTempsFromContext(%TContext* %context) alwaysinline nounwind {
%tempsPtr = getelementptr inbounds %TContext* %context, i32 0, i32 3
%temps = load %TObjectArray** %tempsPtr
%tempsObj = bitcast %TObjectArray* %temps to %TObject*
ret %TObject* %tempsObj
}

define %TObject* @getTemporaryFromContext(%TContext* %context, i32 %index) alwaysinline {
define %TObject* @getTemporaryFromContext(%TContext* %context, i32 %index) alwaysinline nounwind {
%temps = call %TObject* @getTempsFromContext(%TContext* %context)
%temporary = call %TObject* @getObjectField(%TObject* %temps, i32 %index)
ret %TObject* %temporary
}

define void @setTemporaryInContext(%TContext* %context, i32 %index, %TObject* %value) alwaysinline {
define void @setTemporaryInContext(%TContext* %context, i32 %index, %TObject* %value) alwaysinline nounwind {
%temps = call %TObject* @getTempsFromContext(%TContext* %context)
call %TObject** @setObjectField(%TObject* %temps, i32 %index, %TObject* %value)
ret void
}

define %TObject* @getInstanceFromContext(%TContext* %context, i32 %index) alwaysinline {
define %TObject* @getInstanceFromContext(%TContext* %context, i32 %index) alwaysinline nounwind {
%self = call %TObject* @getArgFromContext(%TContext* %context, i32 0)
%instance = call %TObject* @getObjectField(%TObject* %self, i32 %index)
ret %TObject* %instance
}

define void @setInstanceInContext(%TContext* %context, i32 %index, %TObject* %value) alwaysinline {
define void @setInstanceInContext(%TContext* %context, i32 %index, %TObject* %value) alwaysinline nounwind {
%self = call %TObject* @getArgFromContext(%TContext* %context, i32 0)
%instancePtr = call %TObject** @getObjectFieldPtr(%TObject* %self, i32 %index)
call void @checkRoot(%TObject* %value, %TObject** %instancePtr)
store %TObject* %value, %TObject** %instancePtr
ret void
}

define void @dummy() gc "shadow-stack" {
define void @dummy() nounwind gc "shadow-stack" {
; enabling shadow stack init on this module
ret void
}
Expand All @@ -336,7 +336,7 @@ declare %TByteObject* @newBinaryObject(%TClass*, i32)
;declare %TObject* @sendMessage(%TContext* %callingContext, %TSymbol* %selector, %TObjectArray* %arguments, %TClass* %receiverClass, i32 %callSiteOffset)
declare { %TObject*, %TContext* } @sendMessage(%TContext* %callingContext, %TSymbol* %selector, %TObjectArray* %arguments, %TClass* %receiverClass, i32 %callSiteOffset)

declare %TBlock* @createBlock(%TContext* %callingContext, i8 %argLocation, i16 %bytePointer)
declare %TBlock* @createBlock(%TContext* %callingContext, i8 %argLocation, i16 %bytePointer, i32 %stackTop)
declare { %TObject*, %TContext* } @invokeBlock(%TBlock* %block, %TContext* %callingContext)
;declare %TObject* @invokeBlock(%TBlock* %block, %TContext* %callingContext)

Expand Down

0 comments on commit 5263fe0

Please sign in to comment.