| Index: src/api.cc
|
| diff --git a/src/api.cc b/src/api.cc
|
| index 955e0832ed73317ff32242d9675d51416d5bc0ff..f7bdf6770f14ab816df8bdd0c190839393e674e5 100644
|
| --- a/src/api.cc
|
| +++ b/src/api.cc
|
| @@ -2275,9 +2275,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]))) {
|
| @@ -2295,12 +2300,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();
|
| @@ -2350,9 +2367,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();
|
|
|