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

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

Issue 1457223005: Remove a bunch of Isolate::Current() callsites from simulators (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 5 years, 1 month 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 | « src/mips/simulator-mips.cc ('k') | src/mips64/simulator-mips64.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 5
6 // Declares a Simulator for MIPS instructions if we are not generating a native 6 // Declares a Simulator for MIPS instructions if we are not generating a native
7 // MIPS binary. This Simulator allows us to run and debug MIPS code generation 7 // MIPS binary. This Simulator allows us to run and debug MIPS code generation
8 // on regular desktop machines. 8 // on regular desktop machines.
9 // V8 calls into generated code by "calling" the CALL_GENERATED_CODE macro, 9 // V8 calls into generated code by "calling" the CALL_GENERATED_CODE macro,
10 // which will start execution in the Simulator or forwards to the real entry 10 // which will start execution in the Simulator or forwards to the real entry
11 // on a MIPS HW platform. 11 // on a MIPS HW platform.
12 12
13 #ifndef V8_MIPS_SIMULATOR_MIPS_H_ 13 #ifndef V8_MIPS_SIMULATOR_MIPS_H_
14 #define V8_MIPS_SIMULATOR_MIPS_H_ 14 #define V8_MIPS_SIMULATOR_MIPS_H_
15 15
16 #include "src/allocation.h" 16 #include "src/allocation.h"
17 #include "src/mips64/constants-mips64.h" 17 #include "src/mips64/constants-mips64.h"
18 18
19 #if !defined(USE_SIMULATOR) 19 #if !defined(USE_SIMULATOR)
20 // Running without a simulator on a native mips platform. 20 // Running without a simulator on a native mips platform.
21 21
22 namespace v8 { 22 namespace v8 {
23 namespace internal { 23 namespace internal {
24 24
25 // When running without a simulator we call the entry directly. 25 // When running without a simulator we call the entry directly.
26 #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \ 26 #define CALL_GENERATED_CODE(isolate, entry, p0, p1, p2, p3, p4) \
27 entry(p0, p1, p2, p3, p4) 27 entry(p0, p1, p2, p3, p4)
28 28
29 29
30 // Call the generated regexp code directly. The code at the entry address 30 // Call the generated regexp code directly. The code at the entry address
31 // should act as a function matching the type arm_regexp_matcher. 31 // should act as a function matching the type arm_regexp_matcher.
32 // The fifth (or ninth) argument is a dummy that reserves the space used for 32 // The fifth (or ninth) argument is a dummy that reserves the space used for
33 // the return address added by the ExitFrame in native calls. 33 // the return address added by the ExitFrame in native calls.
34 #ifdef MIPS_ABI_N64 34 #ifdef MIPS_ABI_N64
35 typedef int (*mips_regexp_matcher)(String* input, 35 typedef int (*mips_regexp_matcher)(String* input,
36 int64_t start_offset, 36 int64_t start_offset,
37 const byte* input_start, 37 const byte* input_start,
38 const byte* input_end, 38 const byte* input_end,
39 int* output, 39 int* output,
40 int64_t output_size, 40 int64_t output_size,
41 Address stack_base, 41 Address stack_base,
42 int64_t direct_call, 42 int64_t direct_call,
43 void* return_address, 43 void* return_address,
44 Isolate* isolate); 44 Isolate* isolate);
45 45
46 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7, p8) \ 46 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \
47 (FUNCTION_CAST<mips_regexp_matcher>(entry)( \ 47 p7, p8) \
48 p0, p1, p2, p3, p4, p5, p6, p7, NULL, p8)) 48 (FUNCTION_CAST<mips_regexp_matcher>(entry)(p0, p1, p2, p3, p4, p5, p6, p7, \
49 NULL, p8))
49 50
50 #else // O32 Abi. 51 #else // O32 Abi.
51 52
52 typedef int (*mips_regexp_matcher)(String* input, 53 typedef int (*mips_regexp_matcher)(String* input,
53 int32_t start_offset, 54 int32_t start_offset,
54 const byte* input_start, 55 const byte* input_start,
55 const byte* input_end, 56 const byte* input_end,
56 void* return_address, 57 void* return_address,
57 int* output, 58 int* output,
58 int32_t output_size, 59 int32_t output_size,
59 Address stack_base, 60 Address stack_base,
60 int32_t direct_call, 61 int32_t direct_call,
61 Isolate* isolate); 62 Isolate* isolate);
62 63
63 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7, p8) \ 64 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \
64 (FUNCTION_CAST<mips_regexp_matcher>(entry)( \ 65 p7, p8) \
65 p0, p1, p2, p3, NULL, p4, p5, p6, p7, p8)) 66 (FUNCTION_CAST<mips_regexp_matcher>(entry)(p0, p1, p2, p3, NULL, p4, p5, p6, \
67 p7, p8))
66 68
67 #endif // MIPS_ABI_N64 69 #endif // MIPS_ABI_N64
68 70
69 71
70 // The stack limit beyond which we will throw stack overflow errors in 72 // The stack limit beyond which we will throw stack overflow errors in
71 // generated code. Because generated code on mips uses the C stack, we 73 // generated code. Because generated code on mips uses the C stack, we
72 // just use the C stack limit. 74 // just use the C stack limit.
73 class SimulatorStack : public v8::internal::AllStatic { 75 class SimulatorStack : public v8::internal::AllStatic {
74 public: 76 public:
75 static inline uintptr_t JsLimitFromCLimit(Isolate* isolate, 77 static inline uintptr_t JsLimitFromCLimit(Isolate* isolate,
76 uintptr_t c_limit) { 78 uintptr_t c_limit) {
77 return c_limit; 79 return c_limit;
78 } 80 }
79 81
80 static inline uintptr_t RegisterCTryCatch(uintptr_t try_catch_address) { 82 static inline uintptr_t RegisterCTryCatch(Isolate* isolate,
83 uintptr_t try_catch_address) {
84 USE(isolate);
81 return try_catch_address; 85 return try_catch_address;
82 } 86 }
83 87
84 static inline void UnregisterCTryCatch() { } 88 static inline void UnregisterCTryCatch(Isolate* isolate) { USE(isolate); }
85 }; 89 };
86 90
87 } // namespace internal 91 } // namespace internal
88 } // namespace v8 92 } // namespace v8
89 93
90 // Calculated the stack limit beyond which we will throw stack overflow errors. 94 // Calculated the stack limit beyond which we will throw stack overflow errors.
91 // This macro must be called from a C++ method. It relies on being able to take 95 // This macro must be called from a C++ method. It relies on being able to take
92 // the address of "this" to get a value on the current execution stack and then 96 // the address of "this" to get a value on the current execution stack and then
93 // calculates the stack limit based on that value. 97 // calculates the stack limit based on that value.
94 // NOTE: The check for overflow is not safe as there is no guarantee that the 98 // NOTE: The check for overflow is not safe as there is no guarantee that the
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 kIntegerOverflow, 427 kIntegerOverflow,
424 kIntegerUnderflow, 428 kIntegerUnderflow,
425 kDivideByZero, 429 kDivideByZero,
426 kNumExceptions 430 kNumExceptions
427 }; 431 };
428 432
429 // Exceptions. 433 // Exceptions.
430 void SignalException(Exception e); 434 void SignalException(Exception e);
431 435
432 // Runtime call support. 436 // Runtime call support.
433 static void* RedirectExternalReference(void* external_function, 437 static void* RedirectExternalReference(Isolate* isolate,
438 void* external_function,
434 ExternalReference::Type type); 439 ExternalReference::Type type);
435 440
436 // Handle arguments and return value for runtime FP functions. 441 // Handle arguments and return value for runtime FP functions.
437 void GetFpArgs(double* x, double* y, int32_t* z); 442 void GetFpArgs(double* x, double* y, int32_t* z);
438 void SetFpResult(const double& result); 443 void SetFpResult(const double& result);
439 444
440 void CallInternal(byte* entry); 445 void CallInternal(byte* entry);
441 446
442 // Architecture state. 447 // Architecture state.
443 // Registers. 448 // Registers.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 struct StopCountAndDesc { 483 struct StopCountAndDesc {
479 uint32_t count; 484 uint32_t count;
480 char* desc; 485 char* desc;
481 }; 486 };
482 StopCountAndDesc watched_stops_[kMaxStopCode + 1]; 487 StopCountAndDesc watched_stops_[kMaxStopCode + 1];
483 }; 488 };
484 489
485 490
486 // When running with the simulator transition into simulated execution at this 491 // When running with the simulator transition into simulated execution at this
487 // point. 492 // point.
488 #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \ 493 #define CALL_GENERATED_CODE(isolate, entry, p0, p1, p2, p3, p4) \
489 reinterpret_cast<Object*>(Simulator::current(Isolate::Current())->Call( \ 494 reinterpret_cast<Object*>(Simulator::current(isolate)->Call( \
490 FUNCTION_ADDR(entry), 5, reinterpret_cast<int64_t*>(p0), \ 495 FUNCTION_ADDR(entry), 5, reinterpret_cast<int64_t*>(p0), \
491 reinterpret_cast<int64_t*>(p1), reinterpret_cast<int64_t*>(p2), \ 496 reinterpret_cast<int64_t*>(p1), reinterpret_cast<int64_t*>(p2), \
492 reinterpret_cast<int64_t*>(p3), reinterpret_cast<int64_t*>(p4))) 497 reinterpret_cast<int64_t*>(p3), reinterpret_cast<int64_t*>(p4)))
493 498
494 499
495 #ifdef MIPS_ABI_N64 500 #ifdef MIPS_ABI_N64
496 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7, p8) \ 501 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \
497 static_cast<int>(Simulator::current(Isolate::Current()) \ 502 p7, p8) \
498 ->Call(entry, 10, p0, p1, p2, p3, p4, \ 503 static_cast<int>(Simulator::current(isolate)->Call( \
499 reinterpret_cast<int64_t*>(p5), p6, p7, NULL, \ 504 entry, 10, p0, p1, p2, p3, p4, reinterpret_cast<int64_t*>(p5), p6, p7, \
500 p8)) 505 NULL, p8))
501 #else // Must be O32 Abi. 506 #else // Must be O32 Abi.
502 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7, p8) \ 507 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \
503 static_cast<int>( \ 508 p7, p8) \
504 Simulator::current(Isolate::Current()) \ 509 static_cast<int>(Simulator::current(isolate)->Call( \
505 ->Call(entry, 10, p0, p1, p2, p3, NULL, p4, p5, p6, p7, p8)) 510 entry, 10, p0, p1, p2, p3, NULL, p4, p5, p6, p7, p8))
506 #endif // MIPS_ABI_N64 511 #endif // MIPS_ABI_N64
507 512
508 513
509 // The simulator has its own stack. Thus it has a different stack limit from 514 // The simulator has its own stack. Thus it has a different stack limit from
510 // the C-based native code. The JS-based limit normally points near the end of 515 // the C-based native code. The JS-based limit normally points near the end of
511 // the simulator stack. When the C-based limit is exhausted we reflect that by 516 // the simulator stack. When the C-based limit is exhausted we reflect that by
512 // lowering the JS-based limit as well, to make stack checks trigger. 517 // lowering the JS-based limit as well, to make stack checks trigger.
513 class SimulatorStack : public v8::internal::AllStatic { 518 class SimulatorStack : public v8::internal::AllStatic {
514 public: 519 public:
515 static inline uintptr_t JsLimitFromCLimit(Isolate* isolate, 520 static inline uintptr_t JsLimitFromCLimit(Isolate* isolate,
516 uintptr_t c_limit) { 521 uintptr_t c_limit) {
517 return Simulator::current(isolate)->StackLimit(c_limit); 522 return Simulator::current(isolate)->StackLimit(c_limit);
518 } 523 }
519 524
520 static inline uintptr_t RegisterCTryCatch(uintptr_t try_catch_address) { 525 static inline uintptr_t RegisterCTryCatch(Isolate* isolate,
521 Simulator* sim = Simulator::current(Isolate::Current()); 526 uintptr_t try_catch_address) {
527 Simulator* sim = Simulator::current(isolate);
522 return sim->PushAddress(try_catch_address); 528 return sim->PushAddress(try_catch_address);
523 } 529 }
524 530
525 static inline void UnregisterCTryCatch() { 531 static inline void UnregisterCTryCatch(Isolate* isolate) {
526 Simulator::current(Isolate::Current())->PopAddress(); 532 Simulator::current(isolate)->PopAddress();
527 } 533 }
528 }; 534 };
529 535
530 } // namespace internal 536 } // namespace internal
531 } // namespace v8 537 } // namespace v8
532 538
533 #endif // !defined(USE_SIMULATOR) 539 #endif // !defined(USE_SIMULATOR)
534 #endif // V8_MIPS_SIMULATOR_MIPS_H_ 540 #endif // V8_MIPS_SIMULATOR_MIPS_H_
OLDNEW
« no previous file with comments | « src/mips/simulator-mips.cc ('k') | src/mips64/simulator-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698