| 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 2409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2420 Reference property(this, node); | 2420 Reference property(this, node); |
| 2421 property.GetValue(typeof_state()); | 2421 property.GetValue(typeof_state()); |
| 2422 } | 2422 } |
| 2423 | 2423 |
| 2424 | 2424 |
| 2425 void CodeGenerator::VisitCall(Call* node) { | 2425 void CodeGenerator::VisitCall(Call* node) { |
| 2426 Comment cmnt(masm_, "[ Call"); | 2426 Comment cmnt(masm_, "[ Call"); |
| 2427 | 2427 |
| 2428 ZoneList<Expression*>* args = node->arguments(); | 2428 ZoneList<Expression*>* args = node->arguments(); |
| 2429 | 2429 |
| 2430 if (FLAG_debug_info) RecordStatementPosition(node); | 2430 RecordStatementPosition(node); |
| 2431 // Standard function call. | 2431 // Standard function call. |
| 2432 | 2432 |
| 2433 // Check if the function is a variable or a property. | 2433 // Check if the function is a variable or a property. |
| 2434 Expression* function = node->expression(); | 2434 Expression* function = node->expression(); |
| 2435 Variable* var = function->AsVariableProxy()->AsVariable(); | 2435 Variable* var = function->AsVariableProxy()->AsVariable(); |
| 2436 Property* property = function->AsProperty(); | 2436 Property* property = function->AsProperty(); |
| 2437 | 2437 |
| 2438 // ------------------------------------------------------------------------ | 2438 // ------------------------------------------------------------------------ |
| 2439 // Fast-case: Use inline caching. | 2439 // Fast-case: Use inline caching. |
| 2440 // --- | 2440 // --- |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2554 // Pass the global proxy as the receiver. | 2554 // Pass the global proxy as the receiver. |
| 2555 LoadGlobalReceiver(r0); | 2555 LoadGlobalReceiver(r0); |
| 2556 | 2556 |
| 2557 // Call the function. | 2557 // Call the function. |
| 2558 CallWithArguments(args, node->position()); | 2558 CallWithArguments(args, node->position()); |
| 2559 frame_->EmitPush(r0); | 2559 frame_->EmitPush(r0); |
| 2560 } | 2560 } |
| 2561 } | 2561 } |
| 2562 | 2562 |
| 2563 | 2563 |
| 2564 void CodeGenerator::VisitCallEval(CallEval* node) { |
| 2565 Comment cmnt(masm_, "[ CallEval"); |
| 2566 |
| 2567 // In a call to eval, we first call %ResolvePossiblyDirectEval to resolve |
| 2568 // the function we need to call and the receiver of the call. |
| 2569 // Then we call the resolved function using the given arguments. |
| 2570 |
| 2571 ZoneList<Expression*>* args = node->arguments(); |
| 2572 Expression* function = node->expression(); |
| 2573 |
| 2574 RecordStatementPosition(node); |
| 2575 |
| 2576 // Prepare stack for call to resolved function. |
| 2577 Load(function); |
| 2578 __ mov(r2, Operand(Factory::undefined_value())); |
| 2579 __ push(r2); // Slot for receiver |
| 2580 for (int i = 0; i < args->length(); i++) { |
| 2581 Load(args->at(i)); |
| 2582 } |
| 2583 |
| 2584 // Prepare stack for call to ResolvePossiblyDirectEval. |
| 2585 __ ldr(r1, MemOperand(sp, args->length() * kPointerSize + kPointerSize)); |
| 2586 __ push(r1); |
| 2587 if (args->length() > 0) { |
| 2588 __ ldr(r1, MemOperand(sp, args->length() * kPointerSize)); |
| 2589 __ push(r1); |
| 2590 } else { |
| 2591 __ push(r2); |
| 2592 } |
| 2593 |
| 2594 // Resolve the call. |
| 2595 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 2); |
| 2596 |
| 2597 // Touch up stack with the right values for the function and the receiver. |
| 2598 __ ldr(r1, FieldMemOperand(r0, FixedArray::kHeaderSize)); |
| 2599 __ str(r1, MemOperand(sp, (args->length() + 1) * kPointerSize)); |
| 2600 __ ldr(r1, FieldMemOperand(r0, FixedArray::kHeaderSize + kPointerSize)); |
| 2601 __ str(r1, MemOperand(sp, args->length() * kPointerSize)); |
| 2602 |
| 2603 // Call the function. |
| 2604 __ RecordPosition(node->position()); |
| 2605 |
| 2606 CallFunctionStub call_function(args->length()); |
| 2607 __ CallStub(&call_function); |
| 2608 |
| 2609 __ ldr(cp, frame_->Context()); |
| 2610 // Remove the function from the stack. |
| 2611 frame_->Pop(); |
| 2612 frame_->Push(r0); |
| 2613 } |
| 2614 |
| 2615 |
| 2564 void CodeGenerator::VisitCallNew(CallNew* node) { | 2616 void CodeGenerator::VisitCallNew(CallNew* node) { |
| 2565 Comment cmnt(masm_, "[ CallNew"); | 2617 Comment cmnt(masm_, "[ CallNew"); |
| 2566 | 2618 |
| 2567 // According to ECMA-262, section 11.2.2, page 44, the function | 2619 // According to ECMA-262, section 11.2.2, page 44, the function |
| 2568 // expression in new calls must be evaluated before the | 2620 // expression in new calls must be evaluated before the |
| 2569 // arguments. This is different from ordinary calls, where the | 2621 // arguments. This is different from ordinary calls, where the |
| 2570 // actual function to call is resolved after the arguments have been | 2622 // actual function to call is resolved after the arguments have been |
| 2571 // evaluated. | 2623 // evaluated. |
| 2572 | 2624 |
| 2573 // Compute function to call and use the global object as the | 2625 // Compute function to call and use the global object as the |
| (...skipping 1871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4445 __ mov(r2, Operand(0)); | 4497 __ mov(r2, Operand(0)); |
| 4446 __ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION); | 4498 __ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION); |
| 4447 __ Jump(Handle<Code>(Builtins::builtin(Builtins::ArgumentsAdaptorTrampoline)), | 4499 __ Jump(Handle<Code>(Builtins::builtin(Builtins::ArgumentsAdaptorTrampoline)), |
| 4448 RelocInfo::CODE_TARGET); | 4500 RelocInfo::CODE_TARGET); |
| 4449 } | 4501 } |
| 4450 | 4502 |
| 4451 | 4503 |
| 4452 #undef __ | 4504 #undef __ |
| 4453 | 4505 |
| 4454 } } // namespace v8::internal | 4506 } } // namespace v8::internal |
| OLD | NEW |