[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:
Georg Neis 2018-08-02 12:49:02 +02:00 committed by Commit Bot
parent be91e8b18d
commit 3c555d2d6f
5 changed files with 30 additions and 25 deletions

View File

@ -219,11 +219,11 @@ Reduction JSCallReducer::ReduceArrayConstructor(Node* node) {
// Turn the {node} into a {JSCreateArray} call.
DCHECK_LE(2u, p.arity());
Handle<AllocationSite> site;
size_t const arity = p.arity() - 2;
NodeProperties::ReplaceValueInput(node, target, 0);
NodeProperties::ReplaceValueInput(node, target, 1);
NodeProperties::ChangeOp(node, javascript()->CreateArray(arity, site));
NodeProperties::ChangeOp(
node, javascript()->CreateArray(arity, MaybeHandle<AllocationSite>()));
return Changed(node);
}
@ -1536,7 +1536,7 @@ Reduction JSCallReducer::ReduceArrayMap(Node* node,
// Even though {JSCreateArray} is not marked as {kNoThrow}, we can elide the
// exceptional projections because it cannot throw with the given parameters.
Node* a = control = effect = graph()->NewNode(
javascript()->CreateArray(1, Handle<AllocationSite>::null()),
javascript()->CreateArray(1, MaybeHandle<AllocationSite>()),
array_constructor, array_constructor, original_length, context,
outer_frame_state, effect, control);

View File

@ -692,9 +692,12 @@ Reduction JSCreateLowering::ReduceJSCreateArray(Node* node) {
DCHECK_EQ(IrOpcode::kJSCreateArray, node->opcode());
CreateArrayParameters const& p = CreateArrayParametersOf(node->op());
int const arity = static_cast<int>(p.arity());
base::Optional<AllocationSiteRef> site;
if (!p.site().is_null()) {
site = AllocationSiteRef(js_heap_broker(), p.site());
base::Optional<AllocationSiteRef> site_ref;
{
Handle<AllocationSite> site;
if (p.site().ToHandle(&site)) {
site_ref = AllocationSiteRef(js_heap_broker(), site);
}
}
PretenureFlag pretenure = NOT_TENURED;
JSFunctionRef constructor = native_context_ref().array_function();
@ -728,14 +731,14 @@ Reduction JSCreateLowering::ReduceJSCreateArray(Node* node) {
bool can_inline_call = false;
// Check if we have a feedback {site} on the {node}.
if (site) {
ElementsKind elements_kind = site->GetElementsKind();
if (site_ref) {
ElementsKind elements_kind = site_ref->GetElementsKind();
if (initial_map.elements_kind() != elements_kind) {
initial_map = initial_map.AsElementsKind(elements_kind);
}
can_inline_call = site->CanInlineCall();
pretenure = dependencies()->DependOnPretenureMode(*site);
dependencies()->DependOnElementsKind(*site);
can_inline_call = site_ref->CanInlineCall();
pretenure = dependencies()->DependOnPretenureMode(*site_ref);
dependencies()->DependOnElementsKind(*site_ref);
} else {
can_inline_call = isolate()->IsArrayConstructorIntact();
}
@ -821,7 +824,7 @@ Reduction JSCreateLowering::ReduceJSCreateArray(Node* node) {
// TODO(bmeurer): Optimize the subclassing case.
if (target != new_target) return NoChange();
return ReduceNewArrayToStubCall(node, site);
return ReduceNewArrayToStubCall(node, site_ref);
}
Reduction JSCreateLowering::ReduceJSCreateArrayIterator(Node* node) {

View File

@ -359,14 +359,15 @@ void JSGenericLowering::LowerJSCreateArguments(Node* node) {
void JSGenericLowering::LowerJSCreateArray(Node* node) {
CreateArrayParameters const& p = CreateArrayParametersOf(node->op());
int const arity = static_cast<int>(p.arity());
Handle<AllocationSite> const site = p.site();
auto call_descriptor = Linkage::GetStubCallDescriptor(
zone(), ArrayConstructorDescriptor{}, arity + 1,
CallDescriptor::kNeedsFrameState, node->op()->properties());
Node* stub_code = jsgraph()->ArrayConstructorStubConstant();
Node* stub_arity = jsgraph()->Int32Constant(arity);
Node* type_info = site.is_null() ? jsgraph()->UndefinedConstant()
: jsgraph()->HeapConstant(site);
MaybeHandle<AllocationSite> const maybe_site = p.site();
Handle<AllocationSite> site;
Node* type_info = maybe_site.ToHandle(&site) ? jsgraph()->HeapConstant(site)
: jsgraph()->UndefinedConstant();
Node* receiver = jsgraph()->UndefinedConstant();
node->InsertInput(zone(), 0, stub_code);
node->InsertInput(zone(), 3, stub_arity);

View File

@ -363,7 +363,7 @@ CreateArgumentsType const& CreateArgumentsTypeOf(const Operator* op) {
bool operator==(CreateArrayParameters const& lhs,
CreateArrayParameters const& rhs) {
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) {
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) {
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;
}
@ -1111,8 +1112,8 @@ const Operator* JSOperatorBuilder::CreateArguments(CreateArgumentsType type) {
type); // parameter
}
const Operator* JSOperatorBuilder::CreateArray(size_t arity,
Handle<AllocationSite> site) {
const Operator* JSOperatorBuilder::CreateArray(
size_t arity, MaybeHandle<AllocationSite> site) {
// constructor, new_target, arg1, ..., argN
int const value_input_count = static_cast<int>(arity) + 2;
CreateArrayParameters parameters(arity, site);

View File

@ -7,7 +7,7 @@
#include "src/base/compiler-specific.h"
#include "src/globals.h"
#include "src/handles.h"
#include "src/maybe-handles.h"
#include "src/runtime/runtime.h"
#include "src/type-hints.h"
#include "src/vector-slot-pair.h"
@ -457,15 +457,15 @@ CreateArgumentsType const& CreateArgumentsTypeOf(const Operator* op);
// used as parameter by JSCreateArray operators.
class CreateArrayParameters final {
public:
explicit CreateArrayParameters(size_t arity, Handle<AllocationSite> site)
explicit CreateArrayParameters(size_t arity, MaybeHandle<AllocationSite> site)
: arity_(arity), site_(site) {}
size_t arity() const { return arity_; }
Handle<AllocationSite> site() const { return site_; }
MaybeHandle<AllocationSite> site() const { return site_; }
private:
size_t const arity_;
Handle<AllocationSite> const site_;
MaybeHandle<AllocationSite> const site_;
};
bool operator==(CreateArrayParameters const&, CreateArrayParameters const&);
@ -714,7 +714,7 @@ class V8_EXPORT_PRIVATE JSOperatorBuilder final
const Operator* Create();
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* CreateCollectionIterator(CollectionKind, IterationKind);
const Operator* CreateBoundFunction(size_t arity, Handle<Map> map);