| 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 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #if V8_TARGET_ARCH_X64 | 7 #if V8_TARGET_ARCH_X64 |
| 8 | 8 |
| 9 #include "src/arguments.h" | 9 #include "src/arguments.h" |
| 10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 void NamedStoreHandlerCompiler::GenerateStoreField( | 521 void NamedStoreHandlerCompiler::GenerateStoreField( |
| 522 Handle<JSObject> object, LookupResult* lookup, Register receiver_reg, | 522 Handle<JSObject> object, LookupResult* lookup, Register receiver_reg, |
| 523 Register name_reg, Register value_reg, Register scratch1, Register scratch2, | 523 Register name_reg, Register value_reg, Register scratch1, Register scratch2, |
| 524 Label* miss_label) { | 524 Label* miss_label) { |
| 525 // Stub never generated for objects that require access checks. | 525 // Stub never generated for objects that require access checks. |
| 526 DCHECK(!object->IsAccessCheckNeeded()); | 526 DCHECK(!object->IsAccessCheckNeeded()); |
| 527 DCHECK(!object->IsJSGlobalProxy()); | 527 DCHECK(!object->IsJSGlobalProxy()); |
| 528 | 528 |
| 529 FieldIndex index = lookup->GetFieldIndex(); | 529 FieldIndex index = lookup->GetFieldIndex(); |
| 530 | 530 |
| 531 Representation representation = lookup->representation(); | 531 DCHECK(lookup->representation().IsHeapObject()); |
| 532 DCHECK(!representation.IsNone()); | 532 __ JumpIfSmi(value_reg, miss_label); |
| 533 if (representation.IsSmi()) { | 533 HeapType* field_type = lookup->GetFieldType(); |
| 534 __ JumpIfNotSmi(value_reg, miss_label); | 534 HeapType::Iterator<Map> it = field_type->Classes(); |
| 535 } else if (representation.IsHeapObject()) { | 535 if (!it.Done()) { |
| 536 __ JumpIfSmi(value_reg, miss_label); | 536 Label do_store; |
| 537 HeapType* field_type = lookup->GetFieldType(); | 537 while (true) { |
| 538 HeapType::Iterator<Map> it = field_type->Classes(); | 538 __ CompareMap(value_reg, it.Current()); |
| 539 if (!it.Done()) { | 539 it.Advance(); |
| 540 Label do_store; | 540 if (it.Done()) { |
| 541 while (true) { | 541 __ j(not_equal, miss_label); |
| 542 __ CompareMap(value_reg, it.Current()); | 542 break; |
| 543 it.Advance(); | |
| 544 if (it.Done()) { | |
| 545 __ j(not_equal, miss_label); | |
| 546 break; | |
| 547 } | |
| 548 __ j(equal, &do_store, Label::kNear); | |
| 549 } | 543 } |
| 550 __ bind(&do_store); | 544 __ j(equal, &do_store, Label::kNear); |
| 551 } | 545 } |
| 552 } else if (representation.IsDouble()) { | |
| 553 // Load the double storage. | |
| 554 if (index.is_inobject()) { | |
| 555 __ movp(scratch1, FieldOperand(receiver_reg, index.offset())); | |
| 556 } else { | |
| 557 __ movp(scratch1, | |
| 558 FieldOperand(receiver_reg, JSObject::kPropertiesOffset)); | |
| 559 __ movp(scratch1, FieldOperand(scratch1, index.offset())); | |
| 560 } | |
| 561 | |
| 562 // Store the value into the storage. | |
| 563 Label do_store, heap_number; | |
| 564 __ JumpIfNotSmi(value_reg, &heap_number); | |
| 565 __ SmiToInteger32(scratch2, value_reg); | |
| 566 __ Cvtlsi2sd(xmm0, scratch2); | |
| 567 __ jmp(&do_store); | |
| 568 | |
| 569 __ bind(&heap_number); | |
| 570 __ CheckMap(value_reg, isolate()->factory()->heap_number_map(), miss_label, | |
| 571 DONT_DO_SMI_CHECK); | |
| 572 __ movsd(xmm0, FieldOperand(value_reg, HeapNumber::kValueOffset)); | |
| 573 __ bind(&do_store); | 546 __ bind(&do_store); |
| 574 __ movsd(FieldOperand(scratch1, HeapNumber::kValueOffset), xmm0); | |
| 575 // Return the value (register rax). | |
| 576 DCHECK(value_reg.is(rax)); | |
| 577 __ ret(0); | |
| 578 return; | |
| 579 } | 547 } |
| 580 | 548 |
| 581 // TODO(verwaest): Share this code as a code stub. | |
| 582 SmiCheck smi_check = representation.IsTagged() | |
| 583 ? INLINE_SMI_CHECK : OMIT_SMI_CHECK; | |
| 584 if (index.is_inobject()) { | 549 if (index.is_inobject()) { |
| 585 // Set the property straight into the object. | 550 // Set the property straight into the object. |
| 586 __ movp(FieldOperand(receiver_reg, index.offset()), value_reg); | 551 __ movp(FieldOperand(receiver_reg, index.offset()), value_reg); |
| 587 | 552 |
| 588 if (!representation.IsSmi()) { | 553 // Update the write barrier for the array address. |
| 589 // Update the write barrier for the array address. | 554 // Pass the value being stored in the now unused name_reg. |
| 590 // Pass the value being stored in the now unused name_reg. | 555 __ movp(name_reg, value_reg); |
| 591 __ movp(name_reg, value_reg); | 556 __ RecordWriteField(receiver_reg, index.offset(), name_reg, scratch1, |
| 592 __ RecordWriteField( | 557 kDontSaveFPRegs, EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); |
| 593 receiver_reg, index.offset(), name_reg, scratch1, kDontSaveFPRegs, | |
| 594 EMIT_REMEMBERED_SET, smi_check); | |
| 595 } | |
| 596 } else { | 558 } else { |
| 597 // Write to the properties array. | 559 // Write to the properties array. |
| 598 // Get the properties array (optimistically). | 560 // Get the properties array (optimistically). |
| 599 __ movp(scratch1, FieldOperand(receiver_reg, JSObject::kPropertiesOffset)); | 561 __ movp(scratch1, FieldOperand(receiver_reg, JSObject::kPropertiesOffset)); |
| 600 __ movp(FieldOperand(scratch1, index.offset()), value_reg); | 562 __ movp(FieldOperand(scratch1, index.offset()), value_reg); |
| 601 | 563 |
| 602 if (!representation.IsSmi()) { | 564 // Update the write barrier for the array address. |
| 603 // Update the write barrier for the array address. | 565 // Pass the value being stored in the now unused name_reg. |
| 604 // Pass the value being stored in the now unused name_reg. | 566 __ movp(name_reg, value_reg); |
| 605 __ movp(name_reg, value_reg); | 567 __ RecordWriteField(scratch1, index.offset(), name_reg, receiver_reg, |
| 606 __ RecordWriteField( | 568 kDontSaveFPRegs, EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); |
| 607 scratch1, index.offset(), name_reg, receiver_reg, kDontSaveFPRegs, | |
| 608 EMIT_REMEMBERED_SET, smi_check); | |
| 609 } | |
| 610 } | 569 } |
| 611 | 570 |
| 612 // Return the value (register rax). | 571 // Return the value (register rax). |
| 613 DCHECK(value_reg.is(rax)); | 572 DCHECK(value_reg.is(rax)); |
| 614 __ ret(0); | 573 __ ret(0); |
| 615 } | 574 } |
| 616 | 575 |
| 617 | 576 |
| 618 Register PropertyHandlerCompiler::CheckPrototypes( | 577 Register PropertyHandlerCompiler::CheckPrototypes( |
| 619 Register object_reg, Register holder_reg, Register scratch1, | 578 Register object_reg, Register holder_reg, Register scratch1, |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1214 // ----------------------------------- | 1173 // ----------------------------------- |
| 1215 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); | 1174 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); |
| 1216 } | 1175 } |
| 1217 | 1176 |
| 1218 | 1177 |
| 1219 #undef __ | 1178 #undef __ |
| 1220 | 1179 |
| 1221 } } // namespace v8::internal | 1180 } } // namespace v8::internal |
| 1222 | 1181 |
| 1223 #endif // V8_TARGET_ARCH_X64 | 1182 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |