Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: src/ic/x87/stub-cache-x87.cc

Issue 564683002: X87: Encapsulate megamorphic load/tail-call in hydrogen (Closed) Base URL: https://github.com/v8/v8.git@bleeding_edge
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ic/x87/ic-x87.cc ('k') | src/x87/lithium-codegen-x87.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_X87 7 #if V8_TARGET_ARCH_X87
8 8
9 #include "src/codegen.h" 9 #include "src/codegen.h"
10 #include "src/ic/stub-cache.h" 10 #include "src/ic/stub-cache.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 17
18 static void ProbeTable(Isolate* isolate, MacroAssembler* masm, 18 static void ProbeTable(Isolate* isolate, MacroAssembler* masm,
19 Code::Flags flags, StubCache::Table table, Register name, 19 Code::Flags flags, bool leave_frame,
20 Register receiver, 20 StubCache::Table table, Register name, Register receiver,
21 // Number of the cache entry pointer-size scaled. 21 // Number of the cache entry pointer-size scaled.
22 Register offset, Register extra) { 22 Register offset, Register extra) {
23 ExternalReference key_offset(isolate->stub_cache()->key_reference(table)); 23 ExternalReference key_offset(isolate->stub_cache()->key_reference(table));
24 ExternalReference value_offset(isolate->stub_cache()->value_reference(table)); 24 ExternalReference value_offset(isolate->stub_cache()->value_reference(table));
25 ExternalReference map_offset(isolate->stub_cache()->map_reference(table)); 25 ExternalReference map_offset(isolate->stub_cache()->map_reference(table));
26 26
27 Label miss; 27 Label miss;
28 28
29 // Multiply by 3 because there are 3 fields per entry (name, code, map). 29 // Multiply by 3 because there are 3 fields per entry (name, code, map).
30 __ lea(offset, Operand(offset, offset, times_2, 0)); 30 __ lea(offset, Operand(offset, offset, times_2, 0));
(...skipping 18 matching lines...) Expand all
49 __ j(not_equal, &miss); 49 __ j(not_equal, &miss);
50 50
51 #ifdef DEBUG 51 #ifdef DEBUG
52 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { 52 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) {
53 __ jmp(&miss); 53 __ jmp(&miss);
54 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { 54 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) {
55 __ jmp(&miss); 55 __ jmp(&miss);
56 } 56 }
57 #endif 57 #endif
58 58
59 if (leave_frame) __ leave();
60
59 // Jump to the first instruction in the code stub. 61 // Jump to the first instruction in the code stub.
60 __ add(extra, Immediate(Code::kHeaderSize - kHeapObjectTag)); 62 __ add(extra, Immediate(Code::kHeaderSize - kHeapObjectTag));
61 __ jmp(extra); 63 __ jmp(extra);
62 64
63 __ bind(&miss); 65 __ bind(&miss);
64 } else { 66 } else {
65 // Save the offset on the stack. 67 // Save the offset on the stack.
66 __ push(offset); 68 __ push(offset);
67 69
68 // Check that the key in the entry matches the name. 70 // Check that the key in the entry matches the name.
(...skipping 22 matching lines...) Expand all
91 __ jmp(&miss); 93 __ jmp(&miss);
92 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { 94 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) {
93 __ jmp(&miss); 95 __ jmp(&miss);
94 } 96 }
95 #endif 97 #endif
96 98
97 // Restore offset and re-load code entry from cache. 99 // Restore offset and re-load code entry from cache.
98 __ pop(offset); 100 __ pop(offset);
99 __ mov(offset, Operand::StaticArray(offset, times_1, value_offset)); 101 __ mov(offset, Operand::StaticArray(offset, times_1, value_offset));
100 102
103 if (leave_frame) __ leave();
104
101 // Jump to the first instruction in the code stub. 105 // Jump to the first instruction in the code stub.
102 __ add(offset, Immediate(Code::kHeaderSize - kHeapObjectTag)); 106 __ add(offset, Immediate(Code::kHeaderSize - kHeapObjectTag));
103 __ jmp(offset); 107 __ jmp(offset);
104 108
105 // Pop at miss. 109 // Pop at miss.
106 __ bind(&miss); 110 __ bind(&miss);
107 __ pop(offset); 111 __ pop(offset);
108 } 112 }
109 } 113 }
110 114
111 115
112 void StubCache::GenerateProbe(MacroAssembler* masm, Code::Flags flags, 116 void StubCache::GenerateProbe(MacroAssembler* masm, Code::Flags flags,
113 Register receiver, Register name, 117 bool leave_frame, Register receiver,
114 Register scratch, Register extra, Register extra2, 118 Register name, Register scratch, Register extra,
115 Register extra3) { 119 Register extra2, Register extra3) {
116 Label miss; 120 Label miss;
117 121
118 // Assert that code is valid. The multiplying code relies on the entry size 122 // Assert that code is valid. The multiplying code relies on the entry size
119 // being 12. 123 // being 12.
120 DCHECK(sizeof(Entry) == 12); 124 DCHECK(sizeof(Entry) == 12);
121 125
122 // Assert the flags do not name a specific type. 126 // Assert the flags do not name a specific type.
123 DCHECK(Code::ExtractTypeFromFlags(flags) == 0); 127 DCHECK(Code::ExtractTypeFromFlags(flags) == 0);
124 128
125 // Assert that there are no register conflicts. 129 // Assert that there are no register conflicts.
(...skipping 22 matching lines...) Expand all
148 __ add(offset, FieldOperand(receiver, HeapObject::kMapOffset)); 152 __ add(offset, FieldOperand(receiver, HeapObject::kMapOffset));
149 __ xor_(offset, flags); 153 __ xor_(offset, flags);
150 // We mask out the last two bits because they are not part of the hash and 154 // We mask out the last two bits because they are not part of the hash and
151 // they are always 01 for maps. Also in the two 'and' instructions below. 155 // they are always 01 for maps. Also in the two 'and' instructions below.
152 __ and_(offset, (kPrimaryTableSize - 1) << kCacheIndexShift); 156 __ and_(offset, (kPrimaryTableSize - 1) << kCacheIndexShift);
153 // ProbeTable expects the offset to be pointer scaled, which it is, because 157 // ProbeTable expects the offset to be pointer scaled, which it is, because
154 // the heap object tag size is 2 and the pointer size log 2 is also 2. 158 // the heap object tag size is 2 and the pointer size log 2 is also 2.
155 DCHECK(kCacheIndexShift == kPointerSizeLog2); 159 DCHECK(kCacheIndexShift == kPointerSizeLog2);
156 160
157 // Probe the primary table. 161 // Probe the primary table.
158 ProbeTable(isolate(), masm, flags, kPrimary, name, receiver, offset, extra); 162 ProbeTable(isolate(), masm, flags, leave_frame, kPrimary, name, receiver,
163 offset, extra);
159 164
160 // Primary miss: Compute hash for secondary probe. 165 // Primary miss: Compute hash for secondary probe.
161 __ mov(offset, FieldOperand(name, Name::kHashFieldOffset)); 166 __ mov(offset, FieldOperand(name, Name::kHashFieldOffset));
162 __ add(offset, FieldOperand(receiver, HeapObject::kMapOffset)); 167 __ add(offset, FieldOperand(receiver, HeapObject::kMapOffset));
163 __ xor_(offset, flags); 168 __ xor_(offset, flags);
164 __ and_(offset, (kPrimaryTableSize - 1) << kCacheIndexShift); 169 __ and_(offset, (kPrimaryTableSize - 1) << kCacheIndexShift);
165 __ sub(offset, name); 170 __ sub(offset, name);
166 __ add(offset, Immediate(flags)); 171 __ add(offset, Immediate(flags));
167 __ and_(offset, (kSecondaryTableSize - 1) << kCacheIndexShift); 172 __ and_(offset, (kSecondaryTableSize - 1) << kCacheIndexShift);
168 173
169 // Probe the secondary table. 174 // Probe the secondary table.
170 ProbeTable(isolate(), masm, flags, kSecondary, name, receiver, offset, extra); 175 ProbeTable(isolate(), masm, flags, leave_frame, kSecondary, name, receiver,
176 offset, extra);
171 177
172 // Cache miss: Fall-through and let caller handle the miss by 178 // Cache miss: Fall-through and let caller handle the miss by
173 // entering the runtime system. 179 // entering the runtime system.
174 __ bind(&miss); 180 __ bind(&miss);
175 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1); 181 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1);
176 } 182 }
177 183
178 184
179 #undef __ 185 #undef __
180 } 186 }
181 } // namespace v8::internal 187 } // namespace v8::internal
182 188
183 #endif // V8_TARGET_ARCH_X87 189 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « src/ic/x87/ic-x87.cc ('k') | src/x87/lithium-codegen-x87.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698