[turbofan] Turn a Handle parameter into a MaybeHandle.
R=sigurds@chromium.org Change-Id: I9d07847ef92ff7a512c1624b492b37b6991e3c56 Reviewed-on: https://chromium-review.googlesource.com/1160304 Reviewed-by: Sigurd Schneider <sigurds@chromium.org> Commit-Queue: Georg Neis <neis@chromium.org> Cr-Commit-Position: refs/heads/master@{#54867}
This commit is contained in:
parent
be91e8b18d
commit
3c555d2d6f
@ -219,11 +219,11 @@ Reduction JSCallReducer::ReduceArrayConstructor(Node* node) {
|
|||||||
|
|
||||||
// Turn the {node} into a {JSCreateArray} call.
|
// Turn the {node} into a {JSCreateArray} call.
|
||||||
DCHECK_LE(2u, p.arity());
|
DCHECK_LE(2u, p.arity());
|
||||||
Handle<AllocationSite> site;
|
|
||||||
size_t const arity = p.arity() - 2;
|
size_t const arity = p.arity() - 2;
|
||||||
NodeProperties::ReplaceValueInput(node, target, 0);
|
NodeProperties::ReplaceValueInput(node, target, 0);
|
||||||
NodeProperties::ReplaceValueInput(node, target, 1);
|
NodeProperties::ReplaceValueInput(node, target, 1);
|
||||||
NodeProperties::ChangeOp(node, javascript()->CreateArray(arity, site));
|
NodeProperties::ChangeOp(
|
||||||
|
node, javascript()->CreateArray(arity, MaybeHandle<AllocationSite>()));
|
||||||
return Changed(node);
|
return Changed(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1536,7 +1536,7 @@ Reduction JSCallReducer::ReduceArrayMap(Node* node,
|
|||||||
// Even though {JSCreateArray} is not marked as {kNoThrow}, we can elide the
|
// Even though {JSCreateArray} is not marked as {kNoThrow}, we can elide the
|
||||||
// exceptional projections because it cannot throw with the given parameters.
|
// exceptional projections because it cannot throw with the given parameters.
|
||||||
Node* a = control = effect = graph()->NewNode(
|
Node* a = control = effect = graph()->NewNode(
|
||||||
javascript()->CreateArray(1, Handle<AllocationSite>::null()),
|
javascript()->CreateArray(1, MaybeHandle<AllocationSite>()),
|
||||||
array_constructor, array_constructor, original_length, context,
|
array_constructor, array_constructor, original_length, context,
|
||||||
outer_frame_state, effect, control);
|
outer_frame_state, effect, control);
|
||||||
|
|
||||||
|
@ -692,9 +692,12 @@ Reduction JSCreateLowering::ReduceJSCreateArray(Node* node) {
|
|||||||
DCHECK_EQ(IrOpcode::kJSCreateArray, node->opcode());
|
DCHECK_EQ(IrOpcode::kJSCreateArray, node->opcode());
|
||||||
CreateArrayParameters const& p = CreateArrayParametersOf(node->op());
|
CreateArrayParameters const& p = CreateArrayParametersOf(node->op());
|
||||||
int const arity = static_cast<int>(p.arity());
|
int const arity = static_cast<int>(p.arity());
|
||||||
base::Optional<AllocationSiteRef> site;
|
base::Optional<AllocationSiteRef> site_ref;
|
||||||
if (!p.site().is_null()) {
|
{
|
||||||
site = AllocationSiteRef(js_heap_broker(), p.site());
|
Handle<AllocationSite> site;
|
||||||
|
if (p.site().ToHandle(&site)) {
|
||||||
|
site_ref = AllocationSiteRef(js_heap_broker(), site);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
PretenureFlag pretenure = NOT_TENURED;
|
PretenureFlag pretenure = NOT_TENURED;
|
||||||
JSFunctionRef constructor = native_context_ref().array_function();
|
JSFunctionRef constructor = native_context_ref().array_function();
|
||||||
@ -728,14 +731,14 @@ Reduction JSCreateLowering::ReduceJSCreateArray(Node* node) {
|
|||||||
bool can_inline_call = false;
|
bool can_inline_call = false;
|
||||||
|
|
||||||
// Check if we have a feedback {site} on the {node}.
|
// Check if we have a feedback {site} on the {node}.
|
||||||
if (site) {
|
if (site_ref) {
|
||||||
ElementsKind elements_kind = site->GetElementsKind();
|
ElementsKind elements_kind = site_ref->GetElementsKind();
|
||||||
if (initial_map.elements_kind() != elements_kind) {
|
if (initial_map.elements_kind() != elements_kind) {
|
||||||
initial_map = initial_map.AsElementsKind(elements_kind);
|
initial_map = initial_map.AsElementsKind(elements_kind);
|
||||||
}
|
}
|
||||||
can_inline_call = site->CanInlineCall();
|
can_inline_call = site_ref->CanInlineCall();
|
||||||
pretenure = dependencies()->DependOnPretenureMode(*site);
|
pretenure = dependencies()->DependOnPretenureMode(*site_ref);
|
||||||
dependencies()->DependOnElementsKind(*site);
|
dependencies()->DependOnElementsKind(*site_ref);
|
||||||
} else {
|
} else {
|
||||||
can_inline_call = isolate()->IsArrayConstructorIntact();
|
can_inline_call = isolate()->IsArrayConstructorIntact();
|
||||||
}
|
}
|
||||||
@ -821,7 +824,7 @@ Reduction JSCreateLowering::ReduceJSCreateArray(Node* node) {
|
|||||||
// TODO(bmeurer): Optimize the subclassing case.
|
// TODO(bmeurer): Optimize the subclassing case.
|
||||||
if (target != new_target) return NoChange();
|
if (target != new_target) return NoChange();
|
||||||
|
|
||||||
return ReduceNewArrayToStubCall(node, site);
|
return ReduceNewArrayToStubCall(node, site_ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
Reduction JSCreateLowering::ReduceJSCreateArrayIterator(Node* node) {
|
Reduction JSCreateLowering::ReduceJSCreateArrayIterator(Node* node) {
|
||||||
|
@ -359,14 +359,15 @@ void JSGenericLowering::LowerJSCreateArguments(Node* node) {
|
|||||||
void JSGenericLowering::LowerJSCreateArray(Node* node) {
|
void JSGenericLowering::LowerJSCreateArray(Node* node) {
|
||||||
CreateArrayParameters const& p = CreateArrayParametersOf(node->op());
|
CreateArrayParameters const& p = CreateArrayParametersOf(node->op());
|
||||||
int const arity = static_cast<int>(p.arity());
|
int const arity = static_cast<int>(p.arity());
|
||||||
Handle<AllocationSite> const site = p.site();
|
|
||||||
auto call_descriptor = Linkage::GetStubCallDescriptor(
|
auto call_descriptor = Linkage::GetStubCallDescriptor(
|
||||||
zone(), ArrayConstructorDescriptor{}, arity + 1,
|
zone(), ArrayConstructorDescriptor{}, arity + 1,
|
||||||
CallDescriptor::kNeedsFrameState, node->op()->properties());
|
CallDescriptor::kNeedsFrameState, node->op()->properties());
|
||||||
Node* stub_code = jsgraph()->ArrayConstructorStubConstant();
|
Node* stub_code = jsgraph()->ArrayConstructorStubConstant();
|
||||||
Node* stub_arity = jsgraph()->Int32Constant(arity);
|
Node* stub_arity = jsgraph()->Int32Constant(arity);
|
||||||
Node* type_info = site.is_null() ? jsgraph()->UndefinedConstant()
|
MaybeHandle<AllocationSite> const maybe_site = p.site();
|
||||||
: jsgraph()->HeapConstant(site);
|
Handle<AllocationSite> site;
|
||||||
|
Node* type_info = maybe_site.ToHandle(&site) ? jsgraph()->HeapConstant(site)
|
||||||
|
: jsgraph()->UndefinedConstant();
|
||||||
Node* receiver = jsgraph()->UndefinedConstant();
|
Node* receiver = jsgraph()->UndefinedConstant();
|
||||||
node->InsertInput(zone(), 0, stub_code);
|
node->InsertInput(zone(), 0, stub_code);
|
||||||
node->InsertInput(zone(), 3, stub_arity);
|
node->InsertInput(zone(), 3, stub_arity);
|
||||||
|
@ -363,7 +363,7 @@ CreateArgumentsType const& CreateArgumentsTypeOf(const Operator* op) {
|
|||||||
bool operator==(CreateArrayParameters const& lhs,
|
bool operator==(CreateArrayParameters const& lhs,
|
||||||
CreateArrayParameters const& rhs) {
|
CreateArrayParameters const& rhs) {
|
||||||
return lhs.arity() == rhs.arity() &&
|
return lhs.arity() == rhs.arity() &&
|
||||||
lhs.site().location() == rhs.site().location();
|
lhs.site().address() == rhs.site().address();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -374,13 +374,14 @@ bool operator!=(CreateArrayParameters const& lhs,
|
|||||||
|
|
||||||
|
|
||||||
size_t hash_value(CreateArrayParameters const& p) {
|
size_t hash_value(CreateArrayParameters const& p) {
|
||||||
return base::hash_combine(p.arity(), p.site().location());
|
return base::hash_combine(p.arity(), p.site().address());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& os, CreateArrayParameters const& p) {
|
std::ostream& operator<<(std::ostream& os, CreateArrayParameters const& p) {
|
||||||
os << p.arity();
|
os << p.arity();
|
||||||
if (!p.site().is_null()) os << ", " << Brief(*p.site());
|
Handle<AllocationSite> site;
|
||||||
|
if (p.site().ToHandle(&site)) os << ", " << Brief(*site);
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1111,8 +1112,8 @@ const Operator* JSOperatorBuilder::CreateArguments(CreateArgumentsType type) {
|
|||||||
type); // parameter
|
type); // parameter
|
||||||
}
|
}
|
||||||
|
|
||||||
const Operator* JSOperatorBuilder::CreateArray(size_t arity,
|
const Operator* JSOperatorBuilder::CreateArray(
|
||||||
Handle<AllocationSite> site) {
|
size_t arity, MaybeHandle<AllocationSite> site) {
|
||||||
// constructor, new_target, arg1, ..., argN
|
// constructor, new_target, arg1, ..., argN
|
||||||
int const value_input_count = static_cast<int>(arity) + 2;
|
int const value_input_count = static_cast<int>(arity) + 2;
|
||||||
CreateArrayParameters parameters(arity, site);
|
CreateArrayParameters parameters(arity, site);
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#include "src/base/compiler-specific.h"
|
#include "src/base/compiler-specific.h"
|
||||||
#include "src/globals.h"
|
#include "src/globals.h"
|
||||||
#include "src/handles.h"
|
#include "src/maybe-handles.h"
|
||||||
#include "src/runtime/runtime.h"
|
#include "src/runtime/runtime.h"
|
||||||
#include "src/type-hints.h"
|
#include "src/type-hints.h"
|
||||||
#include "src/vector-slot-pair.h"
|
#include "src/vector-slot-pair.h"
|
||||||
@ -457,15 +457,15 @@ CreateArgumentsType const& CreateArgumentsTypeOf(const Operator* op);
|
|||||||
// used as parameter by JSCreateArray operators.
|
// used as parameter by JSCreateArray operators.
|
||||||
class CreateArrayParameters final {
|
class CreateArrayParameters final {
|
||||||
public:
|
public:
|
||||||
explicit CreateArrayParameters(size_t arity, Handle<AllocationSite> site)
|
explicit CreateArrayParameters(size_t arity, MaybeHandle<AllocationSite> site)
|
||||||
: arity_(arity), site_(site) {}
|
: arity_(arity), site_(site) {}
|
||||||
|
|
||||||
size_t arity() const { return arity_; }
|
size_t arity() const { return arity_; }
|
||||||
Handle<AllocationSite> site() const { return site_; }
|
MaybeHandle<AllocationSite> site() const { return site_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
size_t const arity_;
|
size_t const arity_;
|
||||||
Handle<AllocationSite> const site_;
|
MaybeHandle<AllocationSite> const site_;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool operator==(CreateArrayParameters const&, CreateArrayParameters const&);
|
bool operator==(CreateArrayParameters const&, CreateArrayParameters const&);
|
||||||
@ -714,7 +714,7 @@ class V8_EXPORT_PRIVATE JSOperatorBuilder final
|
|||||||
|
|
||||||
const Operator* Create();
|
const Operator* Create();
|
||||||
const Operator* CreateArguments(CreateArgumentsType type);
|
const Operator* CreateArguments(CreateArgumentsType type);
|
||||||
const Operator* CreateArray(size_t arity, Handle<AllocationSite> site);
|
const Operator* CreateArray(size_t arity, MaybeHandle<AllocationSite> site);
|
||||||
const Operator* CreateArrayIterator(IterationKind);
|
const Operator* CreateArrayIterator(IterationKind);
|
||||||
const Operator* CreateCollectionIterator(CollectionKind, IterationKind);
|
const Operator* CreateCollectionIterator(CollectionKind, IterationKind);
|
||||||
const Operator* CreateBoundFunction(size_t arity, Handle<Map> map);
|
const Operator* CreateBoundFunction(size_t arity, Handle<Map> map);
|
||||||
|
Loading…
Reference in New Issue
Block a user