Index: src/x64/full-codegen-x64.cc |
diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc |
index 587f73b882fac02bb5346e500922f4191e3cbddc..9091a54d8df93d681532280ac55dd2db52bf3c18 100644 |
--- a/src/x64/full-codegen-x64.cc |
+++ b/src/x64/full-codegen-x64.cc |
@@ -333,7 +333,21 @@ void FullCodeGenerator::EmitReturnSequence() { |
Label check_exit_codesize; |
masm_->bind(&check_exit_codesize); |
#endif |
- CodeGenerator::RecordPositions(masm_, function()->end_position() - 1); |
+ Scope* scope = function()->scope(); |
+ if (scope->is_function_scope()) { |
+ // Set the source position of the return sequence to the position |
+ // of the closing brace '}'. |
+ CodeGenerator::RecordPositions(masm_, function()->end_position() - 1); |
+ } else { |
+ ASSERT(scope->is_global_scope() || scope->is_eval_scope()); |
+ // Set the source position to one character past the source code, such |
+ // that it definitely is not in the source code range of an immediate |
+ // inner scope. For example in |
+ // eval('with ({x:1}) x = 1'); |
+ // the end position of the function generated for executing the eval code |
+ // coincides with the end of the with scope which is the position of '1'. |
+ CodeGenerator::RecordPositions(masm_, function()->end_position()); |
+ } |
__ RecordJSReturn(); |
// Do not use the leave instruction here because it is too short to |
// patch with the code required by the debugger. |