Chromium Code Reviews| 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 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 620 | 620 |
| 621 OptimizedObjectForAddingMultipleProperties:: | 621 OptimizedObjectForAddingMultipleProperties:: |
| 622 ~OptimizedObjectForAddingMultipleProperties() { | 622 ~OptimizedObjectForAddingMultipleProperties() { |
| 623 // Reoptimize the object to allow fast property access. | 623 // Reoptimize the object to allow fast property access. |
| 624 if (has_been_transformed_) { | 624 if (has_been_transformed_) { |
| 625 TransformToFastProperties(object_, unused_property_fields_); | 625 TransformToFastProperties(object_, unused_property_fields_); |
| 626 } | 626 } |
| 627 } | 627 } |
| 628 | 628 |
| 629 | 629 |
| 630 void LoadLazy(Handle<JSFunction> fun, bool* pending_exception) { | 630 void LoadLazy(Handle<JSObject> obj, bool* pending_exception) { |
| 631 HandleScope scope; | 631 HandleScope scope; |
| 632 Handle<FixedArray> info(FixedArray::cast(fun->shared()->lazy_load_data())); | 632 Handle<FixedArray> info(FixedArray::cast(obj->map()->constructor())); |
| 633 int index = Smi::cast(info->get(0))->value(); | 633 int index = Smi::cast(info->get(0))->value(); |
| 634 ASSERT(index >= 0); | 634 ASSERT(index >= 0); |
| 635 Handle<Context> compile_context(Context::cast(info->get(1))); | 635 Handle<Context> compile_context(Context::cast(info->get(1))); |
| 636 Handle<Context> function_context(Context::cast(info->get(2))); | 636 Handle<Context> function_context(Context::cast(info->get(2))); |
| 637 Handle<Object> receiver(compile_context->global()->builtins()); | 637 Handle<Object> receiver(compile_context->global()->builtins()); |
| 638 | 638 |
| 639 Vector<const char> name = Natives::GetScriptName(index); | 639 Vector<const char> name = Natives::GetScriptName(index); |
| 640 | 640 |
| 641 Handle<JSFunction> boilerplate; | 641 Handle<JSFunction> boilerplate; |
| 642 | 642 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 667 // execution of the boilerplate is in the correct context. | 667 // execution of the boilerplate is in the correct context. |
| 668 SaveContext save; | 668 SaveContext save; |
| 669 if (!Debug::debug_context().is_null() && | 669 if (!Debug::debug_context().is_null() && |
| 670 Top::context() == *Debug::debug_context()) { | 670 Top::context() == *Debug::debug_context()) { |
| 671 Top::set_context(*compile_context); | 671 Top::set_context(*compile_context); |
| 672 } | 672 } |
| 673 #endif | 673 #endif |
| 674 | 674 |
| 675 // Reset the lazy load data before running the script to make sure | 675 // Reset the lazy load data before running the script to make sure |
| 676 // not to get recursive lazy loading. | 676 // not to get recursive lazy loading. |
| 677 fun->shared()->set_lazy_load_data(Heap::undefined_value()); | 677 obj->map()->set_needs_loading(false); |
| 678 obj->map()->set_constructor(info->get(3)); | |
| 678 | 679 |
| 679 // Run the script. | 680 // Run the script. |
| 680 Handle<JSFunction> script_fun( | 681 Handle<JSFunction> script_fun( |
| 681 Factory::NewFunctionFromBoilerplate(boilerplate, function_context)); | 682 Factory::NewFunctionFromBoilerplate(boilerplate, function_context)); |
| 682 Execution::Call(script_fun, receiver, 0, NULL, pending_exception); | 683 Execution::Call(script_fun, receiver, 0, NULL, pending_exception); |
| 683 | 684 |
| 684 // If lazy loading failed, restore the unloaded state of fun. | 685 // If lazy loading failed, restore the unloaded state of fun. |
|
Mads Ager (chromium)
2009/04/23 19:09:25
fun -> obj
| |
| 685 if (*pending_exception) fun->shared()->set_lazy_load_data(*info); | 686 if (*pending_exception) { |
| 687 obj->map()->set_needs_loading(true); | |
| 688 obj->map()->set_constructor(*info); | |
| 689 } | |
| 686 } | 690 } |
| 687 | 691 |
| 688 | 692 |
| 689 void SetupLazy(Handle<JSFunction> fun, | 693 void SetupLazy(Handle<JSObject> obj, |
| 690 int index, | 694 int index, |
| 691 Handle<Context> compile_context, | 695 Handle<Context> compile_context, |
| 692 Handle<Context> function_context) { | 696 Handle<Context> function_context) { |
| 693 Handle<FixedArray> arr = Factory::NewFixedArray(3); | 697 Handle<FixedArray> arr = Factory::NewFixedArray(4); |
| 694 arr->set(0, Smi::FromInt(index)); | 698 arr->set(0, Smi::FromInt(index)); |
| 695 arr->set(1, *compile_context); // Compile in this context | 699 arr->set(1, *compile_context); // Compile in this context |
| 696 arr->set(2, *function_context); // Set function context to this | 700 arr->set(2, *function_context); // Set function context to this |
| 697 fun->shared()->set_lazy_load_data(*arr); | 701 arr->set(3, obj->map()->constructor()); // Remember the constructor |
| 702 Handle<Map> old_map(obj->map()); | |
| 703 Handle<Map> new_map = Factory::CopyMap(old_map); | |
| 704 obj->set_map(*new_map); | |
| 705 new_map->set_needs_loading(true); | |
| 706 // Store the lazy loading info in the constructor field. We'll | |
| 707 // reestablish the constructor from the fixed array after loading. | |
| 708 new_map->set_constructor(*arr); | |
| 709 ASSERT(!obj->IsLoaded()); | |
| 698 } | 710 } |
| 699 | 711 |
| 700 } } // namespace v8::internal | 712 } } // namespace v8::internal |
| OLD | NEW |