| OLD | NEW | 
|---|
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 4525 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4536     // Restore the context and overwrite the function on the stack with | 4536     // Restore the context and overwrite the function on the stack with | 
| 4537     // the result. | 4537     // the result. | 
| 4538     frame_->RestoreContextRegister(); | 4538     frame_->RestoreContextRegister(); | 
| 4539     frame_->SetElementAt(0, &result); | 4539     frame_->SetElementAt(0, &result); | 
| 4540 | 4540 | 
| 4541   } else if (var != NULL && !var->is_this() && var->is_global()) { | 4541   } else if (var != NULL && !var->is_this() && var->is_global()) { | 
| 4542     // ---------------------------------- | 4542     // ---------------------------------- | 
| 4543     // JavaScript example: 'foo(1, 2, 3)'  // foo is global | 4543     // JavaScript example: 'foo(1, 2, 3)'  // foo is global | 
| 4544     // ---------------------------------- | 4544     // ---------------------------------- | 
| 4545 | 4545 | 
| 4546     // Push the name of the function and the receiver onto the stack. |  | 
| 4547     frame_->Push(var->name()); |  | 
| 4548 |  | 
| 4549     // Pass the global object as the receiver and let the IC stub | 4546     // Pass the global object as the receiver and let the IC stub | 
| 4550     // patch the stack to use the global proxy as 'this' in the | 4547     // patch the stack to use the global proxy as 'this' in the | 
| 4551     // invoked function. | 4548     // invoked function. | 
| 4552     LoadGlobal(); | 4549     LoadGlobal(); | 
| 4553 | 4550 | 
| 4554     // Load the arguments. | 4551     // Load the arguments. | 
| 4555     int arg_count = args->length(); | 4552     int arg_count = args->length(); | 
| 4556     for (int i = 0; i < arg_count; i++) { | 4553     for (int i = 0; i < arg_count; i++) { | 
| 4557       Load(args->at(i)); | 4554       Load(args->at(i)); | 
| 4558     } | 4555     } | 
| 4559 | 4556 | 
|  | 4557     // Push the name of the function onto the frame. | 
|  | 4558     frame_->Push(var->name()); | 
|  | 4559 | 
| 4560     // Call the IC initialization code. | 4560     // Call the IC initialization code. | 
| 4561     CodeForSourcePosition(node->position()); | 4561     CodeForSourcePosition(node->position()); | 
| 4562     Result result = frame_->CallCallIC(RelocInfo::CODE_TARGET_CONTEXT, | 4562     Result result = frame_->CallCallIC(RelocInfo::CODE_TARGET_CONTEXT, | 
| 4563                                        arg_count, | 4563                                        arg_count, | 
| 4564                                        loop_nesting()); | 4564                                        loop_nesting()); | 
| 4565     frame_->RestoreContextRegister(); | 4565     frame_->RestoreContextRegister(); | 
| 4566     // Replace the function on the stack with the result. | 4566     frame_->Push(&result); | 
| 4567     frame_->SetElementAt(0, &result); |  | 
| 4568 | 4567 | 
| 4569   } else if (var != NULL && var->slot() != NULL && | 4568   } else if (var != NULL && var->slot() != NULL && | 
| 4570              var->slot()->type() == Slot::LOOKUP) { | 4569              var->slot()->type() == Slot::LOOKUP) { | 
| 4571     // ---------------------------------- | 4570     // ---------------------------------- | 
| 4572     // JavaScript example: 'with (obj) foo(1, 2, 3)'  // foo is in obj | 4571     // JavaScript example: 'with (obj) foo(1, 2, 3)'  // foo is in obj | 
| 4573     // ---------------------------------- | 4572     // ---------------------------------- | 
| 4574 | 4573 | 
| 4575     // Load the function from the context.  Sync the frame so we can | 4574     // Load the function from the context.  Sync the frame so we can | 
| 4576     // push the arguments directly into place. | 4575     // push the arguments directly into place. | 
| 4577     frame_->SyncRange(0, frame_->element_count() - 1); | 4576     frame_->SyncRange(0, frame_->element_count() - 1); | 
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4610           args->at(1)->AsVariableProxy() != NULL && | 4609           args->at(1)->AsVariableProxy() != NULL && | 
| 4611           args->at(1)->AsVariableProxy()->IsArguments()) { | 4610           args->at(1)->AsVariableProxy()->IsArguments()) { | 
| 4612         // Use the optimized Function.prototype.apply that avoids | 4611         // Use the optimized Function.prototype.apply that avoids | 
| 4613         // allocating lazily allocated arguments objects. | 4612         // allocating lazily allocated arguments objects. | 
| 4614         CallApplyLazy(property, | 4613         CallApplyLazy(property, | 
| 4615                       args->at(0), | 4614                       args->at(0), | 
| 4616                       args->at(1)->AsVariableProxy(), | 4615                       args->at(1)->AsVariableProxy(), | 
| 4617                       node->position()); | 4616                       node->position()); | 
| 4618 | 4617 | 
| 4619       } else { | 4618       } else { | 
| 4620         // Push the name of the function and the receiver onto the stack. | 4619         // Push the receiver onto the frame. | 
| 4621         frame_->Push(name); |  | 
| 4622         Load(property->obj()); | 4620         Load(property->obj()); | 
| 4623 | 4621 | 
| 4624         // Load the arguments. | 4622         // Load the arguments. | 
| 4625         int arg_count = args->length(); | 4623         int arg_count = args->length(); | 
| 4626         for (int i = 0; i < arg_count; i++) { | 4624         for (int i = 0; i < arg_count; i++) { | 
| 4627           Load(args->at(i)); | 4625           Load(args->at(i)); | 
| 4628         } | 4626         } | 
| 4629 | 4627 | 
|  | 4628         // Push the name of the function onto the frame. | 
|  | 4629         frame_->Push(name); | 
|  | 4630 | 
| 4630         // Call the IC initialization code. | 4631         // Call the IC initialization code. | 
| 4631         CodeForSourcePosition(node->position()); | 4632         CodeForSourcePosition(node->position()); | 
| 4632         Result result = | 4633         Result result = | 
| 4633             frame_->CallCallIC(RelocInfo::CODE_TARGET, arg_count, | 4634             frame_->CallCallIC(RelocInfo::CODE_TARGET, arg_count, | 
| 4634                                loop_nesting()); | 4635                                loop_nesting()); | 
| 4635         frame_->RestoreContextRegister(); | 4636         frame_->RestoreContextRegister(); | 
| 4636         // Replace the function on the stack with the result. | 4637         frame_->Push(&result); | 
| 4637         frame_->SetElementAt(0, &result); |  | 
| 4638       } | 4638       } | 
| 4639 | 4639 | 
| 4640     } else { | 4640     } else { | 
| 4641       // ------------------------------------------- | 4641       // ------------------------------------------- | 
| 4642       // JavaScript example: 'array[index](1, 2, 3)' | 4642       // JavaScript example: 'array[index](1, 2, 3)' | 
| 4643       // ------------------------------------------- | 4643       // ------------------------------------------- | 
| 4644 | 4644 | 
| 4645       // Load the function to call from the property through a reference. | 4645       // Load the function to call from the property through a reference. | 
| 4646       Reference ref(this, property); | 4646       Reference ref(this, property); | 
| 4647       ref.GetValue(); | 4647       ref.GetValue(); | 
| (...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 5285 void CodeGenerator::VisitCallRuntime(CallRuntime* node) { | 5285 void CodeGenerator::VisitCallRuntime(CallRuntime* node) { | 
| 5286   if (CheckForInlineRuntimeCall(node)) { | 5286   if (CheckForInlineRuntimeCall(node)) { | 
| 5287     return; | 5287     return; | 
| 5288   } | 5288   } | 
| 5289 | 5289 | 
| 5290   ZoneList<Expression*>* args = node->arguments(); | 5290   ZoneList<Expression*>* args = node->arguments(); | 
| 5291   Comment cmnt(masm_, "[ CallRuntime"); | 5291   Comment cmnt(masm_, "[ CallRuntime"); | 
| 5292   Runtime::Function* function = node->function(); | 5292   Runtime::Function* function = node->function(); | 
| 5293 | 5293 | 
| 5294   if (function == NULL) { | 5294   if (function == NULL) { | 
| 5295     // Prepare stack for calling JS runtime function. |  | 
| 5296     frame_->Push(node->name()); |  | 
| 5297     // Push the builtins object found in the current global object. | 5295     // Push the builtins object found in the current global object. | 
| 5298     Result temp = allocator()->Allocate(); | 5296     Result temp = allocator()->Allocate(); | 
| 5299     ASSERT(temp.is_valid()); | 5297     ASSERT(temp.is_valid()); | 
| 5300     __ mov(temp.reg(), GlobalObject()); | 5298     __ mov(temp.reg(), GlobalObject()); | 
| 5301     __ mov(temp.reg(), FieldOperand(temp.reg(), GlobalObject::kBuiltinsOffset)); | 5299     __ mov(temp.reg(), FieldOperand(temp.reg(), GlobalObject::kBuiltinsOffset)); | 
| 5302     frame_->Push(&temp); | 5300     frame_->Push(&temp); | 
| 5303   } | 5301   } | 
| 5304 | 5302 | 
| 5305   // Push the arguments ("left-to-right"). | 5303   // Push the arguments ("left-to-right"). | 
| 5306   int arg_count = args->length(); | 5304   int arg_count = args->length(); | 
| 5307   for (int i = 0; i < arg_count; i++) { | 5305   for (int i = 0; i < arg_count; i++) { | 
| 5308     Load(args->at(i)); | 5306     Load(args->at(i)); | 
| 5309   } | 5307   } | 
| 5310 | 5308 | 
| 5311   if (function == NULL) { | 5309   if (function == NULL) { | 
| 5312     // Call the JS runtime function. | 5310     // Call the JS runtime function. | 
|  | 5311     frame_->Push(node->name()); | 
| 5313     Result answer = frame_->CallCallIC(RelocInfo::CODE_TARGET, | 5312     Result answer = frame_->CallCallIC(RelocInfo::CODE_TARGET, | 
| 5314                                        arg_count, | 5313                                        arg_count, | 
| 5315                                        loop_nesting_); | 5314                                        loop_nesting_); | 
| 5316     frame_->RestoreContextRegister(); | 5315     frame_->RestoreContextRegister(); | 
| 5317     frame_->SetElementAt(0, &answer); | 5316     frame_->Push(&answer); | 
| 5318   } else { | 5317   } else { | 
| 5319     // Call the C runtime function. | 5318     // Call the C runtime function. | 
| 5320     Result answer = frame_->CallRuntime(function, arg_count); | 5319     Result answer = frame_->CallRuntime(function, arg_count); | 
| 5321     frame_->Push(&answer); | 5320     frame_->Push(&answer); | 
| 5322   } | 5321   } | 
| 5323 } | 5322 } | 
| 5324 | 5323 | 
| 5325 | 5324 | 
| 5326 void CodeGenerator::VisitUnaryOperation(UnaryOperation* node) { | 5325 void CodeGenerator::VisitUnaryOperation(UnaryOperation* node) { | 
| 5327   Comment cmnt(masm_, "[ UnaryOperation"); | 5326   Comment cmnt(masm_, "[ UnaryOperation"); | 
| (...skipping 3130 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 8458     __ add(Operand(dest), Immediate(2)); | 8457     __ add(Operand(dest), Immediate(2)); | 
| 8459   } | 8458   } | 
| 8460   __ sub(Operand(count), Immediate(1)); | 8459   __ sub(Operand(count), Immediate(1)); | 
| 8461   __ j(not_zero, &loop); | 8460   __ j(not_zero, &loop); | 
| 8462 } | 8461 } | 
| 8463 | 8462 | 
| 8464 | 8463 | 
| 8465 #undef __ | 8464 #undef __ | 
| 8466 | 8465 | 
| 8467 } }  // namespace v8::internal | 8466 } }  // namespace v8::internal | 
| OLD | NEW | 
|---|