OLD | NEW |
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/bytecode-graph-builder.h" | 5 #include "src/compiler/bytecode-graph-builder.h" |
6 | 6 |
7 #include "src/ast/ast.h" | 7 #include "src/ast/ast.h" |
8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
9 #include "src/compiler/access-builder.h" | 9 #include "src/compiler/access-builder.h" |
10 #include "src/compiler/compiler-source-position-table.h" | 10 #include "src/compiler/compiler-source-position-table.h" |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 } else { | 421 } else { |
422 UpdateStateValues(¶meters_state_values_, &values()->at(0), | 422 UpdateStateValues(¶meters_state_values_, &values()->at(0), |
423 parameter_count()); | 423 parameter_count()); |
424 } | 424 } |
425 | 425 |
426 Node* registers_state_values = | 426 Node* registers_state_values = |
427 GetStateValuesFromCache(&values()->at(register_base()), register_count(), | 427 GetStateValuesFromCache(&values()->at(register_base()), register_count(), |
428 liveness ? &liveness->bit_vector() : nullptr, 0); | 428 liveness ? &liveness->bit_vector() : nullptr, 0); |
429 | 429 |
430 bool accumulator_is_live = !liveness || liveness->AccumulatorIsLive(); | 430 bool accumulator_is_live = !liveness || liveness->AccumulatorIsLive(); |
431 Node* accumulator_state_values; | 431 Node* accumulator_state_value = |
432 if (parameter_count() == 1 && accumulator_is_live && | 432 accumulator_is_live ? values()->at(accumulator_base()) |
433 values()->at(accumulator_base()) == values()->at(0)) { | 433 : builder()->jsgraph()->OptimizedOutConstant(); |
434 // Re-use the parameter state values if there happens to only be one | |
435 // parameter and the accumulator is live and holds that parameter's value. | |
436 accumulator_state_values = parameters_state_values_; | |
437 } else { | |
438 // Otherwise, use the state values cache to hopefully re-use local register | |
439 // state values (if there is only one local register), or at the very least | |
440 // re-use previous accumulator state values. | |
441 accumulator_state_values = GetStateValuesFromCache( | |
442 &values()->at(accumulator_base()), 1, | |
443 liveness ? &liveness->bit_vector() : nullptr, register_count()); | |
444 } | |
445 | 434 |
446 const Operator* op = common()->FrameState( | 435 const Operator* op = common()->FrameState( |
447 bailout_id, combine, builder()->frame_state_function_info()); | 436 bailout_id, combine, builder()->frame_state_function_info()); |
448 Node* result = graph()->NewNode( | 437 Node* result = graph()->NewNode( |
449 op, parameters_state_values_, registers_state_values, | 438 op, parameters_state_values_, registers_state_values, |
450 accumulator_state_values, Context(), builder()->GetFunctionClosure(), | 439 accumulator_state_value, Context(), builder()->GetFunctionClosure(), |
451 builder()->graph()->start()); | 440 builder()->graph()->start()); |
452 | 441 |
453 return result; | 442 return result; |
454 } | 443 } |
455 | 444 |
456 BytecodeGraphBuilder::BytecodeGraphBuilder( | 445 BytecodeGraphBuilder::BytecodeGraphBuilder( |
457 Zone* local_zone, Handle<SharedFunctionInfo> shared_info, | 446 Zone* local_zone, Handle<SharedFunctionInfo> shared_info, |
458 Handle<FeedbackVector> feedback_vector, BailoutId osr_ast_id, | 447 Handle<FeedbackVector> feedback_vector, BailoutId osr_ast_id, |
459 JSGraph* jsgraph, float invocation_frequency, | 448 JSGraph* jsgraph, float invocation_frequency, |
460 SourcePositionTable* source_positions, int inlining_id, | 449 SourcePositionTable* source_positions, int inlining_id, |
(...skipping 2364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2825 it->source_position().ScriptOffset(), start_position_.InliningId())); | 2814 it->source_position().ScriptOffset(), start_position_.InliningId())); |
2826 it->Advance(); | 2815 it->Advance(); |
2827 } else { | 2816 } else { |
2828 DCHECK_GT(it->code_offset(), offset); | 2817 DCHECK_GT(it->code_offset(), offset); |
2829 } | 2818 } |
2830 } | 2819 } |
2831 | 2820 |
2832 } // namespace compiler | 2821 } // namespace compiler |
2833 } // namespace internal | 2822 } // namespace internal |
2834 } // namespace v8 | 2823 } // namespace v8 |
OLD | NEW |