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

Side by Side Diff: src/compiler.cc

Issue 3518005: Make some free functions into static members of class Parser. (Closed)
Patch Set: Remove outdated comment. Created 10 years, 2 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 unified diff | Download patch
« no previous file with comments | « src/compiler.h ('k') | src/jsregexp.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include "v8.h" 28 #include "v8.h"
29 29
30 #include "compiler.h"
31
30 #include "bootstrapper.h" 32 #include "bootstrapper.h"
31 #include "codegen-inl.h" 33 #include "codegen-inl.h"
32 #include "compilation-cache.h" 34 #include "compilation-cache.h"
33 #include "compiler.h"
34 #include "data-flow.h" 35 #include "data-flow.h"
35 #include "debug.h" 36 #include "debug.h"
36 #include "full-codegen.h" 37 #include "full-codegen.h"
37 #include "liveedit.h" 38 #include "liveedit.h"
38 #include "oprofile-agent.h" 39 #include "oprofile-agent.h"
40 #include "parser.h"
39 #include "rewriter.h" 41 #include "rewriter.h"
42 #include "scopeinfo.h"
40 #include "scopes.h" 43 #include "scopes.h"
41 #include "scopeinfo.h"
42 44
43 namespace v8 { 45 namespace v8 {
44 namespace internal { 46 namespace internal {
45 47
46 // For normal operation the syntax checker is used to determine whether to 48 // For normal operation the syntax checker is used to determine whether to
47 // use the full compiler for top level code or not. However if the flag 49 // use the full compiler for top level code or not. However if the flag
48 // --always-full-compiler is specified or debugging is active the full 50 // --always-full-compiler is specified or debugging is active the full
49 // compiler will be used for all code. 51 // compiler will be used for all code.
50 static bool AlwaysFullCompiler() { 52 static bool AlwaysFullCompiler() {
51 #ifdef ENABLE_DEBUGGER_SUPPORT 53 #ifdef ENABLE_DEBUGGER_SUPPORT
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 // Notify debugger 169 // Notify debugger
168 Debugger::OnBeforeCompile(script); 170 Debugger::OnBeforeCompile(script);
169 #endif 171 #endif
170 172
171 // Only allow non-global compiles for eval. 173 // Only allow non-global compiles for eval.
172 ASSERT(is_eval || is_global); 174 ASSERT(is_eval || is_global);
173 175
174 // Build AST. 176 // Build AST.
175 EagerCompilationInfo info(script, is_eval); 177 EagerCompilationInfo info(script, is_eval);
176 FunctionLiteral* lit = 178 FunctionLiteral* lit =
177 MakeAST(is_global, script, extension, pre_data, is_json); 179 Parser::MakeAST(is_global, script, extension, pre_data, is_json);
178 180
179 // Check for parse errors. 181 // Check for parse errors.
180 if (lit == NULL) { 182 if (lit == NULL) {
181 ASSERT(Top::has_pending_exception()); 183 ASSERT(Top::has_pending_exception());
182 return Handle<SharedFunctionInfo>::null(); 184 return Handle<SharedFunctionInfo>::null();
183 } 185 }
184 info.set_function(lit); 186 info.set_function(lit);
185 187
186 // Measure how long it takes to do the compilation; only take the 188 // Measure how long it takes to do the compilation; only take the
187 // rest of the function into account to avoid overlap with the 189 // rest of the function into account to avoid overlap with the
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 // Building preparse data that is only used immediately after is only a 278 // Building preparse data that is only used immediately after is only a
277 // saving if we might skip building the AST for lazily compiled functions. 279 // saving if we might skip building the AST for lazily compiled functions.
278 // I.e., preparse data isn't relevant when the lazy flag is off, and 280 // I.e., preparse data isn't relevant when the lazy flag is off, and
279 // for small sources, odds are that there aren't many functions 281 // for small sources, odds are that there aren't many functions
280 // that would be compiled lazily anyway, so we skip the preparse step 282 // that would be compiled lazily anyway, so we skip the preparse step
281 // in that case too. 283 // in that case too.
282 ScriptDataImpl* pre_data = input_pre_data; 284 ScriptDataImpl* pre_data = input_pre_data;
283 if (pre_data == NULL 285 if (pre_data == NULL
284 && FLAG_lazy 286 && FLAG_lazy
285 && source_length >= FLAG_min_preparse_length) { 287 && source_length >= FLAG_min_preparse_length) {
286 pre_data = PartialPreParse(source, NULL, extension); 288 pre_data = Parser::PartialPreParse(source, NULL, extension);
287 } 289 }
288 290
289 // Create a script object describing the script to be compiled. 291 // Create a script object describing the script to be compiled.
290 Handle<Script> script = Factory::NewScript(source); 292 Handle<Script> script = Factory::NewScript(source);
291 if (natives == NATIVES_CODE) { 293 if (natives == NATIVES_CODE) {
292 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); 294 script->set_type(Smi::FromInt(Script::TYPE_NATIVE));
293 } 295 }
294 if (!script_name.is_null()) { 296 if (!script_name.is_null()) {
295 script->set_name(*script_name); 297 script->set_name(*script_name);
296 script->set_line_offset(Smi::FromInt(line_offset)); 298 script->set_line_offset(Smi::FromInt(line_offset));
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 377
376 PostponeInterruptsScope postpone; 378 PostponeInterruptsScope postpone;
377 379
378 // Compute name, source code and script data. 380 // Compute name, source code and script data.
379 Handle<SharedFunctionInfo> shared = info->shared_info(); 381 Handle<SharedFunctionInfo> shared = info->shared_info();
380 int compiled_size = shared->end_position() - shared->start_position(); 382 int compiled_size = shared->end_position() - shared->start_position();
381 Counters::total_compile_size.Increment(compiled_size); 383 Counters::total_compile_size.Increment(compiled_size);
382 384
383 // Generate the AST for the lazily compiled function. The AST may be 385 // Generate the AST for the lazily compiled function. The AST may be
384 // NULL in case of parser stack overflow. 386 // NULL in case of parser stack overflow.
385 FunctionLiteral* lit = MakeLazyAST(shared); 387 FunctionLiteral* lit = Parser::MakeLazyAST(shared);
386 388
387 // Check for parse errors. 389 // Check for parse errors.
388 if (lit == NULL) { 390 if (lit == NULL) {
389 ASSERT(Top::has_pending_exception()); 391 ASSERT(Top::has_pending_exception());
390 return false; 392 return false;
391 } 393 }
392 info->set_function(lit); 394 info->set_function(lit);
393 395
394 // Measure how long it takes to do the lazy compilation; only take 396 // Measure how long it takes to do the lazy compilation; only take
395 // the rest of the function into account to avoid overlap with the 397 // the rest of the function into account to avoid overlap with the
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 PROFILE(CodeCreateEvent(Logger::ToNativeByScript(tag, *script), 577 PROFILE(CodeCreateEvent(Logger::ToNativeByScript(tag, *script),
576 *code, *func_name)); 578 *code, *func_name));
577 OPROFILE(CreateNativeCodeRegion(*func_name, 579 OPROFILE(CreateNativeCodeRegion(*func_name,
578 code->instruction_start(), 580 code->instruction_start(),
579 code->instruction_size())); 581 code->instruction_size()));
580 } 582 }
581 } 583 }
582 } 584 }
583 585
584 } } // namespace v8::internal 586 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler.h ('k') | src/jsregexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698