Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(521)

Side by Side Diff: src/handles.cc

Issue 1094014: Merge the partial_snapshots branch back into bleeding_edge. For... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 229
230 Handle<Object> ForceSetProperty(Handle<JSObject> object, 230 Handle<Object> ForceSetProperty(Handle<JSObject> object,
231 Handle<Object> key, 231 Handle<Object> key,
232 Handle<Object> value, 232 Handle<Object> value,
233 PropertyAttributes attributes) { 233 PropertyAttributes attributes) {
234 CALL_HEAP_FUNCTION( 234 CALL_HEAP_FUNCTION(
235 Runtime::ForceSetObjectProperty(object, key, value, attributes), Object); 235 Runtime::ForceSetObjectProperty(object, key, value, attributes), Object);
236 } 236 }
237 237
238 238
239 Handle<Object> SetNormalizedProperty(Handle<JSObject> object,
240 Handle<String> key,
241 Handle<Object> value,
242 PropertyDetails details) {
243 CALL_HEAP_FUNCTION(object->SetNormalizedProperty(*key, *value, details),
244 Object);
245 }
246
247
239 Handle<Object> ForceDeleteProperty(Handle<JSObject> object, 248 Handle<Object> ForceDeleteProperty(Handle<JSObject> object,
240 Handle<Object> key) { 249 Handle<Object> key) {
241 CALL_HEAP_FUNCTION(Runtime::ForceDeleteObjectProperty(object, key), Object); 250 CALL_HEAP_FUNCTION(Runtime::ForceDeleteObjectProperty(object, key), Object);
242 } 251 }
243 252
244 253
245 Handle<Object> IgnoreAttributesAndSetLocalProperty( 254 Handle<Object> IgnoreAttributesAndSetLocalProperty(
246 Handle<JSObject> object, 255 Handle<JSObject> object,
247 Handle<String> key, 256 Handle<String> key,
248 Handle<Object> value, 257 Handle<Object> value,
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 779
771 780
772 OptimizedObjectForAddingMultipleProperties:: 781 OptimizedObjectForAddingMultipleProperties::
773 ~OptimizedObjectForAddingMultipleProperties() { 782 ~OptimizedObjectForAddingMultipleProperties() {
774 // Reoptimize the object to allow fast property access. 783 // Reoptimize the object to allow fast property access.
775 if (has_been_transformed_) { 784 if (has_been_transformed_) {
776 TransformToFastProperties(object_, unused_property_fields_); 785 TransformToFastProperties(object_, unused_property_fields_);
777 } 786 }
778 } 787 }
779 788
780
781 void LoadLazy(Handle<JSObject> obj, bool* pending_exception) {
782 HandleScope scope;
783 Handle<FixedArray> info(FixedArray::cast(obj->map()->constructor()));
784 int index = Smi::cast(info->get(0))->value();
785 ASSERT(index >= 0);
786 Handle<Context> compile_context(Context::cast(info->get(1)));
787 Handle<Context> function_context(Context::cast(info->get(2)));
788 Handle<Object> receiver(compile_context->global()->builtins());
789
790 Vector<const char> name = Natives::GetScriptName(index);
791
792 Handle<SharedFunctionInfo> function_info;
793
794 if (!Bootstrapper::NativesCacheLookup(name, &function_info)) {
795 Handle<String> source_code = Bootstrapper::NativesSourceLookup(index);
796 Handle<String> script_name = Factory::NewStringFromAscii(name);
797 bool allow_natives_syntax = FLAG_allow_natives_syntax;
798 FLAG_allow_natives_syntax = true;
799 function_info = Compiler::Compile(source_code,
800 script_name,
801 0, 0, NULL, NULL,
802 Handle<String>::null(),
803 NATIVES_CODE);
804 FLAG_allow_natives_syntax = allow_natives_syntax;
805 // If the compilation failed (possibly due to stack overflows), we
806 // should never enter the result in the natives cache. Instead we
807 // return from the function without marking the function as having
808 // been lazily loaded.
809 if (function_info.is_null()) {
810 *pending_exception = true;
811 return;
812 }
813 Bootstrapper::NativesCacheAdd(name, function_info);
814 }
815
816 // We shouldn't get here if compiling the script failed.
817 ASSERT(!function_info.is_null());
818
819 #ifdef ENABLE_DEBUGGER_SUPPORT
820 // When the debugger running in its own context touches lazy loaded
821 // functions loading can be triggered. In that case ensure that the
822 // execution of the boilerplate is in the correct context.
823 SaveContext save;
824 if (!Debug::debug_context().is_null() &&
825 Top::context() == *Debug::debug_context()) {
826 Top::set_context(*compile_context);
827 }
828 #endif
829
830 // Reset the lazy load data before running the script to make sure
831 // not to get recursive lazy loading.
832 obj->map()->set_needs_loading(false);
833 obj->map()->set_constructor(info->get(3));
834
835 // Run the script.
836 Handle<JSFunction> script_fun(
837 Factory::NewFunctionFromSharedFunctionInfo(function_info,
838 function_context));
839 Execution::Call(script_fun, receiver, 0, NULL, pending_exception);
840
841 // If lazy loading failed, restore the unloaded state of obj.
842 if (*pending_exception) {
843 obj->map()->set_needs_loading(true);
844 obj->map()->set_constructor(*info);
845 }
846 }
847
848
849 void SetupLazy(Handle<JSObject> obj,
850 int index,
851 Handle<Context> compile_context,
852 Handle<Context> function_context) {
853 Handle<FixedArray> arr = Factory::NewFixedArray(4);
854 arr->set(0, Smi::FromInt(index));
855 arr->set(1, *compile_context); // Compile in this context
856 arr->set(2, *function_context); // Set function context to this
857 arr->set(3, obj->map()->constructor()); // Remember the constructor
858 Handle<Map> old_map(obj->map());
859 Handle<Map> new_map = Factory::CopyMapDropTransitions(old_map);
860 obj->set_map(*new_map);
861 new_map->set_needs_loading(true);
862 // Store the lazy loading info in the constructor field. We'll
863 // reestablish the constructor from the fixed array after loading.
864 new_map->set_constructor(*arr);
865 ASSERT(!obj->IsLoaded());
866 }
867
868 } } // namespace v8::internal 789 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698