Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index aa336246e1340cbe8b37a29d6ff18f228b0e7779..317a51fc844aa4d4b53c7905ef65bb1fc30cc63a 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -2274,9 +2274,14 @@ MaybeLocal<Function> ScriptCompiler::CompileFunctionInContext( |
Function); |
TRACE_EVENT0("v8", "V8.ScriptCompiler"); |
i::Handle<i::String> source_string; |
+ int parameters_end_pos = i::kNoSourcePosition; |
auto factory = isolate->factory(); |
if (arguments_count) { |
- source_string = factory->NewStringFromStaticChars("(function("); |
+ if (i::FLAG_harmony_function_tostring) { |
+ source_string = factory->NewStringFromStaticChars("(function anonymous("); |
+ } else { |
+ source_string = factory->NewStringFromStaticChars("(function("); |
+ } |
for (size_t i = 0; i < arguments_count; ++i) { |
IsIdentifierHelper helper; |
if (!helper.Check(*Utils::OpenHandle(*arguments[i]))) { |
@@ -2294,12 +2299,24 @@ MaybeLocal<Function> ScriptCompiler::CompileFunctionInContext( |
',')).ToHandle(&source_string); |
RETURN_ON_FAILED_EXECUTION(Function); |
} |
- auto brackets = factory->NewStringFromStaticChars("){"); |
+ i::Handle<i::String> brackets; |
+ if (i::FLAG_harmony_function_tostring) { |
+ brackets = factory->NewStringFromStaticChars("\n) {"); |
+ parameters_end_pos = source_string->length() - 3; |
+ } else { |
+ brackets = factory->NewStringFromStaticChars("){"); |
+ } |
has_pending_exception = !factory->NewConsString(source_string, brackets) |
.ToHandle(&source_string); |
RETURN_ON_FAILED_EXECUTION(Function); |
} else { |
- source_string = factory->NewStringFromStaticChars("(function(){"); |
+ if (i::FLAG_harmony_function_tostring) { |
+ source_string = |
+ factory->NewStringFromStaticChars("(function anonymous(\n) {"); |
+ parameters_end_pos = source_string->length() - 3; |
+ } else { |
+ source_string = factory->NewStringFromStaticChars("(function(){"); |
+ } |
} |
int scope_position = source_string->length(); |
@@ -2349,9 +2366,9 @@ MaybeLocal<Function> ScriptCompiler::CompileFunctionInContext( |
has_pending_exception = |
!i::Compiler::GetFunctionFromEval( |
source_string, outer_info, context, i::SLOPPY, |
- i::ONLY_SINGLE_FUNCTION_LITERAL, eval_scope_position, eval_position, |
- line_offset, column_offset - scope_position, name_obj, |
- source->resource_options) |
+ i::ONLY_SINGLE_FUNCTION_LITERAL, parameters_end_pos, |
+ eval_scope_position, eval_position, line_offset, |
+ column_offset - scope_position, name_obj, source->resource_options) |
.ToHandle(&fun); |
if (has_pending_exception) { |
isolate->ReportPendingMessages(); |