| OLD | NEW | 
|     1 // Copyright 2012 the V8 project authors. All rights reserved. |     1 // Copyright 2012 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 2640 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2651  |  2651  | 
|  2652 void FullCodeGenerator::VisitCall(Call* expr) { |  2652 void FullCodeGenerator::VisitCall(Call* expr) { | 
|  2653 #ifdef DEBUG |  2653 #ifdef DEBUG | 
|  2654   // We want to verify that RecordJSReturnSite gets called on all paths |  2654   // We want to verify that RecordJSReturnSite gets called on all paths | 
|  2655   // through this function.  Avoid early returns. |  2655   // through this function.  Avoid early returns. | 
|  2656   expr->return_is_recorded_ = false; |  2656   expr->return_is_recorded_ = false; | 
|  2657 #endif |  2657 #endif | 
|  2658  |  2658  | 
|  2659   Comment cmnt(masm_, "[ Call"); |  2659   Comment cmnt(masm_, "[ Call"); | 
|  2660   Expression* callee = expr->expression(); |  2660   Expression* callee = expr->expression(); | 
|  2661   VariableProxy* proxy = callee->AsVariableProxy(); |  2661   Call::CallType call_type = expr->GetCallType(isolate()); | 
|  2662   Property* property = callee->AsProperty(); |  | 
|  2663  |  2662  | 
|  2664   if (proxy != NULL && proxy->var()->is_possibly_eval(isolate())) { |  2663   if (call_type == Call::POSSIBLY_EVAL_CALL) { | 
|  2665     // In a call to eval, we first call %ResolvePossiblyDirectEval to |  2664     // In a call to eval, we first call %ResolvePossiblyDirectEval to | 
|  2666     // resolve the function we need to call and the receiver of the call. |  2665     // resolve the function we need to call and the receiver of the call. | 
|  2667     // Then we call the resolved function using the given arguments. |  2666     // Then we call the resolved function using the given arguments. | 
|  2668     ZoneList<Expression*>* args = expr->arguments(); |  2667     ZoneList<Expression*>* args = expr->arguments(); | 
|  2669     int arg_count = args->length(); |  2668     int arg_count = args->length(); | 
|  2670     { PreservePositionScope pos_scope(masm()->positions_recorder()); |  2669     { PreservePositionScope pos_scope(masm()->positions_recorder()); | 
|  2671       VisitForStackValue(callee); |  2670       VisitForStackValue(callee); | 
|  2672       __ PushRoot(Heap::kUndefinedValueRootIndex);  // Reserved receiver slot. |  2671       __ PushRoot(Heap::kUndefinedValueRootIndex);  // Reserved receiver slot. | 
|  2673  |  2672  | 
|  2674       // Push the arguments. |  2673       // Push the arguments. | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
|  2688     } |  2687     } | 
|  2689     // Record source position for debugger. |  2688     // Record source position for debugger. | 
|  2690     SetSourcePosition(expr->position()); |  2689     SetSourcePosition(expr->position()); | 
|  2691     CallFunctionStub stub(arg_count, NO_CALL_FUNCTION_FLAGS); |  2690     CallFunctionStub stub(arg_count, NO_CALL_FUNCTION_FLAGS); | 
|  2692     __ movq(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); |  2691     __ movq(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); | 
|  2693     __ CallStub(&stub); |  2692     __ CallStub(&stub); | 
|  2694     RecordJSReturnSite(expr); |  2693     RecordJSReturnSite(expr); | 
|  2695     // Restore context register. |  2694     // Restore context register. | 
|  2696     __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |  2695     __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 
|  2697     context()->DropAndPlug(1, rax); |  2696     context()->DropAndPlug(1, rax); | 
|  2698   } else if (proxy != NULL && proxy->var()->IsUnallocated()) { |  2697   } else if (call_type == Call::GLOBAL_CALL) { | 
|  2699     // Call to a global variable.  Push global object as receiver for the |  2698     // Call to a global variable.  Push global object as receiver for the | 
|  2700     // call IC lookup. |  2699     // call IC lookup. | 
|  2701     __ push(GlobalObjectOperand()); |  2700     __ push(GlobalObjectOperand()); | 
 |  2701     VariableProxy* proxy = callee->AsVariableProxy(); | 
|  2702     EmitCallWithIC(expr, proxy->name(), CONTEXTUAL); |  2702     EmitCallWithIC(expr, proxy->name(), CONTEXTUAL); | 
|  2703   } else if (proxy != NULL && proxy->var()->IsLookupSlot()) { |  2703   } else if (call_type == Call::LOOKUP_SLOT_CALL) { | 
|  2704     // Call to a lookup slot (dynamically introduced variable). |  2704     // Call to a lookup slot (dynamically introduced variable). | 
 |  2705     VariableProxy* proxy = callee->AsVariableProxy(); | 
|  2705     Label slow, done; |  2706     Label slow, done; | 
|  2706  |  2707  | 
|  2707     { PreservePositionScope scope(masm()->positions_recorder()); |  2708     { PreservePositionScope scope(masm()->positions_recorder()); | 
|  2708       // Generate code for loading from variables potentially shadowed by |  2709       // Generate code for loading from variables potentially shadowed by | 
|  2709       // eval-introduced variables. |  2710       // eval-introduced variables. | 
|  2710       EmitDynamicLookupFastCase(proxy->var(), NOT_INSIDE_TYPEOF, &slow, &done); |  2711       EmitDynamicLookupFastCase(proxy->var(), NOT_INSIDE_TYPEOF, &slow, &done); | 
|  2711     } |  2712     } | 
|  2712     __ bind(&slow); |  2713     __ bind(&slow); | 
|  2713     // Call the runtime to find the function to call (returned in rax) and |  2714     // Call the runtime to find the function to call (returned in rax) and | 
|  2714     // the object holding it (returned in rdx). |  2715     // the object holding it (returned in rdx). | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
|  2728       __ push(rax); |  2729       __ push(rax); | 
|  2729       // The receiver is implicitly the global receiver. Indicate this by |  2730       // The receiver is implicitly the global receiver. Indicate this by | 
|  2730       // passing the hole to the call function stub. |  2731       // passing the hole to the call function stub. | 
|  2731       __ PushRoot(Heap::kUndefinedValueRootIndex); |  2732       __ PushRoot(Heap::kUndefinedValueRootIndex); | 
|  2732       __ bind(&call); |  2733       __ bind(&call); | 
|  2733     } |  2734     } | 
|  2734  |  2735  | 
|  2735     // The receiver is either the global receiver or an object found by |  2736     // The receiver is either the global receiver or an object found by | 
|  2736     // LoadContextSlot. |  2737     // LoadContextSlot. | 
|  2737     EmitCallWithStub(expr); |  2738     EmitCallWithStub(expr); | 
|  2738   } else if (property != NULL) { |  2739   } else if (call_type == Call::PROPERTY_CALL) { | 
 |  2740     Property* property = callee->AsProperty(); | 
|  2739     { PreservePositionScope scope(masm()->positions_recorder()); |  2741     { PreservePositionScope scope(masm()->positions_recorder()); | 
|  2740       VisitForStackValue(property->obj()); |  2742       VisitForStackValue(property->obj()); | 
|  2741     } |  2743     } | 
|  2742     if (property->key()->IsPropertyName()) { |  2744     if (property->key()->IsPropertyName()) { | 
|  2743       EmitCallWithIC(expr, |  2745       EmitCallWithIC(expr, | 
|  2744                      property->key()->AsLiteral()->value(), |  2746                      property->key()->AsLiteral()->value(), | 
|  2745                      NOT_CONTEXTUAL); |  2747                      NOT_CONTEXTUAL); | 
|  2746     } else { |  2748     } else { | 
|  2747       EmitKeyedCallWithIC(expr, property->key()); |  2749       EmitKeyedCallWithIC(expr, property->key()); | 
|  2748     } |  2750     } | 
|  2749   } else { |  2751   } else { | 
 |  2752     ASSERT(call_type == Call::OTHER_CALL); | 
|  2750     // Call to an arbitrary expression not handled specially above. |  2753     // Call to an arbitrary expression not handled specially above. | 
|  2751     { PreservePositionScope scope(masm()->positions_recorder()); |  2754     { PreservePositionScope scope(masm()->positions_recorder()); | 
|  2752       VisitForStackValue(callee); |  2755       VisitForStackValue(callee); | 
|  2753     } |  2756     } | 
|  2754     __ PushRoot(Heap::kUndefinedValueRootIndex); |  2757     __ PushRoot(Heap::kUndefinedValueRootIndex); | 
|  2755     // Emit function call. |  2758     // Emit function call. | 
|  2756     EmitCallWithStub(expr); |  2759     EmitCallWithStub(expr); | 
|  2757   } |  2760   } | 
|  2758  |  2761  | 
|  2759 #ifdef DEBUG |  2762 #ifdef DEBUG | 
| (...skipping 2137 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  4897  |  4900  | 
|  4898   ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |  4901   ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 
|  4899             Assembler::target_address_at(call_target_address)); |  4902             Assembler::target_address_at(call_target_address)); | 
|  4900   return OSR_AFTER_STACK_CHECK; |  4903   return OSR_AFTER_STACK_CHECK; | 
|  4901 } |  4904 } | 
|  4902  |  4905  | 
|  4903  |  4906  | 
|  4904 } }  // namespace v8::internal |  4907 } }  // namespace v8::internal | 
|  4905  |  4908  | 
|  4906 #endif  // V8_TARGET_ARCH_X64 |  4909 #endif  // V8_TARGET_ARCH_X64 | 
| OLD | NEW |