| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 20 matching lines...) Expand all Loading... |
| 31 #include "codegen-inl.h" | 31 #include "codegen-inl.h" |
| 32 #include "compilation-cache.h" | 32 #include "compilation-cache.h" |
| 33 #include "compiler.h" | 33 #include "compiler.h" |
| 34 #include "debug.h" | 34 #include "debug.h" |
| 35 #include "fast-codegen.h" | 35 #include "fast-codegen.h" |
| 36 #include "full-codegen.h" | 36 #include "full-codegen.h" |
| 37 #include "oprofile-agent.h" | 37 #include "oprofile-agent.h" |
| 38 #include "rewriter.h" | 38 #include "rewriter.h" |
| 39 #include "scopes.h" | 39 #include "scopes.h" |
| 40 #include "usage-analyzer.h" | 40 #include "usage-analyzer.h" |
| 41 #include "liveedit.h" |
| 41 | 42 |
| 42 namespace v8 { | 43 namespace v8 { |
| 43 namespace internal { | 44 namespace internal { |
| 44 | 45 |
| 45 | 46 |
| 46 static Handle<Code> MakeCode(Handle<Context> context, CompilationInfo* info) { | 47 static Handle<Code> MakeCode(Handle<Context> context, CompilationInfo* info) { |
| 47 FunctionLiteral* function = info->function(); | 48 FunctionLiteral* function = info->function(); |
| 48 ASSERT(function != NULL); | 49 ASSERT(function != NULL); |
| 49 // Rewrite the AST by introducing .result assignments where needed. | 50 // Rewrite the AST by introducing .result assignments where needed. |
| 50 if (!Rewriter::Process(function) || !AnalyzeVariableUsage(function)) { | 51 if (!Rewriter::Process(function) || !AnalyzeVariableUsage(function)) { |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 | 232 |
| 232 | 233 |
| 233 static StaticResource<SafeStringInputBuffer> safe_string_input_buffer; | 234 static StaticResource<SafeStringInputBuffer> safe_string_input_buffer; |
| 234 | 235 |
| 235 | 236 |
| 236 Handle<JSFunction> Compiler::Compile(Handle<String> source, | 237 Handle<JSFunction> Compiler::Compile(Handle<String> source, |
| 237 Handle<Object> script_name, | 238 Handle<Object> script_name, |
| 238 int line_offset, int column_offset, | 239 int line_offset, int column_offset, |
| 239 v8::Extension* extension, | 240 v8::Extension* extension, |
| 240 ScriptDataImpl* input_pre_data, | 241 ScriptDataImpl* input_pre_data, |
| 242 Handle<Object> script_data, |
| 241 NativesFlag natives) { | 243 NativesFlag natives) { |
| 242 int source_length = source->length(); | 244 int source_length = source->length(); |
| 243 Counters::total_load_size.Increment(source_length); | 245 Counters::total_load_size.Increment(source_length); |
| 244 Counters::total_compile_size.Increment(source_length); | 246 Counters::total_compile_size.Increment(source_length); |
| 245 | 247 |
| 246 // The VM is in the COMPILER state until exiting this function. | 248 // The VM is in the COMPILER state until exiting this function. |
| 247 VMState state(COMPILER); | 249 VMState state(COMPILER); |
| 248 | 250 |
| 249 // Do a lookup in the compilation cache but not for extensions. | 251 // Do a lookup in the compilation cache but not for extensions. |
| 250 Handle<JSFunction> result; | 252 Handle<JSFunction> result; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 268 Handle<Script> script = Factory::NewScript(source); | 270 Handle<Script> script = Factory::NewScript(source); |
| 269 if (natives == NATIVES_CODE) { | 271 if (natives == NATIVES_CODE) { |
| 270 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); | 272 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); |
| 271 } | 273 } |
| 272 if (!script_name.is_null()) { | 274 if (!script_name.is_null()) { |
| 273 script->set_name(*script_name); | 275 script->set_name(*script_name); |
| 274 script->set_line_offset(Smi::FromInt(line_offset)); | 276 script->set_line_offset(Smi::FromInt(line_offset)); |
| 275 script->set_column_offset(Smi::FromInt(column_offset)); | 277 script->set_column_offset(Smi::FromInt(column_offset)); |
| 276 } | 278 } |
| 277 | 279 |
| 280 script->set_data(script_data.is_null() ? Heap::undefined_value() |
| 281 : *script_data); |
| 282 |
| 278 // Compile the function and add it to the cache. | 283 // Compile the function and add it to the cache. |
| 279 result = MakeFunction(true, | 284 result = MakeFunction(true, |
| 280 false, | 285 false, |
| 281 DONT_VALIDATE_JSON, | 286 DONT_VALIDATE_JSON, |
| 282 script, | 287 script, |
| 283 Handle<Context>::null(), | 288 Handle<Context>::null(), |
| 284 extension, | 289 extension, |
| 285 pre_data); | 290 pre_data); |
| 286 if (extension == NULL && !result.is_null()) { | 291 if (extension == NULL && !result.is_null()) { |
| 287 CompilationCache::PutScript(source, result); | 292 CompilationCache::PutScript(source, result); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 // We should not try to compile the same function literal more than | 427 // We should not try to compile the same function literal more than |
| 423 // once. | 428 // once. |
| 424 literal->mark_as_compiled(); | 429 literal->mark_as_compiled(); |
| 425 #endif | 430 #endif |
| 426 | 431 |
| 427 // Determine if the function can be lazily compiled. This is | 432 // Determine if the function can be lazily compiled. This is |
| 428 // necessary to allow some of our builtin JS files to be lazily | 433 // necessary to allow some of our builtin JS files to be lazily |
| 429 // compiled. These builtins cannot be handled lazily by the parser, | 434 // compiled. These builtins cannot be handled lazily by the parser, |
| 430 // since we have to know if a function uses the special natives | 435 // since we have to know if a function uses the special natives |
| 431 // syntax, which is something the parser records. | 436 // syntax, which is something the parser records. |
| 432 bool allow_lazy = literal->AllowsLazyCompilation(); | 437 bool allow_lazy = literal->AllowsLazyCompilation() && |
| 438 !LiveEditFunctionTracker::IsActive(); |
| 433 | 439 |
| 434 // Generate code | 440 // Generate code |
| 435 Handle<Code> code; | 441 Handle<Code> code; |
| 436 if (FLAG_lazy && allow_lazy) { | 442 if (FLAG_lazy && allow_lazy) { |
| 437 code = ComputeLazyCompile(literal->num_parameters()); | 443 code = ComputeLazyCompile(literal->num_parameters()); |
| 438 } else { | 444 } else { |
| 439 // The bodies of function literals have not yet been visited by | 445 // The bodies of function literals have not yet been visited by |
| 440 // the AST optimizer/analyzer. | 446 // the AST optimizer/analyzer. |
| 441 if (!Rewriter::Optimize(literal)) { | 447 if (!Rewriter::Optimize(literal)) { |
| 442 return Handle<JSFunction>::null(); | 448 return Handle<JSFunction>::null(); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 LOG(CodeCreateEvent(tag, *code, *func_name)); | 567 LOG(CodeCreateEvent(tag, *code, *func_name)); |
| 562 OProfileAgent::CreateNativeCodeRegion(*func_name, | 568 OProfileAgent::CreateNativeCodeRegion(*func_name, |
| 563 code->instruction_start(), | 569 code->instruction_start(), |
| 564 code->instruction_size()); | 570 code->instruction_size()); |
| 565 } | 571 } |
| 566 } | 572 } |
| 567 } | 573 } |
| 568 #endif | 574 #endif |
| 569 | 575 |
| 570 } } // namespace v8::internal | 576 } } // namespace v8::internal |
| OLD | NEW |