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 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 if (boilerplate.is_null()) { | 645 if (boilerplate.is_null()) { |
646 *pending_exception = true; | 646 *pending_exception = true; |
647 return; | 647 return; |
648 } | 648 } |
649 Bootstrapper::NativesCacheAdd(name, boilerplate); | 649 Bootstrapper::NativesCacheAdd(name, boilerplate); |
650 } | 650 } |
651 | 651 |
652 // We shouldn't get here if compiling the script failed. | 652 // We shouldn't get here if compiling the script failed. |
653 ASSERT(!boilerplate.is_null()); | 653 ASSERT(!boilerplate.is_null()); |
654 | 654 |
| 655 #ifdef ENABLE_DEBUGGER_SUPPORT |
655 // When the debugger running in its own context touches lazy loaded | 656 // When the debugger running in its own context touches lazy loaded |
656 // functions loading can be triggered. In that case ensure that the | 657 // functions loading can be triggered. In that case ensure that the |
657 // execution of the boilerplate is in the correct context. | 658 // execution of the boilerplate is in the correct context. |
658 SaveContext save; | 659 SaveContext save; |
659 if (!Debug::debug_context().is_null() && | 660 if (!Debug::debug_context().is_null() && |
660 Top::context() == *Debug::debug_context()) { | 661 Top::context() == *Debug::debug_context()) { |
661 Top::set_context(*compile_context); | 662 Top::set_context(*compile_context); |
662 } | 663 } |
| 664 #endif |
663 | 665 |
664 // Reset the lazy load data before running the script to make sure | 666 // Reset the lazy load data before running the script to make sure |
665 // not to get recursive lazy loading. | 667 // not to get recursive lazy loading. |
666 fun->shared()->set_lazy_load_data(Heap::undefined_value()); | 668 fun->shared()->set_lazy_load_data(Heap::undefined_value()); |
667 | 669 |
668 // Run the script. | 670 // Run the script. |
669 Handle<JSFunction> script_fun( | 671 Handle<JSFunction> script_fun( |
670 Factory::NewFunctionFromBoilerplate(boilerplate, function_context)); | 672 Factory::NewFunctionFromBoilerplate(boilerplate, function_context)); |
671 Execution::Call(script_fun, receiver, 0, NULL, pending_exception); | 673 Execution::Call(script_fun, receiver, 0, NULL, pending_exception); |
672 | 674 |
673 // If lazy loading failed, restore the unloaded state of fun. | 675 // If lazy loading failed, restore the unloaded state of fun. |
674 if (*pending_exception) fun->shared()->set_lazy_load_data(*info); | 676 if (*pending_exception) fun->shared()->set_lazy_load_data(*info); |
675 } | 677 } |
676 | 678 |
677 | 679 |
678 void SetupLazy(Handle<JSFunction> fun, | 680 void SetupLazy(Handle<JSFunction> fun, |
679 int index, | 681 int index, |
680 Handle<Context> compile_context, | 682 Handle<Context> compile_context, |
681 Handle<Context> function_context) { | 683 Handle<Context> function_context) { |
682 Handle<FixedArray> arr = Factory::NewFixedArray(3); | 684 Handle<FixedArray> arr = Factory::NewFixedArray(3); |
683 arr->set(0, Smi::FromInt(index)); | 685 arr->set(0, Smi::FromInt(index)); |
684 arr->set(1, *compile_context); // Compile in this context | 686 arr->set(1, *compile_context); // Compile in this context |
685 arr->set(2, *function_context); // Set function context to this | 687 arr->set(2, *function_context); // Set function context to this |
686 fun->shared()->set_lazy_load_data(*arr); | 688 fun->shared()->set_lazy_load_data(*arr); |
687 } | 689 } |
688 | 690 |
689 } } // namespace v8::internal | 691 } } // namespace v8::internal |
OLD | NEW |