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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/compiler/js-intrinsic-lowering.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 // Copyright 2015 the V8 project authors. All rights reserved. 2 // Copyright 2015 the V8 project authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be 3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file. 4 // found in the LICENSE file.
5 5
6 #include "src/compiler/js-intrinsic-lowering.h" 6 #include "src/compiler/js-intrinsic-lowering.h"
7 7
8 #include "src/compiler/access-builder.h" 8 #include "src/compiler/access-builder.h"
9 #include "src/compiler/js-graph.h" 9 #include "src/compiler/js-graph.h"
10 #include "src/compiler/node-matchers.h"
10 #include "src/compiler/node-properties.h" 11 #include "src/compiler/node-properties.h"
11 12
12 namespace v8 { 13 namespace v8 {
13 namespace internal { 14 namespace internal {
14 namespace compiler { 15 namespace compiler {
15 16
16 JSIntrinsicLowering::JSIntrinsicLowering(JSGraph* jsgraph) 17 JSIntrinsicLowering::JSIntrinsicLowering(JSGraph* jsgraph)
17 : jsgraph_(jsgraph), simplified_(jsgraph->zone()) {} 18 : jsgraph_(jsgraph), simplified_(jsgraph->zone()) {}
18 19
19 20
20 Reduction JSIntrinsicLowering::Reduce(Node* node) { 21 Reduction JSIntrinsicLowering::Reduce(Node* node) {
21 if (node->opcode() != IrOpcode::kJSCallRuntime) return NoChange(); 22 if (node->opcode() != IrOpcode::kJSCallRuntime) return NoChange();
22 const Runtime::Function* const f = 23 const Runtime::Function* const f =
23 Runtime::FunctionForId(CallRuntimeParametersOf(node->op()).id()); 24 Runtime::FunctionForId(CallRuntimeParametersOf(node->op()).id());
24 if (f->intrinsic_type != Runtime::IntrinsicType::INLINE) return NoChange(); 25 if (f->intrinsic_type != Runtime::IntrinsicType::INLINE) return NoChange();
25 switch (f->function_id) { 26 switch (f->function_id) {
26 case Runtime::kInlineConstructDouble: 27 case Runtime::kInlineConstructDouble:
27 return ReduceConstructDouble(node); 28 return ReduceConstructDouble(node);
28 case Runtime::kInlineDeoptimizeNow: 29 case Runtime::kInlineDeoptimizeNow:
29 return ReduceDeoptimizeNow(node); 30 return ReduceDeoptimizeNow(node);
30 case Runtime::kInlineDoubleHi: 31 case Runtime::kInlineDoubleHi:
31 return ReduceDoubleHi(node); 32 return ReduceDoubleHi(node);
32 case Runtime::kInlineDoubleLo: 33 case Runtime::kInlineDoubleLo:
33 return ReduceDoubleLo(node); 34 return ReduceDoubleLo(node);
34 case Runtime::kInlineHeapObjectGetMap: 35 case Runtime::kInlineHeapObjectGetMap:
35 return ReduceHeapObjectGetMap(node); 36 return ReduceHeapObjectGetMap(node);
37 case Runtime::kInlineIncrementStatsCounter:
38 return ReduceIncrementStatsCounter(node);
36 case Runtime::kInlineIsArray: 39 case Runtime::kInlineIsArray:
37 return ReduceIsInstanceType(node, JS_ARRAY_TYPE); 40 return ReduceIsInstanceType(node, JS_ARRAY_TYPE);
38 case Runtime::kInlineIsFunction: 41 case Runtime::kInlineIsFunction:
39 return ReduceIsInstanceType(node, JS_FUNCTION_TYPE); 42 return ReduceIsInstanceType(node, JS_FUNCTION_TYPE);
40 case Runtime::kInlineIsNonNegativeSmi: 43 case Runtime::kInlineIsNonNegativeSmi:
41 return ReduceIsNonNegativeSmi(node); 44 return ReduceIsNonNegativeSmi(node);
42 case Runtime::kInlineIsRegExp: 45 case Runtime::kInlineIsRegExp:
43 return ReduceIsInstanceType(node, JS_REGEXP_TYPE); 46 return ReduceIsInstanceType(node, JS_REGEXP_TYPE);
44 case Runtime::kInlineIsSmi: 47 case Runtime::kInlineIsSmi:
45 return ReduceIsSmi(node); 48 return ReduceIsSmi(node);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 132
130 Reduction JSIntrinsicLowering::ReduceHeapObjectGetMap(Node* node) { 133 Reduction JSIntrinsicLowering::ReduceHeapObjectGetMap(Node* node) {
131 Node* value = NodeProperties::GetValueInput(node, 0); 134 Node* value = NodeProperties::GetValueInput(node, 0);
132 Node* effect = NodeProperties::GetEffectInput(node); 135 Node* effect = NodeProperties::GetEffectInput(node);
133 Node* control = NodeProperties::GetControlInput(node); 136 Node* control = NodeProperties::GetControlInput(node);
134 return Change(node, simplified()->LoadField(AccessBuilder::ForMap()), value, 137 return Change(node, simplified()->LoadField(AccessBuilder::ForMap()), value,
135 effect, control); 138 effect, control);
136 } 139 }
137 140
138 141
142 Reduction JSIntrinsicLowering::ReduceIncrementStatsCounter(Node* node) {
143 if (!FLAG_native_code_counters) return ChangeToUndefined(node);
144 HeapObjectMatcher<String> m(NodeProperties::GetValueInput(node, 0));
145 if (!m.HasValue() || !m.Value().handle()->IsString()) {
146 return ChangeToUndefined(node);
147 }
148 SmartArrayPointer<char> name = m.Value().handle()->ToCString();
149 StatsCounter counter(jsgraph()->isolate(), name.get());
150 if (!counter.Enabled()) return ChangeToUndefined(node);
151
152 Node* effect = NodeProperties::GetEffectInput(node);
153 Node* control = NodeProperties::GetControlInput(node);
154 FieldAccess access = AccessBuilder::ForStatsCounter();
155 Node* cnt = jsgraph()->ExternalConstant(ExternalReference(&counter));
156 Node* load =
157 graph()->NewNode(simplified()->LoadField(access), cnt, effect, control);
158 Node* inc =
159 graph()->NewNode(machine()->Int32Add(), load, jsgraph()->OneConstant());
160 Node* store = graph()->NewNode(simplified()->StoreField(access), cnt, inc,
161 load, control);
162 return ChangeToUndefined(node, store);
163 }
164
165
139 Reduction JSIntrinsicLowering::ReduceIsInstanceType( 166 Reduction JSIntrinsicLowering::ReduceIsInstanceType(
140 Node* node, InstanceType instance_type) { 167 Node* node, InstanceType instance_type) {
141 // if (%_IsSmi(value)) { 168 // if (%_IsSmi(value)) {
142 // return false; 169 // return false;
143 // } else { 170 // } else {
144 // return %_GetInstanceType(%_GetMap(value)) == instance_type; 171 // return %_GetInstanceType(%_GetMap(value)) == instance_type;
145 // } 172 // }
146 MachineType const type = static_cast<MachineType>(kTypeBool | kRepTagged); 173 MachineType const type = static_cast<MachineType>(kTypeBool | kRepTagged);
147 174
148 Node* value = NodeProperties::GetValueInput(node, 0); 175 Node* value = NodeProperties::GetValueInput(node, 0);
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 node->set_op(op); 372 node->set_op(op);
346 node->ReplaceInput(0, a); 373 node->ReplaceInput(0, a);
347 node->ReplaceInput(1, b); 374 node->ReplaceInput(1, b);
348 node->ReplaceInput(2, c); 375 node->ReplaceInput(2, c);
349 node->TrimInputCount(3); 376 node->TrimInputCount(3);
350 NodeProperties::ReplaceWithValue(node, node, node); 377 NodeProperties::ReplaceWithValue(node, node, node);
351 return Changed(node); 378 return Changed(node);
352 } 379 }
353 380
354 381
382 Reduction JSIntrinsicLowering::ChangeToUndefined(Node* node, Node* effect) {
383 NodeProperties::ReplaceWithValue(node, jsgraph()->UndefinedConstant(),
384 effect);
385 return Changed(node);
386 }
387
388
355 Graph* JSIntrinsicLowering::graph() const { return jsgraph()->graph(); } 389 Graph* JSIntrinsicLowering::graph() const { return jsgraph()->graph(); }
356 390
357 391
358 CommonOperatorBuilder* JSIntrinsicLowering::common() const { 392 CommonOperatorBuilder* JSIntrinsicLowering::common() const {
359 return jsgraph()->common(); 393 return jsgraph()->common();
360 } 394 }
361 395
362 396
363 MachineOperatorBuilder* JSIntrinsicLowering::machine() const { 397 MachineOperatorBuilder* JSIntrinsicLowering::machine() const {
364 return jsgraph()->machine(); 398 return jsgraph()->machine();
365 } 399 }
366 400
367 } // namespace compiler 401 } // namespace compiler
368 } // namespace internal 402 } // namespace internal
369 } // namespace v8 403 } // namespace v8
OLDNEW
« 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