blob: 6e82c9afd0993905c69318d46f5977dd6a800804 [file] [log] [blame]
Ben Murdochda12d292016-06-02 14:46:10 +01001// 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/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(HashMap* 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(v8::internal::HashMap* 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
286 // Read and write memory.
287 inline uint8_t ReadBU(intptr_t addr);
288 inline int8_t ReadB(intptr_t addr);
289 inline void WriteB(intptr_t addr, uint8_t value);
290 inline void WriteB(intptr_t addr, int8_t value);
291
292 inline uint16_t ReadHU(intptr_t addr, Instruction* instr);
293 inline int16_t ReadH(intptr_t addr, Instruction* instr);
294 // Note: Overloaded on the sign of the value.
295 inline void WriteH(intptr_t addr, uint16_t value, Instruction* instr);
296 inline void WriteH(intptr_t addr, int16_t value, Instruction* instr);
297
298 inline uint32_t ReadWU(intptr_t addr, Instruction* instr);
299 inline int32_t ReadW(intptr_t addr, Instruction* instr);
300 inline void WriteW(intptr_t addr, uint32_t value, Instruction* instr);
301 inline void WriteW(intptr_t addr, int32_t value, Instruction* instr);
302
303 inline int64_t ReadDW(intptr_t addr);
304 inline double ReadDouble(intptr_t addr);
305 inline void WriteDW(intptr_t addr, int64_t value);
306
307 // S390
308 void Trace(Instruction* instr);
309 bool DecodeTwoByte(Instruction* instr);
310 bool DecodeFourByte(Instruction* instr);
311 bool DecodeFourByteArithmetic(Instruction* instr);
312 bool DecodeFourByteArithmetic64Bit(Instruction* instr);
313 bool DecodeFourByteFloatingPoint(Instruction* instr);
314 void DecodeFourByteFloatingPointIntConversion(Instruction* instr);
315 void DecodeFourByteFloatingPointRound(Instruction* instr);
316
317 bool DecodeSixByte(Instruction* instr);
318 bool DecodeSixByteArithmetic(Instruction* instr);
319 bool S390InstructionDecode(Instruction* instr);
320 void DecodeSixByteBitShift(Instruction* instr);
321
322 // Used by the CL**BR instructions.
323 template <typename T1, typename T2>
324 void SetS390RoundConditionCode(T1 r2_val, T2 max, T2 min) {
325 condition_reg_ = 0;
326 double r2_dval = static_cast<double>(r2_val);
327 double dbl_min = static_cast<double>(min);
328 double dbl_max = static_cast<double>(max);
329
330 if (r2_dval == 0.0)
331 condition_reg_ = 8;
332 else if (r2_dval < 0.0 && r2_dval >= dbl_min && std::isfinite(r2_dval))
333 condition_reg_ = 4;
334 else if (r2_dval > 0.0 && r2_dval <= dbl_max && std::isfinite(r2_dval))
335 condition_reg_ = 2;
336 else
337 condition_reg_ = 1;
338 }
339
340 template <typename T1>
341 void SetS390RoundConditionCode(T1 r2_val, int64_t max, int64_t min) {
342 condition_reg_ = 0;
343 double r2_dval = static_cast<double>(r2_val);
344 double dbl_min = static_cast<double>(min);
345 double dbl_max = static_cast<double>(max);
346
347 // Note that the IEEE 754 floating-point representations (both 32 and
348 // 64 bit) cannot exactly represent INT64_MAX. The closest it can get
349 // is INT64_max + 1. IEEE 754 FP can, though, represent INT64_MIN
350 // exactly.
351
352 // This is not an issue for INT32, as IEEE754 64-bit can represent
353 // INT32_MAX and INT32_MIN with exact precision.
354
355 if (r2_dval == 0.0)
356 condition_reg_ = 8;
357 else if (r2_dval < 0.0 && r2_dval >= dbl_min && std::isfinite(r2_dval))
358 condition_reg_ = 4;
359 else if (r2_dval > 0.0 && r2_dval < dbl_max && std::isfinite(r2_dval))
360 condition_reg_ = 2;
361 else
362 condition_reg_ = 1;
363 }
364
365 // Used by the CL**BR instructions.
366 template <typename T1, typename T2, typename T3>
367 void SetS390ConvertConditionCode(T1 src, T2 dst, T3 max) {
368 condition_reg_ = 0;
369 if (src == static_cast<T1>(0.0)) {
370 condition_reg_ |= 8;
371 } else if (src < static_cast<T1>(0.0) && static_cast<T2>(src) == 0 &&
372 std::isfinite(src)) {
373 condition_reg_ |= 4;
374 } else if (src > static_cast<T1>(0.0) && std::isfinite(src) &&
375 src < static_cast<T1>(max)) {
376 condition_reg_ |= 2;
377 } else {
378 condition_reg_ |= 1;
379 }
380 }
381
382 template <typename T>
383 void SetS390ConditionCode(T lhs, T rhs) {
384 condition_reg_ = 0;
385 if (lhs == rhs) {
386 condition_reg_ |= CC_EQ;
387 } else if (lhs < rhs) {
388 condition_reg_ |= CC_LT;
389 } else if (lhs > rhs) {
390 condition_reg_ |= CC_GT;
391 }
392
393 // We get down here only for floating point
394 // comparisons and the values are unordered
395 // i.e. NaN
396 if (condition_reg_ == 0) condition_reg_ = unordered;
397 }
398
399 // Used by arithmetic operations that use carry.
400 template <typename T>
401 void SetS390ConditionCodeCarry(T result, bool overflow) {
402 condition_reg_ = 0;
403 bool zero_result = (result == static_cast<T>(0));
404 if (zero_result && !overflow) {
405 condition_reg_ |= 8;
406 } else if (!zero_result && !overflow) {
407 condition_reg_ |= 4;
408 } else if (zero_result && overflow) {
409 condition_reg_ |= 2;
410 } else if (!zero_result && overflow) {
411 condition_reg_ |= 1;
412 }
413 if (condition_reg_ == 0) UNREACHABLE();
414 }
415
416 bool isNaN(double value) { return (value != value); }
417
418 // Set the condition code for bitwise operations
419 // CC0 is set if value == 0.
420 // CC1 is set if value != 0.
421 // CC2/CC3 are not set.
422 template <typename T>
423 void SetS390BitWiseConditionCode(T value) {
424 condition_reg_ = 0;
425
426 if (value == 0)
427 condition_reg_ |= CC_EQ;
428 else
429 condition_reg_ |= CC_LT;
430 }
431
432 void SetS390OverflowCode(bool isOF) {
433 if (isOF) condition_reg_ = CC_OF;
434 }
435
436 bool TestConditionCode(Condition mask) {
437 // Check for unconditional branch
438 if (mask == 0xf) return true;
439
440 return (condition_reg_ & mask) != 0;
441 }
442
443 // Executes one instruction.
444 void ExecuteInstruction(Instruction* instr, bool auto_incr_pc = true);
445
446 // ICache.
447 static void CheckICache(v8::internal::HashMap* i_cache, Instruction* instr);
448 static void FlushOnePage(v8::internal::HashMap* i_cache, intptr_t start,
449 int size);
450 static CachePage* GetCachePage(v8::internal::HashMap* i_cache, void* page);
451
452 // Runtime call support.
453 static void* RedirectExternalReference(
454 Isolate* isolate, void* external_function,
455 v8::internal::ExternalReference::Type type);
456
457 // Handle arguments and return value for runtime FP functions.
458 void GetFpArgs(double* x, double* y, intptr_t* z);
459 void SetFpResult(const double& result);
460 void TrashCallerSaveRegisters();
461
462 void CallInternal(byte* entry, int reg_arg_count = 3);
463
464 // Architecture state.
465 // On z9 and higher and supported Linux on z Systems platforms, all registers
466 // are 64-bit, even in 31-bit mode.
467 uint64_t registers_[kNumGPRs];
468 int64_t fp_registers_[kNumFPRs];
469
470 // Condition Code register. In S390, the last 4 bits are used.
471 int32_t condition_reg_;
472 // Special register to track PC.
473 intptr_t special_reg_pc_;
474
475 // Simulator support.
476 char* stack_;
477 static const size_t stack_protection_size_ = 256 * kPointerSize;
478 bool pc_modified_;
479 int64_t icount_;
480
481 // Debugger input.
482 char* last_debugger_input_;
483
484 // Icache simulation
485 v8::internal::HashMap* i_cache_;
486
487 // Registered breakpoints.
488 Instruction* break_pc_;
489 Instr break_instr_;
490
491 v8::internal::Isolate* isolate_;
492
493 // A stop is watched if its code is less than kNumOfWatchedStops.
494 // Only watched stops support enabling/disabling and the counter feature.
495 static const uint32_t kNumOfWatchedStops = 256;
496
497 // Breakpoint is disabled if bit 31 is set.
498 static const uint32_t kStopDisabledBit = 1 << 31;
499
500 // A stop is enabled, meaning the simulator will stop when meeting the
501 // instruction, if bit 31 of watched_stops_[code].count is unset.
502 // The value watched_stops_[code].count & ~(1 << 31) indicates how many times
503 // the breakpoint was hit or gone through.
504 struct StopCountAndDesc {
505 uint32_t count;
506 char* desc;
507 };
508 StopCountAndDesc watched_stops_[kNumOfWatchedStops];
509 void DebugStart();
Ben Murdochc5610432016-08-08 18:44:38 +0100510
511 int DecodeInstructionOriginal(Instruction* instr);
512 int DecodeInstruction(Instruction* instr);
513 int Evaluate_Unknown(Instruction* instr);
514#define MAX_NUM_OPCODES (1 << 16)
515 typedef int (Simulator::*EvaluateFuncType)(Instruction*);
516
517 static EvaluateFuncType EvalTable[MAX_NUM_OPCODES];
518 static void EvalTableInit();
519
520#define EVALUATE(name) int Evaluate_##name(Instruction* instr)
521 EVALUATE(BKPT);
522 EVALUATE(SPM);
523 EVALUATE(BALR);
524 EVALUATE(BCTR);
525 EVALUATE(BCR);
526 EVALUATE(SVC);
527 EVALUATE(BSM);
528 EVALUATE(BASSM);
529 EVALUATE(BASR);
530 EVALUATE(MVCL);
531 EVALUATE(CLCL);
532 EVALUATE(LPR);
533 EVALUATE(LNR);
534 EVALUATE(LTR);
535 EVALUATE(LCR);
536 EVALUATE(NR);
537 EVALUATE(CLR);
538 EVALUATE(OR);
539 EVALUATE(XR);
540 EVALUATE(LR);
541 EVALUATE(CR);
542 EVALUATE(AR);
543 EVALUATE(SR);
544 EVALUATE(MR);
545 EVALUATE(DR);
546 EVALUATE(ALR);
547 EVALUATE(SLR);
548 EVALUATE(LDR);
549 EVALUATE(CDR);
550 EVALUATE(LER);
551 EVALUATE(STH);
552 EVALUATE(LA);
553 EVALUATE(STC);
554 EVALUATE(IC_z);
555 EVALUATE(EX);
556 EVALUATE(BAL);
557 EVALUATE(BCT);
558 EVALUATE(BC);
559 EVALUATE(LH);
560 EVALUATE(CH);
561 EVALUATE(AH);
562 EVALUATE(SH);
563 EVALUATE(MH);
564 EVALUATE(BAS);
565 EVALUATE(CVD);
566 EVALUATE(CVB);
567 EVALUATE(ST);
568 EVALUATE(LAE);
569 EVALUATE(N);
570 EVALUATE(CL);
571 EVALUATE(O);
572 EVALUATE(X);
573 EVALUATE(L);
574 EVALUATE(C);
575 EVALUATE(A);
576 EVALUATE(S);
577 EVALUATE(M);
578 EVALUATE(D);
579 EVALUATE(AL);
580 EVALUATE(SL);
581 EVALUATE(STD);
582 EVALUATE(LD);
583 EVALUATE(CD);
584 EVALUATE(STE);
585 EVALUATE(MS);
586 EVALUATE(LE);
587 EVALUATE(BRXH);
588 EVALUATE(BRXLE);
589 EVALUATE(BXH);
590 EVALUATE(BXLE);
591 EVALUATE(SRL);
592 EVALUATE(SLL);
593 EVALUATE(SRA);
594 EVALUATE(SLA);
595 EVALUATE(SRDL);
596 EVALUATE(SLDL);
597 EVALUATE(SRDA);
598 EVALUATE(SLDA);
599 EVALUATE(STM);
600 EVALUATE(TM);
601 EVALUATE(MVI);
602 EVALUATE(TS);
603 EVALUATE(NI);
604 EVALUATE(CLI);
605 EVALUATE(OI);
606 EVALUATE(XI);
607 EVALUATE(LM);
608 EVALUATE(MVCLE);
609 EVALUATE(CLCLE);
610 EVALUATE(MC);
611 EVALUATE(CDS);
612 EVALUATE(STCM);
613 EVALUATE(ICM);
614 EVALUATE(BPRP);
615 EVALUATE(BPP);
616 EVALUATE(TRTR);
617 EVALUATE(MVN);
618 EVALUATE(MVC);
619 EVALUATE(MVZ);
620 EVALUATE(NC);
621 EVALUATE(CLC);
622 EVALUATE(OC);
623 EVALUATE(XC);
624 EVALUATE(MVCP);
625 EVALUATE(TR);
626 EVALUATE(TRT);
627 EVALUATE(ED);
628 EVALUATE(EDMK);
629 EVALUATE(PKU);
630 EVALUATE(UNPKU);
631 EVALUATE(MVCIN);
632 EVALUATE(PKA);
633 EVALUATE(UNPKA);
634 EVALUATE(PLO);
635 EVALUATE(LMD);
636 EVALUATE(SRP);
637 EVALUATE(MVO);
638 EVALUATE(PACK);
639 EVALUATE(UNPK);
640 EVALUATE(ZAP);
641 EVALUATE(AP);
642 EVALUATE(SP);
643 EVALUATE(MP);
644 EVALUATE(DP);
645 EVALUATE(UPT);
646 EVALUATE(PFPO);
647 EVALUATE(IIHH);
648 EVALUATE(IIHL);
649 EVALUATE(IILH);
650 EVALUATE(IILL);
651 EVALUATE(NIHH);
652 EVALUATE(NIHL);
653 EVALUATE(NILH);
654 EVALUATE(NILL);
655 EVALUATE(OIHH);
656 EVALUATE(OIHL);
657 EVALUATE(OILH);
658 EVALUATE(OILL);
659 EVALUATE(LLIHH);
660 EVALUATE(LLIHL);
661 EVALUATE(LLILH);
662 EVALUATE(LLILL);
663 EVALUATE(TMLH);
664 EVALUATE(TMLL);
665 EVALUATE(TMHH);
666 EVALUATE(TMHL);
667 EVALUATE(BRC);
668 EVALUATE(BRAS);
669 EVALUATE(BRCT);
670 EVALUATE(BRCTG);
671 EVALUATE(LHI);
672 EVALUATE(LGHI);
673 EVALUATE(AHI);
674 EVALUATE(AGHI);
675 EVALUATE(MHI);
676 EVALUATE(MGHI);
677 EVALUATE(CHI);
678 EVALUATE(CGHI);
679 EVALUATE(LARL);
680 EVALUATE(LGFI);
681 EVALUATE(BRCL);
682 EVALUATE(BRASL);
683 EVALUATE(XIHF);
684 EVALUATE(XILF);
685 EVALUATE(IIHF);
686 EVALUATE(IILF);
687 EVALUATE(NIHF);
688 EVALUATE(NILF);
689 EVALUATE(OIHF);
690 EVALUATE(OILF);
691 EVALUATE(LLIHF);
692 EVALUATE(LLILF);
693 EVALUATE(MSGFI);
694 EVALUATE(MSFI);
695 EVALUATE(SLGFI);
696 EVALUATE(SLFI);
697 EVALUATE(AGFI);
698 EVALUATE(AFI);
699 EVALUATE(ALGFI);
700 EVALUATE(ALFI);
701 EVALUATE(CGFI);
702 EVALUATE(CFI);
703 EVALUATE(CLGFI);
704 EVALUATE(CLFI);
705 EVALUATE(LLHRL);
706 EVALUATE(LGHRL);
707 EVALUATE(LHRL);
708 EVALUATE(LLGHRL);
709 EVALUATE(STHRL);
710 EVALUATE(LGRL);
711 EVALUATE(STGRL);
712 EVALUATE(LGFRL);
713 EVALUATE(LRL);
714 EVALUATE(LLGFRL);
715 EVALUATE(STRL);
716 EVALUATE(EXRL);
717 EVALUATE(PFDRL);
718 EVALUATE(CGHRL);
719 EVALUATE(CHRL);
720 EVALUATE(CGRL);
721 EVALUATE(CGFRL);
722 EVALUATE(ECTG);
723 EVALUATE(CSST);
724 EVALUATE(LPD);
725 EVALUATE(LPDG);
726 EVALUATE(BRCTH);
727 EVALUATE(AIH);
728 EVALUATE(ALSIH);
729 EVALUATE(ALSIHN);
730 EVALUATE(CIH);
731 EVALUATE(STCK);
732 EVALUATE(CFC);
733 EVALUATE(IPM);
734 EVALUATE(HSCH);
735 EVALUATE(MSCH);
736 EVALUATE(SSCH);
737 EVALUATE(STSCH);
738 EVALUATE(TSCH);
739 EVALUATE(TPI);
740 EVALUATE(SAL);
741 EVALUATE(RSCH);
742 EVALUATE(STCRW);
743 EVALUATE(STCPS);
744 EVALUATE(RCHP);
745 EVALUATE(SCHM);
746 EVALUATE(CKSM);
747 EVALUATE(SAR);
748 EVALUATE(EAR);
749 EVALUATE(MSR);
750 EVALUATE(MVST);
751 EVALUATE(CUSE);
752 EVALUATE(SRST);
753 EVALUATE(XSCH);
754 EVALUATE(STCKE);
755 EVALUATE(STCKF);
756 EVALUATE(SRNM);
757 EVALUATE(STFPC);
758 EVALUATE(LFPC);
759 EVALUATE(TRE);
760 EVALUATE(CUUTF);
761 EVALUATE(CUTFU);
762 EVALUATE(STFLE);
763 EVALUATE(SRNMB);
764 EVALUATE(SRNMT);
765 EVALUATE(LFAS);
766 EVALUATE(PPA);
767 EVALUATE(ETND);
768 EVALUATE(TEND);
769 EVALUATE(NIAI);
770 EVALUATE(TABORT);
771 EVALUATE(TRAP4);
772 EVALUATE(LPEBR);
773 EVALUATE(LNEBR);
774 EVALUATE(LTEBR);
775 EVALUATE(LCEBR);
776 EVALUATE(LDEBR);
777 EVALUATE(LXDBR);
778 EVALUATE(LXEBR);
779 EVALUATE(MXDBR);
780 EVALUATE(KEBR);
781 EVALUATE(CEBR);
782 EVALUATE(AEBR);
783 EVALUATE(SEBR);
784 EVALUATE(MDEBR);
785 EVALUATE(DEBR);
786 EVALUATE(MAEBR);
787 EVALUATE(MSEBR);
788 EVALUATE(LPDBR);
789 EVALUATE(LNDBR);
790 EVALUATE(LTDBR);
791 EVALUATE(LCDBR);
792 EVALUATE(SQEBR);
793 EVALUATE(SQDBR);
794 EVALUATE(SQXBR);
795 EVALUATE(MEEBR);
796 EVALUATE(KDBR);
797 EVALUATE(CDBR);
798 EVALUATE(ADBR);
799 EVALUATE(SDBR);
800 EVALUATE(MDBR);
801 EVALUATE(DDBR);
802 EVALUATE(MADBR);
803 EVALUATE(MSDBR);
804 EVALUATE(LPXBR);
805 EVALUATE(LNXBR);
806 EVALUATE(LTXBR);
807 EVALUATE(LCXBR);
808 EVALUATE(LEDBRA);
809 EVALUATE(LDXBRA);
810 EVALUATE(LEXBRA);
811 EVALUATE(FIXBRA);
812 EVALUATE(KXBR);
813 EVALUATE(CXBR);
814 EVALUATE(AXBR);
815 EVALUATE(SXBR);
816 EVALUATE(MXBR);
817 EVALUATE(DXBR);
818 EVALUATE(TBEDR);
819 EVALUATE(TBDR);
820 EVALUATE(DIEBR);
821 EVALUATE(FIEBRA);
822 EVALUATE(THDER);
823 EVALUATE(THDR);
824 EVALUATE(DIDBR);
825 EVALUATE(FIDBRA);
826 EVALUATE(LXR);
827 EVALUATE(LPDFR);
828 EVALUATE(LNDFR);
829 EVALUATE(LCDFR);
830 EVALUATE(LZER);
831 EVALUATE(LZDR);
832 EVALUATE(LZXR);
833 EVALUATE(SFPC);
834 EVALUATE(SFASR);
835 EVALUATE(EFPC);
836 EVALUATE(CELFBR);
837 EVALUATE(CDLFBR);
838 EVALUATE(CXLFBR);
839 EVALUATE(CEFBRA);
840 EVALUATE(CDFBRA);
841 EVALUATE(CXFBRA);
842 EVALUATE(CFEBRA);
843 EVALUATE(CFDBRA);
844 EVALUATE(CFXBRA);
845 EVALUATE(CLFEBR);
846 EVALUATE(CLFDBR);
847 EVALUATE(CLFXBR);
848 EVALUATE(CELGBR);
849 EVALUATE(CDLGBR);
850 EVALUATE(CXLGBR);
851 EVALUATE(CEGBRA);
852 EVALUATE(CDGBRA);
853 EVALUATE(CXGBRA);
854 EVALUATE(CGEBRA);
855 EVALUATE(CGDBRA);
856 EVALUATE(CGXBRA);
857 EVALUATE(CLGEBR);
858 EVALUATE(CLGDBR);
859 EVALUATE(CFER);
860 EVALUATE(CFDR);
861 EVALUATE(CFXR);
862 EVALUATE(LDGR);
863 EVALUATE(CGER);
864 EVALUATE(CGDR);
865 EVALUATE(CGXR);
866 EVALUATE(LGDR);
867 EVALUATE(MDTR);
868 EVALUATE(MDTRA);
869 EVALUATE(DDTRA);
870 EVALUATE(ADTRA);
871 EVALUATE(SDTRA);
872 EVALUATE(LDETR);
873 EVALUATE(LEDTR);
874 EVALUATE(LTDTR);
875 EVALUATE(FIDTR);
876 EVALUATE(MXTRA);
877 EVALUATE(DXTRA);
878 EVALUATE(AXTRA);
879 EVALUATE(SXTRA);
880 EVALUATE(LXDTR);
881 EVALUATE(LDXTR);
882 EVALUATE(LTXTR);
883 EVALUATE(FIXTR);
884 EVALUATE(KDTR);
885 EVALUATE(CGDTRA);
886 EVALUATE(CUDTR);
887 EVALUATE(CDTR);
888 EVALUATE(EEDTR);
889 EVALUATE(ESDTR);
890 EVALUATE(KXTR);
891 EVALUATE(CGXTRA);
892 EVALUATE(CUXTR);
893 EVALUATE(CSXTR);
894 EVALUATE(CXTR);
895 EVALUATE(EEXTR);
896 EVALUATE(ESXTR);
897 EVALUATE(CDGTRA);
898 EVALUATE(CDUTR);
899 EVALUATE(CDSTR);
900 EVALUATE(CEDTR);
901 EVALUATE(QADTR);
902 EVALUATE(IEDTR);
903 EVALUATE(RRDTR);
904 EVALUATE(CXGTRA);
905 EVALUATE(CXUTR);
906 EVALUATE(CXSTR);
907 EVALUATE(CEXTR);
908 EVALUATE(QAXTR);
909 EVALUATE(IEXTR);
910 EVALUATE(RRXTR);
911 EVALUATE(LPGR);
912 EVALUATE(LNGR);
913 EVALUATE(LTGR);
914 EVALUATE(LCGR);
915 EVALUATE(LGR);
916 EVALUATE(LGBR);
917 EVALUATE(LGHR);
918 EVALUATE(AGR);
919 EVALUATE(SGR);
920 EVALUATE(ALGR);
921 EVALUATE(SLGR);
922 EVALUATE(MSGR);
923 EVALUATE(DSGR);
924 EVALUATE(LRVGR);
925 EVALUATE(LPGFR);
926 EVALUATE(LNGFR);
927 EVALUATE(LTGFR);
928 EVALUATE(LCGFR);
929 EVALUATE(LGFR);
930 EVALUATE(LLGFR);
931 EVALUATE(LLGTR);
932 EVALUATE(AGFR);
933 EVALUATE(SGFR);
934 EVALUATE(ALGFR);
935 EVALUATE(SLGFR);
936 EVALUATE(MSGFR);
937 EVALUATE(DSGFR);
938 EVALUATE(KMAC);
939 EVALUATE(LRVR);
940 EVALUATE(CGR);
941 EVALUATE(CLGR);
942 EVALUATE(LBR);
943 EVALUATE(LHR);
944 EVALUATE(KMF);
945 EVALUATE(KMO);
946 EVALUATE(PCC);
947 EVALUATE(KMCTR);
948 EVALUATE(KM);
949 EVALUATE(KMC);
950 EVALUATE(CGFR);
951 EVALUATE(KIMD);
952 EVALUATE(KLMD);
953 EVALUATE(CFDTR);
954 EVALUATE(CLGDTR);
955 EVALUATE(CLFDTR);
956 EVALUATE(BCTGR);
957 EVALUATE(CFXTR);
958 EVALUATE(CLFXTR);
959 EVALUATE(CDFTR);
960 EVALUATE(CDLGTR);
961 EVALUATE(CDLFTR);
962 EVALUATE(CXFTR);
963 EVALUATE(CXLGTR);
964 EVALUATE(CXLFTR);
965 EVALUATE(CGRT);
966 EVALUATE(NGR);
967 EVALUATE(OGR);
968 EVALUATE(XGR);
969 EVALUATE(FLOGR);
970 EVALUATE(LLGCR);
971 EVALUATE(LLGHR);
972 EVALUATE(MLGR);
973 EVALUATE(DLGR);
974 EVALUATE(ALCGR);
975 EVALUATE(SLBGR);
976 EVALUATE(EPSW);
977 EVALUATE(TRTT);
978 EVALUATE(TRTO);
979 EVALUATE(TROT);
980 EVALUATE(TROO);
981 EVALUATE(LLCR);
982 EVALUATE(LLHR);
983 EVALUATE(MLR);
984 EVALUATE(DLR);
985 EVALUATE(ALCR);
986 EVALUATE(SLBR);
987 EVALUATE(CU14);
988 EVALUATE(CU24);
989 EVALUATE(CU41);
990 EVALUATE(CU42);
991 EVALUATE(TRTRE);
992 EVALUATE(SRSTU);
993 EVALUATE(TRTE);
994 EVALUATE(AHHHR);
995 EVALUATE(SHHHR);
996 EVALUATE(ALHHHR);
997 EVALUATE(SLHHHR);
998 EVALUATE(CHHR);
999 EVALUATE(AHHLR);
1000 EVALUATE(SHHLR);
1001 EVALUATE(ALHHLR);
1002 EVALUATE(SLHHLR);
1003 EVALUATE(CHLR);
1004 EVALUATE(POPCNT_Z);
1005 EVALUATE(LOCGR);
1006 EVALUATE(NGRK);
1007 EVALUATE(OGRK);
1008 EVALUATE(XGRK);
1009 EVALUATE(AGRK);
1010 EVALUATE(SGRK);
1011 EVALUATE(ALGRK);
1012 EVALUATE(SLGRK);
1013 EVALUATE(LOCR);
1014 EVALUATE(NRK);
1015 EVALUATE(ORK);
1016 EVALUATE(XRK);
1017 EVALUATE(ARK);
1018 EVALUATE(SRK);
1019 EVALUATE(ALRK);
1020 EVALUATE(SLRK);
1021 EVALUATE(LTG);
1022 EVALUATE(LG);
1023 EVALUATE(CVBY);
1024 EVALUATE(AG);
1025 EVALUATE(SG);
1026 EVALUATE(ALG);
1027 EVALUATE(SLG);
1028 EVALUATE(MSG);
1029 EVALUATE(DSG);
1030 EVALUATE(CVBG);
1031 EVALUATE(LRVG);
1032 EVALUATE(LT);
1033 EVALUATE(LGF);
1034 EVALUATE(LGH);
1035 EVALUATE(LLGF);
1036 EVALUATE(LLGT);
1037 EVALUATE(AGF);
1038 EVALUATE(SGF);
1039 EVALUATE(ALGF);
1040 EVALUATE(SLGF);
1041 EVALUATE(MSGF);
1042 EVALUATE(DSGF);
1043 EVALUATE(LRV);
1044 EVALUATE(LRVH);
1045 EVALUATE(CG);
1046 EVALUATE(CLG);
1047 EVALUATE(STG);
1048 EVALUATE(NTSTG);
1049 EVALUATE(CVDY);
1050 EVALUATE(CVDG);
1051 EVALUATE(STRVG);
1052 EVALUATE(CGF);
1053 EVALUATE(CLGF);
1054 EVALUATE(LTGF);
1055 EVALUATE(CGH);
1056 EVALUATE(PFD);
1057 EVALUATE(STRV);
1058 EVALUATE(STRVH);
1059 EVALUATE(BCTG);
1060 EVALUATE(STY);
1061 EVALUATE(MSY);
1062 EVALUATE(NY);
1063 EVALUATE(CLY);
1064 EVALUATE(OY);
1065 EVALUATE(XY);
1066 EVALUATE(LY);
1067 EVALUATE(CY);
1068 EVALUATE(AY);
1069 EVALUATE(SY);
1070 EVALUATE(MFY);
1071 EVALUATE(ALY);
1072 EVALUATE(SLY);
1073 EVALUATE(STHY);
1074 EVALUATE(LAY);
1075 EVALUATE(STCY);
1076 EVALUATE(ICY);
1077 EVALUATE(LAEY);
1078 EVALUATE(LB);
1079 EVALUATE(LGB);
1080 EVALUATE(LHY);
1081 EVALUATE(CHY);
1082 EVALUATE(AHY);
1083 EVALUATE(SHY);
1084 EVALUATE(MHY);
1085 EVALUATE(NG);
1086 EVALUATE(OG);
1087 EVALUATE(XG);
1088 EVALUATE(LGAT);
1089 EVALUATE(MLG);
1090 EVALUATE(DLG);
1091 EVALUATE(ALCG);
1092 EVALUATE(SLBG);
1093 EVALUATE(STPQ);
1094 EVALUATE(LPQ);
1095 EVALUATE(LLGC);
1096 EVALUATE(LLGH);
1097 EVALUATE(LLC);
1098 EVALUATE(LLH);
1099 EVALUATE(ML);
1100 EVALUATE(DL);
1101 EVALUATE(ALC);
1102 EVALUATE(SLB);
1103 EVALUATE(LLGTAT);
1104 EVALUATE(LLGFAT);
1105 EVALUATE(LAT);
1106 EVALUATE(LBH);
1107 EVALUATE(LLCH);
1108 EVALUATE(STCH);
1109 EVALUATE(LHH);
1110 EVALUATE(LLHH);
1111 EVALUATE(STHH);
1112 EVALUATE(LFHAT);
1113 EVALUATE(LFH);
1114 EVALUATE(STFH);
1115 EVALUATE(CHF);
1116 EVALUATE(MVCDK);
1117 EVALUATE(MVHHI);
1118 EVALUATE(MVGHI);
1119 EVALUATE(MVHI);
1120 EVALUATE(CHHSI);
1121 EVALUATE(CGHSI);
1122 EVALUATE(CHSI);
1123 EVALUATE(CLFHSI);
1124 EVALUATE(TBEGIN);
1125 EVALUATE(TBEGINC);
1126 EVALUATE(LMG);
1127 EVALUATE(SRAG);
1128 EVALUATE(SLAG);
1129 EVALUATE(SRLG);
1130 EVALUATE(SLLG);
1131 EVALUATE(CSY);
1132 EVALUATE(RLLG);
1133 EVALUATE(RLL);
1134 EVALUATE(STMG);
1135 EVALUATE(STMH);
1136 EVALUATE(STCMH);
1137 EVALUATE(STCMY);
1138 EVALUATE(CDSY);
1139 EVALUATE(CDSG);
1140 EVALUATE(BXHG);
1141 EVALUATE(BXLEG);
1142 EVALUATE(ECAG);
1143 EVALUATE(TMY);
1144 EVALUATE(MVIY);
1145 EVALUATE(NIY);
1146 EVALUATE(CLIY);
1147 EVALUATE(OIY);
1148 EVALUATE(XIY);
1149 EVALUATE(ASI);
1150 EVALUATE(ALSI);
1151 EVALUATE(AGSI);
1152 EVALUATE(ALGSI);
1153 EVALUATE(ICMH);
1154 EVALUATE(ICMY);
1155 EVALUATE(MVCLU);
1156 EVALUATE(CLCLU);
1157 EVALUATE(STMY);
1158 EVALUATE(LMH);
1159 EVALUATE(LMY);
1160 EVALUATE(TP);
1161 EVALUATE(SRAK);
1162 EVALUATE(SLAK);
1163 EVALUATE(SRLK);
1164 EVALUATE(SLLK);
1165 EVALUATE(LOCG);
1166 EVALUATE(STOCG);
1167 EVALUATE(LANG);
1168 EVALUATE(LAOG);
1169 EVALUATE(LAXG);
1170 EVALUATE(LAAG);
1171 EVALUATE(LAALG);
1172 EVALUATE(LOC);
1173 EVALUATE(STOC);
1174 EVALUATE(LAN);
1175 EVALUATE(LAO);
1176 EVALUATE(LAX);
1177 EVALUATE(LAA);
1178 EVALUATE(LAAL);
1179 EVALUATE(BRXHG);
1180 EVALUATE(BRXLG);
1181 EVALUATE(RISBLG);
1182 EVALUATE(RNSBG);
1183 EVALUATE(RISBG);
1184 EVALUATE(ROSBG);
1185 EVALUATE(RXSBG);
1186 EVALUATE(RISBGN);
1187 EVALUATE(RISBHG);
1188 EVALUATE(CGRJ);
1189 EVALUATE(CGIT);
1190 EVALUATE(CIT);
1191 EVALUATE(CLFIT);
1192 EVALUATE(CGIJ);
1193 EVALUATE(CIJ);
1194 EVALUATE(AHIK);
1195 EVALUATE(AGHIK);
1196 EVALUATE(ALHSIK);
1197 EVALUATE(ALGHSIK);
1198 EVALUATE(CGRB);
1199 EVALUATE(CGIB);
1200 EVALUATE(CIB);
1201 EVALUATE(LDEB);
1202 EVALUATE(LXDB);
1203 EVALUATE(LXEB);
1204 EVALUATE(MXDB);
1205 EVALUATE(KEB);
1206 EVALUATE(CEB);
1207 EVALUATE(AEB);
1208 EVALUATE(SEB);
1209 EVALUATE(MDEB);
1210 EVALUATE(DEB);
1211 EVALUATE(MAEB);
1212 EVALUATE(MSEB);
1213 EVALUATE(TCEB);
1214 EVALUATE(TCDB);
1215 EVALUATE(TCXB);
1216 EVALUATE(SQEB);
1217 EVALUATE(SQDB);
1218 EVALUATE(MEEB);
1219 EVALUATE(KDB);
1220 EVALUATE(CDB);
1221 EVALUATE(ADB);
1222 EVALUATE(SDB);
1223 EVALUATE(MDB);
1224 EVALUATE(DDB);
1225 EVALUATE(MADB);
1226 EVALUATE(MSDB);
1227 EVALUATE(SLDT);
1228 EVALUATE(SRDT);
1229 EVALUATE(SLXT);
1230 EVALUATE(SRXT);
1231 EVALUATE(TDCET);
1232 EVALUATE(TDGET);
1233 EVALUATE(TDCDT);
1234 EVALUATE(TDGDT);
1235 EVALUATE(TDCXT);
1236 EVALUATE(TDGXT);
1237 EVALUATE(LEY);
1238 EVALUATE(LDY);
1239 EVALUATE(STEY);
1240 EVALUATE(STDY);
1241 EVALUATE(CZDT);
1242 EVALUATE(CZXT);
1243 EVALUATE(CDZT);
1244 EVALUATE(CXZT);
1245#undef EVALUATE
Ben Murdochda12d292016-06-02 14:46:10 +01001246};
1247
1248// When running with the simulator transition into simulated execution at this
1249// point.
1250#define CALL_GENERATED_CODE(isolate, entry, p0, p1, p2, p3, p4) \
1251 reinterpret_cast<Object*>(Simulator::current(isolate)->Call( \
1252 FUNCTION_ADDR(entry), 5, (intptr_t)p0, (intptr_t)p1, (intptr_t)p2, \
1253 (intptr_t)p3, (intptr_t)p4))
1254
1255#define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \
1256 p7, p8) \
1257 Simulator::current(isolate)->Call(entry, 10, (intptr_t)p0, (intptr_t)p1, \
1258 (intptr_t)p2, (intptr_t)p3, (intptr_t)p4, \
1259 (intptr_t)p5, (intptr_t)p6, (intptr_t)p7, \
1260 (intptr_t)NULL, (intptr_t)p8)
1261
1262// The simulator has its own stack. Thus it has a different stack limit from
1263// the C-based native code. The JS-based limit normally points near the end of
1264// the simulator stack. When the C-based limit is exhausted we reflect that by
1265// lowering the JS-based limit as well, to make stack checks trigger.
1266class SimulatorStack : public v8::internal::AllStatic {
1267 public:
1268 static inline uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate,
1269 uintptr_t c_limit) {
1270 return Simulator::current(isolate)->StackLimit(c_limit);
1271 }
1272
1273 static inline uintptr_t RegisterCTryCatch(v8::internal::Isolate* isolate,
1274 uintptr_t try_catch_address) {
1275 Simulator* sim = Simulator::current(isolate);
1276 return sim->PushAddress(try_catch_address);
1277 }
1278
1279 static inline void UnregisterCTryCatch(v8::internal::Isolate* isolate) {
1280 Simulator::current(isolate)->PopAddress();
1281 }
1282};
1283
1284} // namespace internal
1285} // namespace v8
1286
1287#endif // !defined(USE_SIMULATOR)
1288#endif // V8_S390_SIMULATOR_S390_H_