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

Side by Side Diff: src/arm/simulator-arm.h

Issue 1523030: Add checks to the ARM simulator to ensure that we flush the icache all... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « src/arm/cpu-arm.cc ('k') | src/arm/simulator-arm.cc » ('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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6) \ 82 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6) \
83 assembler::arm::Simulator::current()->Call( \ 83 assembler::arm::Simulator::current()->Call( \
84 FUNCTION_ADDR(entry), 7, p0, p1, p2, p3, p4, p5, p6) 84 FUNCTION_ADDR(entry), 7, p0, p1, p2, p3, p4, p5, p6)
85 85
86 #define TRY_CATCH_FROM_ADDRESS(try_catch_address) \ 86 #define TRY_CATCH_FROM_ADDRESS(try_catch_address) \
87 try_catch_address == NULL ? \ 87 try_catch_address == NULL ? \
88 NULL : *(reinterpret_cast<TryCatch**>(try_catch_address)) 88 NULL : *(reinterpret_cast<TryCatch**>(try_catch_address))
89 89
90 90
91 #include "constants-arm.h" 91 #include "constants-arm.h"
92 #include "hashmap.h"
92 93
93 94
94 namespace assembler { 95 namespace assembler {
95 namespace arm { 96 namespace arm {
96 97
98 class CachePage {
99 public:
100 static const int LINE_VALID = 0;
101 static const int LINE_INVALID = 1;
102
103 static const int kPageShift = 12;
104 static const int kPageSize = 1 << kPageShift;
105 static const int kPageMask = kPageSize - 1;
106 static const int kLineShift = 2; // The cache line is only 4 bytes right now.
107 static const int kLineLength = 1 << kLineShift;
108 static const int kLineMask = kLineLength - 1;
109
110 CachePage() {
111 memset(&validity_map_, LINE_INVALID, sizeof(validity_map_));
112 }
113
114 char* ValidityByte(int offset) {
115 return &validity_map_[offset >> kLineShift];
116 }
117
118 char* CachedData(int offset) {
119 return &data_[offset];
120 }
121
122 private:
123 char data_[kPageSize]; // The cached data.
124 static const int kValidityMapSize = kPageSize >> kLineShift;
125 char validity_map_[kValidityMapSize]; // One byte per line.
126 };
127
128
97 class Simulator { 129 class Simulator {
98 public: 130 public:
99 friend class Debugger; 131 friend class Debugger;
100 enum Register { 132 enum Register {
101 no_reg = -1, 133 no_reg = -1,
102 r0 = 0, r1, r2, r3, r4, r5, r6, r7, 134 r0 = 0, r1, r2, r3, r4, r5, r6, r7,
103 r8, r9, r10, r11, r12, r13, r14, r15, 135 r8, r9, r10, r11, r12, r13, r14, r15,
104 num_registers, 136 num_registers,
105 sp = 13, 137 sp = 13,
106 lr = 14, 138 lr = 14,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 // generated RegExp code with 7 parameters. This is a convenience function, 187 // generated RegExp code with 7 parameters. This is a convenience function,
156 // which sets up the simulator state and grabs the result on return. 188 // which sets up the simulator state and grabs the result on return.
157 int32_t Call(byte* entry, int argument_count, ...); 189 int32_t Call(byte* entry, int argument_count, ...);
158 190
159 // Push an address onto the JS stack. 191 // Push an address onto the JS stack.
160 uintptr_t PushAddress(uintptr_t address); 192 uintptr_t PushAddress(uintptr_t address);
161 193
162 // Pop an address from the JS stack. 194 // Pop an address from the JS stack.
163 uintptr_t PopAddress(); 195 uintptr_t PopAddress();
164 196
197 // ICache checking.
198 static void FlushICache(void* start, size_t size);
199
165 private: 200 private:
166 enum special_values { 201 enum special_values {
167 // Known bad pc value to ensure that the simulator does not execute 202 // Known bad pc value to ensure that the simulator does not execute
168 // without being properly setup. 203 // without being properly setup.
169 bad_lr = -1, 204 bad_lr = -1,
170 // A pc value used to signal the simulator to stop execution. Generally 205 // A pc value used to signal the simulator to stop execution. Generally
171 // the lr is set to this value on transition from native C code to 206 // the lr is set to this value on transition from native C code to
172 // simulated execution, so that the simulator can "return" to the native 207 // simulated execution, so that the simulator can "return" to the native
173 // C code. 208 // C code.
174 end_sim_pc = -2 209 end_sim_pc = -2
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 void DecodeType6CoprocessorIns(Instr* instr); 267 void DecodeType6CoprocessorIns(Instr* instr);
233 268
234 void DecodeVMOVBetweenCoreAndSinglePrecisionRegisters(Instr* instr); 269 void DecodeVMOVBetweenCoreAndSinglePrecisionRegisters(Instr* instr);
235 void DecodeVCMP(Instr* instr); 270 void DecodeVCMP(Instr* instr);
236 void DecodeVCVTBetweenDoubleAndSingle(Instr* instr); 271 void DecodeVCVTBetweenDoubleAndSingle(Instr* instr);
237 void DecodeVCVTBetweenFloatingPointAndInteger(Instr* instr); 272 void DecodeVCVTBetweenFloatingPointAndInteger(Instr* instr);
238 273
239 // Executes one instruction. 274 // Executes one instruction.
240 void InstructionDecode(Instr* instr); 275 void InstructionDecode(Instr* instr);
241 276
277 // ICache.
278 static void CheckICache(Instr* instr);
279 static void FlushOnePage(intptr_t start, int size);
280 static CachePage* GetCachePage(void* page);
281
242 // Runtime call support. 282 // Runtime call support.
243 static void* RedirectExternalReference(void* external_function, 283 static void* RedirectExternalReference(void* external_function,
244 bool fp_return); 284 bool fp_return);
245 285
246 // For use in calls that take two double values, constructed from r0, r1, r2 286 // For use in calls that take two double values, constructed from r0, r1, r2
247 // and r3. 287 // and r3.
248 void GetFpArgs(double* x, double* y); 288 void GetFpArgs(double* x, double* y);
249 void SetFpResult(const double& result); 289 void SetFpResult(const double& result);
250 void TrashCallerSaveRegisters(); 290 void TrashCallerSaveRegisters();
251 291
(...skipping 17 matching lines...) Expand all
269 bool overflow_vfp_flag_; 309 bool overflow_vfp_flag_;
270 bool underflow_vfp_flag_; 310 bool underflow_vfp_flag_;
271 bool inexact_vfp_flag_; 311 bool inexact_vfp_flag_;
272 312
273 // Simulator support. 313 // Simulator support.
274 char* stack_; 314 char* stack_;
275 bool pc_modified_; 315 bool pc_modified_;
276 int icount_; 316 int icount_;
277 static bool initialized_; 317 static bool initialized_;
278 318
319 // Icache simulation
320 static v8::internal::HashMap* i_cache_;
321
279 // Registered breakpoints. 322 // Registered breakpoints.
280 Instr* break_pc_; 323 Instr* break_pc_;
281 instr_t break_instr_; 324 instr_t break_instr_;
282 }; 325 };
283 326
284 } } // namespace assembler::arm 327 } } // namespace assembler::arm
285 328
286 329
287 // The simulator has its own stack. Thus it has a different stack limit from 330 // The simulator has its own stack. Thus it has a different stack limit from
288 // the C-based native code. Setting the c_limit to indicate a very small 331 // the C-based native code. Setting the c_limit to indicate a very small
(...skipping 13 matching lines...) Expand all
302 345
303 static inline void UnregisterCTryCatch() { 346 static inline void UnregisterCTryCatch() {
304 assembler::arm::Simulator::current()->PopAddress(); 347 assembler::arm::Simulator::current()->PopAddress();
305 } 348 }
306 }; 349 };
307 350
308 351
309 #endif // defined(__arm__) 352 #endif // defined(__arm__)
310 353
311 #endif // V8_ARM_SIMULATOR_ARM_H_ 354 #endif // V8_ARM_SIMULATOR_ARM_H_
OLDNEW
« no previous file with comments | « src/arm/cpu-arm.cc ('k') | src/arm/simulator-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698