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

Unified Diff: src/compiler/js-frame-specialization.cc

Issue 1225683004: [turbofan] Add new JSFrameSpecialization reducer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Also specialize Parameters as discussed with Jaro. Created 5 years, 5 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-frame-specialization.h ('k') | src/compiler/pipeline.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/js-frame-specialization.cc
diff --git a/src/compiler/js-frame-specialization.cc b/src/compiler/js-frame-specialization.cc
new file mode 100644
index 0000000000000000000000000000000000000000..98b1827492545fd96a88a935cabfd33b6d8f36bd
--- /dev/null
+++ b/src/compiler/js-frame-specialization.cc
@@ -0,0 +1,69 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/compiler/js-frame-specialization.h"
+
+#include "src/compiler/js-graph.h"
+#include "src/compiler/linkage.h"
+#include "src/frames-inl.h"
+
+namespace v8 {
+namespace internal {
+namespace compiler {
+
+Reduction JSFrameSpecialization::Reduce(Node* node) {
+ switch (node->opcode()) {
+ case IrOpcode::kOsrValue:
+ return ReduceOsrValue(node);
+ case IrOpcode::kParameter:
+ return ReduceParameter(node);
+ default:
+ break;
+ }
+ return NoChange();
+}
+
+
+Reduction JSFrameSpecialization::ReduceOsrValue(Node* node) {
+ DCHECK_EQ(IrOpcode::kOsrValue, node->opcode());
+ DisallowHeapAllocation no_gc;
+ Object* object;
+ int const index = OpParameter<int>(node);
+ int const parameters_count = frame()->ComputeParametersCount() + 1;
+ if (index == Linkage::kOsrContextSpillSlotIndex) {
+ object = frame()->context();
+ } else if (index >= parameters_count) {
+ object = frame()->GetExpression(index - parameters_count);
+ } else {
+ // The OsrValue index 0 is the receiver.
+ object = index ? frame()->GetParameter(index - 1) : frame()->receiver();
+ }
+ return Replace(jsgraph()->Constant(handle(object, isolate())));
+}
+
+
+Reduction JSFrameSpecialization::ReduceParameter(Node* node) {
+ DCHECK_EQ(IrOpcode::kParameter, node->opcode());
+ DisallowHeapAllocation no_gc;
+ Object* object;
+ int const index = ParameterIndexOf(node->op());
+ int const parameters_count = frame()->ComputeParametersCount() + 1;
+ if (index == Linkage::kJSFunctionCallClosureParamIndex) {
+ object = frame()->function();
+ } else if (index == parameters_count) {
+ // The Parameter index (arity + 1) is the context.
+ object = frame()->context();
+ } else {
+ // The Parameter index 0 is the receiver.
+ object = index ? frame()->GetParameter(index - 1) : frame()->receiver();
+ }
+ return Replace(jsgraph()->Constant(handle(object, isolate())));
+}
+
+
+Isolate* JSFrameSpecialization::isolate() const { return jsgraph()->isolate(); }
+
+} // namespace compiler
+} // namespace internal
+} // namespace v8
« no previous file with comments | « src/compiler/js-frame-specialization.h ('k') | src/compiler/pipeline.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698