Index: src/ia32/full-codegen-ia32.cc |
diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc |
index dd980b8e257dad5216b2654a677d5b5d4c6ab998..5696764be32995f6e00639900bdbdb41b7636ceb 100644 |
--- a/src/ia32/full-codegen-ia32.cc |
+++ b/src/ia32/full-codegen-ia32.cc |
@@ -2557,17 +2557,15 @@ void FullCodeGenerator::CallIC(Handle<Code> code, |
} |
- |
- |
// Code common for calls using the IC. |
-void FullCodeGenerator::EmitCallWithIC(Call* expr) { |
+void FullCodeGenerator::EmitCallWithLoadIC(Call* expr) { |
Expression* callee = expr->expression(); |
- ZoneList<Expression*>* args = expr->arguments(); |
- int arg_count = args->length(); |
- CallFunctionFlags flags; |
+ CallIC::CallType call_type = callee->IsVariableProxy() |
+ ? CallIC::FUNCTION |
+ : CallIC::METHOD; |
// Get the target function. |
- if (callee->IsVariableProxy()) { |
+ if (call_type == CallIC::FUNCTION) { |
{ StackValueContext context(this); |
EmitVariableLoad(callee->AsVariableProxy()); |
PrepareForBailout(callee, NO_REGISTERS); |
@@ -2575,7 +2573,6 @@ void FullCodeGenerator::EmitCallWithIC(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()); |
@@ -2585,39 +2582,19 @@ void FullCodeGenerator::EmitCallWithIC(Call* expr) { |
// Push the target function under the receiver. |
__ push(Operand(esp, 0)); |
__ mov(Operand(esp, kPointerSize), eax); |
- flags = CALL_AS_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(isolate(), 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); |
+ EmitCall(expr, call_type); |
} |
// Code common for calls using the IC. |
-void FullCodeGenerator::EmitKeyedCallWithIC(Call* expr, |
- Expression* key) { |
+void FullCodeGenerator::EmitKeyedCallWithLoadIC(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()); |
@@ -2631,29 +2608,12 @@ void FullCodeGenerator::EmitKeyedCallWithIC(Call* expr, |
__ push(Operand(esp, 0)); |
__ mov(Operand(esp, kPointerSize), eax); |
- // 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(isolate(), 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); |
+ EmitCall(expr, CallIC::METHOD); |
} |
-void FullCodeGenerator::EmitCallWithStub(Call* expr) { |
- // Code common for calls using the call stub. |
+void FullCodeGenerator::EmitCall(Call* expr, CallIC::CallType call_type) { |
+ // Load the arguments. |
ZoneList<Expression*>* args = expr->arguments(); |
int arg_count = args->length(); |
{ PreservePositionScope scope(masm()->positions_recorder()); |
@@ -2661,20 +2621,22 @@ void FullCodeGenerator::EmitCallWithStub(Call* expr) { |
VisitForStackValue(args->at(i)); |
} |
} |
- // Record source position for debugger. |
- SetSourcePosition(expr->position()); |
- |
- __ LoadHeapObject(ebx, FeedbackVector()); |
- __ mov(edx, Immediate(Smi::FromInt(expr->CallFeedbackSlot()))); |
- // Record call targets in unoptimized code. |
- CallFunctionStub stub(isolate(), arg_count, RECORD_CALL_TARGET); |
+ // Record source position of the IC call. |
+ SetSourcePosition(expr->position()); |
+ Handle<Code> ic = CallIC::initialize_stub( |
+ isolate(), arg_count, call_type); |
+ __ Move(edx, Immediate(Smi::FromInt(expr->CallFeedbackSlot()))); |
__ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); |
- __ CallStub(&stub); |
+ // Don't assign a type feedback id to the IC, since type feedback is provided |
+ // by the vector above. |
+ CallIC(ic); |
RecordJSReturnSite(expr); |
+ |
// Restore context register. |
__ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
+ |
context()->DropAndPlug(1, eax); |
} |
@@ -2747,7 +2709,7 @@ void FullCodeGenerator::VisitCall(Call* expr) { |
context()->DropAndPlug(1, eax); |
} else if (call_type == Call::GLOBAL_CALL) { |
- EmitCallWithIC(expr); |
+ EmitCallWithLoadIC(expr); |
} else if (call_type == Call::LOOKUP_SLOT_CALL) { |
// Call to a lookup slot (dynamically introduced variable). |
@@ -2783,7 +2745,7 @@ void FullCodeGenerator::VisitCall(Call* expr) { |
// The receiver is either the global receiver or an object found by |
// LoadContextSlot. |
- EmitCallWithStub(expr); |
+ EmitCall(expr); |
} else if (call_type == Call::PROPERTY_CALL) { |
Property* property = callee->AsProperty(); |
@@ -2791,9 +2753,9 @@ void FullCodeGenerator::VisitCall(Call* expr) { |
VisitForStackValue(property->obj()); |
} |
if (property->key()->IsPropertyName()) { |
- EmitCallWithIC(expr); |
+ EmitCallWithLoadIC(expr); |
} else { |
- EmitKeyedCallWithIC(expr, property->key()); |
+ EmitKeyedCallWithLoadIC(expr, property->key()); |
} |
} else { |
@@ -2804,7 +2766,7 @@ void FullCodeGenerator::VisitCall(Call* expr) { |
} |
__ push(Immediate(isolate()->factory()->undefined_value())); |
// Emit function call. |
- EmitCallWithStub(expr); |
+ EmitCall(expr); |
} |
#ifdef DEBUG |
@@ -2850,7 +2812,7 @@ void FullCodeGenerator::VisitCallNew(CallNew* expr) { |
__ LoadHeapObject(ebx, FeedbackVector()); |
__ mov(edx, Immediate(Smi::FromInt(expr->CallNewFeedbackSlot()))); |
- CallConstructStub stub(isolate(), RECORD_CALL_TARGET); |
+ CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); |
__ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); |
PrepareForBailoutForId(expr->ReturnId(), TOS_REG); |
context()->Plug(eax); |