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

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

Issue 2639333004: [pattern rewriter] Only desugar to call %ToName on computed properties (Closed)
Patch Set: add dcheck 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
« no previous file with comments | « src/parsing/pattern-rewriter.cc ('k') | test/mjsunit/harmony/object-rest-basic.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 RUNTIME_FUNCTION(Runtime_CopyDataPropertiesWithExcludedProperties) { 772 RUNTIME_FUNCTION(Runtime_CopyDataPropertiesWithExcludedProperties) {
773 HandleScope scope(isolate); 773 HandleScope scope(isolate);
774 DCHECK_LE(1, args.length()); 774 DCHECK_LE(1, args.length());
775 CONVERT_ARG_HANDLE_CHECKED(Object, source, 0); 775 CONVERT_ARG_HANDLE_CHECKED(Object, source, 0);
776 776
777 // 2. If source is undefined or null, let keys be an empty List. 777 // 2. If source is undefined or null, let keys be an empty List.
778 if (source->IsUndefined(isolate) || source->IsNull(isolate)) { 778 if (source->IsUndefined(isolate) || source->IsNull(isolate)) {
779 return isolate->heap()->undefined_value(); 779 return isolate->heap()->undefined_value();
780 } 780 }
781 781
782 ScopedVector<Handle<Name>> excluded_properties(args.length() - 1); 782 ScopedVector<Handle<Object>> excluded_properties(args.length() - 1);
783 for (int i = 1; i < args.length(); i++) { 783 for (int i = 1; i < args.length(); i++) {
784 excluded_properties[i - 1] = args.at<Name>(i); 784 Handle<Object> property = args.at(i);
785 uint32_t property_num;
786 // We convert string to number if possible, in cases of computed
787 // properties resolving to numbers, which would've been strings
788 // instead because of our call to %ToName() in the desugaring for
789 // computed properties.
790 if (property->IsString() &&
791 String::cast(*property)->AsArrayIndex(&property_num)) {
792 property = isolate->factory()->NewNumberFromUint(property_num);
793 }
794
795 excluded_properties[i - 1] = property;
785 } 796 }
786 797
787 Handle<JSObject> target = 798 Handle<JSObject> target =
788 isolate->factory()->NewJSObject(isolate->object_function()); 799 isolate->factory()->NewJSObject(isolate->object_function());
789 MAYBE_RETURN(JSReceiver::SetOrCopyDataProperties(isolate, target, source, 800 MAYBE_RETURN(JSReceiver::SetOrCopyDataProperties(isolate, target, source,
790 &excluded_properties, false), 801 &excluded_properties, false),
791 isolate->heap()->exception()); 802 isolate->heap()->exception());
792 return *target; 803 return *target;
793 } 804 }
794 805
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 if (!success) return isolate->heap()->exception(); 983 if (!success) return isolate->heap()->exception();
973 MAYBE_RETURN( 984 MAYBE_RETURN(
974 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR), 985 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR),
975 isolate->heap()->exception()); 986 isolate->heap()->exception());
976 return *value; 987 return *value;
977 } 988 }
978 989
979 990
980 } // namespace internal 991 } // namespace internal
981 } // namespace v8 992 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/pattern-rewriter.cc ('k') | test/mjsunit/harmony/object-rest-basic.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698