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

Unified Diff: src/compiler/js-intrinsic-lowering.cc

Issue 1031383002: Add %_IncrementStatsCounter intrinsic. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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 | « src/compiler/js-intrinsic-lowering.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(); }
« no previous file with comments | « src/compiler/js-intrinsic-lowering.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698