| 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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 PropertyDescriptor desc; | 284 PropertyDescriptor desc; |
| 285 Maybe<bool> found = JSReceiver::GetOwnPropertyDescriptor( | 285 Maybe<bool> found = JSReceiver::GetOwnPropertyDescriptor( |
| 286 isolate, Handle<JSReceiver>::cast(object), key, &desc); | 286 isolate, Handle<JSReceiver>::cast(object), key, &desc); |
| 287 MAYBE_RETURN(found, isolate->heap()->exception()); | 287 MAYBE_RETURN(found, isolate->heap()->exception()); |
| 288 // 4. Return FromPropertyDescriptor(desc). | 288 // 4. Return FromPropertyDescriptor(desc). |
| 289 if (!found.FromJust()) return isolate->heap()->undefined_value(); | 289 if (!found.FromJust()) return isolate->heap()->undefined_value(); |
| 290 return *desc.ToObject(isolate); | 290 return *desc.ToObject(isolate); |
| 291 } | 291 } |
| 292 | 292 |
| 293 | 293 |
| 294 RUNTIME_FUNCTION(Runtime_PreventExtensions) { | |
| 295 HandleScope scope(isolate); | |
| 296 DCHECK(args.length() == 1); | |
| 297 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, obj, 0); | |
| 298 MAYBE_RETURN(JSReceiver::PreventExtensions(obj, Object::THROW_ON_ERROR), | |
| 299 isolate->heap()->exception()); | |
| 300 return *obj; | |
| 301 } | |
| 302 | |
| 303 | |
| 304 RUNTIME_FUNCTION(Runtime_IsExtensible) { | |
| 305 HandleScope scope(isolate); | |
| 306 DCHECK(args.length() == 1); | |
| 307 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, obj, 0); | |
| 308 Maybe<bool> result = JSReceiver::IsExtensible(obj); | |
| 309 MAYBE_RETURN(result, isolate->heap()->exception()); | |
| 310 return isolate->heap()->ToBoolean(result.FromJust()); | |
| 311 } | |
| 312 | |
| 313 | |
| 314 RUNTIME_FUNCTION(Runtime_OptimizeObjectForAddingMultipleProperties) { | 294 RUNTIME_FUNCTION(Runtime_OptimizeObjectForAddingMultipleProperties) { |
| 315 HandleScope scope(isolate); | 295 HandleScope scope(isolate); |
| 316 DCHECK(args.length() == 2); | 296 DCHECK(args.length() == 2); |
| 317 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 297 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
| 318 CONVERT_SMI_ARG_CHECKED(properties, 1); | 298 CONVERT_SMI_ARG_CHECKED(properties, 1); |
| 319 // Conservative upper limit to prevent fuzz tests from going OOM. | 299 // Conservative upper limit to prevent fuzz tests from going OOM. |
| 320 RUNTIME_ASSERT(properties <= 100000); | 300 RUNTIME_ASSERT(properties <= 100000); |
| 321 if (object->HasFastProperties() && !object->IsJSGlobalProxy()) { | 301 if (object->HasFastProperties() && !object->IsJSGlobalProxy()) { |
| 322 JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, properties, | 302 JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, properties, |
| 323 "OptimizeForAdding"); | 303 "OptimizeForAdding"); |
| 324 } | 304 } |
| 325 return *object; | 305 return *object; |
| 326 } | 306 } |
| 327 | 307 |
| 328 | 308 |
| 329 RUNTIME_FUNCTION(Runtime_ObjectFreeze) { | |
| 330 HandleScope scope(isolate); | |
| 331 DCHECK(args.length() == 1); | |
| 332 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); | |
| 333 | |
| 334 MAYBE_RETURN( | |
| 335 JSReceiver::SetIntegrityLevel(object, FROZEN, Object::THROW_ON_ERROR), | |
| 336 isolate->heap()->exception()); | |
| 337 return *object; | |
| 338 } | |
| 339 | |
| 340 | |
| 341 RUNTIME_FUNCTION(Runtime_ObjectIsFrozen) { | |
| 342 HandleScope scope(isolate); | |
| 343 DCHECK(args.length() == 1); | |
| 344 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); | |
| 345 | |
| 346 Maybe<bool> result = JSReceiver::TestIntegrityLevel(object, FROZEN); | |
| 347 MAYBE_RETURN(result, isolate->heap()->exception()); | |
| 348 return isolate->heap()->ToBoolean(result.FromJust()); | |
| 349 } | |
| 350 | |
| 351 | |
| 352 RUNTIME_FUNCTION(Runtime_ObjectSeal) { | |
| 353 HandleScope scope(isolate); | |
| 354 DCHECK(args.length() == 1); | |
| 355 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); | |
| 356 | |
| 357 MAYBE_RETURN( | |
| 358 JSReceiver::SetIntegrityLevel(object, SEALED, Object::THROW_ON_ERROR), | |
| 359 isolate->heap()->exception()); | |
| 360 return *object; | |
| 361 } | |
| 362 | |
| 363 | |
| 364 RUNTIME_FUNCTION(Runtime_ObjectIsSealed) { | |
| 365 HandleScope scope(isolate); | |
| 366 DCHECK(args.length() == 1); | |
| 367 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); | |
| 368 | |
| 369 Maybe<bool> result = JSReceiver::TestIntegrityLevel(object, SEALED); | |
| 370 MAYBE_RETURN(result, isolate->heap()->exception()); | |
| 371 return isolate->heap()->ToBoolean(result.FromJust()); | |
| 372 } | |
| 373 | |
| 374 | |
| 375 RUNTIME_FUNCTION(Runtime_LoadGlobalViaContext) { | 309 RUNTIME_FUNCTION(Runtime_LoadGlobalViaContext) { |
| 376 HandleScope scope(isolate); | 310 HandleScope scope(isolate); |
| 377 DCHECK_EQ(1, args.length()); | 311 DCHECK_EQ(1, args.length()); |
| 378 CONVERT_SMI_ARG_CHECKED(slot, 0); | 312 CONVERT_SMI_ARG_CHECKED(slot, 0); |
| 379 | 313 |
| 380 // Go up context chain to the script context. | 314 // Go up context chain to the script context. |
| 381 Handle<Context> script_context(isolate->context()->script_context(), isolate); | 315 Handle<Context> script_context(isolate->context()->script_context(), isolate); |
| 382 DCHECK(script_context->IsScriptContext()); | 316 DCHECK(script_context->IsScriptContext()); |
| 383 DCHECK(script_context->get(slot)->IsPropertyCell()); | 317 DCHECK(script_context->get(slot)->IsPropertyCell()); |
| 384 | 318 |
| (...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1415 DCHECK(args.length() == 2); | 1349 DCHECK(args.length() == 2); |
| 1416 CONVERT_ARG_HANDLE_CHECKED(Object, o, 0); | 1350 CONVERT_ARG_HANDLE_CHECKED(Object, o, 0); |
| 1417 CONVERT_ARG_HANDLE_CHECKED(Object, properties, 1); | 1351 CONVERT_ARG_HANDLE_CHECKED(Object, properties, 1); |
| 1418 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 1352 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 1419 isolate, o, JSReceiver::DefineProperties(isolate, o, properties)); | 1353 isolate, o, JSReceiver::DefineProperties(isolate, o, properties)); |
| 1420 return *o; | 1354 return *o; |
| 1421 } | 1355 } |
| 1422 | 1356 |
| 1423 } // namespace internal | 1357 } // namespace internal |
| 1424 } // namespace v8 | 1358 } // namespace v8 |
| OLD | NEW |