| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 2960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2971 if (!maybe_result->ToObject(&result)) return maybe_result; | 2971 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 2972 } | 2972 } |
| 2973 return InitializeFunction(JSFunction::cast(result), shared, prototype); | 2973 return InitializeFunction(JSFunction::cast(result), shared, prototype); |
| 2974 } | 2974 } |
| 2975 | 2975 |
| 2976 | 2976 |
| 2977 MaybeObject* Heap::AllocateArgumentsObject(Object* callee, int length) { | 2977 MaybeObject* Heap::AllocateArgumentsObject(Object* callee, int length) { |
| 2978 // To get fast allocation and map sharing for arguments objects we | 2978 // To get fast allocation and map sharing for arguments objects we |
| 2979 // allocate them based on an arguments boilerplate. | 2979 // allocate them based on an arguments boilerplate. |
| 2980 | 2980 |
| 2981 JSObject* boilerplate; |
| 2982 int arguments_object_size; |
| 2983 bool strict_mode_callee = callee->IsJSFunction() && |
| 2984 JSFunction::cast(callee)->shared()->strict_mode(); |
| 2985 if (strict_mode_callee) { |
| 2986 boilerplate = |
| 2987 Top::context()->global_context()->strict_mode_arguments_boilerplate(); |
| 2988 arguments_object_size = kArgumentsObjectSizeStrict; |
| 2989 } else { |
| 2990 boilerplate = Top::context()->global_context()->arguments_boilerplate(); |
| 2991 arguments_object_size = kArgumentsObjectSize; |
| 2992 } |
| 2993 |
| 2981 // This calls Copy directly rather than using Heap::AllocateRaw so we | 2994 // This calls Copy directly rather than using Heap::AllocateRaw so we |
| 2982 // duplicate the check here. | 2995 // duplicate the check here. |
| 2983 ASSERT(allocation_allowed_ && gc_state_ == NOT_IN_GC); | 2996 ASSERT(allocation_allowed_ && gc_state_ == NOT_IN_GC); |
| 2984 | 2997 |
| 2985 JSObject* boilerplate = | |
| 2986 Top::context()->global_context()->arguments_boilerplate(); | |
| 2987 | |
| 2988 // Check that the size of the boilerplate matches our | 2998 // Check that the size of the boilerplate matches our |
| 2989 // expectations. The ArgumentsAccessStub::GenerateNewObject relies | 2999 // expectations. The ArgumentsAccessStub::GenerateNewObject relies |
| 2990 // on the size being a known constant. | 3000 // on the size being a known constant. |
| 2991 ASSERT(kArgumentsObjectSize == boilerplate->map()->instance_size()); | 3001 ASSERT(arguments_object_size == boilerplate->map()->instance_size()); |
| 2992 | 3002 |
| 2993 // Do the allocation. | 3003 // Do the allocation. |
| 2994 Object* result; | 3004 Object* result; |
| 2995 { MaybeObject* maybe_result = | 3005 { MaybeObject* maybe_result = |
| 2996 AllocateRaw(kArgumentsObjectSize, NEW_SPACE, OLD_POINTER_SPACE); | 3006 AllocateRaw(arguments_object_size, NEW_SPACE, OLD_POINTER_SPACE); |
| 2997 if (!maybe_result->ToObject(&result)) return maybe_result; | 3007 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 2998 } | 3008 } |
| 2999 | 3009 |
| 3000 // Copy the content. The arguments boilerplate doesn't have any | 3010 // Copy the content. The arguments boilerplate doesn't have any |
| 3001 // fields that point to new space so it's safe to skip the write | 3011 // fields that point to new space so it's safe to skip the write |
| 3002 // barrier here. | 3012 // barrier here. |
| 3003 CopyBlock(HeapObject::cast(result)->address(), | 3013 CopyBlock(HeapObject::cast(result)->address(), |
| 3004 boilerplate->address(), | 3014 boilerplate->address(), |
| 3005 kArgumentsObjectSize); | 3015 JSObject::kHeaderSize); |
| 3006 | 3016 |
| 3007 // Set the two properties. | 3017 // Set the length property. |
| 3008 JSObject::cast(result)->InObjectPropertyAtPut(arguments_callee_index, | 3018 JSObject::cast(result)->InObjectPropertyAtPut(kArgumentsLengthIndex, |
| 3009 callee); | |
| 3010 JSObject::cast(result)->InObjectPropertyAtPut(arguments_length_index, | |
| 3011 Smi::FromInt(length), | 3019 Smi::FromInt(length), |
| 3012 SKIP_WRITE_BARRIER); | 3020 SKIP_WRITE_BARRIER); |
| 3021 // Set the callee property for non-strict mode arguments object only. |
| 3022 if (!strict_mode_callee) { |
| 3023 JSObject::cast(result)->InObjectPropertyAtPut(kArgumentsCalleeIndex, |
| 3024 callee); |
| 3025 } |
| 3013 | 3026 |
| 3014 // Check the state of the object | 3027 // Check the state of the object |
| 3015 ASSERT(JSObject::cast(result)->HasFastProperties()); | 3028 ASSERT(JSObject::cast(result)->HasFastProperties()); |
| 3016 ASSERT(JSObject::cast(result)->HasFastElements()); | 3029 ASSERT(JSObject::cast(result)->HasFastElements()); |
| 3017 | 3030 |
| 3018 return result; | 3031 return result; |
| 3019 } | 3032 } |
| 3020 | 3033 |
| 3021 | 3034 |
| 3022 static bool HasDuplicates(DescriptorArray* descriptors) { | 3035 static bool HasDuplicates(DescriptorArray* descriptors) { |
| (...skipping 2633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5656 void ExternalStringTable::TearDown() { | 5669 void ExternalStringTable::TearDown() { |
| 5657 new_space_strings_.Free(); | 5670 new_space_strings_.Free(); |
| 5658 old_space_strings_.Free(); | 5671 old_space_strings_.Free(); |
| 5659 } | 5672 } |
| 5660 | 5673 |
| 5661 | 5674 |
| 5662 List<Object*> ExternalStringTable::new_space_strings_; | 5675 List<Object*> ExternalStringTable::new_space_strings_; |
| 5663 List<Object*> ExternalStringTable::old_space_strings_; | 5676 List<Object*> ExternalStringTable::old_space_strings_; |
| 5664 | 5677 |
| 5665 } } // namespace v8::internal | 5678 } } // namespace v8::internal |
| OLD | NEW |