Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(635)

Unified Diff: runtime/vm/intrinsifier.cc

Issue 1825603002: Revert "Add graph intrinsics for many math library functions" (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/intermediate_language.cc ('k') | runtime/vm/method_recognizer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intrinsifier.cc
diff --git a/runtime/vm/intrinsifier.cc b/runtime/vm/intrinsifier.cc
index c2ae37b2d6bca41976f7d4e80d40648d3815147a..af15e7a7f2a81df0e199b6cf7518a5bc31da34a0 100644
--- a/runtime/vm/intrinsifier.cc
+++ b/runtime/vm/intrinsifier.cc
@@ -21,39 +21,16 @@
namespace dart {
DEFINE_FLAG(bool, intrinsify, true, "Instrinsify when possible");
-DEFINE_FLAG(bool, trace_intrinsifier, false, "Trace intrinsifier");
DECLARE_FLAG(bool, code_comments);
DECLARE_FLAG(bool, print_flow_graph);
DECLARE_FLAG(bool, print_flow_graph_optimized);
bool Intrinsifier::CanIntrinsify(const Function& function) {
- if (FLAG_trace_intrinsifier) {
- THR_Print("CanIntrinsify %s ->", function.ToQualifiedCString());
- }
if (!FLAG_intrinsify) return false;
- if (function.IsClosureFunction()) {
- if (FLAG_trace_intrinsifier) {
- THR_Print("No, closure function.\n");
- }
- return false;
- }
+ if (function.IsClosureFunction()) return false;
// Can occur because of compile-all flag.
- if (function.is_external()) {
- if (FLAG_trace_intrinsifier) {
- THR_Print("No, external function.\n");
- }
- return false;
- }
- if (!function.is_intrinsic()) {
- if (FLAG_trace_intrinsifier) {
- THR_Print("No, not intrinsic function.\n");
- }
- return false;
- }
- if (FLAG_trace_intrinsifier) {
- THR_Print("Yes.\n");
- }
- return true;
+ if (function.is_external()) return false;
+ return function.is_intrinsic();
}
@@ -101,7 +78,6 @@ void Intrinsifier::InitializeState() {
lib = Library::MathLibrary();
ASSERT(!lib.IsNull());
MATH_LIB_INTRINSIC_LIST(SETUP_FUNCTION);
- GRAPH_MATH_LIB_INTRINSIC_LIST(SETUP_FUNCTION);
// Set up all dart:typed_data lib functions that can be intrinsified.
lib = Library::TypedDataLibrary();
@@ -123,7 +99,7 @@ static void EmitCodeFor(FlowGraphCompiler* compiler,
FlowGraph* graph) {
// The FlowGraph here is constructed by the intrinsics builder methods, and
// is different from compiler->flow_graph(), the original method's flow graph.
- compiler->assembler()->Comment("Graph intrinsic begin");
+ compiler->assembler()->Comment("Graph intrinsic");
for (intptr_t i = 0; i < graph->reverse_postorder().length(); i++) {
BlockEntryInstr* block = graph->reverse_postorder()[i];
if (block->IsGraphEntry()) continue; // No code for graph entry needed.
@@ -139,11 +115,6 @@ static void EmitCodeFor(FlowGraphCompiler* compiler,
if (instr->IsParallelMove()) {
compiler->parallel_move_resolver()->EmitNativeCode(
instr->AsParallelMove());
- } else if (instr->IsInvokeMathCFunction()) {
- ASSERT(instr->locs() != NULL);
- // InvokeMathCFunction always calls, but it uses registers that
- // are free for the intrinsic to use.
- instr->EmitNativeCode(compiler);
} else {
ASSERT(instr->locs() != NULL);
// Calls are not supported in intrinsics code.
@@ -152,7 +123,6 @@ static void EmitCodeFor(FlowGraphCompiler* compiler,
}
}
}
- compiler->assembler()->Comment("Graph intrinsic end");
}
@@ -254,11 +224,6 @@ static intptr_t CidForRepresentation(Representation rep) {
}
-// Notes about the graph intrinsics:
-//
-// IR instructions which would jump to a deoptimization sequence on failure
-// instead branch to the intrinsic slow path.
-//
class BlockBuilder : public ValueObject {
public:
BlockBuilder(FlowGraph* flow_graph, TargetEntryInstr* entry)
@@ -304,45 +269,17 @@ class BlockBuilder : public ValueObject {
new ConstantInstr(Object::ZoneHandle(Object::null())));
}
- Definition* AddUnboxInstr(Representation rep,
- Value* value,
- bool is_checked) {
+ Definition* AddUnboxInstr(Representation rep, Value* value) {
Definition* unboxed_value = AddDefinition(
UnboxInstr::Create(rep, value, Thread::kNoDeoptId));
- if (is_checked) {
- // The type of |value| has already been checked and it is safe to
- // adjust reaching type. This is done manually because there is no type
- // propagation when building intrinsics.
- unboxed_value->AsUnbox()->value()->SetReachingType(ZoneCompileType::Wrap(
- CompileType::FromCid(CidForRepresentation(rep))));
- }
+ // Manually adjust reaching type because there is no type propagation
+ // when building intrinsics.
+ unboxed_value->AsUnbox()->value()->SetReachingType(ZoneCompileType::Wrap(
+ CompileType::FromCid(CidForRepresentation(rep))));
return unboxed_value;
}
- Definition* AddUnboxInstr(Representation rep,
- Definition* boxed,
- bool is_checked) {
- return AddUnboxInstr(rep, new Value(boxed), is_checked);
- }
-
- Definition* InvokeMathCFunction(MethodRecognizer::Kind recognized_kind,
- ZoneGrowableArray<Value*>* args) {
- return InvokeMathCFunctionHelper(recognized_kind, args);
- }
-
private:
- Definition* InvokeMathCFunctionHelper(MethodRecognizer::Kind recognized_kind,
- ZoneGrowableArray<Value*>* args) {
- InvokeMathCFunctionInstr* invoke_math_c_function =
- new InvokeMathCFunctionInstr(args,
- Thread::kNoDeoptId,
- recognized_kind,
- TokenPos());
- AddDefinition(invoke_math_c_function);
- return invoke_math_c_function;
- }
-
-
FlowGraph* flow_graph_;
BlockEntryInstr* entry_;
Instruction* current_;
@@ -523,9 +460,7 @@ bool Intrinsifier::Build_Uint32ArraySetIndexed(FlowGraph* flow_graph) {
PrepareIndexedOp(&builder, array, index, TypedData::length_offset());
Definition* unboxed_value =
- builder.AddUnboxInstr(kUnboxedUint32,
- new Value(value),
- /* is_checked = */ true);
+ builder.AddUnboxInstr(kUnboxedUint32, new Value(value));
builder.AddInstruction(
new StoreIndexedInstr(new Value(array),
@@ -593,9 +528,7 @@ bool Intrinsifier::Build_Float64ArraySetIndexed(FlowGraph* flow_graph) {
value_check,
builder.TokenPos()));
Definition* double_value =
- builder.AddUnboxInstr(kUnboxedDouble,
- new Value(value),
- /* is_checked = */ true);
+ builder.AddUnboxInstr(kUnboxedDouble, new Value(value));
builder.AddInstruction(
new StoreIndexedInstr(new Value(array),
@@ -663,14 +596,10 @@ static bool BuildBinaryFloat32x4Op(FlowGraph* flow_graph, Token::Kind kind) {
value_check,
builder.TokenPos()));
Definition* left_simd =
- builder.AddUnboxInstr(kUnboxedFloat32x4,
- new Value(left),
- /* is_checked = */ true);
+ builder.AddUnboxInstr(kUnboxedFloat32x4, new Value(left));
Definition* right_simd =
- builder.AddUnboxInstr(kUnboxedFloat32x4,
- new Value(right),
- /* is_checked = */ true);
+ builder.AddUnboxInstr(kUnboxedFloat32x4, new Value(right));
Definition* unboxed_result = builder.AddDefinition(
new BinaryFloat32x4OpInstr(kind,
@@ -709,9 +638,7 @@ static bool BuildFloat32x4Shuffle(FlowGraph* flow_graph,
Definition* receiver = builder.AddParameter(1);
Definition* unboxed_receiver =
- builder.AddUnboxInstr(kUnboxedFloat32x4,
- new Value(receiver),
- /* is_checked = */ true);
+ builder.AddUnboxInstr(kUnboxedFloat32x4, new Value(receiver));
Definition* unboxed_result = builder.AddDefinition(
new Simd32x4ShuffleInstr(kind,
@@ -945,9 +872,7 @@ bool Intrinsifier::Build_DoubleFlipSignBit(FlowGraph* flow_graph) {
Definition* receiver = builder.AddParameter(1);
Definition* unboxed_value =
- builder.AddUnboxInstr(kUnboxedDouble,
- new Value(receiver),
- /* is_checked = */ true);
+ builder.AddUnboxInstr(kUnboxedDouble, new Value(receiver));
Definition* unboxed_result = builder.AddDefinition(
new UnaryDoubleOpInstr(Token::kNEGATE,
new Value(unboxed_value),
@@ -958,115 +883,4 @@ bool Intrinsifier::Build_DoubleFlipSignBit(FlowGraph* flow_graph) {
return true;
}
-
-static bool BuildInvokeMathCFunction(BlockBuilder* builder,
- MethodRecognizer::Kind kind,
- intptr_t num_parameters = 1) {
- ZoneGrowableArray<Value*>* args =
- new ZoneGrowableArray<Value*>(num_parameters);
-
- for (intptr_t i = 0; i < num_parameters; i++) {
- const intptr_t parameter_index = (num_parameters - i);
- Definition* value = builder->AddParameter(parameter_index);
- Definition* unboxed_value =
- builder->AddUnboxInstr(kUnboxedDouble, value, /* is_checked = */ false);
- args->Add(new Value(unboxed_value));
- }
-
- Definition* unboxed_result =
- builder->InvokeMathCFunction(kind, args);
-
- Definition* result = builder->AddDefinition(
- BoxInstr::Create(kUnboxedDouble, new Value(unboxed_result)));
-
- builder->AddIntrinsicReturn(new Value(result));
-
- return true;
-}
-
-
-bool Intrinsifier::Build_MathSin(FlowGraph* flow_graph) {
- if (!FlowGraphCompiler::SupportsUnboxedDoubles()) return false;
-
- GraphEntryInstr* graph_entry = flow_graph->graph_entry();
- TargetEntryInstr* normal_entry = graph_entry->normal_entry();
- BlockBuilder builder(flow_graph, normal_entry);
-
- return BuildInvokeMathCFunction(&builder,
- MethodRecognizer::kMathSin);
-}
-
-
-bool Intrinsifier::Build_MathCos(FlowGraph* flow_graph) {
- if (!FlowGraphCompiler::SupportsUnboxedDoubles()) return false;
-
- GraphEntryInstr* graph_entry = flow_graph->graph_entry();
- TargetEntryInstr* normal_entry = graph_entry->normal_entry();
- BlockBuilder builder(flow_graph, normal_entry);
-
- return BuildInvokeMathCFunction(&builder,
- MethodRecognizer::kMathCos);
-}
-
-
-bool Intrinsifier::Build_MathTan(FlowGraph* flow_graph) {
- if (!FlowGraphCompiler::SupportsUnboxedDoubles()) return false;
-
- GraphEntryInstr* graph_entry = flow_graph->graph_entry();
- TargetEntryInstr* normal_entry = graph_entry->normal_entry();
- BlockBuilder builder(flow_graph, normal_entry);
-
- return BuildInvokeMathCFunction(&builder,
- MethodRecognizer::kMathTan);
-}
-
-
-bool Intrinsifier::Build_MathAsin(FlowGraph* flow_graph) {
- if (!FlowGraphCompiler::SupportsUnboxedDoubles()) return false;
-
- GraphEntryInstr* graph_entry = flow_graph->graph_entry();
- TargetEntryInstr* normal_entry = graph_entry->normal_entry();
- BlockBuilder builder(flow_graph, normal_entry);
-
- return BuildInvokeMathCFunction(&builder,
- MethodRecognizer::kMathAsin);
-}
-
-
-bool Intrinsifier::Build_MathAcos(FlowGraph* flow_graph) {
- if (!FlowGraphCompiler::SupportsUnboxedDoubles()) return false;
-
- GraphEntryInstr* graph_entry = flow_graph->graph_entry();
- TargetEntryInstr* normal_entry = graph_entry->normal_entry();
- BlockBuilder builder(flow_graph, normal_entry);
-
- return BuildInvokeMathCFunction(&builder,
- MethodRecognizer::kMathAcos);
-}
-
-
-bool Intrinsifier::Build_MathAtan(FlowGraph* flow_graph) {
- if (!FlowGraphCompiler::SupportsUnboxedDoubles()) return false;
-
- GraphEntryInstr* graph_entry = flow_graph->graph_entry();
- TargetEntryInstr* normal_entry = graph_entry->normal_entry();
- BlockBuilder builder(flow_graph, normal_entry);
-
- return BuildInvokeMathCFunction(&builder,
- MethodRecognizer::kMathAtan);
-}
-
-
-bool Intrinsifier::Build_MathAtan2(FlowGraph* flow_graph) {
- if (!FlowGraphCompiler::SupportsUnboxedDoubles()) return false;
-
- GraphEntryInstr* graph_entry = flow_graph->graph_entry();
- TargetEntryInstr* normal_entry = graph_entry->normal_entry();
- BlockBuilder builder(flow_graph, normal_entry);
-
- return BuildInvokeMathCFunction(&builder,
- MethodRecognizer::kMathAtan2,
- /* num_parameters = */ 2);
-}
-
} // namespace dart
« no previous file with comments | « runtime/vm/intermediate_language.cc ('k') | runtime/vm/method_recognizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698