| Index: src/ia32/full-codegen-ia32.cc
|
| diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc
|
| index 8e78a4e326441c1ef93bf2838adc48ddaed4b93e..b021e46d3e9eb934beef823b6852ddf72601b983 100644
|
| --- a/src/ia32/full-codegen-ia32.cc
|
| +++ b/src/ia32/full-codegen-ia32.cc
|
| @@ -2582,15 +2582,17 @@ void FullCodeGenerator::CallIC(Handle<Code> code,
|
| }
|
|
|
|
|
| +
|
| +
|
| // Code common for calls using the IC.
|
| -void FullCodeGenerator::EmitCallWithLoadIC(Call* expr) {
|
| +void FullCodeGenerator::EmitCallWithIC(Call* expr) {
|
| Expression* callee = expr->expression();
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| + int arg_count = args->length();
|
|
|
| - CallIC::CallType call_type = callee->IsVariableProxy()
|
| - ? CallIC::FUNCTION
|
| - : CallIC::METHOD;
|
| + CallFunctionFlags flags;
|
| // Get the target function.
|
| - if (call_type == CallIC::FUNCTION) {
|
| + if (callee->IsVariableProxy()) {
|
| { StackValueContext context(this);
|
| EmitVariableLoad(callee->AsVariableProxy());
|
| PrepareForBailout(callee, NO_REGISTERS);
|
| @@ -2598,6 +2600,7 @@ void FullCodeGenerator::EmitCallWithLoadIC(Call* expr) {
|
| // Push undefined as receiver. This is patched in the method prologue if it
|
| // is a sloppy mode method.
|
| __ push(Immediate(isolate()->factory()->undefined_value()));
|
| + flags = NO_CALL_FUNCTION_FLAGS;
|
| } else {
|
| // Load the function from the receiver.
|
| ASSERT(callee->IsProperty());
|
| @@ -2607,19 +2610,39 @@ void FullCodeGenerator::EmitCallWithLoadIC(Call* expr) {
|
| // Push the target function under the receiver.
|
| __ push(Operand(esp, 0));
|
| __ mov(Operand(esp, kPointerSize), eax);
|
| + flags = CALL_AS_METHOD;
|
| }
|
|
|
| - EmitCall(expr, call_type);
|
| + // Load the arguments.
|
| + { PreservePositionScope scope(masm()->positions_recorder());
|
| + for (int i = 0; i < arg_count; i++) {
|
| + VisitForStackValue(args->at(i));
|
| + }
|
| + }
|
| +
|
| + // Record source position of the IC call.
|
| + SetSourcePosition(expr->position());
|
| + CallFunctionStub stub(arg_count, flags);
|
| + __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize));
|
| + __ CallStub(&stub);
|
| + RecordJSReturnSite(expr);
|
| +
|
| + // Restore context register.
|
| + __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
|
| +
|
| + context()->DropAndPlug(1, eax);
|
| }
|
|
|
|
|
| // Code common for calls using the IC.
|
| -void FullCodeGenerator::EmitKeyedCallWithLoadIC(Call* expr,
|
| - Expression* key) {
|
| +void FullCodeGenerator::EmitKeyedCallWithIC(Call* expr,
|
| + Expression* key) {
|
| // Load the key.
|
| VisitForAccumulatorValue(key);
|
|
|
| Expression* callee = expr->expression();
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| + int arg_count = args->length();
|
|
|
| // Load the function from the receiver.
|
| ASSERT(callee->IsProperty());
|
| @@ -2633,12 +2656,29 @@ void FullCodeGenerator::EmitKeyedCallWithLoadIC(Call* expr,
|
| __ push(Operand(esp, 0));
|
| __ mov(Operand(esp, kPointerSize), eax);
|
|
|
| - EmitCall(expr, CallIC::METHOD);
|
| + // Load the arguments.
|
| + { PreservePositionScope scope(masm()->positions_recorder());
|
| + for (int i = 0; i < arg_count; i++) {
|
| + VisitForStackValue(args->at(i));
|
| + }
|
| + }
|
| +
|
| + // Record source position of the IC call.
|
| + SetSourcePosition(expr->position());
|
| + CallFunctionStub stub(arg_count, CALL_AS_METHOD);
|
| + __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize));
|
| + __ CallStub(&stub);
|
| + RecordJSReturnSite(expr);
|
| +
|
| + // Restore context register.
|
| + __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
|
| +
|
| + context()->DropAndPlug(1, eax);
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitCall(Call* expr, CallIC::CallType call_type) {
|
| - // Load the arguments.
|
| +void FullCodeGenerator::EmitCallWithStub(Call* expr) {
|
| + // Code common for calls using the call stub.
|
| ZoneList<Expression*>* args = expr->arguments();
|
| int arg_count = args->length();
|
| { PreservePositionScope scope(masm()->positions_recorder());
|
| @@ -2646,26 +2686,23 @@ void FullCodeGenerator::EmitCall(Call* expr, CallIC::CallType call_type) {
|
| VisitForStackValue(args->at(i));
|
| }
|
| }
|
| -
|
| - // Record source position of the IC call.
|
| + // Record source position for debugger.
|
| SetSourcePosition(expr->position());
|
| - Handle<Code> ic = CallIC::initialize_stub(
|
| - isolate(), arg_count, call_type);
|
| +
|
| Handle<Object> uninitialized =
|
| TypeFeedbackInfo::UninitializedSentinel(isolate());
|
| StoreFeedbackVectorSlot(expr->CallFeedbackSlot(), uninitialized);
|
| __ LoadHeapObject(ebx, FeedbackVector());
|
| __ mov(edx, Immediate(Smi::FromInt(expr->CallFeedbackSlot())));
|
| +
|
| + // Record call targets in unoptimized code.
|
| + CallFunctionStub stub(arg_count, RECORD_CALL_TARGET);
|
| __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize));
|
| - // Don't assign a type feedback id to the IC, since type feedback is provided
|
| - // by the vector above.
|
| - CallIC(ic);
|
| + __ CallStub(&stub);
|
|
|
| RecordJSReturnSite(expr);
|
| -
|
| // Restore context register.
|
| __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
|
| -
|
| context()->DropAndPlug(1, eax);
|
| }
|
|
|
| @@ -2738,7 +2775,7 @@ void FullCodeGenerator::VisitCall(Call* expr) {
|
| context()->DropAndPlug(1, eax);
|
|
|
| } else if (call_type == Call::GLOBAL_CALL) {
|
| - EmitCallWithLoadIC(expr);
|
| + EmitCallWithIC(expr);
|
|
|
| } else if (call_type == Call::LOOKUP_SLOT_CALL) {
|
| // Call to a lookup slot (dynamically introduced variable).
|
| @@ -2774,7 +2811,7 @@ void FullCodeGenerator::VisitCall(Call* expr) {
|
|
|
| // The receiver is either the global receiver or an object found by
|
| // LoadContextSlot.
|
| - EmitCall(expr);
|
| + EmitCallWithStub(expr);
|
|
|
| } else if (call_type == Call::PROPERTY_CALL) {
|
| Property* property = callee->AsProperty();
|
| @@ -2782,9 +2819,9 @@ void FullCodeGenerator::VisitCall(Call* expr) {
|
| VisitForStackValue(property->obj());
|
| }
|
| if (property->key()->IsPropertyName()) {
|
| - EmitCallWithLoadIC(expr);
|
| + EmitCallWithIC(expr);
|
| } else {
|
| - EmitKeyedCallWithLoadIC(expr, property->key());
|
| + EmitKeyedCallWithIC(expr, property->key());
|
| }
|
|
|
| } else {
|
| @@ -2795,7 +2832,7 @@ void FullCodeGenerator::VisitCall(Call* expr) {
|
| }
|
| __ push(Immediate(isolate()->factory()->undefined_value()));
|
| // Emit function call.
|
| - EmitCall(expr);
|
| + EmitCallWithStub(expr);
|
| }
|
|
|
| #ifdef DEBUG
|
| @@ -2845,7 +2882,7 @@ void FullCodeGenerator::VisitCallNew(CallNew* expr) {
|
| __ LoadHeapObject(ebx, FeedbackVector());
|
| __ mov(edx, Immediate(Smi::FromInt(expr->CallNewFeedbackSlot())));
|
|
|
| - CallConstructStub stub(RECORD_CONSTRUCTOR_TARGET);
|
| + CallConstructStub stub(RECORD_CALL_TARGET);
|
| __ call(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL);
|
| PrepareForBailoutForId(expr->ReturnId(), TOS_REG);
|
| context()->Plug(eax);
|
|
|