1// Copyright 2014 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Declares a Simulator for S390 instructions if we are not generating a native
6// S390 binary. This Simulator allows us to run and debug S390 code generation
7// on regular desktop machines.
8// V8 calls into generated code by "calling" the CALL_GENERATED_CODE macro,
9// which will start execution in the Simulator or forwards to the real entry
10// on a S390 hardware platform.
11
12#ifndef V8_S390_SIMULATOR_S390_H_
13#define V8_S390_SIMULATOR_S390_H_
14
15#include "src/allocation.h"
16
17#if !defined(USE_SIMULATOR)
18// Running without a simulator on a native s390 platform.
19
20namespace v8 {
21namespace internal {
22
23// When running without a simulator we call the entry directly.
24#define CALL_GENERATED_CODE(isolate, entry, p0, p1, p2, p3, p4) \
25  (entry(p0, p1, p2, p3, p4))
26
27typedef int (*s390_regexp_matcher)(String*, int, const byte*, const byte*, int*,
28                                   int, Address, int, void*, Isolate*);
29
30// Call the generated regexp code directly. The code at the entry address
31// should act as a function matching the type ppc_regexp_matcher.
32// The ninth argument is a dummy that reserves the space used for
33// the return address added by the ExitFrame in native calls.
34#define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \
35                                   p7, p8)                                     \
36  (FUNCTION_CAST<s390_regexp_matcher>(entry)(p0, p1, p2, p3, p4, p5, p6, p7,   \
37                                             NULL, p8))
38
39// The stack limit beyond which we will throw stack overflow errors in
40// generated code. Because generated code on s390 uses the C stack, we
41// just use the C stack limit.
42class SimulatorStack : public v8::internal::AllStatic {
43 public:
44  static inline uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate,
45                                            uintptr_t c_limit) {
46    USE(isolate);
47    return c_limit;
48  }
49
50  static inline uintptr_t RegisterCTryCatch(v8::internal::Isolate* isolate,
51                                            uintptr_t try_catch_address) {
52    USE(isolate);
53    return try_catch_address;
54  }
55
56  static inline void UnregisterCTryCatch(v8::internal::Isolate* isolate) {
57    USE(isolate);
58  }
59};
60}  // namespace internal
61}  // namespace v8
62
63#else  // !defined(USE_SIMULATOR)
64// Running with a simulator.
65
66#include "src/assembler.h"
67#include "src/base/hashmap.h"
68#include "src/s390/constants-s390.h"
69
70namespace v8 {
71namespace internal {
72
73class CachePage {
74 public:
75  static const int LINE_VALID = 0;
76  static const int LINE_INVALID = 1;
77
78  static const int kPageShift = 12;
79  static const int kPageSize = 1 << kPageShift;
80  static const int kPageMask = kPageSize - 1;
81  static const int kLineShift = 2;  // The cache line is only 4 bytes right now.
82  static const int kLineLength = 1 << kLineShift;
83  static const int kLineMask = kLineLength - 1;
84
85  CachePage() { memset(&validity_map_, LINE_INVALID, sizeof(validity_map_)); }
86
87  char* ValidityByte(int offset) {
88    return &validity_map_[offset >> kLineShift];
89  }
90
91  char* CachedData(int offset) { return &data_[offset]; }
92
93 private:
94  char data_[kPageSize];  // The cached data.
95  static const int kValidityMapSize = kPageSize >> kLineShift;
96  char validity_map_[kValidityMapSize];  // One byte per line.
97};
98
99class Simulator {
100 public:
101  friend class S390Debugger;
102  enum Register {
103    no_reg = -1,
104    r0 = 0,
105    r1 = 1,
106    r2 = 2,
107    r3 = 3,
108    r4 = 4,
109    r5 = 5,
110    r6 = 6,
111    r7 = 7,
112    r8 = 8,
113    r9 = 9,
114    r10 = 10,
115    r11 = 11,
116    r12 = 12,
117    r13 = 13,
118    r14 = 14,
119    r15 = 15,
120    fp = r11,
121    ip = r12,
122    cp = r13,
123    ra = r14,
124    sp = r15,  // name aliases
125    kNumGPRs = 16,
126    d0 = 0,
127    d1,
128    d2,
129    d3,
130    d4,
131    d5,
132    d6,
133    d7,
134    d8,
135    d9,
136    d10,
137    d11,
138    d12,
139    d13,
140    d14,
141    d15,
142    kNumFPRs = 16
143  };
144
145  explicit Simulator(Isolate* isolate);
146  ~Simulator();
147
148  // The currently executing Simulator instance. Potentially there can be one
149  // for each native thread.
150  static Simulator* current(v8::internal::Isolate* isolate);
151
152  // Accessors for register state.
153  void set_register(int reg, uint64_t value);
154  uint64_t get_register(int reg) const;
155  template <typename T>
156  T get_low_register(int reg) const;
157  template <typename T>
158  T get_high_register(int reg) const;
159  void set_low_register(int reg, uint32_t value);
160  void set_high_register(int reg, uint32_t value);
161
162  double get_double_from_register_pair(int reg);
163  void set_d_register_from_double(int dreg, const double dbl) {
164    DCHECK(dreg >= 0 && dreg < kNumFPRs);
165    *bit_cast<double*>(&fp_registers_[dreg]) = dbl;
166  }
167
168  double get_double_from_d_register(int dreg) {
169    DCHECK(dreg >= 0 && dreg < kNumFPRs);
170    return *bit_cast<double*>(&fp_registers_[dreg]);
171  }
172  void set_d_register(int dreg, int64_t value) {
173    DCHECK(dreg >= 0 && dreg < kNumFPRs);
174    fp_registers_[dreg] = value;
175  }
176  int64_t get_d_register(int dreg) {
177    DCHECK(dreg >= 0 && dreg < kNumFPRs);
178    return fp_registers_[dreg];
179  }
180
181  void set_d_register_from_float32(int dreg, const float f) {
182    DCHECK(dreg >= 0 && dreg < kNumFPRs);
183
184    int32_t f_int = *bit_cast<int32_t*>(&f);
185    int64_t finalval = static_cast<int64_t>(f_int) << 32;
186    set_d_register(dreg, finalval);
187  }
188
189  float get_float32_from_d_register(int dreg) {
190    DCHECK(dreg >= 0 && dreg < kNumFPRs);
191
192    int64_t regval = get_d_register(dreg) >> 32;
193    int32_t regval32 = static_cast<int32_t>(regval);
194    return *bit_cast<float*>(&regval32);
195  }
196
197  // Special case of set_register and get_register to access the raw PC value.
198  void set_pc(intptr_t value);
199  intptr_t get_pc() const;
200
201  Address get_sp() const {
202    return reinterpret_cast<Address>(static_cast<intptr_t>(get_register(sp)));
203  }
204
205  // Accessor to the internal simulator stack area.
206  uintptr_t StackLimit(uintptr_t c_limit) const;
207
208  // Executes S390 instructions until the PC reaches end_sim_pc.
209  void Execute();
210
211  // Call on program start.
212  static void Initialize(Isolate* isolate);
213
214  static void TearDown(base::CustomMatcherHashMap* i_cache, Redirection* first);
215
216  // V8 generally calls into generated JS code with 5 parameters and into
217  // generated RegExp code with 7 parameters. This is a convenience function,
218  // which sets up the simulator state and grabs the result on return.
219  intptr_t Call(byte* entry, int argument_count, ...);
220  // Alternative: call a 2-argument double function.
221  void CallFP(byte* entry, double d0, double d1);
222  int32_t CallFPReturnsInt(byte* entry, double d0, double d1);
223  double CallFPReturnsDouble(byte* entry, double d0, double d1);
224
225  // Push an address onto the JS stack.
226  uintptr_t PushAddress(uintptr_t address);
227
228  // Pop an address from the JS stack.
229  uintptr_t PopAddress();
230
231  // Debugger input.
232  void set_last_debugger_input(char* input);
233  char* last_debugger_input() { return last_debugger_input_; }
234
235  // ICache checking.
236  static void FlushICache(base::CustomMatcherHashMap* i_cache, void* start,
237                          size_t size);
238
239  // Returns true if pc register contains one of the 'special_values' defined
240  // below (bad_lr, end_sim_pc).
241  bool has_bad_pc() const;
242
243 private:
244  enum special_values {
245    // Known bad pc value to ensure that the simulator does not execute
246    // without being properly setup.
247    bad_lr = -1,
248    // A pc value used to signal the simulator to stop execution.  Generally
249    // the lr is set to this value on transition from native C code to
250    // simulated execution, so that the simulator can "return" to the native
251    // C code.
252    end_sim_pc = -2
253  };
254
255  // Unsupported instructions use Format to print an error and stop execution.
256  void Format(Instruction* instr, const char* format);
257
258  // Helper functions to set the conditional flags in the architecture state.
259  bool CarryFrom(int32_t left, int32_t right, int32_t carry = 0);
260  bool BorrowFrom(int32_t left, int32_t right);
261  template <typename T1>
262  inline bool OverflowFromSigned(T1 alu_out, T1 left, T1 right, bool addition);
263
264  // Helper functions to decode common "addressing" modes
265  int32_t GetShiftRm(Instruction* instr, bool* carry_out);
266  int32_t GetImm(Instruction* instr, bool* carry_out);
267  void ProcessPUW(Instruction* instr, int num_regs, int operand_size,
268                  intptr_t* start_address, intptr_t* end_address);
269  void HandleRList(Instruction* instr, bool load);
270  void HandleVList(Instruction* inst);
271  void SoftwareInterrupt(Instruction* instr);
272
273  // Stop helper functions.
274  inline bool isStopInstruction(Instruction* instr);
275  inline bool isWatchedStop(uint32_t bkpt_code);
276  inline bool isEnabledStop(uint32_t bkpt_code);
277  inline void EnableStop(uint32_t bkpt_code);
278  inline void DisableStop(uint32_t bkpt_code);
279  inline void IncreaseStopCounter(uint32_t bkpt_code);
280  void PrintStopInfo(uint32_t code);
281
282  // Byte Reverse
283  inline int16_t ByteReverse(int16_t hword);
284  inline int32_t ByteReverse(int32_t word);
285  inline int64_t ByteReverse(int64_t dword);
286
287  // Read and write memory.
288  inline uint8_t ReadBU(intptr_t addr);
289  inline int8_t ReadB(intptr_t addr);
290  inline void WriteB(intptr_t addr, uint8_t value);
291  inline void WriteB(intptr_t addr, int8_t value);
292
293  inline uint16_t ReadHU(intptr_t addr, Instruction* instr);
294  inline int16_t ReadH(intptr_t addr, Instruction* instr);
295  // Note: Overloaded on the sign of the value.
296  inline void WriteH(intptr_t addr, uint16_t value, Instruction* instr);
297  inline void WriteH(intptr_t addr, int16_t value, Instruction* instr);
298
299  inline uint32_t ReadWU(intptr_t addr, Instruction* instr);
300  inline int32_t ReadW(intptr_t addr, Instruction* instr);
301  inline int64_t ReadW64(intptr_t addr, Instruction* instr);
302  inline void WriteW(intptr_t addr, uint32_t value, Instruction* instr);
303  inline void WriteW(intptr_t addr, int32_t value, Instruction* instr);
304
305  inline int64_t ReadDW(intptr_t addr);
306  inline double ReadDouble(intptr_t addr);
307  inline float ReadFloat(intptr_t addr);
308  inline void WriteDW(intptr_t addr, int64_t value);
309
310  // S390
311  void Trace(Instruction* instr);
312  bool DecodeTwoByte(Instruction* instr);
313  bool DecodeFourByte(Instruction* instr);
314  bool DecodeFourByteArithmetic(Instruction* instr);
315  bool DecodeFourByteArithmetic64Bit(Instruction* instr);
316  bool DecodeFourByteFloatingPoint(Instruction* instr);
317  void DecodeFourByteFloatingPointIntConversion(Instruction* instr);
318  void DecodeFourByteFloatingPointRound(Instruction* instr);
319
320  bool DecodeSixByte(Instruction* instr);
321  bool DecodeSixByteArithmetic(Instruction* instr);
322  bool S390InstructionDecode(Instruction* instr);
323  void DecodeSixByteBitShift(Instruction* instr);
324
325  // Used by the CL**BR instructions.
326  template <typename T1, typename T2>
327  void SetS390RoundConditionCode(T1 r2_val, T2 max, T2 min) {
328    condition_reg_ = 0;
329    double r2_dval = static_cast<double>(r2_val);
330    double dbl_min = static_cast<double>(min);
331    double dbl_max = static_cast<double>(max);
332
333    if (r2_dval == 0.0)
334      condition_reg_ = 8;
335    else if (r2_dval < 0.0 && r2_dval >= dbl_min && std::isfinite(r2_dval))
336      condition_reg_ = 4;
337    else if (r2_dval > 0.0 && r2_dval <= dbl_max && std::isfinite(r2_dval))
338      condition_reg_ = 2;
339    else
340      condition_reg_ = 1;
341  }
342
343  template <typename T1>
344  void SetS390RoundConditionCode(T1 r2_val, int64_t max, int64_t min) {
345    condition_reg_ = 0;
346    double r2_dval = static_cast<double>(r2_val);
347    double dbl_min = static_cast<double>(min);
348    double dbl_max = static_cast<double>(max);
349
350    // Note that the IEEE 754 floating-point representations (both 32 and
351    // 64 bit) cannot exactly represent INT64_MAX. The closest it can get
352    // is INT64_max + 1. IEEE 754 FP can, though, represent INT64_MIN
353    // exactly.
354
355    // This is not an issue for INT32, as IEEE754 64-bit can represent
356    // INT32_MAX and INT32_MIN with exact precision.
357
358    if (r2_dval == 0.0)
359      condition_reg_ = 8;
360    else if (r2_dval < 0.0 && r2_dval >= dbl_min && std::isfinite(r2_dval))
361      condition_reg_ = 4;
362    else if (r2_dval > 0.0 && r2_dval < dbl_max && std::isfinite(r2_dval))
363      condition_reg_ = 2;
364    else
365      condition_reg_ = 1;
366  }
367
368  // Used by the CL**BR instructions.
369  template <typename T1, typename T2, typename T3>
370  void SetS390ConvertConditionCode(T1 src, T2 dst, T3 max) {
371    condition_reg_ = 0;
372    if (src == static_cast<T1>(0.0)) {
373      condition_reg_ |= 8;
374    } else if (src < static_cast<T1>(0.0) && static_cast<T2>(src) == 0 &&
375               std::isfinite(src)) {
376      condition_reg_ |= 4;
377    } else if (src > static_cast<T1>(0.0) && std::isfinite(src) &&
378               src < static_cast<T1>(max)) {
379      condition_reg_ |= 2;
380    } else {
381      condition_reg_ |= 1;
382    }
383  }
384
385  template <typename T>
386  void SetS390ConditionCode(T lhs, T rhs) {
387    condition_reg_ = 0;
388    if (lhs == rhs) {
389      condition_reg_ |= CC_EQ;
390    } else if (lhs < rhs) {
391      condition_reg_ |= CC_LT;
392    } else if (lhs > rhs) {
393      condition_reg_ |= CC_GT;
394    }
395
396    // We get down here only for floating point
397    // comparisons and the values are unordered
398    // i.e. NaN
399    if (condition_reg_ == 0) condition_reg_ = unordered;
400  }
401
402  // Used by arithmetic operations that use carry.
403  template <typename T>
404  void SetS390ConditionCodeCarry(T result, bool overflow) {
405    condition_reg_ = 0;
406    bool zero_result = (result == static_cast<T>(0));
407    if (zero_result && !overflow) {
408      condition_reg_ |= 8;
409    } else if (!zero_result && !overflow) {
410      condition_reg_ |= 4;
411    } else if (zero_result && overflow) {
412      condition_reg_ |= 2;
413    } else if (!zero_result && overflow) {
414      condition_reg_ |= 1;
415    }
416    if (condition_reg_ == 0) UNREACHABLE();
417  }
418
419  bool isNaN(double value) { return (value != value); }
420
421  // Set the condition code for bitwise operations
422  // CC0 is set if value == 0.
423  // CC1 is set if value != 0.
424  // CC2/CC3 are not set.
425  template <typename T>
426  void SetS390BitWiseConditionCode(T value) {
427    condition_reg_ = 0;
428
429    if (value == 0)
430      condition_reg_ |= CC_EQ;
431    else
432      condition_reg_ |= CC_LT;
433  }
434
435  void SetS390OverflowCode(bool isOF) {
436    if (isOF) condition_reg_ = CC_OF;
437  }
438
439  bool TestConditionCode(Condition mask) {
440    // Check for unconditional branch
441    if (mask == 0xf) return true;
442
443    return (condition_reg_ & mask) != 0;
444  }
445
446  // Executes one instruction.
447  void ExecuteInstruction(Instruction* instr, bool auto_incr_pc = true);
448
449  // ICache.
450  static void CheckICache(base::CustomMatcherHashMap* i_cache,
451                          Instruction* instr);
452  static void FlushOnePage(base::CustomMatcherHashMap* i_cache, intptr_t start,
453                           int size);
454  static CachePage* GetCachePage(base::CustomMatcherHashMap* i_cache,
455                                 void* page);
456
457  // Runtime call support.
458  static void* RedirectExternalReference(
459      Isolate* isolate, void* external_function,
460      v8::internal::ExternalReference::Type type);
461
462  // Handle arguments and return value for runtime FP functions.
463  void GetFpArgs(double* x, double* y, intptr_t* z);
464  void SetFpResult(const double& result);
465  void TrashCallerSaveRegisters();
466
467  void CallInternal(byte* entry, int reg_arg_count = 3);
468
469  // Architecture state.
470  // On z9 and higher and supported Linux on z Systems platforms, all registers
471  // are 64-bit, even in 31-bit mode.
472  uint64_t registers_[kNumGPRs];
473  int64_t fp_registers_[kNumFPRs];
474
475  // Condition Code register. In S390, the last 4 bits are used.
476  int32_t condition_reg_;
477  // Special register to track PC.
478  intptr_t special_reg_pc_;
479
480  // Simulator support.
481  char* stack_;
482  static const size_t stack_protection_size_ = 256 * kPointerSize;
483  bool pc_modified_;
484  int64_t icount_;
485
486  // Debugger input.
487  char* last_debugger_input_;
488
489  // Icache simulation
490  base::CustomMatcherHashMap* i_cache_;
491
492  // Registered breakpoints.
493  Instruction* break_pc_;
494  Instr break_instr_;
495
496  v8::internal::Isolate* isolate_;
497
498  // A stop is watched if its code is less than kNumOfWatchedStops.
499  // Only watched stops support enabling/disabling and the counter feature.
500  static const uint32_t kNumOfWatchedStops = 256;
501
502  // Breakpoint is disabled if bit 31 is set.
503  static const uint32_t kStopDisabledBit = 1 << 31;
504
505  // A stop is enabled, meaning the simulator will stop when meeting the
506  // instruction, if bit 31 of watched_stops_[code].count is unset.
507  // The value watched_stops_[code].count & ~(1 << 31) indicates how many times
508  // the breakpoint was hit or gone through.
509  struct StopCountAndDesc {
510    uint32_t count;
511    char* desc;
512  };
513  StopCountAndDesc watched_stops_[kNumOfWatchedStops];
514  void DebugStart();
515
516  int DecodeInstructionOriginal(Instruction* instr);
517  int DecodeInstruction(Instruction* instr);
518  int Evaluate_Unknown(Instruction* instr);
519#define MAX_NUM_OPCODES (1 << 16)
520  typedef int (Simulator::*EvaluateFuncType)(Instruction*);
521
522  static EvaluateFuncType EvalTable[MAX_NUM_OPCODES];
523  static void EvalTableInit();
524
525#define EVALUATE(name) int Evaluate_##name(Instruction* instr)
526#define EVALUATE_VRR_INSTRUCTIONS(name, op_name, op_value) EVALUATE(op_name);
527  S390_VRR_C_OPCODE_LIST(EVALUATE_VRR_INSTRUCTIONS)
528  S390_VRR_A_OPCODE_LIST(EVALUATE_VRR_INSTRUCTIONS)
529#undef EVALUATE_VRR_INSTRUCTIONS
530
531  EVALUATE(DUMY);
532  EVALUATE(BKPT);
533  EVALUATE(SPM);
534  EVALUATE(BALR);
535  EVALUATE(BCTR);
536  EVALUATE(BCR);
537  EVALUATE(SVC);
538  EVALUATE(BSM);
539  EVALUATE(BASSM);
540  EVALUATE(BASR);
541  EVALUATE(MVCL);
542  EVALUATE(CLCL);
543  EVALUATE(LPR);
544  EVALUATE(LNR);
545  EVALUATE(LTR);
546  EVALUATE(LCR);
547  EVALUATE(NR);
548  EVALUATE(CLR);
549  EVALUATE(OR);
550  EVALUATE(XR);
551  EVALUATE(LR);
552  EVALUATE(CR);
553  EVALUATE(AR);
554  EVALUATE(SR);
555  EVALUATE(MR);
556  EVALUATE(DR);
557  EVALUATE(ALR);
558  EVALUATE(SLR);
559  EVALUATE(LDR);
560  EVALUATE(CDR);
561  EVALUATE(LER);
562  EVALUATE(STH);
563  EVALUATE(LA);
564  EVALUATE(STC);
565  EVALUATE(IC_z);
566  EVALUATE(EX);
567  EVALUATE(BAL);
568  EVALUATE(BCT);
569  EVALUATE(BC);
570  EVALUATE(LH);
571  EVALUATE(CH);
572  EVALUATE(AH);
573  EVALUATE(SH);
574  EVALUATE(MH);
575  EVALUATE(BAS);
576  EVALUATE(CVD);
577  EVALUATE(CVB);
578  EVALUATE(ST);
579  EVALUATE(LAE);
580  EVALUATE(N);
581  EVALUATE(CL);
582  EVALUATE(O);
583  EVALUATE(X);
584  EVALUATE(L);
585  EVALUATE(C);
586  EVALUATE(A);
587  EVALUATE(S);
588  EVALUATE(M);
589  EVALUATE(D);
590  EVALUATE(AL);
591  EVALUATE(SL);
592  EVALUATE(STD);
593  EVALUATE(LD);
594  EVALUATE(CD);
595  EVALUATE(STE);
596  EVALUATE(MS);
597  EVALUATE(LE);
598  EVALUATE(BRXH);
599  EVALUATE(BRXLE);
600  EVALUATE(BXH);
601  EVALUATE(BXLE);
602  EVALUATE(SRL);
603  EVALUATE(SLL);
604  EVALUATE(SRA);
605  EVALUATE(SLA);
606  EVALUATE(SRDL);
607  EVALUATE(SLDL);
608  EVALUATE(SRDA);
609  EVALUATE(SLDA);
610  EVALUATE(STM);
611  EVALUATE(TM);
612  EVALUATE(MVI);
613  EVALUATE(TS);
614  EVALUATE(NI);
615  EVALUATE(CLI);
616  EVALUATE(OI);
617  EVALUATE(XI);
618  EVALUATE(LM);
619  EVALUATE(MVCLE);
620  EVALUATE(CLCLE);
621  EVALUATE(MC);
622  EVALUATE(CDS);
623  EVALUATE(STCM);
624  EVALUATE(ICM);
625  EVALUATE(BPRP);
626  EVALUATE(BPP);
627  EVALUATE(TRTR);
628  EVALUATE(MVN);
629  EVALUATE(MVC);
630  EVALUATE(MVZ);
631  EVALUATE(NC);
632  EVALUATE(CLC);
633  EVALUATE(OC);
634  EVALUATE(XC);
635  EVALUATE(MVCP);
636  EVALUATE(TR);
637  EVALUATE(TRT);
638  EVALUATE(ED);
639  EVALUATE(EDMK);
640  EVALUATE(PKU);
641  EVALUATE(UNPKU);
642  EVALUATE(MVCIN);
643  EVALUATE(PKA);
644  EVALUATE(UNPKA);
645  EVALUATE(PLO);
646  EVALUATE(LMD);
647  EVALUATE(SRP);
648  EVALUATE(MVO);
649  EVALUATE(PACK);
650  EVALUATE(UNPK);
651  EVALUATE(ZAP);
652  EVALUATE(AP);
653  EVALUATE(SP);
654  EVALUATE(MP);
655  EVALUATE(DP);
656  EVALUATE(UPT);
657  EVALUATE(PFPO);
658  EVALUATE(IIHH);
659  EVALUATE(IIHL);
660  EVALUATE(IILH);
661  EVALUATE(IILL);
662  EVALUATE(NIHH);
663  EVALUATE(NIHL);
664  EVALUATE(NILH);
665  EVALUATE(NILL);
666  EVALUATE(OIHH);
667  EVALUATE(OIHL);
668  EVALUATE(OILH);
669  EVALUATE(OILL);
670  EVALUATE(LLIHH);
671  EVALUATE(LLIHL);
672  EVALUATE(LLILH);
673  EVALUATE(LLILL);
674  EVALUATE(TMLH);
675  EVALUATE(TMLL);
676  EVALUATE(TMHH);
677  EVALUATE(TMHL);
678  EVALUATE(BRC);
679  EVALUATE(BRAS);
680  EVALUATE(BRCT);
681  EVALUATE(BRCTG);
682  EVALUATE(LHI);
683  EVALUATE(LGHI);
684  EVALUATE(AHI);
685  EVALUATE(AGHI);
686  EVALUATE(MHI);
687  EVALUATE(MGHI);
688  EVALUATE(CHI);
689  EVALUATE(CGHI);
690  EVALUATE(LARL);
691  EVALUATE(LGFI);
692  EVALUATE(BRCL);
693  EVALUATE(BRASL);
694  EVALUATE(XIHF);
695  EVALUATE(XILF);
696  EVALUATE(IIHF);
697  EVALUATE(IILF);
698  EVALUATE(NIHF);
699  EVALUATE(NILF);
700  EVALUATE(OIHF);
701  EVALUATE(OILF);
702  EVALUATE(LLIHF);
703  EVALUATE(LLILF);
704  EVALUATE(MSGFI);
705  EVALUATE(MSFI);
706  EVALUATE(SLGFI);
707  EVALUATE(SLFI);
708  EVALUATE(AGFI);
709  EVALUATE(AFI);
710  EVALUATE(ALGFI);
711  EVALUATE(ALFI);
712  EVALUATE(CGFI);
713  EVALUATE(CFI);
714  EVALUATE(CLGFI);
715  EVALUATE(CLFI);
716  EVALUATE(LLHRL);
717  EVALUATE(LGHRL);
718  EVALUATE(LHRL);
719  EVALUATE(LLGHRL);
720  EVALUATE(STHRL);
721  EVALUATE(LGRL);
722  EVALUATE(STGRL);
723  EVALUATE(LGFRL);
724  EVALUATE(LRL);
725  EVALUATE(LLGFRL);
726  EVALUATE(STRL);
727  EVALUATE(EXRL);
728  EVALUATE(PFDRL);
729  EVALUATE(CGHRL);
730  EVALUATE(CHRL);
731  EVALUATE(CGRL);
732  EVALUATE(CGFRL);
733  EVALUATE(ECTG);
734  EVALUATE(CSST);
735  EVALUATE(LPD);
736  EVALUATE(LPDG);
737  EVALUATE(BRCTH);
738  EVALUATE(AIH);
739  EVALUATE(ALSIH);
740  EVALUATE(ALSIHN);
741  EVALUATE(CIH);
742  EVALUATE(CLIH);
743  EVALUATE(STCK);
744  EVALUATE(CFC);
745  EVALUATE(IPM);
746  EVALUATE(HSCH);
747  EVALUATE(MSCH);
748  EVALUATE(SSCH);
749  EVALUATE(STSCH);
750  EVALUATE(TSCH);
751  EVALUATE(TPI);
752  EVALUATE(SAL);
753  EVALUATE(RSCH);
754  EVALUATE(STCRW);
755  EVALUATE(STCPS);
756  EVALUATE(RCHP);
757  EVALUATE(SCHM);
758  EVALUATE(CKSM);
759  EVALUATE(SAR);
760  EVALUATE(EAR);
761  EVALUATE(MSR);
762  EVALUATE(MSRKC);
763  EVALUATE(MVST);
764  EVALUATE(CUSE);
765  EVALUATE(SRST);
766  EVALUATE(XSCH);
767  EVALUATE(STCKE);
768  EVALUATE(STCKF);
769  EVALUATE(SRNM);
770  EVALUATE(STFPC);
771  EVALUATE(LFPC);
772  EVALUATE(TRE);
773  EVALUATE(CUUTF);
774  EVALUATE(CUTFU);
775  EVALUATE(STFLE);
776  EVALUATE(SRNMB);
777  EVALUATE(SRNMT);
778  EVALUATE(LFAS);
779  EVALUATE(PPA);
780  EVALUATE(ETND);
781  EVALUATE(TEND);
782  EVALUATE(NIAI);
783  EVALUATE(TABORT);
784  EVALUATE(TRAP4);
785  EVALUATE(LPEBR);
786  EVALUATE(LNEBR);
787  EVALUATE(LTEBR);
788  EVALUATE(LCEBR);
789  EVALUATE(LDEBR);
790  EVALUATE(LXDBR);
791  EVALUATE(LXEBR);
792  EVALUATE(MXDBR);
793  EVALUATE(KEBR);
794  EVALUATE(CEBR);
795  EVALUATE(AEBR);
796  EVALUATE(SEBR);
797  EVALUATE(MDEBR);
798  EVALUATE(DEBR);
799  EVALUATE(MAEBR);
800  EVALUATE(MSEBR);
801  EVALUATE(LPDBR);
802  EVALUATE(LNDBR);
803  EVALUATE(LTDBR);
804  EVALUATE(LCDBR);
805  EVALUATE(SQEBR);
806  EVALUATE(SQDBR);
807  EVALUATE(SQXBR);
808  EVALUATE(MEEBR);
809  EVALUATE(KDBR);
810  EVALUATE(CDBR);
811  EVALUATE(ADBR);
812  EVALUATE(SDBR);
813  EVALUATE(MDBR);
814  EVALUATE(DDBR);
815  EVALUATE(MADBR);
816  EVALUATE(MSDBR);
817  EVALUATE(LPXBR);
818  EVALUATE(LNXBR);
819  EVALUATE(LTXBR);
820  EVALUATE(LCXBR);
821  EVALUATE(LEDBRA);
822  EVALUATE(LDXBRA);
823  EVALUATE(LEXBRA);
824  EVALUATE(FIXBRA);
825  EVALUATE(KXBR);
826  EVALUATE(CXBR);
827  EVALUATE(AXBR);
828  EVALUATE(SXBR);
829  EVALUATE(MXBR);
830  EVALUATE(DXBR);
831  EVALUATE(TBEDR);
832  EVALUATE(TBDR);
833  EVALUATE(DIEBR);
834  EVALUATE(FIEBRA);
835  EVALUATE(THDER);
836  EVALUATE(THDR);
837  EVALUATE(DIDBR);
838  EVALUATE(FIDBRA);
839  EVALUATE(LXR);
840  EVALUATE(LPDFR);
841  EVALUATE(LNDFR);
842  EVALUATE(LCDFR);
843  EVALUATE(LZER);
844  EVALUATE(LZDR);
845  EVALUATE(LZXR);
846  EVALUATE(SFPC);
847  EVALUATE(SFASR);
848  EVALUATE(EFPC);
849  EVALUATE(CELFBR);
850  EVALUATE(CDLFBR);
851  EVALUATE(CXLFBR);
852  EVALUATE(CEFBRA);
853  EVALUATE(CDFBRA);
854  EVALUATE(CXFBRA);
855  EVALUATE(CFEBRA);
856  EVALUATE(CFDBRA);
857  EVALUATE(CFXBRA);
858  EVALUATE(CLFEBR);
859  EVALUATE(CLFDBR);
860  EVALUATE(CLFXBR);
861  EVALUATE(CELGBR);
862  EVALUATE(CDLGBR);
863  EVALUATE(CXLGBR);
864  EVALUATE(CEGBRA);
865  EVALUATE(CDGBRA);
866  EVALUATE(CXGBRA);
867  EVALUATE(CGEBRA);
868  EVALUATE(CGDBRA);
869  EVALUATE(CGXBRA);
870  EVALUATE(CLGEBR);
871  EVALUATE(CLGDBR);
872  EVALUATE(CFER);
873  EVALUATE(CFDR);
874  EVALUATE(CFXR);
875  EVALUATE(LDGR);
876  EVALUATE(CGER);
877  EVALUATE(CGDR);
878  EVALUATE(CGXR);
879  EVALUATE(LGDR);
880  EVALUATE(MDTR);
881  EVALUATE(MDTRA);
882  EVALUATE(DDTRA);
883  EVALUATE(ADTRA);
884  EVALUATE(SDTRA);
885  EVALUATE(LDETR);
886  EVALUATE(LEDTR);
887  EVALUATE(LTDTR);
888  EVALUATE(FIDTR);
889  EVALUATE(MXTRA);
890  EVALUATE(DXTRA);
891  EVALUATE(AXTRA);
892  EVALUATE(SXTRA);
893  EVALUATE(LXDTR);
894  EVALUATE(LDXTR);
895  EVALUATE(LTXTR);
896  EVALUATE(FIXTR);
897  EVALUATE(KDTR);
898  EVALUATE(CGDTRA);
899  EVALUATE(CUDTR);
900  EVALUATE(CDTR);
901  EVALUATE(EEDTR);
902  EVALUATE(ESDTR);
903  EVALUATE(KXTR);
904  EVALUATE(CGXTRA);
905  EVALUATE(CUXTR);
906  EVALUATE(CSXTR);
907  EVALUATE(CXTR);
908  EVALUATE(EEXTR);
909  EVALUATE(ESXTR);
910  EVALUATE(CDGTRA);
911  EVALUATE(CDUTR);
912  EVALUATE(CDSTR);
913  EVALUATE(CEDTR);
914  EVALUATE(QADTR);
915  EVALUATE(IEDTR);
916  EVALUATE(RRDTR);
917  EVALUATE(CXGTRA);
918  EVALUATE(CXUTR);
919  EVALUATE(CXSTR);
920  EVALUATE(CEXTR);
921  EVALUATE(QAXTR);
922  EVALUATE(IEXTR);
923  EVALUATE(RRXTR);
924  EVALUATE(LPGR);
925  EVALUATE(LNGR);
926  EVALUATE(LTGR);
927  EVALUATE(LCGR);
928  EVALUATE(LGR);
929  EVALUATE(LGBR);
930  EVALUATE(LGHR);
931  EVALUATE(AGR);
932  EVALUATE(SGR);
933  EVALUATE(ALGR);
934  EVALUATE(SLGR);
935  EVALUATE(MSGR);
936  EVALUATE(MSGRKC);
937  EVALUATE(DSGR);
938  EVALUATE(LRVGR);
939  EVALUATE(LPGFR);
940  EVALUATE(LNGFR);
941  EVALUATE(LTGFR);
942  EVALUATE(LCGFR);
943  EVALUATE(LGFR);
944  EVALUATE(LLGFR);
945  EVALUATE(LLGTR);
946  EVALUATE(AGFR);
947  EVALUATE(SGFR);
948  EVALUATE(ALGFR);
949  EVALUATE(SLGFR);
950  EVALUATE(MSGFR);
951  EVALUATE(DSGFR);
952  EVALUATE(KMAC);
953  EVALUATE(LRVR);
954  EVALUATE(CGR);
955  EVALUATE(CLGR);
956  EVALUATE(LBR);
957  EVALUATE(LHR);
958  EVALUATE(KMF);
959  EVALUATE(KMO);
960  EVALUATE(PCC);
961  EVALUATE(KMCTR);
962  EVALUATE(KM);
963  EVALUATE(KMC);
964  EVALUATE(CGFR);
965  EVALUATE(KIMD);
966  EVALUATE(KLMD);
967  EVALUATE(CFDTR);
968  EVALUATE(CLGDTR);
969  EVALUATE(CLFDTR);
970  EVALUATE(BCTGR);
971  EVALUATE(CFXTR);
972  EVALUATE(CLFXTR);
973  EVALUATE(CDFTR);
974  EVALUATE(CDLGTR);
975  EVALUATE(CDLFTR);
976  EVALUATE(CXFTR);
977  EVALUATE(CXLGTR);
978  EVALUATE(CXLFTR);
979  EVALUATE(CGRT);
980  EVALUATE(NGR);
981  EVALUATE(OGR);
982  EVALUATE(XGR);
983  EVALUATE(FLOGR);
984  EVALUATE(LLGCR);
985  EVALUATE(LLGHR);
986  EVALUATE(MLGR);
987  EVALUATE(DLGR);
988  EVALUATE(ALCGR);
989  EVALUATE(SLBGR);
990  EVALUATE(EPSW);
991  EVALUATE(TRTT);
992  EVALUATE(TRTO);
993  EVALUATE(TROT);
994  EVALUATE(TROO);
995  EVALUATE(LLCR);
996  EVALUATE(LLHR);
997  EVALUATE(MLR);
998  EVALUATE(DLR);
999  EVALUATE(ALCR);
1000  EVALUATE(SLBR);
1001  EVALUATE(CU14);
1002  EVALUATE(CU24);
1003  EVALUATE(CU41);
1004  EVALUATE(CU42);
1005  EVALUATE(TRTRE);
1006  EVALUATE(SRSTU);
1007  EVALUATE(TRTE);
1008  EVALUATE(AHHHR);
1009  EVALUATE(SHHHR);
1010  EVALUATE(ALHHHR);
1011  EVALUATE(SLHHHR);
1012  EVALUATE(CHHR);
1013  EVALUATE(AHHLR);
1014  EVALUATE(SHHLR);
1015  EVALUATE(ALHHLR);
1016  EVALUATE(SLHHLR);
1017  EVALUATE(CHLR);
1018  EVALUATE(POPCNT_Z);
1019  EVALUATE(LOCGR);
1020  EVALUATE(NGRK);
1021  EVALUATE(OGRK);
1022  EVALUATE(XGRK);
1023  EVALUATE(AGRK);
1024  EVALUATE(SGRK);
1025  EVALUATE(ALGRK);
1026  EVALUATE(SLGRK);
1027  EVALUATE(LOCR);
1028  EVALUATE(NRK);
1029  EVALUATE(ORK);
1030  EVALUATE(XRK);
1031  EVALUATE(ARK);
1032  EVALUATE(SRK);
1033  EVALUATE(ALRK);
1034  EVALUATE(SLRK);
1035  EVALUATE(LTG);
1036  EVALUATE(LG);
1037  EVALUATE(CVBY);
1038  EVALUATE(AG);
1039  EVALUATE(SG);
1040  EVALUATE(ALG);
1041  EVALUATE(SLG);
1042  EVALUATE(MSG);
1043  EVALUATE(DSG);
1044  EVALUATE(CVBG);
1045  EVALUATE(LRVG);
1046  EVALUATE(LT);
1047  EVALUATE(LGF);
1048  EVALUATE(LGH);
1049  EVALUATE(LLGF);
1050  EVALUATE(LLGT);
1051  EVALUATE(AGF);
1052  EVALUATE(SGF);
1053  EVALUATE(ALGF);
1054  EVALUATE(SLGF);
1055  EVALUATE(MSGF);
1056  EVALUATE(DSGF);
1057  EVALUATE(LRV);
1058  EVALUATE(LRVH);
1059  EVALUATE(CG);
1060  EVALUATE(CLG);
1061  EVALUATE(STG);
1062  EVALUATE(NTSTG);
1063  EVALUATE(CVDY);
1064  EVALUATE(CVDG);
1065  EVALUATE(STRVG);
1066  EVALUATE(CGF);
1067  EVALUATE(CLGF);
1068  EVALUATE(LTGF);
1069  EVALUATE(CGH);
1070  EVALUATE(PFD);
1071  EVALUATE(STRV);
1072  EVALUATE(STRVH);
1073  EVALUATE(BCTG);
1074  EVALUATE(STY);
1075  EVALUATE(MSY);
1076  EVALUATE(NY);
1077  EVALUATE(CLY);
1078  EVALUATE(OY);
1079  EVALUATE(XY);
1080  EVALUATE(LY);
1081  EVALUATE(CY);
1082  EVALUATE(AY);
1083  EVALUATE(SY);
1084  EVALUATE(MFY);
1085  EVALUATE(ALY);
1086  EVALUATE(SLY);
1087  EVALUATE(STHY);
1088  EVALUATE(LAY);
1089  EVALUATE(STCY);
1090  EVALUATE(ICY);
1091  EVALUATE(LAEY);
1092  EVALUATE(LB);
1093  EVALUATE(LGB);
1094  EVALUATE(LHY);
1095  EVALUATE(CHY);
1096  EVALUATE(AHY);
1097  EVALUATE(SHY);
1098  EVALUATE(MHY);
1099  EVALUATE(NG);
1100  EVALUATE(OG);
1101  EVALUATE(XG);
1102  EVALUATE(LGAT);
1103  EVALUATE(MLG);
1104  EVALUATE(DLG);
1105  EVALUATE(ALCG);
1106  EVALUATE(SLBG);
1107  EVALUATE(STPQ);
1108  EVALUATE(LPQ);
1109  EVALUATE(LLGC);
1110  EVALUATE(LLGH);
1111  EVALUATE(LLC);
1112  EVALUATE(LLH);
1113  EVALUATE(ML);
1114  EVALUATE(DL);
1115  EVALUATE(ALC);
1116  EVALUATE(SLB);
1117  EVALUATE(LLGTAT);
1118  EVALUATE(LLGFAT);
1119  EVALUATE(LAT);
1120  EVALUATE(LBH);
1121  EVALUATE(LLCH);
1122  EVALUATE(STCH);
1123  EVALUATE(LHH);
1124  EVALUATE(LLHH);
1125  EVALUATE(STHH);
1126  EVALUATE(LFHAT);
1127  EVALUATE(LFH);
1128  EVALUATE(STFH);
1129  EVALUATE(CHF);
1130  EVALUATE(MVCDK);
1131  EVALUATE(MVHHI);
1132  EVALUATE(MVGHI);
1133  EVALUATE(MVHI);
1134  EVALUATE(CHHSI);
1135  EVALUATE(CGHSI);
1136  EVALUATE(CHSI);
1137  EVALUATE(CLFHSI);
1138  EVALUATE(TBEGIN);
1139  EVALUATE(TBEGINC);
1140  EVALUATE(LMG);
1141  EVALUATE(SRAG);
1142  EVALUATE(SLAG);
1143  EVALUATE(SRLG);
1144  EVALUATE(SLLG);
1145  EVALUATE(CSY);
1146  EVALUATE(RLLG);
1147  EVALUATE(RLL);
1148  EVALUATE(STMG);
1149  EVALUATE(STMH);
1150  EVALUATE(STCMH);
1151  EVALUATE(STCMY);
1152  EVALUATE(CDSY);
1153  EVALUATE(CDSG);
1154  EVALUATE(BXHG);
1155  EVALUATE(BXLEG);
1156  EVALUATE(ECAG);
1157  EVALUATE(TMY);
1158  EVALUATE(MVIY);
1159  EVALUATE(NIY);
1160  EVALUATE(CLIY);
1161  EVALUATE(OIY);
1162  EVALUATE(XIY);
1163  EVALUATE(ASI);
1164  EVALUATE(ALSI);
1165  EVALUATE(AGSI);
1166  EVALUATE(ALGSI);
1167  EVALUATE(ICMH);
1168  EVALUATE(ICMY);
1169  EVALUATE(MVCLU);
1170  EVALUATE(CLCLU);
1171  EVALUATE(STMY);
1172  EVALUATE(LMH);
1173  EVALUATE(LMY);
1174  EVALUATE(TP);
1175  EVALUATE(SRAK);
1176  EVALUATE(SLAK);
1177  EVALUATE(SRLK);
1178  EVALUATE(SLLK);
1179  EVALUATE(LOCG);
1180  EVALUATE(STOCG);
1181  EVALUATE(LANG);
1182  EVALUATE(LAOG);
1183  EVALUATE(LAXG);
1184  EVALUATE(LAAG);
1185  EVALUATE(LAALG);
1186  EVALUATE(LOC);
1187  EVALUATE(STOC);
1188  EVALUATE(LAN);
1189  EVALUATE(LAO);
1190  EVALUATE(LAX);
1191  EVALUATE(LAA);
1192  EVALUATE(LAAL);
1193  EVALUATE(BRXHG);
1194  EVALUATE(BRXLG);
1195  EVALUATE(RISBLG);
1196  EVALUATE(RNSBG);
1197  EVALUATE(RISBG);
1198  EVALUATE(ROSBG);
1199  EVALUATE(RXSBG);
1200  EVALUATE(RISBGN);
1201  EVALUATE(RISBHG);
1202  EVALUATE(CGRJ);
1203  EVALUATE(CGIT);
1204  EVALUATE(CIT);
1205  EVALUATE(CLFIT);
1206  EVALUATE(CGIJ);
1207  EVALUATE(CIJ);
1208  EVALUATE(AHIK);
1209  EVALUATE(AGHIK);
1210  EVALUATE(ALHSIK);
1211  EVALUATE(ALGHSIK);
1212  EVALUATE(CGRB);
1213  EVALUATE(CGIB);
1214  EVALUATE(CIB);
1215  EVALUATE(LDEB);
1216  EVALUATE(LXDB);
1217  EVALUATE(LXEB);
1218  EVALUATE(MXDB);
1219  EVALUATE(KEB);
1220  EVALUATE(CEB);
1221  EVALUATE(AEB);
1222  EVALUATE(SEB);
1223  EVALUATE(MDEB);
1224  EVALUATE(DEB);
1225  EVALUATE(MAEB);
1226  EVALUATE(MSEB);
1227  EVALUATE(TCEB);
1228  EVALUATE(TCDB);
1229  EVALUATE(TCXB);
1230  EVALUATE(SQEB);
1231  EVALUATE(SQDB);
1232  EVALUATE(MEEB);
1233  EVALUATE(KDB);
1234  EVALUATE(CDB);
1235  EVALUATE(ADB);
1236  EVALUATE(SDB);
1237  EVALUATE(MDB);
1238  EVALUATE(DDB);
1239  EVALUATE(MADB);
1240  EVALUATE(MSDB);
1241  EVALUATE(SLDT);
1242  EVALUATE(SRDT);
1243  EVALUATE(SLXT);
1244  EVALUATE(SRXT);
1245  EVALUATE(TDCET);
1246  EVALUATE(TDGET);
1247  EVALUATE(TDCDT);
1248  EVALUATE(TDGDT);
1249  EVALUATE(TDCXT);
1250  EVALUATE(TDGXT);
1251  EVALUATE(LEY);
1252  EVALUATE(LDY);
1253  EVALUATE(STEY);
1254  EVALUATE(STDY);
1255  EVALUATE(CZDT);
1256  EVALUATE(CZXT);
1257  EVALUATE(CDZT);
1258  EVALUATE(CXZT);
1259#undef EVALUATE
1260};
1261
1262// When running with the simulator transition into simulated execution at this
1263// point.
1264#define CALL_GENERATED_CODE(isolate, entry, p0, p1, p2, p3, p4)          \
1265  reinterpret_cast<Object*>(Simulator::current(isolate)->Call(           \
1266      FUNCTION_ADDR(entry), 5, (intptr_t)p0, (intptr_t)p1, (intptr_t)p2, \
1267      (intptr_t)p3, (intptr_t)p4))
1268
1269#define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \
1270                                   p7, p8)                                     \
1271  Simulator::current(isolate)->Call(entry, 10, (intptr_t)p0, (intptr_t)p1,     \
1272                                    (intptr_t)p2, (intptr_t)p3, (intptr_t)p4,  \
1273                                    (intptr_t)p5, (intptr_t)p6, (intptr_t)p7,  \
1274                                    (intptr_t)NULL, (intptr_t)p8)
1275
1276// The simulator has its own stack. Thus it has a different stack limit from
1277// the C-based native code.  The JS-based limit normally points near the end of
1278// the simulator stack.  When the C-based limit is exhausted we reflect that by
1279// lowering the JS-based limit as well, to make stack checks trigger.
1280class SimulatorStack : public v8::internal::AllStatic {
1281 public:
1282  static inline uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate,
1283                                            uintptr_t c_limit) {
1284    return Simulator::current(isolate)->StackLimit(c_limit);
1285  }
1286
1287  static inline uintptr_t RegisterCTryCatch(v8::internal::Isolate* isolate,
1288                                            uintptr_t try_catch_address) {
1289    Simulator* sim = Simulator::current(isolate);
1290    return sim->PushAddress(try_catch_address);
1291  }
1292
1293  static inline void UnregisterCTryCatch(v8::internal::Isolate* isolate) {
1294    Simulator::current(isolate)->PopAddress();
1295  }
1296};
1297
1298}  // namespace internal
1299}  // namespace v8
1300
1301#endif  // !defined(USE_SIMULATOR)
1302#endif  // V8_S390_SIMULATOR_S390_H_
1303