Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 1 | // Copyright 2011 the V8 project authors. All rights reserved. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 4 | |
| 5 | // CPU specific code for ia32 independent of OS goes here. |
| 6 | |
| 7 | #ifdef __GNUC__ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 8 | #include "src/third_party/valgrind/valgrind.h" |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 9 | #endif |
| 10 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 11 | #if V8_TARGET_ARCH_IA32 |
Leon Clarke | f7060e2 | 2010-06-03 12:02:55 +0100 | [diff] [blame] | 12 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 13 | #include "src/assembler.h" |
| 14 | #include "src/macro-assembler.h" |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 15 | |
| 16 | namespace v8 { |
| 17 | namespace internal { |
| 18 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 19 | void CpuFeatures::FlushICache(void* start, size_t size) { |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 20 | // No need to flush the instruction cache on Intel. On Intel instruction |
| 21 | // cache flushing is only necessary when multiple cores running the same |
| 22 | // code simultaneously. V8 (and JavaScript) is single threaded and when code |
| 23 | // is patched on an intel CPU the core performing the patching will have its |
| 24 | // own instruction cache updated automatically. |
| 25 | |
| 26 | // If flushing of the instruction cache becomes necessary Windows has the |
| 27 | // API function FlushInstructionCache. |
| 28 | |
| 29 | // By default, valgrind only checks the stack for writes that might need to |
| 30 | // invalidate already cached translated code. This leads to random |
| 31 | // instability when code patches or moves are sometimes unnoticed. One |
| 32 | // solution is to run valgrind with --smc-check=all, but this comes at a big |
| 33 | // performance cost. We can notify valgrind to invalidate its cache. |
| 34 | #ifdef VALGRIND_DISCARD_TRANSLATIONS |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 35 | unsigned res = VALGRIND_DISCARD_TRANSLATIONS(start, size); |
| 36 | USE(res); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 37 | #endif |
| 38 | } |
| 39 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 40 | } // namespace internal |
| 41 | } // namespace v8 |
Leon Clarke | f7060e2 | 2010-06-03 12:02:55 +0100 | [diff] [blame] | 42 | |
| 43 | #endif // V8_TARGET_ARCH_IA32 |