Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(497)

Side by Side Diff: src/ia32/cpu-ia32.cc

Issue 13612: Notify valgrind when we modify code on x86. (Closed)
Patch Set: Merge. Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « LICENSE ('k') | src/third_party/valgrind/valgrind.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 // CPU specific code for ia32 independent of OS goes here. 28 // CPU specific code for ia32 independent of OS goes here.
29 29
30 #ifdef __GNUC__
31 #include "third_party/valgrind/valgrind.h"
iposva 2009/07/23 18:01:57 The code in valgrind.h does not appear to distingu
32 #endif
33
30 #include "v8.h" 34 #include "v8.h"
31 35
32 #include "cpu.h" 36 #include "cpu.h"
33 #include "macro-assembler.h" 37 #include "macro-assembler.h"
34 38
35 namespace v8 { 39 namespace v8 {
36 namespace internal { 40 namespace internal {
37 41
38 void CPU::Setup() { 42 void CPU::Setup() {
39 CpuFeatures::Probe(); 43 CpuFeatures::Probe();
40 } 44 }
41 45
42 46
43 void CPU::FlushICache(void* start, size_t size) { 47 void CPU::FlushICache(void* start, size_t size) {
44 // No need to flush the instruction cache on Intel. On Intel instruction 48 // No need to flush the instruction cache on Intel. On Intel instruction
45 // cache flushing is only necessary when multiple cores running the same 49 // cache flushing is only necessary when multiple cores running the same
46 // code simultaneously. V8 (and JavaScript) is single threaded and when code 50 // code simultaneously. V8 (and JavaScript) is single threaded and when code
47 // is patched on an intel CPU the core performing the patching will have its 51 // is patched on an intel CPU the core performing the patching will have its
48 // own instruction cache updated automatically. 52 // own instruction cache updated automatically.
49 53
50 // If flushing of the instruction cache becomes necessary Windows has the 54 // If flushing of the instruction cache becomes necessary Windows has the
51 // API function FlushInstructionCache. 55 // API function FlushInstructionCache.
56
57 // By default, valgrind only checks the stack for writes that might need to
58 // invalidate already cached translated code. This leads to random
59 // instability when code patches or moves are sometimes unnoticed. One
60 // solution is to run valgrind with --smc-check=all, but this comes at a big
61 // performance cost. We can notify valgrind to invalidate its cache.
62 #ifdef VALGRIND_DISCARD_TRANSLATIONS
63 VALGRIND_DISCARD_TRANSLATIONS(start, size);
64 #endif
52 } 65 }
53 66
54 67
55 void CPU::DebugBreak() { 68 void CPU::DebugBreak() {
56 #ifdef _MSC_VER 69 #ifdef _MSC_VER
57 // To avoid Visual Studio runtime support the following code can be used 70 // To avoid Visual Studio runtime support the following code can be used
58 // instead 71 // instead
59 // __asm { int 3 } 72 // __asm { int 3 }
60 __debugbreak(); 73 __debugbreak();
61 #else 74 #else
62 asm("int $3"); 75 asm("int $3");
63 #endif 76 #endif
64 } 77 }
65 78
66 } } // namespace v8::internal 79 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « LICENSE ('k') | src/third_party/valgrind/valgrind.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698