[cleanup] Add accessors for operators with handles

Bug: v8:7517, v8:7310
Change-Id: Ic9a1ac8f4a928e1d5d8f807a0875c7314a7777fb
Reviewed-on: https://chromium-review.googlesource.com/946095
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51735}
This commit is contained in:
Sigurd Schneider 2018-03-05 15:15:57 +01:00 committed by Commit Bot
parent fd541d2e19
commit a233b08249
14 changed files with 27 additions and 13 deletions

View File

@ -1168,6 +1168,11 @@ const Operator* CommonOperatorBuilder::HeapConstant(
value); // parameter
}
Handle<HeapObject> HeapConstantOf(const Operator* op) {
DCHECK_EQ(IrOpcode::kHeapConstant, op->opcode());
return OpParameter<Handle<HeapObject>>(op);
}
const Operator* CommonOperatorBuilder::RelocatableInt32Constant(
int32_t value, RelocInfo::Mode rmode) {
return new (zone()) Operator1<RelocatablePtrConstantInfo>( // --

View File

@ -400,7 +400,9 @@ V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&,
V8_EXPORT_PRIVATE IfValueParameters const& IfValueParametersOf(
const Operator* op) WARN_UNUSED_RESULT;
const FrameStateInfo& FrameStateInfoOf(const Operator* op);
const FrameStateInfo& FrameStateInfoOf(const Operator* op) WARN_UNUSED_RESULT;
Handle<HeapObject> HeapConstantOf(const Operator* op) WARN_UNUSED_RESULT;
// Interface for building common operators that can be used at any level of IR,
// including JavaScript, mid-level, and low-level.

View File

@ -74,7 +74,7 @@ class IA32OperandGenerator final : public OperandGenerator {
#if 0
// Constants in new space cannot be used as immediates in V8 because
// the GC does not scan code objects when collecting the new generation.
Handle<HeapObject> value = OpParameter<Handle<HeapObject>>(node->op());
Handle<HeapObject> value = HeapConstantOf(node->op());
Isolate* isolate = value->GetIsolate();
return !isolate->heap()->InNewSpace(*value);
#else

View File

@ -296,7 +296,7 @@ class OperandGenerator {
case IrOpcode::kComment:
return Constant(OpParameter<ExternalReference>(node->op()));
case IrOpcode::kHeapConstant:
return Constant(OpParameter<Handle<HeapObject>>(node->op()));
return Constant(HeapConstantOf(node->op()));
case IrOpcode::kDeadValue: {
switch (DeadValueRepresentationOf(node->op())) {
case MachineRepresentation::kBit:

View File

@ -448,8 +448,7 @@ InstructionOperand OperandForDeopt(Isolate* isolate, OperandGenerator* g,
return InstructionOperand();
}
Handle<HeapObject> constant =
OpParameter<Handle<HeapObject>>(input->op());
Handle<HeapObject> constant = HeapConstantOf(input->op());
Heap::RootListIndex root_index;
if (isolate->heap()->IsRootHandle(constant, &root_index) &&
root_index == Heap::kOptimizedOutRootIndex) {

View File

@ -103,7 +103,7 @@ MaybeHandle<Context> GetSpecializationContext(Node* node, size_t* distance,
Maybe<OuterContext> maybe_outer) {
switch (node->opcode()) {
case IrOpcode::kHeapConstant: {
Handle<Object> object = OpParameter<Handle<HeapObject>>(node->op());
Handle<Object> object = HeapConstantOf(node->op());
if (object->IsContext()) return Handle<Context>::cast(object);
break;
}

View File

@ -1234,7 +1234,7 @@ Reduction JSCreateLowering::ReduceJSCreateFunctionContext(Node* node) {
Reduction JSCreateLowering::ReduceJSCreateWithContext(Node* node) {
DCHECK_EQ(IrOpcode::kJSCreateWithContext, node->opcode());
Handle<ScopeInfo> scope_info = OpParameter<Handle<ScopeInfo>>(node->op());
Handle<ScopeInfo> scope_info = ScopeInfoOf(node->op());
Node* object = NodeProperties::GetValueInput(node, 0);
Node* closure = NodeProperties::GetValueInput(node, 1);
Node* effect = NodeProperties::GetEffectInput(node);
@ -1298,7 +1298,7 @@ Reduction JSCreateLowering::ReduceJSCreateCatchContext(Node* node) {
Reduction JSCreateLowering::ReduceJSCreateBlockContext(Node* node) {
DCHECK_EQ(IrOpcode::kJSCreateBlockContext, node->opcode());
Handle<ScopeInfo> scope_info = OpParameter<Handle<ScopeInfo>>(node->op());
Handle<ScopeInfo> scope_info = ScopeInfoOf(node->op());
int const context_length = scope_info->ContextLength();
Node* const closure = NodeProperties::GetValueInput(node, 0);

View File

@ -522,7 +522,7 @@ void JSGenericLowering::LowerJSCreateWithContext(Node* node) {
}
void JSGenericLowering::LowerJSCreateBlockContext(Node* node) {
Handle<ScopeInfo> scope_info = OpParameter<Handle<ScopeInfo>>(node->op());
Handle<ScopeInfo> scope_info = ScopeInfoOf(node->op());
node->InsertInput(zone(), 0, jsgraph()->HeapConstant(scope_info));
ReplaceWithRuntimeCall(node, Runtime::kPushBlockContext);
}

View File

@ -1225,6 +1225,12 @@ const Operator* JSOperatorBuilder::CreateBlockContext(
scope_info); // parameter
}
Handle<ScopeInfo> ScopeInfoOf(const Operator* op) {
DCHECK(IrOpcode::kJSCreateBlockContext == op->opcode() ||
IrOpcode::kJSCreateWithContext == op->opcode());
return OpParameter<Handle<ScopeInfo>>(op);
}
#undef BINARY_OP_LIST
#undef CACHED_OP_LIST
#undef COMPARE_OP_LIST

View File

@ -639,6 +639,8 @@ CompareOperationHint CompareOperationHintOf(const Operator* op);
int GeneratorStoreRegisterCountOf(const Operator* op) WARN_UNUSED_RESULT;
int RestoreRegisterIndexOf(const Operator* op) WARN_UNUSED_RESULT;
Handle<ScopeInfo> ScopeInfoOf(const Operator* op) WARN_UNUSED_RESULT;
// Interface for building JavaScript-level operators, e.g. directly from the
// AST. Most operators have no parameters, thus can be globally shared for all
// graphs.

View File

@ -739,7 +739,7 @@ Type* Typer::Visitor::TypeNumberConstant(Node* node) {
}
Type* Typer::Visitor::TypeHeapConstant(Node* node) {
return TypeConstant(OpParameter<Handle<HeapObject>>(node->op()));
return TypeConstant(HeapConstantOf(node->op()));
}
Type* Typer::Visitor::TypeExternalConstant(Node* node) {

View File

@ -43,7 +43,7 @@ class JSConstantCacheTester : public HandleAndZoneScope,
Handle<HeapObject> handle(Node* node) {
CHECK_EQ(IrOpcode::kHeapConstant, node->opcode());
return OpParameter<Handle<HeapObject>>(node->op());
return HeapConstantOf(node->op());
}
Factory* factory() { return main_isolate()->factory(); }

View File

@ -181,7 +181,7 @@ class JSTypedLoweringTester : public HandleAndZoneScope {
void CheckHandle(Handle<HeapObject> expected, Node* result) {
CHECK_EQ(IrOpcode::kHeapConstant, result->opcode());
Handle<HeapObject> value = OpParameter<Handle<HeapObject>>(result->op());
Handle<HeapObject> value = HeapConstantOf(result->op());
CHECK_EQ(*expected, *value);
}
};

View File

@ -51,7 +51,7 @@ class ValueHelper {
void CheckHeapConstant(HeapObject* expected, Node* node) {
CHECK_EQ(IrOpcode::kHeapConstant, node->opcode());
CHECK_EQ(expected, *OpParameter<Handle<HeapObject>>(node->op()));
CHECK_EQ(expected, *HeapConstantOf(node->op()));
}
void CheckTrue(Node* node) {