OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 } | 415 } |
416 | 416 |
417 | 417 |
418 // Generate StoreField code, value is passed in a0 register. | 418 // Generate StoreField code, value is passed in a0 register. |
419 // After executing generated code, the receiver_reg and name_reg | 419 // After executing generated code, the receiver_reg and name_reg |
420 // may be clobbered. | 420 // may be clobbered. |
421 void StubCompiler::GenerateStoreField(MacroAssembler* masm, | 421 void StubCompiler::GenerateStoreField(MacroAssembler* masm, |
422 Handle<JSObject> object, | 422 Handle<JSObject> object, |
423 int index, | 423 int index, |
424 Handle<Map> transition, | 424 Handle<Map> transition, |
425 Handle<String> name, | |
426 Register receiver_reg, | 425 Register receiver_reg, |
427 Register name_reg, | 426 Register name_reg, |
428 Register scratch1, | 427 Register scratch, |
429 Register scratch2, | |
430 Label* miss_label) { | 428 Label* miss_label) { |
431 // a0 : value. | 429 // a0 : value. |
432 Label exit; | 430 Label exit; |
433 | |
434 LookupResult lookup(masm->isolate()); | |
435 object->Lookup(*name, &lookup); | |
436 if (lookup.IsFound() && (lookup.IsReadOnly() || !lookup.IsCacheable())) { | |
437 // In sloppy mode, we could just return the value and be done. However, we | |
438 // might be in strict mode, where we have to throw. Since we cannot tell, | |
439 // go into slow case unconditionally. | |
440 __ jmp(miss_label); | |
441 return; | |
442 } | |
443 | |
444 // Check that the map of the object hasn't changed. | 431 // Check that the map of the object hasn't changed. |
445 CompareMapMode mode = transition.is_null() ? ALLOW_ELEMENT_TRANSITION_MAPS | 432 CompareMapMode mode = transition.is_null() ? ALLOW_ELEMENT_TRANSITION_MAPS |
446 : REQUIRE_EXACT_MAP; | 433 : REQUIRE_EXACT_MAP; |
447 __ CheckMap(receiver_reg, scratch1, Handle<Map>(object->map()), miss_label, | 434 __ CheckMap(receiver_reg, scratch, Handle<Map>(object->map()), miss_label, |
448 DO_SMI_CHECK, mode); | 435 DO_SMI_CHECK, mode); |
449 | 436 |
450 // Perform global security token check if needed. | 437 // Perform global security token check if needed. |
451 if (object->IsJSGlobalProxy()) { | 438 if (object->IsJSGlobalProxy()) { |
452 __ CheckAccessGlobalProxy(receiver_reg, scratch1, miss_label); | 439 __ CheckAccessGlobalProxy(receiver_reg, scratch, miss_label); |
453 } | |
454 | |
455 // Check that we are allowed to write this. | |
456 if (!transition.is_null() && object->GetPrototype()->IsJSObject()) { | |
457 JSObject* holder; | |
458 if (lookup.IsFound()) { | |
459 holder = lookup.holder(); | |
460 } else { | |
461 // Find the top object. | |
462 holder = *object; | |
463 do { | |
464 holder = JSObject::cast(holder->GetPrototype()); | |
465 } while (holder->GetPrototype()->IsJSObject()); | |
466 } | |
467 // We need an extra register, push | |
468 __ push(name_reg); | |
469 Label miss_pop, done_check; | |
470 CheckPrototypes(object, receiver_reg, Handle<JSObject>(holder), name_reg, | |
471 scratch1, scratch2, name, &miss_pop); | |
472 __ jmp(&done_check); | |
473 __ bind(&miss_pop); | |
474 __ pop(name_reg); | |
475 __ jmp(miss_label); | |
476 __ bind(&done_check); | |
477 __ pop(name_reg); | |
478 } | 440 } |
479 | 441 |
480 // Stub never generated for non-global objects that require access | 442 // Stub never generated for non-global objects that require access |
481 // checks. | 443 // checks. |
482 ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded()); | 444 ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded()); |
483 | 445 |
484 // Perform map transition for the receiver if necessary. | 446 // Perform map transition for the receiver if necessary. |
485 if (!transition.is_null() && (object->map()->unused_property_fields() == 0)) { | 447 if (!transition.is_null() && (object->map()->unused_property_fields() == 0)) { |
486 // The properties must be extended before we can store the value. | 448 // The properties must be extended before we can store the value. |
487 // We jump to a runtime call that extends the properties array. | 449 // We jump to a runtime call that extends the properties array. |
488 __ push(receiver_reg); | 450 __ push(receiver_reg); |
489 __ li(a2, Operand(transition)); | 451 __ li(a2, Operand(transition)); |
490 __ Push(a2, a0); | 452 __ Push(a2, a0); |
491 __ TailCallExternalReference( | 453 __ TailCallExternalReference( |
492 ExternalReference(IC_Utility(IC::kSharedStoreIC_ExtendStorage), | 454 ExternalReference(IC_Utility(IC::kSharedStoreIC_ExtendStorage), |
493 masm->isolate()), | 455 masm->isolate()), |
494 3, 1); | 456 3, 1); |
495 return; | 457 return; |
496 } | 458 } |
497 | 459 |
498 if (!transition.is_null()) { | 460 if (!transition.is_null()) { |
499 // Update the map of the object. | 461 // Update the map of the object. |
500 __ li(scratch1, Operand(transition)); | 462 __ li(scratch, Operand(transition)); |
501 __ sw(scratch1, FieldMemOperand(receiver_reg, HeapObject::kMapOffset)); | 463 __ sw(scratch, FieldMemOperand(receiver_reg, HeapObject::kMapOffset)); |
502 | 464 |
503 // Update the write barrier for the map field and pass the now unused | 465 // Update the write barrier for the map field and pass the now unused |
504 // name_reg as scratch register. | 466 // name_reg as scratch register. |
505 __ RecordWriteField(receiver_reg, | 467 __ RecordWriteField(receiver_reg, |
506 HeapObject::kMapOffset, | 468 HeapObject::kMapOffset, |
507 scratch1, | 469 scratch, |
508 name_reg, | 470 name_reg, |
509 kRAHasNotBeenSaved, | 471 kRAHasNotBeenSaved, |
510 kDontSaveFPRegs, | 472 kDontSaveFPRegs, |
511 OMIT_REMEMBERED_SET, | 473 OMIT_REMEMBERED_SET, |
512 OMIT_SMI_CHECK); | 474 OMIT_SMI_CHECK); |
513 } | 475 } |
514 | 476 |
515 // Adjust for the number of properties stored in the object. Even in the | 477 // Adjust for the number of properties stored in the object. Even in the |
516 // face of a transition we can use the old map here because the size of the | 478 // face of a transition we can use the old map here because the size of the |
517 // object and the number of in-object properties is not going to change. | 479 // object and the number of in-object properties is not going to change. |
518 index -= object->map()->inobject_properties(); | 480 index -= object->map()->inobject_properties(); |
519 | 481 |
520 if (index < 0) { | 482 if (index < 0) { |
521 // Set the property straight into the object. | 483 // Set the property straight into the object. |
522 int offset = object->map()->instance_size() + (index * kPointerSize); | 484 int offset = object->map()->instance_size() + (index * kPointerSize); |
523 __ sw(a0, FieldMemOperand(receiver_reg, offset)); | 485 __ sw(a0, FieldMemOperand(receiver_reg, offset)); |
524 | 486 |
525 // Skip updating write barrier if storing a smi. | 487 // Skip updating write barrier if storing a smi. |
526 __ JumpIfSmi(a0, &exit, scratch1); | 488 __ JumpIfSmi(a0, &exit, scratch); |
527 | 489 |
528 // Update the write barrier for the array address. | 490 // Update the write barrier for the array address. |
529 // Pass the now unused name_reg as a scratch register. | 491 // Pass the now unused name_reg as a scratch register. |
530 __ mov(name_reg, a0); | 492 __ mov(name_reg, a0); |
531 __ RecordWriteField(receiver_reg, | 493 __ RecordWriteField(receiver_reg, |
532 offset, | 494 offset, |
533 name_reg, | 495 name_reg, |
534 scratch1, | 496 scratch, |
535 kRAHasNotBeenSaved, | 497 kRAHasNotBeenSaved, |
536 kDontSaveFPRegs); | 498 kDontSaveFPRegs); |
537 } else { | 499 } else { |
538 // Write to the properties array. | 500 // Write to the properties array. |
539 int offset = index * kPointerSize + FixedArray::kHeaderSize; | 501 int offset = index * kPointerSize + FixedArray::kHeaderSize; |
540 // Get the properties array. | 502 // Get the properties array. |
541 __ lw(scratch1, | 503 __ lw(scratch, FieldMemOperand(receiver_reg, JSObject::kPropertiesOffset)); |
542 FieldMemOperand(receiver_reg, JSObject::kPropertiesOffset)); | 504 __ sw(a0, FieldMemOperand(scratch, offset)); |
543 __ sw(a0, FieldMemOperand(scratch1, offset)); | |
544 | 505 |
545 // Skip updating write barrier if storing a smi. | 506 // Skip updating write barrier if storing a smi. |
546 __ JumpIfSmi(a0, &exit); | 507 __ JumpIfSmi(a0, &exit); |
547 | 508 |
548 // Update the write barrier for the array address. | 509 // Update the write barrier for the array address. |
549 // Ok to clobber receiver_reg and name_reg, since we return. | 510 // Ok to clobber receiver_reg and name_reg, since we return. |
550 __ mov(name_reg, a0); | 511 __ mov(name_reg, a0); |
551 __ RecordWriteField(scratch1, | 512 __ RecordWriteField(scratch, |
552 offset, | 513 offset, |
553 name_reg, | 514 name_reg, |
554 receiver_reg, | 515 receiver_reg, |
555 kRAHasNotBeenSaved, | 516 kRAHasNotBeenSaved, |
556 kDontSaveFPRegs); | 517 kDontSaveFPRegs); |
557 } | 518 } |
558 | 519 |
559 // Return the value (register v0). | 520 // Return the value (register v0). |
560 __ bind(&exit); | 521 __ bind(&exit); |
561 __ mov(v0, a0); | 522 __ mov(v0, a0); |
(...skipping 2040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2602 Handle<String> name) { | 2563 Handle<String> name) { |
2603 // ----------- S t a t e ------------- | 2564 // ----------- S t a t e ------------- |
2604 // -- a0 : value | 2565 // -- a0 : value |
2605 // -- a1 : receiver | 2566 // -- a1 : receiver |
2606 // -- a2 : name | 2567 // -- a2 : name |
2607 // -- ra : return address | 2568 // -- ra : return address |
2608 // ----------------------------------- | 2569 // ----------------------------------- |
2609 Label miss; | 2570 Label miss; |
2610 | 2571 |
2611 // Name register might be clobbered. | 2572 // Name register might be clobbered. |
2612 GenerateStoreField(masm(), | 2573 GenerateStoreField(masm(), object, index, transition, a1, a2, a3, &miss); |
2613 object, | |
2614 index, | |
2615 transition, | |
2616 name, | |
2617 a1, a2, a3, t0, | |
2618 &miss); | |
2619 __ bind(&miss); | 2574 __ bind(&miss); |
2620 __ li(a2, Operand(Handle<String>(name))); // Restore name. | 2575 __ li(a2, Operand(Handle<String>(name))); // Restore name. |
2621 Handle<Code> ic = masm()->isolate()->builtins()->Builtins::StoreIC_Miss(); | 2576 Handle<Code> ic = masm()->isolate()->builtins()->Builtins::StoreIC_Miss(); |
2622 __ Jump(ic, RelocInfo::CODE_TARGET); | 2577 __ Jump(ic, RelocInfo::CODE_TARGET); |
2623 | 2578 |
2624 // Return the generated code. | 2579 // Return the generated code. |
2625 return GetCode(transition.is_null() ? FIELD : MAP_TRANSITION, name); | 2580 return GetCode(transition.is_null() ? FIELD : MAP_TRANSITION, name); |
2626 } | 2581 } |
2627 | 2582 |
2628 | 2583 |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3147 Label miss; | 3102 Label miss; |
3148 | 3103 |
3149 Counters* counters = masm()->isolate()->counters(); | 3104 Counters* counters = masm()->isolate()->counters(); |
3150 __ IncrementCounter(counters->keyed_store_field(), 1, a3, t0); | 3105 __ IncrementCounter(counters->keyed_store_field(), 1, a3, t0); |
3151 | 3106 |
3152 // Check that the name has not changed. | 3107 // Check that the name has not changed. |
3153 __ Branch(&miss, ne, a1, Operand(name)); | 3108 __ Branch(&miss, ne, a1, Operand(name)); |
3154 | 3109 |
3155 // a3 is used as scratch register. a1 and a2 keep their values if a jump to | 3110 // a3 is used as scratch register. a1 and a2 keep their values if a jump to |
3156 // the miss label is generated. | 3111 // the miss label is generated. |
3157 GenerateStoreField(masm(), | 3112 GenerateStoreField(masm(), object, index, transition, a2, a1, a3, &miss); |
3158 object, | |
3159 index, | |
3160 transition, | |
3161 name, | |
3162 a2, a1, a3, t0, | |
3163 &miss); | |
3164 __ bind(&miss); | 3113 __ bind(&miss); |
3165 | 3114 |
3166 __ DecrementCounter(counters->keyed_store_field(), 1, a3, t0); | 3115 __ DecrementCounter(counters->keyed_store_field(), 1, a3, t0); |
3167 Handle<Code> ic = masm()->isolate()->builtins()->KeyedStoreIC_Miss(); | 3116 Handle<Code> ic = masm()->isolate()->builtins()->KeyedStoreIC_Miss(); |
3168 __ Jump(ic, RelocInfo::CODE_TARGET); | 3117 __ Jump(ic, RelocInfo::CODE_TARGET); |
3169 | 3118 |
3170 // Return the generated code. | 3119 // Return the generated code. |
3171 return GetCode(transition.is_null() ? FIELD : MAP_TRANSITION, name); | 3120 return GetCode(transition.is_null() ? FIELD : MAP_TRANSITION, name); |
3172 } | 3121 } |
3173 | 3122 |
(...skipping 1478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4652 __ Jump(ic_slow, RelocInfo::CODE_TARGET); | 4601 __ Jump(ic_slow, RelocInfo::CODE_TARGET); |
4653 } | 4602 } |
4654 } | 4603 } |
4655 | 4604 |
4656 | 4605 |
4657 #undef __ | 4606 #undef __ |
4658 | 4607 |
4659 } } // namespace v8::internal | 4608 } } // namespace v8::internal |
4660 | 4609 |
4661 #endif // V8_TARGET_ARCH_MIPS | 4610 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |