Line data Source code
1 : // Copyright 2012 the V8 project authors. All rights reserved.
2 : // Use of this source code is governed by a BSD-style license that can be
3 : // found in the LICENSE file.
4 :
5 : // CPU specific code for x64 independent of OS goes here.
6 :
7 : #if defined(__GNUC__) && !defined(__MINGW64__)
8 : #include "src/third_party/valgrind/valgrind.h"
9 : #endif
10 :
11 : #if V8_TARGET_ARCH_X64
12 :
13 : #include "src/cpu-features.h"
14 :
15 : namespace v8 {
16 : namespace internal {
17 :
18 7229349 : void CpuFeatures::FlushICache(void* start, size_t size) {
19 : // No need to flush the instruction cache on Intel. On Intel instruction
20 : // cache flushing is only necessary when multiple cores running the same
21 : // code simultaneously. V8 (and JavaScript) is single threaded and when code
22 : // is patched on an intel CPU the core performing the patching will have its
23 : // own instruction cache updated automatically.
24 :
25 : // If flushing of the instruction cache becomes necessary Windows has the
26 : // API function FlushInstructionCache.
27 :
28 : // By default, valgrind only checks the stack for writes that might need to
29 : // invalidate already cached translated code. This leads to random
30 : // instability when code patches or moves are sometimes unnoticed. One
31 : // solution is to run valgrind with --smc-check=all, but this comes at a big
32 : // performance cost. We can notify valgrind to invalidate its cache.
33 : #ifdef VALGRIND_DISCARD_TRANSLATIONS
34 : unsigned res = VALGRIND_DISCARD_TRANSLATIONS(start, size);
35 : USE(res);
36 : #endif
37 7229349 : }
38 :
39 : } // namespace internal
40 : } // namespace v8
41 :
42 : #endif // V8_TARGET_ARCH_X64
|