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 2584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2595 void LCodeGen::DoApplyArguments(LApplyArguments* instr) { | 2595 void LCodeGen::DoApplyArguments(LApplyArguments* instr) { |
2596 Register receiver = ToRegister(instr->receiver()); | 2596 Register receiver = ToRegister(instr->receiver()); |
2597 Register function = ToRegister(instr->function()); | 2597 Register function = ToRegister(instr->function()); |
2598 Register length = ToRegister(instr->length()); | 2598 Register length = ToRegister(instr->length()); |
2599 Register elements = ToRegister(instr->elements()); | 2599 Register elements = ToRegister(instr->elements()); |
2600 Register scratch = ToRegister(instr->TempAt(0)); | 2600 Register scratch = ToRegister(instr->TempAt(0)); |
2601 ASSERT(receiver.is(eax)); // Used for parameter count. | 2601 ASSERT(receiver.is(eax)); // Used for parameter count. |
2602 ASSERT(function.is(edi)); // Required by InvokeFunction. | 2602 ASSERT(function.is(edi)); // Required by InvokeFunction. |
2603 ASSERT(ToRegister(instr->result()).is(eax)); | 2603 ASSERT(ToRegister(instr->result()).is(eax)); |
2604 | 2604 |
| 2605 // TODO(1412): This is not correct if the called function is a |
| 2606 // strict mode function or a native. |
| 2607 // |
2605 // If the receiver is null or undefined, we have to pass the global object | 2608 // If the receiver is null or undefined, we have to pass the global object |
2606 // as a receiver. | 2609 // as a receiver. |
2607 Label global_object, receiver_ok; | 2610 Label global_object, receiver_ok; |
2608 __ cmp(receiver, factory()->null_value()); | 2611 __ cmp(receiver, factory()->null_value()); |
2609 __ j(equal, &global_object, Label::kNear); | 2612 __ j(equal, &global_object, Label::kNear); |
2610 __ cmp(receiver, factory()->undefined_value()); | 2613 __ cmp(receiver, factory()->undefined_value()); |
2611 __ j(equal, &global_object, Label::kNear); | 2614 __ j(equal, &global_object, Label::kNear); |
2612 | 2615 |
2613 // The receiver should be a JS object. | 2616 // The receiver should be a JS object. |
2614 __ test(receiver, Immediate(kSmiTagMask)); | 2617 __ test(receiver, Immediate(kSmiTagMask)); |
2615 DeoptimizeIf(equal, instr->environment()); | 2618 DeoptimizeIf(equal, instr->environment()); |
2616 __ CmpObjectType(receiver, FIRST_JS_OBJECT_TYPE, scratch); | 2619 __ CmpObjectType(receiver, FIRST_JS_OBJECT_TYPE, scratch); |
2617 DeoptimizeIf(below, instr->environment()); | 2620 DeoptimizeIf(below, instr->environment()); |
2618 __ jmp(&receiver_ok, Label::kNear); | 2621 __ jmp(&receiver_ok, Label::kNear); |
2619 | 2622 |
2620 __ bind(&global_object); | 2623 __ bind(&global_object); |
2621 // TODO(kmillikin): We have a hydrogen value for the global object. See | 2624 // TODO(kmillikin): We have a hydrogen value for the global object. See |
2622 // if it's better to use it than to explicitly fetch it from the context | 2625 // if it's better to use it than to explicitly fetch it from the context |
2623 // here. | 2626 // here. |
2624 __ mov(receiver, Operand(ebp, StandardFrameConstants::kContextOffset)); | 2627 __ mov(receiver, Operand(ebp, StandardFrameConstants::kContextOffset)); |
2625 __ mov(receiver, ContextOperand(receiver, Context::GLOBAL_INDEX)); | 2628 __ mov(receiver, ContextOperand(receiver, Context::GLOBAL_INDEX)); |
| 2629 __ mov(receiver, |
| 2630 FieldOperand(receiver, JSGlobalObject::kGlobalReceiverOffset)); |
2626 __ bind(&receiver_ok); | 2631 __ bind(&receiver_ok); |
2627 | 2632 |
2628 // Copy the arguments to this function possibly from the | 2633 // Copy the arguments to this function possibly from the |
2629 // adaptor frame below it. | 2634 // adaptor frame below it. |
2630 const uint32_t kArgumentsLimit = 1 * KB; | 2635 const uint32_t kArgumentsLimit = 1 * KB; |
2631 __ cmp(length, kArgumentsLimit); | 2636 __ cmp(length, kArgumentsLimit); |
2632 DeoptimizeIf(above, instr->environment()); | 2637 DeoptimizeIf(above, instr->environment()); |
2633 | 2638 |
2634 __ push(receiver); | 2639 __ push(receiver); |
2635 __ mov(receiver, length); | 2640 __ mov(receiver, length); |
(...skipping 13 matching lines...) Expand all Loading... |
2649 __ bind(&invoke); | 2654 __ bind(&invoke); |
2650 ASSERT(instr->HasPointerMap() && instr->HasDeoptimizationEnvironment()); | 2655 ASSERT(instr->HasPointerMap() && instr->HasDeoptimizationEnvironment()); |
2651 LPointerMap* pointers = instr->pointer_map(); | 2656 LPointerMap* pointers = instr->pointer_map(); |
2652 LEnvironment* env = instr->deoptimization_environment(); | 2657 LEnvironment* env = instr->deoptimization_environment(); |
2653 RecordPosition(pointers->position()); | 2658 RecordPosition(pointers->position()); |
2654 RegisterEnvironmentForDeoptimization(env); | 2659 RegisterEnvironmentForDeoptimization(env); |
2655 SafepointGenerator safepoint_generator(this, | 2660 SafepointGenerator safepoint_generator(this, |
2656 pointers, | 2661 pointers, |
2657 env->deoptimization_index()); | 2662 env->deoptimization_index()); |
2658 ParameterCount actual(eax); | 2663 ParameterCount actual(eax); |
2659 __ InvokeFunction(function, actual, CALL_FUNCTION, safepoint_generator); | 2664 __ InvokeFunction(function, actual, CALL_FUNCTION, |
| 2665 safepoint_generator, CALL_AS_METHOD); |
2660 } | 2666 } |
2661 | 2667 |
2662 | 2668 |
2663 void LCodeGen::DoPushArgument(LPushArgument* instr) { | 2669 void LCodeGen::DoPushArgument(LPushArgument* instr) { |
2664 LOperand* argument = instr->InputAt(0); | 2670 LOperand* argument = instr->InputAt(0); |
2665 if (argument->IsConstantOperand()) { | 2671 if (argument->IsConstantOperand()) { |
2666 __ push(ToImmediate(argument)); | 2672 __ push(ToImmediate(argument)); |
2667 } else { | 2673 } else { |
2668 __ push(ToOperand(argument)); | 2674 __ push(ToOperand(argument)); |
2669 } | 2675 } |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3076 ASSERT(ToRegister(instr->context()).is(esi)); | 3082 ASSERT(ToRegister(instr->context()).is(esi)); |
3077 ASSERT(ToRegister(instr->function()).is(edi)); | 3083 ASSERT(ToRegister(instr->function()).is(edi)); |
3078 ASSERT(instr->HasPointerMap()); | 3084 ASSERT(instr->HasPointerMap()); |
3079 ASSERT(instr->HasDeoptimizationEnvironment()); | 3085 ASSERT(instr->HasDeoptimizationEnvironment()); |
3080 LPointerMap* pointers = instr->pointer_map(); | 3086 LPointerMap* pointers = instr->pointer_map(); |
3081 LEnvironment* env = instr->deoptimization_environment(); | 3087 LEnvironment* env = instr->deoptimization_environment(); |
3082 RecordPosition(pointers->position()); | 3088 RecordPosition(pointers->position()); |
3083 RegisterEnvironmentForDeoptimization(env); | 3089 RegisterEnvironmentForDeoptimization(env); |
3084 SafepointGenerator generator(this, pointers, env->deoptimization_index()); | 3090 SafepointGenerator generator(this, pointers, env->deoptimization_index()); |
3085 ParameterCount count(instr->arity()); | 3091 ParameterCount count(instr->arity()); |
3086 __ InvokeFunction(edi, count, CALL_FUNCTION, generator); | 3092 __ InvokeFunction(edi, count, CALL_FUNCTION, generator, CALL_AS_METHOD); |
3087 } | 3093 } |
3088 | 3094 |
3089 | 3095 |
3090 void LCodeGen::DoCallKeyed(LCallKeyed* instr) { | 3096 void LCodeGen::DoCallKeyed(LCallKeyed* instr) { |
3091 ASSERT(ToRegister(instr->context()).is(esi)); | 3097 ASSERT(ToRegister(instr->context()).is(esi)); |
3092 ASSERT(ToRegister(instr->key()).is(ecx)); | 3098 ASSERT(ToRegister(instr->key()).is(ecx)); |
3093 ASSERT(ToRegister(instr->result()).is(eax)); | 3099 ASSERT(ToRegister(instr->result()).is(eax)); |
3094 | 3100 |
3095 int arity = instr->arity(); | 3101 int arity = instr->arity(); |
3096 Handle<Code> ic = isolate()->stub_cache()-> | 3102 Handle<Code> ic = isolate()->stub_cache()-> |
(...skipping 1351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4448 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 4454 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
4449 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); | 4455 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); |
4450 } | 4456 } |
4451 | 4457 |
4452 | 4458 |
4453 #undef __ | 4459 #undef __ |
4454 | 4460 |
4455 } } // namespace v8::internal | 4461 } } // namespace v8::internal |
4456 | 4462 |
4457 #endif // V8_TARGET_ARCH_IA32 | 4463 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |