| OLD | NEW |
| 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" | 13 #include "src/compiler/graph-reducer.h" |
| 16 #include "src/compiler/js-global-object-specialization.h" | |
| 17 #include "src/compiler/js-native-context-specialization.h" | |
| 18 #include "src/compiler/js-operator.h" | 14 #include "src/compiler/js-operator.h" |
| 19 #include "src/compiler/node-matchers.h" | 15 #include "src/compiler/node-matchers.h" |
| 20 #include "src/compiler/node-properties.h" | 16 #include "src/compiler/node-properties.h" |
| 21 #include "src/compiler/operator-properties.h" | 17 #include "src/compiler/operator-properties.h" |
| 22 #include "src/isolate-inl.h" | 18 #include "src/isolate-inl.h" |
| 23 #include "src/parser.h" | 19 #include "src/parser.h" |
| 24 #include "src/rewriter.h" | 20 #include "src/rewriter.h" |
| 25 #include "src/scopes.h" | 21 #include "src/scopes.h" |
| 26 | 22 |
| 27 namespace v8 { | 23 namespace v8 { |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 info_->shared_info()->DebugName()->ToCString().get()); | 345 info_->shared_info()->DebugName()->ToCString().get()); |
| 350 return NoChange(); | 346 return NoChange(); |
| 351 } | 347 } |
| 352 | 348 |
| 353 Zone zone; | 349 Zone zone; |
| 354 ParseInfo parse_info(&zone, function); | 350 ParseInfo parse_info(&zone, function); |
| 355 CompilationInfo info(&parse_info); | 351 CompilationInfo info(&parse_info); |
| 356 if (info_->is_deoptimization_enabled()) { | 352 if (info_->is_deoptimization_enabled()) { |
| 357 info.MarkAsDeoptimizationEnabled(); | 353 info.MarkAsDeoptimizationEnabled(); |
| 358 } | 354 } |
| 359 if (info_->is_native_context_specializing()) { | |
| 360 info.MarkAsNativeContextSpecializing(); | |
| 361 } | |
| 362 | 355 |
| 363 if (!Compiler::ParseAndAnalyze(info.parse_info())) { | 356 if (!Compiler::ParseAndAnalyze(info.parse_info())) { |
| 364 TRACE("Not inlining %s into %s because parsing failed\n", | 357 TRACE("Not inlining %s into %s because parsing failed\n", |
| 365 function->shared()->DebugName()->ToCString().get(), | 358 function->shared()->DebugName()->ToCString().get(), |
| 366 info_->shared_info()->DebugName()->ToCString().get()); | 359 info_->shared_info()->DebugName()->ToCString().get()); |
| 367 if (info_->isolate()->has_pending_exception()) { | 360 if (info_->isolate()->has_pending_exception()) { |
| 368 info_->isolate()->clear_pending_exception(); | 361 info_->isolate()->clear_pending_exception(); |
| 369 } | 362 } |
| 370 return NoChange(); | 363 return NoChange(); |
| 371 } | 364 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 // TODO(mstarzinger): We could use the temporary zone for the graph because | 396 // TODO(mstarzinger): We could use the temporary zone for the graph because |
| 404 // nodes are copied. This however leads to Zone-Types being allocated in the | 397 // nodes are copied. This however leads to Zone-Types being allocated in the |
| 405 // wrong zone and makes the engine explode at high speeds. Explosion bad! | 398 // wrong zone and makes the engine explode at high speeds. Explosion bad! |
| 406 Graph graph(jsgraph_->zone()); | 399 Graph graph(jsgraph_->zone()); |
| 407 JSGraph jsgraph(info.isolate(), &graph, jsgraph_->common(), | 400 JSGraph jsgraph(info.isolate(), &graph, jsgraph_->common(), |
| 408 jsgraph_->javascript(), jsgraph_->simplified(), | 401 jsgraph_->javascript(), jsgraph_->simplified(), |
| 409 jsgraph_->machine()); | 402 jsgraph_->machine()); |
| 410 AstGraphBuilder graph_builder(local_zone_, &info, &jsgraph); | 403 AstGraphBuilder graph_builder(local_zone_, &info, &jsgraph); |
| 411 graph_builder.CreateGraph(false); | 404 graph_builder.CreateGraph(false); |
| 412 | 405 |
| 413 // TODO(mstarzinger): Unify this with the Pipeline once JSInliner refactoring | |
| 414 // starts. | |
| 415 if (info.is_native_context_specializing()) { | |
| 416 GraphReducer graph_reducer(local_zone_, &graph, jsgraph.Dead()); | |
| 417 DeadCodeElimination dead_code_elimination(&graph_reducer, &graph, | |
| 418 jsgraph.common()); | |
| 419 CommonOperatorReducer common_reducer(&graph_reducer, &graph, | |
| 420 jsgraph.common(), jsgraph.machine()); | |
| 421 JSGlobalObjectSpecialization global_object_specialization( | |
| 422 &graph_reducer, &jsgraph, | |
| 423 info.is_deoptimization_enabled() | |
| 424 ? JSGlobalObjectSpecialization::kDeoptimizationEnabled | |
| 425 : JSGlobalObjectSpecialization::kNoFlags, | |
| 426 handle(info.global_object(), info.isolate()), info_->dependencies()); | |
| 427 JSNativeContextSpecialization native_context_specialization( | |
| 428 &graph_reducer, &jsgraph, | |
| 429 info.is_deoptimization_enabled() | |
| 430 ? JSNativeContextSpecialization::kDeoptimizationEnabled | |
| 431 : JSNativeContextSpecialization::kNoFlags, | |
| 432 handle(info.global_object()->native_context(), info.isolate()), | |
| 433 info_->dependencies(), local_zone_); | |
| 434 graph_reducer.AddReducer(&dead_code_elimination); | |
| 435 graph_reducer.AddReducer(&common_reducer); | |
| 436 graph_reducer.AddReducer(&global_object_specialization); | |
| 437 graph_reducer.AddReducer(&native_context_specialization); | |
| 438 graph_reducer.ReduceGraph(); | |
| 439 } | |
| 440 | |
| 441 CopyVisitor visitor(&graph, jsgraph_->graph(), &zone); | 406 CopyVisitor visitor(&graph, jsgraph_->graph(), &zone); |
| 442 visitor.CopyGraph(); | 407 visitor.CopyGraph(); |
| 443 | 408 |
| 444 Node* start = visitor.GetCopy(graph.start()); | 409 Node* start = visitor.GetCopy(graph.start()); |
| 445 Node* end = visitor.GetCopy(graph.end()); | 410 Node* end = visitor.GetCopy(graph.end()); |
| 446 Node* frame_state = call.frame_state_after(); | 411 Node* frame_state = call.frame_state_after(); |
| 447 | 412 |
| 448 // Insert nodes around the call that model the behavior required for a | 413 // Insert nodes around the call that model the behavior required for a |
| 449 // constructor dispatch and turn the constructor call into a regular call. | 414 // constructor dispatch and turn the constructor call into a regular call. |
| 450 // This models the behavior usually accomplished by our {JSConstructStub}. | 415 // This models the behavior usually accomplished by our {JSConstructStub}. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 node, frame_state, call.formal_arguments(), | 482 node, frame_state, call.formal_arguments(), |
| 518 FrameStateType::kArgumentsAdaptor, info.shared_info()); | 483 FrameStateType::kArgumentsAdaptor, info.shared_info()); |
| 519 } | 484 } |
| 520 | 485 |
| 521 return InlineCall(node, context, frame_state, start, end); | 486 return InlineCall(node, context, frame_state, start, end); |
| 522 } | 487 } |
| 523 | 488 |
| 524 } // namespace compiler | 489 } // namespace compiler |
| 525 } // namespace internal | 490 } // namespace internal |
| 526 } // namespace v8 | 491 } // namespace v8 |
| OLD | NEW |