| 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 3089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3100 // constructor invocation. | 3100 // constructor invocation. |
| 3101 __ RecordPosition(node->position()); | 3101 __ RecordPosition(node->position()); |
| 3102 Handle<Code> ic(Builtins::builtin(Builtins::JSConstructCall)); | 3102 Handle<Code> ic(Builtins::builtin(Builtins::JSConstructCall)); |
| 3103 frame_->CallCodeObject(ic, RelocInfo::CONSTRUCT_CALL, args->length() + 1); | 3103 frame_->CallCodeObject(ic, RelocInfo::CONSTRUCT_CALL, args->length() + 1); |
| 3104 // Discard the function and "push" the newly created object. | 3104 // Discard the function and "push" the newly created object. |
| 3105 __ mov(frame_->Top(), eax); | 3105 __ mov(frame_->Top(), eax); |
| 3106 } | 3106 } |
| 3107 | 3107 |
| 3108 | 3108 |
| 3109 void CodeGenerator::VisitCallEval(CallEval* node) { | 3109 void CodeGenerator::VisitCallEval(CallEval* node) { |
| 3110 frame_->SpillAll(); |
| 3110 Comment cmnt(masm_, "[ CallEval"); | 3111 Comment cmnt(masm_, "[ CallEval"); |
| 3111 | 3112 |
| 3112 // In a call to eval, we first call %ResolvePossiblyDirectEval to resolve | 3113 // In a call to eval, we first call %ResolvePossiblyDirectEval to resolve |
| 3113 // the function we need to call and the receiver of the call. | 3114 // the function we need to call and the receiver of the call. |
| 3114 // Then we call the resolved function using the given arguments. | 3115 // Then we call the resolved function using the given arguments. |
| 3115 | 3116 |
| 3116 ZoneList<Expression*>* args = node->arguments(); | 3117 ZoneList<Expression*>* args = node->arguments(); |
| 3117 Expression* function = node->expression(); | 3118 Expression* function = node->expression(); |
| 3118 | 3119 |
| 3119 RecordStatementPosition(node); | 3120 RecordStatementPosition(node); |
| 3120 | 3121 |
| 3121 // Prepare stack for call to resolved function. | 3122 // Prepare stack for call to resolved function. |
| 3122 Load(function); | 3123 Load(function); |
| 3123 __ push(Immediate(Factory::undefined_value())); // Slot for receiver | 3124 frame_->SpillAll(); |
| 3124 for (int i = 0; i < args->length(); i++) { | 3125 // Allocate a frame slot for the receiver. |
| 3126 frame_->EmitPush(Immediate(Factory::undefined_value())); |
| 3127 int arg_count = args->length(); |
| 3128 for (int i = 0; i < arg_count; i++) { |
| 3125 Load(args->at(i)); | 3129 Load(args->at(i)); |
| 3130 frame_->SpillAll(); |
| 3126 } | 3131 } |
| 3127 | 3132 |
| 3128 // Prepare stack for call to ResolvePossiblyDirectEval. | 3133 // Prepare stack for call to ResolvePossiblyDirectEval. |
| 3129 __ push(Operand(esp, args->length() * kPointerSize + kPointerSize)); | 3134 frame_->EmitPush(frame_->ElementAt(arg_count + 1)); |
| 3130 if (args->length() > 0) { | 3135 if (arg_count > 0) { |
| 3131 __ push(Operand(esp, args->length() * kPointerSize)); | 3136 frame_->EmitPush(frame_->ElementAt(arg_count)); |
| 3132 } else { | 3137 } else { |
| 3133 __ push(Immediate(Factory::undefined_value())); | 3138 frame_->EmitPush(Immediate(Factory::undefined_value())); |
| 3134 } | 3139 } |
| 3135 | 3140 |
| 3136 // Resolve the call. | 3141 // Resolve the call. |
| 3137 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 2); | 3142 frame_->CallRuntime(Runtime::kResolvePossiblyDirectEval, 2); |
| 3138 | 3143 |
| 3139 // Touch up stack with the right values for the function and the receiver. | 3144 // Touch up stack with the right values for the function and the receiver. |
| 3140 __ mov(edx, FieldOperand(eax, FixedArray::kHeaderSize)); | 3145 __ mov(edx, FieldOperand(eax, FixedArray::kHeaderSize)); |
| 3141 __ mov(Operand(esp, (args->length() + 1) * kPointerSize), edx); | 3146 __ mov(frame_->ElementAt(arg_count + 1), edx); |
| 3142 __ mov(edx, FieldOperand(eax, FixedArray::kHeaderSize + kPointerSize)); | 3147 __ mov(edx, FieldOperand(eax, FixedArray::kHeaderSize + kPointerSize)); |
| 3143 __ mov(Operand(esp, args->length() * kPointerSize), edx); | 3148 __ mov(frame_->ElementAt(arg_count), edx); |
| 3144 | 3149 |
| 3145 // Call the function. | 3150 // Call the function. |
| 3146 __ RecordPosition(node->position()); | 3151 __ RecordPosition(node->position()); |
| 3147 | 3152 |
| 3148 CallFunctionStub call_function(args->length()); | 3153 CallFunctionStub call_function(arg_count); |
| 3149 __ CallStub(&call_function); | 3154 frame_->CallStub(&call_function, arg_count + 1); |
| 3150 | 3155 |
| 3151 // Restore context and pop function from the stack. | 3156 // Restore context and pop function from the stack. |
| 3152 __ mov(esi, frame_->Context()); | 3157 __ mov(esi, frame_->Context()); |
| 3153 __ mov(frame_->Top(), eax); | 3158 __ mov(frame_->Top(), eax); |
| 3154 } | 3159 } |
| 3155 | 3160 |
| 3156 | 3161 |
| 3157 void CodeGenerator::GenerateIsSmi(ZoneList<Expression*>* args) { | 3162 void CodeGenerator::GenerateIsSmi(ZoneList<Expression*>* args) { |
| 3158 ASSERT(args->length() == 1); | 3163 ASSERT(args->length() == 1); |
| 3159 Load(args->at(0)); | 3164 Load(args->at(0)); |
| (...skipping 2323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5483 | 5488 |
| 5484 // Slow-case: Go through the JavaScript implementation. | 5489 // Slow-case: Go through the JavaScript implementation. |
| 5485 __ bind(&slow); | 5490 __ bind(&slow); |
| 5486 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); | 5491 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); |
| 5487 } | 5492 } |
| 5488 | 5493 |
| 5489 | 5494 |
| 5490 #undef __ | 5495 #undef __ |
| 5491 | 5496 |
| 5492 } } // namespace v8::internal | 5497 } } // namespace v8::internal |
| OLD | NEW |