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

Side by Side Diff: src/runtime/runtime-object.cc

Issue 2639333004: [pattern rewriter] Only desugar to call %ToName on computed properties (Closed)
Patch Set: Created 3 years, 11 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
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/bootstrapper.h" 8 #include "src/bootstrapper.h"
9 #include "src/debug/debug.h" 9 #include "src/debug/debug.h"
10 #include "src/isolate-inl.h" 10 #include "src/isolate-inl.h"
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 RUNTIME_FUNCTION(Runtime_CopyDataPropertiesWithExcludedProperties) { 764 RUNTIME_FUNCTION(Runtime_CopyDataPropertiesWithExcludedProperties) {
765 HandleScope scope(isolate); 765 HandleScope scope(isolate);
766 DCHECK_LE(1, args.length()); 766 DCHECK_LE(1, args.length());
767 CONVERT_ARG_HANDLE_CHECKED(Object, source, 0); 767 CONVERT_ARG_HANDLE_CHECKED(Object, source, 0);
768 768
769 // 2. If source is undefined or null, let keys be an empty List. 769 // 2. If source is undefined or null, let keys be an empty List.
770 if (source->IsUndefined(isolate) || source->IsNull(isolate)) { 770 if (source->IsUndefined(isolate) || source->IsNull(isolate)) {
771 return isolate->heap()->undefined_value(); 771 return isolate->heap()->undefined_value();
772 } 772 }
773 773
774 ScopedVector<Handle<Name>> excluded_properties(args.length() - 1); 774 ScopedVector<Handle<Object>> excluded_properties(args.length() - 1);
775 for (int i = 1; i < args.length(); i++) { 775 for (int i = 1; i < args.length(); i++) {
776 excluded_properties[i - 1] = args.at<Name>(i); 776 Handle<Object> property = args.at(i);
777 uint32_t property_num;
778 // We convert string to number if possible, in cases of computed
779 // properties resolving to numbers, which would've been strings
780 // instead because of our call to %ToName() in the desugaring for
781 // computed properties.
782 if (property->IsString() &&
783 String::cast(*property)->AsArrayIndex(&property_num)) {
784 property = isolate->factory()->NewNumberFromUint(property_num);
785 }
786
787 excluded_properties[i - 1] = property;
777 } 788 }
778 789
779 Handle<JSObject> target = 790 Handle<JSObject> target =
780 isolate->factory()->NewJSObject(isolate->object_function()); 791 isolate->factory()->NewJSObject(isolate->object_function());
781 MAYBE_RETURN(JSReceiver::SetOrCopyDataProperties(isolate, target, source, 792 MAYBE_RETURN(JSReceiver::SetOrCopyDataProperties(isolate, target, source,
782 &excluded_properties, false), 793 &excluded_properties, false),
783 isolate->heap()->exception()); 794 isolate->heap()->exception());
784 return *target; 795 return *target;
785 } 796 }
786 797
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 if (!success) return isolate->heap()->exception(); 975 if (!success) return isolate->heap()->exception();
965 MAYBE_RETURN( 976 MAYBE_RETURN(
966 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR), 977 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR),
967 isolate->heap()->exception()); 978 isolate->heap()->exception());
968 return *value; 979 return *value;
969 } 980 }
970 981
971 982
972 } // namespace internal 983 } // namespace internal
973 } // namespace v8 984 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698