Commit 8b7c1c24 authored by Mike Stanton's avatar Mike Stanton Committed by Commit Bot

[TurboFan] Brokerization of some literal bytecodes

The BytecodeGraphBuilder still looks at the heap. This CL mostly
eliminates heap lookups for:

* CreateArrayLiteral
* CreateObjectLiteral
* CreateRegExpLiteral

What remains is the lookup embedded in the creation of a VectorSlotPair,
which will be addressed in a subsequent change.

Bug: v8:7790
Change-Id: I5e4167f5542b84ed3684ad61f3dd1ef8ad84c96b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1745482
Commit-Queue: Michael Stanton <mvstanton@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63173}
parent 10a1ad25
...@@ -2007,20 +2007,19 @@ void BytecodeGraphBuilder::VisitCreateRestParameter() { ...@@ -2007,20 +2007,19 @@ void BytecodeGraphBuilder::VisitCreateRestParameter() {
} }
void BytecodeGraphBuilder::VisitCreateRegExpLiteral() { void BytecodeGraphBuilder::VisitCreateRegExpLiteral() {
Handle<String> constant_pattern = Handle<String>::cast( StringRef constant_pattern(
bytecode_iterator().GetConstantForIndexOperand(0, isolate())); broker(), bytecode_iterator().GetConstantForIndexOperand(0, isolate()));
int const slot_id = bytecode_iterator().GetIndexOperand(1); int const slot_id = bytecode_iterator().GetIndexOperand(1);
VectorSlotPair pair = CreateVectorSlotPair(slot_id); VectorSlotPair pair = CreateVectorSlotPair(slot_id);
int literal_flags = bytecode_iterator().GetFlagOperand(2); int literal_flags = bytecode_iterator().GetFlagOperand(2);
Node* literal = NewNode( Node* literal = NewNode(javascript()->CreateLiteralRegExp(
javascript()->CreateLiteralRegExp(constant_pattern, pair, literal_flags)); constant_pattern.object(), pair, literal_flags));
environment()->BindAccumulator(literal, Environment::kAttachFrameState); environment()->BindAccumulator(literal, Environment::kAttachFrameState);
} }
void BytecodeGraphBuilder::VisitCreateArrayLiteral() { void BytecodeGraphBuilder::VisitCreateArrayLiteral() {
Handle<ArrayBoilerplateDescription> array_boilerplate_description = ArrayBoilerplateDescriptionRef array_boilerplate_description(
Handle<ArrayBoilerplateDescription>::cast( broker(), bytecode_iterator().GetConstantForIndexOperand(0, isolate()));
bytecode_iterator().GetConstantForIndexOperand(0, isolate()));
int const slot_id = bytecode_iterator().GetIndexOperand(1); int const slot_id = bytecode_iterator().GetIndexOperand(1);
VectorSlotPair pair = CreateVectorSlotPair(slot_id); VectorSlotPair pair = CreateVectorSlotPair(slot_id);
int bytecode_flags = bytecode_iterator().GetFlagOperand(2); int bytecode_flags = bytecode_iterator().GetFlagOperand(2);
...@@ -2034,9 +2033,10 @@ void BytecodeGraphBuilder::VisitCreateArrayLiteral() { ...@@ -2034,9 +2033,10 @@ void BytecodeGraphBuilder::VisitCreateArrayLiteral() {
// TODO(mstarzinger): Thread through number of elements. The below number is // TODO(mstarzinger): Thread through number of elements. The below number is
// only an estimate and does not match {ArrayLiteral::values::length}. // only an estimate and does not match {ArrayLiteral::values::length}.
int number_of_elements = int number_of_elements =
array_boilerplate_description->constant_elements().length(); array_boilerplate_description.constants_elements_length();
Node* literal = NewNode(javascript()->CreateLiteralArray( Node* literal = NewNode(javascript()->CreateLiteralArray(
array_boilerplate_description, pair, literal_flags, number_of_elements)); array_boilerplate_description.object(), pair, literal_flags,
number_of_elements));
environment()->BindAccumulator(literal, Environment::kAttachFrameState); environment()->BindAccumulator(literal, Environment::kAttachFrameState);
} }
...@@ -2054,9 +2054,8 @@ void BytecodeGraphBuilder::VisitCreateArrayFromIterable() { ...@@ -2054,9 +2054,8 @@ void BytecodeGraphBuilder::VisitCreateArrayFromIterable() {
} }
void BytecodeGraphBuilder::VisitCreateObjectLiteral() { void BytecodeGraphBuilder::VisitCreateObjectLiteral() {
Handle<ObjectBoilerplateDescription> constant_properties = ObjectBoilerplateDescriptionRef constant_properties(
Handle<ObjectBoilerplateDescription>::cast( broker(), bytecode_iterator().GetConstantForIndexOperand(0, isolate()));
bytecode_iterator().GetConstantForIndexOperand(0, isolate()));
int const slot_id = bytecode_iterator().GetIndexOperand(1); int const slot_id = bytecode_iterator().GetIndexOperand(1);
VectorSlotPair pair = CreateVectorSlotPair(slot_id); VectorSlotPair pair = CreateVectorSlotPair(slot_id);
int bytecode_flags = bytecode_iterator().GetFlagOperand(2); int bytecode_flags = bytecode_iterator().GetFlagOperand(2);
...@@ -2064,9 +2063,9 @@ void BytecodeGraphBuilder::VisitCreateObjectLiteral() { ...@@ -2064,9 +2063,9 @@ void BytecodeGraphBuilder::VisitCreateObjectLiteral() {
interpreter::CreateObjectLiteralFlags::FlagsBits::decode(bytecode_flags); interpreter::CreateObjectLiteralFlags::FlagsBits::decode(bytecode_flags);
// TODO(mstarzinger): Thread through number of properties. The below number is // TODO(mstarzinger): Thread through number of properties. The below number is
// only an estimate and does not match {ObjectLiteral::properties_count}. // only an estimate and does not match {ObjectLiteral::properties_count}.
int number_of_properties = constant_properties->size(); int number_of_properties = constant_properties.size();
Node* literal = NewNode(javascript()->CreateLiteralObject( Node* literal = NewNode(javascript()->CreateLiteralObject(
constant_properties, pair, literal_flags, number_of_properties)); constant_properties.object(), pair, literal_flags, number_of_properties));
environment()->BindAccumulator(literal, Environment::kAttachFrameState); environment()->BindAccumulator(literal, Environment::kAttachFrameState);
} }
......
...@@ -75,6 +75,7 @@ enum class OddballType : uint8_t { ...@@ -75,6 +75,7 @@ enum class OddballType : uint8_t {
/* Subtypes of HeapObject */ \ /* Subtypes of HeapObject */ \
V(AccessorInfo) \ V(AccessorInfo) \
V(AllocationSite) \ V(AllocationSite) \
V(ArrayBoilerplateDescription) \
V(BigInt) \ V(BigInt) \
V(CallHandlerInfo) \ V(CallHandlerInfo) \
V(Cell) \ V(Cell) \
...@@ -89,6 +90,7 @@ enum class OddballType : uint8_t { ...@@ -89,6 +90,7 @@ enum class OddballType : uint8_t {
V(Map) \ V(Map) \
V(MutableHeapNumber) \ V(MutableHeapNumber) \
V(Name) \ V(Name) \
V(ObjectBoilerplateDescription) \
V(PropertyCell) \ V(PropertyCell) \
V(SharedFunctionInfo) \ V(SharedFunctionInfo) \
V(SourceTextModule) \ V(SourceTextModule) \
...@@ -614,6 +616,22 @@ class FixedArrayBaseRef : public HeapObjectRef { ...@@ -614,6 +616,22 @@ class FixedArrayBaseRef : public HeapObjectRef {
int length() const; int length() const;
}; };
class ArrayBoilerplateDescriptionRef : public HeapObjectRef {
public:
using HeapObjectRef::HeapObjectRef;
Handle<ArrayBoilerplateDescription> object() const;
int constants_elements_length() const;
};
class ObjectBoilerplateDescriptionRef : public HeapObjectRef {
public:
using HeapObjectRef::HeapObjectRef;
Handle<ObjectBoilerplateDescription> object() const;
int size() const;
};
class FixedArrayRef : public FixedArrayBaseRef { class FixedArrayRef : public FixedArrayBaseRef {
public: public:
using FixedArrayBaseRef::FixedArrayBaseRef; using FixedArrayBaseRef::FixedArrayBaseRef;
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "src/objects/js-array-buffer-inl.h" #include "src/objects/js-array-buffer-inl.h"
#include "src/objects/js-array-inl.h" #include "src/objects/js-array-inl.h"
#include "src/objects/js-regexp-inl.h" #include "src/objects/js-regexp-inl.h"
#include "src/objects/literal-objects-inl.h"
#include "src/objects/module-inl.h" #include "src/objects/module-inl.h"
#include "src/objects/objects-inl.h" #include "src/objects/objects-inl.h"
#include "src/objects/template-objects-inl.h" #include "src/objects/template-objects-inl.h"
...@@ -450,6 +451,31 @@ void JSTypedArrayData::Serialize(JSHeapBroker* broker) { ...@@ -450,6 +451,31 @@ void JSTypedArrayData::Serialize(JSHeapBroker* broker) {
} }
} }
class ArrayBoilerplateDescriptionData : public HeapObjectData {
public:
ArrayBoilerplateDescriptionData(JSHeapBroker* broker, ObjectData** storage,
Handle<ArrayBoilerplateDescription> object)
: HeapObjectData(broker, storage, object),
constants_elements_length_(object->constant_elements().length()) {}
int constants_elements_length() const { return constants_elements_length_; }
private:
int const constants_elements_length_;
};
class ObjectBoilerplateDescriptionData : public HeapObjectData {
public:
ObjectBoilerplateDescriptionData(JSHeapBroker* broker, ObjectData** storage,
Handle<ObjectBoilerplateDescription> object)
: HeapObjectData(broker, storage, object), size_(object->size()) {}
int size() const { return size_; }
private:
int const size_;
};
class JSDataViewData : public JSObjectData { class JSDataViewData : public JSObjectData {
public: public:
JSDataViewData(JSHeapBroker* broker, ObjectData** storage, JSDataViewData(JSHeapBroker* broker, ObjectData** storage,
...@@ -2825,6 +2851,22 @@ base::Optional<double> StringRef::ToNumber() { ...@@ -2825,6 +2851,22 @@ base::Optional<double> StringRef::ToNumber() {
return data()->AsString()->to_number(); return data()->AsString()->to_number();
} }
int ArrayBoilerplateDescriptionRef::constants_elements_length() const {
if (broker()->mode() == JSHeapBroker::kDisabled) {
AllowHandleDereference allow_handle_dereference;
return object()->constant_elements().length();
}
return data()->AsArrayBoilerplateDescription()->constants_elements_length();
}
int ObjectBoilerplateDescriptionRef::size() const {
if (broker()->mode() == JSHeapBroker::kDisabled) {
AllowHandleDereference allow_handle_dereference;
return object()->size();
}
return data()->AsObjectBoilerplateDescription()->size();
}
ObjectRef FixedArrayRef::get(int i) const { ObjectRef FixedArrayRef::get(int i) const {
if (broker()->mode() == JSHeapBroker::kDisabled) { if (broker()->mode() == JSHeapBroker::kDisabled) {
AllowHandleAllocation handle_allocation; AllowHandleAllocation handle_allocation;
......
...@@ -86,13 +86,19 @@ Reduction JSHeapCopyReducer::Reduce(Node* node) { ...@@ -86,13 +86,19 @@ Reduction JSHeapCopyReducer::Reduce(Node* node) {
} }
case IrOpcode::kJSCreateLiteralArray: case IrOpcode::kJSCreateLiteralArray:
case IrOpcode::kJSCreateLiteralObject: { case IrOpcode::kJSCreateLiteralObject: {
CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op()); if (!FLAG_concurrent_inlining) {
CreateLiteralParameters const& p =
CreateLiteralParametersOf(node->op());
FeedbackVectorRef(broker(), p.feedback().vector()).SerializeSlots(); FeedbackVectorRef(broker(), p.feedback().vector()).SerializeSlots();
}
break; break;
} }
case IrOpcode::kJSCreateLiteralRegExp: { case IrOpcode::kJSCreateLiteralRegExp: {
CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op()); if (!FLAG_concurrent_inlining) {
CreateLiteralParameters const& p =
CreateLiteralParametersOf(node->op());
FeedbackVectorRef(broker(), p.feedback().vector()).SerializeSlots(); FeedbackVectorRef(broker(), p.feedback().vector()).SerializeSlots();
}
break; break;
} }
case IrOpcode::kJSCreateWithContext: { case IrOpcode::kJSCreateWithContext: {
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "src/objects/code.h" #include "src/objects/code.h"
#include "src/objects/js-array-inl.h" #include "src/objects/js-array-inl.h"
#include "src/objects/js-regexp-inl.h" #include "src/objects/js-regexp-inl.h"
#include "src/objects/literal-objects-inl.h"
#include "src/objects/shared-function-info-inl.h" #include "src/objects/shared-function-info-inl.h"
#include "src/zone/zone-containers.h" #include "src/zone/zone-containers.h"
#include "src/zone/zone.h" #include "src/zone/zone.h"
...@@ -50,12 +51,9 @@ namespace compiler { ...@@ -50,12 +51,9 @@ namespace compiler {
V(CallRuntime) \ V(CallRuntime) \
V(CloneObject) \ V(CloneObject) \
V(CreateArrayFromIterable) \ V(CreateArrayFromIterable) \
V(CreateArrayLiteral) \
V(CreateEmptyArrayLiteral) \ V(CreateEmptyArrayLiteral) \
V(CreateEmptyObjectLiteral) \ V(CreateEmptyObjectLiteral) \
V(CreateMappedArguments) \ V(CreateMappedArguments) \
V(CreateObjectLiteral) \
V(CreateRegExpLiteral) \
V(CreateRestParameter) \ V(CreateRestParameter) \
V(CreateUnmappedArguments) \ V(CreateUnmappedArguments) \
V(Dec) \ V(Dec) \
...@@ -154,11 +152,14 @@ namespace compiler { ...@@ -154,11 +152,14 @@ namespace compiler {
V(CallWithSpread) \ V(CallWithSpread) \
V(Construct) \ V(Construct) \
V(ConstructWithSpread) \ V(ConstructWithSpread) \
V(CreateArrayLiteral) \
V(CreateBlockContext) \ V(CreateBlockContext) \
V(CreateCatchContext) \ V(CreateCatchContext) \
V(CreateClosure) \ V(CreateClosure) \
V(CreateEvalContext) \ V(CreateEvalContext) \
V(CreateFunctionContext) \ V(CreateFunctionContext) \
V(CreateObjectLiteral) \
V(CreateRegExpLiteral) \
V(CreateWithContext) \ V(CreateWithContext) \
V(GetIterator) \ V(GetIterator) \
V(GetSuperConstructor) \ V(GetSuperConstructor) \
...@@ -1282,6 +1283,33 @@ void SerializerForBackgroundCompilation::VisitMov( ...@@ -1282,6 +1283,33 @@ void SerializerForBackgroundCompilation::VisitMov(
environment()->register_hints(dst).Add(environment()->register_hints(src)); environment()->register_hints(dst).Add(environment()->register_hints(src));
} }
void SerializerForBackgroundCompilation::VisitCreateRegExpLiteral(
BytecodeArrayIterator* iterator) {
Handle<String> constant_pattern = Handle<String>::cast(
iterator->GetConstantForIndexOperand(0, broker()->isolate()));
StringRef description(broker(), constant_pattern);
environment()->accumulator_hints().Clear();
}
void SerializerForBackgroundCompilation::VisitCreateArrayLiteral(
BytecodeArrayIterator* iterator) {
Handle<ArrayBoilerplateDescription> array_boilerplate_description =
Handle<ArrayBoilerplateDescription>::cast(
iterator->GetConstantForIndexOperand(0, broker()->isolate()));
ArrayBoilerplateDescriptionRef description(broker(),
array_boilerplate_description);
environment()->accumulator_hints().Clear();
}
void SerializerForBackgroundCompilation::VisitCreateObjectLiteral(
BytecodeArrayIterator* iterator) {
Handle<ObjectBoilerplateDescription> constant_properties =
Handle<ObjectBoilerplateDescription>::cast(
iterator->GetConstantForIndexOperand(0, broker()->isolate()));
ObjectBoilerplateDescriptionRef description(broker(), constant_properties);
environment()->accumulator_hints().Clear();
}
void SerializerForBackgroundCompilation::VisitCreateFunctionContext( void SerializerForBackgroundCompilation::VisitCreateFunctionContext(
BytecodeArrayIterator* iterator) { BytecodeArrayIterator* iterator) {
ProcessCreateContext(iterator, 0); ProcessCreateContext(iterator, 0);
......
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