Index: src/compiler/js-intrinsic-lowering.cc |
diff --git a/src/compiler/js-intrinsic-lowering.cc b/src/compiler/js-intrinsic-lowering.cc |
index 6fcd00f2f5bc079900902bbc39631519deb68902..7253aab787780acfd51268090ec36b81ce558165 100644 |
--- a/src/compiler/js-intrinsic-lowering.cc |
+++ b/src/compiler/js-intrinsic-lowering.cc |
@@ -7,6 +7,7 @@ |
#include "src/compiler/access-builder.h" |
#include "src/compiler/js-graph.h" |
+#include "src/compiler/node-matchers.h" |
#include "src/compiler/node-properties.h" |
namespace v8 { |
@@ -33,6 +34,8 @@ Reduction JSIntrinsicLowering::Reduce(Node* node) { |
return ReduceDoubleLo(node); |
case Runtime::kInlineHeapObjectGetMap: |
return ReduceHeapObjectGetMap(node); |
+ case Runtime::kInlineIncrementStatsCounter: |
+ return ReduceIncrementStatsCounter(node); |
case Runtime::kInlineIsArray: |
return ReduceIsInstanceType(node, JS_ARRAY_TYPE); |
case Runtime::kInlineIsFunction: |
@@ -136,6 +139,30 @@ Reduction JSIntrinsicLowering::ReduceHeapObjectGetMap(Node* node) { |
} |
+Reduction JSIntrinsicLowering::ReduceIncrementStatsCounter(Node* node) { |
+ if (!FLAG_native_code_counters) return ChangeToUndefined(node); |
+ HeapObjectMatcher<String> m(NodeProperties::GetValueInput(node, 0)); |
+ if (!m.HasValue() || !m.Value().handle()->IsString()) { |
+ return ChangeToUndefined(node); |
+ } |
+ SmartArrayPointer<char> name = m.Value().handle()->ToCString(); |
+ StatsCounter counter(jsgraph()->isolate(), name.get()); |
+ if (!counter.Enabled()) return ChangeToUndefined(node); |
+ |
+ Node* effect = NodeProperties::GetEffectInput(node); |
+ Node* control = NodeProperties::GetControlInput(node); |
+ FieldAccess access = AccessBuilder::ForStatsCounter(); |
+ Node* cnt = jsgraph()->ExternalConstant(ExternalReference(&counter)); |
+ Node* load = |
+ graph()->NewNode(simplified()->LoadField(access), cnt, effect, control); |
+ Node* inc = |
+ graph()->NewNode(machine()->Int32Add(), load, jsgraph()->OneConstant()); |
+ Node* store = graph()->NewNode(simplified()->StoreField(access), cnt, inc, |
+ load, control); |
+ return ChangeToUndefined(node, store); |
+} |
+ |
+ |
Reduction JSIntrinsicLowering::ReduceIsInstanceType( |
Node* node, InstanceType instance_type) { |
// if (%_IsSmi(value)) { |
@@ -352,6 +379,13 @@ Reduction JSIntrinsicLowering::Change(Node* node, const Operator* op, Node* a, |
} |
+Reduction JSIntrinsicLowering::ChangeToUndefined(Node* node, Node* effect) { |
+ NodeProperties::ReplaceWithValue(node, jsgraph()->UndefinedConstant(), |
+ effect); |
+ return Changed(node); |
+} |
+ |
+ |
Graph* JSIntrinsicLowering::graph() const { return jsgraph()->graph(); } |