diff options
author | Andy Ayers <andya@microsoft.com> | 2016-05-24 11:12:14 -0700 |
---|---|---|
committer | Andy Ayers <andya@microsoft.com> | 2016-05-25 18:21:35 -0700 |
commit | be9d889b084099797dfcf019b2820433558dbec9 (patch) | |
tree | 81bc616ebcff4a57831e6bab29a7d81366f60a43 /src/jit/inlinepolicy.cpp | |
parent | 78b78103b0a155bc3abbb4b6878390959062ef8c (diff) | |
download | coreclr-be9d889b084099797dfcf019b2820433558dbec9.tar.gz coreclr-be9d889b084099797dfcf019b2820433558dbec9.tar.bz2 coreclr-be9d889b084099797dfcf019b2820433558dbec9.zip |
Inliner: use offset in xml replay
Replay needs the ability to distinguish among multiple calls to the same
callee. The IL offset of the call site can be used for this, so start
checking for it during replay.
Note there is subsequent follow-up work to ensure that we actually track
offsets for calls.
Refactor the way the ReplayPolicy gets notified of the current inline
context (and the IL offset of the call). Instead of trying to pass
this information as arguments to the factory method that creates
policies, add special notifications for this information that only the
ReplayPolicy will act upon.
Diffstat (limited to 'src/jit/inlinepolicy.cpp')
-rw-r--r-- | src/jit/inlinepolicy.cpp | 54 |
1 files changed, 38 insertions, 16 deletions
diff --git a/src/jit/inlinepolicy.cpp b/src/jit/inlinepolicy.cpp index 332ffe0aa1..0f1bd0c8b6 100644 --- a/src/jit/inlinepolicy.cpp +++ b/src/jit/inlinepolicy.cpp @@ -15,7 +15,6 @@ // // Arguments: // compiler - the compiler instance that will evaluate inlines -// inlineContext - the context of the inline // isPrejitRoot - true if this policy is evaluating a prejit root // // Return Value: @@ -25,12 +24,9 @@ // Determines which of the various policies should apply, // and creates (or reuses) a policy instance to use. -InlinePolicy* InlinePolicy::GetPolicy(Compiler* compiler, InlineContext* inlineContext, bool isPrejitRoot) +InlinePolicy* InlinePolicy::GetPolicy(Compiler* compiler, bool isPrejitRoot) { - // inlineContext only conditionally used below. - (void) inlineContext; - #ifdef DEBUG // Optionally install the RandomPolicy. @@ -52,7 +48,7 @@ InlinePolicy* InlinePolicy::GetPolicy(Compiler* compiler, InlineContext* inlineC if (useReplayPolicy) { - return new (compiler, CMK_Inlining) ReplayPolicy(compiler, inlineContext, isPrejitRoot); + return new (compiler, CMK_Inlining) ReplayPolicy(compiler, isPrejitRoot); } // Optionally install the SizePolicy. @@ -2078,12 +2074,11 @@ CritSecObject ReplayPolicy::s_XmlReaderLock; // // Arguments: // compiler -- compiler instance doing the inlining (root compiler) -// inlineContext -- inline context for the inline // isPrejitRoot -- true if this compiler is prejitting the root method -ReplayPolicy::ReplayPolicy(Compiler* compiler, InlineContext* inlineContext, bool isPrejitRoot) +ReplayPolicy::ReplayPolicy(Compiler* compiler, bool isPrejitRoot) : DiscretionaryPolicy(compiler, isPrejitRoot) - , m_InlineContext(inlineContext) + , m_InlineContext(nullptr) { // Is there a log file open already? If so, we can use it. if (s_ReplayFile == nullptr) @@ -2266,8 +2261,9 @@ bool ReplayPolicy::FindContext(InlineContext* context) unsigned contextHash = m_RootCompiler->info.compCompHnd->getMethodHash( context->GetCallee()); + unsigned contextOffset = (unsigned) context->GetOffset(); - return FindInline(contextToken, contextHash); + return FindInline(contextToken, contextHash, contextOffset); } //------------------------------------------------------------------------ @@ -2276,6 +2272,7 @@ bool ReplayPolicy::FindContext(InlineContext* context) // Arguments: // token -- token describing the inline // hash -- hash describing the inline +// offset -- IL offset of the call site in the parent method // // ReturnValue: // true if the inline entry was found @@ -2288,7 +2285,7 @@ bool ReplayPolicy::FindContext(InlineContext* context) // particular inline, if there are multiple calls to the same // method. -bool ReplayPolicy::FindInline(unsigned token, unsigned hash) +bool ReplayPolicy::FindInline(unsigned token, unsigned hash, unsigned offset) { char buffer[256]; bool foundInline = false; @@ -2361,11 +2358,10 @@ bool ReplayPolicy::FindInline(unsigned token, unsigned hash) break; } + // Match token unsigned inlineToken = 0; int count = sscanf(buffer, " <Token>%u</Token> ", &inlineToken); - // Need a secondary check here for callsite. - // ...offset or similar. if ((count != 1) || (inlineToken != token)) { continue; @@ -2377,16 +2373,32 @@ bool ReplayPolicy::FindInline(unsigned token, unsigned hash) break; } + // Match hash unsigned inlineHash = 0; count = sscanf(buffer, " <Hash>%u</Hash> ", &inlineHash); - // Need a secondary check here for callsite ID - // ... offset or similar. if ((count != 1) || (inlineHash != hash)) { continue; } + // Get next line + if (fgets(buffer, sizeof(buffer), s_ReplayFile) == nullptr) + { + break; + } + + // Match offset + unsigned inlineOffset = 0; + count = sscanf(buffer, " <Offset>%u</Offset> ", &inlineOffset); + if ((count != 1) || (inlineOffset != offset)) + { + continue; + } + + // Token,Hash,Offset may still not be unique enough, but it's + // all we have right now. + // We're good! foundInline = true; break; @@ -2420,7 +2432,17 @@ bool ReplayPolicy::FindInline(CORINFO_METHOD_HANDLE callee) unsigned calleeHash = m_RootCompiler->info.compCompHnd->getMethodHash(callee); - bool foundInline = FindInline(calleeToken, calleeHash); + // Abstract this or just pass through raw bits + // See matching code in xml writer + int offset = -1; + if (m_Offset != BAD_IL_OFFSET) + { + offset = (int) jitGetILoffs(m_Offset); + } + + unsigned calleeOffset = (unsigned) offset; + + bool foundInline = FindInline(calleeToken, calleeHash, calleeOffset); return foundInline; } |