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

Side by Side Diff: src/compiler/js-frame-specialization.cc

Issue 1529053003: [turbofan] Flatten cons strings before embedding them into optimized code. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@HeapConstants
Patch Set: Created 5 years 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
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/js-frame-specialization.h" 5 #include "src/compiler/js-frame-specialization.h"
6 6
7 #include "src/compiler/js-graph.h" 7 #include "src/compiler/js-graph.h"
8 #include "src/compiler/linkage.h" 8 #include "src/compiler/linkage.h"
9 #include "src/frames-inl.h" 9 #include "src/frames-inl.h"
10 10
11 namespace v8 { 11 namespace v8 {
12 namespace internal { 12 namespace internal {
13 namespace compiler { 13 namespace compiler {
14 14
15 Reduction JSFrameSpecialization::Reduce(Node* node) { 15 Reduction JSFrameSpecialization::Reduce(Node* node) {
16 switch (node->opcode()) { 16 switch (node->opcode()) {
17 case IrOpcode::kOsrValue: 17 case IrOpcode::kOsrValue:
18 return ReduceOsrValue(node); 18 return ReduceOsrValue(node);
19 case IrOpcode::kParameter: 19 case IrOpcode::kParameter:
20 return ReduceParameter(node); 20 return ReduceParameter(node);
21 default: 21 default:
22 break; 22 break;
23 } 23 }
24 return NoChange(); 24 return NoChange();
25 } 25 }
26 26
27 27
28 Reduction JSFrameSpecialization::ReduceOsrValue(Node* node) { 28 Reduction JSFrameSpecialization::ReduceOsrValue(Node* node) {
29 DCHECK_EQ(IrOpcode::kOsrValue, node->opcode()); 29 DCHECK_EQ(IrOpcode::kOsrValue, node->opcode());
30 DisallowHeapAllocation no_gc; 30 Handle<Object> value;
31 Object* object;
32 int const index = OpParameter<int>(node); 31 int const index = OpParameter<int>(node);
33 int const parameters_count = frame()->ComputeParametersCount() + 1; 32 int const parameters_count = frame()->ComputeParametersCount() + 1;
34 if (index == Linkage::kOsrContextSpillSlotIndex) { 33 if (index == Linkage::kOsrContextSpillSlotIndex) {
35 object = frame()->context(); 34 value = handle(frame()->context(), isolate());
36 } else if (index >= parameters_count) { 35 } else if (index >= parameters_count) {
37 object = frame()->GetExpression(index - parameters_count); 36 value = handle(frame()->GetExpression(index - parameters_count), isolate());
38 } else { 37 } else {
39 // The OsrValue index 0 is the receiver. 38 // The OsrValue index 0 is the receiver.
40 object = index ? frame()->GetParameter(index - 1) : frame()->receiver(); 39 value =
40 handle(index ? frame()->GetParameter(index - 1) : frame()->receiver(),
41 isolate());
41 } 42 }
42 return Replace(jsgraph()->Constant(handle(object, isolate()))); 43 return Replace(jsgraph()->Constant(value));
43 } 44 }
44 45
45 46
46 Reduction JSFrameSpecialization::ReduceParameter(Node* node) { 47 Reduction JSFrameSpecialization::ReduceParameter(Node* node) {
47 DCHECK_EQ(IrOpcode::kParameter, node->opcode()); 48 DCHECK_EQ(IrOpcode::kParameter, node->opcode());
48 DisallowHeapAllocation no_gc; 49 Handle<Object> value;
49 Object* object;
50 int const index = ParameterIndexOf(node->op()); 50 int const index = ParameterIndexOf(node->op());
51 int const parameters_count = frame()->ComputeParametersCount() + 1; 51 int const parameters_count = frame()->ComputeParametersCount() + 1;
52 if (index == Linkage::kJSCallClosureParamIndex) { 52 if (index == Linkage::kJSCallClosureParamIndex) {
53 // The Parameter index references the closure. 53 // The Parameter index references the closure.
54 object = frame()->function(); 54 value = handle(frame()->function(), isolate());
55 } else if (index == Linkage::GetJSCallArgCountParamIndex(parameters_count)) { 55 } else if (index == Linkage::GetJSCallArgCountParamIndex(parameters_count)) {
56 // The Parameter index references the parameter count. 56 // The Parameter index references the parameter count.
57 object = Smi::FromInt(parameters_count - 1); 57 value = handle(Smi::FromInt(parameters_count - 1), isolate());
58 } else if (index == Linkage::GetJSCallContextParamIndex(parameters_count)) { 58 } else if (index == Linkage::GetJSCallContextParamIndex(parameters_count)) {
59 // The Parameter index references the context. 59 // The Parameter index references the context.
60 object = frame()->context(); 60 value = handle(frame()->context(), isolate());
61 } else { 61 } else {
62 // The Parameter index 0 is the receiver. 62 // The Parameter index 0 is the receiver.
63 object = index ? frame()->GetParameter(index - 1) : frame()->receiver(); 63 value =
64 handle(index ? frame()->GetParameter(index - 1) : frame()->receiver(),
65 isolate());
64 } 66 }
65 return Replace(jsgraph()->Constant(handle(object, isolate()))); 67 return Replace(jsgraph()->Constant(value));
66 } 68 }
67 69
68 70
69 Isolate* JSFrameSpecialization::isolate() const { return jsgraph()->isolate(); } 71 Isolate* JSFrameSpecialization::isolate() const { return jsgraph()->isolate(); }
70 72
71 } // namespace compiler 73 } // namespace compiler
72 } // namespace internal 74 } // namespace internal
73 } // namespace v8 75 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698