| 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 3088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3099 // Call the construct call builtin that handles allocation and | 3099 // Call the construct call builtin that handles allocation and |
| 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) { |
| 3110 Comment cmnt(masm_, "[ CallEval"); |
| 3111 |
| 3112 // 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 // Then we call the resolved function using the given arguments. |
| 3115 |
| 3116 ZoneList<Expression*>* args = node->arguments(); |
| 3117 Expression* function = node->expression(); |
| 3118 |
| 3119 RecordStatementPosition(node); |
| 3120 |
| 3121 // Prepare stack for call to resolved function. |
| 3122 Load(function); |
| 3123 __ push(Immediate(Factory::undefined_value())); // Slot for receiver |
| 3124 for (int i = 0; i < args->length(); i++) { |
| 3125 Load(args->at(i)); |
| 3126 } |
| 3127 |
| 3128 // Prepare stack for call to ResolvePossiblyDirectEval. |
| 3129 __ push(Operand(esp, args->length() * kPointerSize + kPointerSize)); |
| 3130 if (args->length() > 0) { |
| 3131 __ push(Operand(esp, args->length() * kPointerSize)); |
| 3132 } else { |
| 3133 __ push(Immediate(Factory::undefined_value())); |
| 3134 } |
| 3135 |
| 3136 // Resolve the call. |
| 3137 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 2); |
| 3138 |
| 3139 // Touch up stack with the right values for the function and the receiver. |
| 3140 __ mov(edx, FieldOperand(eax, FixedArray::kHeaderSize)); |
| 3141 __ mov(Operand(esp, (args->length() + 1) * kPointerSize), edx); |
| 3142 __ mov(edx, FieldOperand(eax, FixedArray::kHeaderSize + kPointerSize)); |
| 3143 __ mov(Operand(esp, args->length() * kPointerSize), edx); |
| 3144 |
| 3145 // Call the function. |
| 3146 __ RecordPosition(node->position()); |
| 3147 |
| 3148 CallFunctionStub call_function(args->length()); |
| 3149 __ CallStub(&call_function); |
| 3150 |
| 3151 // Restore context and pop function from the stack. |
| 3152 __ mov(esi, frame_->Context()); |
| 3153 __ mov(frame_->Top(), eax); |
| 3154 } |
| 3155 |
| 3156 |
| 3109 void CodeGenerator::GenerateIsSmi(ZoneList<Expression*>* args) { | 3157 void CodeGenerator::GenerateIsSmi(ZoneList<Expression*>* args) { |
| 3110 ASSERT(args->length() == 1); | 3158 ASSERT(args->length() == 1); |
| 3111 Load(args->at(0)); | 3159 Load(args->at(0)); |
| 3112 frame_->SpillAll(); | 3160 frame_->SpillAll(); |
| 3113 frame_->EmitPop(eax); | 3161 frame_->EmitPop(eax); |
| 3114 __ test(eax, Immediate(kSmiTagMask)); | 3162 __ test(eax, Immediate(kSmiTagMask)); |
| 3115 cc_reg_ = zero; | 3163 cc_reg_ = zero; |
| 3116 } | 3164 } |
| 3117 | 3165 |
| 3118 | 3166 |
| (...skipping 2316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5435 | 5483 |
| 5436 // Slow-case: Go through the JavaScript implementation. | 5484 // Slow-case: Go through the JavaScript implementation. |
| 5437 __ bind(&slow); | 5485 __ bind(&slow); |
| 5438 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); | 5486 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); |
| 5439 } | 5487 } |
| 5440 | 5488 |
| 5441 | 5489 |
| 5442 #undef __ | 5490 #undef __ |
| 5443 | 5491 |
| 5444 } } // namespace v8::internal | 5492 } } // namespace v8::internal |
| OLD | NEW |