OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 2689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2700 void LCodeGen::DoApplyArguments(LApplyArguments* instr) { | 2700 void LCodeGen::DoApplyArguments(LApplyArguments* instr) { |
2701 Register receiver = ToRegister(instr->receiver()); | 2701 Register receiver = ToRegister(instr->receiver()); |
2702 Register function = ToRegister(instr->function()); | 2702 Register function = ToRegister(instr->function()); |
2703 Register length = ToRegister(instr->length()); | 2703 Register length = ToRegister(instr->length()); |
2704 Register elements = ToRegister(instr->elements()); | 2704 Register elements = ToRegister(instr->elements()); |
2705 Register scratch = scratch0(); | 2705 Register scratch = scratch0(); |
2706 ASSERT(receiver.is(r0)); // Used for parameter count. | 2706 ASSERT(receiver.is(r0)); // Used for parameter count. |
2707 ASSERT(function.is(r1)); // Required by InvokeFunction. | 2707 ASSERT(function.is(r1)); // Required by InvokeFunction. |
2708 ASSERT(ToRegister(instr->result()).is(r0)); | 2708 ASSERT(ToRegister(instr->result()).is(r0)); |
2709 | 2709 |
| 2710 // TODO(1412): This is not correct if the called function is a |
| 2711 // strict mode function or a native. |
| 2712 // |
2710 // If the receiver is null or undefined, we have to pass the global object | 2713 // If the receiver is null or undefined, we have to pass the global object |
2711 // as a receiver. | 2714 // as a receiver. |
2712 Label global_object, receiver_ok; | 2715 Label global_object, receiver_ok; |
2713 __ LoadRoot(scratch, Heap::kNullValueRootIndex); | 2716 __ LoadRoot(scratch, Heap::kNullValueRootIndex); |
2714 __ cmp(receiver, scratch); | 2717 __ cmp(receiver, scratch); |
2715 __ b(eq, &global_object); | 2718 __ b(eq, &global_object); |
2716 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex); | 2719 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex); |
2717 __ cmp(receiver, scratch); | 2720 __ cmp(receiver, scratch); |
2718 __ b(eq, &global_object); | 2721 __ b(eq, &global_object); |
2719 | 2722 |
2720 // Deoptimize if the receiver is not a JS object. | 2723 // Deoptimize if the receiver is not a JS object. |
2721 __ tst(receiver, Operand(kSmiTagMask)); | 2724 __ tst(receiver, Operand(kSmiTagMask)); |
2722 DeoptimizeIf(eq, instr->environment()); | 2725 DeoptimizeIf(eq, instr->environment()); |
2723 __ CompareObjectType(receiver, scratch, scratch, FIRST_JS_OBJECT_TYPE); | 2726 __ CompareObjectType(receiver, scratch, scratch, FIRST_JS_OBJECT_TYPE); |
2724 DeoptimizeIf(lo, instr->environment()); | 2727 DeoptimizeIf(lo, instr->environment()); |
2725 __ jmp(&receiver_ok); | 2728 __ jmp(&receiver_ok); |
2726 | 2729 |
2727 __ bind(&global_object); | 2730 __ bind(&global_object); |
2728 __ ldr(receiver, GlobalObjectOperand()); | 2731 __ ldr(receiver, GlobalObjectOperand()); |
| 2732 __ ldr(receiver, |
| 2733 FieldMemOperand(receiver, JSGlobalObject::kGlobalReceiverOffset)); |
2729 __ bind(&receiver_ok); | 2734 __ bind(&receiver_ok); |
2730 | 2735 |
2731 // Copy the arguments to this function possibly from the | 2736 // Copy the arguments to this function possibly from the |
2732 // adaptor frame below it. | 2737 // adaptor frame below it. |
2733 const uint32_t kArgumentsLimit = 1 * KB; | 2738 const uint32_t kArgumentsLimit = 1 * KB; |
2734 __ cmp(length, Operand(kArgumentsLimit)); | 2739 __ cmp(length, Operand(kArgumentsLimit)); |
2735 DeoptimizeIf(hi, instr->environment()); | 2740 DeoptimizeIf(hi, instr->environment()); |
2736 | 2741 |
2737 // Push the receiver and use the register to keep the original | 2742 // Push the receiver and use the register to keep the original |
2738 // number of arguments. | 2743 // number of arguments. |
(...skipping 19 matching lines...) Expand all Loading... |
2758 LPointerMap* pointers = instr->pointer_map(); | 2763 LPointerMap* pointers = instr->pointer_map(); |
2759 LEnvironment* env = instr->deoptimization_environment(); | 2764 LEnvironment* env = instr->deoptimization_environment(); |
2760 RecordPosition(pointers->position()); | 2765 RecordPosition(pointers->position()); |
2761 RegisterEnvironmentForDeoptimization(env); | 2766 RegisterEnvironmentForDeoptimization(env); |
2762 SafepointGenerator safepoint_generator(this, | 2767 SafepointGenerator safepoint_generator(this, |
2763 pointers, | 2768 pointers, |
2764 env->deoptimization_index()); | 2769 env->deoptimization_index()); |
2765 // The number of arguments is stored in receiver which is r0, as expected | 2770 // The number of arguments is stored in receiver which is r0, as expected |
2766 // by InvokeFunction. | 2771 // by InvokeFunction. |
2767 v8::internal::ParameterCount actual(receiver); | 2772 v8::internal::ParameterCount actual(receiver); |
2768 __ InvokeFunction(function, actual, CALL_FUNCTION, safepoint_generator); | 2773 __ InvokeFunction(function, actual, CALL_FUNCTION, |
| 2774 safepoint_generator, CALL_AS_METHOD); |
2769 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 2775 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
2770 } | 2776 } |
2771 | 2777 |
2772 | 2778 |
2773 void LCodeGen::DoPushArgument(LPushArgument* instr) { | 2779 void LCodeGen::DoPushArgument(LPushArgument* instr) { |
2774 LOperand* argument = instr->InputAt(0); | 2780 LOperand* argument = instr->InputAt(0); |
2775 if (argument->IsDoubleRegister() || argument->IsDoubleStackSlot()) { | 2781 if (argument->IsDoubleRegister() || argument->IsDoubleStackSlot()) { |
2776 Abort("DoPushArgument not implemented for double type."); | 2782 Abort("DoPushArgument not implemented for double type."); |
2777 } else { | 2783 } else { |
2778 Register argument_reg = EmitLoadRegister(argument, ip); | 2784 Register argument_reg = EmitLoadRegister(argument, ip); |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3206 void LCodeGen::DoInvokeFunction(LInvokeFunction* instr) { | 3212 void LCodeGen::DoInvokeFunction(LInvokeFunction* instr) { |
3207 ASSERT(ToRegister(instr->function()).is(r1)); | 3213 ASSERT(ToRegister(instr->function()).is(r1)); |
3208 ASSERT(instr->HasPointerMap()); | 3214 ASSERT(instr->HasPointerMap()); |
3209 ASSERT(instr->HasDeoptimizationEnvironment()); | 3215 ASSERT(instr->HasDeoptimizationEnvironment()); |
3210 LPointerMap* pointers = instr->pointer_map(); | 3216 LPointerMap* pointers = instr->pointer_map(); |
3211 LEnvironment* env = instr->deoptimization_environment(); | 3217 LEnvironment* env = instr->deoptimization_environment(); |
3212 RecordPosition(pointers->position()); | 3218 RecordPosition(pointers->position()); |
3213 RegisterEnvironmentForDeoptimization(env); | 3219 RegisterEnvironmentForDeoptimization(env); |
3214 SafepointGenerator generator(this, pointers, env->deoptimization_index()); | 3220 SafepointGenerator generator(this, pointers, env->deoptimization_index()); |
3215 ParameterCount count(instr->arity()); | 3221 ParameterCount count(instr->arity()); |
3216 __ InvokeFunction(r1, count, CALL_FUNCTION, generator); | 3222 __ InvokeFunction(r1, count, CALL_FUNCTION, generator, CALL_AS_METHOD); |
3217 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 3223 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
3218 } | 3224 } |
3219 | 3225 |
3220 | 3226 |
3221 void LCodeGen::DoCallKeyed(LCallKeyed* instr) { | 3227 void LCodeGen::DoCallKeyed(LCallKeyed* instr) { |
3222 ASSERT(ToRegister(instr->result()).is(r0)); | 3228 ASSERT(ToRegister(instr->result()).is(r0)); |
3223 | 3229 |
3224 int arity = instr->arity(); | 3230 int arity = instr->arity(); |
3225 Handle<Code> ic = | 3231 Handle<Code> ic = |
3226 isolate()->stub_cache()->ComputeKeyedCallInitialize(arity, NOT_IN_LOOP); | 3232 isolate()->stub_cache()->ComputeKeyedCallInitialize(arity, NOT_IN_LOOP); |
(...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4517 ASSERT(osr_pc_offset_ == -1); | 4523 ASSERT(osr_pc_offset_ == -1); |
4518 osr_pc_offset_ = masm()->pc_offset(); | 4524 osr_pc_offset_ = masm()->pc_offset(); |
4519 } | 4525 } |
4520 | 4526 |
4521 | 4527 |
4522 | 4528 |
4523 | 4529 |
4524 #undef __ | 4530 #undef __ |
4525 | 4531 |
4526 } } // namespace v8::internal | 4532 } } // namespace v8::internal |
OLD | NEW |