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

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

Issue 1606783002: [builtins] Migrate Object.getOwnPropertyDescriptor to C++. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE Created 4 years, 10 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/runtime/runtime.h ('k') | no next file » | 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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 DCHECK(args.length() == 2); 259 DCHECK(args.length() == 2);
260 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); 260 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
261 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); 261 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1);
262 Handle<Object> result; 262 Handle<Object> result;
263 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, 263 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
264 GetOwnProperty(isolate, obj, name)); 264 GetOwnProperty(isolate, obj, name));
265 return *result; 265 return *result;
266 } 266 }
267 267
268 268
269 // ES6 19.1.2.6
270 RUNTIME_FUNCTION(Runtime_GetOwnProperty) {
271 HandleScope scope(isolate);
272 DCHECK(args.length() == 2);
273 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
274 CONVERT_ARG_HANDLE_CHECKED(Object, raw_name, 1);
275 // 1. Let obj be ? ToObject(O).
276 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, object,
277 Object::ToObject(isolate, object));
278 // 2. Let key be ? ToPropertyKey(P).
279 Handle<Name> key;
280 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, key,
281 Object::ToName(isolate, raw_name));
282
283 // 3. Let desc be ? obj.[[GetOwnProperty]](key).
284 PropertyDescriptor desc;
285 Maybe<bool> found = JSReceiver::GetOwnPropertyDescriptor(
286 isolate, Handle<JSReceiver>::cast(object), key, &desc);
287 MAYBE_RETURN(found, isolate->heap()->exception());
288 // 4. Return FromPropertyDescriptor(desc).
289 if (!found.FromJust()) return isolate->heap()->undefined_value();
290 return *desc.ToObject(isolate);
291 }
292
293
294 RUNTIME_FUNCTION(Runtime_OptimizeObjectForAddingMultipleProperties) { 269 RUNTIME_FUNCTION(Runtime_OptimizeObjectForAddingMultipleProperties) {
295 HandleScope scope(isolate); 270 HandleScope scope(isolate);
296 DCHECK(args.length() == 2); 271 DCHECK(args.length() == 2);
297 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); 272 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
298 CONVERT_SMI_ARG_CHECKED(properties, 1); 273 CONVERT_SMI_ARG_CHECKED(properties, 1);
299 // Conservative upper limit to prevent fuzz tests from going OOM. 274 // Conservative upper limit to prevent fuzz tests from going OOM.
300 RUNTIME_ASSERT(properties <= 100000); 275 RUNTIME_ASSERT(properties <= 100000);
301 if (object->HasFastProperties() && !object->IsJSGlobalProxy()) { 276 if (object->HasFastProperties() && !object->IsJSGlobalProxy()) {
302 JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, properties, 277 JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, properties,
303 "OptimizeForAdding"); 278 "OptimizeForAdding");
(...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 DCHECK(args.length() == 2); 1263 DCHECK(args.length() == 2);
1289 CONVERT_ARG_HANDLE_CHECKED(Object, o, 0); 1264 CONVERT_ARG_HANDLE_CHECKED(Object, o, 0);
1290 CONVERT_ARG_HANDLE_CHECKED(Object, properties, 1); 1265 CONVERT_ARG_HANDLE_CHECKED(Object, properties, 1);
1291 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 1266 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
1292 isolate, o, JSReceiver::DefineProperties(isolate, o, properties)); 1267 isolate, o, JSReceiver::DefineProperties(isolate, o, properties));
1293 return *o; 1268 return *o;
1294 } 1269 }
1295 1270
1296 } // namespace internal 1271 } // namespace internal
1297 } // namespace v8 1272 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698