OLD | NEW |
---|---|
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 2818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2829 // Call the construct call builtin that handles allocation and | 2829 // Call the construct call builtin that handles allocation and |
2830 // constructor invocation. | 2830 // constructor invocation. |
2831 __ RecordPosition(node->position()); | 2831 __ RecordPosition(node->position()); |
2832 __ call(Handle<Code>(Builtins::builtin(Builtins::JSConstructCall)), | 2832 __ call(Handle<Code>(Builtins::builtin(Builtins::JSConstructCall)), |
2833 RelocInfo::CONSTRUCT_CALL); | 2833 RelocInfo::CONSTRUCT_CALL); |
2834 // Discard the function and "push" the newly created object. | 2834 // Discard the function and "push" the newly created object. |
2835 __ mov(frame_->Top(), eax); | 2835 __ mov(frame_->Top(), eax); |
2836 } | 2836 } |
2837 | 2837 |
2838 | 2838 |
2839 void CodeGenerator::VisitCallEval(CallEval* node) { | |
2840 Comment cmnt(masm_, "[ Call"); | |
Mads Ager (chromium)
2008/11/27 13:46:02
CallEval?
| |
2841 | |
2842 // In a call to eval, we first call %ResolvePossiblyDirectEval to resolve | |
2843 // the function we need to call and the receiver of the call. | |
2844 // Then we call the resolved function using the given arguments. | |
2845 | |
2846 ZoneList<Expression*>* args = node->arguments(); | |
2847 Expression* function = node->expression(); | |
2848 | |
2849 RecordStatementPosition(node); | |
2850 | |
2851 // Prepare stack for call to resolved function. | |
2852 Load(function); | |
2853 __ push(Immediate(Factory::undefined_value())); // Slot for receiver | |
2854 for (int i = 0; i < args->length(); i++) { | |
2855 Load(args->at(i)); | |
2856 } | |
2857 | |
2858 // Prepare stack for call to ResolvePossiblyDirectEval. | |
2859 __ push(Operand(esp, args->length() * kPointerSize + kPointerSize)); | |
2860 if (args->length() > 0) { | |
2861 __ push(Operand(esp, args->length() * kPointerSize)); | |
2862 } else { | |
2863 __ push(Immediate(Factory::undefined_value())); | |
2864 } | |
2865 | |
2866 // Resolve the call. | |
2867 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 2); | |
2868 | |
2869 // Touch up stack with the right values for the function and the receiver. | |
2870 __ mov(edx, FieldOperand(eax, FixedArray::kHeaderSize)); | |
2871 __ mov(Operand(esp, (args->length() + 1) * kPointerSize), edx); | |
2872 __ mov(edx, FieldOperand(eax, FixedArray::kHeaderSize + kPointerSize)); | |
2873 __ mov(Operand(esp, args->length() * kPointerSize), edx); | |
2874 | |
2875 // Call the function. | |
2876 __ RecordPosition(node->position()); | |
2877 | |
2878 CallFunctionStub call_function(args->length()); | |
2879 __ CallStub(&call_function); | |
2880 | |
2881 // Restore context and pop function from the stack. | |
2882 __ mov(esi, frame_->Context()); | |
2883 __ mov(frame_->Top(), eax); | |
2884 } | |
2885 | |
2886 | |
2839 void CodeGenerator::GenerateIsSmi(ZoneList<Expression*>* args) { | 2887 void CodeGenerator::GenerateIsSmi(ZoneList<Expression*>* args) { |
2840 ASSERT(args->length() == 1); | 2888 ASSERT(args->length() == 1); |
2841 Load(args->at(0)); | 2889 Load(args->at(0)); |
2842 frame_->Pop(eax); | 2890 frame_->Pop(eax); |
2843 __ test(eax, Immediate(kSmiTagMask)); | 2891 __ test(eax, Immediate(kSmiTagMask)); |
2844 cc_reg_ = zero; | 2892 cc_reg_ = zero; |
2845 } | 2893 } |
2846 | 2894 |
2847 | 2895 |
2848 void CodeGenerator::GenerateIsNonNegativeSmi(ZoneList<Expression*>* args) { | 2896 void CodeGenerator::GenerateIsNonNegativeSmi(ZoneList<Expression*>* args) { |
(...skipping 2304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5153 | 5201 |
5154 // Slow-case: Go through the JavaScript implementation. | 5202 // Slow-case: Go through the JavaScript implementation. |
5155 __ bind(&slow); | 5203 __ bind(&slow); |
5156 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); | 5204 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); |
5157 } | 5205 } |
5158 | 5206 |
5159 | 5207 |
5160 #undef __ | 5208 #undef __ |
5161 | 5209 |
5162 } } // namespace v8::internal | 5210 } } // namespace v8::internal |
OLD | NEW |