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 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 } | 501 } |
502 | 502 |
503 script->set_data(script_data.is_null() ? HEAP->undefined_value() | 503 script->set_data(script_data.is_null() ? HEAP->undefined_value() |
504 : *script_data); | 504 : *script_data); |
505 | 505 |
506 // Compile the function and add it to the cache. | 506 // Compile the function and add it to the cache. |
507 CompilationInfo info(script); | 507 CompilationInfo info(script); |
508 info.MarkAsGlobal(); | 508 info.MarkAsGlobal(); |
509 info.SetExtension(extension); | 509 info.SetExtension(extension); |
510 info.SetPreParseData(pre_data); | 510 info.SetPreParseData(pre_data); |
511 if (natives == NATIVES_CODE) info.MarkAsAllowingNativesSyntax(); | 511 if (natives == NATIVES_CODE) { |
| 512 info.MarkAsAllowingNativesSyntax(); |
| 513 info.MarkAsNative(); |
| 514 } |
512 result = MakeFunctionInfo(&info); | 515 result = MakeFunctionInfo(&info); |
513 if (extension == NULL && !result.is_null()) { | 516 if (extension == NULL && !result.is_null()) { |
514 compilation_cache->PutScript(source, result); | 517 compilation_cache->PutScript(source, result); |
515 } | 518 } |
516 | 519 |
517 // Get rid of the pre-parsing data (if necessary). | 520 // Get rid of the pre-parsing data (if necessary). |
518 if (input_pre_data == NULL && pre_data != NULL) { | 521 if (input_pre_data == NULL && pre_data != NULL) { |
519 delete pre_data; | 522 delete pre_data; |
520 } | 523 } |
521 } | 524 } |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 } | 673 } |
671 | 674 |
672 | 675 |
673 Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(FunctionLiteral* literal, | 676 Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(FunctionLiteral* literal, |
674 Handle<Script> script) { | 677 Handle<Script> script) { |
675 // Precondition: code has been parsed and scopes have been analyzed. | 678 // Precondition: code has been parsed and scopes have been analyzed. |
676 CompilationInfo info(script); | 679 CompilationInfo info(script); |
677 info.SetFunction(literal); | 680 info.SetFunction(literal); |
678 info.SetScope(literal->scope()); | 681 info.SetScope(literal->scope()); |
679 if (literal->scope()->is_strict_mode()) info.MarkAsStrictMode(); | 682 if (literal->scope()->is_strict_mode()) info.MarkAsStrictMode(); |
| 683 if (script->type()->value() == Script::TYPE_NATIVE) info.MarkAsNative(); |
680 | 684 |
681 LiveEditFunctionTracker live_edit_tracker(info.isolate(), literal); | 685 LiveEditFunctionTracker live_edit_tracker(info.isolate(), literal); |
682 // Determine if the function can be lazily compiled. This is necessary to | 686 // Determine if the function can be lazily compiled. This is necessary to |
683 // allow some of our builtin JS files to be lazily compiled. These | 687 // allow some of our builtin JS files to be lazily compiled. These |
684 // builtins cannot be handled lazily by the parser, since we have to know | 688 // builtins cannot be handled lazily by the parser, since we have to know |
685 // if a function uses the special natives syntax, which is something the | 689 // if a function uses the special natives syntax, which is something the |
686 // parser records. | 690 // parser records. |
687 bool allow_lazy = literal->AllowsLazyCompilation() && | 691 bool allow_lazy = literal->AllowsLazyCompilation() && |
688 !LiveEditFunctionTracker::IsActive(info.isolate()); | 692 !LiveEditFunctionTracker::IsActive(info.isolate()); |
689 | 693 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 shared->DebugName())); | 781 shared->DebugName())); |
778 } | 782 } |
779 } | 783 } |
780 | 784 |
781 GDBJIT(AddCode(Handle<String>(shared->DebugName()), | 785 GDBJIT(AddCode(Handle<String>(shared->DebugName()), |
782 Handle<Script>(info->script()), | 786 Handle<Script>(info->script()), |
783 Handle<Code>(info->code()))); | 787 Handle<Code>(info->code()))); |
784 } | 788 } |
785 | 789 |
786 } } // namespace v8::internal | 790 } } // namespace v8::internal |
OLD | NEW |