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