| 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 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 bool EnsureCompiled(Handle<SharedFunctionInfo> shared, | 873 bool EnsureCompiled(Handle<SharedFunctionInfo> shared, |
| 874 ClearExceptionFlag flag) { | 874 ClearExceptionFlag flag) { |
| 875 return shared->is_compiled() || CompileLazyShared(shared, flag); | 875 return shared->is_compiled() || CompileLazyShared(shared, flag); |
| 876 } | 876 } |
| 877 | 877 |
| 878 | 878 |
| 879 static bool CompileLazyHelper(CompilationInfo* info, | 879 static bool CompileLazyHelper(CompilationInfo* info, |
| 880 ClearExceptionFlag flag) { | 880 ClearExceptionFlag flag) { |
| 881 // Compile the source information to a code object. | 881 // Compile the source information to a code object. |
| 882 ASSERT(info->IsOptimizing() || !info->shared_info()->is_compiled()); | 882 ASSERT(info->IsOptimizing() || !info->shared_info()->is_compiled()); |
| 883 ASSERT(!info->isolate()->has_pending_exception()); |
| 883 bool result = Compiler::CompileLazy(info); | 884 bool result = Compiler::CompileLazy(info); |
| 884 ASSERT(result != Isolate::Current()->has_pending_exception()); | 885 ASSERT(result != Isolate::Current()->has_pending_exception()); |
| 885 if (!result && flag == CLEAR_EXCEPTION) { | 886 if (!result && flag == CLEAR_EXCEPTION) { |
| 886 Isolate::Current()->clear_pending_exception(); | 887 info->isolate()->clear_pending_exception(); |
| 887 } | 888 } |
| 888 return result; | 889 return result; |
| 889 } | 890 } |
| 890 | 891 |
| 891 | 892 |
| 892 bool CompileLazyShared(Handle<SharedFunctionInfo> shared, | 893 bool CompileLazyShared(Handle<SharedFunctionInfo> shared, |
| 893 ClearExceptionFlag flag) { | 894 ClearExceptionFlag flag) { |
| 894 CompilationInfo info(shared); | 895 CompilationInfo info(shared); |
| 895 return CompileLazyHelper(&info, flag); | 896 return CompileLazyHelper(&info, flag); |
| 896 } | 897 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 if (result) PROFILE(FunctionCreateEvent(*function)); | 941 if (result) PROFILE(FunctionCreateEvent(*function)); |
| 941 return result; | 942 return result; |
| 942 } | 943 } |
| 943 | 944 |
| 944 | 945 |
| 945 OptimizedObjectForAddingMultipleProperties:: | 946 OptimizedObjectForAddingMultipleProperties:: |
| 946 OptimizedObjectForAddingMultipleProperties(Handle<JSObject> object, | 947 OptimizedObjectForAddingMultipleProperties(Handle<JSObject> object, |
| 947 int expected_additional_properties, | 948 int expected_additional_properties, |
| 948 bool condition) { | 949 bool condition) { |
| 949 object_ = object; | 950 object_ = object; |
| 950 if (condition && object_->HasFastProperties()) { | 951 if (condition && object_->HasFastProperties() && !object->IsJSGlobalProxy()) { |
| 951 // Normalize the properties of object to avoid n^2 behavior | 952 // Normalize the properties of object to avoid n^2 behavior |
| 952 // when extending the object multiple properties. Indicate the number of | 953 // when extending the object multiple properties. Indicate the number of |
| 953 // properties to be added. | 954 // properties to be added. |
| 954 unused_property_fields_ = object->map()->unused_property_fields(); | 955 unused_property_fields_ = object->map()->unused_property_fields(); |
| 955 NormalizeProperties(object_, | 956 NormalizeProperties(object_, |
| 956 KEEP_INOBJECT_PROPERTIES, | 957 KEEP_INOBJECT_PROPERTIES, |
| 957 expected_additional_properties); | 958 expected_additional_properties); |
| 958 has_been_transformed_ = true; | 959 has_been_transformed_ = true; |
| 959 | 960 |
| 960 } else { | 961 } else { |
| 961 has_been_transformed_ = false; | 962 has_been_transformed_ = false; |
| 962 } | 963 } |
| 963 } | 964 } |
| 964 | 965 |
| 965 | 966 |
| 966 OptimizedObjectForAddingMultipleProperties:: | 967 OptimizedObjectForAddingMultipleProperties:: |
| 967 ~OptimizedObjectForAddingMultipleProperties() { | 968 ~OptimizedObjectForAddingMultipleProperties() { |
| 968 // Reoptimize the object to allow fast property access. | 969 // Reoptimize the object to allow fast property access. |
| 969 if (has_been_transformed_) { | 970 if (has_been_transformed_) { |
| 970 TransformToFastProperties(object_, unused_property_fields_); | 971 TransformToFastProperties(object_, unused_property_fields_); |
| 971 } | 972 } |
| 972 } | 973 } |
| 973 | 974 |
| 974 } } // namespace v8::internal | 975 } } // namespace v8::internal |
| OLD | NEW |