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

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

Issue 483683005: Move IC code into a subdir and move ic-compilation related code from stub-cache into ic-compiler (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix BUILD.gn Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « src/ic/arm64/ic-compiler-arm64.cc ('k') | src/ic/ia32/ic-compiler-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 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 #include "src/v8.h"
6
7 #if V8_TARGET_ARCH_ARM64
8
9 #include "src/codegen.h"
10 #include "src/ic/stub-cache.h"
11
12 namespace v8 {
13 namespace internal {
14
15
16 #define __ ACCESS_MASM(masm)
17
18
19 // Probe primary or secondary table.
20 // If the entry is found in the cache, the generated code jump to the first
21 // instruction of the stub in the cache.
22 // If there is a miss the code fall trough.
23 //
24 // 'receiver', 'name' and 'offset' registers are preserved on miss.
25 static void ProbeTable(Isolate* isolate, MacroAssembler* masm,
26 Code::Flags flags, StubCache::Table table,
27 Register receiver, Register name, Register offset,
28 Register scratch, Register scratch2, Register scratch3) {
29 // Some code below relies on the fact that the Entry struct contains
30 // 3 pointers (name, code, map).
31 STATIC_ASSERT(sizeof(StubCache::Entry) == (3 * kPointerSize));
32
33 ExternalReference key_offset(isolate->stub_cache()->key_reference(table));
34 ExternalReference value_offset(isolate->stub_cache()->value_reference(table));
35 ExternalReference map_offset(isolate->stub_cache()->map_reference(table));
36
37 uintptr_t key_off_addr = reinterpret_cast<uintptr_t>(key_offset.address());
38 uintptr_t value_off_addr =
39 reinterpret_cast<uintptr_t>(value_offset.address());
40 uintptr_t map_off_addr = reinterpret_cast<uintptr_t>(map_offset.address());
41
42 Label miss;
43
44 DCHECK(!AreAliased(name, offset, scratch, scratch2, scratch3));
45
46 // Multiply by 3 because there are 3 fields per entry.
47 __ Add(scratch3, offset, Operand(offset, LSL, 1));
48
49 // Calculate the base address of the entry.
50 __ Mov(scratch, key_offset);
51 __ Add(scratch, scratch, Operand(scratch3, LSL, kPointerSizeLog2));
52
53 // Check that the key in the entry matches the name.
54 __ Ldr(scratch2, MemOperand(scratch));
55 __ Cmp(name, scratch2);
56 __ B(ne, &miss);
57
58 // Check the map matches.
59 __ Ldr(scratch2, MemOperand(scratch, map_off_addr - key_off_addr));
60 __ Ldr(scratch3, FieldMemOperand(receiver, HeapObject::kMapOffset));
61 __ Cmp(scratch2, scratch3);
62 __ B(ne, &miss);
63
64 // Get the code entry from the cache.
65 __ Ldr(scratch, MemOperand(scratch, value_off_addr - key_off_addr));
66
67 // Check that the flags match what we're looking for.
68 __ Ldr(scratch2.W(), FieldMemOperand(scratch, Code::kFlagsOffset));
69 __ Bic(scratch2.W(), scratch2.W(), Code::kFlagsNotUsedInLookup);
70 __ Cmp(scratch2.W(), flags);
71 __ B(ne, &miss);
72
73 #ifdef DEBUG
74 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) {
75 __ B(&miss);
76 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) {
77 __ B(&miss);
78 }
79 #endif
80
81 // Jump to the first instruction in the code stub.
82 __ Add(scratch, scratch, Code::kHeaderSize - kHeapObjectTag);
83 __ Br(scratch);
84
85 // Miss: fall through.
86 __ Bind(&miss);
87 }
88
89
90 void StubCache::GenerateProbe(MacroAssembler* masm, Code::Flags flags,
91 Register receiver, Register name,
92 Register scratch, Register extra, Register extra2,
93 Register extra3) {
94 Isolate* isolate = masm->isolate();
95 Label miss;
96
97 // Make sure the flags does not name a specific type.
98 DCHECK(Code::ExtractTypeFromFlags(flags) == 0);
99
100 // Make sure that there are no register conflicts.
101 DCHECK(!AreAliased(receiver, name, scratch, extra, extra2, extra3));
102
103 // Make sure extra and extra2 registers are valid.
104 DCHECK(!extra.is(no_reg));
105 DCHECK(!extra2.is(no_reg));
106 DCHECK(!extra3.is(no_reg));
107
108 Counters* counters = masm->isolate()->counters();
109 __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1, extra2,
110 extra3);
111
112 // Check that the receiver isn't a smi.
113 __ JumpIfSmi(receiver, &miss);
114
115 // Compute the hash for primary table.
116 __ Ldr(scratch, FieldMemOperand(name, Name::kHashFieldOffset));
117 __ Ldr(extra, FieldMemOperand(receiver, HeapObject::kMapOffset));
118 __ Add(scratch, scratch, extra);
119 __ Eor(scratch, scratch, flags);
120 // We shift out the last two bits because they are not part of the hash.
121 __ Ubfx(scratch, scratch, kCacheIndexShift,
122 CountTrailingZeros(kPrimaryTableSize, 64));
123
124 // Probe the primary table.
125 ProbeTable(isolate, masm, flags, kPrimary, receiver, name, scratch, extra,
126 extra2, extra3);
127
128 // Primary miss: Compute hash for secondary table.
129 __ Sub(scratch, scratch, Operand(name, LSR, kCacheIndexShift));
130 __ Add(scratch, scratch, flags >> kCacheIndexShift);
131 __ And(scratch, scratch, kSecondaryTableSize - 1);
132
133 // Probe the secondary table.
134 ProbeTable(isolate, masm, flags, kSecondary, receiver, name, scratch, extra,
135 extra2, extra3);
136
137 // Cache miss: Fall-through and let caller handle the miss by
138 // entering the runtime system.
139 __ Bind(&miss);
140 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2,
141 extra3);
142 }
143 }
144 } // namespace v8::internal
145
146 #endif // V8_TARGET_ARCH_ARM64
OLDNEW
« no previous file with comments | « src/ic/arm64/ic-compiler-arm64.cc ('k') | src/ic/ia32/ic-compiler-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698