1 /*
2  * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
3  * Copyright (c) 2016, 2017, SAP SE. All rights reserved.
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * This code is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License version 2 only, as
8  * published by the Free Software Foundation.
9  *
10  * This code is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13  * version 2 for more details (a copy is included in the LICENSE file that
14  * accompanied this code).
15  *
16  * You should have received a copy of the GNU General Public License version
17  * 2 along with this work; if not, write to the Free Software Foundation,
18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19  *
20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21  * or visit www.oracle.com if you need additional information or have any
22  * questions.
23  *
24  */
25 
26 #ifndef CPU_S390_VM_STUBROUTINES_ZARCH_64_64_HPP
27 #define CPU_S390_VM_STUBROUTINES_ZARCH_64_64_HPP
28 
29 // This file holds the platform specific parts of the StubRoutines
30 // definition. See stubRoutines.hpp for a description on how to extend it.
31 
returns_to_call_stub(address return_pc)32 static bool returns_to_call_stub(address return_pc) { return return_pc == _call_stub_return_address; }
33 
34 enum { // Platform dependent constants.
35   // TODO: May be able to shrink this a lot
36   code_size1 = 20000,      // Simply increase if too small (assembler will crash if too small).
37   code_size2 = 20000       // Simply increase if too small (assembler will crash if too small).
38 };
39 
40 // MethodHandles adapters
41 enum method_handles_platform_dependent_constants {
42   method_handles_adapters_code_size = 5000
43 };
44 
45 #define CRC32_COLUMN_SIZE 256
46 #define CRC32_BYFOUR
47 #ifdef CRC32_BYFOUR
48   #define CRC32_TABLES 8
49 #else
50   #define CRC32_TABLES 1
51 #endif
52 
53 // Comapct string intrinsics: Translate table for string inflate intrinsic. Used by trot instruction.
54 #define TROT_ALIGNMENT   8  // Required by instruction,
55                             // guaranteed by jlong table element type.
56 #define TROT_COLUMN_SIZE (256*sizeof(jchar)/sizeof(jlong))
57 
58 class zarch {
59  friend class StubGenerator;
60 
61  public:
62   enum { nof_instance_allocators = 10 };
63 
64   // allocator lock values
65   enum {
66     unlocked = 0,
67     locked   = 1
68   };
69 
70  private:
71   static int _atomic_memory_operation_lock;
72 
73   static address _partial_subtype_check;
74   static juint   _crc_table[CRC32_TABLES][CRC32_COLUMN_SIZE];
75   static juint   _crc32c_table[CRC32_TABLES][CRC32_COLUMN_SIZE];
76 
77   // Comapct string intrinsics: Translate table for string inflate intrinsic. Used by trot instruction.
78   static address _trot_table_addr;
79   static jlong   _trot_table[TROT_COLUMN_SIZE];
80 
81  public:
82   // Global lock for everyone who needs to use atomic_compare_and_exchange
83   // or atomic_increment -- should probably use more locks for more
84   // scalability -- for instance one for each eden space or group of.
85 
86   // Address of the lock for atomic_compare_and_exchange.
atomic_memory_operation_lock_addr()87   static int* atomic_memory_operation_lock_addr() { return &_atomic_memory_operation_lock; }
88 
89   // Accessor and mutator for _atomic_memory_operation_lock.
atomic_memory_operation_lock()90   static int atomic_memory_operation_lock() { return _atomic_memory_operation_lock; }
set_atomic_memory_operation_lock(int value)91   static void set_atomic_memory_operation_lock(int value) { _atomic_memory_operation_lock = value; }
92 
partial_subtype_check()93   static address partial_subtype_check()                  { return _partial_subtype_check; }
94 
95   static void generate_load_absolute_address(MacroAssembler* masm, Register table, address table_addr, uint64_t table_contents);
96   static void generate_load_crc_table_addr(MacroAssembler* masm, Register table);
97   static void generate_load_crc32c_table_addr(MacroAssembler* masm, Register table);
98 
99   // Comapct string intrinsics: Translate table for string inflate intrinsic. Used by trot instruction.
100   static void generate_load_trot_table_addr(MacroAssembler* masm, Register table);
101 };
102 
103 #endif // CPU_S390_VM_STUBROUTINES_ZARCH_64_64_HPP
104