Reviewers: marja,
Description:
Pass Isolate* more explicitly in Parser, with less reliance on
info->isolate().
[email protected]
BUG=
Please review this at https://codereview.chromium.org/935413003/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+33, -34 lines):
M src/api.cc
M src/parser.h
M src/parser.cc
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index
da1c0e74618c8e448a6705e8e1b5d5f7f2a2c06c..476eff4c41672425da5d7fd064851063bfe6ded1
100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -1825,8 +1825,9 @@ Local<Script> ScriptCompiler::Compile(Isolate*
v8_isolate,
// Do the parsing tasks which need to be done on the main thread. This
will
// also handle parse errors.
- source->parser->Internalize(source->info.get());
- source->parser->HandleSourceURLComments(source->info.get());
+ source->parser->Internalize(isolate, script,
+ source->info->function() == NULL);
+ source->parser->HandleSourceURLComments(isolate, script);
i::Handle<i::SharedFunctionInfo> result =
i::Handle<i::SharedFunctionInfo>::null();
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index
bb8cb52b75068f0aee6941880fd7d1ecfe58bd29..875f61b05cabdb62d1c9a99656cce9a6226f54c0
100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -822,7 +822,7 @@ Parser::Parser(CompilationInfo* info, uintptr_t
stack_limit, uint32_t hash_seed,
}
-FunctionLiteral* Parser::ParseProgram(CompilationInfo* info) {
+FunctionLiteral* Parser::ParseProgram(Isolate* isolate, CompilationInfo*
info) {
// TODO(bmeurer): We temporarily need to pass allow_nesting = true here,
// see comment for HistogramTimerScope class.
@@ -830,7 +830,6 @@ FunctionLiteral* Parser::ParseProgram(CompilationInfo*
info) {
// called in the main thread.
DCHECK(parsing_on_main_thread_);
- Isolate* isolate = info->isolate();
HistogramTimerScope timer_scope(isolate->counters()->parse(), true);
Handle<String> source(String::cast(info->script()->source()));
isolate->counters()->total_parse_size()->Increment(source->length());
@@ -871,7 +870,7 @@ FunctionLiteral* Parser::ParseProgram(CompilationInfo*
info) {
if (eval_scope != NULL) {
eval_scope->set_end_position(source->length());
}
- HandleSourceURLComments(info);
+ HandleSourceURLComments(isolate, info->script());
if (FLAG_trace_parse && result != NULL) {
double ms = timer.Elapsed().InMillisecondsF();
@@ -991,13 +990,13 @@ FunctionLiteral*
Parser::DoParseProgram(CompilationInfo* info, Scope** scope,
}
-FunctionLiteral* Parser::ParseLazy(CompilationInfo* info) {
+FunctionLiteral* Parser::ParseLazy(Isolate* isolate, CompilationInfo*
info) {
// It's OK to use the Isolate & counters here, since this function is
only
// called in the main thread.
DCHECK(parsing_on_main_thread_);
- HistogramTimerScope
timer_scope(info->isolate()->counters()->parse_lazy());
+ HistogramTimerScope timer_scope(isolate->counters()->parse_lazy());
Handle<String> source(String::cast(info->script()->source()));
-
info->isolate()->counters()->total_parse_size()->Increment(source->length());
+ isolate->counters()->total_parse_size()->Increment(source->length());
base::ElapsedTimer timer;
if (FLAG_trace_parse) {
timer.Start();
@@ -1012,12 +1011,12 @@ FunctionLiteral* Parser::ParseLazy(CompilationInfo*
info) {
Handle<ExternalTwoByteString>::cast(source),
shared_info->start_position(),
shared_info->end_position());
- result = ParseLazy(info, &stream);
+ result = ParseLazy(isolate, info, &stream);
} else {
GenericStringUtf16CharacterStream stream(source,
shared_info->start_position(),
shared_info->end_position());
- result = ParseLazy(info, &stream);
+ result = ParseLazy(isolate, info, &stream);
}
if (FLAG_trace_parse && result != NULL) {
@@ -1029,7 +1028,7 @@ FunctionLiteral* Parser::ParseLazy(CompilationInfo*
info) {
}
-FunctionLiteral* Parser::ParseLazy(CompilationInfo* info,
+FunctionLiteral* Parser::ParseLazy(Isolate* isolate, CompilationInfo* info,
Utf16CharacterStream* source) {
Handle<SharedFunctionInfo> shared_info = info->shared_info();
scanner_.Initialize(source);
@@ -1055,7 +1054,7 @@ FunctionLiteral* Parser::ParseLazy(CompilationInfo*
info,
// Ok to use Isolate here, since lazy function parsing is only done
in the
// main thread.
DCHECK(parsing_on_main_thread_);
- scope = Scope::DeserializeScopeChain(info->isolate(), zone(),
+ scope = Scope::DeserializeScopeChain(isolate, zone(),
info->closure()->context(),
scope);
}
original_scope_ = scope;
@@ -4236,16 +4235,15 @@ IterationStatement*
Parser::LookupContinueTarget(const AstRawString* label,
}
-void Parser::HandleSourceURLComments(CompilationInfo* info) {
+void Parser::HandleSourceURLComments(Isolate* isolate, Handle<Script>
script) {
if (scanner_.source_url()->length() > 0) {
- Handle<String> source_url =
- scanner_.source_url()->Internalize(info->isolate());
- info->script()->set_source_url(*source_url);
+ Handle<String> source_url =
scanner_.source_url()->Internalize(isolate);
+ script->set_source_url(*source_url);
}
if (scanner_.source_mapping_url()->length() > 0) {
Handle<String> source_mapping_url =
- scanner_.source_mapping_url()->Internalize(info->isolate());
- info->script()->set_source_mapping_url(*source_mapping_url);
+ scanner_.source_mapping_url()->Internalize(isolate);
+ script->set_source_mapping_url(*source_mapping_url);
}
}
@@ -4299,16 +4297,16 @@ void Parser::ThrowPendingError(Isolate* isolate,
Handle<Script> script) {
}
-void Parser::Internalize(CompilationInfo* info) {
+void Parser::Internalize(Isolate* isolate, Handle<Script> script, bool
error) {
// Internalize strings.
- ast_value_factory()->Internalize(info->isolate());
+ ast_value_factory()->Internalize(isolate);
// Error processing.
- if (info->function() == NULL) {
+ if (error) {
if (stack_overflow()) {
- info->isolate()->StackOverflow();
+ isolate->StackOverflow();
} else {
- ThrowPendingError(info->isolate(), info->script());
+ ThrowPendingError(isolate, script);
}
}
@@ -4316,10 +4314,10 @@ void Parser::Internalize(CompilationInfo* info) {
for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount;
++feature) {
for (int i = 0; i < use_counts_[feature]; ++i) {
- info->isolate()->CountUsage(v8::Isolate::UseCounterFeature(feature));
+ isolate->CountUsage(v8::Isolate::UseCounterFeature(feature));
}
}
- info->isolate()->counters()->total_preparse_skipped()->Increment(
+ isolate->counters()->total_preparse_skipped()->Increment(
total_preparse_skipped_);
}
@@ -5267,17 +5265,17 @@ bool Parser::Parse(CompilationInfo* info) {
if (info->is_lazy()) {
DCHECK(!info->is_eval());
if (info->shared_info()->is_function()) {
- result = ParseLazy(info);
+ result = ParseLazy(isolate, info);
} else {
- result = ParseProgram(info);
+ result = ParseProgram(isolate, info);
}
} else {
SetCachedData(info);
- result = ParseProgram(info);
+ result = ParseProgram(isolate, info);
}
info->SetFunction(result);
- Internalize(info);
+ Internalize(isolate, info->script(), result == NULL);
DCHECK(ast_value_factory()->IsInternalized());
return (result != NULL);
}
Index: src/parser.h
diff --git a/src/parser.h b/src/parser.h
index
ff36fe90e0b0cd1c9a5c44f6086b7dc6ba069e33..be9dc01f411ea9802cbbcadf7299774332d7f0c8
100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -654,8 +654,8 @@ class Parser : public ParserBase<ParserTraits> {
// Handle errors detected during parsing, move statistics to Isolate,
// internalize strings (move them to the heap).
- void Internalize(CompilationInfo* info);
- void HandleSourceURLComments(CompilationInfo* info);
+ void Internalize(Isolate* isolate, Handle<Script> script, bool error);
+ void HandleSourceURLComments(Isolate* isolate, Handle<Script> script);
private:
friend class ParserTraits;
@@ -670,10 +670,10 @@ class Parser : public ParserBase<ParserTraits> {
static const int kMaxNumFunctionLocals = 4194303; // 2^22-1
// Returns NULL if parsing failed.
- FunctionLiteral* ParseProgram(CompilationInfo* info);
+ FunctionLiteral* ParseProgram(Isolate* isolate, CompilationInfo* info);
- FunctionLiteral* ParseLazy(CompilationInfo* info);
- FunctionLiteral* ParseLazy(CompilationInfo* info,
+ FunctionLiteral* ParseLazy(Isolate* isolate, CompilationInfo* info);
+ FunctionLiteral* ParseLazy(Isolate* isolate, CompilationInfo* info,
Utf16CharacterStream* source);
// Called by ParseProgram after setting up the scanner.
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.