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

Side by Side Diff: src/compiler/js-inlining.cc

Issue 1213383002: [turbofan] Disallow cross native context inlining. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | 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-inlining.h" 5 #include "src/compiler/js-inlining.h"
6 6
7 #include "src/ast.h" 7 #include "src/ast.h"
8 #include "src/ast-numbering.h" 8 #include "src/ast-numbering.h"
9 #include "src/compiler/all-nodes.h" 9 #include "src/compiler/all-nodes.h"
10 #include "src/compiler/ast-graph-builder.h" 10 #include "src/compiler/ast-graph-builder.h"
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 HeapObjectMatcher match(call.jsfunction()); 244 HeapObjectMatcher match(call.jsfunction());
245 if (!match.HasValue()) return NoChange(); 245 if (!match.HasValue()) return NoChange();
246 246
247 if (!match.Value().handle()->IsJSFunction()) return NoChange(); 247 if (!match.Value().handle()->IsJSFunction()) return NoChange();
248 Handle<JSFunction> function = 248 Handle<JSFunction> function =
249 Handle<JSFunction>::cast(match.Value().handle()); 249 Handle<JSFunction>::cast(match.Value().handle());
250 if (mode_ == kRestrictedInlining && !function->shared()->force_inline()) { 250 if (mode_ == kRestrictedInlining && !function->shared()->force_inline()) {
251 return NoChange(); 251 return NoChange();
252 } 252 }
253 253
254 // Disallow cross native-context inlining for now. This means that all parts
255 // of the resulting code will operate on the same global object.
256 // This also prevents cross context leaks for asm.js code, where we could
257 // inline functions from a different context and hold on to that context (and
258 // closure) from the code object.
259 // TODO(turbofan): We might want to revisit this restriction later when we
260 // have a need for this, and we know how to model different native contexts
261 // in the same graph in a compositional way.
262 if (function->context()->native_context() !=
263 info_->context()->native_context()) {
264 TRACE("Not inlining %s into %s because of different native contexts\n",
265 function->shared()->DebugName()->ToCString().get(),
266 info_->shared_info()->DebugName()->ToCString().get());
267 return NoChange();
268 }
269
254 // TODO(turbofan): TranslatedState::GetAdaptedArguments() currently relies on 270 // TODO(turbofan): TranslatedState::GetAdaptedArguments() currently relies on
255 // not inlining recursive functions. We might want to relax that at some 271 // not inlining recursive functions. We might want to relax that at some
256 // point. 272 // point.
257 for (Node* frame_state = call.frame_state(); 273 for (Node* frame_state = call.frame_state();
258 frame_state->opcode() == IrOpcode::kFrameState; 274 frame_state->opcode() == IrOpcode::kFrameState;
259 frame_state = frame_state->InputAt(kFrameStateOuterStateInput)) { 275 frame_state = frame_state->InputAt(kFrameStateOuterStateInput)) {
260 FrameStateInfo const& info = OpParameter<FrameStateInfo>(frame_state); 276 FrameStateInfo const& info = OpParameter<FrameStateInfo>(frame_state);
261 Handle<SharedFunctionInfo> shared_info; 277 Handle<SharedFunctionInfo> shared_info;
262 if (info.shared_info().ToHandle(&shared_info) && 278 if (info.shared_info().ToHandle(&shared_info) &&
263 *shared_info == function->shared()) { 279 *shared_info == function->shared()) {
264 TRACE("Not inlining %s into %s because call is recursive\n", 280 TRACE("Not inlining %s into %s because call is recursive\n",
265 function->shared()->DebugName()->ToCString().get(), 281 function->shared()->DebugName()->ToCString().get(),
266 info_->shared_info()->DebugName()->ToCString().get()); 282 info_->shared_info()->DebugName()->ToCString().get());
267 return NoChange(); 283 return NoChange();
268 } 284 }
269 } 285 }
270 286
271 Zone zone; 287 Zone zone;
272 ParseInfo parse_info(&zone, function); 288 ParseInfo parse_info(&zone, function);
273 CompilationInfo info(&parse_info); 289 CompilationInfo info(&parse_info);
274 if (info_->is_deoptimization_enabled()) info.MarkAsDeoptimizationEnabled(); 290 if (info_->is_deoptimization_enabled()) info.MarkAsDeoptimizationEnabled();
275 291
276 if (!Compiler::ParseAndAnalyze(info.parse_info())) return NoChange(); 292 if (!Compiler::ParseAndAnalyze(info.parse_info())) return NoChange();
277 if (!Compiler::EnsureDeoptimizationSupport(&info)) return NoChange(); 293 if (!Compiler::EnsureDeoptimizationSupport(&info)) return NoChange();
278 294
279 if (info.scope()->arguments() != NULL && is_sloppy(info.language_mode())) { 295 if (info.scope()->arguments() != NULL && is_sloppy(info.language_mode())) {
280 // For now do not inline functions that use their arguments array. 296 // For now do not inline functions that use their arguments array.
281 TRACE("Not Inlining %s into %s because inlinee uses arguments array\n", 297 TRACE("Not inlining %s into %s because inlinee uses arguments array\n",
282 function->shared()->DebugName()->ToCString().get(), 298 function->shared()->DebugName()->ToCString().get(),
283 info_->shared_info()->DebugName()->ToCString().get()); 299 info_->shared_info()->DebugName()->ToCString().get());
284 return NoChange(); 300 return NoChange();
285 } 301 }
286 302
287 TRACE("Inlining %s into %s\n", 303 TRACE("Inlining %s into %s\n",
288 function->shared()->DebugName()->ToCString().get(), 304 function->shared()->DebugName()->ToCString().get(),
289 info_->shared_info()->DebugName()->ToCString().get()); 305 info_->shared_info()->DebugName()->ToCString().get());
290 306
291 Graph graph(info.zone()); 307 Graph graph(info.zone());
(...skipping 29 matching lines...) Expand all
321 337
322 // Remember that we inlined this function. 338 // Remember that we inlined this function.
323 info_->AddInlinedFunction(info.shared_info()); 339 info_->AddInlinedFunction(info.shared_info());
324 340
325 return InlineCall(node, frame_state, start, end); 341 return InlineCall(node, frame_state, start, end);
326 } 342 }
327 343
328 } // namespace compiler 344 } // namespace compiler
329 } // namespace internal 345 } // namespace internal
330 } // namespace v8 346 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698