| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 | 493 |
| 494 if (result.is_null()) { | 494 if (result.is_null()) { |
| 495 // No cache entry found. Do pre-parsing, if it makes sense, and compile | 495 // No cache entry found. Do pre-parsing, if it makes sense, and compile |
| 496 // the script. | 496 // the script. |
| 497 // Building preparse data that is only used immediately after is only a | 497 // Building preparse data that is only used immediately after is only a |
| 498 // saving if we might skip building the AST for lazily compiled functions. | 498 // saving if we might skip building the AST for lazily compiled functions. |
| 499 // I.e., preparse data isn't relevant when the lazy flag is off, and | 499 // I.e., preparse data isn't relevant when the lazy flag is off, and |
| 500 // for small sources, odds are that there aren't many functions | 500 // for small sources, odds are that there aren't many functions |
| 501 // that would be compiled lazily anyway, so we skip the preparse step | 501 // that would be compiled lazily anyway, so we skip the preparse step |
| 502 // in that case too. | 502 // in that case too. |
| 503 int flags = kNoParsingFlags; | |
| 504 if ((natives == NATIVES_CODE) || FLAG_allow_natives_syntax) { | |
| 505 flags |= kAllowNativesSyntax; | |
| 506 } | |
| 507 if (natives != NATIVES_CODE && FLAG_harmony_scoping) { | |
| 508 flags |= EXTENDED_MODE; | |
| 509 } | |
| 510 | 503 |
| 511 // Create a script object describing the script to be compiled. | 504 // Create a script object describing the script to be compiled. |
| 512 Handle<Script> script = FACTORY->NewScript(source); | 505 Handle<Script> script = FACTORY->NewScript(source); |
| 513 if (natives == NATIVES_CODE) { | 506 if (natives == NATIVES_CODE) { |
| 514 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); | 507 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); |
| 515 } | 508 } |
| 516 if (!script_name.is_null()) { | 509 if (!script_name.is_null()) { |
| 517 script->set_name(*script_name); | 510 script->set_name(*script_name); |
| 518 script->set_line_offset(Smi::FromInt(line_offset)); | 511 script->set_line_offset(Smi::FromInt(line_offset)); |
| 519 script->set_column_offset(Smi::FromInt(column_offset)); | 512 script->set_column_offset(Smi::FromInt(column_offset)); |
| 520 } | 513 } |
| 521 | 514 |
| 522 script->set_data(script_data.is_null() ? HEAP->undefined_value() | 515 script->set_data(script_data.is_null() ? HEAP->undefined_value() |
| 523 : *script_data); | 516 : *script_data); |
| 524 | 517 |
| 525 // Compile the function and add it to the cache. | 518 // Compile the function and add it to the cache. |
| 526 CompilationInfo info(script); | 519 CompilationInfo info(script); |
| 527 info.MarkAsGlobal(); | 520 info.MarkAsGlobal(); |
| 528 info.SetExtension(extension); | 521 info.SetExtension(extension); |
| 529 info.SetPreParseData(pre_data); | 522 info.SetPreParseData(pre_data); |
| 523 if (FLAG_use_strict) info.SetLanguageMode(STRICT_MODE); |
| 530 result = MakeFunctionInfo(&info); | 524 result = MakeFunctionInfo(&info); |
| 531 if (extension == NULL && !result.is_null()) { | 525 if (extension == NULL && !result.is_null()) { |
| 532 compilation_cache->PutScript(source, result); | 526 compilation_cache->PutScript(source, result); |
| 533 } | 527 } |
| 534 } | 528 } |
| 535 | 529 |
| 536 if (result.is_null()) isolate->ReportPendingMessages(); | 530 if (result.is_null()) isolate->ReportPendingMessages(); |
| 537 return result; | 531 return result; |
| 538 } | 532 } |
| 539 | 533 |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 } | 803 } |
| 810 } | 804 } |
| 811 | 805 |
| 812 GDBJIT(AddCode(Handle<String>(shared->DebugName()), | 806 GDBJIT(AddCode(Handle<String>(shared->DebugName()), |
| 813 Handle<Script>(info->script()), | 807 Handle<Script>(info->script()), |
| 814 Handle<Code>(info->code()), | 808 Handle<Code>(info->code()), |
| 815 info)); | 809 info)); |
| 816 } | 810 } |
| 817 | 811 |
| 818 } } // namespace v8::internal | 812 } } // namespace v8::internal |
| OLD | NEW |