- [MagicId] -- Its register assignments
- -- (possibly empty)
-
-getEntryConvention :: Name -- Function being applied
- -> LambdaFormInfo -- Its info
- -> [PrimRep] -- Available arguments
- -> FCode EntryConvention
-
-getEntryConvention name lf_info arg_kinds
- = nodeMustPointToIt lf_info `thenFC` \ node_points ->
- returnFC (
-
- -- if we're parallel, then we must always enter via node. The reason
- -- is that the closure may have been fetched since we allocated it.
-
- if (node_points && opt_Parallel) then ViaNode else
-
- -- Commented out by SDM after futher thoughts:
- -- - the only closure type that can be blackholed is a thunk
- -- - we already enter thunks via node (unless the closure is
- -- non-updatable, in which case why is it being re-entered...)
-
- case lf_info of
-
- LFReEntrant _ _ arity _ ->
- if arity == 0 || (listLengthCmp arg_kinds arity == LT) then
- StdEntry (mkStdEntryLabel name)
- else
- DirectEntry (mkFastEntryLabel name arity) arity arg_regs
- where
- (arg_regs, _) = assignRegs live_regs (take arity arg_kinds)
- live_regs = if node_points then [node] else []
-
- LFCon con True{-zero_arity-}
- -- a real constructor. Don't bother entering it, just jump
- -- to the constructor entry code directly.
- -> --false:ASSERT (null arg_kinds)
- -- Should have no args (meaning what?)
- StdEntry (mkStaticConEntryLabel (dataConName con))
-
- LFCon con False{-non-zero_arity-}
- -> --false:ASSERT (null arg_kinds)
- -- Should have no args (meaning what?)
- StdEntry (mkConEntryLabel (dataConName con))
-
- LFTuple tup zero_arity
- -> --false:ASSERT (null arg_kinds)
- -- Should have no args (meaning what?)
- StdEntry (mkConEntryLabel (dataConName tup))
-
- LFThunk _ _ _ updatable std_form_info
- -> if updatable || opt_DoTickyProfiling -- to catch double entry
- || opt_SMP -- always enter via node on SMP, since the
+
+getCallMethod :: HomeModules
+ -> Name -- Function being applied
+ -> LambdaFormInfo -- Its info
+ -> Int -- Number of available arguments
+ -> CallMethod
+
+getCallMethod hmods name lf_info n_args
+ | nodeMustPointToIt lf_info && opt_Parallel
+ = -- If we're parallel, then we must always enter via node.
+ -- The reason is that the closure may have been
+ -- fetched since we allocated it.
+ EnterIt
+
+getCallMethod hmods name (LFReEntrant _ arity _ _) n_args
+ | n_args == 0 = ASSERT( arity /= 0 )
+ ReturnIt -- No args at all
+ | n_args < arity = SlowCall -- Not enough args
+ | otherwise = DirectEntry (enterIdLabel hmods name) arity
+
+getCallMethod hmods name (LFCon con) n_args
+ = ASSERT( n_args == 0 )
+ ReturnCon con
+
+getCallMethod hmods name (LFThunk _ _ updatable std_form_info is_fun) n_args
+ | is_fun -- Must always "call" a function-typed
+ = SlowCall -- thing, cannot just enter it [in eval/apply, the entry code
+ -- is the fast-entry code]
+
+ | updatable || opt_DoTickyProfiling -- to catch double entry
+ || opt_SMP -- Always enter via node on SMP, since the