Commit 64f81870 authored by mvstanton's avatar mvstanton Committed by Commit bot

Super Constructor Calls need to use a vector slot, not an ic slot.

The Ast Call node is accustomed to using a vector IC slot for the
cases when it uses a CallIC. The super constructor work alters this
somewhat by using a CallConstructStub instead, however the
CallConstructStub expects a vector slot and not a vector ic slot.
This distinction needs to be maintained because slots and ic slots
have different clearing strategies and are handled differently.

R=dslomov@chromium.org
BUG=
LOG=N

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

Cr-Commit-Position: refs/heads/master@{#26414}
parent 4f786bef
......@@ -3007,7 +3007,7 @@ void FullCodeGenerator::EmitCall(Call* expr, CallICState::CallType call_type) {
// Record source position of the IC call.
SetSourcePosition(expr->position());
Handle<Code> ic = CodeFactory::CallIC(isolate(), arg_count, call_type).code();
__ mov(r3, Operand(SmiFromSlot(expr->CallFeedbackSlot())));
__ mov(r3, Operand(SmiFromSlot(expr->CallFeedbackICSlot())));
__ ldr(r1, MemOperand(sp, (arg_count + 1) * kPointerSize));
// Don't assign a type feedback id to the IC, since type feedback is provided
// by the vector above.
......
......@@ -2695,7 +2695,7 @@ void FullCodeGenerator::EmitCall(Call* expr, CallICState::CallType call_type) {
SetSourcePosition(expr->position());
Handle<Code> ic = CodeFactory::CallIC(isolate(), arg_count, call_type).code();
__ Mov(x3, SmiFromSlot(expr->CallFeedbackSlot()));
__ Mov(x3, SmiFromSlot(expr->CallFeedbackICSlot()));
__ Peek(x1, (arg_count + 1) * kXRegSize);
// Don't assign a type feedback id to the IC, since type feedback is provided
// by the vector above.
......
......@@ -578,15 +578,28 @@ void Expression::RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle) {
}
bool Call::IsUsingCallFeedbackSlot(Isolate* isolate) const {
bool Call::IsUsingCallFeedbackICSlot(Isolate* isolate) const {
CallType call_type = GetCallType(isolate);
return (call_type != POSSIBLY_EVAL_CALL);
if (IsUsingCallFeedbackSlot(isolate) || call_type == POSSIBLY_EVAL_CALL) {
return false;
}
return true;
}
bool Call::IsUsingCallFeedbackSlot(Isolate* isolate) const {
// SuperConstructorCall uses a CallConstructStub, which wants
// a Slot, not an IC slot.
return FLAG_experimental_classes && GetCallType(isolate) == SUPER_CALL;
}
FeedbackVectorRequirements Call::ComputeFeedbackRequirements(Isolate* isolate) {
int ic_slots = IsUsingCallFeedbackSlot(isolate) ? 1 : 0;
return FeedbackVectorRequirements(0, ic_slots);
int ic_slots = IsUsingCallFeedbackICSlot(isolate) ? 1 : 0;
int slots = IsUsingCallFeedbackSlot(isolate) ? 1 : 0;
// A Call uses either a slot or an IC slot.
DCHECK((ic_slots & slots) == 0);
return FeedbackVectorRequirements(slots, ic_slots);
}
......
......@@ -1813,14 +1813,21 @@ class Call FINAL : public Expression {
virtual FeedbackVectorRequirements ComputeFeedbackRequirements(
Isolate* isolate) OVERRIDE;
void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) OVERRIDE {
call_feedback_slot_ = slot;
ic_slot_or_slot_ = slot.ToInt();
}
void SetFirstFeedbackSlot(FeedbackVectorSlot slot) OVERRIDE {
ic_slot_or_slot_ = slot.ToInt();
}
Code::Kind FeedbackICSlotKind(int index) OVERRIDE { return Code::CALL_IC; }
bool HasCallFeedbackSlot() const { return !call_feedback_slot_.IsInvalid(); }
FeedbackVectorICSlot CallFeedbackSlot() const {
DCHECK(!call_feedback_slot_.IsInvalid());
return call_feedback_slot_;
FeedbackVectorSlot CallFeedbackSlot() const {
DCHECK(ic_slot_or_slot_ != FeedbackVectorSlot::Invalid().ToInt());
return FeedbackVectorSlot(ic_slot_or_slot_);
}
FeedbackVectorICSlot CallFeedbackICSlot() const {
DCHECK(ic_slot_or_slot_ != FeedbackVectorICSlot::Invalid().ToInt());
return FeedbackVectorICSlot(ic_slot_or_slot_);
}
SmallMapList* GetReceiverTypes() OVERRIDE {
......@@ -1881,6 +1888,7 @@ class Call FINAL : public Expression {
// Helpers to determine how to handle the call.
CallType GetCallType(Isolate* isolate) const;
bool IsUsingCallFeedbackSlot(Isolate* isolate) const;
bool IsUsingCallFeedbackICSlot(Isolate* isolate) const;
#ifdef DEBUG
// Used to assert that the FullCodeGenerator records the return site.
......@@ -1891,7 +1899,7 @@ class Call FINAL : public Expression {
Call(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments,
int pos)
: Expression(zone, pos),
call_feedback_slot_(FeedbackVectorICSlot::Invalid()),
ic_slot_or_slot_(FeedbackVectorICSlot::Invalid().ToInt()),
expression_(expression),
arguments_(arguments),
bit_field_(IsUninitializedField::encode(false)) {
......@@ -1904,7 +1912,9 @@ class Call FINAL : public Expression {
private:
int local_id(int n) const { return base_id() + parent_num_ids() + n; }
FeedbackVectorICSlot call_feedback_slot_;
// We store this as an integer because we don't know if we have a slot or
// an ic slot until scoping time.
int ic_slot_or_slot_;
Expression* expression_;
ZoneList<Expression*>* arguments_;
Handle<JSFunction> target_;
......
......@@ -9346,14 +9346,15 @@ void HOptimizedGraphBuilder::VisitCall(Call* expr) {
HCallFunction* call_function =
New<HCallFunction>(function, argument_count);
call = call_function;
if (expr->is_uninitialized() && expr->HasCallFeedbackSlot()) {
if (expr->is_uninitialized() &&
expr->IsUsingCallFeedbackICSlot(isolate())) {
// We've never seen this call before, so let's have Crankshaft learn
// through the type vector.
Handle<SharedFunctionInfo> current_shared =
function_state()->compilation_info()->shared_info();
Handle<TypeFeedbackVector> vector =
handle(current_shared->feedback_vector(), isolate());
FeedbackVectorICSlot slot = expr->CallFeedbackSlot();
FeedbackVectorICSlot slot = expr->CallFeedbackICSlot();
call_function->SetVectorAndSlot(vector, slot);
}
}
......
......@@ -2904,7 +2904,7 @@ void FullCodeGenerator::EmitCall(Call* expr, CallICState::CallType call_type) {
// Record source position of the IC call.
SetSourcePosition(expr->position());
Handle<Code> ic = CodeFactory::CallIC(isolate(), arg_count, call_type).code();
__ Move(edx, Immediate(SmiFromSlot(expr->CallFeedbackSlot())));
__ Move(edx, Immediate(SmiFromSlot(expr->CallFeedbackICSlot())));
__ 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.
......
......@@ -2978,7 +2978,7 @@ void FullCodeGenerator::EmitCall(Call* expr, CallICState::CallType call_type) {
// Record source position of the IC call.
SetSourcePosition(expr->position());
Handle<Code> ic = CodeFactory::CallIC(isolate(), arg_count, call_type).code();
__ li(a3, Operand(SmiFromSlot(expr->CallFeedbackSlot())));
__ li(a3, Operand(SmiFromSlot(expr->CallFeedbackICSlot())));
__ lw(a1, MemOperand(sp, (arg_count + 1) * kPointerSize));
// Don't assign a type feedback id to the IC, since type feedback is provided
// by the vector above.
......
......@@ -120,6 +120,7 @@ class TypeFeedbackVector : public FixedArray {
// Conversion from a slot or ic slot to an integer index to the underlying
// array.
int GetIndex(FeedbackVectorSlot slot) const {
DCHECK(slot.ToInt() < first_ic_slot_index());
return kReservedIndexCount + ic_metadata_length() + slot.ToInt();
}
......
......@@ -532,8 +532,8 @@ void AstTyper::VisitCall(Call* expr) {
// Collect type feedback.
RECURSE(Visit(expr->expression()));
bool is_uninitialized = true;
if (expr->IsUsingCallFeedbackSlot(isolate())) {
FeedbackVectorICSlot slot = expr->CallFeedbackSlot();
if (expr->IsUsingCallFeedbackICSlot(isolate())) {
FeedbackVectorICSlot slot = expr->CallFeedbackICSlot();
is_uninitialized = oracle()->CallIsUninitialized(slot);
if (!expr->expression()->IsProperty() &&
oracle()->CallIsMonomorphic(slot)) {
......
......@@ -2906,7 +2906,7 @@ void FullCodeGenerator::EmitCall(Call* expr, CallICState::CallType call_type) {
// Record source position of the IC call.
SetSourcePosition(expr->position());
Handle<Code> ic = CodeFactory::CallIC(isolate(), arg_count, call_type).code();
__ Move(rdx, SmiFromSlot(expr->CallFeedbackSlot()));
__ Move(rdx, SmiFromSlot(expr->CallFeedbackICSlot()));
__ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize));
// Don't assign a type feedback id to the IC, since type feedback is provided
// by the vector above.
......
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