OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 11216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11227 // Reparse the code and analyze the scopes. | 11227 // Reparse the code and analyze the scopes. |
11228 ZoneScope zone_scope(isolate, DELETE_ON_EXIT); | 11228 ZoneScope zone_scope(isolate, DELETE_ON_EXIT); |
11229 Handle<Script> script(Script::cast(shared_info->script())); | 11229 Handle<Script> script(Script::cast(shared_info->script())); |
11230 Scope* scope; | 11230 Scope* scope; |
11231 | 11231 |
11232 // Check whether we are in global, eval or function code. | 11232 // Check whether we are in global, eval or function code. |
11233 Handle<ScopeInfo> scope_info(shared_info->scope_info()); | 11233 Handle<ScopeInfo> scope_info(shared_info->scope_info()); |
11234 if (scope_info->Type() != FUNCTION_SCOPE) { | 11234 if (scope_info->Type() != FUNCTION_SCOPE) { |
11235 // Global or eval code. | 11235 // Global or eval code. |
11236 CompilationInfo info(script); | 11236 CompilationInfo info(script); |
11237 ScriptDataImpl* pre_data = NULL; | |
11238 int flags = kNoParsingFlags; | |
11239 if (info.is_native() || FLAG_allow_natives_syntax) { | |
11240 flags |= kAllowNativesSyntax; | |
11241 } | |
11242 if (!info.is_native() && FLAG_harmony_scoping){ | |
11243 flags |= kHarmonyScoping; | |
11244 } | |
11237 if (scope_info->Type() == GLOBAL_SCOPE) { | 11245 if (scope_info->Type() == GLOBAL_SCOPE) { |
11246 Handle<String> source(String::cast(script->source())); | |
11247 pre_data = ParserApi::PartialPreParse(source, NULL, flags); | |
Lasse Reichstein
2011/11/18 14:12:52
Why preparse? Is it for speed?
Maybe only do it i
Steven
2011/11/18 16:53:19
Initially this was only for mimicking the behaviou
| |
11238 info.MarkAsGlobal(); | 11248 info.MarkAsGlobal(); |
11249 info.SetPreParseData(pre_data); | |
11239 } else { | 11250 } else { |
11240 ASSERT(scope_info->Type() == EVAL_SCOPE); | 11251 ASSERT(scope_info->Type() == EVAL_SCOPE); |
11241 info.MarkAsEval(); | 11252 info.MarkAsEval(); |
11242 info.SetCallingContext(Handle<Context>(function_->context())); | 11253 info.SetCallingContext(Handle<Context>(function_->context())); |
11243 } | 11254 } |
11244 CHECK(ParserApi::Parse(&info)); | 11255 CHECK(ParserApi::Parse(&info)); |
11245 CHECK(Scope::Analyze(&info)); | 11256 CHECK(Scope::Analyze(&info)); |
11246 scope = info.function()->scope(); | 11257 scope = info.function()->scope(); |
11258 // Delete preparse data again. | |
11259 if (pre_data != NULL) { | |
11260 delete pre_data; | |
11261 } | |
11247 } else { | 11262 } else { |
11248 // Function code | 11263 // Function code |
11249 CompilationInfo info(shared_info); | 11264 CompilationInfo info(shared_info); |
11250 CHECK(ParserApi::Parse(&info)); | 11265 CHECK(ParserApi::Parse(&info)); |
11251 CHECK(Scope::Analyze(&info)); | 11266 CHECK(Scope::Analyze(&info)); |
11252 scope = info.function()->scope(); | 11267 scope = info.function()->scope(); |
11253 } | 11268 } |
11254 | 11269 |
11255 // Retrieve the scope chain for the current position. | 11270 // Retrieve the scope chain for the current position. |
11256 int source_position = shared_info->code()->SourcePosition(frame_->pc()); | 11271 int source_position = shared_info->code()->SourcePosition(frame_->pc()); |
(...skipping 2280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13537 } else { | 13552 } else { |
13538 // Handle last resort GC and make sure to allow future allocations | 13553 // Handle last resort GC and make sure to allow future allocations |
13539 // to grow the heap without causing GCs (if possible). | 13554 // to grow the heap without causing GCs (if possible). |
13540 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13555 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13541 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); | 13556 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); |
13542 } | 13557 } |
13543 } | 13558 } |
13544 | 13559 |
13545 | 13560 |
13546 } } // namespace v8::internal | 13561 } } // namespace v8::internal |
OLD | NEW |