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