Commit 294671e8 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[turbofan] Support GetSuperConstructor in serializer

Drive-by: also add support for trivial bytecodes such as LdaFalse.

Bug: v8:7790
Change-Id: I72626500096310899d37d57e3d0dd3bd54fddff4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1532066
Commit-Queue: Georg Neis <neis@chromium.org>
Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60460}
parent 539017b0
......@@ -729,6 +729,7 @@ class MapData : public HeapObjectData {
}
void SerializePrototype(JSHeapBroker* broker);
bool serialized_prototype() const { return serialized_prototype_; }
ObjectData* prototype() const {
CHECK(serialized_prototype_);
return prototype_;
......@@ -2898,6 +2899,11 @@ void MapRef::SerializePrototype() {
data()->AsMap()->SerializePrototype(broker());
}
bool MapRef::serialized_prototype() const {
CHECK_NE(broker()->mode(), JSHeapBroker::kDisabled);
return data()->AsMap()->serialized_prototype();
}
void ModuleRef::Serialize() {
if (broker()->mode() == JSHeapBroker::kDisabled) return;
CHECK_EQ(broker()->mode(), JSHeapBroker::kSerializing);
......
......@@ -461,6 +461,7 @@ class MapRef : public HeapObjectRef {
base::Optional<MapRef> AsElementsKind(ElementsKind kind) const;
void SerializePrototype();
bool serialized_prototype() const;
ObjectRef prototype() const;
void SerializeForElementLoad();
......
......@@ -353,8 +353,13 @@ Reduction JSNativeContextSpecialization::ReduceJSGetSuperConstructor(
if (!m.HasValue()) return NoChange();
JSFunctionRef function = m.Ref(broker()).AsJSFunction();
MapRef function_map = function.map();
// TODO(neis): Remove SerializePrototype call once brokerization is complete.
function_map.SerializePrototype();
if (!FLAG_concurrent_inlining) {
function_map.SerializePrototype();
} else if (!function_map.serialized_prototype()) {
TRACE_BROKER(broker(), "ReduceJSGetSuperConstructor: missing data for map "
<< function_map.object().address() << "\n");
return NoChange();
}
ObjectRef function_prototype = function_map.prototype();
// We can constant-fold the super constructor access if the
......
......@@ -320,8 +320,44 @@ void SerializerForBackgroundCompilation::VisitExtraWide(
UNREACHABLE();
}
void SerializerForBackgroundCompilation::VisitStackCheck(
BytecodeArrayIterator* iterator) {}
void SerializerForBackgroundCompilation::VisitGetSuperConstructor(
BytecodeArrayIterator* iterator) {
interpreter::Register dst = iterator->GetRegisterOperand(0);
environment()->register_hints(dst).Clear();
for (auto constant : environment()->accumulator_hints().constants()) {
// For JSNativeContextSpecialization::ReduceJSGetSuperConstructor.
if (!constant->IsJSFunction()) continue;
MapRef map(broker(),
handle(HeapObject::cast(*constant)->map(), broker()->isolate()));
map.SerializePrototype();
ObjectRef proto = map.prototype();
if (proto.IsHeapObject() && proto.AsHeapObject().map().is_constructor()) {
environment()->register_hints(dst).AddConstant(proto.object());
}
}
}
void SerializerForBackgroundCompilation::VisitLdaTrue(
BytecodeArrayIterator* iterator) {
environment()->accumulator_hints().Clear();
environment()->accumulator_hints().AddConstant(
broker()->isolate()->factory()->true_value());
}
void SerializerForBackgroundCompilation::VisitLdaFalse(
BytecodeArrayIterator* iterator) {
environment()->accumulator_hints().Clear();
environment()->accumulator_hints().AddConstant(
broker()->isolate()->factory()->false_value());
}
void SerializerForBackgroundCompilation::VisitLdaTheHole(
BytecodeArrayIterator* iterator) {
environment()->accumulator_hints().Clear();
environment()->accumulator_hints().AddConstant(
broker()->isolate()->factory()->the_hole_value());
}
void SerializerForBackgroundCompilation::VisitLdaUndefined(
BytecodeArrayIterator* iterator) {
......
......@@ -83,25 +83,26 @@ namespace compiler {
V(JumpIfUndefined) \
V(JumpIfUndefinedConstant)
#define INGORED_BYTECODE_LIST(V) \
V(CallNoFeedback) \
V(LdaNamedPropertyNoFeedback) \
V(StaNamedPropertyNoFeedback) \
V(TestEqual) \
V(TestEqualStrict) \
V(TestLessThan) \
V(TestGreaterThan) \
V(TestLessThanOrEqual) \
V(TestGreaterThanOrEqual) \
V(TestReferenceEqual) \
V(TestInstanceOf) \
V(TestUndetectable) \
V(TestNull) \
V(TestUndefined) \
V(TestTypeOf) \
V(ThrowReferenceErrorIfHole) \
V(ThrowSuperNotCalledIfHole) \
V(ThrowSuperAlreadyCalledIfNotHole)
#define INGORED_BYTECODE_LIST(V) \
V(CallNoFeedback) \
V(LdaNamedPropertyNoFeedback) \
V(StackCheck) \
V(StaNamedPropertyNoFeedback) \
V(TestEqual) \
V(TestEqualStrict) \
V(TestGreaterThan) \
V(TestGreaterThanOrEqual) \
V(TestInstanceOf) \
V(TestLessThan) \
V(TestLessThanOrEqual) \
V(TestNull) \
V(TestReferenceEqual) \
V(TestTypeOf) \
V(TestUndefined) \
V(TestUndetectable) \
V(ThrowReferenceErrorIfHole) \
V(ThrowSuperAlreadyCalledIfNotHole) \
V(ThrowSuperNotCalledIfHole)
#define SUPPORTED_BYTECODE_LIST(V) \
V(CallAnyReceiver) \
......@@ -118,7 +119,9 @@ namespace compiler {
V(ConstructWithSpread) \
V(CreateClosure) \
V(ExtraWide) \
V(GetSuperConstructor) \
V(Illegal) \
V(LdaFalse) \
V(LdaConstant) \
V(LdaGlobal) \
V(LdaGlobalInsideTypeof) \
......@@ -129,11 +132,12 @@ namespace compiler {
V(LdaNull) \
V(Ldar) \
V(LdaSmi) \
V(LdaTheHole) \
V(LdaTrue) \
V(LdaUndefined) \
V(LdaZero) \
V(Mov) \
V(Return) \
V(StackCheck) \
V(StaGlobal) \
V(StaInArrayLiteral) \
V(StaKeyedProperty) \
......
......@@ -182,6 +182,15 @@ TEST(SerializeConstructWithSpread) {
"}; f(); return f;");
}
TEST(SerializeConstructSuper) {
CheckForSerializedInlinee(
"class A {};"
"class B extends A { constructor() { super(); } };"
"function f() {"
" new B(); return A;"
"}; f(); return f;");
}
TEST(SerializeConditionalJump) {
CheckForSerializedInlinee(
"function g(callee) { callee(); };"
......
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