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" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 DCHECK(JS_OBJECT_TYPE > JS_VALUE_TYPE); | 151 DCHECK(JS_OBJECT_TYPE > JS_VALUE_TYPE); |
152 __ lbu(scratch, FieldMemOperand(map, Map::kInstanceTypeOffset)); | 152 __ lbu(scratch, FieldMemOperand(map, Map::kInstanceTypeOffset)); |
153 __ Branch(slow, lt, scratch, Operand(JS_OBJECT_TYPE)); | 153 __ Branch(slow, lt, scratch, Operand(JS_OBJECT_TYPE)); |
154 } | 154 } |
155 | 155 |
156 | 156 |
157 // Loads an indexed element from a fast case array. | 157 // Loads an indexed element from a fast case array. |
158 static void GenerateFastArrayLoad(MacroAssembler* masm, Register receiver, | 158 static void GenerateFastArrayLoad(MacroAssembler* masm, Register receiver, |
159 Register key, Register elements, | 159 Register key, Register elements, |
160 Register scratch1, Register scratch2, | 160 Register scratch1, Register scratch2, |
161 Register result, Label* slow, | 161 Register result, Label* slow) { |
162 LanguageMode language_mode) { | |
163 // Register use: | 162 // Register use: |
164 // | 163 // |
165 // receiver - holds the receiver on entry. | 164 // receiver - holds the receiver on entry. |
166 // Unchanged unless 'result' is the same register. | 165 // Unchanged unless 'result' is the same register. |
167 // | 166 // |
168 // key - holds the smi key on entry. | 167 // key - holds the smi key on entry. |
169 // Unchanged unless 'result' is the same register. | 168 // Unchanged unless 'result' is the same register. |
170 // | 169 // |
171 // result - holds the result on exit if the load succeeded. | 170 // result - holds the result on exit if the load succeeded. |
172 // Allowed to be the the same as 'receiver' or 'key'. | 171 // Allowed to be the the same as 'receiver' or 'key'. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 __ Branch(slow, lo, scratch1, Operand(JS_OBJECT_TYPE)); | 207 __ Branch(slow, lo, scratch1, Operand(JS_OBJECT_TYPE)); |
209 __ lbu(scratch1, FieldMemOperand(scratch2, Map::kBitFieldOffset)); | 208 __ lbu(scratch1, FieldMemOperand(scratch2, Map::kBitFieldOffset)); |
210 __ And(at, scratch1, Operand((1 << Map::kIsAccessCheckNeeded) | | 209 __ And(at, scratch1, Operand((1 << Map::kIsAccessCheckNeeded) | |
211 (1 << Map::kHasIndexedInterceptor))); | 210 (1 << Map::kHasIndexedInterceptor))); |
212 __ Branch(slow, ne, at, Operand(zero_reg)); | 211 __ Branch(slow, ne, at, Operand(zero_reg)); |
213 __ LoadRoot(at, Heap::kEmptyFixedArrayRootIndex); | 212 __ LoadRoot(at, Heap::kEmptyFixedArrayRootIndex); |
214 __ Branch(slow, ne, elements, Operand(at)); | 213 __ Branch(slow, ne, elements, Operand(at)); |
215 __ Branch(&check_next_prototype); | 214 __ Branch(&check_next_prototype); |
216 | 215 |
217 __ bind(&absent); | 216 __ bind(&absent); |
218 if (is_strong(language_mode)) { | 217 __ LoadRoot(result, Heap::kUndefinedValueRootIndex); |
219 __ Branch(slow); | 218 __ Branch(&done); |
220 } else { | |
221 __ LoadRoot(result, Heap::kUndefinedValueRootIndex); | |
222 __ Branch(&done); | |
223 } | |
224 | 219 |
225 __ bind(&in_bounds); | 220 __ bind(&in_bounds); |
226 // Fast case: Do the load. | 221 // Fast case: Do the load. |
227 __ Daddu(scratch1, elements, | 222 __ Daddu(scratch1, elements, |
228 Operand(FixedArray::kHeaderSize - kHeapObjectTag)); | 223 Operand(FixedArray::kHeaderSize - kHeapObjectTag)); |
229 // The key is a smi. | 224 // The key is a smi. |
230 STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize < kPointerSizeLog2); | 225 STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize < kPointerSizeLog2); |
231 __ SmiScale(at, key, kPointerSizeLog2); | 226 __ SmiScale(at, key, kPointerSizeLog2); |
232 __ daddu(at, at, scratch1); | 227 __ daddu(at, at, scratch1); |
233 __ ld(scratch2, MemOperand(at)); | 228 __ ld(scratch2, MemOperand(at)); |
(...skipping 28 matching lines...) Expand all Loading... |
262 // bit test is enough. | 257 // bit test is enough. |
263 // map: key map | 258 // map: key map |
264 __ lbu(hash, FieldMemOperand(map, Map::kInstanceTypeOffset)); | 259 __ lbu(hash, FieldMemOperand(map, Map::kInstanceTypeOffset)); |
265 STATIC_ASSERT(kInternalizedTag == 0); | 260 STATIC_ASSERT(kInternalizedTag == 0); |
266 __ And(at, hash, Operand(kIsNotInternalizedMask)); | 261 __ And(at, hash, Operand(kIsNotInternalizedMask)); |
267 __ Branch(not_unique, ne, at, Operand(zero_reg)); | 262 __ Branch(not_unique, ne, at, Operand(zero_reg)); |
268 | 263 |
269 __ bind(&unique); | 264 __ bind(&unique); |
270 } | 265 } |
271 | 266 |
272 | 267 void LoadIC::GenerateNormal(MacroAssembler* masm) { |
273 void LoadIC::GenerateNormal(MacroAssembler* masm, LanguageMode language_mode) { | |
274 Register dictionary = a0; | 268 Register dictionary = a0; |
275 DCHECK(!dictionary.is(LoadDescriptor::ReceiverRegister())); | 269 DCHECK(!dictionary.is(LoadDescriptor::ReceiverRegister())); |
276 DCHECK(!dictionary.is(LoadDescriptor::NameRegister())); | 270 DCHECK(!dictionary.is(LoadDescriptor::NameRegister())); |
277 Label slow; | 271 Label slow; |
278 | 272 |
279 __ ld(dictionary, FieldMemOperand(LoadDescriptor::ReceiverRegister(), | 273 __ ld(dictionary, FieldMemOperand(LoadDescriptor::ReceiverRegister(), |
280 JSObject::kPropertiesOffset)); | 274 JSObject::kPropertiesOffset)); |
281 GenerateDictionaryLoad(masm, &slow, dictionary, | 275 GenerateDictionaryLoad(masm, &slow, dictionary, |
282 LoadDescriptor::NameRegister(), v0, a3, a4); | 276 LoadDescriptor::NameRegister(), v0, a3, a4); |
283 __ Ret(); | 277 __ Ret(); |
284 | 278 |
285 // Dictionary load failed, go slow (but don't miss). | 279 // Dictionary load failed, go slow (but don't miss). |
286 __ bind(&slow); | 280 __ bind(&slow); |
287 GenerateRuntimeGetProperty(masm, language_mode); | 281 GenerateRuntimeGetProperty(masm); |
288 } | 282 } |
289 | 283 |
290 | 284 |
291 // A register that isn't one of the parameters to the load ic. | 285 // A register that isn't one of the parameters to the load ic. |
292 static const Register LoadIC_TempRegister() { return a3; } | 286 static const Register LoadIC_TempRegister() { return a3; } |
293 | 287 |
294 | 288 |
295 static void LoadIC_PushArgs(MacroAssembler* masm) { | 289 static void LoadIC_PushArgs(MacroAssembler* masm) { |
296 Register receiver = LoadDescriptor::ReceiverRegister(); | 290 Register receiver = LoadDescriptor::ReceiverRegister(); |
297 Register name = LoadDescriptor::NameRegister(); | 291 Register name = LoadDescriptor::NameRegister(); |
(...skipping 11 matching lines...) Expand all Loading... |
309 DCHECK(!AreAliased(a4, a5, LoadWithVectorDescriptor::SlotRegister(), | 303 DCHECK(!AreAliased(a4, a5, LoadWithVectorDescriptor::SlotRegister(), |
310 LoadWithVectorDescriptor::VectorRegister())); | 304 LoadWithVectorDescriptor::VectorRegister())); |
311 __ IncrementCounter(isolate->counters()->ic_load_miss(), 1, a4, a5); | 305 __ IncrementCounter(isolate->counters()->ic_load_miss(), 1, a4, a5); |
312 | 306 |
313 LoadIC_PushArgs(masm); | 307 LoadIC_PushArgs(masm); |
314 | 308 |
315 // Perform tail call to the entry. | 309 // Perform tail call to the entry. |
316 __ TailCallRuntime(Runtime::kLoadIC_Miss); | 310 __ TailCallRuntime(Runtime::kLoadIC_Miss); |
317 } | 311 } |
318 | 312 |
319 | 313 void LoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) { |
320 void LoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm, | |
321 LanguageMode language_mode) { | |
322 // The return address is in ra. | 314 // The return address is in ra. |
323 | 315 |
324 __ mov(LoadIC_TempRegister(), LoadDescriptor::ReceiverRegister()); | 316 __ mov(LoadIC_TempRegister(), LoadDescriptor::ReceiverRegister()); |
325 __ Push(LoadIC_TempRegister(), LoadDescriptor::NameRegister()); | 317 __ Push(LoadIC_TempRegister(), LoadDescriptor::NameRegister()); |
326 | 318 |
327 // Do tail-call to runtime routine. | 319 // Do tail-call to runtime routine. |
328 __ TailCallRuntime(is_strong(language_mode) ? Runtime::kGetPropertyStrong | 320 __ TailCallRuntime(Runtime::kGetProperty); |
329 : Runtime::kGetProperty); | |
330 } | 321 } |
331 | 322 |
332 | 323 |
333 void KeyedLoadIC::GenerateMiss(MacroAssembler* masm) { | 324 void KeyedLoadIC::GenerateMiss(MacroAssembler* masm) { |
334 // The return address is in ra. | 325 // The return address is in ra. |
335 Isolate* isolate = masm->isolate(); | 326 Isolate* isolate = masm->isolate(); |
336 | 327 |
337 DCHECK(!AreAliased(a4, a5, LoadWithVectorDescriptor::SlotRegister(), | 328 DCHECK(!AreAliased(a4, a5, LoadWithVectorDescriptor::SlotRegister(), |
338 LoadWithVectorDescriptor::VectorRegister())); | 329 LoadWithVectorDescriptor::VectorRegister())); |
339 __ IncrementCounter(isolate->counters()->ic_keyed_load_miss(), 1, a4, a5); | 330 __ IncrementCounter(isolate->counters()->ic_keyed_load_miss(), 1, a4, a5); |
340 | 331 |
341 LoadIC_PushArgs(masm); | 332 LoadIC_PushArgs(masm); |
342 | 333 |
343 // Perform tail call to the entry. | 334 // Perform tail call to the entry. |
344 __ TailCallRuntime(Runtime::kKeyedLoadIC_Miss); | 335 __ TailCallRuntime(Runtime::kKeyedLoadIC_Miss); |
345 } | 336 } |
346 | 337 |
347 | 338 void KeyedLoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) { |
348 void KeyedLoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm, | |
349 LanguageMode language_mode) { | |
350 // The return address is in ra. | 339 // The return address is in ra. |
351 | 340 |
352 __ Push(LoadDescriptor::ReceiverRegister(), LoadDescriptor::NameRegister()); | 341 __ Push(LoadDescriptor::ReceiverRegister(), LoadDescriptor::NameRegister()); |
353 | 342 |
354 // Do tail-call to runtime routine. | 343 // Do tail-call to runtime routine. |
355 __ TailCallRuntime(is_strong(language_mode) ? Runtime::kKeyedGetPropertyStrong | 344 __ TailCallRuntime(Runtime::kKeyedGetProperty); |
356 : Runtime::kKeyedGetProperty); | |
357 } | 345 } |
358 | 346 |
359 | 347 void KeyedLoadIC::GenerateMegamorphic(MacroAssembler* masm) { |
360 void KeyedLoadIC::GenerateMegamorphic(MacroAssembler* masm, | |
361 LanguageMode language_mode) { | |
362 // The return address is in ra. | 348 // The return address is in ra. |
363 Label slow, check_name, index_smi, index_name, property_array_property; | 349 Label slow, check_name, index_smi, index_name, property_array_property; |
364 Label probe_dictionary, check_number_dictionary; | 350 Label probe_dictionary, check_number_dictionary; |
365 | 351 |
366 Register key = LoadDescriptor::NameRegister(); | 352 Register key = LoadDescriptor::NameRegister(); |
367 Register receiver = LoadDescriptor::ReceiverRegister(); | 353 Register receiver = LoadDescriptor::ReceiverRegister(); |
368 DCHECK(key.is(a2)); | 354 DCHECK(key.is(a2)); |
369 DCHECK(receiver.is(a1)); | 355 DCHECK(receiver.is(a1)); |
370 | 356 |
371 Isolate* isolate = masm->isolate(); | 357 Isolate* isolate = masm->isolate(); |
372 | 358 |
373 // Check that the key is a smi. | 359 // Check that the key is a smi. |
374 __ JumpIfNotSmi(key, &check_name); | 360 __ JumpIfNotSmi(key, &check_name); |
375 __ bind(&index_smi); | 361 __ bind(&index_smi); |
376 // Now the key is known to be a smi. This place is also jumped to from below | 362 // Now the key is known to be a smi. This place is also jumped to from below |
377 // where a numeric string is converted to a smi. | 363 // where a numeric string is converted to a smi. |
378 | 364 |
379 GenerateKeyedLoadReceiverCheck(masm, receiver, a0, a3, | 365 GenerateKeyedLoadReceiverCheck(masm, receiver, a0, a3, |
380 Map::kHasIndexedInterceptor, &slow); | 366 Map::kHasIndexedInterceptor, &slow); |
381 | 367 |
382 // Check the receiver's map to see if it has fast elements. | 368 // Check the receiver's map to see if it has fast elements. |
383 __ CheckFastElements(a0, a3, &check_number_dictionary); | 369 __ CheckFastElements(a0, a3, &check_number_dictionary); |
384 | 370 |
385 GenerateFastArrayLoad(masm, receiver, key, a0, a3, a4, v0, &slow, | 371 GenerateFastArrayLoad(masm, receiver, key, a0, a3, a4, v0, &slow); |
386 language_mode); | |
387 __ IncrementCounter(isolate->counters()->ic_keyed_load_generic_smi(), 1, a4, | 372 __ IncrementCounter(isolate->counters()->ic_keyed_load_generic_smi(), 1, a4, |
388 a3); | 373 a3); |
389 __ Ret(); | 374 __ Ret(); |
390 | 375 |
391 __ bind(&check_number_dictionary); | 376 __ bind(&check_number_dictionary); |
392 __ ld(a4, FieldMemOperand(receiver, JSObject::kElementsOffset)); | 377 __ ld(a4, FieldMemOperand(receiver, JSObject::kElementsOffset)); |
393 __ ld(a3, FieldMemOperand(a4, JSObject::kMapOffset)); | 378 __ ld(a3, FieldMemOperand(a4, JSObject::kMapOffset)); |
394 | 379 |
395 // Check whether the elements is a number dictionary. | 380 // Check whether the elements is a number dictionary. |
396 // a3: elements map | 381 // a3: elements map |
397 // a4: elements | 382 // a4: elements |
398 __ LoadRoot(at, Heap::kHashTableMapRootIndex); | 383 __ LoadRoot(at, Heap::kHashTableMapRootIndex); |
399 __ Branch(&slow, ne, a3, Operand(at)); | 384 __ Branch(&slow, ne, a3, Operand(at)); |
400 __ dsra32(a0, key, 0); | 385 __ dsra32(a0, key, 0); |
401 __ LoadFromNumberDictionary(&slow, a4, key, v0, a0, a3, a5); | 386 __ LoadFromNumberDictionary(&slow, a4, key, v0, a0, a3, a5); |
402 __ Ret(); | 387 __ Ret(); |
403 | 388 |
404 // Slow case, key and receiver still in a2 and a1. | 389 // Slow case, key and receiver still in a2 and a1. |
405 __ bind(&slow); | 390 __ bind(&slow); |
406 __ IncrementCounter(isolate->counters()->ic_keyed_load_generic_slow(), 1, a4, | 391 __ IncrementCounter(isolate->counters()->ic_keyed_load_generic_slow(), 1, a4, |
407 a3); | 392 a3); |
408 GenerateRuntimeGetProperty(masm, language_mode); | 393 GenerateRuntimeGetProperty(masm); |
409 | 394 |
410 __ bind(&check_name); | 395 __ bind(&check_name); |
411 GenerateKeyNameCheck(masm, key, a0, a3, &index_name, &slow); | 396 GenerateKeyNameCheck(masm, key, a0, a3, &index_name, &slow); |
412 | 397 |
413 GenerateKeyedLoadReceiverCheck(masm, receiver, a0, a3, | 398 GenerateKeyedLoadReceiverCheck(masm, receiver, a0, a3, |
414 Map::kHasNamedInterceptor, &slow); | 399 Map::kHasNamedInterceptor, &slow); |
415 | 400 |
416 | 401 |
417 // If the receiver is a fast-case object, check the stub cache. Otherwise | 402 // If the receiver is a fast-case object, check the stub cache. Otherwise |
418 // probe the dictionary. | 403 // probe the dictionary. |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
919 break; | 904 break; |
920 default: | 905 default: |
921 UNIMPLEMENTED(); | 906 UNIMPLEMENTED(); |
922 } | 907 } |
923 patcher.ChangeBranchCondition(branch_instr, opcode); | 908 patcher.ChangeBranchCondition(branch_instr, opcode); |
924 } | 909 } |
925 } // namespace internal | 910 } // namespace internal |
926 } // namespace v8 | 911 } // namespace v8 |
927 | 912 |
928 #endif // V8_TARGET_ARCH_MIPS64 | 913 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |