| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_PPC | 5 #if V8_TARGET_ARCH_PPC |
| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 __ lbz(scratch, FieldMemOperand(map, Map::kInstanceTypeOffset)); | 156 __ lbz(scratch, FieldMemOperand(map, Map::kInstanceTypeOffset)); |
| 157 __ cmpi(scratch, Operand(JS_OBJECT_TYPE)); | 157 __ cmpi(scratch, Operand(JS_OBJECT_TYPE)); |
| 158 __ blt(slow); | 158 __ blt(slow); |
| 159 } | 159 } |
| 160 | 160 |
| 161 | 161 |
| 162 // Loads an indexed element from a fast case array. | 162 // Loads an indexed element from a fast case array. |
| 163 static void GenerateFastArrayLoad(MacroAssembler* masm, Register receiver, | 163 static void GenerateFastArrayLoad(MacroAssembler* masm, Register receiver, |
| 164 Register key, Register elements, | 164 Register key, Register elements, |
| 165 Register scratch1, Register scratch2, | 165 Register scratch1, Register scratch2, |
| 166 Register result, Label* slow, | 166 Register result, Label* slow) { |
| 167 LanguageMode language_mode) { | |
| 168 // Register use: | 167 // Register use: |
| 169 // | 168 // |
| 170 // receiver - holds the receiver on entry. | 169 // receiver - holds the receiver on entry. |
| 171 // Unchanged unless 'result' is the same register. | 170 // Unchanged unless 'result' is the same register. |
| 172 // | 171 // |
| 173 // key - holds the smi key on entry. | 172 // key - holds the smi key on entry. |
| 174 // Unchanged unless 'result' is the same register. | 173 // Unchanged unless 'result' is the same register. |
| 175 // | 174 // |
| 176 // result - holds the result on exit if the load succeeded. | 175 // result - holds the result on exit if the load succeeded. |
| 177 // Allowed to be the the same as 'receiver' or 'key'. | 176 // Allowed to be the the same as 'receiver' or 'key'. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 __ blt(slow); | 213 __ blt(slow); |
| 215 __ lbz(scratch1, FieldMemOperand(scratch2, Map::kBitFieldOffset)); | 214 __ lbz(scratch1, FieldMemOperand(scratch2, Map::kBitFieldOffset)); |
| 216 __ andi(r0, scratch1, Operand((1 << Map::kIsAccessCheckNeeded) | | 215 __ andi(r0, scratch1, Operand((1 << Map::kIsAccessCheckNeeded) | |
| 217 (1 << Map::kHasIndexedInterceptor))); | 216 (1 << Map::kHasIndexedInterceptor))); |
| 218 __ bne(slow, cr0); | 217 __ bne(slow, cr0); |
| 219 __ CompareRoot(elements, Heap::kEmptyFixedArrayRootIndex); | 218 __ CompareRoot(elements, Heap::kEmptyFixedArrayRootIndex); |
| 220 __ bne(slow); | 219 __ bne(slow); |
| 221 __ jmp(&check_next_prototype); | 220 __ jmp(&check_next_prototype); |
| 222 | 221 |
| 223 __ bind(&absent); | 222 __ bind(&absent); |
| 224 if (is_strong(language_mode)) { | 223 __ LoadRoot(result, Heap::kUndefinedValueRootIndex); |
| 225 // Strong mode accesses must throw in this case, so call the runtime. | 224 __ jmp(&done); |
| 226 __ jmp(slow); | |
| 227 } else { | |
| 228 __ LoadRoot(result, Heap::kUndefinedValueRootIndex); | |
| 229 __ jmp(&done); | |
| 230 } | |
| 231 | 225 |
| 232 __ bind(&in_bounds); | 226 __ bind(&in_bounds); |
| 233 // Fast case: Do the load. | 227 // Fast case: Do the load. |
| 234 __ addi(scratch1, elements, | 228 __ addi(scratch1, elements, |
| 235 Operand(FixedArray::kHeaderSize - kHeapObjectTag)); | 229 Operand(FixedArray::kHeaderSize - kHeapObjectTag)); |
| 236 // The key is a smi. | 230 // The key is a smi. |
| 237 __ SmiToPtrArrayOffset(scratch2, key); | 231 __ SmiToPtrArrayOffset(scratch2, key); |
| 238 __ LoadPX(scratch2, MemOperand(scratch2, scratch1)); | 232 __ LoadPX(scratch2, MemOperand(scratch2, scratch1)); |
| 239 __ CompareRoot(scratch2, Heap::kTheHoleValueRootIndex); | 233 __ CompareRoot(scratch2, Heap::kTheHoleValueRootIndex); |
| 240 // In case the loaded value is the_hole we have to check the prototype chain. | 234 // In case the loaded value is the_hole we have to check the prototype chain. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 267 // bit test is enough. | 261 // bit test is enough. |
| 268 // map: key map | 262 // map: key map |
| 269 __ lbz(hash, FieldMemOperand(map, Map::kInstanceTypeOffset)); | 263 __ lbz(hash, FieldMemOperand(map, Map::kInstanceTypeOffset)); |
| 270 STATIC_ASSERT(kInternalizedTag == 0); | 264 STATIC_ASSERT(kInternalizedTag == 0); |
| 271 __ andi(r0, hash, Operand(kIsNotInternalizedMask)); | 265 __ andi(r0, hash, Operand(kIsNotInternalizedMask)); |
| 272 __ bne(not_unique, cr0); | 266 __ bne(not_unique, cr0); |
| 273 | 267 |
| 274 __ bind(&unique); | 268 __ bind(&unique); |
| 275 } | 269 } |
| 276 | 270 |
| 277 | 271 void LoadIC::GenerateNormal(MacroAssembler* masm) { |
| 278 void LoadIC::GenerateNormal(MacroAssembler* masm, LanguageMode language_mode) { | |
| 279 Register dictionary = r3; | 272 Register dictionary = r3; |
| 280 DCHECK(!dictionary.is(LoadDescriptor::ReceiverRegister())); | 273 DCHECK(!dictionary.is(LoadDescriptor::ReceiverRegister())); |
| 281 DCHECK(!dictionary.is(LoadDescriptor::NameRegister())); | 274 DCHECK(!dictionary.is(LoadDescriptor::NameRegister())); |
| 282 | 275 |
| 283 Label slow; | 276 Label slow; |
| 284 | 277 |
| 285 __ LoadP(dictionary, FieldMemOperand(LoadDescriptor::ReceiverRegister(), | 278 __ LoadP(dictionary, FieldMemOperand(LoadDescriptor::ReceiverRegister(), |
| 286 JSObject::kPropertiesOffset)); | 279 JSObject::kPropertiesOffset)); |
| 287 GenerateDictionaryLoad(masm, &slow, dictionary, | 280 GenerateDictionaryLoad(masm, &slow, dictionary, |
| 288 LoadDescriptor::NameRegister(), r3, r6, r7); | 281 LoadDescriptor::NameRegister(), r3, r6, r7); |
| 289 __ Ret(); | 282 __ Ret(); |
| 290 | 283 |
| 291 // Dictionary load failed, go slow (but don't miss). | 284 // Dictionary load failed, go slow (but don't miss). |
| 292 __ bind(&slow); | 285 __ bind(&slow); |
| 293 GenerateRuntimeGetProperty(masm, language_mode); | 286 GenerateRuntimeGetProperty(masm); |
| 294 } | 287 } |
| 295 | 288 |
| 296 | 289 |
| 297 // A register that isn't one of the parameters to the load ic. | 290 // A register that isn't one of the parameters to the load ic. |
| 298 static const Register LoadIC_TempRegister() { return r6; } | 291 static const Register LoadIC_TempRegister() { return r6; } |
| 299 | 292 |
| 300 | 293 |
| 301 static void LoadIC_PushArgs(MacroAssembler* masm) { | 294 static void LoadIC_PushArgs(MacroAssembler* masm) { |
| 302 Register receiver = LoadDescriptor::ReceiverRegister(); | 295 Register receiver = LoadDescriptor::ReceiverRegister(); |
| 303 Register name = LoadDescriptor::NameRegister(); | 296 Register name = LoadDescriptor::NameRegister(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 315 DCHECK(!AreAliased(r7, r8, LoadWithVectorDescriptor::SlotRegister(), | 308 DCHECK(!AreAliased(r7, r8, LoadWithVectorDescriptor::SlotRegister(), |
| 316 LoadWithVectorDescriptor::VectorRegister())); | 309 LoadWithVectorDescriptor::VectorRegister())); |
| 317 __ IncrementCounter(isolate->counters()->ic_load_miss(), 1, r7, r8); | 310 __ IncrementCounter(isolate->counters()->ic_load_miss(), 1, r7, r8); |
| 318 | 311 |
| 319 LoadIC_PushArgs(masm); | 312 LoadIC_PushArgs(masm); |
| 320 | 313 |
| 321 // Perform tail call to the entry. | 314 // Perform tail call to the entry. |
| 322 __ TailCallRuntime(Runtime::kLoadIC_Miss); | 315 __ TailCallRuntime(Runtime::kLoadIC_Miss); |
| 323 } | 316 } |
| 324 | 317 |
| 325 | 318 void LoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) { |
| 326 void LoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm, | |
| 327 LanguageMode language_mode) { | |
| 328 // The return address is in lr. | 319 // The return address is in lr. |
| 329 | 320 |
| 330 __ mr(LoadIC_TempRegister(), LoadDescriptor::ReceiverRegister()); | 321 __ mr(LoadIC_TempRegister(), LoadDescriptor::ReceiverRegister()); |
| 331 __ Push(LoadIC_TempRegister(), LoadDescriptor::NameRegister()); | 322 __ Push(LoadIC_TempRegister(), LoadDescriptor::NameRegister()); |
| 332 | 323 |
| 333 // Do tail-call to runtime routine. | 324 // Do tail-call to runtime routine. |
| 334 __ TailCallRuntime(is_strong(language_mode) ? Runtime::kGetPropertyStrong | 325 __ TailCallRuntime(Runtime::kGetProperty); |
| 335 : Runtime::kGetProperty); | |
| 336 } | 326 } |
| 337 | 327 |
| 338 | 328 |
| 339 void KeyedLoadIC::GenerateMiss(MacroAssembler* masm) { | 329 void KeyedLoadIC::GenerateMiss(MacroAssembler* masm) { |
| 340 // The return address is in lr. | 330 // The return address is in lr. |
| 341 Isolate* isolate = masm->isolate(); | 331 Isolate* isolate = masm->isolate(); |
| 342 | 332 |
| 343 DCHECK(!AreAliased(r7, r8, LoadWithVectorDescriptor::SlotRegister(), | 333 DCHECK(!AreAliased(r7, r8, LoadWithVectorDescriptor::SlotRegister(), |
| 344 LoadWithVectorDescriptor::VectorRegister())); | 334 LoadWithVectorDescriptor::VectorRegister())); |
| 345 __ IncrementCounter(isolate->counters()->ic_keyed_load_miss(), 1, r7, r8); | 335 __ IncrementCounter(isolate->counters()->ic_keyed_load_miss(), 1, r7, r8); |
| 346 | 336 |
| 347 LoadIC_PushArgs(masm); | 337 LoadIC_PushArgs(masm); |
| 348 | 338 |
| 349 // Perform tail call to the entry. | 339 // Perform tail call to the entry. |
| 350 __ TailCallRuntime(Runtime::kKeyedLoadIC_Miss); | 340 __ TailCallRuntime(Runtime::kKeyedLoadIC_Miss); |
| 351 } | 341 } |
| 352 | 342 |
| 353 | 343 void KeyedLoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) { |
| 354 void KeyedLoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm, | |
| 355 LanguageMode language_mode) { | |
| 356 // The return address is in lr. | 344 // The return address is in lr. |
| 357 | 345 |
| 358 __ Push(LoadDescriptor::ReceiverRegister(), LoadDescriptor::NameRegister()); | 346 __ Push(LoadDescriptor::ReceiverRegister(), LoadDescriptor::NameRegister()); |
| 359 | 347 |
| 360 // Do tail-call to runtime routine. | 348 // Do tail-call to runtime routine. |
| 361 __ TailCallRuntime(is_strong(language_mode) ? Runtime::kKeyedGetPropertyStrong | 349 __ TailCallRuntime(Runtime::kKeyedGetProperty); |
| 362 : Runtime::kKeyedGetProperty); | |
| 363 } | 350 } |
| 364 | 351 |
| 365 | 352 void KeyedLoadIC::GenerateMegamorphic(MacroAssembler* masm) { |
| 366 void KeyedLoadIC::GenerateMegamorphic(MacroAssembler* masm, | |
| 367 LanguageMode language_mode) { | |
| 368 // The return address is in lr. | 353 // The return address is in lr. |
| 369 Label slow, check_name, index_smi, index_name, property_array_property; | 354 Label slow, check_name, index_smi, index_name, property_array_property; |
| 370 Label probe_dictionary, check_number_dictionary; | 355 Label probe_dictionary, check_number_dictionary; |
| 371 | 356 |
| 372 Register key = LoadDescriptor::NameRegister(); | 357 Register key = LoadDescriptor::NameRegister(); |
| 373 Register receiver = LoadDescriptor::ReceiverRegister(); | 358 Register receiver = LoadDescriptor::ReceiverRegister(); |
| 374 DCHECK(key.is(r5)); | 359 DCHECK(key.is(r5)); |
| 375 DCHECK(receiver.is(r4)); | 360 DCHECK(receiver.is(r4)); |
| 376 | 361 |
| 377 Isolate* isolate = masm->isolate(); | 362 Isolate* isolate = masm->isolate(); |
| 378 | 363 |
| 379 // Check that the key is a smi. | 364 // Check that the key is a smi. |
| 380 __ JumpIfNotSmi(key, &check_name); | 365 __ JumpIfNotSmi(key, &check_name); |
| 381 __ bind(&index_smi); | 366 __ bind(&index_smi); |
| 382 // Now the key is known to be a smi. This place is also jumped to from below | 367 // Now the key is known to be a smi. This place is also jumped to from below |
| 383 // where a numeric string is converted to a smi. | 368 // where a numeric string is converted to a smi. |
| 384 | 369 |
| 385 GenerateKeyedLoadReceiverCheck(masm, receiver, r3, r6, | 370 GenerateKeyedLoadReceiverCheck(masm, receiver, r3, r6, |
| 386 Map::kHasIndexedInterceptor, &slow); | 371 Map::kHasIndexedInterceptor, &slow); |
| 387 | 372 |
| 388 // Check the receiver's map to see if it has fast elements. | 373 // Check the receiver's map to see if it has fast elements. |
| 389 __ CheckFastElements(r3, r6, &check_number_dictionary); | 374 __ CheckFastElements(r3, r6, &check_number_dictionary); |
| 390 | 375 |
| 391 GenerateFastArrayLoad(masm, receiver, key, r3, r6, r7, r3, &slow, | 376 GenerateFastArrayLoad(masm, receiver, key, r3, r6, r7, r3, &slow); |
| 392 language_mode); | |
| 393 __ IncrementCounter(isolate->counters()->ic_keyed_load_generic_smi(), 1, r7, | 377 __ IncrementCounter(isolate->counters()->ic_keyed_load_generic_smi(), 1, r7, |
| 394 r6); | 378 r6); |
| 395 __ Ret(); | 379 __ Ret(); |
| 396 | 380 |
| 397 __ bind(&check_number_dictionary); | 381 __ bind(&check_number_dictionary); |
| 398 __ LoadP(r7, FieldMemOperand(receiver, JSObject::kElementsOffset)); | 382 __ LoadP(r7, FieldMemOperand(receiver, JSObject::kElementsOffset)); |
| 399 __ LoadP(r6, FieldMemOperand(r7, JSObject::kMapOffset)); | 383 __ LoadP(r6, FieldMemOperand(r7, JSObject::kMapOffset)); |
| 400 | 384 |
| 401 // Check whether the elements is a number dictionary. | 385 // Check whether the elements is a number dictionary. |
| 402 // r6: elements map | 386 // r6: elements map |
| 403 // r7: elements | 387 // r7: elements |
| 404 __ LoadRoot(ip, Heap::kHashTableMapRootIndex); | 388 __ LoadRoot(ip, Heap::kHashTableMapRootIndex); |
| 405 __ cmp(r6, ip); | 389 __ cmp(r6, ip); |
| 406 __ bne(&slow); | 390 __ bne(&slow); |
| 407 __ SmiUntag(r3, key); | 391 __ SmiUntag(r3, key); |
| 408 __ LoadFromNumberDictionary(&slow, r7, key, r3, r3, r6, r8); | 392 __ LoadFromNumberDictionary(&slow, r7, key, r3, r3, r6, r8); |
| 409 __ Ret(); | 393 __ Ret(); |
| 410 | 394 |
| 411 // Slow case, key and receiver still in r3 and r4. | 395 // Slow case, key and receiver still in r3 and r4. |
| 412 __ bind(&slow); | 396 __ bind(&slow); |
| 413 __ IncrementCounter(isolate->counters()->ic_keyed_load_generic_slow(), 1, r7, | 397 __ IncrementCounter(isolate->counters()->ic_keyed_load_generic_slow(), 1, r7, |
| 414 r6); | 398 r6); |
| 415 GenerateRuntimeGetProperty(masm, language_mode); | 399 GenerateRuntimeGetProperty(masm); |
| 416 | 400 |
| 417 __ bind(&check_name); | 401 __ bind(&check_name); |
| 418 GenerateKeyNameCheck(masm, key, r3, r6, &index_name, &slow); | 402 GenerateKeyNameCheck(masm, key, r3, r6, &index_name, &slow); |
| 419 | 403 |
| 420 GenerateKeyedLoadReceiverCheck(masm, receiver, r3, r6, | 404 GenerateKeyedLoadReceiverCheck(masm, receiver, r3, r6, |
| 421 Map::kHasNamedInterceptor, &slow); | 405 Map::kHasNamedInterceptor, &slow); |
| 422 | 406 |
| 423 // If the receiver is a fast-case object, check the stub cache. Otherwise | 407 // If the receiver is a fast-case object, check the stub cache. Otherwise |
| 424 // probe the dictionary. | 408 // probe the dictionary. |
| 425 __ LoadP(r6, FieldMemOperand(receiver, JSObject::kPropertiesOffset)); | 409 __ LoadP(r6, FieldMemOperand(receiver, JSObject::kPropertiesOffset)); |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 903 patcher.EmitCondition(ne); | 887 patcher.EmitCondition(ne); |
| 904 } else { | 888 } else { |
| 905 DCHECK(Assembler::GetCondition(branch_instr) == ne); | 889 DCHECK(Assembler::GetCondition(branch_instr) == ne); |
| 906 patcher.EmitCondition(eq); | 890 patcher.EmitCondition(eq); |
| 907 } | 891 } |
| 908 } | 892 } |
| 909 } // namespace internal | 893 } // namespace internal |
| 910 } // namespace v8 | 894 } // namespace v8 |
| 911 | 895 |
| 912 #endif // V8_TARGET_ARCH_PPC | 896 #endif // V8_TARGET_ARCH_PPC |
| OLD | NEW |