Commit 8791f01b authored by bmeurer's avatar bmeurer Committed by Commit bot

[ignition] Collect feedback for super constructor calls.

In order to optimize super constructor calls with ES6 classes, we need
some feedback for both the JSCallConstruct and the resulting JSCreate
nodes in TurboFan. Both already optimize perfectly when the see nodes
with JSFunction constants, so utilizing the existing CallIC machinery
here, enables us to optimize the super constructor calls right now w/o
a lot of effort.

Note that there are probably better ways to track this information,
for example we could do some tracking on the constructor functions;
this will however require serious changes in TurboFan and the runtime,
and would block progress on more important tasks.

R=mythria@chromium.org
BUG=v8:5517

Review-Url: https://codereview.chromium.org/2419423002
Cr-Commit-Position: refs/heads/master@{#40337}
parent 4c364e63
......@@ -2501,13 +2501,14 @@ void BytecodeGenerator::VisitCallSuper(Call* expr) {
// Call construct.
builder()->SetExpressionPosition(expr);
// Valid type feedback slots can only be greater than kReservedIndexCount.
// Assert that 0 cannot be valid a valid slot id.
STATIC_ASSERT(TypeFeedbackVector::kReservedIndexCount > 0);
// Type feedback is not necessary for super constructor calls. The type
// information can be inferred in most cases. Slot id 0 indicates type
// feedback is not required.
builder()->New(constructor, args, 0);
// TODO(turbofan): For now we do gather feedback on super constructor
// calls, utilizing the existing machinery to inline the actual call
// target and the JSCreate for the implicit receiver allocation. This
// is not an ideal solution for super constructor calls, but it gets
// the job done for now. In the long run we might want to revisit this
// and come up with a better way.
int const feedback_slot_index = feedback_index(expr->CallFeedbackICSlot());
builder()->New(constructor, args, feedback_slot_index);
}
void BytecodeGenerator::VisitCallNew(CallNew* expr) {
......
......@@ -115,7 +115,7 @@ bytecodes: [
B(LdaSmi), U8(1),
B(Star), R(3),
B(Ldar), R(0),
/* 118 E> */ B(New), R(2), R(3), U8(1), U8(0),
/* 118 E> */ B(New), R(2), R(3), U8(1), U8(2),
B(Star), R(2),
B(Ldar), R(this),
B(JumpIfNotHole), U8(4),
......@@ -170,7 +170,7 @@ bytecodes: [
/* 117 S> */ B(CallRuntime), U16(Runtime::k_GetSuperConstructor), R(1), U8(1),
B(Star), R(2),
B(Ldar), R(0),
/* 117 E> */ B(New), R(2), R(0), U8(0), U8(0),
/* 117 E> */ B(New), R(2), R(0), U8(0), U8(2),
B(Star), R(2),
B(Ldar), R(this),
B(JumpIfNotHole), U8(4),
......
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