| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 2874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2885 if (!maybe_result->ToObject(&result)) return maybe_result; | 2885 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 2886 } | 2886 } |
| 2887 return InitializeFunction(JSFunction::cast(result), shared, prototype); | 2887 return InitializeFunction(JSFunction::cast(result), shared, prototype); |
| 2888 } | 2888 } |
| 2889 | 2889 |
| 2890 | 2890 |
| 2891 MaybeObject* Heap::AllocateArgumentsObject(Object* callee, int length) { | 2891 MaybeObject* Heap::AllocateArgumentsObject(Object* callee, int length) { |
| 2892 // To get fast allocation and map sharing for arguments objects we | 2892 // To get fast allocation and map sharing for arguments objects we |
| 2893 // allocate them based on an arguments boilerplate. | 2893 // allocate them based on an arguments boilerplate. |
| 2894 | 2894 |
| 2895 JSObject* boilerplate; |
| 2896 int arguments_object_size; |
| 2897 bool strict_mode_callee = callee->IsJSFunction() && |
| 2898 JSFunction::cast(callee)->shared()->strict_mode(); |
| 2899 if (strict_mode_callee) { |
| 2900 boilerplate = |
| 2901 isolate()->context()->global_context()-> |
| 2902 strict_mode_arguments_boilerplate(); |
| 2903 arguments_object_size = kArgumentsObjectSizeStrict; |
| 2904 } else { |
| 2905 boilerplate = |
| 2906 isolate()->context()->global_context()->arguments_boilerplate(); |
| 2907 arguments_object_size = kArgumentsObjectSize; |
| 2908 } |
| 2909 |
| 2895 // This calls Copy directly rather than using Heap::AllocateRaw so we | 2910 // This calls Copy directly rather than using Heap::AllocateRaw so we |
| 2896 // duplicate the check here. | 2911 // duplicate the check here. |
| 2897 ASSERT(allocation_allowed_ && gc_state_ == NOT_IN_GC); | 2912 ASSERT(allocation_allowed_ && gc_state_ == NOT_IN_GC); |
| 2898 | 2913 |
| 2899 JSObject* boilerplate = | |
| 2900 isolate()->context()->global_context()->arguments_boilerplate(); | |
| 2901 | |
| 2902 // Check that the size of the boilerplate matches our | 2914 // Check that the size of the boilerplate matches our |
| 2903 // expectations. The ArgumentsAccessStub::GenerateNewObject relies | 2915 // expectations. The ArgumentsAccessStub::GenerateNewObject relies |
| 2904 // on the size being a known constant. | 2916 // on the size being a known constant. |
| 2905 ASSERT(kArgumentsObjectSize == boilerplate->map()->instance_size()); | 2917 ASSERT(arguments_object_size == boilerplate->map()->instance_size()); |
| 2906 | 2918 |
| 2907 // Do the allocation. | 2919 // Do the allocation. |
| 2908 Object* result; | 2920 Object* result; |
| 2909 { MaybeObject* maybe_result = | 2921 { MaybeObject* maybe_result = |
| 2910 AllocateRaw(kArgumentsObjectSize, NEW_SPACE, OLD_POINTER_SPACE); | 2922 AllocateRaw(arguments_object_size, NEW_SPACE, OLD_POINTER_SPACE); |
| 2911 if (!maybe_result->ToObject(&result)) return maybe_result; | 2923 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 2912 } | 2924 } |
| 2913 | 2925 |
| 2914 // Copy the content. The arguments boilerplate doesn't have any | 2926 // Copy the content. The arguments boilerplate doesn't have any |
| 2915 // fields that point to new space so it's safe to skip the write | 2927 // fields that point to new space so it's safe to skip the write |
| 2916 // barrier here. | 2928 // barrier here. |
| 2917 CopyBlock(HeapObject::cast(result)->address(), | 2929 CopyBlock(HeapObject::cast(result)->address(), |
| 2918 boilerplate->address(), | 2930 boilerplate->address(), |
| 2919 kArgumentsObjectSize); | 2931 JSObject::kHeaderSize); |
| 2920 | 2932 |
| 2921 // Set the two properties. | 2933 // Set the length property. |
| 2922 JSObject::cast(result)->InObjectPropertyAtPut(arguments_callee_index, | 2934 JSObject::cast(result)->InObjectPropertyAtPut(kArgumentsLengthIndex, |
| 2923 callee); | |
| 2924 JSObject::cast(result)->InObjectPropertyAtPut(arguments_length_index, | |
| 2925 Smi::FromInt(length), | 2935 Smi::FromInt(length), |
| 2926 SKIP_WRITE_BARRIER); | 2936 SKIP_WRITE_BARRIER); |
| 2937 // Set the callee property for non-strict mode arguments object only. |
| 2938 if (!strict_mode_callee) { |
| 2939 JSObject::cast(result)->InObjectPropertyAtPut(kArgumentsCalleeIndex, |
| 2940 callee); |
| 2941 } |
| 2927 | 2942 |
| 2928 // Check the state of the object | 2943 // Check the state of the object |
| 2929 ASSERT(JSObject::cast(result)->HasFastProperties()); | 2944 ASSERT(JSObject::cast(result)->HasFastProperties()); |
| 2930 ASSERT(JSObject::cast(result)->HasFastElements()); | 2945 ASSERT(JSObject::cast(result)->HasFastElements()); |
| 2931 | 2946 |
| 2932 return result; | 2947 return result; |
| 2933 } | 2948 } |
| 2934 | 2949 |
| 2935 | 2950 |
| 2936 static bool HasDuplicates(DescriptorArray* descriptors) { | 2951 static bool HasDuplicates(DescriptorArray* descriptors) { |
| (...skipping 2825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5762 } | 5777 } |
| 5763 | 5778 |
| 5764 | 5779 |
| 5765 void ExternalStringTable::TearDown() { | 5780 void ExternalStringTable::TearDown() { |
| 5766 new_space_strings_.Free(); | 5781 new_space_strings_.Free(); |
| 5767 old_space_strings_.Free(); | 5782 old_space_strings_.Free(); |
| 5768 } | 5783 } |
| 5769 | 5784 |
| 5770 | 5785 |
| 5771 } } // namespace v8::internal | 5786 } } // namespace v8::internal |
| OLD | NEW |