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

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

Issue 1404123002: [turbofan] Move native context specialization before inlining. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: No more JSGraphReducer in JSInliner Created 5 years, 2 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 | src/compiler/pipeline.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-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.h" 9 #include "src/compiler.h"
10 #include "src/compiler/all-nodes.h" 10 #include "src/compiler/all-nodes.h"
11 #include "src/compiler/ast-graph-builder.h" 11 #include "src/compiler/ast-graph-builder.h"
12 #include "src/compiler/common-operator.h" 12 #include "src/compiler/common-operator.h"
13 #include "src/compiler/common-operator-reducer.h"
14 #include "src/compiler/dead-code-elimination.h"
15 #include "src/compiler/graph-reducer.h"
16 #include "src/compiler/js-global-specialization.h"
13 #include "src/compiler/js-operator.h" 17 #include "src/compiler/js-operator.h"
14 #include "src/compiler/node-matchers.h" 18 #include "src/compiler/node-matchers.h"
15 #include "src/compiler/node-properties.h" 19 #include "src/compiler/node-properties.h"
16 #include "src/compiler/operator-properties.h" 20 #include "src/compiler/operator-properties.h"
17 #include "src/full-codegen/full-codegen.h" 21 #include "src/full-codegen/full-codegen.h"
18 #include "src/isolate-inl.h" 22 #include "src/isolate-inl.h"
19 #include "src/parser.h" 23 #include "src/parser.h"
20 #include "src/rewriter.h" 24 #include "src/rewriter.h"
21 #include "src/scopes.h" 25 #include "src/scopes.h"
22 26
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 TRACE("Not inlining %s into %s because call is recursive\n", 307 TRACE("Not inlining %s into %s because call is recursive\n",
304 function->shared()->DebugName()->ToCString().get(), 308 function->shared()->DebugName()->ToCString().get(),
305 info_->shared_info()->DebugName()->ToCString().get()); 309 info_->shared_info()->DebugName()->ToCString().get());
306 return NoChange(); 310 return NoChange();
307 } 311 }
308 } 312 }
309 313
310 Zone zone; 314 Zone zone;
311 ParseInfo parse_info(&zone, function); 315 ParseInfo parse_info(&zone, function);
312 CompilationInfo info(&parse_info); 316 CompilationInfo info(&parse_info);
313 if (info_->is_deoptimization_enabled()) info.MarkAsDeoptimizationEnabled(); 317 if (info_->is_deoptimization_enabled()) {
318 info.MarkAsDeoptimizationEnabled();
319 }
320 if (info_->is_native_context_specializing()) {
321 info.MarkAsNativeContextSpecializing();
322 }
323 if (info_->is_typing_enabled()) {
324 info.MarkAsTypingEnabled();
325 }
314 326
315 if (!Compiler::ParseAndAnalyze(info.parse_info())) { 327 if (!Compiler::ParseAndAnalyze(info.parse_info())) {
316 TRACE("Not inlining %s into %s because parsing failed\n", 328 TRACE("Not inlining %s into %s because parsing failed\n",
317 function->shared()->DebugName()->ToCString().get(), 329 function->shared()->DebugName()->ToCString().get(),
318 info_->shared_info()->DebugName()->ToCString().get()); 330 info_->shared_info()->DebugName()->ToCString().get());
319 if (info_->isolate()->has_pending_exception()) { 331 if (info_->isolate()->has_pending_exception()) {
320 info_->isolate()->clear_pending_exception(); 332 info_->isolate()->clear_pending_exception();
321 } 333 }
322 return NoChange(); 334 return NoChange();
323 } 335 }
324 336
325 if (!Compiler::EnsureDeoptimizationSupport(&info)) { 337 if (!Compiler::EnsureDeoptimizationSupport(&info)) {
326 TRACE("Not inlining %s into %s because deoptimization support failed\n", 338 TRACE("Not inlining %s into %s because deoptimization support failed\n",
327 function->shared()->DebugName()->ToCString().get(), 339 function->shared()->DebugName()->ToCString().get(),
328 info_->shared_info()->DebugName()->ToCString().get()); 340 info_->shared_info()->DebugName()->ToCString().get());
329 return NoChange(); 341 return NoChange();
330 } 342 }
331 343
332 TRACE("Inlining %s into %s\n", 344 TRACE("Inlining %s into %s\n",
333 function->shared()->DebugName()->ToCString().get(), 345 function->shared()->DebugName()->ToCString().get(),
334 info_->shared_info()->DebugName()->ToCString().get()); 346 info_->shared_info()->DebugName()->ToCString().get());
335 347
336 Graph graph(info.zone()); 348 Graph graph(info.zone());
337 JSGraph jsgraph(info.isolate(), &graph, jsgraph_->common(), 349 JSGraph jsgraph(info.isolate(), &graph, jsgraph_->common(),
338 jsgraph_->javascript(), jsgraph_->machine()); 350 jsgraph_->javascript(), jsgraph_->machine());
339 AstGraphBuilder graph_builder(local_zone_, &info, &jsgraph); 351 AstGraphBuilder graph_builder(local_zone_, &info, &jsgraph);
340 graph_builder.CreateGraph(false); 352 graph_builder.CreateGraph(false);
341 353
354 // TODO(mstarzinger): Unify this with the Pipeline once JSInliner refactoring
355 // starts.
356 if (info.is_native_context_specializing()) {
357 GraphReducer graph_reducer(local_zone_, &graph, jsgraph.Dead());
358 DeadCodeElimination dead_code_elimination(&graph_reducer, &graph,
359 jsgraph.common());
360 CommonOperatorReducer common_reducer(&graph_reducer, &graph,
361 jsgraph.common(), jsgraph.machine());
362 JSGlobalSpecialization::Flags flags = JSGlobalSpecialization::kNoFlags;
363 if (info.is_deoptimization_enabled()) {
364 flags |= JSGlobalSpecialization::kDeoptimizationEnabled;
365 }
366 if (info.is_typing_enabled()) {
367 flags |= JSGlobalSpecialization::kTypingEnabled;
368 }
369 JSGlobalSpecialization global_specialization(
370 &graph_reducer, &jsgraph, flags,
371 handle(info.global_object(), info.isolate()), info_->dependencies());
372 graph_reducer.AddReducer(&dead_code_elimination);
373 graph_reducer.AddReducer(&common_reducer);
374 graph_reducer.AddReducer(&global_specialization);
375 graph_reducer.ReduceGraph();
376 }
377
342 // The inlinee specializes to the context from the JSFunction object. 378 // The inlinee specializes to the context from the JSFunction object.
343 // TODO(turbofan): We might want to load the context from the JSFunction at 379 // TODO(turbofan): We might want to load the context from the JSFunction at
344 // runtime in case we only know the SharedFunctionInfo once we have dynamic 380 // runtime in case we only know the SharedFunctionInfo once we have dynamic
345 // type feedback in the compiler. 381 // type feedback in the compiler.
346 Node* context = jsgraph_->Constant(handle(function->context())); 382 Node* context = jsgraph_->Constant(handle(function->context()));
347 383
348 CopyVisitor visitor(&graph, jsgraph_->graph(), info.zone()); 384 CopyVisitor visitor(&graph, jsgraph_->graph(), info.zone());
349 visitor.CopyGraph(); 385 visitor.CopyGraph();
350 386
351 Node* start = visitor.GetCopy(graph.start()); 387 Node* start = visitor.GetCopy(graph.start());
(...skipping 15 matching lines...) Expand all
367 403
368 // Remember that we inlined this function. 404 // Remember that we inlined this function.
369 info_->AddInlinedFunction(info.shared_info()); 405 info_->AddInlinedFunction(info.shared_info());
370 406
371 return InlineCall(node, context, frame_state, start, end); 407 return InlineCall(node, context, frame_state, start, end);
372 } 408 }
373 409
374 } // namespace compiler 410 } // namespace compiler
375 } // namespace internal 411 } // namespace internal
376 } // namespace v8 412 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/pipeline.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698