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

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

Issue 1366753003: [turbofan] Make Node::set_op safer via wrapper. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comments. Created 5 years, 3 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/diamond.h ('k') | src/compiler/js-generic-lowering.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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-context-specialization.h" 5 #include "src/compiler/js-context-specialization.h"
6 6
7 #include "src/compiler/common-operator.h" 7 #include "src/compiler/common-operator.h"
8 #include "src/compiler/js-graph.h" 8 #include "src/compiler/js-graph.h"
9 #include "src/compiler/js-operator.h" 9 #include "src/compiler/js-operator.h"
10 #include "src/compiler/node-matchers.h" 10 #include "src/compiler/node-matchers.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 } 70 }
71 71
72 // If the access itself is mutable, only fold-in the parent. 72 // If the access itself is mutable, only fold-in the parent.
73 if (!access.immutable()) { 73 if (!access.immutable()) {
74 // The access does not have to look up a parent, nothing to fold. 74 // The access does not have to look up a parent, nothing to fold.
75 if (access.depth() == 0) { 75 if (access.depth() == 0) {
76 return NoChange(); 76 return NoChange();
77 } 77 }
78 const Operator* op = jsgraph_->javascript()->LoadContext( 78 const Operator* op = jsgraph_->javascript()->LoadContext(
79 0, access.index(), access.immutable()); 79 0, access.index(), access.immutable());
80 node->set_op(op);
81 node->ReplaceInput(0, jsgraph_->Constant(context)); 80 node->ReplaceInput(0, jsgraph_->Constant(context));
81 NodeProperties::ChangeOp(node, op);
82 return Changed(node); 82 return Changed(node);
83 } 83 }
84 Handle<Object> value = 84 Handle<Object> value =
85 handle(context->get(static_cast<int>(access.index())), isolate()); 85 handle(context->get(static_cast<int>(access.index())), isolate());
86 86
87 // Even though the context slot is immutable, the context might have escaped 87 // Even though the context slot is immutable, the context might have escaped
88 // before the function to which it belongs has initialized the slot. 88 // before the function to which it belongs has initialized the slot.
89 // We must be conservative and check if the value in the slot is currently the 89 // We must be conservative and check if the value in the slot is currently the
90 // hole or undefined. If it is neither of these, then it must be initialized. 90 // hole or undefined. If it is neither of these, then it must be initialized.
91 if (value->IsUndefined() || value->IsTheHole()) { 91 if (value->IsUndefined() || value->IsTheHole()) {
(...skipping 20 matching lines...) Expand all
112 const ContextAccess& access = ContextAccessOf(node->op()); 112 const ContextAccess& access = ContextAccessOf(node->op());
113 if (access.depth() == 0) { 113 if (access.depth() == 0) {
114 return NoChange(); 114 return NoChange();
115 } 115 }
116 116
117 // Find the right parent context. 117 // Find the right parent context.
118 for (size_t i = access.depth(); i > 0; --i) { 118 for (size_t i = access.depth(); i > 0; --i) {
119 context = handle(context->previous(), isolate()); 119 context = handle(context->previous(), isolate());
120 } 120 }
121 121
122 node->set_op(javascript()->StoreContext(0, access.index()));
123 node->ReplaceInput(0, jsgraph_->Constant(context)); 122 node->ReplaceInput(0, jsgraph_->Constant(context));
123 NodeProperties::ChangeOp(node, javascript()->StoreContext(0, access.index()));
124 return Changed(node); 124 return Changed(node);
125 } 125 }
126 126
127 127
128 Isolate* JSContextSpecialization::isolate() const { 128 Isolate* JSContextSpecialization::isolate() const {
129 return jsgraph()->isolate(); 129 return jsgraph()->isolate();
130 } 130 }
131 131
132 132
133 JSOperatorBuilder* JSContextSpecialization::javascript() const { 133 JSOperatorBuilder* JSContextSpecialization::javascript() const {
134 return jsgraph()->javascript(); 134 return jsgraph()->javascript();
135 } 135 }
136 136
137 } // namespace compiler 137 } // namespace compiler
138 } // namespace internal 138 } // namespace internal
139 } // namespace v8 139 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/diamond.h ('k') | src/compiler/js-generic-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698