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

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

Issue 6965006: Update mips infrastructure files. (Closed) Base URL: http://github.com/v8/v8.git@bleeding_edge
Patch Set: Fix additional style issues. Created 9 years, 7 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
OLDNEW
1 // Copyright 2010 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
11 // with the distribution. 11 // with the distribution.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 // Running without a simulator on a native mips platform. 43 // Running without a simulator on a native mips platform.
44 44
45 namespace v8 { 45 namespace v8 {
46 namespace internal { 46 namespace internal {
47 47
48 // When running without a simulator we call the entry directly. 48 // When running without a simulator we call the entry directly.
49 #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \ 49 #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \
50 entry(p0, p1, p2, p3, p4) 50 entry(p0, p1, p2, p3, p4)
51 51
52 typedef int (*mips_regexp_matcher)(String*, int, const byte*, const byte*, 52 typedef int (*mips_regexp_matcher)(String*, int, const byte*, const byte*,
53 void*, int*, Address, int, Isolate*); 53 int*, Address, int, Isolate*);
54
54 55
55 // Call the generated regexp code directly. The code at the entry address 56 // Call the generated regexp code directly. The code at the entry address
56 // should act as a function matching the type arm_regexp_matcher. 57 // should act as a function matching the type arm_regexp_matcher.
57 // The fifth argument is a dummy that reserves the space used for 58 // The fifth argument is a dummy that reserves the space used for
58 // the return address added by the ExitFrame in native calls. 59 // the return address added by the ExitFrame in native calls.
59 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7) \ 60 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7) \
60 (FUNCTION_CAST<mips_regexp_matcher>(entry)( \ 61 (FUNCTION_CAST<mips_regexp_matcher>(entry)(p0, p1, p2, p3, p4, p5, p6, p7))
61 p0, p1, p2, p3, NULL, p4, p5, p6, p7))
62 62
63 #define TRY_CATCH_FROM_ADDRESS(try_catch_address) \ 63 #define TRY_CATCH_FROM_ADDRESS(try_catch_address) \
64 reinterpret_cast<TryCatch*>(try_catch_address) 64 reinterpret_cast<TryCatch*>(try_catch_address)
65 65
66 // The stack limit beyond which we will throw stack overflow errors in 66 // The stack limit beyond which we will throw stack overflow errors in
67 // generated code. Because generated code on mips uses the C stack, we 67 // generated code. Because generated code on mips uses the C stack, we
68 // just use the C stack limit. 68 // just use the C stack limit.
69 class SimulatorStack : public v8::internal::AllStatic { 69 class SimulatorStack : public v8::internal::AllStatic {
70 public: 70 public:
71 static inline uintptr_t JsLimitFromCLimit(Isolate* isolate, 71 static inline uintptr_t JsLimitFromCLimit(Isolate* isolate,
(...skipping 17 matching lines...) Expand all
89 // NOTE: The check for overflow is not safe as there is no guarantee that the 89 // NOTE: The check for overflow is not safe as there is no guarantee that the
90 // running thread has its stack in all memory up to address 0x00000000. 90 // running thread has its stack in all memory up to address 0x00000000.
91 #define GENERATED_CODE_STACK_LIMIT(limit) \ 91 #define GENERATED_CODE_STACK_LIMIT(limit) \
92 (reinterpret_cast<uintptr_t>(this) >= limit ? \ 92 (reinterpret_cast<uintptr_t>(this) >= limit ? \
93 reinterpret_cast<uintptr_t>(this) - limit : 0) 93 reinterpret_cast<uintptr_t>(this) - limit : 0)
94 94
95 #else // !defined(USE_SIMULATOR) 95 #else // !defined(USE_SIMULATOR)
96 // Running with a simulator. 96 // Running with a simulator.
97 97
98 #include "hashmap.h" 98 #include "hashmap.h"
99 #include "assembler.h"
99 100
100 namespace v8 { 101 namespace v8 {
101 namespace internal { 102 namespace internal {
102 103
103 // ----------------------------------------------------------------------------- 104 // -----------------------------------------------------------------------------
104 // Utility functions 105 // Utility functions
105 106
106 class CachePage { 107 class CachePage {
107 public: 108 public:
108 static const int LINE_VALID = 0; 109 static const int LINE_VALID = 0;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 v0, v1, 146 v0, v1,
146 a0, a1, a2, a3, 147 a0, a1, a2, a3,
147 t0, t1, t2, t3, t4, t5, t6, t7, 148 t0, t1, t2, t3, t4, t5, t6, t7,
148 s0, s1, s2, s3, s4, s5, s6, s7, 149 s0, s1, s2, s3, s4, s5, s6, s7,
149 t8, t9, 150 t8, t9,
150 k0, k1, 151 k0, k1,
151 gp, 152 gp,
152 sp, 153 sp,
153 s8, 154 s8,
154 ra, 155 ra,
155 // LO, HI, and pc 156 // LO, HI, and pc.
156 LO, 157 LO,
157 HI, 158 HI,
158 pc, // pc must be the last register. 159 pc, // pc must be the last register.
159 kNumSimuRegisters, 160 kNumSimuRegisters,
160 // aliases 161 // aliases
161 fp = s8 162 fp = s8
162 }; 163 };
163 164
164 // Coprocessor registers. 165 // Coprocessor registers.
165 // Generated code will always use doubles. So we will only use even registers. 166 // Generated code will always use doubles. So we will only use even registers.
166 enum FPURegister { 167 enum FPURegister {
167 f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, 168 f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11,
168 f12, f13, f14, f15, // f12 and f14 are arguments FPURegisters 169 f12, f13, f14, f15, // f12 and f14 are arguments FPURegisters.
169 f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, 170 f16, f17, f18, f19, f20, f21, f22, f23, f24, f25,
170 f26, f27, f28, f29, f30, f31, 171 f26, f27, f28, f29, f30, f31,
171 kNumFPURegisters 172 kNumFPURegisters
172 }; 173 };
173 174
174 explicit Simulator(Isolate* isolate); 175 explicit Simulator(Isolate* isolate);
175 ~Simulator(); 176 ~Simulator();
176 177
177 // The currently executing Simulator instance. Potentially there can be one 178 // The currently executing Simulator instance. Potentially there can be one
178 // for each native thread. 179 // for each native thread.
179 static Simulator* current(v8::internal::Isolate* isolate); 180 static Simulator* current(v8::internal::Isolate* isolate);
180 181
181 // Accessors for register state. Reading the pc value adheres to the MIPS 182 // Accessors for register state. Reading the pc value adheres to the MIPS
182 // architecture specification and is off by a 8 from the currently executing 183 // architecture specification and is off by a 8 from the currently executing
183 // instruction. 184 // instruction.
184 void set_register(int reg, int32_t value); 185 void set_register(int reg, int32_t value);
185 int32_t get_register(int reg) const; 186 int32_t get_register(int reg) const;
186 // Same for FPURegisters 187 // Same for FPURegisters.
187 void set_fpu_register(int fpureg, int32_t value); 188 void set_fpu_register(int fpureg, int32_t value);
188 void set_fpu_register_float(int fpureg, float value); 189 void set_fpu_register_float(int fpureg, float value);
189 void set_fpu_register_double(int fpureg, double value); 190 void set_fpu_register_double(int fpureg, double value);
190 int32_t get_fpu_register(int fpureg) const; 191 int32_t get_fpu_register(int fpureg) const;
191 int64_t get_fpu_register_long(int fpureg) const; 192 int64_t get_fpu_register_long(int fpureg) const;
192 float get_fpu_register_float(int fpureg) const; 193 float get_fpu_register_float(int fpureg) const;
193 double get_fpu_register_double(int fpureg) const; 194 double get_fpu_register_double(int fpureg) const;
194 void set_fcsr_bit(uint32_t cc, bool value); 195 void set_fcsr_bit(uint32_t cc, bool value);
195 bool test_fcsr_bit(uint32_t cc); 196 bool test_fcsr_bit(uint32_t cc);
196 bool set_fcsr_round_error(double original, double rounded); 197 bool set_fcsr_round_error(double original, double rounded);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 } 299 }
299 InstructionDecode(instr); 300 InstructionDecode(instr);
300 } 301 }
301 302
302 // ICache. 303 // ICache.
303 static void CheckICache(v8::internal::HashMap* i_cache, Instruction* instr); 304 static void CheckICache(v8::internal::HashMap* i_cache, Instruction* instr);
304 static void FlushOnePage(v8::internal::HashMap* i_cache, intptr_t start, 305 static void FlushOnePage(v8::internal::HashMap* i_cache, intptr_t start,
305 int size); 306 int size);
306 static CachePage* GetCachePage(v8::internal::HashMap* i_cache, void* page); 307 static CachePage* GetCachePage(v8::internal::HashMap* i_cache, void* page);
307 308
308
309 enum Exception { 309 enum Exception {
310 none, 310 none,
311 kIntegerOverflow, 311 kIntegerOverflow,
312 kIntegerUnderflow, 312 kIntegerUnderflow,
313 kDivideByZero, 313 kDivideByZero,
314 kNumExceptions 314 kNumExceptions
315 }; 315 };
316 int16_t exceptions[kNumExceptions]; 316 int16_t exceptions[kNumExceptions];
317 317
318 // Exceptions. 318 // Exceptions.
319 void SignalExceptions(); 319 void SignalExceptions();
320 320
321 // Runtime call support. 321 // Runtime call support.
322 static void* RedirectExternalReference(void* external_function, 322 static void* RedirectExternalReference(void* external_function,
323 ExternalReference::Type type); 323 ExternalReference::Type type);
324 324
325 // Used for real time calls that takes two double values as arguments and 325 // Used for real time calls that takes two double values as arguments and
326 // returns a double. 326 // returns a double.
327 void SetFpResult(double result); 327 void SetFpResult(double result);
328 328
329 // Architecture state. 329 // Architecture state.
330 // Registers. 330 // Registers.
331 int32_t registers_[kNumSimuRegisters]; 331 int32_t registers_[kNumSimuRegisters];
332 // Coprocessor Registers. 332 // Coprocessor Registers.
333 int32_t FPUregisters_[kNumFPURegisters]; 333 int32_t FPUregisters_[kNumFPURegisters];
334 // FPU control register. 334 // FPU control register.
335 uint32_t FCSR_; 335 uint32_t FCSR_;
336 336
337 // Simulator support. 337 // Simulator support.
338 // Allocate 1MB for stack.
339 static const size_t stack_size_ = 1 * 1024*1024;
338 char* stack_; 340 char* stack_;
339 size_t stack_size_;
340 bool pc_modified_; 341 bool pc_modified_;
341 int icount_; 342 int icount_;
342 int break_count_; 343 int break_count_;
343 344
344 // Icache simulation 345 // Icache simulation.
345 v8::internal::HashMap* i_cache_; 346 v8::internal::HashMap* i_cache_;
346 347
348 v8::internal::Isolate* isolate_;
349
347 // Registered breakpoints. 350 // Registered breakpoints.
348 Instruction* break_pc_; 351 Instruction* break_pc_;
349 Instr break_instr_; 352 Instr break_instr_;
350
351 v8::internal::Isolate* isolate_;
352 }; 353 };
353 354
354 355
355 // When running with the simulator transition into simulated execution at this 356 // When running with the simulator transition into simulated execution at this
356 // point. 357 // point.
357 #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \ 358 #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \
358 reinterpret_cast<Object*>(Simulator::current(Isolate::Current())->Call( \ 359 reinterpret_cast<Object*>(Simulator::current(Isolate::Current())->Call( \
359 FUNCTION_ADDR(entry), 5, p0, p1, p2, p3, p4)) 360 FUNCTION_ADDR(entry), 5, p0, p1, p2, p3, p4))
360 361
361 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7) \ 362 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7) \
362 Simulator::current(Isolate::Current())->Call( \ 363 Simulator::current(Isolate::Current())->Call( \
363 entry, 9, p0, p1, p2, p3, NULL, p4, p5, p6, p7) 364 entry, 8, p0, p1, p2, p3, p4, p5, p6, p7)
364 365
365 #define TRY_CATCH_FROM_ADDRESS(try_catch_address) \ 366 #define TRY_CATCH_FROM_ADDRESS(try_catch_address) \
366 try_catch_address == NULL ? \ 367 try_catch_address == NULL ? \
367 NULL : *(reinterpret_cast<TryCatch**>(try_catch_address)) 368 NULL : *(reinterpret_cast<TryCatch**>(try_catch_address))
368 369
369 370
370 // The simulator has its own stack. Thus it has a different stack limit from 371 // The simulator has its own stack. Thus it has a different stack limit from
371 // the C-based native code. Setting the c_limit to indicate a very small 372 // the C-based native code. Setting the c_limit to indicate a very small
372 // stack cause stack overflow errors, since the simulator ignores the input. 373 // stack cause stack overflow errors, since the simulator ignores the input.
373 // This is unlikely to be an issue in practice, though it might cause testing 374 // This is unlikely to be an issue in practice, though it might cause testing
374 // trouble down the line. 375 // trouble down the line.
375 class SimulatorStack : public v8::internal::AllStatic { 376 class SimulatorStack : public v8::internal::AllStatic {
376 public: 377 public:
(...skipping 10 matching lines...) Expand all
387 static inline void UnregisterCTryCatch() { 388 static inline void UnregisterCTryCatch() {
388 Simulator::current(Isolate::Current())->PopAddress(); 389 Simulator::current(Isolate::Current())->PopAddress();
389 } 390 }
390 }; 391 };
391 392
392 } } // namespace v8::internal 393 } } // namespace v8::internal
393 394
394 #endif // !defined(USE_SIMULATOR) 395 #endif // !defined(USE_SIMULATOR)
395 #endif // V8_MIPS_SIMULATOR_MIPS_H_ 396 #endif // V8_MIPS_SIMULATOR_MIPS_H_
396 397
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698