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

Side by Side Diff: src/heap.cc

Issue 6698015: Implement strict mode arguments caller/callee. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 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 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 2880 matching lines...) Expand 10 before | Expand all | Expand 10 after
2891 if (!maybe_result->ToObject(&result)) return maybe_result; 2891 if (!maybe_result->ToObject(&result)) return maybe_result;
2892 } 2892 }
2893 return InitializeFunction(JSFunction::cast(result), shared, prototype); 2893 return InitializeFunction(JSFunction::cast(result), shared, prototype);
2894 } 2894 }
2895 2895
2896 2896
2897 MaybeObject* Heap::AllocateArgumentsObject(Object* callee, int length) { 2897 MaybeObject* Heap::AllocateArgumentsObject(Object* callee, int length) {
2898 // To get fast allocation and map sharing for arguments objects we 2898 // To get fast allocation and map sharing for arguments objects we
2899 // allocate them based on an arguments boilerplate. 2899 // allocate them based on an arguments boilerplate.
2900 2900
2901 JSObject* boilerplate;
2902 int arguments_object_size;
2903
2904 if (callee->IsJSFunction() &&
2905 JSFunction::cast(callee)->shared()->strict_mode()) {
2906 boilerplate =
2907 Top::context()->global_context()->arguments_boilerplate_strict();
2908 arguments_object_size = kArgumentsObjectSizeStrict;
2909 } else {
2910 boilerplate = Top::context()->global_context()->arguments_boilerplate();
2911 arguments_object_size = kArgumentsObjectSize;
2912 }
2913
2901 // This calls Copy directly rather than using Heap::AllocateRaw so we 2914 // This calls Copy directly rather than using Heap::AllocateRaw so we
2902 // duplicate the check here. 2915 // duplicate the check here.
2903 ASSERT(allocation_allowed_ && gc_state_ == NOT_IN_GC); 2916 ASSERT(allocation_allowed_ && gc_state_ == NOT_IN_GC);
2904 2917
2905 JSObject* boilerplate =
2906 Top::context()->global_context()->arguments_boilerplate();
2907
2908 // Check that the size of the boilerplate matches our 2918 // Check that the size of the boilerplate matches our
2909 // expectations. The ArgumentsAccessStub::GenerateNewObject relies 2919 // expectations. The ArgumentsAccessStub::GenerateNewObject relies
2910 // on the size being a known constant. 2920 // on the size being a known constant.
2911 ASSERT(kArgumentsObjectSize == boilerplate->map()->instance_size()); 2921 ASSERT(arguments_object_size == boilerplate->map()->instance_size());
2912 2922
2913 // Do the allocation. 2923 // Do the allocation.
2914 Object* result; 2924 Object* result;
2915 { MaybeObject* maybe_result = 2925 { MaybeObject* maybe_result =
2916 AllocateRaw(kArgumentsObjectSize, NEW_SPACE, OLD_POINTER_SPACE); 2926 AllocateRaw(arguments_object_size, NEW_SPACE, OLD_POINTER_SPACE);
2917 if (!maybe_result->ToObject(&result)) return maybe_result; 2927 if (!maybe_result->ToObject(&result)) return maybe_result;
2918 } 2928 }
2919 2929
2920 // Copy the content. The arguments boilerplate doesn't have any 2930 // 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 2931 // fields that point to new space so it's safe to skip the write
2922 // barrier here. 2932 // barrier here.
2923 CopyBlock(HeapObject::cast(result)->address(), 2933 CopyBlock(HeapObject::cast(result)->address(),
2924 boilerplate->address(), 2934 boilerplate->address(),
2925 kArgumentsObjectSize); 2935 JSObject::kHeaderSize);
2926 2936
2927 // Set the two properties. 2937 // Set the length property.
2928 JSObject::cast(result)->InObjectPropertyAtPut(arguments_callee_index,
2929 callee);
2930 JSObject::cast(result)->InObjectPropertyAtPut(arguments_length_index, 2938 JSObject::cast(result)->InObjectPropertyAtPut(arguments_length_index,
2931 Smi::FromInt(length), 2939 Smi::FromInt(length),
2932 SKIP_WRITE_BARRIER); 2940 SKIP_WRITE_BARRIER);
2941 // Set the callee property for non-strict mode arguments object.
2942 if (arguments_object_size == kArgumentsObjectSize) {
Lasse Reichstein 2011/03/15 09:58:40 Save the is_strict_callee boolean as a variable, a
Martin Maly 2011/03/16 01:21:24 Done.
2943 JSObject::cast(result)->InObjectPropertyAtPut(arguments_callee_index,
2944 callee);
2945 }
2933 2946
2934 // Check the state of the object 2947 // Check the state of the object
2935 ASSERT(JSObject::cast(result)->HasFastProperties()); 2948 ASSERT(JSObject::cast(result)->HasFastProperties());
2936 ASSERT(JSObject::cast(result)->HasFastElements()); 2949 ASSERT(JSObject::cast(result)->HasFastElements());
2937 2950
2938 return result; 2951 return result;
2939 } 2952 }
2940 2953
2941 2954
2942 static bool HasDuplicates(DescriptorArray* descriptors) { 2955 static bool HasDuplicates(DescriptorArray* descriptors) {
(...skipping 2617 matching lines...) Expand 10 before | Expand all | Expand 10 after
5560 void ExternalStringTable::TearDown() { 5573 void ExternalStringTable::TearDown() {
5561 new_space_strings_.Free(); 5574 new_space_strings_.Free();
5562 old_space_strings_.Free(); 5575 old_space_strings_.Free();
5563 } 5576 }
5564 5577
5565 5578
5566 List<Object*> ExternalStringTable::new_space_strings_; 5579 List<Object*> ExternalStringTable::new_space_strings_;
5567 List<Object*> ExternalStringTable::old_space_strings_; 5580 List<Object*> ExternalStringTable::old_space_strings_;
5568 5581
5569 } } // namespace v8::internal 5582 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698