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

Unified Diff: src/api.cc

Issue 2156303002: Implement new Function.prototype.toString and fix CreateDynamicFunction parsing (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 3 years, 10 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 | « no previous file | src/bootstrapper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « no previous file | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698