OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 } | 57 } |
58 | 58 |
59 | 59 |
60 void CPU::FlushICache(void* start, size_t size) { | 60 void CPU::FlushICache(void* start, size_t size) { |
61 // Nothing to do, flushing no instructions. | 61 // Nothing to do, flushing no instructions. |
62 if (size == 0) { | 62 if (size == 0) { |
63 return; | 63 return; |
64 } | 64 } |
65 | 65 |
66 #if !defined (USE_SIMULATOR) | 66 #if !defined (USE_SIMULATOR) |
| 67 #if defined(ANDROID) |
| 68 // Bionic cacheflush can typically run in userland, avoiding kernel call. |
| 69 char *end = reinterpret_cast<char *>(start) + size; |
| 70 cacheflush( |
| 71 reinterpret_cast<intptr_t>(start), reinterpret_cast<intptr_t>(end), 0); |
| 72 #else // ANDROID |
67 int res; | 73 int res; |
68 | 74 // See http://www.linux-mips.org/wiki/Cacheflush_Syscall . |
69 // See http://www.linux-mips.org/wiki/Cacheflush_Syscall. | |
70 res = syscall(__NR_cacheflush, start, size, ICACHE); | 75 res = syscall(__NR_cacheflush, start, size, ICACHE); |
71 | |
72 if (res) { | 76 if (res) { |
73 V8_Fatal(__FILE__, __LINE__, "Failed to flush the instruction cache"); | 77 V8_Fatal(__FILE__, __LINE__, "Failed to flush the instruction cache"); |
74 } | 78 } |
75 | 79 #endif // ANDROID |
76 #else // USE_SIMULATOR. | 80 #else // USE_SIMULATOR. |
77 // Not generating mips instructions for C-code. This means that we are | 81 // Not generating mips instructions for C-code. This means that we are |
78 // building a mips emulator based target. We should notify the simulator | 82 // building a mips emulator based target. We should notify the simulator |
79 // that the Icache was flushed. | 83 // that the Icache was flushed. |
80 // None of this code ends up in the snapshot so there are no issues | 84 // None of this code ends up in the snapshot so there are no issues |
81 // around whether or not to generate the code when building snapshots. | 85 // around whether or not to generate the code when building snapshots. |
82 Simulator::FlushICache(Isolate::Current()->simulator_i_cache(), start, size); | 86 Simulator::FlushICache(Isolate::Current()->simulator_i_cache(), start, size); |
83 #endif // USE_SIMULATOR. | 87 #endif // USE_SIMULATOR. |
84 } | 88 } |
85 | 89 |
86 | 90 |
87 void CPU::DebugBreak() { | 91 void CPU::DebugBreak() { |
88 #ifdef __mips | 92 #ifdef __mips |
89 asm volatile("break"); | 93 asm volatile("break"); |
90 #endif // #ifdef __mips | 94 #endif // #ifdef __mips |
91 } | 95 } |
92 | 96 |
93 | 97 |
94 } } // namespace v8::internal | 98 } } // namespace v8::internal |
95 | 99 |
96 #endif // V8_TARGET_ARCH_MIPS | 100 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |