| 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 } | 167 } |
| 168 | 168 |
| 169 | 169 |
| 170 void SetExpectedNofPropertiesFromEstimate(Handle<SharedFunctionInfo> shared, | 170 void SetExpectedNofPropertiesFromEstimate(Handle<SharedFunctionInfo> shared, |
| 171 int estimate) { | 171 int estimate) { |
| 172 shared->set_expected_nof_properties( | 172 shared->set_expected_nof_properties( |
| 173 ExpectedNofPropertiesFromEstimate(estimate)); | 173 ExpectedNofPropertiesFromEstimate(estimate)); |
| 174 } | 174 } |
| 175 | 175 |
| 176 | 176 |
| 177 void SetExpectedNofPropertiesFromEstimate(Handle<JSFunction> func, | |
| 178 int estimate) { | |
| 179 SetExpectedNofProperties( | |
| 180 func, ExpectedNofPropertiesFromEstimate(estimate)); | |
| 181 } | |
| 182 | |
| 183 | |
| 184 void NormalizeProperties(Handle<JSObject> object, | 177 void NormalizeProperties(Handle<JSObject> object, |
| 185 PropertyNormalizationMode mode, | 178 PropertyNormalizationMode mode, |
| 186 int expected_additional_properties) { | 179 int expected_additional_properties) { |
| 187 CALL_HEAP_FUNCTION_VOID(object->NormalizeProperties( | 180 CALL_HEAP_FUNCTION_VOID(object->NormalizeProperties( |
| 188 mode, | 181 mode, |
| 189 expected_additional_properties)); | 182 expected_additional_properties)); |
| 190 } | 183 } |
| 191 | 184 |
| 192 | 185 |
| 193 void NormalizeElements(Handle<JSObject> object) { | 186 void NormalizeElements(Handle<JSObject> object) { |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 HandleScope scope; | 782 HandleScope scope; |
| 790 Handle<FixedArray> info(FixedArray::cast(obj->map()->constructor())); | 783 Handle<FixedArray> info(FixedArray::cast(obj->map()->constructor())); |
| 791 int index = Smi::cast(info->get(0))->value(); | 784 int index = Smi::cast(info->get(0))->value(); |
| 792 ASSERT(index >= 0); | 785 ASSERT(index >= 0); |
| 793 Handle<Context> compile_context(Context::cast(info->get(1))); | 786 Handle<Context> compile_context(Context::cast(info->get(1))); |
| 794 Handle<Context> function_context(Context::cast(info->get(2))); | 787 Handle<Context> function_context(Context::cast(info->get(2))); |
| 795 Handle<Object> receiver(compile_context->global()->builtins()); | 788 Handle<Object> receiver(compile_context->global()->builtins()); |
| 796 | 789 |
| 797 Vector<const char> name = Natives::GetScriptName(index); | 790 Vector<const char> name = Natives::GetScriptName(index); |
| 798 | 791 |
| 799 Handle<JSFunction> boilerplate; | 792 Handle<SharedFunctionInfo> function_info; |
| 800 | 793 |
| 801 if (!Bootstrapper::NativesCacheLookup(name, &boilerplate)) { | 794 if (!Bootstrapper::NativesCacheLookup(name, &function_info)) { |
| 802 Handle<String> source_code = Bootstrapper::NativesSourceLookup(index); | 795 Handle<String> source_code = Bootstrapper::NativesSourceLookup(index); |
| 803 Handle<String> script_name = Factory::NewStringFromAscii(name); | 796 Handle<String> script_name = Factory::NewStringFromAscii(name); |
| 804 bool allow_natives_syntax = FLAG_allow_natives_syntax; | 797 bool allow_natives_syntax = FLAG_allow_natives_syntax; |
| 805 FLAG_allow_natives_syntax = true; | 798 FLAG_allow_natives_syntax = true; |
| 806 boilerplate = Compiler::Compile(source_code, script_name, 0, 0, NULL, NULL, | 799 function_info = Compiler::Compile(source_code, |
| 807 Handle<String>::null(), NATIVES_CODE); | 800 script_name, |
| 801 0, 0, NULL, NULL, |
| 802 Handle<String>::null(), |
| 803 NATIVES_CODE); |
| 808 FLAG_allow_natives_syntax = allow_natives_syntax; | 804 FLAG_allow_natives_syntax = allow_natives_syntax; |
| 809 // If the compilation failed (possibly due to stack overflows), we | 805 // If the compilation failed (possibly due to stack overflows), we |
| 810 // should never enter the result in the natives cache. Instead we | 806 // should never enter the result in the natives cache. Instead we |
| 811 // return from the function without marking the function as having | 807 // return from the function without marking the function as having |
| 812 // been lazily loaded. | 808 // been lazily loaded. |
| 813 if (boilerplate.is_null()) { | 809 if (function_info.is_null()) { |
| 814 *pending_exception = true; | 810 *pending_exception = true; |
| 815 return; | 811 return; |
| 816 } | 812 } |
| 817 Bootstrapper::NativesCacheAdd(name, boilerplate); | 813 Bootstrapper::NativesCacheAdd(name, function_info); |
| 818 } | 814 } |
| 819 | 815 |
| 820 // We shouldn't get here if compiling the script failed. | 816 // We shouldn't get here if compiling the script failed. |
| 821 ASSERT(!boilerplate.is_null()); | 817 ASSERT(!function_info.is_null()); |
| 822 | 818 |
| 823 #ifdef ENABLE_DEBUGGER_SUPPORT | 819 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 824 // When the debugger running in its own context touches lazy loaded | 820 // When the debugger running in its own context touches lazy loaded |
| 825 // functions loading can be triggered. In that case ensure that the | 821 // functions loading can be triggered. In that case ensure that the |
| 826 // execution of the boilerplate is in the correct context. | 822 // execution of the boilerplate is in the correct context. |
| 827 SaveContext save; | 823 SaveContext save; |
| 828 if (!Debug::debug_context().is_null() && | 824 if (!Debug::debug_context().is_null() && |
| 829 Top::context() == *Debug::debug_context()) { | 825 Top::context() == *Debug::debug_context()) { |
| 830 Top::set_context(*compile_context); | 826 Top::set_context(*compile_context); |
| 831 } | 827 } |
| 832 #endif | 828 #endif |
| 833 | 829 |
| 834 // Reset the lazy load data before running the script to make sure | 830 // Reset the lazy load data before running the script to make sure |
| 835 // not to get recursive lazy loading. | 831 // not to get recursive lazy loading. |
| 836 obj->map()->set_needs_loading(false); | 832 obj->map()->set_needs_loading(false); |
| 837 obj->map()->set_constructor(info->get(3)); | 833 obj->map()->set_constructor(info->get(3)); |
| 838 | 834 |
| 839 // Run the script. | 835 // Run the script. |
| 840 Handle<JSFunction> script_fun( | 836 Handle<JSFunction> script_fun( |
| 841 Factory::NewFunctionFromBoilerplate(boilerplate, function_context)); | 837 Factory::NewFunctionFromSharedFunctionInfo(function_info, |
| 838 function_context)); |
| 842 Execution::Call(script_fun, receiver, 0, NULL, pending_exception); | 839 Execution::Call(script_fun, receiver, 0, NULL, pending_exception); |
| 843 | 840 |
| 844 // If lazy loading failed, restore the unloaded state of obj. | 841 // If lazy loading failed, restore the unloaded state of obj. |
| 845 if (*pending_exception) { | 842 if (*pending_exception) { |
| 846 obj->map()->set_needs_loading(true); | 843 obj->map()->set_needs_loading(true); |
| 847 obj->map()->set_constructor(*info); | 844 obj->map()->set_constructor(*info); |
| 848 } | 845 } |
| 849 } | 846 } |
| 850 | 847 |
| 851 | 848 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 862 Handle<Map> new_map = Factory::CopyMapDropTransitions(old_map); | 859 Handle<Map> new_map = Factory::CopyMapDropTransitions(old_map); |
| 863 obj->set_map(*new_map); | 860 obj->set_map(*new_map); |
| 864 new_map->set_needs_loading(true); | 861 new_map->set_needs_loading(true); |
| 865 // Store the lazy loading info in the constructor field. We'll | 862 // Store the lazy loading info in the constructor field. We'll |
| 866 // reestablish the constructor from the fixed array after loading. | 863 // reestablish the constructor from the fixed array after loading. |
| 867 new_map->set_constructor(*arr); | 864 new_map->set_constructor(*arr); |
| 868 ASSERT(!obj->IsLoaded()); | 865 ASSERT(!obj->IsLoaded()); |
| 869 } | 866 } |
| 870 | 867 |
| 871 } } // namespace v8::internal | 868 } } // namespace v8::internal |
| OLD | NEW |