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 5744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5755 // In a call to eval, we first call %ResolvePossiblyDirectEval to | 5755 // In a call to eval, we first call %ResolvePossiblyDirectEval to |
5756 // resolve the function we need to call and the receiver of the | 5756 // resolve the function we need to call and the receiver of the |
5757 // call. Then we call the resolved function using the given | 5757 // call. Then we call the resolved function using the given |
5758 // arguments. | 5758 // arguments. |
5759 | 5759 |
5760 // Prepare the stack for the call to the resolved function. | 5760 // Prepare the stack for the call to the resolved function. |
5761 Load(function); | 5761 Load(function); |
5762 | 5762 |
5763 // Allocate a frame slot for the receiver. | 5763 // Allocate a frame slot for the receiver. |
5764 frame_->Push(Factory::undefined_value()); | 5764 frame_->Push(Factory::undefined_value()); |
| 5765 |
| 5766 // Load the arguments. |
5765 int arg_count = args->length(); | 5767 int arg_count = args->length(); |
5766 for (int i = 0; i < arg_count; i++) { | 5768 for (int i = 0; i < arg_count; i++) { |
5767 Load(args->at(i)); | 5769 Load(args->at(i)); |
5768 frame_->SpillTop(); | 5770 frame_->SpillTop(); |
5769 } | 5771 } |
5770 | 5772 |
5771 // Prepare the stack for the call to ResolvePossiblyDirectEval. | 5773 // Result to hold the result of the function resolution and the |
| 5774 // final result of the eval call. |
| 5775 Result result; |
| 5776 |
| 5777 // If we know that eval can only be shadowed by eval-introduced |
| 5778 // variables we attempt to load the global eval function directly |
| 5779 // in generated code. If we succeed, there is no need to perform a |
| 5780 // context lookup in the runtime system. |
| 5781 JumpTarget done; |
| 5782 if (var->slot() != NULL && var->mode() == Variable::DYNAMIC_GLOBAL) { |
| 5783 ASSERT(var->slot()->type() == Slot::LOOKUP); |
| 5784 JumpTarget slow; |
| 5785 // Prepare the stack for the call to |
| 5786 // ResolvePossiblyDirectEvalNoLookup by pushing the loaded |
| 5787 // function, the first argument to the eval call and the |
| 5788 // receiver. |
| 5789 Result fun = LoadFromGlobalSlotCheckExtensions(var->slot(), |
| 5790 NOT_INSIDE_TYPEOF, |
| 5791 &slow); |
| 5792 frame_->Push(&fun); |
| 5793 if (arg_count > 0) { |
| 5794 frame_->PushElementAt(arg_count); |
| 5795 } else { |
| 5796 frame_->Push(Factory::undefined_value()); |
| 5797 } |
| 5798 frame_->PushParameterAt(-1); |
| 5799 |
| 5800 // Resolve the call. |
| 5801 result = |
| 5802 frame_->CallRuntime(Runtime::kResolvePossiblyDirectEvalNoLookup, 3); |
| 5803 |
| 5804 done.Jump(&result); |
| 5805 slow.Bind(); |
| 5806 } |
| 5807 |
| 5808 // Prepare the stack for the call to ResolvePossiblyDirectEval by |
| 5809 // pushing the loaded function, the first argument to the eval |
| 5810 // call and the receiver. |
5772 frame_->PushElementAt(arg_count + 1); | 5811 frame_->PushElementAt(arg_count + 1); |
5773 if (arg_count > 0) { | 5812 if (arg_count > 0) { |
5774 frame_->PushElementAt(arg_count); | 5813 frame_->PushElementAt(arg_count); |
5775 } else { | 5814 } else { |
5776 frame_->Push(Factory::undefined_value()); | 5815 frame_->Push(Factory::undefined_value()); |
5777 } | 5816 } |
5778 | |
5779 // Push the receiver. | |
5780 frame_->PushParameterAt(-1); | 5817 frame_->PushParameterAt(-1); |
5781 | 5818 |
5782 // Resolve the call. | 5819 // Resolve the call. |
5783 Result result = | 5820 result = frame_->CallRuntime(Runtime::kResolvePossiblyDirectEval, 3); |
5784 frame_->CallRuntime(Runtime::kResolvePossiblyDirectEval, 3); | 5821 |
| 5822 // If we generated fast-case code bind the jump-target where fast |
| 5823 // and slow case merge. |
| 5824 if (done.is_linked()) done.Bind(&result); |
5785 | 5825 |
5786 // The runtime call returns a pair of values in eax (function) and | 5826 // The runtime call returns a pair of values in eax (function) and |
5787 // edx (receiver). Touch up the stack with the right values. | 5827 // edx (receiver). Touch up the stack with the right values. |
5788 Result receiver = allocator_->Allocate(edx); | 5828 Result receiver = allocator_->Allocate(edx); |
5789 frame_->SetElementAt(arg_count + 1, &result); | 5829 frame_->SetElementAt(arg_count + 1, &result); |
5790 frame_->SetElementAt(arg_count, &receiver); | 5830 frame_->SetElementAt(arg_count, &receiver); |
5791 receiver.Unuse(); | 5831 receiver.Unuse(); |
5792 | 5832 |
5793 // Call the function. | 5833 // Call the function. |
5794 CodeForSourcePosition(node->position()); | 5834 CodeForSourcePosition(node->position()); |
(...skipping 7697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13492 // tagged as a small integer. | 13532 // tagged as a small integer. |
13493 __ bind(&runtime); | 13533 __ bind(&runtime); |
13494 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); | 13534 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); |
13495 } | 13535 } |
13496 | 13536 |
13497 #undef __ | 13537 #undef __ |
13498 | 13538 |
13499 } } // namespace v8::internal | 13539 } } // namespace v8::internal |
13500 | 13540 |
13501 #endif // V8_TARGET_ARCH_IA32 | 13541 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |