OLD | NEW |
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 #if V8_TARGET_ARCH_MIPS64 | 5 #if V8_TARGET_ARCH_MIPS64 |
6 | 6 |
7 #include "src/codegen.h" | 7 #include "src/codegen.h" |
8 #include "src/ic/ic.h" | 8 #include "src/ic/ic.h" |
9 #include "src/ic/ic-compiler.h" | 9 #include "src/ic/ic-compiler.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 | 15 |
16 // ---------------------------------------------------------------------------- | 16 // ---------------------------------------------------------------------------- |
17 // Static IC stub generators. | 17 // Static IC stub generators. |
18 // | 18 // |
19 | 19 |
20 #define __ ACCESS_MASM(masm) | 20 #define __ ACCESS_MASM(masm) |
21 | 21 |
22 // Helper function used from LoadIC GenerateNormal. | |
23 // | |
24 // elements: Property dictionary. It is not clobbered if a jump to the miss | |
25 // label is done. | |
26 // name: Property name. It is not clobbered if a jump to the miss label is | |
27 // done | |
28 // result: Register for the result. It is only updated if a jump to the miss | |
29 // label is not done. Can be the same as elements or name clobbering | |
30 // one of these in the case of not jumping to the miss label. | |
31 // The two scratch registers need to be different from elements, name and | |
32 // result. | |
33 // The generated code assumes that the receiver has slow properties, | |
34 // is not a global object and does not have interceptors. | |
35 // The address returned from GenerateStringDictionaryProbes() in scratch2 | |
36 // is used. | |
37 static void GenerateDictionaryLoad(MacroAssembler* masm, Label* miss, | |
38 Register elements, Register name, | |
39 Register result, Register scratch1, | |
40 Register scratch2) { | |
41 // Main use of the scratch registers. | |
42 // scratch1: Used as temporary and to hold the capacity of the property | |
43 // dictionary. | |
44 // scratch2: Used as temporary. | |
45 Label done; | |
46 | |
47 // Probe the dictionary. | |
48 NameDictionaryLookupStub::GeneratePositiveLookup(masm, miss, &done, elements, | |
49 name, scratch1, scratch2); | |
50 | |
51 // If probing finds an entry check that the value is a normal | |
52 // property. | |
53 __ bind(&done); // scratch2 == elements + 4 * index. | |
54 const int kElementsStartOffset = | |
55 NameDictionary::kHeaderSize + | |
56 NameDictionary::kElementsStartIndex * kPointerSize; | |
57 const int kDetailsOffset = kElementsStartOffset + 2 * kPointerSize; | |
58 __ ld(scratch1, FieldMemOperand(scratch2, kDetailsOffset)); | |
59 __ And(at, scratch1, | |
60 Operand(Smi::FromInt(PropertyDetails::TypeField::kMask))); | |
61 __ Branch(miss, ne, at, Operand(zero_reg)); | |
62 | |
63 // Get the value at the masked, scaled index and return. | |
64 __ ld(result, | |
65 FieldMemOperand(scratch2, kElementsStartOffset + 1 * kPointerSize)); | |
66 } | |
67 | |
68 | |
69 // Helper function used from StoreIC::GenerateNormal. | |
70 // | |
71 // elements: Property dictionary. It is not clobbered if a jump to the miss | |
72 // label is done. | |
73 // name: Property name. It is not clobbered if a jump to the miss label is | |
74 // done | |
75 // value: The value to store. | |
76 // The two scratch registers need to be different from elements, name and | |
77 // result. | |
78 // The generated code assumes that the receiver has slow properties, | |
79 // is not a global object and does not have interceptors. | |
80 // The address returned from GenerateStringDictionaryProbes() in scratch2 | |
81 // is used. | |
82 static void GenerateDictionaryStore(MacroAssembler* masm, Label* miss, | |
83 Register elements, Register name, | |
84 Register value, Register scratch1, | |
85 Register scratch2) { | |
86 // Main use of the scratch registers. | |
87 // scratch1: Used as temporary and to hold the capacity of the property | |
88 // dictionary. | |
89 // scratch2: Used as temporary. | |
90 Label done; | |
91 | |
92 // Probe the dictionary. | |
93 NameDictionaryLookupStub::GeneratePositiveLookup(masm, miss, &done, elements, | |
94 name, scratch1, scratch2); | |
95 | |
96 // If probing finds an entry in the dictionary check that the value | |
97 // is a normal property that is not read only. | |
98 __ bind(&done); // scratch2 == elements + 4 * index. | |
99 const int kElementsStartOffset = | |
100 NameDictionary::kHeaderSize + | |
101 NameDictionary::kElementsStartIndex * kPointerSize; | |
102 const int kDetailsOffset = kElementsStartOffset + 2 * kPointerSize; | |
103 const int kTypeAndReadOnlyMask = | |
104 (PropertyDetails::TypeField::kMask | | |
105 PropertyDetails::AttributesField::encode(READ_ONLY)); | |
106 __ ld(scratch1, FieldMemOperand(scratch2, kDetailsOffset)); | |
107 __ And(at, scratch1, Operand(Smi::FromInt(kTypeAndReadOnlyMask))); | |
108 __ Branch(miss, ne, at, Operand(zero_reg)); | |
109 | |
110 // Store the value at the masked, scaled index and return. | |
111 const int kValueOffset = kElementsStartOffset + kPointerSize; | |
112 __ Daddu(scratch2, scratch2, Operand(kValueOffset - kHeapObjectTag)); | |
113 __ sd(value, MemOperand(scratch2)); | |
114 | |
115 // Update the write barrier. Make sure not to clobber the value. | |
116 __ mov(scratch1, value); | |
117 __ RecordWrite(elements, scratch2, scratch1, kRAHasNotBeenSaved, | |
118 kDontSaveFPRegs); | |
119 } | |
120 | |
121 void LoadIC::GenerateNormal(MacroAssembler* masm) { | |
122 Register dictionary = a0; | |
123 DCHECK(!dictionary.is(LoadDescriptor::ReceiverRegister())); | |
124 DCHECK(!dictionary.is(LoadDescriptor::NameRegister())); | |
125 Label slow; | |
126 | |
127 __ ld(dictionary, FieldMemOperand(LoadDescriptor::ReceiverRegister(), | |
128 JSObject::kPropertiesOffset)); | |
129 GenerateDictionaryLoad(masm, &slow, dictionary, | |
130 LoadDescriptor::NameRegister(), v0, a3, a4); | |
131 __ Ret(); | |
132 | |
133 // Dictionary load failed, go slow (but don't miss). | |
134 __ bind(&slow); | |
135 GenerateRuntimeGetProperty(masm); | |
136 } | |
137 | |
138 | |
139 // A register that isn't one of the parameters to the load ic. | |
140 static const Register LoadIC_TempRegister() { return a3; } | |
141 | |
142 void LoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) { | |
143 // The return address is in ra. | |
144 | |
145 __ mov(LoadIC_TempRegister(), LoadDescriptor::ReceiverRegister()); | |
146 __ Push(LoadIC_TempRegister(), LoadDescriptor::NameRegister()); | |
147 | |
148 // Do tail-call to runtime routine. | |
149 __ TailCallRuntime(Runtime::kGetProperty); | |
150 } | |
151 | |
152 static void StoreIC_PushArgs(MacroAssembler* masm) { | 22 static void StoreIC_PushArgs(MacroAssembler* masm) { |
153 __ Push(StoreWithVectorDescriptor::ValueRegister(), | 23 __ Push(StoreWithVectorDescriptor::ValueRegister(), |
154 StoreWithVectorDescriptor::SlotRegister(), | 24 StoreWithVectorDescriptor::SlotRegister(), |
155 StoreWithVectorDescriptor::VectorRegister(), | 25 StoreWithVectorDescriptor::VectorRegister(), |
156 StoreWithVectorDescriptor::ReceiverRegister(), | 26 StoreWithVectorDescriptor::ReceiverRegister(), |
157 StoreWithVectorDescriptor::NameRegister()); | 27 StoreWithVectorDescriptor::NameRegister()); |
158 } | 28 } |
159 | 29 |
160 | 30 |
161 void KeyedStoreIC::GenerateMiss(MacroAssembler* masm) { | 31 void KeyedStoreIC::GenerateMiss(MacroAssembler* masm) { |
162 StoreIC_PushArgs(masm); | 32 StoreIC_PushArgs(masm); |
163 | 33 |
164 __ TailCallRuntime(Runtime::kKeyedStoreIC_Miss); | 34 __ TailCallRuntime(Runtime::kKeyedStoreIC_Miss); |
165 } | 35 } |
166 | 36 |
167 void KeyedStoreIC::GenerateSlow(MacroAssembler* masm) { | 37 void KeyedStoreIC::GenerateSlow(MacroAssembler* masm) { |
168 StoreIC_PushArgs(masm); | 38 StoreIC_PushArgs(masm); |
169 | 39 |
170 // The slow case calls into the runtime to complete the store without causing | 40 // The slow case calls into the runtime to complete the store without causing |
171 // an IC miss that would otherwise cause a transition to the generic stub. | 41 // an IC miss that would otherwise cause a transition to the generic stub. |
172 __ TailCallRuntime(Runtime::kKeyedStoreIC_Slow); | 42 __ TailCallRuntime(Runtime::kKeyedStoreIC_Slow); |
173 } | 43 } |
174 | 44 |
175 void StoreIC::GenerateMiss(MacroAssembler* masm) { | |
176 StoreIC_PushArgs(masm); | |
177 | |
178 // Perform tail call to the entry. | |
179 __ TailCallRuntime(Runtime::kStoreIC_Miss); | |
180 } | |
181 | |
182 | |
183 void StoreIC::GenerateNormal(MacroAssembler* masm) { | |
184 Label miss; | |
185 Register receiver = StoreDescriptor::ReceiverRegister(); | |
186 Register name = StoreDescriptor::NameRegister(); | |
187 Register value = StoreDescriptor::ValueRegister(); | |
188 Register dictionary = a5; | |
189 DCHECK(!AreAliased( | |
190 value, receiver, name, StoreWithVectorDescriptor::VectorRegister(), | |
191 StoreWithVectorDescriptor::SlotRegister(), dictionary, a6, a7)); | |
192 | |
193 __ ld(dictionary, FieldMemOperand(receiver, JSObject::kPropertiesOffset)); | |
194 | |
195 GenerateDictionaryStore(masm, &miss, dictionary, name, value, a6, a7); | |
196 Counters* counters = masm->isolate()->counters(); | |
197 __ IncrementCounter(counters->ic_store_normal_hit(), 1, a6, a7); | |
198 __ Ret(USE_DELAY_SLOT); | |
199 __ Move(v0, value); // Ensure the stub returns correct value. | |
200 | |
201 __ bind(&miss); | |
202 __ IncrementCounter(counters->ic_store_normal_miss(), 1, a6, a7); | |
203 GenerateMiss(masm); | |
204 } | |
205 | |
206 | |
207 #undef __ | 45 #undef __ |
208 | 46 |
209 | 47 |
210 Condition CompareIC::ComputeCondition(Token::Value op) { | 48 Condition CompareIC::ComputeCondition(Token::Value op) { |
211 switch (op) { | 49 switch (op) { |
212 case Token::EQ_STRICT: | 50 case Token::EQ_STRICT: |
213 case Token::EQ: | 51 case Token::EQ: |
214 return eq; | 52 return eq; |
215 case Token::LT: | 53 case Token::LT: |
216 return lt; | 54 return lt; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 break; | 165 break; |
328 default: | 166 default: |
329 UNIMPLEMENTED(); | 167 UNIMPLEMENTED(); |
330 } | 168 } |
331 patcher.ChangeBranchCondition(branch_instr, opcode); | 169 patcher.ChangeBranchCondition(branch_instr, opcode); |
332 } | 170 } |
333 } // namespace internal | 171 } // namespace internal |
334 } // namespace v8 | 172 } // namespace v8 |
335 | 173 |
336 #endif // V8_TARGET_ARCH_MIPS64 | 174 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |