| 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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 CONVERT_ARG_HANDLE_CHECKED(Object, receiver_obj, 0); | 386 CONVERT_ARG_HANDLE_CHECKED(Object, receiver_obj, 0); |
| 387 CONVERT_ARG_HANDLE_CHECKED(Object, key_obj, 1); | 387 CONVERT_ARG_HANDLE_CHECKED(Object, key_obj, 1); |
| 388 | 388 |
| 389 RETURN_RESULT_OR_FAILURE( | 389 RETURN_RESULT_OR_FAILURE( |
| 390 isolate, KeyedGetObjectProperty(isolate, receiver_obj, key_obj)); | 390 isolate, KeyedGetObjectProperty(isolate, receiver_obj, key_obj)); |
| 391 } | 391 } |
| 392 | 392 |
| 393 | 393 |
| 394 RUNTIME_FUNCTION(Runtime_AddNamedProperty) { | 394 RUNTIME_FUNCTION(Runtime_AddNamedProperty) { |
| 395 HandleScope scope(isolate); | 395 HandleScope scope(isolate); |
| 396 RUNTIME_ASSERT(args.length() == 4); | 396 DCHECK_EQ(4, args.length()); |
| 397 | 397 |
| 398 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 398 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
| 399 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 399 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
| 400 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | 400 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
| 401 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); | 401 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); |
| 402 | 402 |
| 403 #ifdef DEBUG | 403 #ifdef DEBUG |
| 404 uint32_t index = 0; | 404 uint32_t index = 0; |
| 405 DCHECK(!name->ToArrayIndex(&index)); | 405 DCHECK(!name->ToArrayIndex(&index)); |
| 406 LookupIterator it(object, name, object, LookupIterator::OWN_SKIP_INTERCEPTOR); | 406 LookupIterator it(object, name, object, LookupIterator::OWN_SKIP_INTERCEPTOR); |
| 407 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); | 407 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); |
| 408 if (!maybe.IsJust()) return isolate->heap()->exception(); | 408 if (!maybe.IsJust()) return isolate->heap()->exception(); |
| 409 RUNTIME_ASSERT(!it.IsFound()); | 409 CHECK(!it.IsFound()); |
| 410 #endif | 410 #endif |
| 411 | 411 |
| 412 RETURN_RESULT_OR_FAILURE(isolate, JSObject::SetOwnPropertyIgnoreAttributes( | 412 RETURN_RESULT_OR_FAILURE(isolate, JSObject::SetOwnPropertyIgnoreAttributes( |
| 413 object, name, value, attrs)); | 413 object, name, value, attrs)); |
| 414 } | 414 } |
| 415 | 415 |
| 416 | 416 |
| 417 // Adds an element to an array. | 417 // Adds an element to an array. |
| 418 // This is used to create an indexed data property into an array. | 418 // This is used to create an indexed data property into an array. |
| 419 RUNTIME_FUNCTION(Runtime_AddElement) { | 419 RUNTIME_FUNCTION(Runtime_AddElement) { |
| 420 HandleScope scope(isolate); | 420 HandleScope scope(isolate); |
| 421 RUNTIME_ASSERT(args.length() == 3); | 421 DCHECK_EQ(3, args.length()); |
| 422 | 422 |
| 423 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 423 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
| 424 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 424 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
| 425 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | 425 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
| 426 | 426 |
| 427 uint32_t index = 0; | 427 uint32_t index = 0; |
| 428 CHECK(key->ToArrayIndex(&index)); | 428 CHECK(key->ToArrayIndex(&index)); |
| 429 | 429 |
| 430 #ifdef DEBUG | 430 #ifdef DEBUG |
| 431 LookupIterator it(isolate, object, index, object, | 431 LookupIterator it(isolate, object, index, object, |
| 432 LookupIterator::OWN_SKIP_INTERCEPTOR); | 432 LookupIterator::OWN_SKIP_INTERCEPTOR); |
| 433 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); | 433 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); |
| 434 if (!maybe.IsJust()) return isolate->heap()->exception(); | 434 if (!maybe.IsJust()) return isolate->heap()->exception(); |
| 435 RUNTIME_ASSERT(!it.IsFound()); | 435 CHECK(!it.IsFound()); |
| 436 | 436 |
| 437 if (object->IsJSArray()) { | 437 if (object->IsJSArray()) { |
| 438 Handle<JSArray> array = Handle<JSArray>::cast(object); | 438 Handle<JSArray> array = Handle<JSArray>::cast(object); |
| 439 RUNTIME_ASSERT(!JSArray::WouldChangeReadOnlyLength(array, index)); | 439 CHECK(!JSArray::WouldChangeReadOnlyLength(array, index)); |
| 440 } | 440 } |
| 441 #endif | 441 #endif |
| 442 | 442 |
| 443 RETURN_RESULT_OR_FAILURE(isolate, JSObject::SetOwnElementIgnoreAttributes( | 443 RETURN_RESULT_OR_FAILURE(isolate, JSObject::SetOwnElementIgnoreAttributes( |
| 444 object, index, value, NONE)); | 444 object, index, value, NONE)); |
| 445 } | 445 } |
| 446 | 446 |
| 447 | 447 |
| 448 RUNTIME_FUNCTION(Runtime_AppendElement) { | 448 RUNTIME_FUNCTION(Runtime_AppendElement) { |
| 449 HandleScope scope(isolate); | 449 HandleScope scope(isolate); |
| 450 RUNTIME_ASSERT(args.length() == 2); | 450 DCHECK_EQ(2, args.length()); |
| 451 | 451 |
| 452 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); | 452 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); |
| 453 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); | 453 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); |
| 454 | 454 |
| 455 uint32_t index; | 455 uint32_t index; |
| 456 CHECK(array->length()->ToArrayIndex(&index)); | 456 CHECK(array->length()->ToArrayIndex(&index)); |
| 457 | 457 |
| 458 RETURN_FAILURE_ON_EXCEPTION( | 458 RETURN_FAILURE_ON_EXCEPTION( |
| 459 isolate, JSObject::AddDataElement(array, index, value, NONE)); | 459 isolate, JSObject::AddDataElement(array, index, value, NONE)); |
| 460 JSObject::ValidateElements(array); | 460 JSObject::ValidateElements(array); |
| 461 return *array; | 461 return *array; |
| 462 } | 462 } |
| 463 | 463 |
| 464 | 464 |
| 465 RUNTIME_FUNCTION(Runtime_SetProperty) { | 465 RUNTIME_FUNCTION(Runtime_SetProperty) { |
| 466 HandleScope scope(isolate); | 466 HandleScope scope(isolate); |
| 467 RUNTIME_ASSERT(args.length() == 4); | 467 DCHECK_EQ(4, args.length()); |
| 468 | 468 |
| 469 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 469 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
| 470 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 470 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
| 471 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | 471 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
| 472 CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode_arg, 3); | 472 CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode_arg, 3); |
| 473 LanguageMode language_mode = language_mode_arg; | 473 LanguageMode language_mode = language_mode_arg; |
| 474 | 474 |
| 475 RETURN_RESULT_OR_FAILURE( | 475 RETURN_RESULT_OR_FAILURE( |
| 476 isolate, | 476 isolate, |
| 477 Runtime::SetObjectProperty(isolate, object, key, value, language_mode)); | 477 Runtime::SetObjectProperty(isolate, object, key, value, language_mode)); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 | 627 |
| 628 return isolate->heap()->undefined_value(); | 628 return isolate->heap()->undefined_value(); |
| 629 } | 629 } |
| 630 | 630 |
| 631 | 631 |
| 632 RUNTIME_FUNCTION(Runtime_LoadMutableDouble) { | 632 RUNTIME_FUNCTION(Runtime_LoadMutableDouble) { |
| 633 HandleScope scope(isolate); | 633 HandleScope scope(isolate); |
| 634 DCHECK(args.length() == 2); | 634 DCHECK(args.length() == 2); |
| 635 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 635 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
| 636 CONVERT_ARG_HANDLE_CHECKED(Smi, index, 1); | 636 CONVERT_ARG_HANDLE_CHECKED(Smi, index, 1); |
| 637 RUNTIME_ASSERT((index->value() & 1) == 1); | 637 CHECK((index->value() & 1) == 1); |
| 638 FieldIndex field_index = | 638 FieldIndex field_index = |
| 639 FieldIndex::ForLoadByFieldIndex(object->map(), index->value()); | 639 FieldIndex::ForLoadByFieldIndex(object->map(), index->value()); |
| 640 if (field_index.is_inobject()) { | 640 if (field_index.is_inobject()) { |
| 641 RUNTIME_ASSERT(field_index.property_index() < | 641 CHECK(field_index.property_index() < |
| 642 object->map()->GetInObjectProperties()); | 642 object->map()->GetInObjectProperties()); |
| 643 } else { | 643 } else { |
| 644 RUNTIME_ASSERT(field_index.outobject_array_index() < | 644 CHECK(field_index.outobject_array_index() < object->properties()->length()); |
| 645 object->properties()->length()); | |
| 646 } | 645 } |
| 647 return *JSObject::FastPropertyAt(object, Representation::Double(), | 646 return *JSObject::FastPropertyAt(object, Representation::Double(), |
| 648 field_index); | 647 field_index); |
| 649 } | 648 } |
| 650 | 649 |
| 651 | 650 |
| 652 RUNTIME_FUNCTION(Runtime_TryMigrateInstance) { | 651 RUNTIME_FUNCTION(Runtime_TryMigrateInstance) { |
| 653 HandleScope scope(isolate); | 652 HandleScope scope(isolate); |
| 654 DCHECK(args.length() == 1); | 653 DCHECK(args.length() == 1); |
| 655 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 654 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 680 // Implements part of 8.12.9 DefineOwnProperty. | 679 // Implements part of 8.12.9 DefineOwnProperty. |
| 681 // There are 3 cases that lead here: | 680 // There are 3 cases that lead here: |
| 682 // Step 4b - define a new accessor property. | 681 // Step 4b - define a new accessor property. |
| 683 // Steps 9c & 12 - replace an existing data property with an accessor property. | 682 // Steps 9c & 12 - replace an existing data property with an accessor property. |
| 684 // Step 12 - update an existing accessor property with an accessor or generic | 683 // Step 12 - update an existing accessor property with an accessor or generic |
| 685 // descriptor. | 684 // descriptor. |
| 686 RUNTIME_FUNCTION(Runtime_DefineAccessorPropertyUnchecked) { | 685 RUNTIME_FUNCTION(Runtime_DefineAccessorPropertyUnchecked) { |
| 687 HandleScope scope(isolate); | 686 HandleScope scope(isolate); |
| 688 DCHECK(args.length() == 5); | 687 DCHECK(args.length() == 5); |
| 689 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 688 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
| 690 RUNTIME_ASSERT(!obj->IsNull()); | 689 CHECK(!obj->IsNull()); |
| 691 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 690 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
| 692 CONVERT_ARG_HANDLE_CHECKED(Object, getter, 2); | 691 CONVERT_ARG_HANDLE_CHECKED(Object, getter, 2); |
| 693 RUNTIME_ASSERT(IsValidAccessor(isolate, getter)); | 692 CHECK(IsValidAccessor(isolate, getter)); |
| 694 CONVERT_ARG_HANDLE_CHECKED(Object, setter, 3); | 693 CONVERT_ARG_HANDLE_CHECKED(Object, setter, 3); |
| 695 RUNTIME_ASSERT(IsValidAccessor(isolate, setter)); | 694 CHECK(IsValidAccessor(isolate, setter)); |
| 696 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 4); | 695 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 4); |
| 697 | 696 |
| 698 RETURN_FAILURE_ON_EXCEPTION( | 697 RETURN_FAILURE_ON_EXCEPTION( |
| 699 isolate, JSObject::DefineAccessor(obj, name, getter, setter, attrs)); | 698 isolate, JSObject::DefineAccessor(obj, name, getter, setter, attrs)); |
| 700 return isolate->heap()->undefined_value(); | 699 return isolate->heap()->undefined_value(); |
| 701 } | 700 } |
| 702 | 701 |
| 703 | 702 |
| 704 RUNTIME_FUNCTION(Runtime_DefineDataPropertyInLiteral) { | 703 RUNTIME_FUNCTION(Runtime_DefineDataPropertyInLiteral) { |
| 705 HandleScope scope(isolate); | 704 HandleScope scope(isolate); |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 isolate, o, key, &success, LookupIterator::OWN); | 974 isolate, o, key, &success, LookupIterator::OWN); |
| 976 if (!success) return isolate->heap()->exception(); | 975 if (!success) return isolate->heap()->exception(); |
| 977 MAYBE_RETURN( | 976 MAYBE_RETURN( |
| 978 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR), | 977 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR), |
| 979 isolate->heap()->exception()); | 978 isolate->heap()->exception()); |
| 980 return *value; | 979 return *value; |
| 981 } | 980 } |
| 982 | 981 |
| 983 } // namespace internal | 982 } // namespace internal |
| 984 } // namespace v8 | 983 } // namespace v8 |
| OLD | NEW |