| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 1826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1837 JSObject* holder, | 1837 JSObject* holder, |
| 1838 AccessorInfo* callback) { | 1838 AccessorInfo* callback) { |
| 1839 // ----------- S t a t e ------------- | 1839 // ----------- S t a t e ------------- |
| 1840 // -- rax : receiver | 1840 // -- rax : receiver |
| 1841 // -- rcx : name | 1841 // -- rcx : name |
| 1842 // -- rsp[0] : return address | 1842 // -- rsp[0] : return address |
| 1843 // ----------------------------------- | 1843 // ----------------------------------- |
| 1844 Label miss; | 1844 Label miss; |
| 1845 | 1845 |
| 1846 Failure* failure = Failure::InternalError(); | 1846 Failure* failure = Failure::InternalError(); |
| 1847 bool success = GenerateLoadCallback(object, holder, rax, rcx, rbx, rdx, rdi, | 1847 bool success = GenerateLoadCallback(object, holder, rax, rcx, rdx, rbx, rdi, |
| 1848 callback, name, &miss, &failure); | 1848 callback, name, &miss, &failure); |
| 1849 if (!success) { | 1849 if (!success) { |
| 1850 miss.Unuse(); | 1850 miss.Unuse(); |
| 1851 return failure; | 1851 return failure; |
| 1852 } | 1852 } |
| 1853 | 1853 |
| 1854 __ bind(&miss); | 1854 __ bind(&miss); |
| 1855 GenerateLoadMiss(masm(), Code::LOAD_IC); | 1855 GenerateLoadMiss(masm(), Code::LOAD_IC); |
| 1856 | 1856 |
| 1857 // Return the generated code. | 1857 // Return the generated code. |
| (...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2578 // Check that the receiver isn't a smi. | 2578 // Check that the receiver isn't a smi. |
| 2579 __ JumpIfSmi(receiver, miss); | 2579 __ JumpIfSmi(receiver, miss); |
| 2580 | 2580 |
| 2581 // Check that the maps haven't changed. | 2581 // Check that the maps haven't changed. |
| 2582 Register reg = | 2582 Register reg = |
| 2583 CheckPrototypes(object, receiver, holder, scratch1, | 2583 CheckPrototypes(object, receiver, holder, scratch1, |
| 2584 scratch2, scratch3, name, miss); | 2584 scratch2, scratch3, name, miss); |
| 2585 | 2585 |
| 2586 Handle<AccessorInfo> callback_handle(callback); | 2586 Handle<AccessorInfo> callback_handle(callback); |
| 2587 | 2587 |
| 2588 __ EnterInternalFrame(); | 2588 // Insert additional parameters into the stack frame above return address. |
| 2589 // Push the stack address where the list of arguments ends. | 2589 ASSERT(!scratch2.is(reg)); |
| 2590 __ movq(scratch2, rsp); | 2590 __ pop(scratch2); // Get return address to place it below. |
| 2591 __ subq(scratch2, Immediate(2 * kPointerSize)); | 2591 |
| 2592 __ push(scratch2); | |
| 2593 __ push(receiver); // receiver | 2592 __ push(receiver); // receiver |
| 2593 ASSERT(!scratch3.is(reg)); |
| 2594 __ movq(scratch3, rsp); |
| 2594 __ push(reg); // holder | 2595 __ push(reg); // holder |
| 2595 if (Heap::InNewSpace(callback_handle->data())) { | 2596 if (Heap::InNewSpace(callback_handle->data())) { |
| 2596 __ Move(scratch2, callback_handle); | 2597 __ Move(scratch1, callback_handle); |
| 2597 __ push(FieldOperand(scratch2, AccessorInfo::kDataOffset)); // data | 2598 __ push(FieldOperand(scratch1, AccessorInfo::kDataOffset)); // data |
| 2598 } else { | 2599 } else { |
| 2599 __ Push(Handle<Object>(callback_handle->data())); | 2600 __ Push(Handle<Object>(callback_handle->data())); |
| 2600 } | 2601 } |
| 2602 __ push(scratch3); |
| 2601 __ push(name_reg); // name | 2603 __ push(name_reg); // name |
| 2602 // Save a pointer to where we pushed the arguments pointer. | 2604 // Save a pointer to where we pushed the arguments pointer. |
| 2603 // This will be passed as the const AccessorInfo& to the C++ callback. | 2605 // This will be passed as the const AccessorInfo& to the C++ callback. |
| 2604 | 2606 |
| 2605 #ifdef _WIN64 | 2607 #ifdef _WIN64 |
| 2606 // Win64 uses first register--rcx--for returned value. | 2608 // Win64 uses first register--rcx--for returned value. |
| 2607 Register accessor_info_arg = r8; | 2609 Register accessor_info_arg = r8; |
| 2608 Register name_arg = rdx; | 2610 Register name_arg = rdx; |
| 2609 #else | 2611 #else |
| 2610 Register accessor_info_arg = rdx; // temporary, copied to rsi by the stub. | 2612 Register accessor_info_arg = rsi; |
| 2611 Register name_arg = rdi; | 2613 Register name_arg = rdi; |
| 2612 #endif | 2614 #endif |
| 2613 | 2615 |
| 2614 __ movq(accessor_info_arg, rsp); | 2616 ASSERT(!name_arg.is(scratch2)); |
| 2615 __ addq(accessor_info_arg, Immediate(4 * kPointerSize)); | |
| 2616 __ movq(name_arg, rsp); | 2617 __ movq(name_arg, rsp); |
| 2618 __ push(scratch2); // Restore return address. |
| 2617 | 2619 |
| 2618 // Do call through the api. | 2620 // Do call through the api. |
| 2619 ASSERT_EQ(5, ApiGetterEntryStub::kStackSpace); | |
| 2620 Address getter_address = v8::ToCData<Address>(callback->getter()); | 2621 Address getter_address = v8::ToCData<Address>(callback->getter()); |
| 2621 ApiFunction fun(getter_address); | 2622 ApiFunction fun(getter_address); |
| 2622 ApiGetterEntryStub stub(callback_handle, &fun); | 2623 |
| 2623 #ifdef _WIN64 | 2624 // 3 elements array for v8::Agruments::values_, handler for name and pointer |
| 2624 // We need to prepare a slot for result handle on stack and put | 2625 // to the values (it considered as smi in GC). |
| 2625 // a pointer to it into 1st arg register. | 2626 const int kStackSpace = 5; |
| 2626 __ push(Immediate(0)); | 2627 const int kApiArgc = 2; |
| 2627 __ movq(rcx, rsp); | 2628 |
| 2628 #endif | 2629 __ PrepareCallApiFunction(kStackSpace, kApiArgc); |
| 2630 |
| 2631 // The context register (rsi) has been saved in PrepareCallApiFunction and |
| 2632 // could be used to pass arguments. |
| 2633 __ lea(accessor_info_arg, Operand(name_arg, 1 * kPointerSize)); |
| 2634 |
| 2629 // Emitting a stub call may try to allocate (if the code is not | 2635 // Emitting a stub call may try to allocate (if the code is not |
| 2630 // already generated). Do not allow the assembler to perform a | 2636 // already generated). Do not allow the assembler to perform a |
| 2631 // garbage collection but instead return the allocation failure | 2637 // garbage collection but instead return the allocation failure |
| 2632 // object. | 2638 // object. |
| 2633 MaybeObject* result = masm()->TryCallStub(&stub); | 2639 MaybeObject* result = masm()->TryCallApiFunctionAndReturn(&fun); |
| 2634 if (result->IsFailure()) { | 2640 if (result->IsFailure()) { |
| 2635 *failure = Failure::cast(result); | 2641 *failure = Failure::cast(result); |
| 2636 return false; | 2642 return false; |
| 2637 } | 2643 } |
| 2638 #ifdef _WIN64 | |
| 2639 // Discard allocated slot. | |
| 2640 __ addq(rsp, Immediate(kPointerSize)); | |
| 2641 #endif | |
| 2642 __ LeaveInternalFrame(); | |
| 2643 | |
| 2644 __ ret(0); | |
| 2645 | |
| 2646 return true; | 2644 return true; |
| 2647 } | 2645 } |
| 2648 | 2646 |
| 2649 | 2647 |
| 2650 Register StubCompiler::CheckPrototypes(JSObject* object, | 2648 Register StubCompiler::CheckPrototypes(JSObject* object, |
| 2651 Register object_reg, | 2649 Register object_reg, |
| 2652 JSObject* holder, | 2650 JSObject* holder, |
| 2653 Register holder_reg, | 2651 Register holder_reg, |
| 2654 Register scratch1, | 2652 Register scratch1, |
| 2655 Register scratch2, | 2653 Register scratch2, |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2965 // Return the generated code. | 2963 // Return the generated code. |
| 2966 return GetCode(); | 2964 return GetCode(); |
| 2967 } | 2965 } |
| 2968 | 2966 |
| 2969 | 2967 |
| 2970 #undef __ | 2968 #undef __ |
| 2971 | 2969 |
| 2972 } } // namespace v8::internal | 2970 } } // namespace v8::internal |
| 2973 | 2971 |
| 2974 #endif // V8_TARGET_ARCH_X64 | 2972 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |