| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 // fp: Caller's frame pointer. | 147 // fp: Caller's frame pointer. |
| 148 // lr: Caller's pc. | 148 // lr: Caller's pc. |
| 149 | 149 |
| 150 // Classic mode functions and builtins need to replace the receiver with the | 150 // Classic mode functions and builtins need to replace the receiver with the |
| 151 // global proxy when called as functions (without an explicit receiver | 151 // global proxy when called as functions (without an explicit receiver |
| 152 // object). | 152 // object). |
| 153 if (info_->this_has_uses() && | 153 if (info_->this_has_uses() && |
| 154 info_->is_classic_mode() && | 154 info_->is_classic_mode() && |
| 155 !info_->is_native()) { | 155 !info_->is_native()) { |
| 156 Label ok; | 156 Label ok; |
| 157 __ cmp(r5, Operand::Zero()); | |
| 158 __ b(eq, &ok); | |
| 159 | |
| 160 int receiver_offset = info_->scope()->num_parameters() * kPointerSize; | 157 int receiver_offset = info_->scope()->num_parameters() * kPointerSize; |
| 161 __ ldr(r2, MemOperand(sp, receiver_offset)); | 158 __ ldr(r2, MemOperand(sp, receiver_offset)); |
| 162 __ CompareRoot(r2, Heap::kUndefinedValueRootIndex); | 159 __ CompareRoot(r2, Heap::kUndefinedValueRootIndex); |
| 163 __ b(ne, &ok); | 160 __ b(ne, &ok); |
| 164 | 161 |
| 165 __ ldr(r2, GlobalObjectOperand()); | 162 __ ldr(r2, GlobalObjectOperand()); |
| 166 __ ldr(r2, FieldMemOperand(r2, GlobalObject::kGlobalReceiverOffset)); | 163 __ ldr(r2, FieldMemOperand(r2, GlobalObject::kGlobalReceiverOffset)); |
| 167 | 164 |
| 168 __ str(r2, MemOperand(sp, receiver_offset)); | 165 __ str(r2, MemOperand(sp, receiver_offset)); |
| 169 | 166 |
| (...skipping 3391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3561 __ b(ne, &loop); | 3558 __ b(ne, &loop); |
| 3562 | 3559 |
| 3563 __ bind(&invoke); | 3560 __ bind(&invoke); |
| 3564 ASSERT(instr->HasPointerMap()); | 3561 ASSERT(instr->HasPointerMap()); |
| 3565 LPointerMap* pointers = instr->pointer_map(); | 3562 LPointerMap* pointers = instr->pointer_map(); |
| 3566 SafepointGenerator safepoint_generator( | 3563 SafepointGenerator safepoint_generator( |
| 3567 this, pointers, Safepoint::kLazyDeopt); | 3564 this, pointers, Safepoint::kLazyDeopt); |
| 3568 // The number of arguments is stored in receiver which is r0, as expected | 3565 // The number of arguments is stored in receiver which is r0, as expected |
| 3569 // by InvokeFunction. | 3566 // by InvokeFunction. |
| 3570 ParameterCount actual(receiver); | 3567 ParameterCount actual(receiver); |
| 3571 __ InvokeFunction(function, actual, CALL_FUNCTION, | 3568 __ InvokeFunction(function, actual, CALL_FUNCTION, safepoint_generator); |
| 3572 safepoint_generator, CALL_AS_FUNCTION); | |
| 3573 } | 3569 } |
| 3574 | 3570 |
| 3575 | 3571 |
| 3576 void LCodeGen::DoPushArgument(LPushArgument* instr) { | 3572 void LCodeGen::DoPushArgument(LPushArgument* instr) { |
| 3577 LOperand* argument = instr->value(); | 3573 LOperand* argument = instr->value(); |
| 3578 if (argument->IsDoubleRegister() || argument->IsDoubleStackSlot()) { | 3574 if (argument->IsDoubleRegister() || argument->IsDoubleStackSlot()) { |
| 3579 Abort(kDoPushArgumentNotImplementedForDoubleType); | 3575 Abort(kDoPushArgumentNotImplementedForDoubleType); |
| 3580 } else { | 3576 } else { |
| 3581 Register argument_reg = EmitLoadRegister(argument, ip); | 3577 Register argument_reg = EmitLoadRegister(argument, ip); |
| 3582 __ push(argument_reg); | 3578 __ push(argument_reg); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3637 Register global = ToRegister(instr->global_object()); | 3633 Register global = ToRegister(instr->global_object()); |
| 3638 Register result = ToRegister(instr->result()); | 3634 Register result = ToRegister(instr->result()); |
| 3639 __ ldr(result, FieldMemOperand(global, GlobalObject::kGlobalReceiverOffset)); | 3635 __ ldr(result, FieldMemOperand(global, GlobalObject::kGlobalReceiverOffset)); |
| 3640 } | 3636 } |
| 3641 | 3637 |
| 3642 | 3638 |
| 3643 void LCodeGen::CallKnownFunction(Handle<JSFunction> function, | 3639 void LCodeGen::CallKnownFunction(Handle<JSFunction> function, |
| 3644 int formal_parameter_count, | 3640 int formal_parameter_count, |
| 3645 int arity, | 3641 int arity, |
| 3646 LInstruction* instr, | 3642 LInstruction* instr, |
| 3647 CallKind call_kind, | |
| 3648 R1State r1_state) { | 3643 R1State r1_state) { |
| 3649 bool dont_adapt_arguments = | 3644 bool dont_adapt_arguments = |
| 3650 formal_parameter_count == SharedFunctionInfo::kDontAdaptArgumentsSentinel; | 3645 formal_parameter_count == SharedFunctionInfo::kDontAdaptArgumentsSentinel; |
| 3651 bool can_invoke_directly = | 3646 bool can_invoke_directly = |
| 3652 dont_adapt_arguments || formal_parameter_count == arity; | 3647 dont_adapt_arguments || formal_parameter_count == arity; |
| 3653 | 3648 |
| 3654 LPointerMap* pointers = instr->pointer_map(); | 3649 LPointerMap* pointers = instr->pointer_map(); |
| 3655 | 3650 |
| 3656 if (can_invoke_directly) { | 3651 if (can_invoke_directly) { |
| 3657 if (r1_state == R1_UNINITIALIZED) { | 3652 if (r1_state == R1_UNINITIALIZED) { |
| 3658 __ Move(r1, function); | 3653 __ Move(r1, function); |
| 3659 } | 3654 } |
| 3660 | 3655 |
| 3661 // Change context. | 3656 // Change context. |
| 3662 __ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); | 3657 __ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); |
| 3663 | 3658 |
| 3664 // Set r0 to arguments count if adaption is not needed. Assumes that r0 | 3659 // Set r0 to arguments count if adaption is not needed. Assumes that r0 |
| 3665 // is available to write to at this point. | 3660 // is available to write to at this point. |
| 3666 if (dont_adapt_arguments) { | 3661 if (dont_adapt_arguments) { |
| 3667 __ mov(r0, Operand(arity)); | 3662 __ mov(r0, Operand(arity)); |
| 3668 } | 3663 } |
| 3669 | 3664 |
| 3670 // Invoke function. | 3665 // Invoke function. |
| 3671 __ SetCallKind(r5, call_kind); | |
| 3672 __ ldr(ip, FieldMemOperand(r1, JSFunction::kCodeEntryOffset)); | 3666 __ ldr(ip, FieldMemOperand(r1, JSFunction::kCodeEntryOffset)); |
| 3673 __ Call(ip); | 3667 __ Call(ip); |
| 3674 | 3668 |
| 3675 // Set up deoptimization. | 3669 // Set up deoptimization. |
| 3676 RecordSafepointWithLazyDeopt(instr, RECORD_SIMPLE_SAFEPOINT); | 3670 RecordSafepointWithLazyDeopt(instr, RECORD_SIMPLE_SAFEPOINT); |
| 3677 } else { | 3671 } else { |
| 3678 SafepointGenerator generator(this, pointers, Safepoint::kLazyDeopt); | 3672 SafepointGenerator generator(this, pointers, Safepoint::kLazyDeopt); |
| 3679 ParameterCount count(arity); | 3673 ParameterCount count(arity); |
| 3680 ParameterCount expected(formal_parameter_count); | 3674 ParameterCount expected(formal_parameter_count); |
| 3681 __ InvokeFunction( | 3675 __ InvokeFunction(function, expected, count, CALL_FUNCTION, generator); |
| 3682 function, expected, count, CALL_FUNCTION, generator, call_kind); | |
| 3683 } | 3676 } |
| 3684 } | 3677 } |
| 3685 | 3678 |
| 3686 | 3679 |
| 3687 void LCodeGen::DoCallConstantFunction(LCallConstantFunction* instr) { | 3680 void LCodeGen::DoCallConstantFunction(LCallConstantFunction* instr) { |
| 3688 ASSERT(ToRegister(instr->result()).is(r0)); | 3681 ASSERT(ToRegister(instr->result()).is(r0)); |
| 3689 CallKnownFunction(instr->hydrogen()->function(), | 3682 CallKnownFunction(instr->hydrogen()->function(), |
| 3690 instr->hydrogen()->formal_parameter_count(), | 3683 instr->hydrogen()->formal_parameter_count(), |
| 3691 instr->arity(), | 3684 instr->arity(), |
| 3692 instr, | 3685 instr, |
| 3693 CALL_AS_FUNCTION, | |
| 3694 R1_UNINITIALIZED); | 3686 R1_UNINITIALIZED); |
| 3695 } | 3687 } |
| 3696 | 3688 |
| 3697 | 3689 |
| 3698 void LCodeGen::DoDeferredMathAbsTaggedHeapNumber(LMathAbs* instr) { | 3690 void LCodeGen::DoDeferredMathAbsTaggedHeapNumber(LMathAbs* instr) { |
| 3699 ASSERT(instr->context() != NULL); | 3691 ASSERT(instr->context() != NULL); |
| 3700 ASSERT(ToRegister(instr->context()).is(cp)); | 3692 ASSERT(ToRegister(instr->context()).is(cp)); |
| 3701 Register input = ToRegister(instr->value()); | 3693 Register input = ToRegister(instr->value()); |
| 3702 Register result = ToRegister(instr->result()); | 3694 Register result = ToRegister(instr->result()); |
| 3703 Register scratch = scratch0(); | 3695 Register scratch = scratch0(); |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3961 void LCodeGen::DoInvokeFunction(LInvokeFunction* instr) { | 3953 void LCodeGen::DoInvokeFunction(LInvokeFunction* instr) { |
| 3962 ASSERT(ToRegister(instr->context()).is(cp)); | 3954 ASSERT(ToRegister(instr->context()).is(cp)); |
| 3963 ASSERT(ToRegister(instr->function()).is(r1)); | 3955 ASSERT(ToRegister(instr->function()).is(r1)); |
| 3964 ASSERT(instr->HasPointerMap()); | 3956 ASSERT(instr->HasPointerMap()); |
| 3965 | 3957 |
| 3966 Handle<JSFunction> known_function = instr->hydrogen()->known_function(); | 3958 Handle<JSFunction> known_function = instr->hydrogen()->known_function(); |
| 3967 if (known_function.is_null()) { | 3959 if (known_function.is_null()) { |
| 3968 LPointerMap* pointers = instr->pointer_map(); | 3960 LPointerMap* pointers = instr->pointer_map(); |
| 3969 SafepointGenerator generator(this, pointers, Safepoint::kLazyDeopt); | 3961 SafepointGenerator generator(this, pointers, Safepoint::kLazyDeopt); |
| 3970 ParameterCount count(instr->arity()); | 3962 ParameterCount count(instr->arity()); |
| 3971 __ InvokeFunction(r1, count, CALL_FUNCTION, generator, CALL_AS_FUNCTION); | 3963 __ InvokeFunction(r1, count, CALL_FUNCTION, generator); |
| 3972 } else { | 3964 } else { |
| 3973 CallKnownFunction(known_function, | 3965 CallKnownFunction(known_function, |
| 3974 instr->hydrogen()->formal_parameter_count(), | 3966 instr->hydrogen()->formal_parameter_count(), |
| 3975 instr->arity(), | 3967 instr->arity(), |
| 3976 instr, | 3968 instr, |
| 3977 CALL_AS_FUNCTION, | |
| 3978 R1_CONTAINS_TARGET); | 3969 R1_CONTAINS_TARGET); |
| 3979 } | 3970 } |
| 3980 } | 3971 } |
| 3981 | 3972 |
| 3982 | 3973 |
| 3983 void LCodeGen::DoCallKeyed(LCallKeyed* instr) { | 3974 void LCodeGen::DoCallKeyed(LCallKeyed* instr) { |
| 3984 ASSERT(ToRegister(instr->context()).is(cp)); | 3975 ASSERT(ToRegister(instr->context()).is(cp)); |
| 3985 ASSERT(ToRegister(instr->result()).is(r0)); | 3976 ASSERT(ToRegister(instr->result()).is(r0)); |
| 3986 | 3977 |
| 3987 int arity = instr->arity(); | 3978 int arity = instr->arity(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4030 CallCode(ic, RelocInfo::CODE_TARGET, instr, NEVER_INLINE_TARGET_ADDRESS); | 4021 CallCode(ic, RelocInfo::CODE_TARGET, instr, NEVER_INLINE_TARGET_ADDRESS); |
| 4031 } | 4022 } |
| 4032 | 4023 |
| 4033 | 4024 |
| 4034 void LCodeGen::DoCallKnownGlobal(LCallKnownGlobal* instr) { | 4025 void LCodeGen::DoCallKnownGlobal(LCallKnownGlobal* instr) { |
| 4035 ASSERT(ToRegister(instr->result()).is(r0)); | 4026 ASSERT(ToRegister(instr->result()).is(r0)); |
| 4036 CallKnownFunction(instr->hydrogen()->target(), | 4027 CallKnownFunction(instr->hydrogen()->target(), |
| 4037 instr->hydrogen()->formal_parameter_count(), | 4028 instr->hydrogen()->formal_parameter_count(), |
| 4038 instr->arity(), | 4029 instr->arity(), |
| 4039 instr, | 4030 instr, |
| 4040 CALL_AS_FUNCTION, | |
| 4041 R1_UNINITIALIZED); | 4031 R1_UNINITIALIZED); |
| 4042 } | 4032 } |
| 4043 | 4033 |
| 4044 | 4034 |
| 4045 void LCodeGen::DoCallNew(LCallNew* instr) { | 4035 void LCodeGen::DoCallNew(LCallNew* instr) { |
| 4046 ASSERT(ToRegister(instr->context()).is(cp)); | 4036 ASSERT(ToRegister(instr->context()).is(cp)); |
| 4047 ASSERT(ToRegister(instr->constructor()).is(r1)); | 4037 ASSERT(ToRegister(instr->constructor()).is(r1)); |
| 4048 ASSERT(ToRegister(instr->result()).is(r0)); | 4038 ASSERT(ToRegister(instr->result()).is(r0)); |
| 4049 | 4039 |
| 4050 __ mov(r0, Operand(instr->arity())); | 4040 __ mov(r0, Operand(instr->arity())); |
| (...skipping 1773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5824 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index)); | 5814 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index)); |
| 5825 __ ldr(result, FieldMemOperand(scratch, | 5815 __ ldr(result, FieldMemOperand(scratch, |
| 5826 FixedArray::kHeaderSize - kPointerSize)); | 5816 FixedArray::kHeaderSize - kPointerSize)); |
| 5827 __ bind(&done); | 5817 __ bind(&done); |
| 5828 } | 5818 } |
| 5829 | 5819 |
| 5830 | 5820 |
| 5831 #undef __ | 5821 #undef __ |
| 5832 | 5822 |
| 5833 } } // namespace v8::internal | 5823 } } // namespace v8::internal |
| OLD | NEW |