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

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

Issue 1417243002: [es6] Partially implement Reflect.setPrototypeOf. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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/runtime/runtime-classes.cc ('k') | test/mjsunit/harmony/reflect.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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 HandleScope scope(isolate); 157 HandleScope scope(isolate);
158 DCHECK(args.length() == 1); 158 DCHECK(args.length() == 1);
159 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); 159 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0);
160 return *Object::GetPrototype(isolate, obj); 160 return *Object::GetPrototype(isolate, obj);
161 } 161 }
162 162
163 163
164 RUNTIME_FUNCTION(Runtime_InternalSetPrototype) { 164 RUNTIME_FUNCTION(Runtime_InternalSetPrototype) {
165 HandleScope scope(isolate); 165 HandleScope scope(isolate);
166 DCHECK(args.length() == 2); 166 DCHECK(args.length() == 2);
167 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); 167 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, obj, 0);
168 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1); 168 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1);
169 Handle<Object> result; 169 MAYBE_RETURN(JSReceiver::SetPrototype(obj, prototype, false, THROW_ON_ERROR),
170 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 170 isolate->heap()->exception());
171 isolate, result, JSObject::SetPrototype(obj, prototype, false)); 171 return *obj;
172 return *result;
173 } 172 }
174 173
175 174
176 RUNTIME_FUNCTION(Runtime_SetPrototype) { 175 RUNTIME_FUNCTION(Runtime_SetPrototype) {
177 HandleScope scope(isolate); 176 HandleScope scope(isolate);
178 DCHECK(args.length() == 2); 177 DCHECK(args.length() == 2);
179 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); 178 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, obj, 0);
180 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1); 179 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1);
181 Handle<Object> result; 180 MAYBE_RETURN(JSReceiver::SetPrototype(obj, prototype, true, THROW_ON_ERROR),
182 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 181 isolate->heap()->exception());
183 isolate, result, JSObject::SetPrototype(obj, prototype, true)); 182 return *obj;
184 return *result;
185 } 183 }
186 184
187 185
188 // Enumerator used as indices into the array returned from GetOwnProperty 186 // Enumerator used as indices into the array returned from GetOwnProperty
189 enum PropertyDescriptorIndices { 187 enum PropertyDescriptorIndices {
190 IS_ACCESSOR_INDEX, 188 IS_ACCESSOR_INDEX,
191 VALUE_INDEX, 189 VALUE_INDEX,
192 GETTER_INDEX, 190 GETTER_INDEX,
193 SETTER_INDEX, 191 SETTER_INDEX,
194 WRITABLE_INDEX, 192 WRITABLE_INDEX,
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 result = isolate->factory()->NewJSObjectWithMemento(function, site); 1018 result = isolate->factory()->NewJSObjectWithMemento(function, site);
1021 } 1019 }
1022 1020
1023 // Set up the prototoype using original function. 1021 // Set up the prototoype using original function.
1024 // TODO(dslomov): instead of setting the __proto__, 1022 // TODO(dslomov): instead of setting the __proto__,
1025 // use and cache the correct map. 1023 // use and cache the correct map.
1026 if (*original_function != *function) { 1024 if (*original_function != *function) {
1027 if (original_function->has_instance_prototype()) { 1025 if (original_function->has_instance_prototype()) {
1028 Handle<Object> prototype = 1026 Handle<Object> prototype =
1029 handle(original_function->instance_prototype(), isolate); 1027 handle(original_function->instance_prototype(), isolate);
1030 RETURN_FAILURE_ON_EXCEPTION( 1028 MAYBE_RETURN(
1031 isolate, JSObject::SetPrototype(result, prototype, false)); 1029 JSObject::SetPrototype(result, prototype, false, THROW_ON_ERROR),
1030 isolate->heap()->exception());
1032 } 1031 }
1033 } 1032 }
1034 1033
1035 isolate->counters()->constructed_objects()->Increment(); 1034 isolate->counters()->constructed_objects()->Increment();
1036 isolate->counters()->constructed_objects_runtime()->Increment(); 1035 isolate->counters()->constructed_objects_runtime()->Increment();
1037 1036
1038 return *result; 1037 return *result;
1039 } 1038 }
1040 1039
1041 1040
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
1573 1572
1574 RUNTIME_FUNCTION(Runtime_ObjectDefineProperties) { 1573 RUNTIME_FUNCTION(Runtime_ObjectDefineProperties) {
1575 HandleScope scope(isolate); 1574 HandleScope scope(isolate);
1576 DCHECK(args.length() == 2); 1575 DCHECK(args.length() == 2);
1577 CONVERT_ARG_HANDLE_CHECKED(Object, o, 0); 1576 CONVERT_ARG_HANDLE_CHECKED(Object, o, 0);
1578 CONVERT_ARG_HANDLE_CHECKED(Object, properties, 1); 1577 CONVERT_ARG_HANDLE_CHECKED(Object, properties, 1);
1579 return JSReceiver::DefineProperties(isolate, o, properties); 1578 return JSReceiver::DefineProperties(isolate, o, properties);
1580 } 1579 }
1581 } // namespace internal 1580 } // namespace internal
1582 } // namespace v8 1581 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-classes.cc ('k') | test/mjsunit/harmony/reflect.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698