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