Cleanups: parsed_function()->function() => function()

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//881063003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43213 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
srdjan@google.com 2015-01-27 22:09:31 +00:00
parent 3c66f9be64
commit 110a74f954
12 changed files with 55 additions and 58 deletions

View file

@ -87,7 +87,7 @@ bool FlowGraph::ShouldReorderBlocks(const Function& function,
GrowableArray<BlockEntryInstr*>* FlowGraph::CodegenBlockOrder(
bool is_optimized) {
return ShouldReorderBlocks(parsed_function()->function(), is_optimized)
return ShouldReorderBlocks(function(), is_optimized)
? &optimized_block_order_
: &reverse_postorder_;
}
@ -855,7 +855,7 @@ void FlowGraph::Rename(GrowableArray<PhiInstr*>* live_phis,
if (!IsCompiledForOsr()) {
for (intptr_t i = parameter_count(); i < variable_count(); ++i) {
if (i == CurrentContextEnvIndex()) {
if (parsed_function()->function().IsClosureFunction()) {
if (function().IsClosureFunction()) {
CurrentContextInstr* context = new CurrentContextInstr();
context->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp.
AddToInitialDefinitions(context);

View file

@ -92,6 +92,9 @@ class FlowGraph : public ZoneAllocated {
ParsedFunction* parsed_function() const {
return parsed_function_;
}
const Function& function() const {
return parsed_function_->function();
}
intptr_t parameter_count() const {
return num_copied_params_ + num_non_copied_params_;
}
@ -108,7 +111,7 @@ class FlowGraph : public ZoneAllocated {
return num_non_copied_params_;
}
bool IsIrregexpFunction() const {
return parsed_function()->function().IsIrregexpFunction();
return function().IsIrregexpFunction();
}
LocalVariable* CurrentContextVar() const {

View file

@ -2919,7 +2919,7 @@ void FlowGraphAllocator::AllocateRegisters() {
}
if (FLAG_print_ssa_liveranges) {
const Function& function = flow_graph_.parsed_function()->function();
const Function& function = flow_graph_.function();
OS::Print("-- [before ssa allocator] ranges [%s] ---------\n",
function.ToFullyQualifiedCString());
@ -2960,7 +2960,7 @@ void FlowGraphAllocator::AllocateRegisters() {
entry->set_spill_slot_count(cpu_spill_slot_count_ + double_spill_slot_count);
if (FLAG_print_ssa_liveranges) {
const Function& function = flow_graph_.parsed_function()->function();
const Function& function = flow_graph_.function();
OS::Print("-- [after ssa allocator] ranges [%s] ---------\n",
function.ToFullyQualifiedCString());

View file

@ -1005,7 +1005,7 @@ void EffectGraphVisitor::Bailout(const char* reason) const {
void EffectGraphVisitor::InlineBailout(const char* reason) const {
owner()->parsed_function()->function().set_is_inlinable(false);
owner()->function().set_is_inlinable(false);
if (owner()->IsInlining()) owner()->Bailout(reason);
}
@ -1039,7 +1039,7 @@ void EffectGraphVisitor::VisitReturnNode(ReturnNode* node) {
// unchained so that captured variables can be inspected.
// No debugger check is done in native functions or for return
// statements for which there is no associated source position.
const Function& function = owner()->parsed_function()->function();
const Function& function = owner()->function();
if ((node->token_pos() != Scanner::kNoSourcePos) && !function.is_native()) {
AddInstruction(new(I) DebugStepCheckInstr(node->token_pos(),
RawPcDescriptors::kRuntimeCall));
@ -1143,7 +1143,7 @@ void ValueGraphVisitor::VisitTypeNode(TypeNode* node) {
ReturnDefinition(new(I) ConstantInstr(type));
} else {
const Class& instantiator_class = Class::ZoneHandle(
I, owner()->parsed_function()->function().Owner());
I, owner()->function().Owner());
Value* instantiator_value = BuildInstantiatorTypeArguments(
node->token_pos(), instantiator_class, NULL);
ReturnDefinition(new(I) InstantiateTypeInstr(
@ -1396,7 +1396,7 @@ void EffectGraphVisitor::BuildTypecheckPushArguments(
PushArgumentInstr** push_instantiator_result,
PushArgumentInstr** push_instantiator_type_arguments_result) {
const Class& instantiator_class = Class::Handle(
I, owner()->parsed_function()->function().Owner());
I, owner()->function().Owner());
// Since called only when type tested against is not instantiated.
ASSERT(instantiator_class.NumTypeParameters() > 0);
Value* instantiator_type_arguments = NULL;
@ -1426,7 +1426,7 @@ void EffectGraphVisitor::BuildTypecheckArguments(
Value* instantiator = NULL;
Value* instantiator_type_arguments = NULL;
const Class& instantiator_class = Class::Handle(
I, owner()->parsed_function()->function().Owner());
I, owner()->function().Owner());
// Since called only when type tested against is not instantiated.
ASSERT(instantiator_class.NumTypeParameters() > 0);
instantiator = BuildInstantiator(instantiator_class);
@ -2449,7 +2449,7 @@ void EffectGraphVisitor::VisitClosureNode(ClosureNode* node) {
ASSERT(function.context_scope() == ContextScope::null());
function.set_context_scope(context_scope);
const Class& cls = Class::Handle(
I, owner()->parsed_function()->function().Owner());
I, owner()->function().Owner());
// The closure is now properly setup, add it to the lookup table.
// It is possible that the compiler creates more than one function
// object for the same closure, e.g. when inlining nodes from
@ -2485,7 +2485,7 @@ void EffectGraphVisitor::VisitClosureNode(ClosureNode* node) {
Closure::type_arguments_offset());
ASSERT(cls.instance_size() == Closure::InstanceSize());
const Class& instantiator_class = Class::Handle(
I, owner()->parsed_function()->function().Owner());
I, owner()->function().Owner());
type_arguments = BuildInstantiatorTypeArguments(node->token_pos(),
instantiator_class,
NULL);
@ -2807,8 +2807,7 @@ void EffectGraphVisitor::VisitConstructorCallNode(ConstructorCallNode* node) {
Value* EffectGraphVisitor::BuildInstantiator(const Class& instantiator_class) {
ASSERT(instantiator_class.NumTypeParameters() > 0);
Function& outer_function =
Function::Handle(I, owner()->parsed_function()->function().raw());
Function& outer_function = Function::Handle(I, owner()->function().raw());
while (outer_function.IsLocalFunction()) {
outer_function = outer_function.parent_function();
}
@ -2844,8 +2843,7 @@ Value* EffectGraphVisitor::BuildInstantiatorTypeArguments(
type_arguments = type_arguments.Canonicalize();
return Bind(new(I) ConstantInstr(type_arguments));
}
Function& outer_function =
Function::Handle(I, owner()->parsed_function()->function().raw());
Function& outer_function = Function::Handle(I, owner()->function().raw());
while (outer_function.IsLocalFunction()) {
outer_function = outer_function.parent_function();
}
@ -2884,7 +2882,7 @@ Value* EffectGraphVisitor::BuildInstantiatedTypeArguments(
}
// The type arguments are uninstantiated.
const Class& instantiator_class = Class::ZoneHandle(
I, owner()->parsed_function()->function().Owner());
I, owner()->function().Owner());
Value* instantiator_value =
BuildInstantiatorTypeArguments(token_pos, instantiator_class, NULL);
const bool use_instantiator_type_args =
@ -3190,7 +3188,7 @@ LoadLocalInstr* EffectGraphVisitor::BuildLoadThisVar(LocalScope* scope) {
void EffectGraphVisitor::VisitNativeBodyNode(NativeBodyNode* node) {
const Function& function = owner()->parsed_function()->function();
const Function& function = owner()->function();
if (!function.IsClosureFunction()) {
MethodRecognizer::Kind kind = MethodRecognizer::RecognizeKind(function);
switch (kind) {
@ -3711,7 +3709,7 @@ void ValueGraphVisitor::VisitStoreIndexedNode(StoreIndexedNode* node) {
bool EffectGraphVisitor::HasContextScope() const {
const ContextScope& context_scope = ContextScope::Handle(
owner()->parsed_function()->function().context_scope());
owner()->function().context_scope());
return !context_scope.IsNull() && (context_scope.num_variables() > 0);
}
@ -3769,7 +3767,7 @@ void EffectGraphVisitor::VisitSequenceNode(SequenceNode* node) {
// the captured parameters from the frame into the context.
if (is_top_level_sequence) {
ASSERT(scope->context_level() == 1);
const Function& function = owner()->parsed_function()->function();
const Function& function = owner()->function();
const int num_params = function.NumParameters();
int param_frame_index = (num_params == function.num_fixed_parameters()) ?
(kParamEndSlotFromFp + num_params) : kFirstLocalSlotFromFp;
@ -3807,7 +3805,7 @@ void EffectGraphVisitor::VisitSequenceNode(SequenceNode* node) {
// This check may be deleted if the generated code is leaf.
// Native functions don't need a stack check at entry.
const Function& function = owner()->parsed_function()->function();
const Function& function = owner()->function();
if (is_top_level_sequence && !function.is_native()) {
// Always allocate CheckOverflowInstr so that deopt-ids match regardless
// if we inline or not.
@ -3824,7 +3822,7 @@ void EffectGraphVisitor::VisitSequenceNode(SequenceNode* node) {
}
if (FLAG_enable_type_checks && is_top_level_sequence) {
const Function& function = owner()->parsed_function()->function();
const Function& function = owner()->function();
const int num_params = function.NumParameters();
int pos = 0;
if (function.IsConstructor()) {
@ -3856,8 +3854,7 @@ void EffectGraphVisitor::VisitSequenceNode(SequenceNode* node) {
// If this node sequence is the body of an async closure leave room for a
// preamble. The preamble is generated after visiting the body.
GotoInstr* preamble_start = NULL;
if (is_top_level_sequence &&
(owner()->parsed_function()->function().is_async_closure())) {
if (is_top_level_sequence && (owner()->function().is_async_closure())) {
JoinEntryInstr* preamble_end = new(I) JoinEntryInstr(
owner()->AllocateBlockId(), owner()->try_index());
ASSERT(exit() != NULL);
@ -3882,8 +3879,7 @@ void EffectGraphVisitor::VisitSequenceNode(SequenceNode* node) {
// Continuation part:
// After generating the CFG for the body we can create the preamble because we
// know exactly how many continuation states we need.
if (is_top_level_sequence &&
(owner()->parsed_function()->function().is_async_closure())) {
if (is_top_level_sequence && (owner()->function().is_async_closure())) {
ASSERT(preamble_start != NULL);
// We are at the top level. Fetch the corresponding scope.
LocalScope* top_scope = node->scope();

View file

@ -151,6 +151,7 @@ class FlowGraphBuilder: public ValueObject {
FlowGraph* BuildGraph();
ParsedFunction* parsed_function() const { return parsed_function_; }
const Function& function() const { return parsed_function_->function(); }
const ZoneGrowableArray<const ICData*>& ic_data_array() const {
return ic_data_array_;
}

View file

@ -135,7 +135,7 @@ FlowGraphCompiler::FlowGraphCompiler(
(*deopt_id_to_ic_data_)[i] = NULL;
}
const Array& old_saved_icdata = Array::Handle(isolate(),
flow_graph->parsed_function()->function().ic_data_array());
flow_graph->function().ic_data_array());
const intptr_t saved_len =
old_saved_icdata.IsNull() ? 0 : old_saved_icdata.Length();
for (intptr_t i = 0; i < saved_len; i++) {

View file

@ -197,7 +197,7 @@ class CallSites : public ValueObject {
FlowGraph* flow_graph)
: call(call_arg),
ratio(0.0),
caller(&flow_graph->parsed_function()->function()) {}
caller(&flow_graph->function()) {}
};
struct StaticCallInfo {
@ -207,7 +207,7 @@ class CallSites : public ValueObject {
StaticCallInfo(StaticCallInstr* value, FlowGraph* flow_graph)
: call(value),
ratio(0.0),
caller(&flow_graph->parsed_function()->function()) {}
caller(&flow_graph->function()) {}
};
struct ClosureCallInfo {
@ -215,7 +215,7 @@ class CallSites : public ValueObject {
const Function* caller;
ClosureCallInfo(ClosureCallInstr* value, FlowGraph* flow_graph)
: call(value),
caller(&flow_graph->parsed_function()->function()) {}
caller(&flow_graph->function()) {}
};
const GrowableArray<InstanceCallInfo>& instance_calls() const {
@ -291,7 +291,7 @@ class CallSites : public ValueObject {
FlowGraph* graph,
intptr_t depth,
GrowableArray<InlinedInfo>* inlined_info) {
const Function* caller = &graph->parsed_function()->function();
const Function* caller = &graph->function();
Function& target = Function::ZoneHandle();
for (BlockIterator block_it = graph->postorder_iterator();
!block_it.Done();
@ -358,7 +358,7 @@ class CallSites : public ValueObject {
// Method not inlined because inlining too deep and method
// not recognized.
if (FLAG_print_inlining_tree) {
const Function* caller = &graph->parsed_function()->function();
const Function* caller = &graph->function();
const Function* target =
&Function::ZoneHandle(
instance_call->ic_data().GetTargetAt(0));
@ -375,7 +375,7 @@ class CallSites : public ValueObject {
// Method not inlined because inlining too deep and method
// not recognized.
if (FLAG_print_inlining_tree) {
const Function* caller = &graph->parsed_function()->function();
const Function* caller = &graph->function();
const Function* target = &static_call->function();
inlined_info->Add(InlinedInfo(
caller, target, depth + 1, static_call, "Too deep"));
@ -534,7 +534,7 @@ class CallSiteInliner : public ValueObject {
void InlineCalls() {
// If inlining depth is less then one abort.
if (FLAG_inlining_depth_threshold < 1) return;
if (caller_graph_->parsed_function()->function().deoptimization_counter() >=
if (caller_graph_->function().deoptimization_counter() >=
FLAG_deoptimization_counter_inlining_threshold) {
return;
}
@ -851,7 +851,7 @@ class CallSiteInliner : public ValueObject {
caller_graph()->AddToDeferredPrefixes(callee_graph->deferred_prefixes());
FlowGraphInliner::SetInliningId(*callee_graph,
inliner_->NextInlineId(callee_graph->parsed_function()->function()));
inliner_->NextInlineId(callee_graph->function()));
// We allocate a ZoneHandle for the unoptimized code so that it cannot be
// disconnected from its function during the rest of compilation.
Code::ZoneHandle(unoptimized_code.raw());
@ -1733,7 +1733,7 @@ static uint16_t ClampUint16(intptr_t v) {
void FlowGraphInliner::CollectGraphInfo(FlowGraph* flow_graph, bool force) {
const Function& function = flow_graph->parsed_function()->function();
const Function& function = flow_graph->function();
if (force || (function.optimized_instruction_count() == 0)) {
GraphInfoCollector info;
info.Collect(*flow_graph);
@ -1788,7 +1788,7 @@ void FlowGraphInliner::Inline() {
// We might later use it for an early bailout from the inlining.
CollectGraphInfo(flow_graph_);
const Function& top = flow_graph_->parsed_function()->function();
const Function& top = flow_graph_->function();
if ((FLAG_inlining_filter != NULL) &&
(strstr(top.ToFullyQualifiedCString(), FLAG_inlining_filter) == NULL)) {
return;
@ -1799,7 +1799,7 @@ void FlowGraphInliner::Inline() {
if (FLAG_trace_inlining &&
(FLAG_print_flow_graph || FLAG_print_flow_graph_optimized)) {
OS::Print("Before Inlining of %s\n", flow_graph_->
parsed_function()->function().ToFullyQualifiedCString());
function().ToFullyQualifiedCString());
FlowGraphPrinter printer(*flow_graph_);
printer.PrintBlocks();
}
@ -1816,7 +1816,7 @@ void FlowGraphInliner::Inline() {
OS::Print("Inlining growth factor: %f\n", inliner.GrowthFactor());
if (FLAG_print_flow_graph || FLAG_print_flow_graph_optimized) {
OS::Print("After Inlining of %s\n", flow_graph_->
parsed_function()->function().ToFullyQualifiedCString());
function().ToFullyQualifiedCString());
FlowGraphPrinter printer(*flow_graph_);
printer.PrintBlocks();
}

View file

@ -196,7 +196,7 @@ bool FlowGraphOptimizer::TryCreateICData(InstanceCallInstr* call) {
// TODO(srdjan): Prevent modification of ICData object that is
// referenced in assembly code.
ICData& ic_data = ICData::ZoneHandle(Z, ICData::New(
flow_graph_->parsed_function()->function(),
flow_graph_->function(),
call->function_name(),
args_desc_array,
call->deopt_id(),
@ -2263,7 +2263,7 @@ bool FlowGraphOptimizer::InstanceCallNeedsClassCheck(
if (!FLAG_use_cha) return true;
Definition* callee_receiver = call->ArgumentAt(0);
ASSERT(callee_receiver != NULL);
const Function& function = flow_graph_->parsed_function()->function();
const Function& function = flow_graph_->function();
if (function.IsDynamicFunction() &&
callee_receiver->IsParameter() &&
(callee_receiver->AsParameter()->index() == 0)) {
@ -3635,7 +3635,7 @@ bool FlowGraphOptimizer::InlineByteArrayBaseStore(const Function& target,
case kTypedDataInt16ArrayCid:
case kTypedDataUint16ArrayCid: {
// Check that value is always smi.
value_check = ICData::New(flow_graph_->parsed_function()->function(),
value_check = ICData::New(flow_graph_->function(),
i_call->function_name(),
Object::empty_array(), // Dummy args. descr.
Isolate::kNoDeoptId,
@ -3647,7 +3647,7 @@ bool FlowGraphOptimizer::InlineByteArrayBaseStore(const Function& target,
case kTypedDataUint32ArrayCid:
// On 64-bit platforms assume that stored value is always a smi.
if (kSmiBits >= 32) {
value_check = ICData::New(flow_graph_->parsed_function()->function(),
value_check = ICData::New(flow_graph_->function(),
i_call->function_name(),
Object::empty_array(), // Dummy args. descr.
Isolate::kNoDeoptId,
@ -3658,7 +3658,7 @@ bool FlowGraphOptimizer::InlineByteArrayBaseStore(const Function& target,
case kTypedDataFloat32ArrayCid:
case kTypedDataFloat64ArrayCid: {
// Check that value is always double.
value_check = ICData::New(flow_graph_->parsed_function()->function(),
value_check = ICData::New(flow_graph_->function(),
i_call->function_name(),
Object::empty_array(), // Dummy args. descr.
Isolate::kNoDeoptId,
@ -3668,7 +3668,7 @@ bool FlowGraphOptimizer::InlineByteArrayBaseStore(const Function& target,
}
case kTypedDataInt32x4ArrayCid: {
// Check that value is always Int32x4.
value_check = ICData::New(flow_graph_->parsed_function()->function(),
value_check = ICData::New(flow_graph_->function(),
i_call->function_name(),
Object::empty_array(), // Dummy args. descr.
Isolate::kNoDeoptId,
@ -3678,7 +3678,7 @@ bool FlowGraphOptimizer::InlineByteArrayBaseStore(const Function& target,
}
case kTypedDataFloat32x4ArrayCid: {
// Check that value is always Float32x4.
value_check = ICData::New(flow_graph_->parsed_function()->function(),
value_check = ICData::New(flow_graph_->function(),
i_call->function_name(),
Object::empty_array(), // Dummy args. descr.
Isolate::kNoDeoptId,
@ -4994,8 +4994,7 @@ static bool IsLoopInvariantLoad(ZoneGrowableArray<BitVector*>* sets,
void LICM::OptimisticallySpecializeSmiPhis() {
if (!flow_graph()->parsed_function()->function().
allows_hoisting_check_class()) {
if (!flow_graph()->function().allows_hoisting_check_class()) {
// Do not hoist any.
return;
}
@ -5017,8 +5016,7 @@ void LICM::OptimisticallySpecializeSmiPhis() {
void LICM::Optimize() {
if (!flow_graph()->parsed_function()->function().
allows_hoisting_check_class()) {
if (!flow_graph()->function().allows_hoisting_check_class()) {
// Do not hoist any.
return;
}

View file

@ -1528,7 +1528,7 @@ class BoundsCheckGeneralizer {
void RangeAnalysis::EliminateRedundantBoundsChecks() {
if (FLAG_array_bounds_check_elimination) {
const Function& function = flow_graph_->parsed_function()->function();
const Function& function = flow_graph_->function();
const bool try_generalization =
function.allows_bounds_check_generalization();

View file

@ -37,7 +37,7 @@ class FlowGraphPrinter : public ValueObject {
public:
FlowGraphPrinter(const FlowGraph& flow_graph,
bool print_locations = false)
: function_(flow_graph.parsed_function()->function()),
: function_(flow_graph.function()),
block_order_(flow_graph.reverse_postorder()),
print_locations_(print_locations) { }

View file

@ -3261,7 +3261,7 @@ Definition* StringInterpolateInstr::Canonicalize(FlowGraph* flow_graph) {
// v8 <- StringInterpolate(v2)
// Don't compile-time fold when optimizing the interpolation function itself.
if (flow_graph->parsed_function()->function().raw() == CallFunction().raw()) {
if (flow_graph->function().raw() == CallFunction().raw()) {
return this;
}

View file

@ -250,7 +250,7 @@ class BlockBuilder : public ValueObject {
}
intptr_t TokenPos() {
return flow_graph_->parsed_function()->function().token_pos();
return flow_graph_->function().token_pos();
}
private:
@ -438,13 +438,12 @@ bool Intrinsifier::Build_Float64ArraySetIndexed(FlowGraph* flow_graph) {
PrepareIndexedOp(&builder, array, index, TypedData::length_offset());
const ICData& value_check = ICData::ZoneHandle(ICData::New(
flow_graph->parsed_function()->function(),
String::Handle(flow_graph->parsed_function()->function().name()),
flow_graph->function(),
String::Handle(flow_graph->function().name()),
Object::empty_array(), // Dummy args. descr.
Isolate::kNoDeoptId,
1));
value_check.AddReceiverCheck(kDoubleCid,
flow_graph->parsed_function()->function());
value_check.AddReceiverCheck(kDoubleCid, flow_graph->function());
builder.AddInstruction(
new CheckClassInstr(new Value(value),
Isolate::kNoDeoptId,