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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 intptr_t Heap::external_allocation_limit_ = 0; | 131 intptr_t Heap::external_allocation_limit_ = 0; |
132 | 132 |
133 Heap::HeapState Heap::gc_state_ = NOT_IN_GC; | 133 Heap::HeapState Heap::gc_state_ = NOT_IN_GC; |
134 | 134 |
135 int Heap::mc_count_ = 0; | 135 int Heap::mc_count_ = 0; |
136 int Heap::ms_count_ = 0; | 136 int Heap::ms_count_ = 0; |
137 unsigned int Heap::gc_count_ = 0; | 137 unsigned int Heap::gc_count_ = 0; |
138 | 138 |
139 GCTracer* Heap::tracer_ = NULL; | 139 GCTracer* Heap::tracer_ = NULL; |
140 | 140 |
| 141 const int Heap::kArgumentsObjectSize; |
| 142 const int Heap::kArgumentsObjectSizeStrict; |
| 143 |
141 int Heap::unflattened_strings_length_ = 0; | 144 int Heap::unflattened_strings_length_ = 0; |
142 | 145 |
143 int Heap::always_allocate_scope_depth_ = 0; | 146 int Heap::always_allocate_scope_depth_ = 0; |
144 int Heap::linear_allocation_scope_depth_ = 0; | 147 int Heap::linear_allocation_scope_depth_ = 0; |
145 int Heap::contexts_disposed_ = 0; | 148 int Heap::contexts_disposed_ = 0; |
146 | 149 |
147 int Heap::young_survivors_after_last_gc_ = 0; | 150 int Heap::young_survivors_after_last_gc_ = 0; |
148 int Heap::high_survival_rate_period_length_ = 0; | 151 int Heap::high_survival_rate_period_length_ = 0; |
149 double Heap::survival_rate_ = 0; | 152 double Heap::survival_rate_ = 0; |
150 Heap::SurvivalRateTrend Heap::previous_survival_rate_trend_ = Heap::STABLE; | 153 Heap::SurvivalRateTrend Heap::previous_survival_rate_trend_ = Heap::STABLE; |
(...skipping 2740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2891 if (!maybe_result->ToObject(&result)) return maybe_result; | 2894 if (!maybe_result->ToObject(&result)) return maybe_result; |
2892 } | 2895 } |
2893 return InitializeFunction(JSFunction::cast(result), shared, prototype); | 2896 return InitializeFunction(JSFunction::cast(result), shared, prototype); |
2894 } | 2897 } |
2895 | 2898 |
2896 | 2899 |
2897 MaybeObject* Heap::AllocateArgumentsObject(Object* callee, int length) { | 2900 MaybeObject* Heap::AllocateArgumentsObject(Object* callee, int length) { |
2898 // To get fast allocation and map sharing for arguments objects we | 2901 // To get fast allocation and map sharing for arguments objects we |
2899 // allocate them based on an arguments boilerplate. | 2902 // allocate them based on an arguments boilerplate. |
2900 | 2903 |
| 2904 JSObject* boilerplate; |
| 2905 int arguments_object_size; |
| 2906 bool strict_mode_callee = callee->IsJSFunction() && |
| 2907 JSFunction::cast(callee)->shared()->strict_mode(); |
| 2908 if (strict_mode_callee) { |
| 2909 boilerplate = |
| 2910 Top::context()->global_context()->strict_mode_arguments_boilerplate(); |
| 2911 arguments_object_size = kArgumentsObjectSizeStrict; |
| 2912 } else { |
| 2913 boilerplate = Top::context()->global_context()->arguments_boilerplate(); |
| 2914 arguments_object_size = kArgumentsObjectSize; |
| 2915 } |
| 2916 |
2901 // This calls Copy directly rather than using Heap::AllocateRaw so we | 2917 // This calls Copy directly rather than using Heap::AllocateRaw so we |
2902 // duplicate the check here. | 2918 // duplicate the check here. |
2903 ASSERT(allocation_allowed_ && gc_state_ == NOT_IN_GC); | 2919 ASSERT(allocation_allowed_ && gc_state_ == NOT_IN_GC); |
2904 | 2920 |
2905 JSObject* boilerplate = | |
2906 Top::context()->global_context()->arguments_boilerplate(); | |
2907 | |
2908 // Check that the size of the boilerplate matches our | 2921 // Check that the size of the boilerplate matches our |
2909 // expectations. The ArgumentsAccessStub::GenerateNewObject relies | 2922 // expectations. The ArgumentsAccessStub::GenerateNewObject relies |
2910 // on the size being a known constant. | 2923 // on the size being a known constant. |
2911 ASSERT(kArgumentsObjectSize == boilerplate->map()->instance_size()); | 2924 ASSERT(arguments_object_size == boilerplate->map()->instance_size()); |
2912 | 2925 |
2913 // Do the allocation. | 2926 // Do the allocation. |
2914 Object* result; | 2927 Object* result; |
2915 { MaybeObject* maybe_result = | 2928 { MaybeObject* maybe_result = |
2916 AllocateRaw(kArgumentsObjectSize, NEW_SPACE, OLD_POINTER_SPACE); | 2929 AllocateRaw(arguments_object_size, NEW_SPACE, OLD_POINTER_SPACE); |
2917 if (!maybe_result->ToObject(&result)) return maybe_result; | 2930 if (!maybe_result->ToObject(&result)) return maybe_result; |
2918 } | 2931 } |
2919 | 2932 |
2920 // Copy the content. The arguments boilerplate doesn't have any | 2933 // Copy the content. The arguments boilerplate doesn't have any |
2921 // fields that point to new space so it's safe to skip the write | 2934 // fields that point to new space so it's safe to skip the write |
2922 // barrier here. | 2935 // barrier here. |
2923 CopyBlock(HeapObject::cast(result)->address(), | 2936 CopyBlock(HeapObject::cast(result)->address(), |
2924 boilerplate->address(), | 2937 boilerplate->address(), |
2925 kArgumentsObjectSize); | 2938 JSObject::kHeaderSize); |
2926 | 2939 |
2927 // Set the two properties. | 2940 // Set the length property. |
2928 JSObject::cast(result)->InObjectPropertyAtPut(arguments_callee_index, | 2941 JSObject::cast(result)->InObjectPropertyAtPut(kArgumentsLengthIndex, |
2929 callee); | |
2930 JSObject::cast(result)->InObjectPropertyAtPut(arguments_length_index, | |
2931 Smi::FromInt(length), | 2942 Smi::FromInt(length), |
2932 SKIP_WRITE_BARRIER); | 2943 SKIP_WRITE_BARRIER); |
| 2944 // Set the callee property for non-strict mode arguments object only. |
| 2945 if (!strict_mode_callee) { |
| 2946 JSObject::cast(result)->InObjectPropertyAtPut(kArgumentsCalleeIndex, |
| 2947 callee); |
| 2948 } |
2933 | 2949 |
2934 // Check the state of the object | 2950 // Check the state of the object |
2935 ASSERT(JSObject::cast(result)->HasFastProperties()); | 2951 ASSERT(JSObject::cast(result)->HasFastProperties()); |
2936 ASSERT(JSObject::cast(result)->HasFastElements()); | 2952 ASSERT(JSObject::cast(result)->HasFastElements()); |
2937 | 2953 |
2938 return result; | 2954 return result; |
2939 } | 2955 } |
2940 | 2956 |
2941 | 2957 |
2942 static bool HasDuplicates(DescriptorArray* descriptors) { | 2958 static bool HasDuplicates(DescriptorArray* descriptors) { |
(...skipping 2617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5560 void ExternalStringTable::TearDown() { | 5576 void ExternalStringTable::TearDown() { |
5561 new_space_strings_.Free(); | 5577 new_space_strings_.Free(); |
5562 old_space_strings_.Free(); | 5578 old_space_strings_.Free(); |
5563 } | 5579 } |
5564 | 5580 |
5565 | 5581 |
5566 List<Object*> ExternalStringTable::new_space_strings_; | 5582 List<Object*> ExternalStringTable::new_space_strings_; |
5567 List<Object*> ExternalStringTable::old_space_strings_; | 5583 List<Object*> ExternalStringTable::old_space_strings_; |
5568 | 5584 |
5569 } } // namespace v8::internal | 5585 } } // namespace v8::internal |
OLD | NEW |