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

Unified Diff: src/compiler/bytecode-graph-builder.cc

Issue 2329933003: [turbofan] Decouple OSR entry from {OsrPoll} bytecode. (Closed)
Patch Set: Add safety check. Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/bytecode-graph-builder.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/bytecode-graph-builder.cc
diff --git a/src/compiler/bytecode-graph-builder.cc b/src/compiler/bytecode-graph-builder.cc
index a7a1cb58f40c883488876446f3ddba8fe70121cc..5fb931f5d8d0e183eea305613b127d4c011cc0fa 100644
--- a/src/compiler/bytecode-graph-builder.cc
+++ b/src/compiler/bytecode-graph-builder.cc
@@ -648,10 +648,6 @@ VectorSlotPair BytecodeGraphBuilder::CreateVectorSlotPair(int slot_id) {
}
bool BytecodeGraphBuilder::CreateGraph() {
- // Set up the basic structure of the graph. Outputs for {Start} are
- // the formal parameters (including the receiver) plus context and
- // closure.
-
// Set up the basic structure of the graph. Outputs for {Start} are the formal
// parameters (including the receiver) plus new target, number of arguments,
// context and closure.
@@ -663,10 +659,6 @@ bool BytecodeGraphBuilder::CreateGraph() {
GetFunctionContext());
set_environment(&env);
- // For OSR add an {OsrNormalEntry} as the start of the top-level environment.
- // It will be replaced with {Dead} after typing and optimizations.
- if (!osr_ast_id_.IsNone()) NewNode(common()->OsrNormalEntry());
-
VisitBytecodes();
// Finish the basic structure of the graph.
@@ -704,12 +696,14 @@ void BytecodeGraphBuilder::VisitBytecodes() {
set_loop_analysis(&loop_analysis);
interpreter::BytecodeArrayIterator iterator(bytecode_array());
set_bytecode_iterator(&iterator);
+ BuildOSRNormalEntryPoint();
while (!iterator.done()) {
int current_offset = iterator.current_offset();
EnterAndExitExceptionHandlers(current_offset);
SwitchToMergeEnvironment(current_offset);
if (environment() != nullptr) {
BuildLoopHeaderEnvironment(current_offset);
+ BuildOSRLoopEntryPoint(current_offset);
switch (iterator.current_bytecode()) {
#define BYTECODE_CASE(name, ...) \
@@ -1632,14 +1626,7 @@ void BytecodeGraphBuilder::VisitStackCheck() {
environment()->RecordAfterState(node, &states);
}
-void BytecodeGraphBuilder::VisitOsrPoll() {
- // TODO(4764): This should be moved into the {VisitBytecodes} once we merge
- // the polling with existing bytecode. This will also guarantee that we are
- // not missing the OSR entry point, which we wouldn't catch right now.
- if (osr_ast_id_.ToInt() == bytecode_iterator().current_offset()) {
- environment()->PrepareForOsr();
- }
-}
+void BytecodeGraphBuilder::VisitOsrPoll() {}
void BytecodeGraphBuilder::VisitReturn() {
BuildLoopExitsForFunctionExit();
@@ -1812,6 +1799,25 @@ void BytecodeGraphBuilder::MergeControlToLeaveFunction(Node* exit) {
set_environment(nullptr);
}
+void BytecodeGraphBuilder::BuildOSRLoopEntryPoint(int current_offset) {
+ if (!osr_ast_id_.IsNone() && osr_ast_id_.ToInt() == current_offset) {
+ // For OSR add a special {OsrLoopEntry} node into the current loop header.
+ // It will be turned into a usable entry by the OSR deconstruction.
+ environment()->PrepareForOsr();
+ }
+}
+
+void BytecodeGraphBuilder::BuildOSRNormalEntryPoint() {
+ if (!osr_ast_id_.IsNone()) {
+ // For OSR add an {OsrNormalEntry} as the the top-level environment start.
+ // It will be replaced with {Dead} by the OSR deconstruction.
+ NewNode(common()->OsrNormalEntry());
+ // Note that the requested OSR entry point must be the target of a backward
+ // branch, otherwise there will not be a proper loop header available.
+ DCHECK(branch_analysis()->backward_branches_target(osr_ast_id_.ToInt()));
+ }
+}
+
void BytecodeGraphBuilder::BuildLoopExitsForBranch(int target_offset) {
int origin_offset = bytecode_iterator().current_offset();
// Only build loop exits for forward edges.
« no previous file with comments | « src/compiler/bytecode-graph-builder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698