Commit 54a9d349 authored by zhengxing.li's avatar zhengxing.li Committed by Commit bot

X87: Provide call counts for constructor calls, surface them as a vector IC.

  port 66d5a9df (r32452)

  original commit message:
  CallIC and CallConstructStub look so alike, at least in the feedback they gather even if the implementation differs...and CallIC has such a nice way of surfacing the feedback (CallICNexus), that there

BUG=

Review URL: https://codereview.chromium.org/1491063003

Cr-Commit-Position: refs/heads/master@{#32488}
parent ee29b94a
...@@ -2901,8 +2901,8 @@ void FullCodeGenerator::VisitCallNew(CallNew* expr) { ...@@ -2901,8 +2901,8 @@ void FullCodeGenerator::VisitCallNew(CallNew* expr) {
__ EmitLoadTypeFeedbackVector(ebx); __ EmitLoadTypeFeedbackVector(ebx);
__ mov(edx, Immediate(SmiFromSlot(expr->CallNewFeedbackSlot()))); __ mov(edx, Immediate(SmiFromSlot(expr->CallNewFeedbackSlot())));
CallConstructStub stub(isolate()); Handle<Code> code = CodeFactory::ConstructIC(isolate()).code();
__ call(stub.GetCode(), RelocInfo::CODE_TARGET); __ call(code, RelocInfo::CODE_TARGET);
PrepareForBailoutForId(expr->ReturnId(), TOS_REG); PrepareForBailoutForId(expr->ReturnId(), TOS_REG);
// Restore context register. // Restore context register.
__ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
......
...@@ -1644,6 +1644,7 @@ static void GenerateRecordCallTarget(MacroAssembler* masm) { ...@@ -1644,6 +1644,7 @@ static void GenerateRecordCallTarget(MacroAssembler* masm) {
// edi : the function to call // edi : the function to call
Isolate* isolate = masm->isolate(); Isolate* isolate = masm->isolate();
Label initialize, done, miss, megamorphic, not_array_function; Label initialize, done, miss, megamorphic, not_array_function;
Label done_increment_count;
// Load the cache state into ecx. // Load the cache state into ecx.
__ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size, __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size,
...@@ -1656,7 +1657,7 @@ static void GenerateRecordCallTarget(MacroAssembler* masm) { ...@@ -1656,7 +1657,7 @@ static void GenerateRecordCallTarget(MacroAssembler* masm) {
// type-feedback-vector.h). // type-feedback-vector.h).
Label check_allocation_site; Label check_allocation_site;
__ cmp(edi, FieldOperand(ecx, WeakCell::kValueOffset)); __ cmp(edi, FieldOperand(ecx, WeakCell::kValueOffset));
__ j(equal, &done, Label::kFar); __ j(equal, &done_increment_count, Label::kFar);
__ CompareRoot(ecx, Heap::kmegamorphic_symbolRootIndex); __ CompareRoot(ecx, Heap::kmegamorphic_symbolRootIndex);
__ j(equal, &done, Label::kFar); __ j(equal, &done, Label::kFar);
__ CompareRoot(FieldOperand(ecx, HeapObject::kMapOffset), __ CompareRoot(FieldOperand(ecx, HeapObject::kMapOffset),
...@@ -1679,7 +1680,7 @@ static void GenerateRecordCallTarget(MacroAssembler* masm) { ...@@ -1679,7 +1680,7 @@ static void GenerateRecordCallTarget(MacroAssembler* masm) {
__ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx);
__ cmp(edi, ecx); __ cmp(edi, ecx);
__ j(not_equal, &megamorphic); __ j(not_equal, &megamorphic);
__ jmp(&done, Label::kFar); __ jmp(&done_increment_count, Label::kFar);
__ bind(&miss); __ bind(&miss);
...@@ -1698,6 +1699,12 @@ static void GenerateRecordCallTarget(MacroAssembler* masm) { ...@@ -1698,6 +1699,12 @@ static void GenerateRecordCallTarget(MacroAssembler* masm) {
// An uninitialized cache is patched with the function or sentinel to // An uninitialized cache is patched with the function or sentinel to
// indicate the ElementsKind if function is the Array constructor. // indicate the ElementsKind if function is the Array constructor.
__ bind(&initialize); __ bind(&initialize);
// Initialize the call counter.
__ mov(FieldOperand(ebx, edx, times_half_pointer_size,
FixedArray::kHeaderSize + kPointerSize),
Immediate(Smi::FromInt(ConstructICNexus::kCallCountIncrement)));
// Make sure the function is the Array() function // Make sure the function is the Array() function
__ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx);
__ cmp(edi, ecx); __ cmp(edi, ecx);
...@@ -1713,11 +1720,18 @@ static void GenerateRecordCallTarget(MacroAssembler* masm) { ...@@ -1713,11 +1720,18 @@ static void GenerateRecordCallTarget(MacroAssembler* masm) {
__ bind(&not_array_function); __ bind(&not_array_function);
CreateWeakCellStub weak_cell_stub(isolate); CreateWeakCellStub weak_cell_stub(isolate);
CallStubInRecordCallTarget(masm, &weak_cell_stub); CallStubInRecordCallTarget(masm, &weak_cell_stub);
__ jmp(&done);
__ bind(&done_increment_count);
__ add(FieldOperand(ebx, edx, times_half_pointer_size,
FixedArray::kHeaderSize + kPointerSize),
Immediate(Smi::FromInt(ConstructICNexus::kCallCountIncrement)));
__ bind(&done); __ bind(&done);
} }
void CallConstructStub::Generate(MacroAssembler* masm) { void ConstructICStub::Generate(MacroAssembler* masm) {
// eax : number of arguments // eax : number of arguments
// ebx : feedback vector // ebx : feedback vector
// edx : slot in feedback vector (Smi, for RecordCallTarget) // edx : slot in feedback vector (Smi, for RecordCallTarget)
......
...@@ -194,16 +194,15 @@ void CallFunctionWithFeedbackAndVectorDescriptor::InitializePlatformSpecific( ...@@ -194,16 +194,15 @@ void CallFunctionWithFeedbackAndVectorDescriptor::InitializePlatformSpecific(
} }
void CallConstructDescriptor::InitializePlatformSpecific( void ConstructDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
// eax : number of arguments // eax : number of arguments
// ebx : feedback vector // ebx : feedback vector
// ecx : new target (for IsSuperConstructorCall)
// edx : slot in feedback vector (Smi, for RecordCallTarget) // edx : slot in feedback vector (Smi, for RecordCallTarget)
// edi : constructor function // edi : constructor function
// TODO(turbofan): So far we don't gather type feedback and hence skip the // TODO(turbofan): So far we don't gather type feedback and hence skip the
// slot parameter, but ArrayConstructStub needs the vector to be undefined. // slot parameter, but ArrayConstructStub needs the vector to be undefined.
Register registers[] = {eax, edi, ecx, ebx}; Register registers[] = {eax, edi, edx, ebx};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL); data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment