Commit a5c456ad authored by Jaroslav Sevcik's avatar Jaroslav Sevcik Committed by Commit Bot

[turbofan] Broker for more straightforward create lowering methods.

Bug: v8:7790
Change-Id: I543078d72c9ce40c6927b57fd81b555f90bbfbff
Reviewed-on: https://chromium-review.googlesource.com/1126764
Commit-Queue: Jaroslav Sevcik <jarin@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54277}
parent 4b7d253e
...@@ -838,6 +838,7 @@ Reduction JSCreateLowering::ReduceJSCreateArray(Node* node) { ...@@ -838,6 +838,7 @@ Reduction JSCreateLowering::ReduceJSCreateArray(Node* node) {
} }
Reduction JSCreateLowering::ReduceJSCreateArrayIterator(Node* node) { Reduction JSCreateLowering::ReduceJSCreateArrayIterator(Node* node) {
DisallowHandleDereference disallow_dereference;
DCHECK_EQ(IrOpcode::kJSCreateArrayIterator, node->opcode()); DCHECK_EQ(IrOpcode::kJSCreateArrayIterator, node->opcode());
CreateArrayIteratorParameters const& p = CreateArrayIteratorParameters const& p =
CreateArrayIteratorParametersOf(node->op()); CreateArrayIteratorParametersOf(node->op());
...@@ -849,7 +850,7 @@ Reduction JSCreateLowering::ReduceJSCreateArrayIterator(Node* node) { ...@@ -849,7 +850,7 @@ Reduction JSCreateLowering::ReduceJSCreateArrayIterator(Node* node) {
AllocationBuilder a(jsgraph(), js_heap_broker(), effect, control); AllocationBuilder a(jsgraph(), js_heap_broker(), effect, control);
a.Allocate(JSArrayIterator::kSize, NOT_TENURED, Type::OtherObject()); a.Allocate(JSArrayIterator::kSize, NOT_TENURED, Type::OtherObject());
a.Store(AccessBuilder::ForMap(), a.Store(AccessBuilder::ForMap(),
handle(native_context()->initial_array_iterator_map(), isolate())); native_context_ref().initial_array_iterator_map(js_heap_broker()));
a.Store(AccessBuilder::ForJSObjectPropertiesOrHash(), a.Store(AccessBuilder::ForJSObjectPropertiesOrHash(),
jsgraph()->EmptyFixedArrayConstant()); jsgraph()->EmptyFixedArrayConstant());
a.Store(AccessBuilder::ForJSObjectElements(), a.Store(AccessBuilder::ForJSObjectElements(),
...@@ -866,27 +867,29 @@ Reduction JSCreateLowering::ReduceJSCreateArrayIterator(Node* node) { ...@@ -866,27 +867,29 @@ Reduction JSCreateLowering::ReduceJSCreateArrayIterator(Node* node) {
namespace { namespace {
Context::Field ContextFieldForCollectionIterationKind( MapRef MapForCollectionIterationKind(const NativeContextRef& native_context,
CollectionKind collection_kind, IterationKind iteration_kind) { const JSHeapBroker* broker,
CollectionKind collection_kind,
IterationKind iteration_kind) {
switch (collection_kind) { switch (collection_kind) {
case CollectionKind::kSet: case CollectionKind::kSet:
switch (iteration_kind) { switch (iteration_kind) {
case IterationKind::kKeys: case IterationKind::kKeys:
UNREACHABLE(); UNREACHABLE();
case IterationKind::kValues: case IterationKind::kValues:
return Context::SET_VALUE_ITERATOR_MAP_INDEX; return native_context.set_value_iterator_map(broker);
case IterationKind::kEntries: case IterationKind::kEntries:
return Context::SET_KEY_VALUE_ITERATOR_MAP_INDEX; return native_context.set_key_value_iterator_map(broker);
} }
break; break;
case CollectionKind::kMap: case CollectionKind::kMap:
switch (iteration_kind) { switch (iteration_kind) {
case IterationKind::kKeys: case IterationKind::kKeys:
return Context::MAP_KEY_ITERATOR_MAP_INDEX; return native_context.map_key_iterator_map(broker);
case IterationKind::kValues: case IterationKind::kValues:
return Context::MAP_VALUE_ITERATOR_MAP_INDEX; return native_context.map_value_iterator_map(broker);
case IterationKind::kEntries: case IterationKind::kEntries:
return Context::MAP_KEY_VALUE_ITERATOR_MAP_INDEX; return native_context.map_key_value_iterator_map(broker);
} }
break; break;
} }
...@@ -896,6 +899,7 @@ Context::Field ContextFieldForCollectionIterationKind( ...@@ -896,6 +899,7 @@ Context::Field ContextFieldForCollectionIterationKind(
} // namespace } // namespace
Reduction JSCreateLowering::ReduceJSCreateCollectionIterator(Node* node) { Reduction JSCreateLowering::ReduceJSCreateCollectionIterator(Node* node) {
DisallowHandleDereference disallow_dereference;
DCHECK_EQ(IrOpcode::kJSCreateCollectionIterator, node->opcode()); DCHECK_EQ(IrOpcode::kJSCreateCollectionIterator, node->opcode());
CreateCollectionIteratorParameters const& p = CreateCollectionIteratorParameters const& p =
CreateCollectionIteratorParametersOf(node->op()); CreateCollectionIteratorParametersOf(node->op());
...@@ -911,10 +915,10 @@ Reduction JSCreateLowering::ReduceJSCreateCollectionIterator(Node* node) { ...@@ -911,10 +915,10 @@ Reduction JSCreateLowering::ReduceJSCreateCollectionIterator(Node* node) {
// Create the JSArrayIterator result. // Create the JSArrayIterator result.
AllocationBuilder a(jsgraph(), js_heap_broker(), effect, control); AllocationBuilder a(jsgraph(), js_heap_broker(), effect, control);
a.Allocate(JSCollectionIterator::kSize, NOT_TENURED, Type::OtherObject()); a.Allocate(JSCollectionIterator::kSize, NOT_TENURED, Type::OtherObject());
a.Store(AccessBuilder::ForMap(), a.Store(
handle(native_context()->get(ContextFieldForCollectionIterationKind( AccessBuilder::ForMap(),
p.collection_kind(), p.iteration_kind())), MapForCollectionIterationKind(native_context_ref(), js_heap_broker(),
isolate())); p.collection_kind(), p.iteration_kind()));
a.Store(AccessBuilder::ForJSObjectPropertiesOrHash(), a.Store(AccessBuilder::ForJSObjectPropertiesOrHash(),
jsgraph()->EmptyFixedArrayConstant()); jsgraph()->EmptyFixedArrayConstant());
a.Store(AccessBuilder::ForJSObjectElements(), a.Store(AccessBuilder::ForJSObjectElements(),
...@@ -928,11 +932,12 @@ Reduction JSCreateLowering::ReduceJSCreateCollectionIterator(Node* node) { ...@@ -928,11 +932,12 @@ Reduction JSCreateLowering::ReduceJSCreateCollectionIterator(Node* node) {
} }
Reduction JSCreateLowering::ReduceJSCreateBoundFunction(Node* node) { Reduction JSCreateLowering::ReduceJSCreateBoundFunction(Node* node) {
DisallowHandleDereference disallow_dereference;
DCHECK_EQ(IrOpcode::kJSCreateBoundFunction, node->opcode()); DCHECK_EQ(IrOpcode::kJSCreateBoundFunction, node->opcode());
CreateBoundFunctionParameters const& p = CreateBoundFunctionParameters const& p =
CreateBoundFunctionParametersOf(node->op()); CreateBoundFunctionParametersOf(node->op());
int const arity = static_cast<int>(p.arity()); int const arity = static_cast<int>(p.arity());
Handle<Map> const map = p.map(); MapRef const map(p.map());
Node* bound_target_function = NodeProperties::GetValueInput(node, 0); Node* bound_target_function = NodeProperties::GetValueInput(node, 0);
Node* bound_this = NodeProperties::GetValueInput(node, 1); Node* bound_this = NodeProperties::GetValueInput(node, 1);
Node* effect = NodeProperties::GetEffectInput(node); Node* effect = NodeProperties::GetEffectInput(node);
...@@ -1379,6 +1384,7 @@ Reduction JSCreateLowering::ReduceJSCreateBlockContext(Node* node) { ...@@ -1379,6 +1384,7 @@ Reduction JSCreateLowering::ReduceJSCreateBlockContext(Node* node) {
} }
Reduction JSCreateLowering::ReduceJSCreateObject(Node* node) { Reduction JSCreateLowering::ReduceJSCreateObject(Node* node) {
DisallowHandleDereference disallow_dereference;
DCHECK_EQ(IrOpcode::kJSCreateObject, node->opcode()); DCHECK_EQ(IrOpcode::kJSCreateObject, node->opcode());
Node* effect = NodeProperties::GetEffectInput(node); Node* effect = NodeProperties::GetEffectInput(node);
Node* control = NodeProperties::GetControlInput(node); Node* control = NodeProperties::GetControlInput(node);
...@@ -1386,15 +1392,16 @@ Reduction JSCreateLowering::ReduceJSCreateObject(Node* node) { ...@@ -1386,15 +1392,16 @@ Reduction JSCreateLowering::ReduceJSCreateObject(Node* node) {
Type prototype_type = NodeProperties::GetType(prototype); Type prototype_type = NodeProperties::GetType(prototype);
if (!prototype_type.IsHeapConstant()) return NoChange(); if (!prototype_type.IsHeapConstant()) return NoChange();
Handle<Map> instance_map; HeapObjectRef prototype_const = prototype_type.AsHeapConstant()->Ref();
Handle<HeapObject> prototype_const = prototype_type.AsHeapConstant()->Value(); auto maybe_instance_map =
MaybeHandle<Map> maybe_instance_map = prototype_const.TryGetObjectCreateMap(js_heap_broker());
Map::TryGetObjectCreateMap(isolate(), prototype_const); if (!maybe_instance_map) return NoChange();
if (!maybe_instance_map.ToHandle(&instance_map)) return NoChange(); MapRef instance_map = maybe_instance_map.value();
Node* properties = jsgraph()->EmptyFixedArrayConstant(); Node* properties = jsgraph()->EmptyFixedArrayConstant();
if (instance_map->is_dictionary_map()) { if (instance_map.is_dictionary_map()) {
DCHECK(prototype_const->IsNull()); DCHECK_EQ(prototype_const.type(js_heap_broker()).oddball_type(),
OddballType::kNull);
// Allocated an empty NameDictionary as backing store for the properties. // Allocated an empty NameDictionary as backing store for the properties.
Handle<Map> map(ReadOnlyRoots(isolate()).name_dictionary_map(), isolate()); Handle<Map> map(ReadOnlyRoots(isolate()).name_dictionary_map(), isolate());
int capacity = int capacity =
...@@ -1433,9 +1440,9 @@ Reduction JSCreateLowering::ReduceJSCreateObject(Node* node) { ...@@ -1433,9 +1440,9 @@ Reduction JSCreateLowering::ReduceJSCreateObject(Node* node) {
properties = effect = a.Finish(); properties = effect = a.Finish();
} }
int const instance_size = instance_map->instance_size(); int const instance_size = instance_map.instance_size();
if (instance_size > kMaxRegularHeapObjectSize) return NoChange(); if (instance_size > kMaxRegularHeapObjectSize) return NoChange();
CHECK(!instance_map->IsInobjectSlackTrackingInProgress()); CHECK(!instance_map.IsInobjectSlackTrackingInProgress());
// Emit code to allocate the JSObject instance for the given // Emit code to allocate the JSObject instance for the given
// {instance_map}. // {instance_map}.
......
...@@ -139,6 +139,18 @@ HeapObjectType HeapObjectRef::type(const JSHeapBroker* broker) const { ...@@ -139,6 +139,18 @@ HeapObjectType HeapObjectRef::type(const JSHeapBroker* broker) const {
return broker->HeapObjectTypeFromMap(object<HeapObject>()->map()); return broker->HeapObjectTypeFromMap(object<HeapObject>()->map());
} }
base::Optional<MapRef> HeapObjectRef::TryGetObjectCreateMap(
const JSHeapBroker* broker) const {
AllowHandleDereference allow_handle_dereference;
Handle<Map> instance_map;
if (Map::TryGetObjectCreateMap(broker->isolate(), object<HeapObject>())
.ToHandle(&instance_map)) {
return MapRef(instance_map);
} else {
return base::Optional<MapRef>();
}
}
bool JSFunctionRef::HasBuiltinFunctionId() const { bool JSFunctionRef::HasBuiltinFunctionId() const {
AllowHandleDereference allow_handle_dereference; AllowHandleDereference allow_handle_dereference;
return object<JSFunction>()->shared()->HasBuiltinFunctionId(); return object<JSFunction>()->shared()->HasBuiltinFunctionId();
...@@ -383,6 +395,16 @@ bool MapRef::IsJSArrayMap() const { ...@@ -383,6 +395,16 @@ bool MapRef::IsJSArrayMap() const {
return object<Map>()->IsJSArrayMap(); return object<Map>()->IsJSArrayMap();
} }
bool MapRef::IsInobjectSlackTrackingInProgress() const {
AllowHandleDereference allow_handle_dereference;
return object<Map>()->IsInobjectSlackTrackingInProgress();
}
bool MapRef::is_dictionary_map() const {
AllowHandleDereference allow_handle_dereference;
return object<Map>()->is_dictionary_map();
}
bool MapRef::IsFixedCowArrayMap(const JSHeapBroker* broker) const { bool MapRef::IsFixedCowArrayMap(const JSHeapBroker* broker) const {
AllowHandleDereference allow_handle_dereference; AllowHandleDereference allow_handle_dereference;
return *object<Map>() == return *object<Map>() ==
...@@ -494,6 +516,48 @@ MapRef NativeContextRef::js_array_fast_elements_map_index( ...@@ -494,6 +516,48 @@ MapRef NativeContextRef::js_array_fast_elements_map_index(
broker->isolate())); broker->isolate()));
} }
MapRef NativeContextRef::initial_array_iterator_map(
const JSHeapBroker* broker) const {
AllowHandleDereference allow_handle_dereference;
return MapRef(handle(object<Context>()->initial_array_iterator_map(),
broker->isolate()));
}
MapRef NativeContextRef::set_value_iterator_map(
const JSHeapBroker* broker) const {
AllowHandleDereference allow_handle_dereference;
return MapRef(
handle(object<Context>()->set_value_iterator_map(), broker->isolate()));
}
MapRef NativeContextRef::set_key_value_iterator_map(
const JSHeapBroker* broker) const {
AllowHandleDereference allow_handle_dereference;
return MapRef(handle(object<Context>()->set_key_value_iterator_map(),
broker->isolate()));
}
MapRef NativeContextRef::map_key_iterator_map(
const JSHeapBroker* broker) const {
AllowHandleDereference allow_handle_dereference;
return MapRef(
handle(object<Context>()->map_key_iterator_map(), broker->isolate()));
}
MapRef NativeContextRef::map_value_iterator_map(
const JSHeapBroker* broker) const {
AllowHandleDereference allow_handle_dereference;
return MapRef(
handle(object<Context>()->map_value_iterator_map(), broker->isolate()));
}
MapRef NativeContextRef::map_key_value_iterator_map(
const JSHeapBroker* broker) const {
AllowHandleDereference allow_handle_dereference;
return MapRef(handle(object<Context>()->map_key_value_iterator_map(),
broker->isolate()));
}
} // namespace compiler } // namespace compiler
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
...@@ -118,6 +118,8 @@ class HeapObjectRef : public ObjectRef { ...@@ -118,6 +118,8 @@ class HeapObjectRef : public ObjectRef {
HeapObjectType type(const JSHeapBroker* broker) const; HeapObjectType type(const JSHeapBroker* broker) const;
MapRef map(const JSHeapBroker* broker) const; MapRef map(const JSHeapBroker* broker) const;
base::Optional<MapRef> TryGetObjectCreateMap(
const JSHeapBroker* broker) const;
private: private:
friend class JSHeapBroker; friend class JSHeapBroker;
...@@ -203,6 +205,12 @@ class NativeContextRef : public ContextRef { ...@@ -203,6 +205,12 @@ class NativeContextRef : public ContextRef {
MapRef sloppy_arguments_map(const JSHeapBroker* broker) const; MapRef sloppy_arguments_map(const JSHeapBroker* broker) const;
MapRef strict_arguments_map(const JSHeapBroker* broker) const; MapRef strict_arguments_map(const JSHeapBroker* broker) const;
MapRef js_array_fast_elements_map_index(const JSHeapBroker* broker) const; MapRef js_array_fast_elements_map_index(const JSHeapBroker* broker) const;
MapRef initial_array_iterator_map(const JSHeapBroker* broker) const;
MapRef set_value_iterator_map(const JSHeapBroker* broker) const;
MapRef set_key_value_iterator_map(const JSHeapBroker* broker) const;
MapRef map_key_iterator_map(const JSHeapBroker* broker) const;
MapRef map_value_iterator_map(const JSHeapBroker* broker) const;
MapRef map_key_value_iterator_map(const JSHeapBroker* broker) const;
}; };
class NameRef : public HeapObjectRef { class NameRef : public HeapObjectRef {
...@@ -254,6 +262,9 @@ class MapRef : public HeapObjectRef { ...@@ -254,6 +262,9 @@ class MapRef : public HeapObjectRef {
bool IsJSArrayMap() const; bool IsJSArrayMap() const;
bool IsFixedCowArrayMap(const JSHeapBroker* broker) const; bool IsFixedCowArrayMap(const JSHeapBroker* broker) const;
bool is_dictionary_map() const;
bool IsInobjectSlackTrackingInProgress() const;
}; };
class FixedArrayBaseRef : public HeapObjectRef { class FixedArrayBaseRef : public HeapObjectRef {
......
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