OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if V8_TARGET_ARCH_PPC | 5 #if V8_TARGET_ARCH_S390 |
6 | 6 |
| 7 #include "src/ic/stub-cache.h" |
7 #include "src/codegen.h" | 8 #include "src/codegen.h" |
8 #include "src/ic/ic.h" | 9 #include "src/ic/ic.h" |
9 #include "src/ic/stub-cache.h" | |
10 #include "src/interface-descriptors.h" | 10 #include "src/interface-descriptors.h" |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 | 14 |
15 #define __ ACCESS_MASM(masm) | 15 #define __ ACCESS_MASM(masm) |
16 | 16 |
17 | |
18 static void ProbeTable(Isolate* isolate, MacroAssembler* masm, | 17 static void ProbeTable(Isolate* isolate, MacroAssembler* masm, |
19 Code::Kind ic_kind, Code::Flags flags, | 18 Code::Kind ic_kind, Code::Flags flags, |
20 StubCache::Table table, Register receiver, Register name, | 19 StubCache::Table table, Register receiver, Register name, |
21 // Number of the cache entry, not scaled. | 20 // Number of the cache entry, not scaled. |
22 Register offset, Register scratch, Register scratch2, | 21 Register offset, Register scratch, Register scratch2, |
23 Register offset_scratch) { | 22 Register offset_scratch) { |
24 ExternalReference key_offset(isolate->stub_cache()->key_reference(table)); | 23 ExternalReference key_offset(isolate->stub_cache()->key_reference(table)); |
25 ExternalReference value_offset(isolate->stub_cache()->value_reference(table)); | 24 ExternalReference value_offset(isolate->stub_cache()->value_reference(table)); |
26 ExternalReference map_offset(isolate->stub_cache()->map_reference(table)); | 25 ExternalReference map_offset(isolate->stub_cache()->map_reference(table)); |
27 | 26 |
28 uintptr_t key_off_addr = reinterpret_cast<uintptr_t>(key_offset.address()); | 27 uintptr_t key_off_addr = reinterpret_cast<uintptr_t>(key_offset.address()); |
29 uintptr_t value_off_addr = | 28 uintptr_t value_off_addr = |
30 reinterpret_cast<uintptr_t>(value_offset.address()); | 29 reinterpret_cast<uintptr_t>(value_offset.address()); |
31 uintptr_t map_off_addr = reinterpret_cast<uintptr_t>(map_offset.address()); | 30 uintptr_t map_off_addr = reinterpret_cast<uintptr_t>(map_offset.address()); |
32 | 31 |
33 // Check the relative positions of the address fields. | 32 // Check the relative positions of the address fields. |
34 DCHECK(value_off_addr > key_off_addr); | 33 DCHECK(value_off_addr > key_off_addr); |
35 DCHECK((value_off_addr - key_off_addr) % 4 == 0); | 34 DCHECK((value_off_addr - key_off_addr) % 4 == 0); |
36 DCHECK((value_off_addr - key_off_addr) < (256 * 4)); | 35 DCHECK((value_off_addr - key_off_addr) < (256 * 4)); |
37 DCHECK(map_off_addr > key_off_addr); | 36 DCHECK(map_off_addr > key_off_addr); |
38 DCHECK((map_off_addr - key_off_addr) % 4 == 0); | 37 DCHECK((map_off_addr - key_off_addr) % 4 == 0); |
39 DCHECK((map_off_addr - key_off_addr) < (256 * 4)); | 38 DCHECK((map_off_addr - key_off_addr) < (256 * 4)); |
40 | 39 |
41 Label miss; | 40 Label miss; |
42 Register base_addr = scratch; | 41 Register base_addr = scratch; |
43 scratch = no_reg; | 42 scratch = no_reg; |
44 | 43 |
45 // Multiply by 3 because there are 3 fields per entry (name, code, map). | 44 // Multiply by 3 because there are 3 fields per entry (name, code, map). |
46 __ ShiftLeftImm(offset_scratch, offset, Operand(1)); | 45 __ ShiftLeftP(offset_scratch, offset, Operand(1)); |
47 __ add(offset_scratch, offset, offset_scratch); | 46 __ AddP(offset_scratch, offset, offset_scratch); |
48 | 47 |
49 // Calculate the base address of the entry. | 48 // Calculate the base address of the entry. |
50 __ mov(base_addr, Operand(key_offset)); | 49 __ mov(base_addr, Operand(key_offset)); |
51 #if V8_TARGET_ARCH_PPC64 | 50 #if V8_TARGET_ARCH_S390X |
52 DCHECK(kPointerSizeLog2 > StubCache::kCacheIndexShift); | 51 DCHECK(kPointerSizeLog2 > StubCache::kCacheIndexShift); |
53 __ ShiftLeftImm(offset_scratch, offset_scratch, | 52 __ ShiftLeftP(offset_scratch, offset_scratch, |
54 Operand(kPointerSizeLog2 - StubCache::kCacheIndexShift)); | 53 Operand(kPointerSizeLog2 - StubCache::kCacheIndexShift)); |
55 #else | 54 #else |
56 DCHECK(kPointerSizeLog2 == StubCache::kCacheIndexShift); | 55 DCHECK(kPointerSizeLog2 == StubCache::kCacheIndexShift); |
57 #endif | 56 #endif |
58 __ add(base_addr, base_addr, offset_scratch); | 57 __ AddP(base_addr, base_addr, offset_scratch); |
59 | 58 |
60 // Check that the key in the entry matches the name. | 59 // Check that the key in the entry matches the name. |
61 __ LoadP(ip, MemOperand(base_addr, 0)); | 60 __ CmpP(name, MemOperand(base_addr, 0)); |
62 __ cmp(name, ip); | 61 __ bne(&miss, Label::kNear); |
63 __ bne(&miss); | |
64 | 62 |
65 // Check the map matches. | 63 // Check the map matches. |
66 __ LoadP(ip, MemOperand(base_addr, map_off_addr - key_off_addr)); | 64 __ LoadP(ip, MemOperand(base_addr, map_off_addr - key_off_addr)); |
67 __ LoadP(scratch2, FieldMemOperand(receiver, HeapObject::kMapOffset)); | 65 __ CmpP(ip, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
68 __ cmp(ip, scratch2); | 66 __ bne(&miss, Label::kNear); |
69 __ bne(&miss); | |
70 | 67 |
71 // Get the code entry from the cache. | 68 // Get the code entry from the cache. |
72 Register code = scratch2; | 69 Register code = scratch2; |
73 scratch2 = no_reg; | 70 scratch2 = no_reg; |
74 __ LoadP(code, MemOperand(base_addr, value_off_addr - key_off_addr)); | 71 __ LoadP(code, MemOperand(base_addr, value_off_addr - key_off_addr)); |
75 | 72 |
76 // Check that the flags match what we're looking for. | 73 // Check that the flags match what we're looking for. |
77 Register flags_reg = base_addr; | 74 Register flags_reg = base_addr; |
78 base_addr = no_reg; | 75 base_addr = no_reg; |
79 __ lwz(flags_reg, FieldMemOperand(code, Code::kFlagsOffset)); | 76 __ LoadlW(flags_reg, FieldMemOperand(code, Code::kFlagsOffset)); |
80 | 77 |
81 DCHECK(!r0.is(flags_reg)); | 78 DCHECK(!r0.is(flags_reg)); |
82 __ li(r0, Operand(Code::kFlagsNotUsedInLookup)); | 79 __ AndP(flags_reg, flags_reg, Operand(~Code::kFlagsNotUsedInLookup)); |
83 __ andc(flags_reg, flags_reg, r0); | 80 __ CmpLogicalP(flags_reg, Operand(flags)); |
84 __ mov(r0, Operand(flags)); | 81 __ bne(&miss, Label::kNear); |
85 __ cmpl(flags_reg, r0); | |
86 __ bne(&miss); | |
87 | 82 |
88 #ifdef DEBUG | 83 #ifdef DEBUG |
89 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { | 84 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { |
90 __ b(&miss); | 85 __ b(&miss, Label::kNear); |
91 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { | 86 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { |
92 __ b(&miss); | 87 __ b(&miss, Label::kNear); |
93 } | 88 } |
94 #endif | 89 #endif |
95 | 90 |
96 // Jump to the first instruction in the code stub. | 91 // Jump to the first instruction in the code stub. |
97 __ addi(r0, code, Operand(Code::kHeaderSize - kHeapObjectTag)); | 92 // TODO(joransiu): Combine into indirect branch |
98 __ mtctr(r0); | 93 __ la(code, MemOperand(code, Code::kHeaderSize - kHeapObjectTag)); |
99 __ bctr(); | 94 __ b(code); |
100 | 95 |
101 // Miss: fall through. | 96 // Miss: fall through. |
102 __ bind(&miss); | 97 __ bind(&miss); |
103 } | 98 } |
104 | 99 |
105 | |
106 void StubCache::GenerateProbe(MacroAssembler* masm, Code::Kind ic_kind, | 100 void StubCache::GenerateProbe(MacroAssembler* masm, Code::Kind ic_kind, |
107 Code::Flags flags, Register receiver, | 101 Code::Flags flags, Register receiver, |
108 Register name, Register scratch, Register extra, | 102 Register name, Register scratch, Register extra, |
109 Register extra2, Register extra3) { | 103 Register extra2, Register extra3) { |
110 Isolate* isolate = masm->isolate(); | 104 Isolate* isolate = masm->isolate(); |
111 Label miss; | 105 Label miss; |
112 | 106 |
113 #if V8_TARGET_ARCH_PPC64 | 107 #if V8_TARGET_ARCH_S390X |
114 // Make sure that code is valid. The multiplying code relies on the | 108 // Make sure that code is valid. The multiplying code relies on the |
115 // entry size being 24. | 109 // entry size being 24. |
116 DCHECK(sizeof(Entry) == 24); | 110 DCHECK(sizeof(Entry) == 24); |
117 #else | 111 #else |
118 // Make sure that code is valid. The multiplying code relies on the | 112 // Make sure that code is valid. The multiplying code relies on the |
119 // entry size being 12. | 113 // entry size being 12. |
120 DCHECK(sizeof(Entry) == 12); | 114 DCHECK(sizeof(Entry) == 12); |
121 #endif | 115 #endif |
122 | 116 |
123 // Make sure the flags does not name a specific type. | 117 // Make sure the flags does not name a specific type. |
(...skipping 26 matching lines...) Expand all Loading... |
150 #endif | 144 #endif |
151 | 145 |
152 Counters* counters = masm->isolate()->counters(); | 146 Counters* counters = masm->isolate()->counters(); |
153 __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1, extra2, | 147 __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1, extra2, |
154 extra3); | 148 extra3); |
155 | 149 |
156 // Check that the receiver isn't a smi. | 150 // Check that the receiver isn't a smi. |
157 __ JumpIfSmi(receiver, &miss); | 151 __ JumpIfSmi(receiver, &miss); |
158 | 152 |
159 // Get the map of the receiver and compute the hash. | 153 // Get the map of the receiver and compute the hash. |
160 __ lwz(scratch, FieldMemOperand(name, Name::kHashFieldOffset)); | 154 __ LoadlW(scratch, FieldMemOperand(name, Name::kHashFieldOffset)); |
161 __ LoadP(ip, FieldMemOperand(receiver, HeapObject::kMapOffset)); | 155 __ LoadP(ip, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
162 __ add(scratch, scratch, ip); | 156 __ AddP(scratch, scratch, ip); |
163 __ xori(scratch, scratch, Operand(flags)); | 157 __ XorP(scratch, scratch, Operand(flags)); |
164 // The mask omits the last two bits because they are not part of the hash. | 158 // The mask omits the last two bits because they are not part of the hash. |
165 __ andi(scratch, scratch, | 159 __ AndP(scratch, scratch, |
166 Operand((kPrimaryTableSize - 1) << kCacheIndexShift)); | 160 Operand((kPrimaryTableSize - 1) << kCacheIndexShift)); |
167 | 161 |
168 // Probe the primary table. | 162 // Probe the primary table. |
169 ProbeTable(isolate, masm, ic_kind, flags, kPrimary, receiver, name, scratch, | 163 ProbeTable(isolate, masm, ic_kind, flags, kPrimary, receiver, name, scratch, |
170 extra, extra2, extra3); | 164 extra, extra2, extra3); |
171 | 165 |
172 // Primary miss: Compute hash for secondary probe. | 166 // Primary miss: Compute hash for secondary probe. |
173 __ sub(scratch, scratch, name); | 167 __ SubP(scratch, scratch, name); |
174 __ addi(scratch, scratch, Operand(flags)); | 168 __ AddP(scratch, scratch, Operand(flags)); |
175 __ andi(scratch, scratch, | 169 __ AndP(scratch, scratch, |
176 Operand((kSecondaryTableSize - 1) << kCacheIndexShift)); | 170 Operand((kSecondaryTableSize - 1) << kCacheIndexShift)); |
177 | 171 |
178 // Probe the secondary table. | 172 // Probe the secondary table. |
179 ProbeTable(isolate, masm, ic_kind, flags, kSecondary, receiver, name, scratch, | 173 ProbeTable(isolate, masm, ic_kind, flags, kSecondary, receiver, name, scratch, |
180 extra, extra2, extra3); | 174 extra, extra2, extra3); |
181 | 175 |
182 // Cache miss: Fall-through and let caller handle the miss by | 176 // Cache miss: Fall-through and let caller handle the miss by |
183 // entering the runtime system. | 177 // entering the runtime system. |
184 __ bind(&miss); | 178 __ bind(&miss); |
185 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, | 179 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, |
186 extra3); | 180 extra3); |
187 } | 181 } |
188 | 182 |
189 | |
190 #undef __ | 183 #undef __ |
191 } // namespace internal | 184 } // namespace internal |
192 } // namespace v8 | 185 } // namespace v8 |
193 | 186 |
194 #endif // V8_TARGET_ARCH_PPC | 187 #endif // V8_TARGET_ARCH_S390 |
OLD | NEW |