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_MIPS | 5 #if V8_TARGET_ARCH_MIPS |
6 | 6 |
7 #include "src/ic/handler-compiler.h" | 7 #include "src/ic/handler-compiler.h" |
8 | 8 |
9 #include "src/api-arguments.h" | 9 #include "src/api-arguments.h" |
10 #include "src/field-type.h" | 10 #include "src/field-type.h" |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 } | 577 } |
578 | 578 |
579 | 579 |
580 void NamedLoadHandlerCompiler::GenerateLoadConstant(Handle<Object> value) { | 580 void NamedLoadHandlerCompiler::GenerateLoadConstant(Handle<Object> value) { |
581 // Return the constant value. | 581 // Return the constant value. |
582 __ li(v0, value); | 582 __ li(v0, value); |
583 __ Ret(); | 583 __ Ret(); |
584 } | 584 } |
585 | 585 |
586 | 586 |
| 587 void NamedLoadHandlerCompiler::GenerateLoadCallback( |
| 588 Register reg, Handle<AccessorInfo> callback) { |
| 589 DCHECK(!AreAliased(scratch2(), scratch3(), scratch4(), receiver())); |
| 590 DCHECK(!AreAliased(scratch2(), scratch3(), scratch4(), reg)); |
| 591 |
| 592 // Build v8::PropertyCallbackInfo::args_ array on the stack and push property |
| 593 // name below the exit frame to make GC aware of them. |
| 594 STATIC_ASSERT(PropertyCallbackArguments::kShouldThrowOnErrorIndex == 0); |
| 595 STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == 1); |
| 596 STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == 2); |
| 597 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == 3); |
| 598 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == 4); |
| 599 STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == 5); |
| 600 STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 6); |
| 601 STATIC_ASSERT(PropertyCallbackArguments::kArgsLength == 7); |
| 602 |
| 603 // Here and below +1 is for name() pushed after the args_ array. |
| 604 typedef PropertyCallbackArguments PCA; |
| 605 __ Subu(sp, sp, (PCA::kArgsLength + 1) * kPointerSize); |
| 606 __ sw(receiver(), MemOperand(sp, (PCA::kThisIndex + 1) * kPointerSize)); |
| 607 Handle<Object> data(callback->data(), isolate()); |
| 608 if (data->IsUndefined() || data->IsSmi()) { |
| 609 __ li(scratch2(), data); |
| 610 } else { |
| 611 Handle<WeakCell> cell = |
| 612 isolate()->factory()->NewWeakCell(Handle<HeapObject>::cast(data)); |
| 613 // The callback is alive if this instruction is executed, |
| 614 // so the weak cell is not cleared and points to data. |
| 615 __ GetWeakValue(scratch2(), cell); |
| 616 } |
| 617 __ sw(scratch2(), MemOperand(sp, (PCA::kDataIndex + 1) * kPointerSize)); |
| 618 __ LoadRoot(scratch2(), Heap::kUndefinedValueRootIndex); |
| 619 __ sw(scratch2(), |
| 620 MemOperand(sp, (PCA::kReturnValueOffset + 1) * kPointerSize)); |
| 621 __ sw(scratch2(), MemOperand(sp, (PCA::kReturnValueDefaultValueIndex + 1) * |
| 622 kPointerSize)); |
| 623 __ li(scratch2(), Operand(ExternalReference::isolate_address(isolate()))); |
| 624 __ sw(scratch2(), MemOperand(sp, (PCA::kIsolateIndex + 1) * kPointerSize)); |
| 625 __ sw(reg, MemOperand(sp, (PCA::kHolderIndex + 1) * kPointerSize)); |
| 626 // should_throw_on_error -> false |
| 627 DCHECK(Smi::FromInt(0) == nullptr); |
| 628 __ sw(zero_reg, |
| 629 MemOperand(sp, (PCA::kShouldThrowOnErrorIndex + 1) * kPointerSize)); |
| 630 |
| 631 __ sw(name(), MemOperand(sp, 0 * kPointerSize)); |
| 632 |
| 633 // Abi for CallApiGetter. |
| 634 Register getter_address_reg = ApiGetterDescriptor::function_address(); |
| 635 |
| 636 Address getter_address = v8::ToCData<Address>(callback->getter()); |
| 637 ApiFunction fun(getter_address); |
| 638 ExternalReference::Type type = ExternalReference::DIRECT_GETTER_CALL; |
| 639 ExternalReference ref = ExternalReference(&fun, type, isolate()); |
| 640 __ li(getter_address_reg, Operand(ref)); |
| 641 |
| 642 CallApiGetterStub stub(isolate()); |
| 643 __ TailCallStub(&stub); |
| 644 } |
| 645 |
| 646 |
587 void NamedLoadHandlerCompiler::GenerateLoadInterceptorWithFollowup( | 647 void NamedLoadHandlerCompiler::GenerateLoadInterceptorWithFollowup( |
588 LookupIterator* it, Register holder_reg) { | 648 LookupIterator* it, Register holder_reg) { |
589 DCHECK(holder()->HasNamedInterceptor()); | 649 DCHECK(holder()->HasNamedInterceptor()); |
590 DCHECK(!holder()->GetNamedInterceptor()->getter()->IsUndefined()); | 650 DCHECK(!holder()->GetNamedInterceptor()->getter()->IsUndefined()); |
591 | 651 |
592 // Compile the interceptor call, followed by inline code to load the | 652 // Compile the interceptor call, followed by inline code to load the |
593 // property from further up the prototype chain if the call fails. | 653 // property from further up the prototype chain if the call fails. |
594 // Check that the maps haven't changed. | 654 // Check that the maps haven't changed. |
595 DCHECK(holder_reg.is(receiver()) || holder_reg.is(scratch1())); | 655 DCHECK(holder_reg.is(receiver()) || holder_reg.is(scratch1())); |
596 | 656 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 // Return the generated code. | 780 // Return the generated code. |
721 return GetCode(kind(), name); | 781 return GetCode(kind(), name); |
722 } | 782 } |
723 | 783 |
724 | 784 |
725 #undef __ | 785 #undef __ |
726 } // namespace internal | 786 } // namespace internal |
727 } // namespace v8 | 787 } // namespace v8 |
728 | 788 |
729 #endif // V8_TARGET_ARCH_MIPS | 789 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |