Calling context has been widely used in many software development processes such as testing, event logging, and program analysis. It plays an even more important role in data race detection and performance bottleneck analysis for multi-threaded programs. This paper presents DACCE (Dynamic and Adaptive Calling Context Encoding), an efficient runtime encoding/decoding mechanism for singlethreaded and multi-threaded programs that captures dynamic calling contexts. It can dynamically encode all call paths invoked at runtime, and adjust the encodings according to program's execution behavior. In contrast to existing context encoding method, DACCE can work on incomplete call graph, and it does not require source code analysis and offline profiling to conduct context encoding. DACCE has significantly expanded the functionality and applicability of calling context with even lower runtime overhead. DACCE is very efficient based on experiments with SPEC CPU2006 and Parsec 2.1 (with about 2% of runtime overhead) and effective for all tested benchmarks. Copyright © 2014 by the Association for Computing Machinery, Inc. (ACM).