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

Unified Diff: src/interpreter/bytecode-generator.cc

Issue 2387363003: [interpreter] Implement support for the --trace flag. (Closed)
Patch Set: Addressed comments. Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/interpreter/bytecode-generator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter/bytecode-generator.cc
diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc
index c7d333f0a534fc194c367304cbd8dafe99706248..c7b46e5fdb1995b77a1a35f775b7dcdefd81214c 100644
--- a/src/interpreter/bytecode-generator.cc
+++ b/src/interpreter/bytecode-generator.cc
@@ -217,10 +217,10 @@ class BytecodeGenerator::ControlScopeForTopLevel final
case CMD_CONTINUE:
UNREACHABLE();
case CMD_RETURN:
- generator()->builder()->Return();
+ generator()->BuildReturn();
return true;
case CMD_RETHROW:
- generator()->builder()->ReThrow();
+ generator()->BuildReThrow();
return true;
}
return false;
@@ -311,7 +311,7 @@ class BytecodeGenerator::ControlScopeForTryCatch final
case CMD_RETURN:
break;
case CMD_RETHROW:
- generator()->builder()->ReThrow();
+ generator()->BuildReThrow();
return true;
}
return false;
@@ -649,7 +649,13 @@ void BytecodeGenerator::GenerateBytecode(uintptr_t stack_limit) {
if (!label.is_bound()) builder()->Bind(&label);
}
- builder()->EnsureReturn();
+ // Emit an implicit return instruction in case control flow can fall off the
+ // end of the function without an explicit return being present on all paths.
+ if (builder()->RequiresImplicitReturn()) {
+ builder()->LoadUndefined();
+ BuildReturn();
+ }
+ DCHECK(!builder()->RequiresImplicitReturn());
}
void BytecodeGenerator::GenerateBytecodeBody() {
@@ -666,10 +672,8 @@ void BytecodeGenerator::GenerateBytecodeBody() {
// Build assignment to {new.target} variable if it is used.
VisitNewTargetVariable(scope()->new_target_var());
- // TODO(rmcilroy): Emit tracing call if requested to do so.
- if (FLAG_trace) {
- UNIMPLEMENTED();
- }
+ // Emit tracing call if requested to do so.
+ if (FLAG_trace) builder()->CallRuntime(Runtime::kTraceEnter);
// Visit declarations within the function scope.
VisitDeclarations(scope()->declarations());
@@ -1855,6 +1859,19 @@ void BytecodeGenerator::VisitVariableLoadForAccumulatorValue(
VisitVariableLoad(variable, slot, typeof_mode);
}
+void BytecodeGenerator::BuildReturn() {
+ if (FLAG_trace) {
+ RegisterAllocationScope register_scope(this);
+ Register result = register_allocator()->NewRegister();
+ // Runtime returns {result} value, preserving accumulator.
+ builder()->StoreAccumulatorInRegister(result).CallRuntime(
+ Runtime::kTraceExit, result);
+ }
+ builder()->Return();
+}
+
+void BytecodeGenerator::BuildReThrow() { builder()->ReThrow(); }
+
void BytecodeGenerator::BuildAbort(BailoutReason bailout_reason) {
RegisterAllocationScope register_scope(this);
Register reason = register_allocator()->NewRegister();
« no previous file with comments | « src/interpreter/bytecode-generator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698