OLD | NEW |
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 Loading... |
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 |
269 RUNTIME_FUNCTION(Runtime_OptimizeObjectForAddingMultipleProperties) { | 294 RUNTIME_FUNCTION(Runtime_OptimizeObjectForAddingMultipleProperties) { |
270 HandleScope scope(isolate); | 295 HandleScope scope(isolate); |
271 DCHECK(args.length() == 2); | 296 DCHECK(args.length() == 2); |
272 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 297 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
273 CONVERT_SMI_ARG_CHECKED(properties, 1); | 298 CONVERT_SMI_ARG_CHECKED(properties, 1); |
274 // Conservative upper limit to prevent fuzz tests from going OOM. | 299 // Conservative upper limit to prevent fuzz tests from going OOM. |
275 RUNTIME_ASSERT(properties <= 100000); | 300 RUNTIME_ASSERT(properties <= 100000); |
276 if (object->HasFastProperties() && !object->IsJSGlobalProxy()) { | 301 if (object->HasFastProperties() && !object->IsJSGlobalProxy()) { |
277 JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, properties, | 302 JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, properties, |
278 "OptimizeForAdding"); | 303 "OptimizeForAdding"); |
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1289 DCHECK(args.length() == 2); | 1314 DCHECK(args.length() == 2); |
1290 CONVERT_ARG_HANDLE_CHECKED(Object, o, 0); | 1315 CONVERT_ARG_HANDLE_CHECKED(Object, o, 0); |
1291 CONVERT_ARG_HANDLE_CHECKED(Object, properties, 1); | 1316 CONVERT_ARG_HANDLE_CHECKED(Object, properties, 1); |
1292 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 1317 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
1293 isolate, o, JSReceiver::DefineProperties(isolate, o, properties)); | 1318 isolate, o, JSReceiver::DefineProperties(isolate, o, properties)); |
1294 return *o; | 1319 return *o; |
1295 } | 1320 } |
1296 | 1321 |
1297 } // namespace internal | 1322 } // namespace internal |
1298 } // namespace v8 | 1323 } // namespace v8 |
OLD | NEW |