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

Side by Side Diff: src/compiler/bytecode-graph-builder.cc

Issue 2465913002: [turbofan] Move OSR BailoutId translation into graph builder. (Closed)
Patch Set: Created 4 years, 1 month 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
OLDNEW
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/compilation-info.h" 9 #include "src/compilation-info.h"
10 #include "src/compiler/bytecode-branch-analysis.h" 10 #include "src/compiler/bytecode-branch-analysis.h"
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 invocation_frequency_(invocation_frequency), 497 invocation_frequency_(invocation_frequency),
498 bytecode_array_(handle(info->shared_info()->bytecode_array())), 498 bytecode_array_(handle(info->shared_info()->bytecode_array())),
499 exception_handler_table_( 499 exception_handler_table_(
500 handle(HandlerTable::cast(bytecode_array()->handler_table()))), 500 handle(HandlerTable::cast(bytecode_array()->handler_table()))),
501 feedback_vector_(handle(info->closure()->feedback_vector())), 501 feedback_vector_(handle(info->closure()->feedback_vector())),
502 frame_state_function_info_(common()->CreateFrameStateFunctionInfo( 502 frame_state_function_info_(common()->CreateFrameStateFunctionInfo(
503 FrameStateType::kInterpretedFunction, 503 FrameStateType::kInterpretedFunction,
504 bytecode_array()->parameter_count(), 504 bytecode_array()->parameter_count(),
505 bytecode_array()->register_count(), info->shared_info())), 505 bytecode_array()->register_count(), info->shared_info())),
506 osr_ast_id_(info->osr_ast_id()), 506 osr_ast_id_(info->osr_ast_id()),
507 osr_loop_offset_(-1),
507 merge_environments_(local_zone), 508 merge_environments_(local_zone),
508 exception_handlers_(local_zone), 509 exception_handlers_(local_zone),
509 current_exception_handler_(0), 510 current_exception_handler_(0),
510 input_buffer_size_(0), 511 input_buffer_size_(0),
511 input_buffer_(nullptr), 512 input_buffer_(nullptr),
512 exit_controls_(local_zone), 513 exit_controls_(local_zone),
513 is_liveness_analysis_enabled_(FLAG_analyze_environment_liveness && 514 is_liveness_analysis_enabled_(FLAG_analyze_environment_liveness &&
514 info->is_deoptimization_enabled()), 515 info->is_deoptimization_enabled()),
515 state_values_cache_(jsgraph), 516 state_values_cache_(jsgraph),
516 liveness_analyzer_( 517 liveness_analyzer_(
(...skipping 1409 matching lines...) Expand 10 before | Expand all | Expand 10 after
1926 } 1927 }
1927 set_environment(nullptr); 1928 set_environment(nullptr);
1928 } 1929 }
1929 1930
1930 void BytecodeGraphBuilder::MergeControlToLeaveFunction(Node* exit) { 1931 void BytecodeGraphBuilder::MergeControlToLeaveFunction(Node* exit) {
1931 exit_controls_.push_back(exit); 1932 exit_controls_.push_back(exit);
1932 set_environment(nullptr); 1933 set_environment(nullptr);
1933 } 1934 }
1934 1935
1935 void BytecodeGraphBuilder::BuildOSRLoopEntryPoint(int current_offset) { 1936 void BytecodeGraphBuilder::BuildOSRLoopEntryPoint(int current_offset) {
1936 if (!osr_ast_id_.IsNone() && osr_ast_id_.ToInt() == current_offset) { 1937 if (!osr_ast_id_.IsNone() && osr_loop_offset_ == current_offset) {
1937 // For OSR add a special {OsrLoopEntry} node into the current loop header. 1938 // For OSR add a special {OsrLoopEntry} node into the current loop header.
1938 // It will be turned into a usable entry by the OSR deconstruction. 1939 // It will be turned into a usable entry by the OSR deconstruction.
1939 Environment* loop_env = merge_environments_[current_offset]; 1940 Environment* loop_env = merge_environments_[current_offset];
1940 Environment* osr_env = loop_env->CopyForOsrEntry(); 1941 Environment* osr_env = loop_env->CopyForOsrEntry();
1941 osr_env->PrepareForOsrEntry(); 1942 osr_env->PrepareForOsrEntry();
1942 loop_env->Merge(osr_env); 1943 loop_env->Merge(osr_env);
1943 } 1944 }
1944 } 1945 }
1945 1946
1946 void BytecodeGraphBuilder::BuildOSRNormalEntryPoint() { 1947 void BytecodeGraphBuilder::BuildOSRNormalEntryPoint() {
1947 if (!osr_ast_id_.IsNone()) { 1948 if (!osr_ast_id_.IsNone()) {
1948 // For OSR add an {OsrNormalEntry} as the the top-level environment start. 1949 // For OSR add an {OsrNormalEntry} as the the top-level environment start.
1949 // It will be replaced with {Dead} by the OSR deconstruction. 1950 // It will be replaced with {Dead} by the OSR deconstruction.
1950 NewNode(common()->OsrNormalEntry()); 1951 NewNode(common()->OsrNormalEntry());
1951 // Note that the requested OSR entry point must be the target of a backward 1952 // Translate the offset of the jump instruction to the jump target offset of
1952 // branch, otherwise there will not be a proper loop header available. 1953 // that instruction so that the derived BailoutId points to the loop header.
1953 DCHECK(branch_analysis()->backward_branches_target(osr_ast_id_.ToInt())); 1954 osr_loop_offset_ = loop_analysis()->GetLoopOffsetFor(osr_ast_id_.ToInt());
1955 DCHECK(branch_analysis()->backward_branches_target(osr_loop_offset_));
1954 } 1956 }
1955 } 1957 }
1956 1958
1957 void BytecodeGraphBuilder::BuildLoopExitsForBranch(int target_offset) { 1959 void BytecodeGraphBuilder::BuildLoopExitsForBranch(int target_offset) {
1958 int origin_offset = bytecode_iterator().current_offset(); 1960 int origin_offset = bytecode_iterator().current_offset();
1959 // Only build loop exits for forward edges. 1961 // Only build loop exits for forward edges.
1960 if (target_offset > origin_offset) { 1962 if (target_offset > origin_offset) {
1961 BuildLoopExitsUntilLoop(loop_analysis()->GetLoopOffsetFor(target_offset)); 1963 BuildLoopExitsUntilLoop(loop_analysis()->GetLoopOffsetFor(target_offset));
1962 } 1964 }
1963 } 1965 }
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
2233 source_positions_->set_current_position(it->source_position()); 2235 source_positions_->set_current_position(it->source_position());
2234 it->Advance(); 2236 it->Advance();
2235 } else { 2237 } else {
2236 DCHECK_GT(it->code_offset(), offset); 2238 DCHECK_GT(it->code_offset(), offset);
2237 } 2239 }
2238 } 2240 }
2239 2241
2240 } // namespace compiler 2242 } // namespace compiler
2241 } // namespace internal 2243 } // namespace internal
2242 } // namespace v8 2244 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698