| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 case CompileTimeValue::ARRAY_LITERAL: | 475 case CompileTimeValue::ARRAY_LITERAL: |
| 476 return Runtime::CreateArrayLiteralBoilerplate( | 476 return Runtime::CreateArrayLiteralBoilerplate( |
| 477 isolate, literals, elements); | 477 isolate, literals, elements); |
| 478 default: | 478 default: |
| 479 UNREACHABLE(); | 479 UNREACHABLE(); |
| 480 return MaybeHandle<Object>(); | 480 return MaybeHandle<Object>(); |
| 481 } | 481 } |
| 482 } | 482 } |
| 483 | 483 |
| 484 | 484 |
| 485 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_CreateObjectLiteral) { | 485 RUNTIME_FUNCTION(RuntimeHidden_CreateObjectLiteral) { |
| 486 HandleScope scope(isolate); | 486 HandleScope scope(isolate); |
| 487 ASSERT(args.length() == 4); | 487 ASSERT(args.length() == 4); |
| 488 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); | 488 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); |
| 489 CONVERT_SMI_ARG_CHECKED(literals_index, 1); | 489 CONVERT_SMI_ARG_CHECKED(literals_index, 1); |
| 490 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2); | 490 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2); |
| 491 CONVERT_SMI_ARG_CHECKED(flags, 3); | 491 CONVERT_SMI_ARG_CHECKED(flags, 3); |
| 492 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; | 492 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; |
| 493 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0; | 493 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0; |
| 494 | 494 |
| 495 RUNTIME_ASSERT(literals_index >= 0 && literals_index < literals->length()); | 495 RUNTIME_ASSERT(literals_index >= 0 && literals_index < literals->length()); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 JSObject::DeepCopyHints hints = (flags & ArrayLiteral::kShallowElements) == 0 | 589 JSObject::DeepCopyHints hints = (flags & ArrayLiteral::kShallowElements) == 0 |
| 590 ? JSObject::kNoHints | 590 ? JSObject::kNoHints |
| 591 : JSObject::kObjectIsShallowArray; | 591 : JSObject::kObjectIsShallowArray; |
| 592 MaybeHandle<JSObject> copy = JSObject::DeepCopy(boilerplate, &usage_context, | 592 MaybeHandle<JSObject> copy = JSObject::DeepCopy(boilerplate, &usage_context, |
| 593 hints); | 593 hints); |
| 594 usage_context.ExitScope(site, boilerplate); | 594 usage_context.ExitScope(site, boilerplate); |
| 595 return copy; | 595 return copy; |
| 596 } | 596 } |
| 597 | 597 |
| 598 | 598 |
| 599 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_CreateArrayLiteral) { | 599 RUNTIME_FUNCTION(RuntimeHidden_CreateArrayLiteral) { |
| 600 HandleScope scope(isolate); | 600 HandleScope scope(isolate); |
| 601 ASSERT(args.length() == 4); | 601 ASSERT(args.length() == 4); |
| 602 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); | 602 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); |
| 603 CONVERT_SMI_ARG_CHECKED(literals_index, 1); | 603 CONVERT_SMI_ARG_CHECKED(literals_index, 1); |
| 604 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); | 604 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); |
| 605 CONVERT_SMI_ARG_CHECKED(flags, 3); | 605 CONVERT_SMI_ARG_CHECKED(flags, 3); |
| 606 | 606 |
| 607 Handle<JSObject> result; | 607 Handle<JSObject> result; |
| 608 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | 608 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, |
| 609 CreateArrayLiteralImpl(isolate, literals, literals_index, elements, | 609 CreateArrayLiteralImpl(isolate, literals, literals_index, elements, |
| 610 flags)); | 610 flags)); |
| 611 return *result; | 611 return *result; |
| 612 } | 612 } |
| 613 | 613 |
| 614 | 614 |
| 615 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_CreateArrayLiteralStubBailout) { | 615 RUNTIME_FUNCTION(RuntimeHidden_CreateArrayLiteralStubBailout) { |
| 616 HandleScope scope(isolate); | 616 HandleScope scope(isolate); |
| 617 ASSERT(args.length() == 3); | 617 ASSERT(args.length() == 3); |
| 618 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); | 618 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); |
| 619 CONVERT_SMI_ARG_CHECKED(literals_index, 1); | 619 CONVERT_SMI_ARG_CHECKED(literals_index, 1); |
| 620 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); | 620 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); |
| 621 | 621 |
| 622 Handle<JSObject> result; | 622 Handle<JSObject> result; |
| 623 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | 623 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, |
| 624 CreateArrayLiteralImpl(isolate, literals, literals_index, elements, | 624 CreateArrayLiteralImpl(isolate, literals, literals_index, elements, |
| 625 ArrayLiteral::kShallowElements)); | 625 ArrayLiteral::kShallowElements)); |
| 626 return *result; | 626 return *result; |
| 627 } | 627 } |
| 628 | 628 |
| 629 | 629 |
| 630 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateSymbol) { | 630 RUNTIME_FUNCTION(Runtime_CreateSymbol) { |
| 631 HandleScope scope(isolate); | 631 HandleScope scope(isolate); |
| 632 ASSERT(args.length() == 1); | 632 ASSERT(args.length() == 1); |
| 633 CONVERT_ARG_HANDLE_CHECKED(Object, name, 0); | 633 CONVERT_ARG_HANDLE_CHECKED(Object, name, 0); |
| 634 RUNTIME_ASSERT(name->IsString() || name->IsUndefined()); | 634 RUNTIME_ASSERT(name->IsString() || name->IsUndefined()); |
| 635 Handle<Symbol> symbol = isolate->factory()->NewSymbol(); | 635 Handle<Symbol> symbol = isolate->factory()->NewSymbol(); |
| 636 if (name->IsString()) symbol->set_name(*name); | 636 if (name->IsString()) symbol->set_name(*name); |
| 637 return *symbol; | 637 return *symbol; |
| 638 } | 638 } |
| 639 | 639 |
| 640 | 640 |
| 641 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreatePrivateSymbol) { | 641 RUNTIME_FUNCTION(Runtime_CreatePrivateSymbol) { |
| 642 HandleScope scope(isolate); | 642 HandleScope scope(isolate); |
| 643 ASSERT(args.length() == 1); | 643 ASSERT(args.length() == 1); |
| 644 CONVERT_ARG_HANDLE_CHECKED(Object, name, 0); | 644 CONVERT_ARG_HANDLE_CHECKED(Object, name, 0); |
| 645 RUNTIME_ASSERT(name->IsString() || name->IsUndefined()); | 645 RUNTIME_ASSERT(name->IsString() || name->IsUndefined()); |
| 646 Handle<Symbol> symbol = isolate->factory()->NewPrivateSymbol(); | 646 Handle<Symbol> symbol = isolate->factory()->NewPrivateSymbol(); |
| 647 if (name->IsString()) symbol->set_name(*name); | 647 if (name->IsString()) symbol->set_name(*name); |
| 648 return *symbol; | 648 return *symbol; |
| 649 } | 649 } |
| 650 | 650 |
| 651 | 651 |
| 652 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateGlobalPrivateSymbol) { | 652 RUNTIME_FUNCTION(Runtime_CreateGlobalPrivateSymbol) { |
| 653 HandleScope scope(isolate); | 653 HandleScope scope(isolate); |
| 654 ASSERT(args.length() == 1); | 654 ASSERT(args.length() == 1); |
| 655 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); | 655 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); |
| 656 Handle<JSObject> registry = isolate->GetSymbolRegistry(); | 656 Handle<JSObject> registry = isolate->GetSymbolRegistry(); |
| 657 Handle<String> part = isolate->factory()->private_intern_string(); | 657 Handle<String> part = isolate->factory()->private_intern_string(); |
| 658 Handle<Object> privates; | 658 Handle<Object> privates; |
| 659 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 659 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 660 isolate, privates, Object::GetPropertyOrElement(registry, part)); | 660 isolate, privates, Object::GetPropertyOrElement(registry, part)); |
| 661 Handle<Object> symbol; | 661 Handle<Object> symbol; |
| 662 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 662 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 663 isolate, symbol, Object::GetPropertyOrElement(privates, name)); | 663 isolate, symbol, Object::GetPropertyOrElement(privates, name)); |
| 664 if (!symbol->IsSymbol()) { | 664 if (!symbol->IsSymbol()) { |
| 665 ASSERT(symbol->IsUndefined()); | 665 ASSERT(symbol->IsUndefined()); |
| 666 symbol = isolate->factory()->NewPrivateSymbol(); | 666 symbol = isolate->factory()->NewPrivateSymbol(); |
| 667 Handle<Symbol>::cast(symbol)->set_name(*name); | 667 Handle<Symbol>::cast(symbol)->set_name(*name); |
| 668 JSObject::SetProperty(Handle<JSObject>::cast(privates), | 668 JSObject::SetProperty(Handle<JSObject>::cast(privates), |
| 669 name, symbol, NONE, STRICT).Assert(); | 669 name, symbol, NONE, STRICT).Assert(); |
| 670 } | 670 } |
| 671 return *symbol; | 671 return *symbol; |
| 672 } | 672 } |
| 673 | 673 |
| 674 | 674 |
| 675 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewSymbolWrapper) { | 675 RUNTIME_FUNCTION(Runtime_NewSymbolWrapper) { |
| 676 HandleScope scope(isolate); | 676 HandleScope scope(isolate); |
| 677 ASSERT(args.length() == 1); | 677 ASSERT(args.length() == 1); |
| 678 CONVERT_ARG_HANDLE_CHECKED(Symbol, symbol, 0); | 678 CONVERT_ARG_HANDLE_CHECKED(Symbol, symbol, 0); |
| 679 return *Object::ToObject(isolate, symbol).ToHandleChecked(); | 679 return *Object::ToObject(isolate, symbol).ToHandleChecked(); |
| 680 } | 680 } |
| 681 | 681 |
| 682 | 682 |
| 683 RUNTIME_FUNCTION(MaybeObject*, Runtime_SymbolDescription) { | 683 RUNTIME_FUNCTION(Runtime_SymbolDescription) { |
| 684 SealHandleScope shs(isolate); | 684 SealHandleScope shs(isolate); |
| 685 ASSERT(args.length() == 1); | 685 ASSERT(args.length() == 1); |
| 686 CONVERT_ARG_CHECKED(Symbol, symbol, 0); | 686 CONVERT_ARG_CHECKED(Symbol, symbol, 0); |
| 687 return symbol->name(); | 687 return symbol->name(); |
| 688 } | 688 } |
| 689 | 689 |
| 690 | 690 |
| 691 RUNTIME_FUNCTION(MaybeObject*, Runtime_SymbolRegistry) { | 691 RUNTIME_FUNCTION(Runtime_SymbolRegistry) { |
| 692 HandleScope scope(isolate); | 692 HandleScope scope(isolate); |
| 693 ASSERT(args.length() == 0); | 693 ASSERT(args.length() == 0); |
| 694 return *isolate->GetSymbolRegistry(); | 694 return *isolate->GetSymbolRegistry(); |
| 695 } | 695 } |
| 696 | 696 |
| 697 | 697 |
| 698 RUNTIME_FUNCTION(MaybeObject*, Runtime_SymbolIsPrivate) { | 698 RUNTIME_FUNCTION(Runtime_SymbolIsPrivate) { |
| 699 SealHandleScope shs(isolate); | 699 SealHandleScope shs(isolate); |
| 700 ASSERT(args.length() == 1); | 700 ASSERT(args.length() == 1); |
| 701 CONVERT_ARG_CHECKED(Symbol, symbol, 0); | 701 CONVERT_ARG_CHECKED(Symbol, symbol, 0); |
| 702 return isolate->heap()->ToBoolean(symbol->is_private()); | 702 return isolate->heap()->ToBoolean(symbol->is_private()); |
| 703 } | 703 } |
| 704 | 704 |
| 705 | 705 |
| 706 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSProxy) { | 706 RUNTIME_FUNCTION(Runtime_CreateJSProxy) { |
| 707 HandleScope scope(isolate); | 707 HandleScope scope(isolate); |
| 708 ASSERT(args.length() == 2); | 708 ASSERT(args.length() == 2); |
| 709 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, handler, 0); | 709 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, handler, 0); |
| 710 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1); | 710 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1); |
| 711 if (!prototype->IsJSReceiver()) prototype = isolate->factory()->null_value(); | 711 if (!prototype->IsJSReceiver()) prototype = isolate->factory()->null_value(); |
| 712 return *isolate->factory()->NewJSProxy(handler, prototype); | 712 return *isolate->factory()->NewJSProxy(handler, prototype); |
| 713 } | 713 } |
| 714 | 714 |
| 715 | 715 |
| 716 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSFunctionProxy) { | 716 RUNTIME_FUNCTION(Runtime_CreateJSFunctionProxy) { |
| 717 HandleScope scope(isolate); | 717 HandleScope scope(isolate); |
| 718 ASSERT(args.length() == 4); | 718 ASSERT(args.length() == 4); |
| 719 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, handler, 0); | 719 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, handler, 0); |
| 720 CONVERT_ARG_HANDLE_CHECKED(Object, call_trap, 1); | 720 CONVERT_ARG_HANDLE_CHECKED(Object, call_trap, 1); |
| 721 RUNTIME_ASSERT(call_trap->IsJSFunction() || call_trap->IsJSFunctionProxy()); | 721 RUNTIME_ASSERT(call_trap->IsJSFunction() || call_trap->IsJSFunctionProxy()); |
| 722 CONVERT_ARG_HANDLE_CHECKED(JSFunction, construct_trap, 2); | 722 CONVERT_ARG_HANDLE_CHECKED(JSFunction, construct_trap, 2); |
| 723 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 3); | 723 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 3); |
| 724 if (!prototype->IsJSReceiver()) prototype = isolate->factory()->null_value(); | 724 if (!prototype->IsJSReceiver()) prototype = isolate->factory()->null_value(); |
| 725 return *isolate->factory()->NewJSFunctionProxy( | 725 return *isolate->factory()->NewJSFunctionProxy( |
| 726 handler, call_trap, construct_trap, prototype); | 726 handler, call_trap, construct_trap, prototype); |
| 727 } | 727 } |
| 728 | 728 |
| 729 | 729 |
| 730 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsJSProxy) { | 730 RUNTIME_FUNCTION(Runtime_IsJSProxy) { |
| 731 SealHandleScope shs(isolate); | 731 SealHandleScope shs(isolate); |
| 732 ASSERT(args.length() == 1); | 732 ASSERT(args.length() == 1); |
| 733 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); | 733 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); |
| 734 return isolate->heap()->ToBoolean(obj->IsJSProxy()); | 734 return isolate->heap()->ToBoolean(obj->IsJSProxy()); |
| 735 } | 735 } |
| 736 | 736 |
| 737 | 737 |
| 738 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsJSFunctionProxy) { | 738 RUNTIME_FUNCTION(Runtime_IsJSFunctionProxy) { |
| 739 SealHandleScope shs(isolate); | 739 SealHandleScope shs(isolate); |
| 740 ASSERT(args.length() == 1); | 740 ASSERT(args.length() == 1); |
| 741 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); | 741 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); |
| 742 return isolate->heap()->ToBoolean(obj->IsJSFunctionProxy()); | 742 return isolate->heap()->ToBoolean(obj->IsJSFunctionProxy()); |
| 743 } | 743 } |
| 744 | 744 |
| 745 | 745 |
| 746 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetHandler) { | 746 RUNTIME_FUNCTION(Runtime_GetHandler) { |
| 747 SealHandleScope shs(isolate); | 747 SealHandleScope shs(isolate); |
| 748 ASSERT(args.length() == 1); | 748 ASSERT(args.length() == 1); |
| 749 CONVERT_ARG_CHECKED(JSProxy, proxy, 0); | 749 CONVERT_ARG_CHECKED(JSProxy, proxy, 0); |
| 750 return proxy->handler(); | 750 return proxy->handler(); |
| 751 } | 751 } |
| 752 | 752 |
| 753 | 753 |
| 754 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetCallTrap) { | 754 RUNTIME_FUNCTION(Runtime_GetCallTrap) { |
| 755 SealHandleScope shs(isolate); | 755 SealHandleScope shs(isolate); |
| 756 ASSERT(args.length() == 1); | 756 ASSERT(args.length() == 1); |
| 757 CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0); | 757 CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0); |
| 758 return proxy->call_trap(); | 758 return proxy->call_trap(); |
| 759 } | 759 } |
| 760 | 760 |
| 761 | 761 |
| 762 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetConstructTrap) { | 762 RUNTIME_FUNCTION(Runtime_GetConstructTrap) { |
| 763 SealHandleScope shs(isolate); | 763 SealHandleScope shs(isolate); |
| 764 ASSERT(args.length() == 1); | 764 ASSERT(args.length() == 1); |
| 765 CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0); | 765 CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0); |
| 766 return proxy->construct_trap(); | 766 return proxy->construct_trap(); |
| 767 } | 767 } |
| 768 | 768 |
| 769 | 769 |
| 770 RUNTIME_FUNCTION(MaybeObject*, Runtime_Fix) { | 770 RUNTIME_FUNCTION(Runtime_Fix) { |
| 771 HandleScope scope(isolate); | 771 HandleScope scope(isolate); |
| 772 ASSERT(args.length() == 1); | 772 ASSERT(args.length() == 1); |
| 773 CONVERT_ARG_HANDLE_CHECKED(JSProxy, proxy, 0); | 773 CONVERT_ARG_HANDLE_CHECKED(JSProxy, proxy, 0); |
| 774 JSProxy::Fix(proxy); | 774 JSProxy::Fix(proxy); |
| 775 return isolate->heap()->undefined_value(); | 775 return isolate->heap()->undefined_value(); |
| 776 } | 776 } |
| 777 | 777 |
| 778 | 778 |
| 779 void Runtime::FreeArrayBuffer(Isolate* isolate, | 779 void Runtime::FreeArrayBuffer(Isolate* isolate, |
| 780 JSArrayBuffer* phantom_array_buffer) { | 780 JSArrayBuffer* phantom_array_buffer) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 JSDataView::cast(*view)->Neuter(); | 859 JSDataView::cast(*view)->Neuter(); |
| 860 } else { | 860 } else { |
| 861 UNREACHABLE(); | 861 UNREACHABLE(); |
| 862 } | 862 } |
| 863 view_obj = handle(view->weak_next(), isolate); | 863 view_obj = handle(view->weak_next(), isolate); |
| 864 } | 864 } |
| 865 array_buffer->Neuter(); | 865 array_buffer->Neuter(); |
| 866 } | 866 } |
| 867 | 867 |
| 868 | 868 |
| 869 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayBufferInitialize) { | 869 RUNTIME_FUNCTION(Runtime_ArrayBufferInitialize) { |
| 870 HandleScope scope(isolate); | 870 HandleScope scope(isolate); |
| 871 ASSERT(args.length() == 2); | 871 ASSERT(args.length() == 2); |
| 872 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, holder, 0); | 872 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, holder, 0); |
| 873 CONVERT_NUMBER_ARG_HANDLE_CHECKED(byteLength, 1); | 873 CONVERT_NUMBER_ARG_HANDLE_CHECKED(byteLength, 1); |
| 874 size_t allocated_length = 0; | 874 size_t allocated_length = 0; |
| 875 if (!TryNumberToSize(isolate, *byteLength, &allocated_length)) { | 875 if (!TryNumberToSize(isolate, *byteLength, &allocated_length)) { |
| 876 return isolate->Throw( | 876 return isolate->Throw( |
| 877 *isolate->factory()->NewRangeError("invalid_array_buffer_length", | 877 *isolate->factory()->NewRangeError("invalid_array_buffer_length", |
| 878 HandleVector<Object>(NULL, 0))); | 878 HandleVector<Object>(NULL, 0))); |
| 879 } | 879 } |
| 880 if (!Runtime::SetupArrayBufferAllocatingData(isolate, | 880 if (!Runtime::SetupArrayBufferAllocatingData(isolate, |
| 881 holder, allocated_length)) { | 881 holder, allocated_length)) { |
| 882 return isolate->Throw( | 882 return isolate->Throw( |
| 883 *isolate->factory()->NewRangeError("invalid_array_buffer_length", | 883 *isolate->factory()->NewRangeError("invalid_array_buffer_length", |
| 884 HandleVector<Object>(NULL, 0))); | 884 HandleVector<Object>(NULL, 0))); |
| 885 } | 885 } |
| 886 return *holder; | 886 return *holder; |
| 887 } | 887 } |
| 888 | 888 |
| 889 | 889 |
| 890 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayBufferGetByteLength) { | 890 RUNTIME_FUNCTION(Runtime_ArrayBufferGetByteLength) { |
| 891 SealHandleScope shs(isolate); | 891 SealHandleScope shs(isolate); |
| 892 ASSERT(args.length() == 1); | 892 ASSERT(args.length() == 1); |
| 893 CONVERT_ARG_CHECKED(JSArrayBuffer, holder, 0); | 893 CONVERT_ARG_CHECKED(JSArrayBuffer, holder, 0); |
| 894 return holder->byte_length(); | 894 return holder->byte_length(); |
| 895 } | 895 } |
| 896 | 896 |
| 897 | 897 |
| 898 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayBufferSliceImpl) { | 898 RUNTIME_FUNCTION(Runtime_ArrayBufferSliceImpl) { |
| 899 HandleScope scope(isolate); | 899 HandleScope scope(isolate); |
| 900 ASSERT(args.length() == 3); | 900 ASSERT(args.length() == 3); |
| 901 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, source, 0); | 901 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, source, 0); |
| 902 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, target, 1); | 902 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, target, 1); |
| 903 CONVERT_NUMBER_ARG_HANDLE_CHECKED(first, 2); | 903 CONVERT_NUMBER_ARG_HANDLE_CHECKED(first, 2); |
| 904 size_t start = 0; | 904 size_t start = 0; |
| 905 RUNTIME_ASSERT(TryNumberToSize(isolate, *first, &start)); | 905 RUNTIME_ASSERT(TryNumberToSize(isolate, *first, &start)); |
| 906 size_t target_length = NumberToSize(isolate, target->byte_length()); | 906 size_t target_length = NumberToSize(isolate, target->byte_length()); |
| 907 | 907 |
| 908 if (target_length == 0) return isolate->heap()->undefined_value(); | 908 if (target_length == 0) return isolate->heap()->undefined_value(); |
| 909 | 909 |
| 910 size_t source_byte_length = NumberToSize(isolate, source->byte_length()); | 910 size_t source_byte_length = NumberToSize(isolate, source->byte_length()); |
| 911 RUNTIME_ASSERT(start <= source_byte_length); | 911 RUNTIME_ASSERT(start <= source_byte_length); |
| 912 RUNTIME_ASSERT(source_byte_length - start >= target_length); | 912 RUNTIME_ASSERT(source_byte_length - start >= target_length); |
| 913 uint8_t* source_data = reinterpret_cast<uint8_t*>(source->backing_store()); | 913 uint8_t* source_data = reinterpret_cast<uint8_t*>(source->backing_store()); |
| 914 uint8_t* target_data = reinterpret_cast<uint8_t*>(target->backing_store()); | 914 uint8_t* target_data = reinterpret_cast<uint8_t*>(target->backing_store()); |
| 915 CopyBytes(target_data, source_data + start, target_length); | 915 CopyBytes(target_data, source_data + start, target_length); |
| 916 return isolate->heap()->undefined_value(); | 916 return isolate->heap()->undefined_value(); |
| 917 } | 917 } |
| 918 | 918 |
| 919 | 919 |
| 920 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayBufferIsView) { | 920 RUNTIME_FUNCTION(Runtime_ArrayBufferIsView) { |
| 921 HandleScope scope(isolate); | 921 HandleScope scope(isolate); |
| 922 ASSERT(args.length() == 1); | 922 ASSERT(args.length() == 1); |
| 923 CONVERT_ARG_CHECKED(Object, object, 0); | 923 CONVERT_ARG_CHECKED(Object, object, 0); |
| 924 return isolate->heap()->ToBoolean(object->IsJSArrayBufferView()); | 924 return isolate->heap()->ToBoolean(object->IsJSArrayBufferView()); |
| 925 } | 925 } |
| 926 | 926 |
| 927 | 927 |
| 928 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayBufferNeuter) { | 928 RUNTIME_FUNCTION(Runtime_ArrayBufferNeuter) { |
| 929 HandleScope scope(isolate); | 929 HandleScope scope(isolate); |
| 930 ASSERT(args.length() == 1); | 930 ASSERT(args.length() == 1); |
| 931 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, array_buffer, 0); | 931 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, array_buffer, 0); |
| 932 if (array_buffer->backing_store() == NULL) { | 932 if (array_buffer->backing_store() == NULL) { |
| 933 CHECK(Smi::FromInt(0) == array_buffer->byte_length()); | 933 CHECK(Smi::FromInt(0) == array_buffer->byte_length()); |
| 934 return isolate->heap()->undefined_value(); | 934 return isolate->heap()->undefined_value(); |
| 935 } | 935 } |
| 936 ASSERT(!array_buffer->is_external()); | 936 ASSERT(!array_buffer->is_external()); |
| 937 void* backing_store = array_buffer->backing_store(); | 937 void* backing_store = array_buffer->backing_store(); |
| 938 size_t byte_length = NumberToSize(isolate, array_buffer->byte_length()); | 938 size_t byte_length = NumberToSize(isolate, array_buffer->byte_length()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 960 | 960 |
| 961 TYPED_ARRAYS(ARRAY_ID_CASE) | 961 TYPED_ARRAYS(ARRAY_ID_CASE) |
| 962 #undef ARRAY_ID_CASE | 962 #undef ARRAY_ID_CASE |
| 963 | 963 |
| 964 default: | 964 default: |
| 965 UNREACHABLE(); | 965 UNREACHABLE(); |
| 966 } | 966 } |
| 967 } | 967 } |
| 968 | 968 |
| 969 | 969 |
| 970 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayInitialize) { | 970 RUNTIME_FUNCTION(Runtime_TypedArrayInitialize) { |
| 971 HandleScope scope(isolate); | 971 HandleScope scope(isolate); |
| 972 ASSERT(args.length() == 5); | 972 ASSERT(args.length() == 5); |
| 973 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0); | 973 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0); |
| 974 CONVERT_SMI_ARG_CHECKED(arrayId, 1); | 974 CONVERT_SMI_ARG_CHECKED(arrayId, 1); |
| 975 CONVERT_ARG_HANDLE_CHECKED(Object, maybe_buffer, 2); | 975 CONVERT_ARG_HANDLE_CHECKED(Object, maybe_buffer, 2); |
| 976 CONVERT_NUMBER_ARG_HANDLE_CHECKED(byte_offset_object, 3); | 976 CONVERT_NUMBER_ARG_HANDLE_CHECKED(byte_offset_object, 3); |
| 977 CONVERT_NUMBER_ARG_HANDLE_CHECKED(byte_length_object, 4); | 977 CONVERT_NUMBER_ARG_HANDLE_CHECKED(byte_length_object, 4); |
| 978 | 978 |
| 979 ASSERT(holder->GetInternalFieldCount() == | 979 ASSERT(holder->GetInternalFieldCount() == |
| 980 v8::ArrayBufferView::kInternalFieldCount); | 980 v8::ArrayBufferView::kInternalFieldCount); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1042 } | 1042 } |
| 1043 return isolate->heap()->undefined_value(); | 1043 return isolate->heap()->undefined_value(); |
| 1044 } | 1044 } |
| 1045 | 1045 |
| 1046 | 1046 |
| 1047 // Initializes a typed array from an array-like object. | 1047 // Initializes a typed array from an array-like object. |
| 1048 // If an array-like object happens to be a typed array of the same type, | 1048 // If an array-like object happens to be a typed array of the same type, |
| 1049 // initializes backing store using memove. | 1049 // initializes backing store using memove. |
| 1050 // | 1050 // |
| 1051 // Returns true if backing store was initialized or false otherwise. | 1051 // Returns true if backing store was initialized or false otherwise. |
| 1052 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayInitializeFromArrayLike) { | 1052 RUNTIME_FUNCTION(Runtime_TypedArrayInitializeFromArrayLike) { |
| 1053 HandleScope scope(isolate); | 1053 HandleScope scope(isolate); |
| 1054 ASSERT(args.length() == 4); | 1054 ASSERT(args.length() == 4); |
| 1055 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0); | 1055 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0); |
| 1056 CONVERT_SMI_ARG_CHECKED(arrayId, 1); | 1056 CONVERT_SMI_ARG_CHECKED(arrayId, 1); |
| 1057 CONVERT_ARG_HANDLE_CHECKED(Object, source, 2); | 1057 CONVERT_ARG_HANDLE_CHECKED(Object, source, 2); |
| 1058 CONVERT_ARG_HANDLE_CHECKED(Object, length_obj, 3); | 1058 CONVERT_ARG_HANDLE_CHECKED(Object, length_obj, 3); |
| 1059 | 1059 |
| 1060 ASSERT(holder->GetInternalFieldCount() == | 1060 ASSERT(holder->GetInternalFieldCount() == |
| 1061 v8::ArrayBufferView::kInternalFieldCount); | 1061 v8::ArrayBufferView::kInternalFieldCount); |
| 1062 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { | 1062 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1144 byte_length); | 1144 byte_length); |
| 1145 return isolate->heap()->true_value(); | 1145 return isolate->heap()->true_value(); |
| 1146 } | 1146 } |
| 1147 } | 1147 } |
| 1148 | 1148 |
| 1149 return isolate->heap()->false_value(); | 1149 return isolate->heap()->false_value(); |
| 1150 } | 1150 } |
| 1151 | 1151 |
| 1152 | 1152 |
| 1153 #define BUFFER_VIEW_GETTER(Type, getter, accessor) \ | 1153 #define BUFFER_VIEW_GETTER(Type, getter, accessor) \ |
| 1154 RUNTIME_FUNCTION(MaybeObject*, Runtime_##Type##Get##getter) { \ | 1154 RUNTIME_FUNCTION(Runtime_##Type##Get##getter) { \ |
| 1155 HandleScope scope(isolate); \ | 1155 HandleScope scope(isolate); \ |
| 1156 ASSERT(args.length() == 1); \ | 1156 ASSERT(args.length() == 1); \ |
| 1157 CONVERT_ARG_HANDLE_CHECKED(JS##Type, holder, 0); \ | 1157 CONVERT_ARG_HANDLE_CHECKED(JS##Type, holder, 0); \ |
| 1158 return holder->accessor(); \ | 1158 return holder->accessor(); \ |
| 1159 } | 1159 } |
| 1160 | 1160 |
| 1161 BUFFER_VIEW_GETTER(ArrayBufferView, ByteLength, byte_length) | 1161 BUFFER_VIEW_GETTER(ArrayBufferView, ByteLength, byte_length) |
| 1162 BUFFER_VIEW_GETTER(ArrayBufferView, ByteOffset, byte_offset) | 1162 BUFFER_VIEW_GETTER(ArrayBufferView, ByteOffset, byte_offset) |
| 1163 BUFFER_VIEW_GETTER(TypedArray, Length, length) | 1163 BUFFER_VIEW_GETTER(TypedArray, Length, length) |
| 1164 BUFFER_VIEW_GETTER(DataView, Buffer, buffer) | 1164 BUFFER_VIEW_GETTER(DataView, Buffer, buffer) |
| 1165 | 1165 |
| 1166 #undef BUFFER_VIEW_GETTER | 1166 #undef BUFFER_VIEW_GETTER |
| 1167 | 1167 |
| 1168 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayGetBuffer) { | 1168 RUNTIME_FUNCTION(Runtime_TypedArrayGetBuffer) { |
| 1169 HandleScope scope(isolate); | 1169 HandleScope scope(isolate); |
| 1170 ASSERT(args.length() == 1); | 1170 ASSERT(args.length() == 1); |
| 1171 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0); | 1171 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0); |
| 1172 return *holder->GetBuffer(); | 1172 return *holder->GetBuffer(); |
| 1173 } | 1173 } |
| 1174 | 1174 |
| 1175 | 1175 |
| 1176 // Return codes for Runtime_TypedArraySetFastCases. | 1176 // Return codes for Runtime_TypedArraySetFastCases. |
| 1177 // Should be synchronized with typedarray.js natives. | 1177 // Should be synchronized with typedarray.js natives. |
| 1178 enum TypedArraySetResultCodes { | 1178 enum TypedArraySetResultCodes { |
| 1179 // Set from typed array of the same type. | 1179 // Set from typed array of the same type. |
| 1180 // This is processed by TypedArraySetFastCases | 1180 // This is processed by TypedArraySetFastCases |
| 1181 TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE = 0, | 1181 TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE = 0, |
| 1182 // Set from typed array of the different type, overlapping in memory. | 1182 // Set from typed array of the different type, overlapping in memory. |
| 1183 TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING = 1, | 1183 TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING = 1, |
| 1184 // Set from typed array of the different type, non-overlapping. | 1184 // Set from typed array of the different type, non-overlapping. |
| 1185 TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING = 2, | 1185 TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING = 2, |
| 1186 // Set from non-typed array. | 1186 // Set from non-typed array. |
| 1187 TYPED_ARRAY_SET_NON_TYPED_ARRAY = 3 | 1187 TYPED_ARRAY_SET_NON_TYPED_ARRAY = 3 |
| 1188 }; | 1188 }; |
| 1189 | 1189 |
| 1190 | 1190 |
| 1191 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArraySetFastCases) { | 1191 RUNTIME_FUNCTION(Runtime_TypedArraySetFastCases) { |
| 1192 HandleScope scope(isolate); | 1192 HandleScope scope(isolate); |
| 1193 ASSERT(args.length() == 3); | 1193 ASSERT(args.length() == 3); |
| 1194 CONVERT_ARG_HANDLE_CHECKED(Object, target_obj, 0); | 1194 CONVERT_ARG_HANDLE_CHECKED(Object, target_obj, 0); |
| 1195 CONVERT_ARG_HANDLE_CHECKED(Object, source_obj, 1); | 1195 CONVERT_ARG_HANDLE_CHECKED(Object, source_obj, 1); |
| 1196 CONVERT_ARG_HANDLE_CHECKED(Object, offset_obj, 2); | 1196 CONVERT_ARG_HANDLE_CHECKED(Object, offset_obj, 2); |
| 1197 | 1197 |
| 1198 if (!target_obj->IsJSTypedArray()) | 1198 if (!target_obj->IsJSTypedArray()) |
| 1199 return isolate->Throw(*isolate->factory()->NewTypeError( | 1199 return isolate->Throw(*isolate->factory()->NewTypeError( |
| 1200 "not_typed_array", HandleVector<Object>(NULL, 0))); | 1200 "not_typed_array", HandleVector<Object>(NULL, 0))); |
| 1201 | 1201 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1240 ASSERT( | 1240 ASSERT( |
| 1241 target->GetBuffer()->backing_store() == | 1241 target->GetBuffer()->backing_store() == |
| 1242 source->GetBuffer()->backing_store()); | 1242 source->GetBuffer()->backing_store()); |
| 1243 return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING); | 1243 return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING); |
| 1244 } else { // Non-overlapping typed arrays | 1244 } else { // Non-overlapping typed arrays |
| 1245 return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING); | 1245 return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING); |
| 1246 } | 1246 } |
| 1247 } | 1247 } |
| 1248 | 1248 |
| 1249 | 1249 |
| 1250 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayMaxSizeInHeap) { | 1250 RUNTIME_FUNCTION(Runtime_TypedArrayMaxSizeInHeap) { |
| 1251 ASSERT(args.length() == 0); | 1251 ASSERT(args.length() == 0); |
| 1252 ASSERT_OBJECT_SIZE( | 1252 ASSERT_OBJECT_SIZE( |
| 1253 FLAG_typed_array_max_size_in_heap + FixedTypedArrayBase::kDataOffset); | 1253 FLAG_typed_array_max_size_in_heap + FixedTypedArrayBase::kDataOffset); |
| 1254 return Smi::FromInt(FLAG_typed_array_max_size_in_heap); | 1254 return Smi::FromInt(FLAG_typed_array_max_size_in_heap); |
| 1255 } | 1255 } |
| 1256 | 1256 |
| 1257 | 1257 |
| 1258 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewInitialize) { | 1258 RUNTIME_FUNCTION(Runtime_DataViewInitialize) { |
| 1259 HandleScope scope(isolate); | 1259 HandleScope scope(isolate); |
| 1260 ASSERT(args.length() == 4); | 1260 ASSERT(args.length() == 4); |
| 1261 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); | 1261 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); |
| 1262 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, buffer, 1); | 1262 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, buffer, 1); |
| 1263 CONVERT_ARG_HANDLE_CHECKED(Object, byte_offset, 2); | 1263 CONVERT_ARG_HANDLE_CHECKED(Object, byte_offset, 2); |
| 1264 CONVERT_ARG_HANDLE_CHECKED(Object, byte_length, 3); | 1264 CONVERT_ARG_HANDLE_CHECKED(Object, byte_length, 3); |
| 1265 | 1265 |
| 1266 ASSERT(holder->GetInternalFieldCount() == | 1266 ASSERT(holder->GetInternalFieldCount() == |
| 1267 v8::ArrayBufferView::kInternalFieldCount); | 1267 v8::ArrayBufferView::kInternalFieldCount); |
| 1268 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { | 1268 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1394 if (NeedToFlipBytes(is_little_endian)) { | 1394 if (NeedToFlipBytes(is_little_endian)) { |
| 1395 FlipBytes<sizeof(T)>(target, value.bytes); | 1395 FlipBytes<sizeof(T)>(target, value.bytes); |
| 1396 } else { | 1396 } else { |
| 1397 CopyBytes<sizeof(T)>(target, value.bytes); | 1397 CopyBytes<sizeof(T)>(target, value.bytes); |
| 1398 } | 1398 } |
| 1399 return true; | 1399 return true; |
| 1400 } | 1400 } |
| 1401 | 1401 |
| 1402 | 1402 |
| 1403 #define DATA_VIEW_GETTER(TypeName, Type, Converter) \ | 1403 #define DATA_VIEW_GETTER(TypeName, Type, Converter) \ |
| 1404 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewGet##TypeName) { \ | 1404 RUNTIME_FUNCTION(Runtime_DataViewGet##TypeName) { \ |
| 1405 HandleScope scope(isolate); \ | 1405 HandleScope scope(isolate); \ |
| 1406 ASSERT(args.length() == 3); \ | 1406 ASSERT(args.length() == 3); \ |
| 1407 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); \ | 1407 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); \ |
| 1408 CONVERT_ARG_HANDLE_CHECKED(Object, offset, 1); \ | 1408 CONVERT_ARG_HANDLE_CHECKED(Object, offset, 1); \ |
| 1409 CONVERT_BOOLEAN_ARG_CHECKED(is_little_endian, 2); \ | 1409 CONVERT_BOOLEAN_ARG_CHECKED(is_little_endian, 2); \ |
| 1410 Type result; \ | 1410 Type result; \ |
| 1411 if (DataViewGetValue( \ | 1411 if (DataViewGetValue( \ |
| 1412 isolate, holder, offset, is_little_endian, &result)) { \ | 1412 isolate, holder, offset, is_little_endian, &result)) { \ |
| 1413 return *isolate->factory()->Converter(result); \ | 1413 return *isolate->factory()->Converter(result); \ |
| 1414 } else { \ | 1414 } else { \ |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1476 } | 1476 } |
| 1477 | 1477 |
| 1478 | 1478 |
| 1479 template <> | 1479 template <> |
| 1480 double DataViewConvertValue<double>(double value) { | 1480 double DataViewConvertValue<double>(double value) { |
| 1481 return value; | 1481 return value; |
| 1482 } | 1482 } |
| 1483 | 1483 |
| 1484 | 1484 |
| 1485 #define DATA_VIEW_SETTER(TypeName, Type) \ | 1485 #define DATA_VIEW_SETTER(TypeName, Type) \ |
| 1486 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewSet##TypeName) { \ | 1486 RUNTIME_FUNCTION(Runtime_DataViewSet##TypeName) { \ |
| 1487 HandleScope scope(isolate); \ | 1487 HandleScope scope(isolate); \ |
| 1488 ASSERT(args.length() == 4); \ | 1488 ASSERT(args.length() == 4); \ |
| 1489 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); \ | 1489 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); \ |
| 1490 CONVERT_ARG_HANDLE_CHECKED(Object, offset, 1); \ | 1490 CONVERT_ARG_HANDLE_CHECKED(Object, offset, 1); \ |
| 1491 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); \ | 1491 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); \ |
| 1492 CONVERT_BOOLEAN_ARG_CHECKED(is_little_endian, 3); \ | 1492 CONVERT_BOOLEAN_ARG_CHECKED(is_little_endian, 3); \ |
| 1493 Type v = DataViewConvertValue<Type>(value->Number()); \ | 1493 Type v = DataViewConvertValue<Type>(value->Number()); \ |
| 1494 if (DataViewSetValue( \ | 1494 if (DataViewSetValue( \ |
| 1495 isolate, holder, offset, is_little_endian, v)) { \ | 1495 isolate, holder, offset, is_little_endian, v)) { \ |
| 1496 return isolate->heap()->undefined_value(); \ | 1496 return isolate->heap()->undefined_value(); \ |
| 1497 } else { \ | 1497 } else { \ |
| 1498 return isolate->Throw(*isolate->factory()->NewRangeError( \ | 1498 return isolate->Throw(*isolate->factory()->NewRangeError( \ |
| 1499 "invalid_data_view_accessor_offset", \ | 1499 "invalid_data_view_accessor_offset", \ |
| 1500 HandleVector<Object>(NULL, 0))); \ | 1500 HandleVector<Object>(NULL, 0))); \ |
| 1501 } \ | 1501 } \ |
| 1502 } | 1502 } |
| 1503 | 1503 |
| 1504 DATA_VIEW_SETTER(Uint8, uint8_t) | 1504 DATA_VIEW_SETTER(Uint8, uint8_t) |
| 1505 DATA_VIEW_SETTER(Int8, int8_t) | 1505 DATA_VIEW_SETTER(Int8, int8_t) |
| 1506 DATA_VIEW_SETTER(Uint16, uint16_t) | 1506 DATA_VIEW_SETTER(Uint16, uint16_t) |
| 1507 DATA_VIEW_SETTER(Int16, int16_t) | 1507 DATA_VIEW_SETTER(Int16, int16_t) |
| 1508 DATA_VIEW_SETTER(Uint32, uint32_t) | 1508 DATA_VIEW_SETTER(Uint32, uint32_t) |
| 1509 DATA_VIEW_SETTER(Int32, int32_t) | 1509 DATA_VIEW_SETTER(Int32, int32_t) |
| 1510 DATA_VIEW_SETTER(Float32, float) | 1510 DATA_VIEW_SETTER(Float32, float) |
| 1511 DATA_VIEW_SETTER(Float64, double) | 1511 DATA_VIEW_SETTER(Float64, double) |
| 1512 | 1512 |
| 1513 #undef DATA_VIEW_SETTER | 1513 #undef DATA_VIEW_SETTER |
| 1514 | 1514 |
| 1515 | 1515 |
| 1516 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetInitialize) { | 1516 RUNTIME_FUNCTION(Runtime_SetInitialize) { |
| 1517 HandleScope scope(isolate); | 1517 HandleScope scope(isolate); |
| 1518 ASSERT(args.length() == 1); | 1518 ASSERT(args.length() == 1); |
| 1519 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); | 1519 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); |
| 1520 Handle<OrderedHashSet> table = isolate->factory()->NewOrderedHashSet(); | 1520 Handle<OrderedHashSet> table = isolate->factory()->NewOrderedHashSet(); |
| 1521 holder->set_table(*table); | 1521 holder->set_table(*table); |
| 1522 return *holder; | 1522 return *holder; |
| 1523 } | 1523 } |
| 1524 | 1524 |
| 1525 | 1525 |
| 1526 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetAdd) { | 1526 RUNTIME_FUNCTION(Runtime_SetAdd) { |
| 1527 HandleScope scope(isolate); | 1527 HandleScope scope(isolate); |
| 1528 ASSERT(args.length() == 2); | 1528 ASSERT(args.length() == 2); |
| 1529 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); | 1529 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); |
| 1530 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 1530 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
| 1531 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); | 1531 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); |
| 1532 table = OrderedHashSet::Add(table, key); | 1532 table = OrderedHashSet::Add(table, key); |
| 1533 holder->set_table(*table); | 1533 holder->set_table(*table); |
| 1534 return isolate->heap()->undefined_value(); | 1534 return isolate->heap()->undefined_value(); |
| 1535 } | 1535 } |
| 1536 | 1536 |
| 1537 | 1537 |
| 1538 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetHas) { | 1538 RUNTIME_FUNCTION(Runtime_SetHas) { |
| 1539 HandleScope scope(isolate); | 1539 HandleScope scope(isolate); |
| 1540 ASSERT(args.length() == 2); | 1540 ASSERT(args.length() == 2); |
| 1541 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); | 1541 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); |
| 1542 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 1542 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
| 1543 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); | 1543 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); |
| 1544 return isolate->heap()->ToBoolean(table->Contains(*key)); | 1544 return isolate->heap()->ToBoolean(table->Contains(*key)); |
| 1545 } | 1545 } |
| 1546 | 1546 |
| 1547 | 1547 |
| 1548 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDelete) { | 1548 RUNTIME_FUNCTION(Runtime_SetDelete) { |
| 1549 HandleScope scope(isolate); | 1549 HandleScope scope(isolate); |
| 1550 ASSERT(args.length() == 2); | 1550 ASSERT(args.length() == 2); |
| 1551 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); | 1551 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); |
| 1552 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 1552 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
| 1553 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); | 1553 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); |
| 1554 table = OrderedHashSet::Remove(table, key); | 1554 table = OrderedHashSet::Remove(table, key); |
| 1555 holder->set_table(*table); | 1555 holder->set_table(*table); |
| 1556 return isolate->heap()->undefined_value(); | 1556 return isolate->heap()->undefined_value(); |
| 1557 } | 1557 } |
| 1558 | 1558 |
| 1559 | 1559 |
| 1560 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetClear) { | 1560 RUNTIME_FUNCTION(Runtime_SetClear) { |
| 1561 HandleScope scope(isolate); | 1561 HandleScope scope(isolate); |
| 1562 ASSERT(args.length() == 1); | 1562 ASSERT(args.length() == 1); |
| 1563 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); | 1563 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); |
| 1564 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); | 1564 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); |
| 1565 table = OrderedHashSet::Clear(table); | 1565 table = OrderedHashSet::Clear(table); |
| 1566 holder->set_table(*table); | 1566 holder->set_table(*table); |
| 1567 return isolate->heap()->undefined_value(); | 1567 return isolate->heap()->undefined_value(); |
| 1568 } | 1568 } |
| 1569 | 1569 |
| 1570 | 1570 |
| 1571 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetGetSize) { | 1571 RUNTIME_FUNCTION(Runtime_SetGetSize) { |
| 1572 HandleScope scope(isolate); | 1572 HandleScope scope(isolate); |
| 1573 ASSERT(args.length() == 1); | 1573 ASSERT(args.length() == 1); |
| 1574 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); | 1574 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); |
| 1575 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); | 1575 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); |
| 1576 return Smi::FromInt(table->NumberOfElements()); | 1576 return Smi::FromInt(table->NumberOfElements()); |
| 1577 } | 1577 } |
| 1578 | 1578 |
| 1579 | 1579 |
| 1580 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetCreateIterator) { | 1580 RUNTIME_FUNCTION(Runtime_SetCreateIterator) { |
| 1581 HandleScope scope(isolate); | 1581 HandleScope scope(isolate); |
| 1582 ASSERT(args.length() == 2); | 1582 ASSERT(args.length() == 2); |
| 1583 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); | 1583 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); |
| 1584 CONVERT_SMI_ARG_CHECKED(kind, 1) | 1584 CONVERT_SMI_ARG_CHECKED(kind, 1) |
| 1585 ASSERT(kind == JSSetIterator::kKindValues | 1585 ASSERT(kind == JSSetIterator::kKindValues |
| 1586 || kind == JSSetIterator::kKindEntries); | 1586 || kind == JSSetIterator::kKindEntries); |
| 1587 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); | 1587 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); |
| 1588 Handle<JSSetIterator> iterator = JSSetIterator::Create(table, kind); | 1588 return *JSSetIterator::Create(table, kind); |
| 1589 return *iterator; | |
| 1590 } | 1589 } |
| 1591 | 1590 |
| 1592 | 1591 |
| 1593 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetIteratorNext) { | 1592 RUNTIME_FUNCTION(Runtime_SetIteratorNext) { |
| 1594 HandleScope scope(isolate); | 1593 HandleScope scope(isolate); |
| 1595 ASSERT(args.length() == 1); | 1594 ASSERT(args.length() == 1); |
| 1596 CONVERT_ARG_HANDLE_CHECKED(JSSetIterator, holder, 0); | 1595 CONVERT_ARG_HANDLE_CHECKED(JSSetIterator, holder, 0); |
| 1597 Handle<JSObject> result = JSSetIterator::Next(holder); | 1596 return *JSSetIterator::Next(holder); |
| 1598 return *result; | |
| 1599 } | 1597 } |
| 1600 | 1598 |
| 1601 | 1599 |
| 1602 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetIteratorClose) { | 1600 RUNTIME_FUNCTION(Runtime_SetIteratorClose) { |
| 1603 HandleScope scope(isolate); | 1601 HandleScope scope(isolate); |
| 1604 ASSERT(args.length() == 1); | 1602 ASSERT(args.length() == 1); |
| 1605 CONVERT_ARG_HANDLE_CHECKED(JSSetIterator, holder, 0); | 1603 CONVERT_ARG_HANDLE_CHECKED(JSSetIterator, holder, 0); |
| 1606 holder->Close(); | 1604 holder->Close(); |
| 1607 return isolate->heap()->undefined_value(); | 1605 return isolate->heap()->undefined_value(); |
| 1608 } | 1606 } |
| 1609 | 1607 |
| 1610 | 1608 |
| 1611 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapInitialize) { | 1609 RUNTIME_FUNCTION(Runtime_MapInitialize) { |
| 1612 HandleScope scope(isolate); | 1610 HandleScope scope(isolate); |
| 1613 ASSERT(args.length() == 1); | 1611 ASSERT(args.length() == 1); |
| 1614 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); | 1612 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); |
| 1615 Handle<OrderedHashMap> table = isolate->factory()->NewOrderedHashMap(); | 1613 Handle<OrderedHashMap> table = isolate->factory()->NewOrderedHashMap(); |
| 1616 holder->set_table(*table); | 1614 holder->set_table(*table); |
| 1617 return *holder; | 1615 return *holder; |
| 1618 } | 1616 } |
| 1619 | 1617 |
| 1620 | 1618 |
| 1621 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapGet) { | 1619 RUNTIME_FUNCTION(Runtime_MapGet) { |
| 1622 HandleScope scope(isolate); | 1620 HandleScope scope(isolate); |
| 1623 ASSERT(args.length() == 2); | 1621 ASSERT(args.length() == 2); |
| 1624 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); | 1622 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); |
| 1625 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 1623 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
| 1626 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); | 1624 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); |
| 1627 Handle<Object> lookup(table->Lookup(*key), isolate); | 1625 Handle<Object> lookup(table->Lookup(*key), isolate); |
| 1628 return lookup->IsTheHole() ? isolate->heap()->undefined_value() : *lookup; | 1626 return lookup->IsTheHole() ? isolate->heap()->undefined_value() : *lookup; |
| 1629 } | 1627 } |
| 1630 | 1628 |
| 1631 | 1629 |
| 1632 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapHas) { | 1630 RUNTIME_FUNCTION(Runtime_MapHas) { |
| 1633 HandleScope scope(isolate); | 1631 HandleScope scope(isolate); |
| 1634 ASSERT(args.length() == 2); | 1632 ASSERT(args.length() == 2); |
| 1635 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); | 1633 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); |
| 1636 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 1634 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
| 1637 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); | 1635 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); |
| 1638 Handle<Object> lookup(table->Lookup(*key), isolate); | 1636 Handle<Object> lookup(table->Lookup(*key), isolate); |
| 1639 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); | 1637 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); |
| 1640 } | 1638 } |
| 1641 | 1639 |
| 1642 | 1640 |
| 1643 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapDelete) { | 1641 RUNTIME_FUNCTION(Runtime_MapDelete) { |
| 1644 HandleScope scope(isolate); | 1642 HandleScope scope(isolate); |
| 1645 ASSERT(args.length() == 2); | 1643 ASSERT(args.length() == 2); |
| 1646 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); | 1644 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); |
| 1647 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 1645 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
| 1648 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); | 1646 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); |
| 1649 Handle<Object> lookup(table->Lookup(*key), isolate); | 1647 Handle<Object> lookup(table->Lookup(*key), isolate); |
| 1650 Handle<OrderedHashMap> new_table = | 1648 Handle<OrderedHashMap> new_table = |
| 1651 OrderedHashMap::Put(table, key, isolate->factory()->the_hole_value()); | 1649 OrderedHashMap::Put(table, key, isolate->factory()->the_hole_value()); |
| 1652 holder->set_table(*new_table); | 1650 holder->set_table(*new_table); |
| 1653 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); | 1651 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); |
| 1654 } | 1652 } |
| 1655 | 1653 |
| 1656 | 1654 |
| 1657 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapClear) { | 1655 RUNTIME_FUNCTION(Runtime_MapClear) { |
| 1658 HandleScope scope(isolate); | 1656 HandleScope scope(isolate); |
| 1659 ASSERT(args.length() == 1); | 1657 ASSERT(args.length() == 1); |
| 1660 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); | 1658 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); |
| 1661 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); | 1659 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); |
| 1662 table = OrderedHashMap::Clear(table); | 1660 table = OrderedHashMap::Clear(table); |
| 1663 holder->set_table(*table); | 1661 holder->set_table(*table); |
| 1664 return isolate->heap()->undefined_value(); | 1662 return isolate->heap()->undefined_value(); |
| 1665 } | 1663 } |
| 1666 | 1664 |
| 1667 | 1665 |
| 1668 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapSet) { | 1666 RUNTIME_FUNCTION(Runtime_MapSet) { |
| 1669 HandleScope scope(isolate); | 1667 HandleScope scope(isolate); |
| 1670 ASSERT(args.length() == 3); | 1668 ASSERT(args.length() == 3); |
| 1671 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); | 1669 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); |
| 1672 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 1670 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
| 1673 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | 1671 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
| 1674 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); | 1672 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); |
| 1675 Handle<OrderedHashMap> new_table = OrderedHashMap::Put(table, key, value); | 1673 Handle<OrderedHashMap> new_table = OrderedHashMap::Put(table, key, value); |
| 1676 holder->set_table(*new_table); | 1674 holder->set_table(*new_table); |
| 1677 return isolate->heap()->undefined_value(); | 1675 return isolate->heap()->undefined_value(); |
| 1678 } | 1676 } |
| 1679 | 1677 |
| 1680 | 1678 |
| 1681 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapGetSize) { | 1679 RUNTIME_FUNCTION(Runtime_MapGetSize) { |
| 1682 HandleScope scope(isolate); | 1680 HandleScope scope(isolate); |
| 1683 ASSERT(args.length() == 1); | 1681 ASSERT(args.length() == 1); |
| 1684 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); | 1682 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); |
| 1685 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); | 1683 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); |
| 1686 return Smi::FromInt(table->NumberOfElements()); | 1684 return Smi::FromInt(table->NumberOfElements()); |
| 1687 } | 1685 } |
| 1688 | 1686 |
| 1689 | 1687 |
| 1690 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapCreateIterator) { | 1688 RUNTIME_FUNCTION(Runtime_MapCreateIterator) { |
| 1691 HandleScope scope(isolate); | 1689 HandleScope scope(isolate); |
| 1692 ASSERT(args.length() == 2); | 1690 ASSERT(args.length() == 2); |
| 1693 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); | 1691 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); |
| 1694 CONVERT_SMI_ARG_CHECKED(kind, 1) | 1692 CONVERT_SMI_ARG_CHECKED(kind, 1) |
| 1695 ASSERT(kind == JSMapIterator::kKindKeys | 1693 ASSERT(kind == JSMapIterator::kKindKeys |
| 1696 || kind == JSMapIterator::kKindValues | 1694 || kind == JSMapIterator::kKindValues |
| 1697 || kind == JSMapIterator::kKindEntries); | 1695 || kind == JSMapIterator::kKindEntries); |
| 1698 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); | 1696 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); |
| 1699 Handle<JSMapIterator> iterator = JSMapIterator::Create(table, kind); | 1697 return *JSMapIterator::Create(table, kind); |
| 1700 return *iterator; | |
| 1701 } | 1698 } |
| 1702 | 1699 |
| 1703 | 1700 |
| 1704 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapIteratorNext) { | 1701 RUNTIME_FUNCTION(Runtime_MapIteratorNext) { |
| 1705 HandleScope scope(isolate); | 1702 HandleScope scope(isolate); |
| 1706 ASSERT(args.length() == 1); | 1703 ASSERT(args.length() == 1); |
| 1707 CONVERT_ARG_HANDLE_CHECKED(JSMapIterator, holder, 0); | 1704 CONVERT_ARG_HANDLE_CHECKED(JSMapIterator, holder, 0); |
| 1708 Handle<JSObject> result = JSMapIterator::Next(holder); | 1705 return *JSMapIterator::Next(holder); |
| 1709 return *result; | |
| 1710 } | 1706 } |
| 1711 | 1707 |
| 1712 | 1708 |
| 1713 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapIteratorClose) { | 1709 RUNTIME_FUNCTION(Runtime_MapIteratorClose) { |
| 1714 HandleScope scope(isolate); | 1710 HandleScope scope(isolate); |
| 1715 ASSERT(args.length() == 1); | 1711 ASSERT(args.length() == 1); |
| 1716 CONVERT_ARG_HANDLE_CHECKED(JSMapIterator, holder, 0); | 1712 CONVERT_ARG_HANDLE_CHECKED(JSMapIterator, holder, 0); |
| 1717 holder->Close(); | 1713 holder->Close(); |
| 1718 return isolate->heap()->undefined_value(); | 1714 return isolate->heap()->undefined_value(); |
| 1719 } | 1715 } |
| 1720 | 1716 |
| 1721 | 1717 |
| 1722 static JSWeakCollection* WeakCollectionInitialize(Isolate* isolate, | 1718 static Handle<JSWeakCollection> WeakCollectionInitialize( |
| 1719 Isolate* isolate, |
| 1723 Handle<JSWeakCollection> weak_collection) { | 1720 Handle<JSWeakCollection> weak_collection) { |
| 1724 ASSERT(weak_collection->map()->inobject_properties() == 0); | 1721 ASSERT(weak_collection->map()->inobject_properties() == 0); |
| 1725 Handle<ObjectHashTable> table = isolate->factory()->NewObjectHashTable(0); | 1722 Handle<ObjectHashTable> table = isolate->factory()->NewObjectHashTable(0); |
| 1726 weak_collection->set_table(*table); | 1723 weak_collection->set_table(*table); |
| 1727 weak_collection->set_next(Smi::FromInt(0)); | 1724 weak_collection->set_next(Smi::FromInt(0)); |
| 1728 return *weak_collection; | 1725 return weak_collection; |
| 1729 } | 1726 } |
| 1730 | 1727 |
| 1731 | 1728 |
| 1732 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakCollectionInitialize) { | 1729 RUNTIME_FUNCTION(Runtime_WeakCollectionInitialize) { |
| 1733 HandleScope scope(isolate); | 1730 HandleScope scope(isolate); |
| 1734 ASSERT(args.length() == 1); | 1731 ASSERT(args.length() == 1); |
| 1735 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); | 1732 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); |
| 1736 return WeakCollectionInitialize(isolate, weak_collection); | 1733 return *WeakCollectionInitialize(isolate, weak_collection); |
| 1737 } | 1734 } |
| 1738 | 1735 |
| 1739 | 1736 |
| 1740 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakCollectionGet) { | 1737 RUNTIME_FUNCTION(Runtime_WeakCollectionGet) { |
| 1741 HandleScope scope(isolate); | 1738 HandleScope scope(isolate); |
| 1742 ASSERT(args.length() == 2); | 1739 ASSERT(args.length() == 2); |
| 1743 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); | 1740 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); |
| 1744 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 1741 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
| 1745 Handle<ObjectHashTable> table( | 1742 Handle<ObjectHashTable> table( |
| 1746 ObjectHashTable::cast(weak_collection->table())); | 1743 ObjectHashTable::cast(weak_collection->table())); |
| 1747 Handle<Object> lookup(table->Lookup(*key), isolate); | 1744 Handle<Object> lookup(table->Lookup(*key), isolate); |
| 1748 return lookup->IsTheHole() ? isolate->heap()->undefined_value() : *lookup; | 1745 return lookup->IsTheHole() ? isolate->heap()->undefined_value() : *lookup; |
| 1749 } | 1746 } |
| 1750 | 1747 |
| 1751 | 1748 |
| 1752 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakCollectionHas) { | 1749 RUNTIME_FUNCTION(Runtime_WeakCollectionHas) { |
| 1753 HandleScope scope(isolate); | 1750 HandleScope scope(isolate); |
| 1754 ASSERT(args.length() == 2); | 1751 ASSERT(args.length() == 2); |
| 1755 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); | 1752 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); |
| 1756 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 1753 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
| 1757 Handle<ObjectHashTable> table( | 1754 Handle<ObjectHashTable> table( |
| 1758 ObjectHashTable::cast(weak_collection->table())); | 1755 ObjectHashTable::cast(weak_collection->table())); |
| 1759 Handle<Object> lookup(table->Lookup(*key), isolate); | 1756 Handle<Object> lookup(table->Lookup(*key), isolate); |
| 1760 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); | 1757 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); |
| 1761 } | 1758 } |
| 1762 | 1759 |
| 1763 | 1760 |
| 1764 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakCollectionDelete) { | 1761 RUNTIME_FUNCTION(Runtime_WeakCollectionDelete) { |
| 1765 HandleScope scope(isolate); | 1762 HandleScope scope(isolate); |
| 1766 ASSERT(args.length() == 2); | 1763 ASSERT(args.length() == 2); |
| 1767 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); | 1764 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); |
| 1768 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 1765 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
| 1769 Handle<ObjectHashTable> table(ObjectHashTable::cast( | 1766 Handle<ObjectHashTable> table(ObjectHashTable::cast( |
| 1770 weak_collection->table())); | 1767 weak_collection->table())); |
| 1771 Handle<Object> lookup(table->Lookup(*key), isolate); | 1768 Handle<Object> lookup(table->Lookup(*key), isolate); |
| 1772 Handle<ObjectHashTable> new_table = | 1769 Handle<ObjectHashTable> new_table = |
| 1773 ObjectHashTable::Put(table, key, isolate->factory()->the_hole_value()); | 1770 ObjectHashTable::Put(table, key, isolate->factory()->the_hole_value()); |
| 1774 weak_collection->set_table(*new_table); | 1771 weak_collection->set_table(*new_table); |
| 1775 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); | 1772 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); |
| 1776 } | 1773 } |
| 1777 | 1774 |
| 1778 | 1775 |
| 1779 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakCollectionSet) { | 1776 RUNTIME_FUNCTION(Runtime_WeakCollectionSet) { |
| 1780 HandleScope scope(isolate); | 1777 HandleScope scope(isolate); |
| 1781 ASSERT(args.length() == 3); | 1778 ASSERT(args.length() == 3); |
| 1782 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); | 1779 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); |
| 1783 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 1780 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
| 1784 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | 1781 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
| 1785 Handle<ObjectHashTable> table( | 1782 Handle<ObjectHashTable> table( |
| 1786 ObjectHashTable::cast(weak_collection->table())); | 1783 ObjectHashTable::cast(weak_collection->table())); |
| 1787 Handle<ObjectHashTable> new_table = ObjectHashTable::Put(table, key, value); | 1784 Handle<ObjectHashTable> new_table = ObjectHashTable::Put(table, key, value); |
| 1788 weak_collection->set_table(*new_table); | 1785 weak_collection->set_table(*new_table); |
| 1789 return isolate->heap()->undefined_value(); | 1786 return isolate->heap()->undefined_value(); |
| 1790 } | 1787 } |
| 1791 | 1788 |
| 1792 | 1789 |
| 1793 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClassOf) { | 1790 RUNTIME_FUNCTION(Runtime_ClassOf) { |
| 1794 SealHandleScope shs(isolate); | 1791 SealHandleScope shs(isolate); |
| 1795 ASSERT(args.length() == 1); | 1792 ASSERT(args.length() == 1); |
| 1796 CONVERT_ARG_CHECKED(Object, obj, 0); | 1793 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 1797 if (!obj->IsJSObject()) return isolate->heap()->null_value(); | 1794 if (!obj->IsJSObject()) return isolate->heap()->null_value(); |
| 1798 return JSObject::cast(obj)->class_name(); | 1795 return JSObject::cast(obj)->class_name(); |
| 1799 } | 1796 } |
| 1800 | 1797 |
| 1801 | 1798 |
| 1802 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPrototype) { | 1799 RUNTIME_FUNCTION(Runtime_GetPrototype) { |
| 1803 HandleScope scope(isolate); | 1800 HandleScope scope(isolate); |
| 1804 ASSERT(args.length() == 1); | 1801 ASSERT(args.length() == 1); |
| 1805 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); | 1802 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); |
| 1806 // We don't expect access checks to be needed on JSProxy objects. | 1803 // We don't expect access checks to be needed on JSProxy objects. |
| 1807 ASSERT(!obj->IsAccessCheckNeeded() || obj->IsJSObject()); | 1804 ASSERT(!obj->IsAccessCheckNeeded() || obj->IsJSObject()); |
| 1808 do { | 1805 do { |
| 1809 if (obj->IsAccessCheckNeeded() && | 1806 if (obj->IsAccessCheckNeeded() && |
| 1810 !isolate->MayNamedAccess(Handle<JSObject>::cast(obj), | 1807 !isolate->MayNamedAccess(Handle<JSObject>::cast(obj), |
| 1811 isolate->factory()->proto_string(), | 1808 isolate->factory()->proto_string(), |
| 1812 v8::ACCESS_GET)) { | 1809 v8::ACCESS_GET)) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1826 Isolate* isolate, Handle<Object> receiver) { | 1823 Isolate* isolate, Handle<Object> receiver) { |
| 1827 Handle<Object> current = Object::GetPrototype(isolate, receiver); | 1824 Handle<Object> current = Object::GetPrototype(isolate, receiver); |
| 1828 while (current->IsJSObject() && | 1825 while (current->IsJSObject() && |
| 1829 JSObject::cast(*current)->map()->is_hidden_prototype()) { | 1826 JSObject::cast(*current)->map()->is_hidden_prototype()) { |
| 1830 current = Object::GetPrototype(isolate, current); | 1827 current = Object::GetPrototype(isolate, current); |
| 1831 } | 1828 } |
| 1832 return current; | 1829 return current; |
| 1833 } | 1830 } |
| 1834 | 1831 |
| 1835 | 1832 |
| 1836 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetPrototype) { | 1833 RUNTIME_FUNCTION(Runtime_SetPrototype) { |
| 1837 HandleScope scope(isolate); | 1834 HandleScope scope(isolate); |
| 1838 ASSERT(args.length() == 2); | 1835 ASSERT(args.length() == 2); |
| 1839 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 1836 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
| 1840 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1); | 1837 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1); |
| 1841 if (obj->IsAccessCheckNeeded() && | 1838 if (obj->IsAccessCheckNeeded() && |
| 1842 !isolate->MayNamedAccess( | 1839 !isolate->MayNamedAccess( |
| 1843 obj, isolate->factory()->proto_string(), v8::ACCESS_SET)) { | 1840 obj, isolate->factory()->proto_string(), v8::ACCESS_SET)) { |
| 1844 isolate->ReportFailedAccessCheck(obj, v8::ACCESS_SET); | 1841 isolate->ReportFailedAccessCheck(obj, v8::ACCESS_SET); |
| 1845 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 1842 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
| 1846 return isolate->heap()->undefined_value(); | 1843 return isolate->heap()->undefined_value(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1861 return *result; | 1858 return *result; |
| 1862 } | 1859 } |
| 1863 Handle<Object> result; | 1860 Handle<Object> result; |
| 1864 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 1861 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 1865 isolate, result, | 1862 isolate, result, |
| 1866 JSObject::SetPrototype(obj, prototype, true)); | 1863 JSObject::SetPrototype(obj, prototype, true)); |
| 1867 return *result; | 1864 return *result; |
| 1868 } | 1865 } |
| 1869 | 1866 |
| 1870 | 1867 |
| 1871 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsInPrototypeChain) { | 1868 RUNTIME_FUNCTION(Runtime_IsInPrototypeChain) { |
| 1872 HandleScope shs(isolate); | 1869 HandleScope shs(isolate); |
| 1873 ASSERT(args.length() == 2); | 1870 ASSERT(args.length() == 2); |
| 1874 // See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8). | 1871 // See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8). |
| 1875 CONVERT_ARG_HANDLE_CHECKED(Object, O, 0); | 1872 CONVERT_ARG_HANDLE_CHECKED(Object, O, 0); |
| 1876 CONVERT_ARG_HANDLE_CHECKED(Object, V, 1); | 1873 CONVERT_ARG_HANDLE_CHECKED(Object, V, 1); |
| 1877 while (true) { | 1874 while (true) { |
| 1878 Handle<Object> prototype = Object::GetPrototype(isolate, V); | 1875 Handle<Object> prototype = Object::GetPrototype(isolate, V); |
| 1879 if (prototype->IsNull()) return isolate->heap()->false_value(); | 1876 if (prototype->IsNull()) return isolate->heap()->false_value(); |
| 1880 if (*O == *prototype) return isolate->heap()->true_value(); | 1877 if (*O == *prototype) return isolate->heap()->true_value(); |
| 1881 V = prototype; | 1878 V = prototype; |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2065 } | 2062 } |
| 2066 | 2063 |
| 2067 | 2064 |
| 2068 // Returns an array with the property description: | 2065 // Returns an array with the property description: |
| 2069 // if args[1] is not a property on args[0] | 2066 // if args[1] is not a property on args[0] |
| 2070 // returns undefined | 2067 // returns undefined |
| 2071 // if args[1] is a data property on args[0] | 2068 // if args[1] is a data property on args[0] |
| 2072 // [false, value, Writeable, Enumerable, Configurable] | 2069 // [false, value, Writeable, Enumerable, Configurable] |
| 2073 // if args[1] is an accessor on args[0] | 2070 // if args[1] is an accessor on args[0] |
| 2074 // [true, GetFunction, SetFunction, Enumerable, Configurable] | 2071 // [true, GetFunction, SetFunction, Enumerable, Configurable] |
| 2075 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOwnProperty) { | 2072 RUNTIME_FUNCTION(Runtime_GetOwnProperty) { |
| 2076 HandleScope scope(isolate); | 2073 HandleScope scope(isolate); |
| 2077 ASSERT(args.length() == 2); | 2074 ASSERT(args.length() == 2); |
| 2078 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 2075 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
| 2079 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 2076 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
| 2080 Handle<Object> result; | 2077 Handle<Object> result; |
| 2081 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 2078 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 2082 isolate, result, GetOwnProperty(isolate, obj, name)); | 2079 isolate, result, GetOwnProperty(isolate, obj, name)); |
| 2083 return *result; | 2080 return *result; |
| 2084 } | 2081 } |
| 2085 | 2082 |
| 2086 | 2083 |
| 2087 RUNTIME_FUNCTION(MaybeObject*, Runtime_PreventExtensions) { | 2084 RUNTIME_FUNCTION(Runtime_PreventExtensions) { |
| 2088 HandleScope scope(isolate); | 2085 HandleScope scope(isolate); |
| 2089 ASSERT(args.length() == 1); | 2086 ASSERT(args.length() == 1); |
| 2090 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 2087 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
| 2091 Handle<Object> result; | 2088 Handle<Object> result; |
| 2092 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 2089 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 2093 isolate, result, JSObject::PreventExtensions(obj)); | 2090 isolate, result, JSObject::PreventExtensions(obj)); |
| 2094 return *result; | 2091 return *result; |
| 2095 } | 2092 } |
| 2096 | 2093 |
| 2097 | 2094 |
| 2098 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsExtensible) { | 2095 RUNTIME_FUNCTION(Runtime_IsExtensible) { |
| 2099 SealHandleScope shs(isolate); | 2096 SealHandleScope shs(isolate); |
| 2100 ASSERT(args.length() == 1); | 2097 ASSERT(args.length() == 1); |
| 2101 CONVERT_ARG_CHECKED(JSObject, obj, 0); | 2098 CONVERT_ARG_CHECKED(JSObject, obj, 0); |
| 2102 if (obj->IsJSGlobalProxy()) { | 2099 if (obj->IsJSGlobalProxy()) { |
| 2103 Object* proto = obj->GetPrototype(); | 2100 Object* proto = obj->GetPrototype(); |
| 2104 if (proto->IsNull()) return isolate->heap()->false_value(); | 2101 if (proto->IsNull()) return isolate->heap()->false_value(); |
| 2105 ASSERT(proto->IsJSGlobalObject()); | 2102 ASSERT(proto->IsJSGlobalObject()); |
| 2106 obj = JSObject::cast(proto); | 2103 obj = JSObject::cast(proto); |
| 2107 } | 2104 } |
| 2108 return isolate->heap()->ToBoolean(obj->map()->is_extensible()); | 2105 return isolate->heap()->ToBoolean(obj->map()->is_extensible()); |
| 2109 } | 2106 } |
| 2110 | 2107 |
| 2111 | 2108 |
| 2112 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpCompile) { | 2109 RUNTIME_FUNCTION(Runtime_RegExpCompile) { |
| 2113 HandleScope scope(isolate); | 2110 HandleScope scope(isolate); |
| 2114 ASSERT(args.length() == 3); | 2111 ASSERT(args.length() == 3); |
| 2115 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, re, 0); | 2112 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, re, 0); |
| 2116 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 1); | 2113 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 1); |
| 2117 CONVERT_ARG_HANDLE_CHECKED(String, flags, 2); | 2114 CONVERT_ARG_HANDLE_CHECKED(String, flags, 2); |
| 2118 Handle<Object> result; | 2115 Handle<Object> result; |
| 2119 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 2116 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 2120 isolate, result, RegExpImpl::Compile(re, pattern, flags)); | 2117 isolate, result, RegExpImpl::Compile(re, pattern, flags)); |
| 2121 return *result; | 2118 return *result; |
| 2122 } | 2119 } |
| 2123 | 2120 |
| 2124 | 2121 |
| 2125 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateApiFunction) { | 2122 RUNTIME_FUNCTION(Runtime_CreateApiFunction) { |
| 2126 HandleScope scope(isolate); | 2123 HandleScope scope(isolate); |
| 2127 ASSERT(args.length() == 1); | 2124 ASSERT(args.length() == 1); |
| 2128 CONVERT_ARG_HANDLE_CHECKED(FunctionTemplateInfo, data, 0); | 2125 CONVERT_ARG_HANDLE_CHECKED(FunctionTemplateInfo, data, 0); |
| 2129 return *isolate->factory()->CreateApiFunction(data); | 2126 return *isolate->factory()->CreateApiFunction(data); |
| 2130 } | 2127 } |
| 2131 | 2128 |
| 2132 | 2129 |
| 2133 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsTemplate) { | 2130 RUNTIME_FUNCTION(Runtime_IsTemplate) { |
| 2134 SealHandleScope shs(isolate); | 2131 SealHandleScope shs(isolate); |
| 2135 ASSERT(args.length() == 1); | 2132 ASSERT(args.length() == 1); |
| 2136 CONVERT_ARG_HANDLE_CHECKED(Object, arg, 0); | 2133 CONVERT_ARG_HANDLE_CHECKED(Object, arg, 0); |
| 2137 bool result = arg->IsObjectTemplateInfo() || arg->IsFunctionTemplateInfo(); | 2134 bool result = arg->IsObjectTemplateInfo() || arg->IsFunctionTemplateInfo(); |
| 2138 return isolate->heap()->ToBoolean(result); | 2135 return isolate->heap()->ToBoolean(result); |
| 2139 } | 2136 } |
| 2140 | 2137 |
| 2141 | 2138 |
| 2142 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetTemplateField) { | 2139 RUNTIME_FUNCTION(Runtime_GetTemplateField) { |
| 2143 SealHandleScope shs(isolate); | 2140 SealHandleScope shs(isolate); |
| 2144 ASSERT(args.length() == 2); | 2141 ASSERT(args.length() == 2); |
| 2145 CONVERT_ARG_CHECKED(HeapObject, templ, 0); | 2142 CONVERT_ARG_CHECKED(HeapObject, templ, 0); |
| 2146 CONVERT_SMI_ARG_CHECKED(index, 1); | 2143 CONVERT_SMI_ARG_CHECKED(index, 1); |
| 2147 int offset = index * kPointerSize + HeapObject::kHeaderSize; | 2144 int offset = index * kPointerSize + HeapObject::kHeaderSize; |
| 2148 InstanceType type = templ->map()->instance_type(); | 2145 InstanceType type = templ->map()->instance_type(); |
| 2149 RUNTIME_ASSERT(type == FUNCTION_TEMPLATE_INFO_TYPE || | 2146 RUNTIME_ASSERT(type == FUNCTION_TEMPLATE_INFO_TYPE || |
| 2150 type == OBJECT_TEMPLATE_INFO_TYPE); | 2147 type == OBJECT_TEMPLATE_INFO_TYPE); |
| 2151 RUNTIME_ASSERT(offset > 0); | 2148 RUNTIME_ASSERT(offset > 0); |
| 2152 if (type == FUNCTION_TEMPLATE_INFO_TYPE) { | 2149 if (type == FUNCTION_TEMPLATE_INFO_TYPE) { |
| 2153 RUNTIME_ASSERT(offset < FunctionTemplateInfo::kSize); | 2150 RUNTIME_ASSERT(offset < FunctionTemplateInfo::kSize); |
| 2154 } else { | 2151 } else { |
| 2155 RUNTIME_ASSERT(offset < ObjectTemplateInfo::kSize); | 2152 RUNTIME_ASSERT(offset < ObjectTemplateInfo::kSize); |
| 2156 } | 2153 } |
| 2157 return *HeapObject::RawField(templ, offset); | 2154 return *HeapObject::RawField(templ, offset); |
| 2158 } | 2155 } |
| 2159 | 2156 |
| 2160 | 2157 |
| 2161 RUNTIME_FUNCTION(MaybeObject*, Runtime_DisableAccessChecks) { | 2158 RUNTIME_FUNCTION(Runtime_DisableAccessChecks) { |
| 2162 HandleScope scope(isolate); | 2159 HandleScope scope(isolate); |
| 2163 ASSERT(args.length() == 1); | 2160 ASSERT(args.length() == 1); |
| 2164 CONVERT_ARG_HANDLE_CHECKED(HeapObject, object, 0); | 2161 CONVERT_ARG_HANDLE_CHECKED(HeapObject, object, 0); |
| 2165 Handle<Map> old_map(object->map()); | 2162 Handle<Map> old_map(object->map()); |
| 2166 bool needs_access_checks = old_map->is_access_check_needed(); | 2163 bool needs_access_checks = old_map->is_access_check_needed(); |
| 2167 if (needs_access_checks) { | 2164 if (needs_access_checks) { |
| 2168 // Copy map so it won't interfere constructor's initial map. | 2165 // Copy map so it won't interfere constructor's initial map. |
| 2169 Handle<Map> new_map = Map::Copy(old_map); | 2166 Handle<Map> new_map = Map::Copy(old_map); |
| 2170 new_map->set_is_access_check_needed(false); | 2167 new_map->set_is_access_check_needed(false); |
| 2171 if (object->IsJSObject()) { | 2168 if (object->IsJSObject()) { |
| 2172 JSObject::MigrateToMap(Handle<JSObject>::cast(object), new_map); | 2169 JSObject::MigrateToMap(Handle<JSObject>::cast(object), new_map); |
| 2173 } else { | 2170 } else { |
| 2174 object->set_map(*new_map); | 2171 object->set_map(*new_map); |
| 2175 } | 2172 } |
| 2176 } | 2173 } |
| 2177 return isolate->heap()->ToBoolean(needs_access_checks); | 2174 return isolate->heap()->ToBoolean(needs_access_checks); |
| 2178 } | 2175 } |
| 2179 | 2176 |
| 2180 | 2177 |
| 2181 RUNTIME_FUNCTION(MaybeObject*, Runtime_EnableAccessChecks) { | 2178 RUNTIME_FUNCTION(Runtime_EnableAccessChecks) { |
| 2182 HandleScope scope(isolate); | 2179 HandleScope scope(isolate); |
| 2183 ASSERT(args.length() == 1); | 2180 ASSERT(args.length() == 1); |
| 2184 CONVERT_ARG_HANDLE_CHECKED(HeapObject, object, 0); | 2181 CONVERT_ARG_HANDLE_CHECKED(HeapObject, object, 0); |
| 2185 Handle<Map> old_map(object->map()); | 2182 Handle<Map> old_map(object->map()); |
| 2186 if (!old_map->is_access_check_needed()) { | 2183 if (!old_map->is_access_check_needed()) { |
| 2187 // Copy map so it won't interfere constructor's initial map. | 2184 // Copy map so it won't interfere constructor's initial map. |
| 2188 Handle<Map> new_map = Map::Copy(old_map); | 2185 Handle<Map> new_map = Map::Copy(old_map); |
| 2189 new_map->set_is_access_check_needed(true); | 2186 new_map->set_is_access_check_needed(true); |
| 2190 if (object->IsJSObject()) { | 2187 if (object->IsJSObject()) { |
| 2191 JSObject::MigrateToMap(Handle<JSObject>::cast(object), new_map); | 2188 JSObject::MigrateToMap(Handle<JSObject>::cast(object), new_map); |
| 2192 } else { | 2189 } else { |
| 2193 object->set_map(*new_map); | 2190 object->set_map(*new_map); |
| 2194 } | 2191 } |
| 2195 } | 2192 } |
| 2196 return isolate->heap()->undefined_value(); | 2193 return isolate->heap()->undefined_value(); |
| 2197 } | 2194 } |
| 2198 | 2195 |
| 2199 | 2196 |
| 2200 // Transform getter or setter into something DefineAccessor can handle. | 2197 // Transform getter or setter into something DefineAccessor can handle. |
| 2201 static Handle<Object> InstantiateAccessorComponent(Isolate* isolate, | 2198 static Handle<Object> InstantiateAccessorComponent(Isolate* isolate, |
| 2202 Handle<Object> component) { | 2199 Handle<Object> component) { |
| 2203 if (component->IsUndefined()) return isolate->factory()->null_value(); | 2200 if (component->IsUndefined()) return isolate->factory()->null_value(); |
| 2204 Handle<FunctionTemplateInfo> info = | 2201 Handle<FunctionTemplateInfo> info = |
| 2205 Handle<FunctionTemplateInfo>::cast(component); | 2202 Handle<FunctionTemplateInfo>::cast(component); |
| 2206 return Utils::OpenHandle(*Utils::ToLocal(info)->GetFunction()); | 2203 return Utils::OpenHandle(*Utils::ToLocal(info)->GetFunction()); |
| 2207 } | 2204 } |
| 2208 | 2205 |
| 2209 | 2206 |
| 2210 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetAccessorProperty) { | 2207 RUNTIME_FUNCTION(Runtime_SetAccessorProperty) { |
| 2211 HandleScope scope(isolate); | 2208 HandleScope scope(isolate); |
| 2212 ASSERT(args.length() == 6); | 2209 ASSERT(args.length() == 6); |
| 2213 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 2210 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
| 2214 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 2211 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
| 2215 CONVERT_ARG_HANDLE_CHECKED(Object, getter, 2); | 2212 CONVERT_ARG_HANDLE_CHECKED(Object, getter, 2); |
| 2216 CONVERT_ARG_HANDLE_CHECKED(Object, setter, 3); | 2213 CONVERT_ARG_HANDLE_CHECKED(Object, setter, 3); |
| 2217 CONVERT_SMI_ARG_CHECKED(attribute, 4); | 2214 CONVERT_SMI_ARG_CHECKED(attribute, 4); |
| 2218 CONVERT_SMI_ARG_CHECKED(access_control, 5); | 2215 CONVERT_SMI_ARG_CHECKED(access_control, 5); |
| 2219 RUNTIME_ASSERT(getter->IsUndefined() || getter->IsFunctionTemplateInfo()); | 2216 RUNTIME_ASSERT(getter->IsUndefined() || getter->IsFunctionTemplateInfo()); |
| 2220 RUNTIME_ASSERT(setter->IsUndefined() || setter->IsFunctionTemplateInfo()); | 2217 RUNTIME_ASSERT(setter->IsUndefined() || setter->IsFunctionTemplateInfo()); |
| 2221 JSObject::DefineAccessor(object, | 2218 JSObject::DefineAccessor(object, |
| 2222 name, | 2219 name, |
| 2223 InstantiateAccessorComponent(isolate, getter), | 2220 InstantiateAccessorComponent(isolate, getter), |
| 2224 InstantiateAccessorComponent(isolate, setter), | 2221 InstantiateAccessorComponent(isolate, setter), |
| 2225 static_cast<PropertyAttributes>(attribute), | 2222 static_cast<PropertyAttributes>(attribute), |
| 2226 static_cast<v8::AccessControl>(access_control)); | 2223 static_cast<v8::AccessControl>(access_control)); |
| 2227 return isolate->heap()->undefined_value(); | 2224 return isolate->heap()->undefined_value(); |
| 2228 } | 2225 } |
| 2229 | 2226 |
| 2230 | 2227 |
| 2231 static Failure* ThrowRedeclarationError(Isolate* isolate, Handle<String> name) { | 2228 static Object* ThrowRedeclarationError(Isolate* isolate, Handle<String> name) { |
| 2232 HandleScope scope(isolate); | 2229 HandleScope scope(isolate); |
| 2233 Handle<Object> args[1] = { name }; | 2230 Handle<Object> args[1] = { name }; |
| 2234 Handle<Object> error = isolate->factory()->NewTypeError( | 2231 Handle<Object> error = isolate->factory()->NewTypeError( |
| 2235 "var_redeclaration", HandleVector(args, 1)); | 2232 "var_redeclaration", HandleVector(args, 1)); |
| 2236 return isolate->Throw(*error); | 2233 return isolate->Throw(*error); |
| 2237 } | 2234 } |
| 2238 | 2235 |
| 2239 | 2236 |
| 2240 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_DeclareGlobals) { | 2237 RUNTIME_FUNCTION(RuntimeHidden_DeclareGlobals) { |
| 2241 HandleScope scope(isolate); | 2238 HandleScope scope(isolate); |
| 2242 ASSERT(args.length() == 3); | 2239 ASSERT(args.length() == 3); |
| 2243 Handle<GlobalObject> global = Handle<GlobalObject>( | 2240 Handle<GlobalObject> global = Handle<GlobalObject>( |
| 2244 isolate->context()->global_object()); | 2241 isolate->context()->global_object()); |
| 2245 | 2242 |
| 2246 CONVERT_ARG_HANDLE_CHECKED(Context, context, 0); | 2243 CONVERT_ARG_HANDLE_CHECKED(Context, context, 0); |
| 2247 CONVERT_ARG_HANDLE_CHECKED(FixedArray, pairs, 1); | 2244 CONVERT_ARG_HANDLE_CHECKED(FixedArray, pairs, 1); |
| 2248 CONVERT_SMI_ARG_CHECKED(flags, 2); | 2245 CONVERT_SMI_ARG_CHECKED(flags, 2); |
| 2249 | 2246 |
| 2250 // Traverse the name/value pairs and set the properties. | 2247 // Traverse the name/value pairs and set the properties. |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2326 global, name, value, static_cast<PropertyAttributes>(attr), | 2323 global, name, value, static_cast<PropertyAttributes>(attr), |
| 2327 strict_mode)); | 2324 strict_mode)); |
| 2328 } | 2325 } |
| 2329 } | 2326 } |
| 2330 | 2327 |
| 2331 ASSERT(!isolate->has_pending_exception()); | 2328 ASSERT(!isolate->has_pending_exception()); |
| 2332 return isolate->heap()->undefined_value(); | 2329 return isolate->heap()->undefined_value(); |
| 2333 } | 2330 } |
| 2334 | 2331 |
| 2335 | 2332 |
| 2336 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_DeclareContextSlot) { | 2333 RUNTIME_FUNCTION(RuntimeHidden_DeclareContextSlot) { |
| 2337 HandleScope scope(isolate); | 2334 HandleScope scope(isolate); |
| 2338 ASSERT(args.length() == 4); | 2335 ASSERT(args.length() == 4); |
| 2339 | 2336 |
| 2340 // Declarations are always made in a function or native context. In the | 2337 // Declarations are always made in a function or native context. In the |
| 2341 // case of eval code, the context passed is the context of the caller, | 2338 // case of eval code, the context passed is the context of the caller, |
| 2342 // which may be some nested context and not the declaration context. | 2339 // which may be some nested context and not the declaration context. |
| 2343 CONVERT_ARG_HANDLE_CHECKED(Context, context_arg, 0); | 2340 CONVERT_ARG_HANDLE_CHECKED(Context, context_arg, 0); |
| 2344 Handle<Context> context(context_arg->declaration_context()); | 2341 Handle<Context> context(context_arg->declaration_context()); |
| 2345 CONVERT_ARG_HANDLE_CHECKED(String, name, 1); | 2342 CONVERT_ARG_HANDLE_CHECKED(String, name, 1); |
| 2346 CONVERT_SMI_ARG_CHECKED(mode_arg, 2); | 2343 CONVERT_SMI_ARG_CHECKED(mode_arg, 2); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2426 } else { | 2423 } else { |
| 2427 RETURN_FAILURE_ON_EXCEPTION(isolate, | 2424 RETURN_FAILURE_ON_EXCEPTION(isolate, |
| 2428 JSReceiver::SetProperty(object, name, value, mode, SLOPPY)); | 2425 JSReceiver::SetProperty(object, name, value, mode, SLOPPY)); |
| 2429 } | 2426 } |
| 2430 } | 2427 } |
| 2431 | 2428 |
| 2432 return isolate->heap()->undefined_value(); | 2429 return isolate->heap()->undefined_value(); |
| 2433 } | 2430 } |
| 2434 | 2431 |
| 2435 | 2432 |
| 2436 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeVarGlobal) { | 2433 RUNTIME_FUNCTION(Runtime_InitializeVarGlobal) { |
| 2437 HandleScope scope(isolate); | 2434 HandleScope scope(isolate); |
| 2438 // args[0] == name | 2435 // args[0] == name |
| 2439 // args[1] == language_mode | 2436 // args[1] == language_mode |
| 2440 // args[2] == value (optional) | 2437 // args[2] == value (optional) |
| 2441 | 2438 |
| 2442 // Determine if we need to assign to the variable if it already | 2439 // Determine if we need to assign to the variable if it already |
| 2443 // exists (based on the number of arguments). | 2440 // exists (based on the number of arguments). |
| 2444 RUNTIME_ASSERT(args.length() == 2 || args.length() == 3); | 2441 RUNTIME_ASSERT(args.length() == 2 || args.length() == 3); |
| 2445 bool assign = args.length() == 3; | 2442 bool assign = args.length() == 3; |
| 2446 | 2443 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2486 Handle<Object> result; | 2483 Handle<Object> result; |
| 2487 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 2484 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 2488 isolate, result, | 2485 isolate, result, |
| 2489 JSReceiver::SetProperty(global, name, value, attributes, strict_mode)); | 2486 JSReceiver::SetProperty(global, name, value, attributes, strict_mode)); |
| 2490 return *result; | 2487 return *result; |
| 2491 } | 2488 } |
| 2492 return isolate->heap()->undefined_value(); | 2489 return isolate->heap()->undefined_value(); |
| 2493 } | 2490 } |
| 2494 | 2491 |
| 2495 | 2492 |
| 2496 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_InitializeConstGlobal) { | 2493 RUNTIME_FUNCTION(RuntimeHidden_InitializeConstGlobal) { |
| 2497 SealHandleScope shs(isolate); | 2494 SealHandleScope shs(isolate); |
| 2498 // All constants are declared with an initial value. The name | 2495 // All constants are declared with an initial value. The name |
| 2499 // of the constant is the first argument and the initial value | 2496 // of the constant is the first argument and the initial value |
| 2500 // is the second. | 2497 // is the second. |
| 2501 RUNTIME_ASSERT(args.length() == 2); | 2498 RUNTIME_ASSERT(args.length() == 2); |
| 2502 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); | 2499 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); |
| 2503 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); | 2500 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); |
| 2504 | 2501 |
| 2505 // Get the current global object from top. | 2502 // Get the current global object from top. |
| 2506 GlobalObject* global = isolate->context()->global_object(); | 2503 GlobalObject* global = isolate->context()->global_object(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2563 // Ignore re-initialization of constants that have already been | 2560 // Ignore re-initialization of constants that have already been |
| 2564 // assigned a constant value. | 2561 // assigned a constant value. |
| 2565 ASSERT(lookup.IsReadOnly() && lookup.IsConstant()); | 2562 ASSERT(lookup.IsReadOnly() && lookup.IsConstant()); |
| 2566 } | 2563 } |
| 2567 | 2564 |
| 2568 // Use the set value as the result of the operation. | 2565 // Use the set value as the result of the operation. |
| 2569 return *value; | 2566 return *value; |
| 2570 } | 2567 } |
| 2571 | 2568 |
| 2572 | 2569 |
| 2573 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_InitializeConstContextSlot) { | 2570 RUNTIME_FUNCTION(RuntimeHidden_InitializeConstContextSlot) { |
| 2574 HandleScope scope(isolate); | 2571 HandleScope scope(isolate); |
| 2575 ASSERT(args.length() == 3); | 2572 ASSERT(args.length() == 3); |
| 2576 | 2573 |
| 2577 CONVERT_ARG_HANDLE_CHECKED(Object, value, 0); | 2574 CONVERT_ARG_HANDLE_CHECKED(Object, value, 0); |
| 2578 ASSERT(!value->IsTheHole()); | 2575 ASSERT(!value->IsTheHole()); |
| 2579 // Initializations are always done in a function or native context. | 2576 // Initializations are always done in a function or native context. |
| 2580 CONVERT_ARG_HANDLE_CHECKED(Context, context_arg, 1); | 2577 CONVERT_ARG_HANDLE_CHECKED(Context, context_arg, 1); |
| 2581 Handle<Context> context(context_arg->declaration_context()); | 2578 Handle<Context> context(context_arg->declaration_context()); |
| 2582 CONVERT_ARG_HANDLE_CHECKED(String, name, 2); | 2579 CONVERT_ARG_HANDLE_CHECKED(String, name, 2); |
| 2583 | 2580 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2659 RETURN_FAILURE_ON_EXCEPTION( | 2656 RETURN_FAILURE_ON_EXCEPTION( |
| 2660 isolate, | 2657 isolate, |
| 2661 JSReceiver::SetProperty(object, name, value, attributes, SLOPPY)); | 2658 JSReceiver::SetProperty(object, name, value, attributes, SLOPPY)); |
| 2662 } | 2659 } |
| 2663 } | 2660 } |
| 2664 | 2661 |
| 2665 return *value; | 2662 return *value; |
| 2666 } | 2663 } |
| 2667 | 2664 |
| 2668 | 2665 |
| 2669 RUNTIME_FUNCTION(MaybeObject*, | 2666 RUNTIME_FUNCTION(Runtime_OptimizeObjectForAddingMultipleProperties) { |
| 2670 Runtime_OptimizeObjectForAddingMultipleProperties) { | |
| 2671 HandleScope scope(isolate); | 2667 HandleScope scope(isolate); |
| 2672 ASSERT(args.length() == 2); | 2668 ASSERT(args.length() == 2); |
| 2673 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 2669 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
| 2674 CONVERT_SMI_ARG_CHECKED(properties, 1); | 2670 CONVERT_SMI_ARG_CHECKED(properties, 1); |
| 2675 if (object->HasFastProperties() && !object->IsJSGlobalProxy()) { | 2671 if (object->HasFastProperties() && !object->IsJSGlobalProxy()) { |
| 2676 JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, properties); | 2672 JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, properties); |
| 2677 } | 2673 } |
| 2678 return *object; | 2674 return *object; |
| 2679 } | 2675 } |
| 2680 | 2676 |
| 2681 | 2677 |
| 2682 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_RegExpExec) { | 2678 RUNTIME_FUNCTION(RuntimeHidden_RegExpExec) { |
| 2683 HandleScope scope(isolate); | 2679 HandleScope scope(isolate); |
| 2684 ASSERT(args.length() == 4); | 2680 ASSERT(args.length() == 4); |
| 2685 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0); | 2681 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0); |
| 2686 CONVERT_ARG_HANDLE_CHECKED(String, subject, 1); | 2682 CONVERT_ARG_HANDLE_CHECKED(String, subject, 1); |
| 2687 // Due to the way the JS calls are constructed this must be less than the | 2683 // Due to the way the JS calls are constructed this must be less than the |
| 2688 // length of a string, i.e. it is always a Smi. We check anyway for security. | 2684 // length of a string, i.e. it is always a Smi. We check anyway for security. |
| 2689 CONVERT_SMI_ARG_CHECKED(index, 2); | 2685 CONVERT_SMI_ARG_CHECKED(index, 2); |
| 2690 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 3); | 2686 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 3); |
| 2691 RUNTIME_ASSERT(index >= 0); | 2687 RUNTIME_ASSERT(index >= 0); |
| 2692 RUNTIME_ASSERT(index <= subject->length()); | 2688 RUNTIME_ASSERT(index <= subject->length()); |
| 2693 isolate->counters()->regexp_entry_runtime()->Increment(); | 2689 isolate->counters()->regexp_entry_runtime()->Increment(); |
| 2694 Handle<Object> result; | 2690 Handle<Object> result; |
| 2695 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 2691 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 2696 isolate, result, | 2692 isolate, result, |
| 2697 RegExpImpl::Exec(regexp, subject, index, last_match_info)); | 2693 RegExpImpl::Exec(regexp, subject, index, last_match_info)); |
| 2698 return *result; | 2694 return *result; |
| 2699 } | 2695 } |
| 2700 | 2696 |
| 2701 | 2697 |
| 2702 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_RegExpConstructResult) { | 2698 RUNTIME_FUNCTION(RuntimeHidden_RegExpConstructResult) { |
| 2703 HandleScope handle_scope(isolate); | 2699 HandleScope handle_scope(isolate); |
| 2704 ASSERT(args.length() == 3); | 2700 ASSERT(args.length() == 3); |
| 2705 CONVERT_SMI_ARG_CHECKED(size, 0); | 2701 CONVERT_SMI_ARG_CHECKED(size, 0); |
| 2706 RUNTIME_ASSERT(size >= 0 && size <= FixedArray::kMaxLength); | 2702 RUNTIME_ASSERT(size >= 0 && size <= FixedArray::kMaxLength); |
| 2707 CONVERT_ARG_HANDLE_CHECKED(Object, index, 1); | 2703 CONVERT_ARG_HANDLE_CHECKED(Object, index, 1); |
| 2708 CONVERT_ARG_HANDLE_CHECKED(Object, input, 2); | 2704 CONVERT_ARG_HANDLE_CHECKED(Object, input, 2); |
| 2709 Handle<FixedArray> elements = isolate->factory()->NewFixedArray(size); | 2705 Handle<FixedArray> elements = isolate->factory()->NewFixedArray(size); |
| 2710 Handle<Map> regexp_map(isolate->native_context()->regexp_result_map()); | 2706 Handle<Map> regexp_map(isolate->native_context()->regexp_result_map()); |
| 2711 Handle<JSObject> object = | 2707 Handle<JSObject> object = |
| 2712 isolate->factory()->NewJSObjectFromMap(regexp_map, NOT_TENURED, false); | 2708 isolate->factory()->NewJSObjectFromMap(regexp_map, NOT_TENURED, false); |
| 2713 Handle<JSArray> array = Handle<JSArray>::cast(object); | 2709 Handle<JSArray> array = Handle<JSArray>::cast(object); |
| 2714 array->set_elements(*elements); | 2710 array->set_elements(*elements); |
| 2715 array->set_length(Smi::FromInt(size)); | 2711 array->set_length(Smi::FromInt(size)); |
| 2716 // Write in-object properties after the length of the array. | 2712 // Write in-object properties after the length of the array. |
| 2717 array->InObjectPropertyAtPut(JSRegExpResult::kIndexIndex, *index); | 2713 array->InObjectPropertyAtPut(JSRegExpResult::kIndexIndex, *index); |
| 2718 array->InObjectPropertyAtPut(JSRegExpResult::kInputIndex, *input); | 2714 array->InObjectPropertyAtPut(JSRegExpResult::kInputIndex, *input); |
| 2719 return *array; | 2715 return *array; |
| 2720 } | 2716 } |
| 2721 | 2717 |
| 2722 | 2718 |
| 2723 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpInitializeObject) { | 2719 RUNTIME_FUNCTION(Runtime_RegExpInitializeObject) { |
| 2724 HandleScope scope(isolate); | 2720 HandleScope scope(isolate); |
| 2725 ASSERT(args.length() == 5); | 2721 ASSERT(args.length() == 5); |
| 2726 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0); | 2722 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0); |
| 2727 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); | 2723 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); |
| 2728 // If source is the empty string we set it to "(?:)" instead as | 2724 // If source is the empty string we set it to "(?:)" instead as |
| 2729 // suggested by ECMA-262, 5th, section 15.10.4.1. | 2725 // suggested by ECMA-262, 5th, section 15.10.4.1. |
| 2730 if (source->length() == 0) source = isolate->factory()->query_colon_string(); | 2726 if (source->length() == 0) source = isolate->factory()->query_colon_string(); |
| 2731 | 2727 |
| 2732 CONVERT_ARG_HANDLE_CHECKED(Object, global, 2); | 2728 CONVERT_ARG_HANDLE_CHECKED(Object, global, 2); |
| 2733 if (!global->IsTrue()) global = isolate->factory()->false_value(); | 2729 if (!global->IsTrue()) global = isolate->factory()->false_value(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2771 JSObject::SetLocalPropertyIgnoreAttributes( | 2767 JSObject::SetLocalPropertyIgnoreAttributes( |
| 2772 regexp, factory->ignore_case_string(), ignoreCase, final).Check(); | 2768 regexp, factory->ignore_case_string(), ignoreCase, final).Check(); |
| 2773 JSObject::SetLocalPropertyIgnoreAttributes( | 2769 JSObject::SetLocalPropertyIgnoreAttributes( |
| 2774 regexp, factory->multiline_string(), multiline, final).Check(); | 2770 regexp, factory->multiline_string(), multiline, final).Check(); |
| 2775 JSObject::SetLocalPropertyIgnoreAttributes( | 2771 JSObject::SetLocalPropertyIgnoreAttributes( |
| 2776 regexp, factory->last_index_string(), zero, writable).Check(); | 2772 regexp, factory->last_index_string(), zero, writable).Check(); |
| 2777 return *regexp; | 2773 return *regexp; |
| 2778 } | 2774 } |
| 2779 | 2775 |
| 2780 | 2776 |
| 2781 RUNTIME_FUNCTION(MaybeObject*, Runtime_FinishArrayPrototypeSetup) { | 2777 RUNTIME_FUNCTION(Runtime_FinishArrayPrototypeSetup) { |
| 2782 HandleScope scope(isolate); | 2778 HandleScope scope(isolate); |
| 2783 ASSERT(args.length() == 1); | 2779 ASSERT(args.length() == 1); |
| 2784 CONVERT_ARG_HANDLE_CHECKED(JSArray, prototype, 0); | 2780 CONVERT_ARG_HANDLE_CHECKED(JSArray, prototype, 0); |
| 2785 // This is necessary to enable fast checks for absence of elements | 2781 // This is necessary to enable fast checks for absence of elements |
| 2786 // on Array.prototype and below. | 2782 // on Array.prototype and below. |
| 2787 prototype->set_elements(isolate->heap()->empty_fixed_array()); | 2783 prototype->set_elements(isolate->heap()->empty_fixed_array()); |
| 2788 return Smi::FromInt(0); | 2784 return Smi::FromInt(0); |
| 2789 } | 2785 } |
| 2790 | 2786 |
| 2791 | 2787 |
| 2792 static Handle<JSFunction> InstallBuiltin(Isolate* isolate, | 2788 static Handle<JSFunction> InstallBuiltin(Isolate* isolate, |
| 2793 Handle<JSObject> holder, | 2789 Handle<JSObject> holder, |
| 2794 const char* name, | 2790 const char* name, |
| 2795 Builtins::Name builtin_name) { | 2791 Builtins::Name builtin_name) { |
| 2796 Handle<String> key = isolate->factory()->InternalizeUtf8String(name); | 2792 Handle<String> key = isolate->factory()->InternalizeUtf8String(name); |
| 2797 Handle<Code> code(isolate->builtins()->builtin(builtin_name)); | 2793 Handle<Code> code(isolate->builtins()->builtin(builtin_name)); |
| 2798 Handle<JSFunction> optimized = | 2794 Handle<JSFunction> optimized = |
| 2799 isolate->factory()->NewFunction(key, | 2795 isolate->factory()->NewFunction(key, |
| 2800 JS_OBJECT_TYPE, | 2796 JS_OBJECT_TYPE, |
| 2801 JSObject::kHeaderSize, | 2797 JSObject::kHeaderSize, |
| 2802 code, | 2798 code, |
| 2803 false); | 2799 false); |
| 2804 optimized->shared()->DontAdaptArguments(); | 2800 optimized->shared()->DontAdaptArguments(); |
| 2805 JSReceiver::SetProperty(holder, key, optimized, NONE, STRICT).Assert(); | 2801 JSReceiver::SetProperty(holder, key, optimized, NONE, STRICT).Assert(); |
| 2806 return optimized; | 2802 return optimized; |
| 2807 } | 2803 } |
| 2808 | 2804 |
| 2809 | 2805 |
| 2810 RUNTIME_FUNCTION(MaybeObject*, Runtime_SpecialArrayFunctions) { | 2806 RUNTIME_FUNCTION(Runtime_SpecialArrayFunctions) { |
| 2811 HandleScope scope(isolate); | 2807 HandleScope scope(isolate); |
| 2812 ASSERT(args.length() == 1); | 2808 ASSERT(args.length() == 1); |
| 2813 CONVERT_ARG_HANDLE_CHECKED(JSObject, holder, 0); | 2809 CONVERT_ARG_HANDLE_CHECKED(JSObject, holder, 0); |
| 2814 | 2810 |
| 2815 InstallBuiltin(isolate, holder, "pop", Builtins::kArrayPop); | 2811 InstallBuiltin(isolate, holder, "pop", Builtins::kArrayPop); |
| 2816 InstallBuiltin(isolate, holder, "push", Builtins::kArrayPush); | 2812 InstallBuiltin(isolate, holder, "push", Builtins::kArrayPush); |
| 2817 InstallBuiltin(isolate, holder, "shift", Builtins::kArrayShift); | 2813 InstallBuiltin(isolate, holder, "shift", Builtins::kArrayShift); |
| 2818 InstallBuiltin(isolate, holder, "unshift", Builtins::kArrayUnshift); | 2814 InstallBuiltin(isolate, holder, "unshift", Builtins::kArrayUnshift); |
| 2819 InstallBuiltin(isolate, holder, "slice", Builtins::kArraySlice); | 2815 InstallBuiltin(isolate, holder, "slice", Builtins::kArraySlice); |
| 2820 InstallBuiltin(isolate, holder, "splice", Builtins::kArraySplice); | 2816 InstallBuiltin(isolate, holder, "splice", Builtins::kArraySplice); |
| 2821 InstallBuiltin(isolate, holder, "concat", Builtins::kArrayConcat); | 2817 InstallBuiltin(isolate, holder, "concat", Builtins::kArrayConcat); |
| 2822 | 2818 |
| 2823 return *holder; | 2819 return *holder; |
| 2824 } | 2820 } |
| 2825 | 2821 |
| 2826 | 2822 |
| 2827 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsSloppyModeFunction) { | 2823 RUNTIME_FUNCTION(Runtime_IsSloppyModeFunction) { |
| 2828 SealHandleScope shs(isolate); | 2824 SealHandleScope shs(isolate); |
| 2829 ASSERT(args.length() == 1); | 2825 ASSERT(args.length() == 1); |
| 2830 CONVERT_ARG_CHECKED(JSReceiver, callable, 0); | 2826 CONVERT_ARG_CHECKED(JSReceiver, callable, 0); |
| 2831 if (!callable->IsJSFunction()) { | 2827 if (!callable->IsJSFunction()) { |
| 2832 HandleScope scope(isolate); | 2828 HandleScope scope(isolate); |
| 2833 Handle<Object> delegate; | 2829 Handle<Object> delegate; |
| 2834 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 2830 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 2835 isolate, delegate, | 2831 isolate, delegate, |
| 2836 Execution::TryGetFunctionDelegate( | 2832 Execution::TryGetFunctionDelegate( |
| 2837 isolate, Handle<JSReceiver>(callable))); | 2833 isolate, Handle<JSReceiver>(callable))); |
| 2838 callable = JSFunction::cast(*delegate); | 2834 callable = JSFunction::cast(*delegate); |
| 2839 } | 2835 } |
| 2840 JSFunction* function = JSFunction::cast(callable); | 2836 JSFunction* function = JSFunction::cast(callable); |
| 2841 SharedFunctionInfo* shared = function->shared(); | 2837 SharedFunctionInfo* shared = function->shared(); |
| 2842 return isolate->heap()->ToBoolean(shared->strict_mode() == SLOPPY); | 2838 return isolate->heap()->ToBoolean(shared->strict_mode() == SLOPPY); |
| 2843 } | 2839 } |
| 2844 | 2840 |
| 2845 | 2841 |
| 2846 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDefaultReceiver) { | 2842 RUNTIME_FUNCTION(Runtime_GetDefaultReceiver) { |
| 2847 SealHandleScope shs(isolate); | 2843 SealHandleScope shs(isolate); |
| 2848 ASSERT(args.length() == 1); | 2844 ASSERT(args.length() == 1); |
| 2849 CONVERT_ARG_CHECKED(JSReceiver, callable, 0); | 2845 CONVERT_ARG_CHECKED(JSReceiver, callable, 0); |
| 2850 | 2846 |
| 2851 if (!callable->IsJSFunction()) { | 2847 if (!callable->IsJSFunction()) { |
| 2852 HandleScope scope(isolate); | 2848 HandleScope scope(isolate); |
| 2853 Handle<Object> delegate; | 2849 Handle<Object> delegate; |
| 2854 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 2850 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 2855 isolate, delegate, | 2851 isolate, delegate, |
| 2856 Execution::TryGetFunctionDelegate( | 2852 Execution::TryGetFunctionDelegate( |
| 2857 isolate, Handle<JSReceiver>(callable))); | 2853 isolate, Handle<JSReceiver>(callable))); |
| 2858 callable = JSFunction::cast(*delegate); | 2854 callable = JSFunction::cast(*delegate); |
| 2859 } | 2855 } |
| 2860 JSFunction* function = JSFunction::cast(callable); | 2856 JSFunction* function = JSFunction::cast(callable); |
| 2861 | 2857 |
| 2862 SharedFunctionInfo* shared = function->shared(); | 2858 SharedFunctionInfo* shared = function->shared(); |
| 2863 if (shared->native() || shared->strict_mode() == STRICT) { | 2859 if (shared->native() || shared->strict_mode() == STRICT) { |
| 2864 return isolate->heap()->undefined_value(); | 2860 return isolate->heap()->undefined_value(); |
| 2865 } | 2861 } |
| 2866 // Returns undefined for strict or native functions, or | 2862 // Returns undefined for strict or native functions, or |
| 2867 // the associated global receiver for "normal" functions. | 2863 // the associated global receiver for "normal" functions. |
| 2868 | 2864 |
| 2869 Context* native_context = | 2865 Context* native_context = |
| 2870 function->context()->global_object()->native_context(); | 2866 function->context()->global_object()->native_context(); |
| 2871 return native_context->global_object()->global_receiver(); | 2867 return native_context->global_object()->global_receiver(); |
| 2872 } | 2868 } |
| 2873 | 2869 |
| 2874 | 2870 |
| 2875 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_MaterializeRegExpLiteral) { | 2871 RUNTIME_FUNCTION(RuntimeHidden_MaterializeRegExpLiteral) { |
| 2876 HandleScope scope(isolate); | 2872 HandleScope scope(isolate); |
| 2877 ASSERT(args.length() == 4); | 2873 ASSERT(args.length() == 4); |
| 2878 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); | 2874 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); |
| 2879 CONVERT_SMI_ARG_CHECKED(index, 1); | 2875 CONVERT_SMI_ARG_CHECKED(index, 1); |
| 2880 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 2); | 2876 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 2); |
| 2881 CONVERT_ARG_HANDLE_CHECKED(String, flags, 3); | 2877 CONVERT_ARG_HANDLE_CHECKED(String, flags, 3); |
| 2882 | 2878 |
| 2883 // Get the RegExp function from the context in the literals array. | 2879 // Get the RegExp function from the context in the literals array. |
| 2884 // This is the RegExp function from the context in which the | 2880 // This is the RegExp function from the context in which the |
| 2885 // function was created. We do not use the RegExp function from the | 2881 // function was created. We do not use the RegExp function from the |
| 2886 // current native context because this might be the RegExp function | 2882 // current native context because this might be the RegExp function |
| 2887 // from another context which we should not have access to. | 2883 // from another context which we should not have access to. |
| 2888 Handle<JSFunction> constructor = | 2884 Handle<JSFunction> constructor = |
| 2889 Handle<JSFunction>( | 2885 Handle<JSFunction>( |
| 2890 JSFunction::NativeContextFromLiterals(*literals)->regexp_function()); | 2886 JSFunction::NativeContextFromLiterals(*literals)->regexp_function()); |
| 2891 // Compute the regular expression literal. | 2887 // Compute the regular expression literal. |
| 2892 Handle<Object> regexp; | 2888 Handle<Object> regexp; |
| 2893 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 2889 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 2894 isolate, regexp, | 2890 isolate, regexp, |
| 2895 RegExpImpl::CreateRegExpLiteral(constructor, pattern, flags)); | 2891 RegExpImpl::CreateRegExpLiteral(constructor, pattern, flags)); |
| 2896 literals->set(index, *regexp); | 2892 literals->set(index, *regexp); |
| 2897 return *regexp; | 2893 return *regexp; |
| 2898 } | 2894 } |
| 2899 | 2895 |
| 2900 | 2896 |
| 2901 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetName) { | 2897 RUNTIME_FUNCTION(Runtime_FunctionGetName) { |
| 2902 SealHandleScope shs(isolate); | 2898 SealHandleScope shs(isolate); |
| 2903 ASSERT(args.length() == 1); | 2899 ASSERT(args.length() == 1); |
| 2904 | 2900 |
| 2905 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 2901 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
| 2906 return f->shared()->name(); | 2902 return f->shared()->name(); |
| 2907 } | 2903 } |
| 2908 | 2904 |
| 2909 | 2905 |
| 2910 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetName) { | 2906 RUNTIME_FUNCTION(Runtime_FunctionSetName) { |
| 2911 SealHandleScope shs(isolate); | 2907 SealHandleScope shs(isolate); |
| 2912 ASSERT(args.length() == 2); | 2908 ASSERT(args.length() == 2); |
| 2913 | 2909 |
| 2914 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 2910 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
| 2915 CONVERT_ARG_CHECKED(String, name, 1); | 2911 CONVERT_ARG_CHECKED(String, name, 1); |
| 2916 f->shared()->set_name(name); | 2912 f->shared()->set_name(name); |
| 2917 return isolate->heap()->undefined_value(); | 2913 return isolate->heap()->undefined_value(); |
| 2918 } | 2914 } |
| 2919 | 2915 |
| 2920 | 2916 |
| 2921 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionNameShouldPrintAsAnonymous) { | 2917 RUNTIME_FUNCTION(Runtime_FunctionNameShouldPrintAsAnonymous) { |
| 2922 SealHandleScope shs(isolate); | 2918 SealHandleScope shs(isolate); |
| 2923 ASSERT(args.length() == 1); | 2919 ASSERT(args.length() == 1); |
| 2924 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 2920 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
| 2925 return isolate->heap()->ToBoolean( | 2921 return isolate->heap()->ToBoolean( |
| 2926 f->shared()->name_should_print_as_anonymous()); | 2922 f->shared()->name_should_print_as_anonymous()); |
| 2927 } | 2923 } |
| 2928 | 2924 |
| 2929 | 2925 |
| 2930 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionMarkNameShouldPrintAsAnonymous) { | 2926 RUNTIME_FUNCTION(Runtime_FunctionMarkNameShouldPrintAsAnonymous) { |
| 2931 SealHandleScope shs(isolate); | 2927 SealHandleScope shs(isolate); |
| 2932 ASSERT(args.length() == 1); | 2928 ASSERT(args.length() == 1); |
| 2933 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 2929 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
| 2934 f->shared()->set_name_should_print_as_anonymous(true); | 2930 f->shared()->set_name_should_print_as_anonymous(true); |
| 2935 return isolate->heap()->undefined_value(); | 2931 return isolate->heap()->undefined_value(); |
| 2936 } | 2932 } |
| 2937 | 2933 |
| 2938 | 2934 |
| 2939 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsGenerator) { | 2935 RUNTIME_FUNCTION(Runtime_FunctionIsGenerator) { |
| 2940 SealHandleScope shs(isolate); | 2936 SealHandleScope shs(isolate); |
| 2941 ASSERT(args.length() == 1); | 2937 ASSERT(args.length() == 1); |
| 2942 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 2938 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
| 2943 return isolate->heap()->ToBoolean(f->shared()->is_generator()); | 2939 return isolate->heap()->ToBoolean(f->shared()->is_generator()); |
| 2944 } | 2940 } |
| 2945 | 2941 |
| 2946 | 2942 |
| 2947 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionRemovePrototype) { | 2943 RUNTIME_FUNCTION(Runtime_FunctionRemovePrototype) { |
| 2948 SealHandleScope shs(isolate); | 2944 SealHandleScope shs(isolate); |
| 2949 ASSERT(args.length() == 1); | 2945 ASSERT(args.length() == 1); |
| 2950 | 2946 |
| 2951 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 2947 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
| 2952 f->RemovePrototype(); | 2948 f->RemovePrototype(); |
| 2953 | 2949 |
| 2954 return isolate->heap()->undefined_value(); | 2950 return isolate->heap()->undefined_value(); |
| 2955 } | 2951 } |
| 2956 | 2952 |
| 2957 | 2953 |
| 2958 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetScript) { | 2954 RUNTIME_FUNCTION(Runtime_FunctionGetScript) { |
| 2959 HandleScope scope(isolate); | 2955 HandleScope scope(isolate); |
| 2960 ASSERT(args.length() == 1); | 2956 ASSERT(args.length() == 1); |
| 2961 | 2957 |
| 2962 CONVERT_ARG_CHECKED(JSFunction, fun, 0); | 2958 CONVERT_ARG_CHECKED(JSFunction, fun, 0); |
| 2963 Handle<Object> script = Handle<Object>(fun->shared()->script(), isolate); | 2959 Handle<Object> script = Handle<Object>(fun->shared()->script(), isolate); |
| 2964 if (!script->IsScript()) return isolate->heap()->undefined_value(); | 2960 if (!script->IsScript()) return isolate->heap()->undefined_value(); |
| 2965 | 2961 |
| 2966 return *Script::GetWrapper(Handle<Script>::cast(script)); | 2962 return *Script::GetWrapper(Handle<Script>::cast(script)); |
| 2967 } | 2963 } |
| 2968 | 2964 |
| 2969 | 2965 |
| 2970 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetSourceCode) { | 2966 RUNTIME_FUNCTION(Runtime_FunctionGetSourceCode) { |
| 2971 HandleScope scope(isolate); | 2967 HandleScope scope(isolate); |
| 2972 ASSERT(args.length() == 1); | 2968 ASSERT(args.length() == 1); |
| 2973 | 2969 |
| 2974 CONVERT_ARG_HANDLE_CHECKED(JSFunction, f, 0); | 2970 CONVERT_ARG_HANDLE_CHECKED(JSFunction, f, 0); |
| 2975 Handle<SharedFunctionInfo> shared(f->shared()); | 2971 Handle<SharedFunctionInfo> shared(f->shared()); |
| 2976 return *shared->GetSourceCode(); | 2972 return *shared->GetSourceCode(); |
| 2977 } | 2973 } |
| 2978 | 2974 |
| 2979 | 2975 |
| 2980 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetScriptSourcePosition) { | 2976 RUNTIME_FUNCTION(Runtime_FunctionGetScriptSourcePosition) { |
| 2981 SealHandleScope shs(isolate); | 2977 SealHandleScope shs(isolate); |
| 2982 ASSERT(args.length() == 1); | 2978 ASSERT(args.length() == 1); |
| 2983 | 2979 |
| 2984 CONVERT_ARG_CHECKED(JSFunction, fun, 0); | 2980 CONVERT_ARG_CHECKED(JSFunction, fun, 0); |
| 2985 int pos = fun->shared()->start_position(); | 2981 int pos = fun->shared()->start_position(); |
| 2986 return Smi::FromInt(pos); | 2982 return Smi::FromInt(pos); |
| 2987 } | 2983 } |
| 2988 | 2984 |
| 2989 | 2985 |
| 2990 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetPositionForOffset) { | 2986 RUNTIME_FUNCTION(Runtime_FunctionGetPositionForOffset) { |
| 2991 SealHandleScope shs(isolate); | 2987 SealHandleScope shs(isolate); |
| 2992 ASSERT(args.length() == 2); | 2988 ASSERT(args.length() == 2); |
| 2993 | 2989 |
| 2994 CONVERT_ARG_CHECKED(Code, code, 0); | 2990 CONVERT_ARG_CHECKED(Code, code, 0); |
| 2995 CONVERT_NUMBER_CHECKED(int, offset, Int32, args[1]); | 2991 CONVERT_NUMBER_CHECKED(int, offset, Int32, args[1]); |
| 2996 | 2992 |
| 2997 RUNTIME_ASSERT(0 <= offset && offset < code->Size()); | 2993 RUNTIME_ASSERT(0 <= offset && offset < code->Size()); |
| 2998 | 2994 |
| 2999 Address pc = code->address() + offset; | 2995 Address pc = code->address() + offset; |
| 3000 return Smi::FromInt(code->SourcePosition(pc)); | 2996 return Smi::FromInt(code->SourcePosition(pc)); |
| 3001 } | 2997 } |
| 3002 | 2998 |
| 3003 | 2999 |
| 3004 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetInstanceClassName) { | 3000 RUNTIME_FUNCTION(Runtime_FunctionSetInstanceClassName) { |
| 3005 SealHandleScope shs(isolate); | 3001 SealHandleScope shs(isolate); |
| 3006 ASSERT(args.length() == 2); | 3002 ASSERT(args.length() == 2); |
| 3007 | 3003 |
| 3008 CONVERT_ARG_CHECKED(JSFunction, fun, 0); | 3004 CONVERT_ARG_CHECKED(JSFunction, fun, 0); |
| 3009 CONVERT_ARG_CHECKED(String, name, 1); | 3005 CONVERT_ARG_CHECKED(String, name, 1); |
| 3010 fun->SetInstanceClassName(name); | 3006 fun->SetInstanceClassName(name); |
| 3011 return isolate->heap()->undefined_value(); | 3007 return isolate->heap()->undefined_value(); |
| 3012 } | 3008 } |
| 3013 | 3009 |
| 3014 | 3010 |
| 3015 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetLength) { | 3011 RUNTIME_FUNCTION(Runtime_FunctionSetLength) { |
| 3016 SealHandleScope shs(isolate); | 3012 SealHandleScope shs(isolate); |
| 3017 ASSERT(args.length() == 2); | 3013 ASSERT(args.length() == 2); |
| 3018 | 3014 |
| 3019 CONVERT_ARG_CHECKED(JSFunction, fun, 0); | 3015 CONVERT_ARG_CHECKED(JSFunction, fun, 0); |
| 3020 CONVERT_SMI_ARG_CHECKED(length, 1); | 3016 CONVERT_SMI_ARG_CHECKED(length, 1); |
| 3021 fun->shared()->set_length(length); | 3017 fun->shared()->set_length(length); |
| 3022 return isolate->heap()->undefined_value(); | 3018 return isolate->heap()->undefined_value(); |
| 3023 } | 3019 } |
| 3024 | 3020 |
| 3025 | 3021 |
| 3026 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetPrototype) { | 3022 RUNTIME_FUNCTION(Runtime_FunctionSetPrototype) { |
| 3027 HandleScope scope(isolate); | 3023 HandleScope scope(isolate); |
| 3028 ASSERT(args.length() == 2); | 3024 ASSERT(args.length() == 2); |
| 3029 | 3025 |
| 3030 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); | 3026 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); |
| 3031 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); | 3027 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); |
| 3032 ASSERT(fun->should_have_prototype()); | 3028 ASSERT(fun->should_have_prototype()); |
| 3033 Accessors::FunctionSetPrototype(fun, value); | 3029 Accessors::FunctionSetPrototype(fun, value); |
| 3034 return args[0]; // return TOS | 3030 return args[0]; // return TOS |
| 3035 } | 3031 } |
| 3036 | 3032 |
| 3037 | 3033 |
| 3038 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetReadOnlyPrototype) { | 3034 RUNTIME_FUNCTION(Runtime_FunctionSetReadOnlyPrototype) { |
| 3039 HandleScope shs(isolate); | 3035 HandleScope shs(isolate); |
| 3040 RUNTIME_ASSERT(args.length() == 1); | 3036 RUNTIME_ASSERT(args.length() == 1); |
| 3041 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 3037 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 3042 | 3038 |
| 3043 Handle<String> name = isolate->factory()->prototype_string(); | 3039 Handle<String> name = isolate->factory()->prototype_string(); |
| 3044 | 3040 |
| 3045 if (function->HasFastProperties()) { | 3041 if (function->HasFastProperties()) { |
| 3046 // Construct a new field descriptor with updated attributes. | 3042 // Construct a new field descriptor with updated attributes. |
| 3047 Handle<DescriptorArray> instance_desc = | 3043 Handle<DescriptorArray> instance_desc = |
| 3048 handle(function->map()->instance_descriptors()); | 3044 handle(function->map()->instance_descriptors()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 3071 PropertyDetails new_details( | 3067 PropertyDetails new_details( |
| 3072 static_cast<PropertyAttributes>(details.attributes() | READ_ONLY), | 3068 static_cast<PropertyAttributes>(details.attributes() | READ_ONLY), |
| 3073 details.type(), | 3069 details.type(), |
| 3074 details.dictionary_index()); | 3070 details.dictionary_index()); |
| 3075 function->property_dictionary()->DetailsAtPut(entry, new_details); | 3071 function->property_dictionary()->DetailsAtPut(entry, new_details); |
| 3076 } | 3072 } |
| 3077 return *function; | 3073 return *function; |
| 3078 } | 3074 } |
| 3079 | 3075 |
| 3080 | 3076 |
| 3081 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsAPIFunction) { | 3077 RUNTIME_FUNCTION(Runtime_FunctionIsAPIFunction) { |
| 3082 SealHandleScope shs(isolate); | 3078 SealHandleScope shs(isolate); |
| 3083 ASSERT(args.length() == 1); | 3079 ASSERT(args.length() == 1); |
| 3084 | 3080 |
| 3085 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 3081 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
| 3086 return isolate->heap()->ToBoolean(f->shared()->IsApiFunction()); | 3082 return isolate->heap()->ToBoolean(f->shared()->IsApiFunction()); |
| 3087 } | 3083 } |
| 3088 | 3084 |
| 3089 | 3085 |
| 3090 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsBuiltin) { | 3086 RUNTIME_FUNCTION(Runtime_FunctionIsBuiltin) { |
| 3091 SealHandleScope shs(isolate); | 3087 SealHandleScope shs(isolate); |
| 3092 ASSERT(args.length() == 1); | 3088 ASSERT(args.length() == 1); |
| 3093 | 3089 |
| 3094 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 3090 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
| 3095 return isolate->heap()->ToBoolean(f->IsBuiltin()); | 3091 return isolate->heap()->ToBoolean(f->IsBuiltin()); |
| 3096 } | 3092 } |
| 3097 | 3093 |
| 3098 | 3094 |
| 3099 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetCode) { | 3095 RUNTIME_FUNCTION(Runtime_SetCode) { |
| 3100 HandleScope scope(isolate); | 3096 HandleScope scope(isolate); |
| 3101 ASSERT(args.length() == 2); | 3097 ASSERT(args.length() == 2); |
| 3102 | 3098 |
| 3103 CONVERT_ARG_HANDLE_CHECKED(JSFunction, target, 0); | 3099 CONVERT_ARG_HANDLE_CHECKED(JSFunction, target, 0); |
| 3104 CONVERT_ARG_HANDLE_CHECKED(Object, code, 1); | 3100 CONVERT_ARG_HANDLE_CHECKED(Object, code, 1); |
| 3105 | 3101 |
| 3106 if (code->IsNull()) return *target; | 3102 if (code->IsNull()) return *target; |
| 3107 RUNTIME_ASSERT(code->IsJSFunction()); | 3103 RUNTIME_ASSERT(code->IsJSFunction()); |
| 3108 Handle<JSFunction> source = Handle<JSFunction>::cast(code); | 3104 Handle<JSFunction> source = Handle<JSFunction>::cast(code); |
| 3109 Handle<SharedFunctionInfo> target_shared(target->shared()); | 3105 Handle<SharedFunctionInfo> target_shared(target->shared()); |
| 3110 Handle<SharedFunctionInfo> source_shared(source->shared()); | 3106 Handle<SharedFunctionInfo> source_shared(source->shared()); |
| 3111 | 3107 |
| 3112 if (!Compiler::EnsureCompiled(source, KEEP_EXCEPTION)) { | 3108 if (!Compiler::EnsureCompiled(source, KEEP_EXCEPTION)) { |
| 3113 return Failure::Exception(); | 3109 return isolate->heap()->exception(); |
| 3114 } | 3110 } |
| 3115 | 3111 |
| 3116 // Mark both, the source and the target, as un-flushable because the | 3112 // Mark both, the source and the target, as un-flushable because the |
| 3117 // shared unoptimized code makes them impossible to enqueue in a list. | 3113 // shared unoptimized code makes them impossible to enqueue in a list. |
| 3118 ASSERT(target_shared->code()->gc_metadata() == NULL); | 3114 ASSERT(target_shared->code()->gc_metadata() == NULL); |
| 3119 ASSERT(source_shared->code()->gc_metadata() == NULL); | 3115 ASSERT(source_shared->code()->gc_metadata() == NULL); |
| 3120 target_shared->set_dont_flush(true); | 3116 target_shared->set_dont_flush(true); |
| 3121 source_shared->set_dont_flush(true); | 3117 source_shared->set_dont_flush(true); |
| 3122 | 3118 |
| 3123 // Set the code, scope info, formal parameter count, and the length | 3119 // Set the code, scope info, formal parameter count, and the length |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3155 if (isolate->logger()->is_logging_code_events() || | 3151 if (isolate->logger()->is_logging_code_events() || |
| 3156 isolate->cpu_profiler()->is_profiling()) { | 3152 isolate->cpu_profiler()->is_profiling()) { |
| 3157 isolate->logger()->LogExistingFunction( | 3153 isolate->logger()->LogExistingFunction( |
| 3158 source_shared, Handle<Code>(source_shared->code())); | 3154 source_shared, Handle<Code>(source_shared->code())); |
| 3159 } | 3155 } |
| 3160 | 3156 |
| 3161 return *target; | 3157 return *target; |
| 3162 } | 3158 } |
| 3163 | 3159 |
| 3164 | 3160 |
| 3165 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetExpectedNumberOfProperties) { | 3161 RUNTIME_FUNCTION(Runtime_SetExpectedNumberOfProperties) { |
| 3166 HandleScope scope(isolate); | 3162 HandleScope scope(isolate); |
| 3167 ASSERT(args.length() == 2); | 3163 ASSERT(args.length() == 2); |
| 3168 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); | 3164 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); |
| 3169 CONVERT_SMI_ARG_CHECKED(num, 1); | 3165 CONVERT_SMI_ARG_CHECKED(num, 1); |
| 3170 RUNTIME_ASSERT(num >= 0); | 3166 RUNTIME_ASSERT(num >= 0); |
| 3171 // If objects constructed from this function exist then changing | 3167 // If objects constructed from this function exist then changing |
| 3172 // 'estimated_nof_properties' is dangerous since the previous value might | 3168 // 'estimated_nof_properties' is dangerous since the previous value might |
| 3173 // have been compiled into the fast construct stub. Moreover, the inobject | 3169 // have been compiled into the fast construct stub. Moreover, the inobject |
| 3174 // slack tracking logic might have adjusted the previous value, so even | 3170 // slack tracking logic might have adjusted the previous value, so even |
| 3175 // passing the same value is risky. | 3171 // passing the same value is risky. |
| 3176 if (!func->shared()->live_objects_may_exist()) { | 3172 if (!func->shared()->live_objects_may_exist()) { |
| 3177 func->shared()->set_expected_nof_properties(num); | 3173 func->shared()->set_expected_nof_properties(num); |
| 3178 if (func->has_initial_map()) { | 3174 if (func->has_initial_map()) { |
| 3179 Handle<Map> new_initial_map = Map::Copy(handle(func->initial_map())); | 3175 Handle<Map> new_initial_map = Map::Copy(handle(func->initial_map())); |
| 3180 new_initial_map->set_unused_property_fields(num); | 3176 new_initial_map->set_unused_property_fields(num); |
| 3181 func->set_initial_map(*new_initial_map); | 3177 func->set_initial_map(*new_initial_map); |
| 3182 } | 3178 } |
| 3183 } | 3179 } |
| 3184 return isolate->heap()->undefined_value(); | 3180 return isolate->heap()->undefined_value(); |
| 3185 } | 3181 } |
| 3186 | 3182 |
| 3187 | 3183 |
| 3188 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_CreateJSGeneratorObject) { | 3184 RUNTIME_FUNCTION(RuntimeHidden_CreateJSGeneratorObject) { |
| 3189 HandleScope scope(isolate); | 3185 HandleScope scope(isolate); |
| 3190 ASSERT(args.length() == 0); | 3186 ASSERT(args.length() == 0); |
| 3191 | 3187 |
| 3192 JavaScriptFrameIterator it(isolate); | 3188 JavaScriptFrameIterator it(isolate); |
| 3193 JavaScriptFrame* frame = it.frame(); | 3189 JavaScriptFrame* frame = it.frame(); |
| 3194 Handle<JSFunction> function(frame->function()); | 3190 Handle<JSFunction> function(frame->function()); |
| 3195 RUNTIME_ASSERT(function->shared()->is_generator()); | 3191 RUNTIME_ASSERT(function->shared()->is_generator()); |
| 3196 | 3192 |
| 3197 Handle<JSGeneratorObject> generator; | 3193 Handle<JSGeneratorObject> generator; |
| 3198 if (frame->IsConstructor()) { | 3194 if (frame->IsConstructor()) { |
| 3199 generator = handle(JSGeneratorObject::cast(frame->receiver())); | 3195 generator = handle(JSGeneratorObject::cast(frame->receiver())); |
| 3200 } else { | 3196 } else { |
| 3201 generator = isolate->factory()->NewJSGeneratorObject(function); | 3197 generator = isolate->factory()->NewJSGeneratorObject(function); |
| 3202 } | 3198 } |
| 3203 generator->set_function(*function); | 3199 generator->set_function(*function); |
| 3204 generator->set_context(Context::cast(frame->context())); | 3200 generator->set_context(Context::cast(frame->context())); |
| 3205 generator->set_receiver(frame->receiver()); | 3201 generator->set_receiver(frame->receiver()); |
| 3206 generator->set_continuation(0); | 3202 generator->set_continuation(0); |
| 3207 generator->set_operand_stack(isolate->heap()->empty_fixed_array()); | 3203 generator->set_operand_stack(isolate->heap()->empty_fixed_array()); |
| 3208 generator->set_stack_handler_index(-1); | 3204 generator->set_stack_handler_index(-1); |
| 3209 | 3205 |
| 3210 return *generator; | 3206 return *generator; |
| 3211 } | 3207 } |
| 3212 | 3208 |
| 3213 | 3209 |
| 3214 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_SuspendJSGeneratorObject) { | 3210 RUNTIME_FUNCTION(RuntimeHidden_SuspendJSGeneratorObject) { |
| 3215 HandleScope handle_scope(isolate); | 3211 HandleScope handle_scope(isolate); |
| 3216 ASSERT(args.length() == 1); | 3212 ASSERT(args.length() == 1); |
| 3217 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator_object, 0); | 3213 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator_object, 0); |
| 3218 | 3214 |
| 3219 JavaScriptFrameIterator stack_iterator(isolate); | 3215 JavaScriptFrameIterator stack_iterator(isolate); |
| 3220 JavaScriptFrame* frame = stack_iterator.frame(); | 3216 JavaScriptFrame* frame = stack_iterator.frame(); |
| 3221 RUNTIME_ASSERT(frame->function()->shared()->is_generator()); | 3217 RUNTIME_ASSERT(frame->function()->shared()->is_generator()); |
| 3222 ASSERT_EQ(frame->function(), generator_object->function()); | 3218 ASSERT_EQ(frame->function(), generator_object->function()); |
| 3223 | 3219 |
| 3224 // The caller should have saved the context and continuation already. | 3220 // The caller should have saved the context and continuation already. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 3254 } | 3250 } |
| 3255 | 3251 |
| 3256 | 3252 |
| 3257 // Note that this function is the slow path for resuming generators. It is only | 3253 // Note that this function is the slow path for resuming generators. It is only |
| 3258 // called if the suspended activation had operands on the stack, stack handlers | 3254 // called if the suspended activation had operands on the stack, stack handlers |
| 3259 // needing rewinding, or if the resume should throw an exception. The fast path | 3255 // needing rewinding, or if the resume should throw an exception. The fast path |
| 3260 // is handled directly in FullCodeGenerator::EmitGeneratorResume(), which is | 3256 // is handled directly in FullCodeGenerator::EmitGeneratorResume(), which is |
| 3261 // inlined into GeneratorNext and GeneratorThrow. EmitGeneratorResumeResume is | 3257 // inlined into GeneratorNext and GeneratorThrow. EmitGeneratorResumeResume is |
| 3262 // called in any case, as it needs to reconstruct the stack frame and make space | 3258 // called in any case, as it needs to reconstruct the stack frame and make space |
| 3263 // for arguments and operands. | 3259 // for arguments and operands. |
| 3264 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_ResumeJSGeneratorObject) { | 3260 RUNTIME_FUNCTION(RuntimeHidden_ResumeJSGeneratorObject) { |
| 3265 SealHandleScope shs(isolate); | 3261 SealHandleScope shs(isolate); |
| 3266 ASSERT(args.length() == 3); | 3262 ASSERT(args.length() == 3); |
| 3267 CONVERT_ARG_CHECKED(JSGeneratorObject, generator_object, 0); | 3263 CONVERT_ARG_CHECKED(JSGeneratorObject, generator_object, 0); |
| 3268 CONVERT_ARG_CHECKED(Object, value, 1); | 3264 CONVERT_ARG_CHECKED(Object, value, 1); |
| 3269 CONVERT_SMI_ARG_CHECKED(resume_mode_int, 2); | 3265 CONVERT_SMI_ARG_CHECKED(resume_mode_int, 2); |
| 3270 JavaScriptFrameIterator stack_iterator(isolate); | 3266 JavaScriptFrameIterator stack_iterator(isolate); |
| 3271 JavaScriptFrame* frame = stack_iterator.frame(); | 3267 JavaScriptFrame* frame = stack_iterator.frame(); |
| 3272 | 3268 |
| 3273 ASSERT_EQ(frame->function(), generator_object->function()); | 3269 ASSERT_EQ(frame->function(), generator_object->function()); |
| 3274 ASSERT(frame->function()->is_compiled()); | 3270 ASSERT(frame->function()->is_compiled()); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 3302 return value; | 3298 return value; |
| 3303 case JSGeneratorObject::THROW: | 3299 case JSGeneratorObject::THROW: |
| 3304 return isolate->Throw(value); | 3300 return isolate->Throw(value); |
| 3305 } | 3301 } |
| 3306 | 3302 |
| 3307 UNREACHABLE(); | 3303 UNREACHABLE(); |
| 3308 return isolate->ThrowIllegalOperation(); | 3304 return isolate->ThrowIllegalOperation(); |
| 3309 } | 3305 } |
| 3310 | 3306 |
| 3311 | 3307 |
| 3312 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_ThrowGeneratorStateError) { | 3308 RUNTIME_FUNCTION(RuntimeHidden_ThrowGeneratorStateError) { |
| 3313 HandleScope scope(isolate); | 3309 HandleScope scope(isolate); |
| 3314 ASSERT(args.length() == 1); | 3310 ASSERT(args.length() == 1); |
| 3315 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); | 3311 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); |
| 3316 int continuation = generator->continuation(); | 3312 int continuation = generator->continuation(); |
| 3317 const char* message = continuation == JSGeneratorObject::kGeneratorClosed ? | 3313 const char* message = continuation == JSGeneratorObject::kGeneratorClosed ? |
| 3318 "generator_finished" : "generator_running"; | 3314 "generator_finished" : "generator_running"; |
| 3319 Vector< Handle<Object> > argv = HandleVector<Object>(NULL, 0); | 3315 Vector< Handle<Object> > argv = HandleVector<Object>(NULL, 0); |
| 3320 Handle<Object> error = isolate->factory()->NewError(message, argv); | 3316 Handle<Object> error = isolate->factory()->NewError(message, argv); |
| 3321 return isolate->Throw(*error); | 3317 return isolate->Throw(*error); |
| 3322 } | 3318 } |
| 3323 | 3319 |
| 3324 | 3320 |
| 3325 RUNTIME_FUNCTION(MaybeObject*, Runtime_ObjectFreeze) { | 3321 RUNTIME_FUNCTION(Runtime_ObjectFreeze) { |
| 3326 HandleScope scope(isolate); | 3322 HandleScope scope(isolate); |
| 3327 ASSERT(args.length() == 1); | 3323 ASSERT(args.length() == 1); |
| 3328 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 3324 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
| 3329 Handle<Object> result; | 3325 Handle<Object> result; |
| 3330 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, JSObject::Freeze(object)); | 3326 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, JSObject::Freeze(object)); |
| 3331 return *result; | 3327 return *result; |
| 3332 } | 3328 } |
| 3333 | 3329 |
| 3334 | 3330 |
| 3335 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_StringCharCodeAt) { | 3331 RUNTIME_FUNCTION(RuntimeHidden_StringCharCodeAt) { |
| 3336 HandleScope handle_scope(isolate); | 3332 HandleScope handle_scope(isolate); |
| 3337 ASSERT(args.length() == 2); | 3333 ASSERT(args.length() == 2); |
| 3338 | 3334 |
| 3339 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); | 3335 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); |
| 3340 CONVERT_NUMBER_CHECKED(uint32_t, i, Uint32, args[1]); | 3336 CONVERT_NUMBER_CHECKED(uint32_t, i, Uint32, args[1]); |
| 3341 | 3337 |
| 3342 // Flatten the string. If someone wants to get a char at an index | 3338 // Flatten the string. If someone wants to get a char at an index |
| 3343 // in a cons string, it is likely that more indices will be | 3339 // in a cons string, it is likely that more indices will be |
| 3344 // accessed. | 3340 // accessed. |
| 3345 subject = String::Flatten(subject); | 3341 subject = String::Flatten(subject); |
| 3346 | 3342 |
| 3347 if (i >= static_cast<uint32_t>(subject->length())) { | 3343 if (i >= static_cast<uint32_t>(subject->length())) { |
| 3348 return isolate->heap()->nan_value(); | 3344 return isolate->heap()->nan_value(); |
| 3349 } | 3345 } |
| 3350 | 3346 |
| 3351 return Smi::FromInt(subject->Get(i)); | 3347 return Smi::FromInt(subject->Get(i)); |
| 3352 } | 3348 } |
| 3353 | 3349 |
| 3354 | 3350 |
| 3355 RUNTIME_FUNCTION(MaybeObject*, Runtime_CharFromCode) { | 3351 RUNTIME_FUNCTION(Runtime_CharFromCode) { |
| 3356 HandleScope handlescope(isolate); | 3352 HandleScope handlescope(isolate); |
| 3357 ASSERT(args.length() == 1); | 3353 ASSERT(args.length() == 1); |
| 3358 if (args[0]->IsNumber()) { | 3354 if (args[0]->IsNumber()) { |
| 3359 CONVERT_NUMBER_CHECKED(uint32_t, code, Uint32, args[0]); | 3355 CONVERT_NUMBER_CHECKED(uint32_t, code, Uint32, args[0]); |
| 3360 code &= 0xffff; | 3356 code &= 0xffff; |
| 3361 return *isolate->factory()->LookupSingleCharacterStringFromCode(code); | 3357 return *isolate->factory()->LookupSingleCharacterStringFromCode(code); |
| 3362 } | 3358 } |
| 3363 return isolate->heap()->empty_string(); | 3359 return isolate->heap()->empty_string(); |
| 3364 } | 3360 } |
| 3365 | 3361 |
| (...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4001 limit, | 3997 limit, |
| 4002 zone); | 3998 zone); |
| 4003 } | 3999 } |
| 4004 } | 4000 } |
| 4005 } | 4001 } |
| 4006 } | 4002 } |
| 4007 } | 4003 } |
| 4008 | 4004 |
| 4009 | 4005 |
| 4010 template<typename ResultSeqString> | 4006 template<typename ResultSeqString> |
| 4011 MUST_USE_RESULT static MaybeObject* StringReplaceGlobalAtomRegExpWithString( | 4007 MUST_USE_RESULT static Object* StringReplaceGlobalAtomRegExpWithString( |
| 4012 Isolate* isolate, | 4008 Isolate* isolate, |
| 4013 Handle<String> subject, | 4009 Handle<String> subject, |
| 4014 Handle<JSRegExp> pattern_regexp, | 4010 Handle<JSRegExp> pattern_regexp, |
| 4015 Handle<String> replacement, | 4011 Handle<String> replacement, |
| 4016 Handle<JSArray> last_match_info) { | 4012 Handle<JSArray> last_match_info) { |
| 4017 ASSERT(subject->IsFlat()); | 4013 ASSERT(subject->IsFlat()); |
| 4018 ASSERT(replacement->IsFlat()); | 4014 ASSERT(replacement->IsFlat()); |
| 4019 | 4015 |
| 4020 ZoneScope zone_scope(isolate->runtime_zone()); | 4016 ZoneScope zone_scope(isolate->runtime_zone()); |
| 4021 ZoneList<int> indices(8, zone_scope.zone()); | 4017 ZoneList<int> indices(8, zone_scope.zone()); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4089 } | 4085 } |
| 4090 | 4086 |
| 4091 int32_t match_indices[] = { indices.at(matches - 1), | 4087 int32_t match_indices[] = { indices.at(matches - 1), |
| 4092 indices.at(matches - 1) + pattern_len }; | 4088 indices.at(matches - 1) + pattern_len }; |
| 4093 RegExpImpl::SetLastMatchInfo(last_match_info, subject, 0, match_indices); | 4089 RegExpImpl::SetLastMatchInfo(last_match_info, subject, 0, match_indices); |
| 4094 | 4090 |
| 4095 return *result; | 4091 return *result; |
| 4096 } | 4092 } |
| 4097 | 4093 |
| 4098 | 4094 |
| 4099 MUST_USE_RESULT static MaybeObject* StringReplaceGlobalRegExpWithString( | 4095 MUST_USE_RESULT static Object* StringReplaceGlobalRegExpWithString( |
| 4100 Isolate* isolate, | 4096 Isolate* isolate, |
| 4101 Handle<String> subject, | 4097 Handle<String> subject, |
| 4102 Handle<JSRegExp> regexp, | 4098 Handle<JSRegExp> regexp, |
| 4103 Handle<String> replacement, | 4099 Handle<String> replacement, |
| 4104 Handle<JSArray> last_match_info) { | 4100 Handle<JSArray> last_match_info) { |
| 4105 ASSERT(subject->IsFlat()); | 4101 ASSERT(subject->IsFlat()); |
| 4106 ASSERT(replacement->IsFlat()); | 4102 ASSERT(replacement->IsFlat()); |
| 4107 | 4103 |
| 4108 int capture_count = regexp->CaptureCount(); | 4104 int capture_count = regexp->CaptureCount(); |
| 4109 int subject_length = subject->length(); | 4105 int subject_length = subject->length(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 4121 replacement->HasOnlyOneByteChars()) { | 4117 replacement->HasOnlyOneByteChars()) { |
| 4122 return StringReplaceGlobalAtomRegExpWithString<SeqOneByteString>( | 4118 return StringReplaceGlobalAtomRegExpWithString<SeqOneByteString>( |
| 4123 isolate, subject, regexp, replacement, last_match_info); | 4119 isolate, subject, regexp, replacement, last_match_info); |
| 4124 } else { | 4120 } else { |
| 4125 return StringReplaceGlobalAtomRegExpWithString<SeqTwoByteString>( | 4121 return StringReplaceGlobalAtomRegExpWithString<SeqTwoByteString>( |
| 4126 isolate, subject, regexp, replacement, last_match_info); | 4122 isolate, subject, regexp, replacement, last_match_info); |
| 4127 } | 4123 } |
| 4128 } | 4124 } |
| 4129 | 4125 |
| 4130 RegExpImpl::GlobalCache global_cache(regexp, subject, true, isolate); | 4126 RegExpImpl::GlobalCache global_cache(regexp, subject, true, isolate); |
| 4131 if (global_cache.HasException()) return Failure::Exception(); | 4127 if (global_cache.HasException()) return isolate->heap()->exception(); |
| 4132 | 4128 |
| 4133 int32_t* current_match = global_cache.FetchNext(); | 4129 int32_t* current_match = global_cache.FetchNext(); |
| 4134 if (current_match == NULL) { | 4130 if (current_match == NULL) { |
| 4135 if (global_cache.HasException()) return Failure::Exception(); | 4131 if (global_cache.HasException()) return isolate->heap()->exception(); |
| 4136 return *subject; | 4132 return *subject; |
| 4137 } | 4133 } |
| 4138 | 4134 |
| 4139 // Guessing the number of parts that the final result string is built | 4135 // Guessing the number of parts that the final result string is built |
| 4140 // from. Global regexps can match any number of times, so we guess | 4136 // from. Global regexps can match any number of times, so we guess |
| 4141 // conservatively. | 4137 // conservatively. |
| 4142 int expected_parts = (compiled_replacement.parts() + 1) * 4 + 1; | 4138 int expected_parts = (compiled_replacement.parts() + 1) * 4 + 1; |
| 4143 ReplacementStringBuilder builder(isolate->heap(), | 4139 ReplacementStringBuilder builder(isolate->heap(), |
| 4144 subject, | 4140 subject, |
| 4145 expected_parts); | 4141 expected_parts); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 4167 compiled_replacement.Apply(&builder, | 4163 compiled_replacement.Apply(&builder, |
| 4168 start, | 4164 start, |
| 4169 end, | 4165 end, |
| 4170 current_match); | 4166 current_match); |
| 4171 } | 4167 } |
| 4172 prev = end; | 4168 prev = end; |
| 4173 | 4169 |
| 4174 current_match = global_cache.FetchNext(); | 4170 current_match = global_cache.FetchNext(); |
| 4175 } while (current_match != NULL); | 4171 } while (current_match != NULL); |
| 4176 | 4172 |
| 4177 if (global_cache.HasException()) return Failure::Exception(); | 4173 if (global_cache.HasException()) return isolate->heap()->exception(); |
| 4178 | 4174 |
| 4179 if (prev < subject_length) { | 4175 if (prev < subject_length) { |
| 4180 builder.EnsureCapacity(2); | 4176 builder.EnsureCapacity(2); |
| 4181 builder.AddSubjectSlice(prev, subject_length); | 4177 builder.AddSubjectSlice(prev, subject_length); |
| 4182 } | 4178 } |
| 4183 | 4179 |
| 4184 RegExpImpl::SetLastMatchInfo(last_match_info, | 4180 RegExpImpl::SetLastMatchInfo(last_match_info, |
| 4185 subject, | 4181 subject, |
| 4186 capture_count, | 4182 capture_count, |
| 4187 global_cache.LastSuccessfulMatch()); | 4183 global_cache.LastSuccessfulMatch()); |
| 4188 | 4184 |
| 4189 Handle<String> result; | 4185 Handle<String> result; |
| 4190 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, builder.ToString()); | 4186 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, builder.ToString()); |
| 4191 return *result; | 4187 return *result; |
| 4192 } | 4188 } |
| 4193 | 4189 |
| 4194 | 4190 |
| 4195 template <typename ResultSeqString> | 4191 template <typename ResultSeqString> |
| 4196 MUST_USE_RESULT static MaybeObject* StringReplaceGlobalRegExpWithEmptyString( | 4192 MUST_USE_RESULT static Object* StringReplaceGlobalRegExpWithEmptyString( |
| 4197 Isolate* isolate, | 4193 Isolate* isolate, |
| 4198 Handle<String> subject, | 4194 Handle<String> subject, |
| 4199 Handle<JSRegExp> regexp, | 4195 Handle<JSRegExp> regexp, |
| 4200 Handle<JSArray> last_match_info) { | 4196 Handle<JSArray> last_match_info) { |
| 4201 ASSERT(subject->IsFlat()); | 4197 ASSERT(subject->IsFlat()); |
| 4202 | 4198 |
| 4203 // Shortcut for simple non-regexp global replacements | 4199 // Shortcut for simple non-regexp global replacements |
| 4204 if (regexp->TypeTag() == JSRegExp::ATOM) { | 4200 if (regexp->TypeTag() == JSRegExp::ATOM) { |
| 4205 Handle<String> empty_string = isolate->factory()->empty_string(); | 4201 Handle<String> empty_string = isolate->factory()->empty_string(); |
| 4206 if (subject->IsOneByteRepresentation()) { | 4202 if (subject->IsOneByteRepresentation()) { |
| 4207 return StringReplaceGlobalAtomRegExpWithString<SeqOneByteString>( | 4203 return StringReplaceGlobalAtomRegExpWithString<SeqOneByteString>( |
| 4208 isolate, subject, regexp, empty_string, last_match_info); | 4204 isolate, subject, regexp, empty_string, last_match_info); |
| 4209 } else { | 4205 } else { |
| 4210 return StringReplaceGlobalAtomRegExpWithString<SeqTwoByteString>( | 4206 return StringReplaceGlobalAtomRegExpWithString<SeqTwoByteString>( |
| 4211 isolate, subject, regexp, empty_string, last_match_info); | 4207 isolate, subject, regexp, empty_string, last_match_info); |
| 4212 } | 4208 } |
| 4213 } | 4209 } |
| 4214 | 4210 |
| 4215 RegExpImpl::GlobalCache global_cache(regexp, subject, true, isolate); | 4211 RegExpImpl::GlobalCache global_cache(regexp, subject, true, isolate); |
| 4216 if (global_cache.HasException()) return Failure::Exception(); | 4212 if (global_cache.HasException()) return isolate->heap()->exception(); |
| 4217 | 4213 |
| 4218 int32_t* current_match = global_cache.FetchNext(); | 4214 int32_t* current_match = global_cache.FetchNext(); |
| 4219 if (current_match == NULL) { | 4215 if (current_match == NULL) { |
| 4220 if (global_cache.HasException()) return Failure::Exception(); | 4216 if (global_cache.HasException()) return isolate->heap()->exception(); |
| 4221 return *subject; | 4217 return *subject; |
| 4222 } | 4218 } |
| 4223 | 4219 |
| 4224 int start = current_match[0]; | 4220 int start = current_match[0]; |
| 4225 int end = current_match[1]; | 4221 int end = current_match[1]; |
| 4226 int capture_count = regexp->CaptureCount(); | 4222 int capture_count = regexp->CaptureCount(); |
| 4227 int subject_length = subject->length(); | 4223 int subject_length = subject->length(); |
| 4228 | 4224 |
| 4229 int new_length = subject_length - (end - start); | 4225 int new_length = subject_length - (end - start); |
| 4230 if (new_length == 0) return isolate->heap()->empty_string(); | 4226 if (new_length == 0) return isolate->heap()->empty_string(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 4247 if (prev < start) { | 4243 if (prev < start) { |
| 4248 // Add substring subject[prev;start] to answer string. | 4244 // Add substring subject[prev;start] to answer string. |
| 4249 String::WriteToFlat(*subject, answer->GetChars() + position, prev, start); | 4245 String::WriteToFlat(*subject, answer->GetChars() + position, prev, start); |
| 4250 position += start - prev; | 4246 position += start - prev; |
| 4251 } | 4247 } |
| 4252 prev = end; | 4248 prev = end; |
| 4253 | 4249 |
| 4254 current_match = global_cache.FetchNext(); | 4250 current_match = global_cache.FetchNext(); |
| 4255 } while (current_match != NULL); | 4251 } while (current_match != NULL); |
| 4256 | 4252 |
| 4257 if (global_cache.HasException()) return Failure::Exception(); | 4253 if (global_cache.HasException()) return isolate->heap()->exception(); |
| 4258 | 4254 |
| 4259 RegExpImpl::SetLastMatchInfo(last_match_info, | 4255 RegExpImpl::SetLastMatchInfo(last_match_info, |
| 4260 subject, | 4256 subject, |
| 4261 capture_count, | 4257 capture_count, |
| 4262 global_cache.LastSuccessfulMatch()); | 4258 global_cache.LastSuccessfulMatch()); |
| 4263 | 4259 |
| 4264 if (prev < subject_length) { | 4260 if (prev < subject_length) { |
| 4265 // Add substring subject[prev;length] to answer string. | 4261 // Add substring subject[prev;length] to answer string. |
| 4266 String::WriteToFlat( | 4262 String::WriteToFlat( |
| 4267 *subject, answer->GetChars() + position, prev, subject_length); | 4263 *subject, answer->GetChars() + position, prev, subject_length); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 4284 // The trimming is performed on a newly allocated object, which is on a | 4280 // The trimming is performed on a newly allocated object, which is on a |
| 4285 // fresly allocated page or on an already swept page. Hence, the sweeper | 4281 // fresly allocated page or on an already swept page. Hence, the sweeper |
| 4286 // thread can not get confused with the filler creation. No synchronization | 4282 // thread can not get confused with the filler creation. No synchronization |
| 4287 // needed. | 4283 // needed. |
| 4288 heap->CreateFillerObjectAt(end_of_string, delta); | 4284 heap->CreateFillerObjectAt(end_of_string, delta); |
| 4289 heap->AdjustLiveBytes(answer->address(), -delta, Heap::FROM_MUTATOR); | 4285 heap->AdjustLiveBytes(answer->address(), -delta, Heap::FROM_MUTATOR); |
| 4290 return *answer; | 4286 return *answer; |
| 4291 } | 4287 } |
| 4292 | 4288 |
| 4293 | 4289 |
| 4294 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringReplaceGlobalRegExpWithString) { | 4290 RUNTIME_FUNCTION(Runtime_StringReplaceGlobalRegExpWithString) { |
| 4295 HandleScope scope(isolate); | 4291 HandleScope scope(isolate); |
| 4296 ASSERT(args.length() == 4); | 4292 ASSERT(args.length() == 4); |
| 4297 | 4293 |
| 4298 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); | 4294 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); |
| 4299 CONVERT_ARG_HANDLE_CHECKED(String, replacement, 2); | 4295 CONVERT_ARG_HANDLE_CHECKED(String, replacement, 2); |
| 4300 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1); | 4296 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1); |
| 4301 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 3); | 4297 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 3); |
| 4302 | 4298 |
| 4303 ASSERT(regexp->GetFlags().is_global()); | 4299 ASSERT(regexp->GetFlags().is_global()); |
| 4304 | 4300 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4362 isolate, cons1, | 4358 isolate, cons1, |
| 4363 isolate->factory()->NewConsString(first, replace), | 4359 isolate->factory()->NewConsString(first, replace), |
| 4364 String); | 4360 String); |
| 4365 Handle<String> second = | 4361 Handle<String> second = |
| 4366 isolate->factory()->NewSubString(subject, index + 1, subject->length()); | 4362 isolate->factory()->NewSubString(subject, index + 1, subject->length()); |
| 4367 return isolate->factory()->NewConsString(cons1, second); | 4363 return isolate->factory()->NewConsString(cons1, second); |
| 4368 } | 4364 } |
| 4369 } | 4365 } |
| 4370 | 4366 |
| 4371 | 4367 |
| 4372 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringReplaceOneCharWithString) { | 4368 RUNTIME_FUNCTION(Runtime_StringReplaceOneCharWithString) { |
| 4373 HandleScope scope(isolate); | 4369 HandleScope scope(isolate); |
| 4374 ASSERT(args.length() == 3); | 4370 ASSERT(args.length() == 3); |
| 4375 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); | 4371 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); |
| 4376 CONVERT_ARG_HANDLE_CHECKED(String, search, 1); | 4372 CONVERT_ARG_HANDLE_CHECKED(String, search, 1); |
| 4377 CONVERT_ARG_HANDLE_CHECKED(String, replace, 2); | 4373 CONVERT_ARG_HANDLE_CHECKED(String, replace, 2); |
| 4378 | 4374 |
| 4379 // If the cons string tree is too deep, we simply abort the recursion and | 4375 // If the cons string tree is too deep, we simply abort the recursion and |
| 4380 // retry with a flattened subject string. | 4376 // retry with a flattened subject string. |
| 4381 const int kRecursionLimit = 0x1000; | 4377 const int kRecursionLimit = 0x1000; |
| 4382 bool found = false; | 4378 bool found = false; |
| 4383 Handle<String> result; | 4379 Handle<String> result; |
| 4384 if (StringReplaceOneCharWithString( | 4380 if (StringReplaceOneCharWithString( |
| 4385 isolate, subject, search, replace, &found, kRecursionLimit) | 4381 isolate, subject, search, replace, &found, kRecursionLimit) |
| 4386 .ToHandle(&result)) { | 4382 .ToHandle(&result)) { |
| 4387 return *result; | 4383 return *result; |
| 4388 } | 4384 } |
| 4389 if (isolate->has_pending_exception()) return Failure::Exception(); | 4385 if (isolate->has_pending_exception()) return isolate->heap()->exception(); |
| 4390 | 4386 |
| 4391 subject = String::Flatten(subject); | 4387 subject = String::Flatten(subject); |
| 4392 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 4388 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 4393 isolate, result, | 4389 isolate, result, |
| 4394 StringReplaceOneCharWithString( | 4390 StringReplaceOneCharWithString( |
| 4395 isolate, subject, search, replace, &found, kRecursionLimit)); | 4391 isolate, subject, search, replace, &found, kRecursionLimit)); |
| 4396 return *result; | 4392 return *result; |
| 4397 } | 4393 } |
| 4398 | 4394 |
| 4399 | 4395 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4442 pat_vector, | 4438 pat_vector, |
| 4443 start_index); | 4439 start_index); |
| 4444 } | 4440 } |
| 4445 return SearchString(isolate, | 4441 return SearchString(isolate, |
| 4446 seq_sub.ToUC16Vector(), | 4442 seq_sub.ToUC16Vector(), |
| 4447 pat_vector, | 4443 pat_vector, |
| 4448 start_index); | 4444 start_index); |
| 4449 } | 4445 } |
| 4450 | 4446 |
| 4451 | 4447 |
| 4452 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringIndexOf) { | 4448 RUNTIME_FUNCTION(Runtime_StringIndexOf) { |
| 4453 HandleScope scope(isolate); | 4449 HandleScope scope(isolate); |
| 4454 ASSERT(args.length() == 3); | 4450 ASSERT(args.length() == 3); |
| 4455 | 4451 |
| 4456 CONVERT_ARG_HANDLE_CHECKED(String, sub, 0); | 4452 CONVERT_ARG_HANDLE_CHECKED(String, sub, 0); |
| 4457 CONVERT_ARG_HANDLE_CHECKED(String, pat, 1); | 4453 CONVERT_ARG_HANDLE_CHECKED(String, pat, 1); |
| 4458 CONVERT_ARG_HANDLE_CHECKED(Object, index, 2); | 4454 CONVERT_ARG_HANDLE_CHECKED(Object, index, 2); |
| 4459 | 4455 |
| 4460 uint32_t start_index; | 4456 uint32_t start_index; |
| 4461 if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1); | 4457 if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1); |
| 4462 | 4458 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4494 j++; | 4490 j++; |
| 4495 } | 4491 } |
| 4496 if (j == pattern_length) { | 4492 if (j == pattern_length) { |
| 4497 return i; | 4493 return i; |
| 4498 } | 4494 } |
| 4499 } | 4495 } |
| 4500 return -1; | 4496 return -1; |
| 4501 } | 4497 } |
| 4502 | 4498 |
| 4503 | 4499 |
| 4504 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringLastIndexOf) { | 4500 RUNTIME_FUNCTION(Runtime_StringLastIndexOf) { |
| 4505 HandleScope scope(isolate); | 4501 HandleScope scope(isolate); |
| 4506 ASSERT(args.length() == 3); | 4502 ASSERT(args.length() == 3); |
| 4507 | 4503 |
| 4508 CONVERT_ARG_HANDLE_CHECKED(String, sub, 0); | 4504 CONVERT_ARG_HANDLE_CHECKED(String, sub, 0); |
| 4509 CONVERT_ARG_HANDLE_CHECKED(String, pat, 1); | 4505 CONVERT_ARG_HANDLE_CHECKED(String, pat, 1); |
| 4510 CONVERT_ARG_HANDLE_CHECKED(Object, index, 2); | 4506 CONVERT_ARG_HANDLE_CHECKED(Object, index, 2); |
| 4511 | 4507 |
| 4512 uint32_t start_index; | 4508 uint32_t start_index; |
| 4513 if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1); | 4509 if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1); |
| 4514 | 4510 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4553 position = StringMatchBackwards(sub_content.ToUC16Vector(), | 4549 position = StringMatchBackwards(sub_content.ToUC16Vector(), |
| 4554 pat_vector, | 4550 pat_vector, |
| 4555 start_index); | 4551 start_index); |
| 4556 } | 4552 } |
| 4557 } | 4553 } |
| 4558 | 4554 |
| 4559 return Smi::FromInt(position); | 4555 return Smi::FromInt(position); |
| 4560 } | 4556 } |
| 4561 | 4557 |
| 4562 | 4558 |
| 4563 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringLocaleCompare) { | 4559 RUNTIME_FUNCTION(Runtime_StringLocaleCompare) { |
| 4564 HandleScope handle_scope(isolate); | 4560 HandleScope handle_scope(isolate); |
| 4565 ASSERT(args.length() == 2); | 4561 ASSERT(args.length() == 2); |
| 4566 | 4562 |
| 4567 CONVERT_ARG_HANDLE_CHECKED(String, str1, 0); | 4563 CONVERT_ARG_HANDLE_CHECKED(String, str1, 0); |
| 4568 CONVERT_ARG_HANDLE_CHECKED(String, str2, 1); | 4564 CONVERT_ARG_HANDLE_CHECKED(String, str2, 1); |
| 4569 | 4565 |
| 4570 if (str1.is_identical_to(str2)) return Smi::FromInt(0); // Equal. | 4566 if (str1.is_identical_to(str2)) return Smi::FromInt(0); // Equal. |
| 4571 int str1_length = str1->length(); | 4567 int str1_length = str1->length(); |
| 4572 int str2_length = str2->length(); | 4568 int str2_length = str2->length(); |
| 4573 | 4569 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 4597 for (int i = 0; i < end; i++) { | 4593 for (int i = 0; i < end; i++) { |
| 4598 if (flat1.Get(i) != flat2.Get(i)) { | 4594 if (flat1.Get(i) != flat2.Get(i)) { |
| 4599 return Smi::FromInt(flat1.Get(i) - flat2.Get(i)); | 4595 return Smi::FromInt(flat1.Get(i) - flat2.Get(i)); |
| 4600 } | 4596 } |
| 4601 } | 4597 } |
| 4602 | 4598 |
| 4603 return Smi::FromInt(str1_length - str2_length); | 4599 return Smi::FromInt(str1_length - str2_length); |
| 4604 } | 4600 } |
| 4605 | 4601 |
| 4606 | 4602 |
| 4607 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_SubString) { | 4603 RUNTIME_FUNCTION(RuntimeHidden_SubString) { |
| 4608 HandleScope scope(isolate); | 4604 HandleScope scope(isolate); |
| 4609 ASSERT(args.length() == 3); | 4605 ASSERT(args.length() == 3); |
| 4610 | 4606 |
| 4611 CONVERT_ARG_HANDLE_CHECKED(String, string, 0); | 4607 CONVERT_ARG_HANDLE_CHECKED(String, string, 0); |
| 4612 int start, end; | 4608 int start, end; |
| 4613 // We have a fast integer-only case here to avoid a conversion to double in | 4609 // We have a fast integer-only case here to avoid a conversion to double in |
| 4614 // the common case where from and to are Smis. | 4610 // the common case where from and to are Smis. |
| 4615 if (args[1]->IsSmi() && args[2]->IsSmi()) { | 4611 if (args[1]->IsSmi() && args[2]->IsSmi()) { |
| 4616 CONVERT_SMI_ARG_CHECKED(from_number, 1); | 4612 CONVERT_SMI_ARG_CHECKED(from_number, 1); |
| 4617 CONVERT_SMI_ARG_CHECKED(to_number, 2); | 4613 CONVERT_SMI_ARG_CHECKED(to_number, 2); |
| 4618 start = from_number; | 4614 start = from_number; |
| 4619 end = to_number; | 4615 end = to_number; |
| 4620 } else { | 4616 } else { |
| 4621 CONVERT_DOUBLE_ARG_CHECKED(from_number, 1); | 4617 CONVERT_DOUBLE_ARG_CHECKED(from_number, 1); |
| 4622 CONVERT_DOUBLE_ARG_CHECKED(to_number, 2); | 4618 CONVERT_DOUBLE_ARG_CHECKED(to_number, 2); |
| 4623 start = FastD2IChecked(from_number); | 4619 start = FastD2IChecked(from_number); |
| 4624 end = FastD2IChecked(to_number); | 4620 end = FastD2IChecked(to_number); |
| 4625 } | 4621 } |
| 4626 RUNTIME_ASSERT(end >= start); | 4622 RUNTIME_ASSERT(end >= start); |
| 4627 RUNTIME_ASSERT(start >= 0); | 4623 RUNTIME_ASSERT(start >= 0); |
| 4628 RUNTIME_ASSERT(end <= string->length()); | 4624 RUNTIME_ASSERT(end <= string->length()); |
| 4629 isolate->counters()->sub_string_runtime()->Increment(); | 4625 isolate->counters()->sub_string_runtime()->Increment(); |
| 4630 | 4626 |
| 4631 return *isolate->factory()->NewSubString(string, start, end); | 4627 return *isolate->factory()->NewSubString(string, start, end); |
| 4632 } | 4628 } |
| 4633 | 4629 |
| 4634 | 4630 |
| 4635 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringMatch) { | 4631 RUNTIME_FUNCTION(Runtime_StringMatch) { |
| 4636 HandleScope handles(isolate); | 4632 HandleScope handles(isolate); |
| 4637 ASSERT(args.length() == 3); | 4633 ASSERT(args.length() == 3); |
| 4638 | 4634 |
| 4639 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); | 4635 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); |
| 4640 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1); | 4636 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1); |
| 4641 CONVERT_ARG_HANDLE_CHECKED(JSArray, regexp_info, 2); | 4637 CONVERT_ARG_HANDLE_CHECKED(JSArray, regexp_info, 2); |
| 4642 | 4638 |
| 4643 RegExpImpl::GlobalCache global_cache(regexp, subject, true, isolate); | 4639 RegExpImpl::GlobalCache global_cache(regexp, subject, true, isolate); |
| 4644 if (global_cache.HasException()) return Failure::Exception(); | 4640 if (global_cache.HasException()) return isolate->heap()->exception(); |
| 4645 | 4641 |
| 4646 int capture_count = regexp->CaptureCount(); | 4642 int capture_count = regexp->CaptureCount(); |
| 4647 | 4643 |
| 4648 ZoneScope zone_scope(isolate->runtime_zone()); | 4644 ZoneScope zone_scope(isolate->runtime_zone()); |
| 4649 ZoneList<int> offsets(8, zone_scope.zone()); | 4645 ZoneList<int> offsets(8, zone_scope.zone()); |
| 4650 | 4646 |
| 4651 while (true) { | 4647 while (true) { |
| 4652 int32_t* match = global_cache.FetchNext(); | 4648 int32_t* match = global_cache.FetchNext(); |
| 4653 if (match == NULL) break; | 4649 if (match == NULL) break; |
| 4654 offsets.Add(match[0], zone_scope.zone()); // start | 4650 offsets.Add(match[0], zone_scope.zone()); // start |
| 4655 offsets.Add(match[1], zone_scope.zone()); // end | 4651 offsets.Add(match[1], zone_scope.zone()); // end |
| 4656 } | 4652 } |
| 4657 | 4653 |
| 4658 if (global_cache.HasException()) return Failure::Exception(); | 4654 if (global_cache.HasException()) return isolate->heap()->exception(); |
| 4659 | 4655 |
| 4660 if (offsets.length() == 0) { | 4656 if (offsets.length() == 0) { |
| 4661 // Not a single match. | 4657 // Not a single match. |
| 4662 return isolate->heap()->null_value(); | 4658 return isolate->heap()->null_value(); |
| 4663 } | 4659 } |
| 4664 | 4660 |
| 4665 RegExpImpl::SetLastMatchInfo(regexp_info, | 4661 RegExpImpl::SetLastMatchInfo(regexp_info, |
| 4666 subject, | 4662 subject, |
| 4667 capture_count, | 4663 capture_count, |
| 4668 global_cache.LastSuccessfulMatch()); | 4664 global_cache.LastSuccessfulMatch()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 4682 } | 4678 } |
| 4683 Handle<JSArray> result = isolate->factory()->NewJSArrayWithElements(elements); | 4679 Handle<JSArray> result = isolate->factory()->NewJSArrayWithElements(elements); |
| 4684 result->set_length(Smi::FromInt(matches)); | 4680 result->set_length(Smi::FromInt(matches)); |
| 4685 return *result; | 4681 return *result; |
| 4686 } | 4682 } |
| 4687 | 4683 |
| 4688 | 4684 |
| 4689 // Only called from Runtime_RegExpExecMultiple so it doesn't need to maintain | 4685 // Only called from Runtime_RegExpExecMultiple so it doesn't need to maintain |
| 4690 // separate last match info. See comment on that function. | 4686 // separate last match info. See comment on that function. |
| 4691 template<bool has_capture> | 4687 template<bool has_capture> |
| 4692 static MaybeObject* SearchRegExpMultiple( | 4688 static Object* SearchRegExpMultiple( |
| 4693 Isolate* isolate, | 4689 Isolate* isolate, |
| 4694 Handle<String> subject, | 4690 Handle<String> subject, |
| 4695 Handle<JSRegExp> regexp, | 4691 Handle<JSRegExp> regexp, |
| 4696 Handle<JSArray> last_match_array, | 4692 Handle<JSArray> last_match_array, |
| 4697 Handle<JSArray> result_array) { | 4693 Handle<JSArray> result_array) { |
| 4698 ASSERT(subject->IsFlat()); | 4694 ASSERT(subject->IsFlat()); |
| 4699 ASSERT_NE(has_capture, regexp->CaptureCount() == 0); | 4695 ASSERT_NE(has_capture, regexp->CaptureCount() == 0); |
| 4700 | 4696 |
| 4701 int capture_count = regexp->CaptureCount(); | 4697 int capture_count = regexp->CaptureCount(); |
| 4702 int subject_length = subject->length(); | 4698 int subject_length = subject->length(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 4720 cached_fixed_array->get(cached_fixed_array->length() - 1); | 4716 cached_fixed_array->get(cached_fixed_array->length() - 1); |
| 4721 Smi* js_array_length = Smi::cast(cached_fixed_array_last_element); | 4717 Smi* js_array_length = Smi::cast(cached_fixed_array_last_element); |
| 4722 result_array->set_length(js_array_length); | 4718 result_array->set_length(js_array_length); |
| 4723 RegExpImpl::SetLastMatchInfo( | 4719 RegExpImpl::SetLastMatchInfo( |
| 4724 last_match_array, subject, capture_count, NULL); | 4720 last_match_array, subject, capture_count, NULL); |
| 4725 return *result_array; | 4721 return *result_array; |
| 4726 } | 4722 } |
| 4727 } | 4723 } |
| 4728 | 4724 |
| 4729 RegExpImpl::GlobalCache global_cache(regexp, subject, true, isolate); | 4725 RegExpImpl::GlobalCache global_cache(regexp, subject, true, isolate); |
| 4730 if (global_cache.HasException()) return Failure::Exception(); | 4726 if (global_cache.HasException()) return isolate->heap()->exception(); |
| 4731 | 4727 |
| 4732 Handle<FixedArray> result_elements; | 4728 Handle<FixedArray> result_elements; |
| 4733 if (result_array->HasFastObjectElements()) { | 4729 if (result_array->HasFastObjectElements()) { |
| 4734 result_elements = | 4730 result_elements = |
| 4735 Handle<FixedArray>(FixedArray::cast(result_array->elements())); | 4731 Handle<FixedArray>(FixedArray::cast(result_array->elements())); |
| 4736 } | 4732 } |
| 4737 if (result_elements.is_null() || result_elements->length() < 16) { | 4733 if (result_elements.is_null() || result_elements->length() < 16) { |
| 4738 result_elements = isolate->factory()->NewFixedArrayWithHoles(16); | 4734 result_elements = isolate->factory()->NewFixedArrayWithHoles(16); |
| 4739 } | 4735 } |
| 4740 | 4736 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4796 } | 4792 } |
| 4797 elements->set(capture_count + 1, Smi::FromInt(match_start)); | 4793 elements->set(capture_count + 1, Smi::FromInt(match_start)); |
| 4798 elements->set(capture_count + 2, *subject); | 4794 elements->set(capture_count + 2, *subject); |
| 4799 builder.Add(*isolate->factory()->NewJSArrayWithElements(elements)); | 4795 builder.Add(*isolate->factory()->NewJSArrayWithElements(elements)); |
| 4800 } else { | 4796 } else { |
| 4801 builder.Add(*match); | 4797 builder.Add(*match); |
| 4802 } | 4798 } |
| 4803 } | 4799 } |
| 4804 } | 4800 } |
| 4805 | 4801 |
| 4806 if (global_cache.HasException()) return Failure::Exception(); | 4802 if (global_cache.HasException()) return isolate->heap()->exception(); |
| 4807 | 4803 |
| 4808 if (match_start >= 0) { | 4804 if (match_start >= 0) { |
| 4809 // Finished matching, with at least one match. | 4805 // Finished matching, with at least one match. |
| 4810 if (match_end < subject_length) { | 4806 if (match_end < subject_length) { |
| 4811 ReplacementStringBuilder::AddSubjectSlice(&builder, | 4807 ReplacementStringBuilder::AddSubjectSlice(&builder, |
| 4812 match_end, | 4808 match_end, |
| 4813 subject_length); | 4809 subject_length); |
| 4814 } | 4810 } |
| 4815 | 4811 |
| 4816 RegExpImpl::SetLastMatchInfo( | 4812 RegExpImpl::SetLastMatchInfo( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 4833 return *builder.ToJSArray(result_array); | 4829 return *builder.ToJSArray(result_array); |
| 4834 } else { | 4830 } else { |
| 4835 return isolate->heap()->null_value(); // No matches at all. | 4831 return isolate->heap()->null_value(); // No matches at all. |
| 4836 } | 4832 } |
| 4837 } | 4833 } |
| 4838 | 4834 |
| 4839 | 4835 |
| 4840 // This is only called for StringReplaceGlobalRegExpWithFunction. This sets | 4836 // This is only called for StringReplaceGlobalRegExpWithFunction. This sets |
| 4841 // lastMatchInfoOverride to maintain the last match info, so we don't need to | 4837 // lastMatchInfoOverride to maintain the last match info, so we don't need to |
| 4842 // set any other last match array info. | 4838 // set any other last match array info. |
| 4843 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpExecMultiple) { | 4839 RUNTIME_FUNCTION(Runtime_RegExpExecMultiple) { |
| 4844 HandleScope handles(isolate); | 4840 HandleScope handles(isolate); |
| 4845 ASSERT(args.length() == 4); | 4841 ASSERT(args.length() == 4); |
| 4846 | 4842 |
| 4847 CONVERT_ARG_HANDLE_CHECKED(String, subject, 1); | 4843 CONVERT_ARG_HANDLE_CHECKED(String, subject, 1); |
| 4848 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0); | 4844 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0); |
| 4849 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 2); | 4845 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 2); |
| 4850 CONVERT_ARG_HANDLE_CHECKED(JSArray, result_array, 3); | 4846 CONVERT_ARG_HANDLE_CHECKED(JSArray, result_array, 3); |
| 4851 | 4847 |
| 4852 subject = String::Flatten(subject); | 4848 subject = String::Flatten(subject); |
| 4853 ASSERT(regexp->GetFlags().is_global()); | 4849 ASSERT(regexp->GetFlags().is_global()); |
| 4854 | 4850 |
| 4855 if (regexp->CaptureCount() == 0) { | 4851 if (regexp->CaptureCount() == 0) { |
| 4856 return SearchRegExpMultiple<false>( | 4852 return SearchRegExpMultiple<false>( |
| 4857 isolate, subject, regexp, last_match_info, result_array); | 4853 isolate, subject, regexp, last_match_info, result_array); |
| 4858 } else { | 4854 } else { |
| 4859 return SearchRegExpMultiple<true>( | 4855 return SearchRegExpMultiple<true>( |
| 4860 isolate, subject, regexp, last_match_info, result_array); | 4856 isolate, subject, regexp, last_match_info, result_array); |
| 4861 } | 4857 } |
| 4862 } | 4858 } |
| 4863 | 4859 |
| 4864 | 4860 |
| 4865 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToRadixString) { | 4861 RUNTIME_FUNCTION(Runtime_NumberToRadixString) { |
| 4866 HandleScope scope(isolate); | 4862 HandleScope scope(isolate); |
| 4867 ASSERT(args.length() == 2); | 4863 ASSERT(args.length() == 2); |
| 4868 CONVERT_SMI_ARG_CHECKED(radix, 1); | 4864 CONVERT_SMI_ARG_CHECKED(radix, 1); |
| 4869 RUNTIME_ASSERT(2 <= radix && radix <= 36); | 4865 RUNTIME_ASSERT(2 <= radix && radix <= 36); |
| 4870 | 4866 |
| 4871 // Fast case where the result is a one character string. | 4867 // Fast case where the result is a one character string. |
| 4872 if (args[0]->IsSmi()) { | 4868 if (args[0]->IsSmi()) { |
| 4873 int value = args.smi_at(0); | 4869 int value = args.smi_at(0); |
| 4874 if (value >= 0 && value < radix) { | 4870 if (value >= 0 && value < radix) { |
| 4875 // Character array used for conversion. | 4871 // Character array used for conversion. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 4890 } | 4886 } |
| 4891 return isolate->heap()->infinity_string(); | 4887 return isolate->heap()->infinity_string(); |
| 4892 } | 4888 } |
| 4893 char* str = DoubleToRadixCString(value, radix); | 4889 char* str = DoubleToRadixCString(value, radix); |
| 4894 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); | 4890 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); |
| 4895 DeleteArray(str); | 4891 DeleteArray(str); |
| 4896 return *result; | 4892 return *result; |
| 4897 } | 4893 } |
| 4898 | 4894 |
| 4899 | 4895 |
| 4900 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToFixed) { | 4896 RUNTIME_FUNCTION(Runtime_NumberToFixed) { |
| 4901 HandleScope scope(isolate); | 4897 HandleScope scope(isolate); |
| 4902 ASSERT(args.length() == 2); | 4898 ASSERT(args.length() == 2); |
| 4903 | 4899 |
| 4904 CONVERT_DOUBLE_ARG_CHECKED(value, 0); | 4900 CONVERT_DOUBLE_ARG_CHECKED(value, 0); |
| 4905 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); | 4901 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); |
| 4906 int f = FastD2IChecked(f_number); | 4902 int f = FastD2IChecked(f_number); |
| 4907 RUNTIME_ASSERT(f >= 0); | 4903 RUNTIME_ASSERT(f >= 0); |
| 4908 char* str = DoubleToFixedCString(value, f); | 4904 char* str = DoubleToFixedCString(value, f); |
| 4909 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); | 4905 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); |
| 4910 DeleteArray(str); | 4906 DeleteArray(str); |
| 4911 return *result; | 4907 return *result; |
| 4912 } | 4908 } |
| 4913 | 4909 |
| 4914 | 4910 |
| 4915 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToExponential) { | 4911 RUNTIME_FUNCTION(Runtime_NumberToExponential) { |
| 4916 HandleScope scope(isolate); | 4912 HandleScope scope(isolate); |
| 4917 ASSERT(args.length() == 2); | 4913 ASSERT(args.length() == 2); |
| 4918 | 4914 |
| 4919 CONVERT_DOUBLE_ARG_CHECKED(value, 0); | 4915 CONVERT_DOUBLE_ARG_CHECKED(value, 0); |
| 4920 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); | 4916 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); |
| 4921 int f = FastD2IChecked(f_number); | 4917 int f = FastD2IChecked(f_number); |
| 4922 RUNTIME_ASSERT(f >= -1 && f <= 20); | 4918 RUNTIME_ASSERT(f >= -1 && f <= 20); |
| 4923 char* str = DoubleToExponentialCString(value, f); | 4919 char* str = DoubleToExponentialCString(value, f); |
| 4924 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); | 4920 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); |
| 4925 DeleteArray(str); | 4921 DeleteArray(str); |
| 4926 return *result; | 4922 return *result; |
| 4927 } | 4923 } |
| 4928 | 4924 |
| 4929 | 4925 |
| 4930 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToPrecision) { | 4926 RUNTIME_FUNCTION(Runtime_NumberToPrecision) { |
| 4931 HandleScope scope(isolate); | 4927 HandleScope scope(isolate); |
| 4932 ASSERT(args.length() == 2); | 4928 ASSERT(args.length() == 2); |
| 4933 | 4929 |
| 4934 CONVERT_DOUBLE_ARG_CHECKED(value, 0); | 4930 CONVERT_DOUBLE_ARG_CHECKED(value, 0); |
| 4935 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); | 4931 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); |
| 4936 int f = FastD2IChecked(f_number); | 4932 int f = FastD2IChecked(f_number); |
| 4937 RUNTIME_ASSERT(f >= 1 && f <= 21); | 4933 RUNTIME_ASSERT(f >= 1 && f <= 21); |
| 4938 char* str = DoubleToPrecisionCString(value, f); | 4934 char* str = DoubleToPrecisionCString(value, f); |
| 4939 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); | 4935 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); |
| 4940 DeleteArray(str); | 4936 DeleteArray(str); |
| 4941 return *result; | 4937 return *result; |
| 4942 } | 4938 } |
| 4943 | 4939 |
| 4944 | 4940 |
| 4945 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsValidSmi) { | 4941 RUNTIME_FUNCTION(Runtime_IsValidSmi) { |
| 4946 SealHandleScope shs(isolate); | 4942 SealHandleScope shs(isolate); |
| 4947 ASSERT(args.length() == 1); | 4943 ASSERT(args.length() == 1); |
| 4948 | 4944 |
| 4949 CONVERT_NUMBER_CHECKED(int32_t, number, Int32, args[0]); | 4945 CONVERT_NUMBER_CHECKED(int32_t, number, Int32, args[0]); |
| 4950 return isolate->heap()->ToBoolean(Smi::IsValid(number)); | 4946 return isolate->heap()->ToBoolean(Smi::IsValid(number)); |
| 4951 } | 4947 } |
| 4952 | 4948 |
| 4953 | 4949 |
| 4954 // Returns a single character string where first character equals | 4950 // Returns a single character string where first character equals |
| 4955 // string->Get(index). | 4951 // string->Get(index). |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5043 // Check if the name is trivially convertible to an index and get | 5039 // Check if the name is trivially convertible to an index and get |
| 5044 // the element if so. | 5040 // the element if so. |
| 5045 if (name->AsArrayIndex(&index)) { | 5041 if (name->AsArrayIndex(&index)) { |
| 5046 return GetElementOrCharAt(isolate, object, index); | 5042 return GetElementOrCharAt(isolate, object, index); |
| 5047 } else { | 5043 } else { |
| 5048 return Object::GetProperty(object, name); | 5044 return Object::GetProperty(object, name); |
| 5049 } | 5045 } |
| 5050 } | 5046 } |
| 5051 | 5047 |
| 5052 | 5048 |
| 5053 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetProperty) { | 5049 RUNTIME_FUNCTION(Runtime_GetProperty) { |
| 5054 HandleScope scope(isolate); | 5050 HandleScope scope(isolate); |
| 5055 ASSERT(args.length() == 2); | 5051 ASSERT(args.length() == 2); |
| 5056 | 5052 |
| 5057 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 5053 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
| 5058 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 5054 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
| 5059 Handle<Object> result; | 5055 Handle<Object> result; |
| 5060 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 5056 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 5061 isolate, result, | 5057 isolate, result, |
| 5062 Runtime::GetObjectProperty(isolate, object, key)); | 5058 Runtime::GetObjectProperty(isolate, object, key)); |
| 5063 return *result; | 5059 return *result; |
| 5064 } | 5060 } |
| 5065 | 5061 |
| 5066 | 5062 |
| 5067 // KeyedGetProperty is called from KeyedLoadIC::GenerateGeneric. | 5063 // KeyedGetProperty is called from KeyedLoadIC::GenerateGeneric. |
| 5068 RUNTIME_FUNCTION(MaybeObject*, Runtime_KeyedGetProperty) { | 5064 RUNTIME_FUNCTION(Runtime_KeyedGetProperty) { |
| 5069 SealHandleScope shs(isolate); | 5065 SealHandleScope shs(isolate); |
| 5070 ASSERT(args.length() == 2); | 5066 ASSERT(args.length() == 2); |
| 5071 | 5067 |
| 5072 // Fast cases for getting named properties of the receiver JSObject | 5068 // Fast cases for getting named properties of the receiver JSObject |
| 5073 // itself. | 5069 // itself. |
| 5074 // | 5070 // |
| 5075 // The global proxy objects has to be excluded since LocalLookup on | 5071 // The global proxy objects has to be excluded since LocalLookup on |
| 5076 // the global proxy object can return a valid result even though the | 5072 // the global proxy object can return a valid result even though the |
| 5077 // global proxy object never has properties. This is the case | 5073 // global proxy object never has properties. This is the case |
| 5078 // because the global proxy object forwards everything to its hidden | 5074 // because the global proxy object forwards everything to its hidden |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5175 return obj->IsUndefined() || obj->IsSpecFunction() || obj->IsNull(); | 5171 return obj->IsUndefined() || obj->IsSpecFunction() || obj->IsNull(); |
| 5176 } | 5172 } |
| 5177 | 5173 |
| 5178 | 5174 |
| 5179 // Implements part of 8.12.9 DefineOwnProperty. | 5175 // Implements part of 8.12.9 DefineOwnProperty. |
| 5180 // There are 3 cases that lead here: | 5176 // There are 3 cases that lead here: |
| 5181 // Step 4b - define a new accessor property. | 5177 // Step 4b - define a new accessor property. |
| 5182 // Steps 9c & 12 - replace an existing data property with an accessor property. | 5178 // Steps 9c & 12 - replace an existing data property with an accessor property. |
| 5183 // Step 12 - update an existing accessor property with an accessor or generic | 5179 // Step 12 - update an existing accessor property with an accessor or generic |
| 5184 // descriptor. | 5180 // descriptor. |
| 5185 RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineAccessorProperty) { | 5181 RUNTIME_FUNCTION(Runtime_DefineOrRedefineAccessorProperty) { |
| 5186 HandleScope scope(isolate); | 5182 HandleScope scope(isolate); |
| 5187 ASSERT(args.length() == 5); | 5183 ASSERT(args.length() == 5); |
| 5188 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 5184 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
| 5189 RUNTIME_ASSERT(!obj->IsNull()); | 5185 RUNTIME_ASSERT(!obj->IsNull()); |
| 5190 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 5186 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
| 5191 CONVERT_ARG_HANDLE_CHECKED(Object, getter, 2); | 5187 CONVERT_ARG_HANDLE_CHECKED(Object, getter, 2); |
| 5192 RUNTIME_ASSERT(IsValidAccessor(getter)); | 5188 RUNTIME_ASSERT(IsValidAccessor(getter)); |
| 5193 CONVERT_ARG_HANDLE_CHECKED(Object, setter, 3); | 5189 CONVERT_ARG_HANDLE_CHECKED(Object, setter, 3); |
| 5194 RUNTIME_ASSERT(IsValidAccessor(setter)); | 5190 RUNTIME_ASSERT(IsValidAccessor(setter)); |
| 5195 CONVERT_SMI_ARG_CHECKED(unchecked, 4); | 5191 CONVERT_SMI_ARG_CHECKED(unchecked, 4); |
| 5196 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | 5192 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
| 5197 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked); | 5193 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked); |
| 5198 | 5194 |
| 5199 bool fast = obj->HasFastProperties(); | 5195 bool fast = obj->HasFastProperties(); |
| 5200 JSObject::DefineAccessor(obj, name, getter, setter, attr); | 5196 JSObject::DefineAccessor(obj, name, getter, setter, attr); |
| 5201 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 5197 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
| 5202 if (fast) JSObject::TransformToFastProperties(obj, 0); | 5198 if (fast) JSObject::TransformToFastProperties(obj, 0); |
| 5203 return isolate->heap()->undefined_value(); | 5199 return isolate->heap()->undefined_value(); |
| 5204 } | 5200 } |
| 5205 | 5201 |
| 5206 | 5202 |
| 5207 // Implements part of 8.12.9 DefineOwnProperty. | 5203 // Implements part of 8.12.9 DefineOwnProperty. |
| 5208 // There are 3 cases that lead here: | 5204 // There are 3 cases that lead here: |
| 5209 // Step 4a - define a new data property. | 5205 // Step 4a - define a new data property. |
| 5210 // Steps 9b & 12 - replace an existing accessor property with a data property. | 5206 // Steps 9b & 12 - replace an existing accessor property with a data property. |
| 5211 // Step 12 - update an existing data property with a data or generic | 5207 // Step 12 - update an existing data property with a data or generic |
| 5212 // descriptor. | 5208 // descriptor. |
| 5213 RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineDataProperty) { | 5209 RUNTIME_FUNCTION(Runtime_DefineOrRedefineDataProperty) { |
| 5214 HandleScope scope(isolate); | 5210 HandleScope scope(isolate); |
| 5215 ASSERT(args.length() == 4); | 5211 ASSERT(args.length() == 4); |
| 5216 CONVERT_ARG_HANDLE_CHECKED(JSObject, js_object, 0); | 5212 CONVERT_ARG_HANDLE_CHECKED(JSObject, js_object, 0); |
| 5217 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 5213 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
| 5218 CONVERT_ARG_HANDLE_CHECKED(Object, obj_value, 2); | 5214 CONVERT_ARG_HANDLE_CHECKED(Object, obj_value, 2); |
| 5219 CONVERT_SMI_ARG_CHECKED(unchecked, 3); | 5215 CONVERT_SMI_ARG_CHECKED(unchecked, 3); |
| 5220 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | 5216 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
| 5221 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked); | 5217 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked); |
| 5222 | 5218 |
| 5223 LookupResult lookup(isolate); | 5219 LookupResult lookup(isolate); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5277 | 5273 |
| 5278 Handle<Object> result; | 5274 Handle<Object> result; |
| 5279 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 5275 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 5280 isolate, result, | 5276 isolate, result, |
| 5281 Runtime::ForceSetObjectProperty(js_object, name, obj_value, attr)); | 5277 Runtime::ForceSetObjectProperty(js_object, name, obj_value, attr)); |
| 5282 return *result; | 5278 return *result; |
| 5283 } | 5279 } |
| 5284 | 5280 |
| 5285 | 5281 |
| 5286 // Return property without being observable by accessors or interceptors. | 5282 // Return property without being observable by accessors or interceptors. |
| 5287 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDataProperty) { | 5283 RUNTIME_FUNCTION(Runtime_GetDataProperty) { |
| 5288 HandleScope scope(isolate); | 5284 HandleScope scope(isolate); |
| 5289 ASSERT(args.length() == 2); | 5285 ASSERT(args.length() == 2); |
| 5290 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 5286 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
| 5291 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); | 5287 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); |
| 5292 return *JSObject::GetDataProperty(object, key); | 5288 return *JSObject::GetDataProperty(object, key); |
| 5293 } | 5289 } |
| 5294 | 5290 |
| 5295 | 5291 |
| 5296 MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate, | 5292 MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate, |
| 5297 Handle<Object> object, | 5293 Handle<Object> object, |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5470 ASSIGN_RETURN_ON_EXCEPTION( | 5466 ASSIGN_RETURN_ON_EXCEPTION( |
| 5471 isolate, converted, Execution::ToString(isolate, key), Object); | 5467 isolate, converted, Execution::ToString(isolate, key), Object); |
| 5472 name = Handle<String>::cast(converted); | 5468 name = Handle<String>::cast(converted); |
| 5473 } | 5469 } |
| 5474 | 5470 |
| 5475 if (name->IsString()) name = String::Flatten(Handle<String>::cast(name)); | 5471 if (name->IsString()) name = String::Flatten(Handle<String>::cast(name)); |
| 5476 return JSReceiver::DeleteProperty(receiver, name, mode); | 5472 return JSReceiver::DeleteProperty(receiver, name, mode); |
| 5477 } | 5473 } |
| 5478 | 5474 |
| 5479 | 5475 |
| 5480 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetHiddenProperty) { | 5476 RUNTIME_FUNCTION(Runtime_SetHiddenProperty) { |
| 5481 HandleScope scope(isolate); | 5477 HandleScope scope(isolate); |
| 5482 RUNTIME_ASSERT(args.length() == 3); | 5478 RUNTIME_ASSERT(args.length() == 3); |
| 5483 | 5479 |
| 5484 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 5480 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
| 5485 CONVERT_ARG_HANDLE_CHECKED(String, key, 1); | 5481 CONVERT_ARG_HANDLE_CHECKED(String, key, 1); |
| 5486 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | 5482 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
| 5487 return *JSObject::SetHiddenProperty(object, key, value); | 5483 return *JSObject::SetHiddenProperty(object, key, value); |
| 5488 } | 5484 } |
| 5489 | 5485 |
| 5490 | 5486 |
| 5491 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetProperty) { | 5487 RUNTIME_FUNCTION(Runtime_SetProperty) { |
| 5492 HandleScope scope(isolate); | 5488 HandleScope scope(isolate); |
| 5493 RUNTIME_ASSERT(args.length() == 4 || args.length() == 5); | 5489 RUNTIME_ASSERT(args.length() == 4 || args.length() == 5); |
| 5494 | 5490 |
| 5495 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 5491 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
| 5496 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 5492 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
| 5497 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | 5493 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
| 5498 CONVERT_SMI_ARG_CHECKED(unchecked_attributes, 3); | 5494 CONVERT_SMI_ARG_CHECKED(unchecked_attributes, 3); |
| 5499 RUNTIME_ASSERT( | 5495 RUNTIME_ASSERT( |
| 5500 (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | 5496 (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
| 5501 // Compute attributes. | 5497 // Compute attributes. |
| 5502 PropertyAttributes attributes = | 5498 PropertyAttributes attributes = |
| 5503 static_cast<PropertyAttributes>(unchecked_attributes); | 5499 static_cast<PropertyAttributes>(unchecked_attributes); |
| 5504 | 5500 |
| 5505 StrictMode strict_mode = SLOPPY; | 5501 StrictMode strict_mode = SLOPPY; |
| 5506 if (args.length() == 5) { | 5502 if (args.length() == 5) { |
| 5507 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode_arg, 4); | 5503 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode_arg, 4); |
| 5508 strict_mode = strict_mode_arg; | 5504 strict_mode = strict_mode_arg; |
| 5509 } | 5505 } |
| 5510 | 5506 |
| 5511 Handle<Object> result; | 5507 Handle<Object> result; |
| 5512 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 5508 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 5513 isolate, result, | 5509 isolate, result, |
| 5514 Runtime::SetObjectProperty( | 5510 Runtime::SetObjectProperty( |
| 5515 isolate, object, key, value, attributes, strict_mode)); | 5511 isolate, object, key, value, attributes, strict_mode)); |
| 5516 return *result; | 5512 return *result; |
| 5517 } | 5513 } |
| 5518 | 5514 |
| 5519 | 5515 |
| 5520 RUNTIME_FUNCTION(MaybeObject*, Runtime_TransitionElementsKind) { | 5516 RUNTIME_FUNCTION(Runtime_TransitionElementsKind) { |
| 5521 HandleScope scope(isolate); | 5517 HandleScope scope(isolate); |
| 5522 RUNTIME_ASSERT(args.length() == 2); | 5518 RUNTIME_ASSERT(args.length() == 2); |
| 5523 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); | 5519 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); |
| 5524 CONVERT_ARG_HANDLE_CHECKED(Map, map, 1); | 5520 CONVERT_ARG_HANDLE_CHECKED(Map, map, 1); |
| 5525 JSObject::TransitionElementsKind(array, map->elements_kind()); | 5521 JSObject::TransitionElementsKind(array, map->elements_kind()); |
| 5526 return *array; | 5522 return *array; |
| 5527 } | 5523 } |
| 5528 | 5524 |
| 5529 | 5525 |
| 5530 // Set the native flag on the function. | 5526 // Set the native flag on the function. |
| 5531 // This is used to decide if we should transform null and undefined | 5527 // This is used to decide if we should transform null and undefined |
| 5532 // into the global object when doing call and apply. | 5528 // into the global object when doing call and apply. |
| 5533 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetNativeFlag) { | 5529 RUNTIME_FUNCTION(Runtime_SetNativeFlag) { |
| 5534 SealHandleScope shs(isolate); | 5530 SealHandleScope shs(isolate); |
| 5535 RUNTIME_ASSERT(args.length() == 1); | 5531 RUNTIME_ASSERT(args.length() == 1); |
| 5536 | 5532 |
| 5537 CONVERT_ARG_CHECKED(Object, object, 0); | 5533 CONVERT_ARG_CHECKED(Object, object, 0); |
| 5538 | 5534 |
| 5539 if (object->IsJSFunction()) { | 5535 if (object->IsJSFunction()) { |
| 5540 JSFunction* func = JSFunction::cast(object); | 5536 JSFunction* func = JSFunction::cast(object); |
| 5541 func->shared()->set_native(true); | 5537 func->shared()->set_native(true); |
| 5542 } | 5538 } |
| 5543 return isolate->heap()->undefined_value(); | 5539 return isolate->heap()->undefined_value(); |
| 5544 } | 5540 } |
| 5545 | 5541 |
| 5546 | 5542 |
| 5547 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetInlineBuiltinFlag) { | 5543 RUNTIME_FUNCTION(Runtime_SetInlineBuiltinFlag) { |
| 5548 SealHandleScope shs(isolate); | 5544 SealHandleScope shs(isolate); |
| 5549 RUNTIME_ASSERT(args.length() == 1); | 5545 RUNTIME_ASSERT(args.length() == 1); |
| 5550 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 5546 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
| 5551 | 5547 |
| 5552 if (object->IsJSFunction()) { | 5548 if (object->IsJSFunction()) { |
| 5553 JSFunction* func = JSFunction::cast(*object); | 5549 JSFunction* func = JSFunction::cast(*object); |
| 5554 func->shared()->set_inline_builtin(true); | 5550 func->shared()->set_inline_builtin(true); |
| 5555 } | 5551 } |
| 5556 return isolate->heap()->undefined_value(); | 5552 return isolate->heap()->undefined_value(); |
| 5557 } | 5553 } |
| 5558 | 5554 |
| 5559 | 5555 |
| 5560 RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreArrayLiteralElement) { | 5556 RUNTIME_FUNCTION(Runtime_StoreArrayLiteralElement) { |
| 5561 HandleScope scope(isolate); | 5557 HandleScope scope(isolate); |
| 5562 RUNTIME_ASSERT(args.length() == 5); | 5558 RUNTIME_ASSERT(args.length() == 5); |
| 5563 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 5559 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
| 5564 CONVERT_SMI_ARG_CHECKED(store_index, 1); | 5560 CONVERT_SMI_ARG_CHECKED(store_index, 1); |
| 5565 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | 5561 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
| 5566 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 3); | 5562 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 3); |
| 5567 CONVERT_SMI_ARG_CHECKED(literal_index, 4); | 5563 CONVERT_SMI_ARG_CHECKED(literal_index, 4); |
| 5568 | 5564 |
| 5569 Object* raw_literal_cell = literals->get(literal_index); | 5565 Object* raw_literal_cell = literals->get(literal_index); |
| 5570 JSArray* boilerplate = NULL; | 5566 JSArray* boilerplate = NULL; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5609 } | 5605 } |
| 5610 FixedArray* object_array = FixedArray::cast(object->elements()); | 5606 FixedArray* object_array = FixedArray::cast(object->elements()); |
| 5611 object_array->set(store_index, *value); | 5607 object_array->set(store_index, *value); |
| 5612 } | 5608 } |
| 5613 return *object; | 5609 return *object; |
| 5614 } | 5610 } |
| 5615 | 5611 |
| 5616 | 5612 |
| 5617 // Check whether debugger and is about to step into the callback that is passed | 5613 // Check whether debugger and is about to step into the callback that is passed |
| 5618 // to a built-in function such as Array.forEach. | 5614 // to a built-in function such as Array.forEach. |
| 5619 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugCallbackSupportsStepping) { | 5615 RUNTIME_FUNCTION(Runtime_DebugCallbackSupportsStepping) { |
| 5620 SealHandleScope shs(isolate); | 5616 SealHandleScope shs(isolate); |
| 5621 #ifdef ENABLE_DEBUGGER_SUPPORT | 5617 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 5622 ASSERT(args.length() == 1); | 5618 ASSERT(args.length() == 1); |
| 5623 if (!isolate->IsDebuggerActive() || !isolate->debug()->StepInActive()) { | 5619 if (!isolate->IsDebuggerActive() || !isolate->debug()->StepInActive()) { |
| 5624 return isolate->heap()->false_value(); | 5620 return isolate->heap()->false_value(); |
| 5625 } | 5621 } |
| 5626 CONVERT_ARG_CHECKED(Object, callback, 0); | 5622 CONVERT_ARG_CHECKED(Object, callback, 0); |
| 5627 // We do not step into the callback if it's a builtin or not even a function. | 5623 // We do not step into the callback if it's a builtin or not even a function. |
| 5628 return isolate->heap()->ToBoolean( | 5624 return isolate->heap()->ToBoolean( |
| 5629 callback->IsJSFunction() && !JSFunction::cast(callback)->IsBuiltin()); | 5625 callback->IsJSFunction() && !JSFunction::cast(callback)->IsBuiltin()); |
| 5630 #else | 5626 #else |
| 5631 return isolate->heap()->false_value(); | 5627 return isolate->heap()->false_value(); |
| 5632 #endif // ENABLE_DEBUGGER_SUPPORT | 5628 #endif // ENABLE_DEBUGGER_SUPPORT |
| 5633 } | 5629 } |
| 5634 | 5630 |
| 5635 | 5631 |
| 5636 // Set one shot breakpoints for the callback function that is passed to a | 5632 // Set one shot breakpoints for the callback function that is passed to a |
| 5637 // built-in function such as Array.forEach to enable stepping into the callback. | 5633 // built-in function such as Array.forEach to enable stepping into the callback. |
| 5638 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPrepareStepInIfStepping) { | 5634 RUNTIME_FUNCTION(Runtime_DebugPrepareStepInIfStepping) { |
| 5639 SealHandleScope shs(isolate); | 5635 SealHandleScope shs(isolate); |
| 5640 #ifdef ENABLE_DEBUGGER_SUPPORT | 5636 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 5641 ASSERT(args.length() == 1); | 5637 ASSERT(args.length() == 1); |
| 5642 Debug* debug = isolate->debug(); | 5638 Debug* debug = isolate->debug(); |
| 5643 if (!debug->IsStepping()) return isolate->heap()->undefined_value(); | 5639 if (!debug->IsStepping()) return isolate->heap()->undefined_value(); |
| 5644 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callback, 0); | 5640 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callback, 0); |
| 5645 HandleScope scope(isolate); | 5641 HandleScope scope(isolate); |
| 5646 // When leaving the callback, step out has been activated, but not performed | 5642 // When leaving the callback, step out has been activated, but not performed |
| 5647 // if we do not leave the builtin. To be able to step into the callback | 5643 // if we do not leave the builtin. To be able to step into the callback |
| 5648 // again, we need to clear the step out at this point. | 5644 // again, we need to clear the step out at this point. |
| 5649 debug->ClearStepOut(); | 5645 debug->ClearStepOut(); |
| 5650 debug->FloodWithOneShot(callback); | 5646 debug->FloodWithOneShot(callback); |
| 5651 #endif // ENABLE_DEBUGGER_SUPPORT | 5647 #endif // ENABLE_DEBUGGER_SUPPORT |
| 5652 return isolate->heap()->undefined_value(); | 5648 return isolate->heap()->undefined_value(); |
| 5653 } | 5649 } |
| 5654 | 5650 |
| 5655 | 5651 |
| 5656 // Set a local property, even if it is READ_ONLY. If the property does not | 5652 // Set a local property, even if it is READ_ONLY. If the property does not |
| 5657 // exist, it will be added with attributes NONE. | 5653 // exist, it will be added with attributes NONE. |
| 5658 RUNTIME_FUNCTION(MaybeObject*, Runtime_IgnoreAttributesAndSetProperty) { | 5654 RUNTIME_FUNCTION(Runtime_IgnoreAttributesAndSetProperty) { |
| 5659 HandleScope scope(isolate); | 5655 HandleScope scope(isolate); |
| 5660 RUNTIME_ASSERT(args.length() == 3 || args.length() == 4); | 5656 RUNTIME_ASSERT(args.length() == 3 || args.length() == 4); |
| 5661 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 5657 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
| 5662 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 5658 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
| 5663 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | 5659 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
| 5664 // Compute attributes. | 5660 // Compute attributes. |
| 5665 PropertyAttributes attributes = NONE; | 5661 PropertyAttributes attributes = NONE; |
| 5666 if (args.length() == 4) { | 5662 if (args.length() == 4) { |
| 5667 CONVERT_SMI_ARG_CHECKED(unchecked_value, 3); | 5663 CONVERT_SMI_ARG_CHECKED(unchecked_value, 3); |
| 5668 // Only attribute bits should be set. | 5664 // Only attribute bits should be set. |
| 5669 RUNTIME_ASSERT( | 5665 RUNTIME_ASSERT( |
| 5670 (unchecked_value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | 5666 (unchecked_value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
| 5671 attributes = static_cast<PropertyAttributes>(unchecked_value); | 5667 attributes = static_cast<PropertyAttributes>(unchecked_value); |
| 5672 } | 5668 } |
| 5673 Handle<Object> result; | 5669 Handle<Object> result; |
| 5674 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 5670 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 5675 isolate, result, | 5671 isolate, result, |
| 5676 JSObject::SetLocalPropertyIgnoreAttributes( | 5672 JSObject::SetLocalPropertyIgnoreAttributes( |
| 5677 object, name, value, attributes)); | 5673 object, name, value, attributes)); |
| 5678 return *result; | 5674 return *result; |
| 5679 } | 5675 } |
| 5680 | 5676 |
| 5681 | 5677 |
| 5682 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteProperty) { | 5678 RUNTIME_FUNCTION(Runtime_DeleteProperty) { |
| 5683 HandleScope scope(isolate); | 5679 HandleScope scope(isolate); |
| 5684 ASSERT(args.length() == 3); | 5680 ASSERT(args.length() == 3); |
| 5685 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); | 5681 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); |
| 5686 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); | 5682 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); |
| 5687 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 2); | 5683 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 2); |
| 5688 JSReceiver::DeleteMode delete_mode = strict_mode == STRICT | 5684 JSReceiver::DeleteMode delete_mode = strict_mode == STRICT |
| 5689 ? JSReceiver::STRICT_DELETION : JSReceiver::NORMAL_DELETION; | 5685 ? JSReceiver::STRICT_DELETION : JSReceiver::NORMAL_DELETION; |
| 5690 Handle<Object> result; | 5686 Handle<Object> result; |
| 5691 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 5687 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 5692 isolate, result, | 5688 isolate, result, |
| 5693 JSReceiver::DeleteProperty(object, key, delete_mode)); | 5689 JSReceiver::DeleteProperty(object, key, delete_mode)); |
| 5694 return *result; | 5690 return *result; |
| 5695 } | 5691 } |
| 5696 | 5692 |
| 5697 | 5693 |
| 5698 static MaybeObject* HasLocalPropertyImplementation(Isolate* isolate, | 5694 static Object* HasLocalPropertyImplementation(Isolate* isolate, |
| 5699 Handle<JSObject> object, | 5695 Handle<JSObject> object, |
| 5700 Handle<Name> key) { | 5696 Handle<Name> key) { |
| 5701 if (JSReceiver::HasLocalProperty(object, key)) { | 5697 if (JSReceiver::HasLocalProperty(object, key)) { |
| 5702 return isolate->heap()->true_value(); | 5698 return isolate->heap()->true_value(); |
| 5703 } | 5699 } |
| 5704 // Handle hidden prototypes. If there's a hidden prototype above this thing | 5700 // Handle hidden prototypes. If there's a hidden prototype above this thing |
| 5705 // then we have to check it for properties, because they are supposed to | 5701 // then we have to check it for properties, because they are supposed to |
| 5706 // look like they are on this object. | 5702 // look like they are on this object. |
| 5707 Handle<Object> proto(object->GetPrototype(), isolate); | 5703 Handle<Object> proto(object->GetPrototype(), isolate); |
| 5708 if (proto->IsJSObject() && | 5704 if (proto->IsJSObject() && |
| 5709 Handle<JSObject>::cast(proto)->map()->is_hidden_prototype()) { | 5705 Handle<JSObject>::cast(proto)->map()->is_hidden_prototype()) { |
| 5710 return HasLocalPropertyImplementation(isolate, | 5706 return HasLocalPropertyImplementation(isolate, |
| 5711 Handle<JSObject>::cast(proto), | 5707 Handle<JSObject>::cast(proto), |
| 5712 key); | 5708 key); |
| 5713 } | 5709 } |
| 5714 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 5710 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
| 5715 return isolate->heap()->false_value(); | 5711 return isolate->heap()->false_value(); |
| 5716 } | 5712 } |
| 5717 | 5713 |
| 5718 | 5714 |
| 5719 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasLocalProperty) { | 5715 RUNTIME_FUNCTION(Runtime_HasLocalProperty) { |
| 5720 HandleScope scope(isolate); | 5716 HandleScope scope(isolate); |
| 5721 ASSERT(args.length() == 2); | 5717 ASSERT(args.length() == 2); |
| 5722 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0) | 5718 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0) |
| 5723 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); | 5719 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); |
| 5724 | 5720 |
| 5725 uint32_t index; | 5721 uint32_t index; |
| 5726 const bool key_is_array_index = key->AsArrayIndex(&index); | 5722 const bool key_is_array_index = key->AsArrayIndex(&index); |
| 5727 | 5723 |
| 5728 // Only JS objects can have properties. | 5724 // Only JS objects can have properties. |
| 5729 if (object->IsJSObject()) { | 5725 if (object->IsJSObject()) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 5751 // Well, there is one exception: Handle [] on strings. | 5747 // Well, there is one exception: Handle [] on strings. |
| 5752 Handle<String> string = Handle<String>::cast(object); | 5748 Handle<String> string = Handle<String>::cast(object); |
| 5753 if (index < static_cast<uint32_t>(string->length())) { | 5749 if (index < static_cast<uint32_t>(string->length())) { |
| 5754 return isolate->heap()->true_value(); | 5750 return isolate->heap()->true_value(); |
| 5755 } | 5751 } |
| 5756 } | 5752 } |
| 5757 return isolate->heap()->false_value(); | 5753 return isolate->heap()->false_value(); |
| 5758 } | 5754 } |
| 5759 | 5755 |
| 5760 | 5756 |
| 5761 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasProperty) { | 5757 RUNTIME_FUNCTION(Runtime_HasProperty) { |
| 5762 HandleScope scope(isolate); | 5758 HandleScope scope(isolate); |
| 5763 ASSERT(args.length() == 2); | 5759 ASSERT(args.length() == 2); |
| 5764 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); | 5760 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); |
| 5765 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); | 5761 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); |
| 5766 | 5762 |
| 5767 bool result = JSReceiver::HasProperty(receiver, key); | 5763 bool result = JSReceiver::HasProperty(receiver, key); |
| 5768 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 5764 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
| 5769 if (isolate->has_pending_exception()) return Failure::Exception(); | 5765 if (isolate->has_pending_exception()) return isolate->heap()->exception(); |
| 5770 return isolate->heap()->ToBoolean(result); | 5766 return isolate->heap()->ToBoolean(result); |
| 5771 } | 5767 } |
| 5772 | 5768 |
| 5773 | 5769 |
| 5774 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasElement) { | 5770 RUNTIME_FUNCTION(Runtime_HasElement) { |
| 5775 HandleScope scope(isolate); | 5771 HandleScope scope(isolate); |
| 5776 ASSERT(args.length() == 2); | 5772 ASSERT(args.length() == 2); |
| 5777 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); | 5773 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); |
| 5778 CONVERT_SMI_ARG_CHECKED(index, 1); | 5774 CONVERT_SMI_ARG_CHECKED(index, 1); |
| 5779 | 5775 |
| 5780 bool result = JSReceiver::HasElement(receiver, index); | 5776 bool result = JSReceiver::HasElement(receiver, index); |
| 5781 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 5777 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
| 5782 return isolate->heap()->ToBoolean(result); | 5778 return isolate->heap()->ToBoolean(result); |
| 5783 } | 5779 } |
| 5784 | 5780 |
| 5785 | 5781 |
| 5786 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsPropertyEnumerable) { | 5782 RUNTIME_FUNCTION(Runtime_IsPropertyEnumerable) { |
| 5787 HandleScope scope(isolate); | 5783 HandleScope scope(isolate); |
| 5788 ASSERT(args.length() == 2); | 5784 ASSERT(args.length() == 2); |
| 5789 | 5785 |
| 5790 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 5786 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
| 5791 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); | 5787 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); |
| 5792 | 5788 |
| 5793 PropertyAttributes att = JSReceiver::GetLocalPropertyAttribute(object, key); | 5789 PropertyAttributes att = JSReceiver::GetLocalPropertyAttribute(object, key); |
| 5794 if (att == ABSENT || (att & DONT_ENUM) != 0) { | 5790 if (att == ABSENT || (att & DONT_ENUM) != 0) { |
| 5795 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 5791 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
| 5796 return isolate->heap()->false_value(); | 5792 return isolate->heap()->false_value(); |
| 5797 } | 5793 } |
| 5798 ASSERT(!isolate->has_scheduled_exception()); | 5794 ASSERT(!isolate->has_scheduled_exception()); |
| 5799 return isolate->heap()->true_value(); | 5795 return isolate->heap()->true_value(); |
| 5800 } | 5796 } |
| 5801 | 5797 |
| 5802 | 5798 |
| 5803 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNames) { | 5799 RUNTIME_FUNCTION(Runtime_GetPropertyNames) { |
| 5804 HandleScope scope(isolate); | 5800 HandleScope scope(isolate); |
| 5805 ASSERT(args.length() == 1); | 5801 ASSERT(args.length() == 1); |
| 5806 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); | 5802 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); |
| 5807 Handle<JSArray> result; | 5803 Handle<JSArray> result; |
| 5808 | 5804 |
| 5809 isolate->counters()->for_in()->Increment(); | 5805 isolate->counters()->for_in()->Increment(); |
| 5810 Handle<FixedArray> elements; | 5806 Handle<FixedArray> elements; |
| 5811 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 5807 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 5812 isolate, elements, | 5808 isolate, elements, |
| 5813 JSReceiver::GetKeys(object, JSReceiver::INCLUDE_PROTOS)); | 5809 JSReceiver::GetKeys(object, JSReceiver::INCLUDE_PROTOS)); |
| 5814 return *isolate->factory()->NewJSArrayWithElements(elements); | 5810 return *isolate->factory()->NewJSArrayWithElements(elements); |
| 5815 } | 5811 } |
| 5816 | 5812 |
| 5817 | 5813 |
| 5818 // Returns either a FixedArray as Runtime_GetPropertyNames, | 5814 // Returns either a FixedArray as Runtime_GetPropertyNames, |
| 5819 // or, if the given object has an enum cache that contains | 5815 // or, if the given object has an enum cache that contains |
| 5820 // all enumerable properties of the object and its prototypes | 5816 // all enumerable properties of the object and its prototypes |
| 5821 // have none, the map of the object. This is used to speed up | 5817 // have none, the map of the object. This is used to speed up |
| 5822 // the check for deletions during a for-in. | 5818 // the check for deletions during a for-in. |
| 5823 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNamesFast) { | 5819 RUNTIME_FUNCTION(Runtime_GetPropertyNamesFast) { |
| 5824 SealHandleScope shs(isolate); | 5820 SealHandleScope shs(isolate); |
| 5825 ASSERT(args.length() == 1); | 5821 ASSERT(args.length() == 1); |
| 5826 | 5822 |
| 5827 CONVERT_ARG_CHECKED(JSReceiver, raw_object, 0); | 5823 CONVERT_ARG_CHECKED(JSReceiver, raw_object, 0); |
| 5828 | 5824 |
| 5829 if (raw_object->IsSimpleEnum()) return raw_object->map(); | 5825 if (raw_object->IsSimpleEnum()) return raw_object->map(); |
| 5830 | 5826 |
| 5831 HandleScope scope(isolate); | 5827 HandleScope scope(isolate); |
| 5832 Handle<JSReceiver> object(raw_object); | 5828 Handle<JSReceiver> object(raw_object); |
| 5833 Handle<FixedArray> content; | 5829 Handle<FixedArray> content; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 5853 count++; | 5849 count++; |
| 5854 proto = JSObject::cast(proto)->GetPrototype(); | 5850 proto = JSObject::cast(proto)->GetPrototype(); |
| 5855 } | 5851 } |
| 5856 return count; | 5852 return count; |
| 5857 } | 5853 } |
| 5858 | 5854 |
| 5859 | 5855 |
| 5860 // Return the names of the local named properties. | 5856 // Return the names of the local named properties. |
| 5861 // args[0]: object | 5857 // args[0]: object |
| 5862 // args[1]: PropertyAttributes as int | 5858 // args[1]: PropertyAttributes as int |
| 5863 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLocalPropertyNames) { | 5859 RUNTIME_FUNCTION(Runtime_GetLocalPropertyNames) { |
| 5864 HandleScope scope(isolate); | 5860 HandleScope scope(isolate); |
| 5865 ASSERT(args.length() == 2); | 5861 ASSERT(args.length() == 2); |
| 5866 if (!args[0]->IsJSObject()) { | 5862 if (!args[0]->IsJSObject()) { |
| 5867 return isolate->heap()->undefined_value(); | 5863 return isolate->heap()->undefined_value(); |
| 5868 } | 5864 } |
| 5869 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 5865 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
| 5870 CONVERT_SMI_ARG_CHECKED(filter_value, 1); | 5866 CONVERT_SMI_ARG_CHECKED(filter_value, 1); |
| 5871 PropertyAttributes filter = static_cast<PropertyAttributes>(filter_value); | 5867 PropertyAttributes filter = static_cast<PropertyAttributes>(filter_value); |
| 5872 | 5868 |
| 5873 // Skip the global proxy as it has no properties and always delegates to the | 5869 // Skip the global proxy as it has no properties and always delegates to the |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5967 } | 5963 } |
| 5968 ASSERT_EQ(0, hidden_strings); | 5964 ASSERT_EQ(0, hidden_strings); |
| 5969 } | 5965 } |
| 5970 | 5966 |
| 5971 return *isolate->factory()->NewJSArrayWithElements(names); | 5967 return *isolate->factory()->NewJSArrayWithElements(names); |
| 5972 } | 5968 } |
| 5973 | 5969 |
| 5974 | 5970 |
| 5975 // Return the names of the local indexed properties. | 5971 // Return the names of the local indexed properties. |
| 5976 // args[0]: object | 5972 // args[0]: object |
| 5977 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLocalElementNames) { | 5973 RUNTIME_FUNCTION(Runtime_GetLocalElementNames) { |
| 5978 HandleScope scope(isolate); | 5974 HandleScope scope(isolate); |
| 5979 ASSERT(args.length() == 1); | 5975 ASSERT(args.length() == 1); |
| 5980 if (!args[0]->IsJSObject()) { | 5976 if (!args[0]->IsJSObject()) { |
| 5981 return isolate->heap()->undefined_value(); | 5977 return isolate->heap()->undefined_value(); |
| 5982 } | 5978 } |
| 5983 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 5979 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
| 5984 | 5980 |
| 5985 int n = obj->NumberOfLocalElements(static_cast<PropertyAttributes>(NONE)); | 5981 int n = obj->NumberOfLocalElements(static_cast<PropertyAttributes>(NONE)); |
| 5986 Handle<FixedArray> names = isolate->factory()->NewFixedArray(n); | 5982 Handle<FixedArray> names = isolate->factory()->NewFixedArray(n); |
| 5987 obj->GetLocalElementKeys(*names, static_cast<PropertyAttributes>(NONE)); | 5983 obj->GetLocalElementKeys(*names, static_cast<PropertyAttributes>(NONE)); |
| 5988 return *isolate->factory()->NewJSArrayWithElements(names); | 5984 return *isolate->factory()->NewJSArrayWithElements(names); |
| 5989 } | 5985 } |
| 5990 | 5986 |
| 5991 | 5987 |
| 5992 // Return information on whether an object has a named or indexed interceptor. | 5988 // Return information on whether an object has a named or indexed interceptor. |
| 5993 // args[0]: object | 5989 // args[0]: object |
| 5994 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetInterceptorInfo) { | 5990 RUNTIME_FUNCTION(Runtime_GetInterceptorInfo) { |
| 5995 HandleScope scope(isolate); | 5991 HandleScope scope(isolate); |
| 5996 ASSERT(args.length() == 1); | 5992 ASSERT(args.length() == 1); |
| 5997 if (!args[0]->IsJSObject()) { | 5993 if (!args[0]->IsJSObject()) { |
| 5998 return Smi::FromInt(0); | 5994 return Smi::FromInt(0); |
| 5999 } | 5995 } |
| 6000 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 5996 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
| 6001 | 5997 |
| 6002 int result = 0; | 5998 int result = 0; |
| 6003 if (obj->HasNamedInterceptor()) result |= 2; | 5999 if (obj->HasNamedInterceptor()) result |= 2; |
| 6004 if (obj->HasIndexedInterceptor()) result |= 1; | 6000 if (obj->HasIndexedInterceptor()) result |= 1; |
| 6005 | 6001 |
| 6006 return Smi::FromInt(result); | 6002 return Smi::FromInt(result); |
| 6007 } | 6003 } |
| 6008 | 6004 |
| 6009 | 6005 |
| 6010 // Return property names from named interceptor. | 6006 // Return property names from named interceptor. |
| 6011 // args[0]: object | 6007 // args[0]: object |
| 6012 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetNamedInterceptorPropertyNames) { | 6008 RUNTIME_FUNCTION(Runtime_GetNamedInterceptorPropertyNames) { |
| 6013 HandleScope scope(isolate); | 6009 HandleScope scope(isolate); |
| 6014 ASSERT(args.length() == 1); | 6010 ASSERT(args.length() == 1); |
| 6015 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 6011 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
| 6016 | 6012 |
| 6017 if (obj->HasNamedInterceptor()) { | 6013 if (obj->HasNamedInterceptor()) { |
| 6018 Handle<JSArray> result; | 6014 Handle<JSArray> result; |
| 6019 if (JSObject::GetKeysForNamedInterceptor(obj, obj).ToHandle(&result)) { | 6015 if (JSObject::GetKeysForNamedInterceptor(obj, obj).ToHandle(&result)) { |
| 6020 return *result; | 6016 return *result; |
| 6021 } | 6017 } |
| 6022 } | 6018 } |
| 6023 return isolate->heap()->undefined_value(); | 6019 return isolate->heap()->undefined_value(); |
| 6024 } | 6020 } |
| 6025 | 6021 |
| 6026 | 6022 |
| 6027 // Return element names from indexed interceptor. | 6023 // Return element names from indexed interceptor. |
| 6028 // args[0]: object | 6024 // args[0]: object |
| 6029 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetIndexedInterceptorElementNames) { | 6025 RUNTIME_FUNCTION(Runtime_GetIndexedInterceptorElementNames) { |
| 6030 HandleScope scope(isolate); | 6026 HandleScope scope(isolate); |
| 6031 ASSERT(args.length() == 1); | 6027 ASSERT(args.length() == 1); |
| 6032 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 6028 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
| 6033 | 6029 |
| 6034 if (obj->HasIndexedInterceptor()) { | 6030 if (obj->HasIndexedInterceptor()) { |
| 6035 Handle<JSArray> result; | 6031 Handle<JSArray> result; |
| 6036 if (JSObject::GetKeysForIndexedInterceptor(obj, obj).ToHandle(&result)) { | 6032 if (JSObject::GetKeysForIndexedInterceptor(obj, obj).ToHandle(&result)) { |
| 6037 return *result; | 6033 return *result; |
| 6038 } | 6034 } |
| 6039 } | 6035 } |
| 6040 return isolate->heap()->undefined_value(); | 6036 return isolate->heap()->undefined_value(); |
| 6041 } | 6037 } |
| 6042 | 6038 |
| 6043 | 6039 |
| 6044 RUNTIME_FUNCTION(MaybeObject*, Runtime_LocalKeys) { | 6040 RUNTIME_FUNCTION(Runtime_LocalKeys) { |
| 6045 HandleScope scope(isolate); | 6041 HandleScope scope(isolate); |
| 6046 ASSERT(args.length() == 1); | 6042 ASSERT(args.length() == 1); |
| 6047 CONVERT_ARG_CHECKED(JSObject, raw_object, 0); | 6043 CONVERT_ARG_CHECKED(JSObject, raw_object, 0); |
| 6048 Handle<JSObject> object(raw_object); | 6044 Handle<JSObject> object(raw_object); |
| 6049 | 6045 |
| 6050 if (object->IsJSGlobalProxy()) { | 6046 if (object->IsJSGlobalProxy()) { |
| 6051 // Do access checks before going to the global object. | 6047 // Do access checks before going to the global object. |
| 6052 if (object->IsAccessCheckNeeded() && | 6048 if (object->IsAccessCheckNeeded() && |
| 6053 !isolate->MayNamedAccess( | 6049 !isolate->MayNamedAccess( |
| 6054 object, isolate->factory()->undefined_value(), v8::ACCESS_KEYS)) { | 6050 object, isolate->factory()->undefined_value(), v8::ACCESS_KEYS)) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 6083 Handle<Object> entry_handle(entry, isolate); | 6079 Handle<Object> entry_handle(entry, isolate); |
| 6084 Handle<Object> entry_str = | 6080 Handle<Object> entry_str = |
| 6085 isolate->factory()->NumberToString(entry_handle); | 6081 isolate->factory()->NumberToString(entry_handle); |
| 6086 copy->set(i, *entry_str); | 6082 copy->set(i, *entry_str); |
| 6087 } | 6083 } |
| 6088 } | 6084 } |
| 6089 return *isolate->factory()->NewJSArrayWithElements(copy); | 6085 return *isolate->factory()->NewJSArrayWithElements(copy); |
| 6090 } | 6086 } |
| 6091 | 6087 |
| 6092 | 6088 |
| 6093 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArgumentsProperty) { | 6089 RUNTIME_FUNCTION(Runtime_GetArgumentsProperty) { |
| 6094 SealHandleScope shs(isolate); | 6090 SealHandleScope shs(isolate); |
| 6095 ASSERT(args.length() == 1); | 6091 ASSERT(args.length() == 1); |
| 6096 CONVERT_ARG_HANDLE_CHECKED(Object, raw_key, 0); | 6092 CONVERT_ARG_HANDLE_CHECKED(Object, raw_key, 0); |
| 6097 | 6093 |
| 6098 // Compute the frame holding the arguments. | 6094 // Compute the frame holding the arguments. |
| 6099 JavaScriptFrameIterator it(isolate); | 6095 JavaScriptFrameIterator it(isolate); |
| 6100 it.AdvanceToArgumentsFrame(); | 6096 it.AdvanceToArgumentsFrame(); |
| 6101 JavaScriptFrame* frame = it.frame(); | 6097 JavaScriptFrame* frame = it.frame(); |
| 6102 | 6098 |
| 6103 // Get the actual number of provided arguments. | 6099 // Get the actual number of provided arguments. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6156 | 6152 |
| 6157 // Lookup in the initial Object.prototype object. | 6153 // Lookup in the initial Object.prototype object. |
| 6158 Handle<Object> result; | 6154 Handle<Object> result; |
| 6159 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 6155 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 6160 isolate, result, | 6156 isolate, result, |
| 6161 Object::GetProperty(isolate->initial_object_prototype(), key)); | 6157 Object::GetProperty(isolate->initial_object_prototype(), key)); |
| 6162 return *result; | 6158 return *result; |
| 6163 } | 6159 } |
| 6164 | 6160 |
| 6165 | 6161 |
| 6166 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToFastProperties) { | 6162 RUNTIME_FUNCTION(Runtime_ToFastProperties) { |
| 6167 HandleScope scope(isolate); | 6163 HandleScope scope(isolate); |
| 6168 ASSERT(args.length() == 1); | 6164 ASSERT(args.length() == 1); |
| 6169 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 6165 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
| 6170 if (object->IsJSObject() && !object->IsGlobalObject()) { | 6166 if (object->IsJSObject() && !object->IsGlobalObject()) { |
| 6171 JSObject::TransformToFastProperties(Handle<JSObject>::cast(object), 0); | 6167 JSObject::TransformToFastProperties(Handle<JSObject>::cast(object), 0); |
| 6172 } | 6168 } |
| 6173 return *object; | 6169 return *object; |
| 6174 } | 6170 } |
| 6175 | 6171 |
| 6176 | 6172 |
| 6177 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToBool) { | 6173 RUNTIME_FUNCTION(Runtime_ToBool) { |
| 6178 SealHandleScope shs(isolate); | 6174 SealHandleScope shs(isolate); |
| 6179 ASSERT(args.length() == 1); | 6175 ASSERT(args.length() == 1); |
| 6180 CONVERT_ARG_CHECKED(Object, object, 0); | 6176 CONVERT_ARG_CHECKED(Object, object, 0); |
| 6181 | 6177 |
| 6182 return isolate->heap()->ToBoolean(object->BooleanValue()); | 6178 return isolate->heap()->ToBoolean(object->BooleanValue()); |
| 6183 } | 6179 } |
| 6184 | 6180 |
| 6185 | 6181 |
| 6186 // Returns the type string of a value; see ECMA-262, 11.4.3 (p 47). | 6182 // Returns the type string of a value; see ECMA-262, 11.4.3 (p 47). |
| 6187 // Possible optimizations: put the type string into the oddballs. | 6183 // Possible optimizations: put the type string into the oddballs. |
| 6188 RUNTIME_FUNCTION(MaybeObject*, Runtime_Typeof) { | 6184 RUNTIME_FUNCTION(Runtime_Typeof) { |
| 6189 SealHandleScope shs(isolate); | 6185 SealHandleScope shs(isolate); |
| 6190 ASSERT(args.length() == 1); | 6186 ASSERT(args.length() == 1); |
| 6191 CONVERT_ARG_CHECKED(Object, obj, 0); | 6187 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 6192 if (obj->IsNumber()) return isolate->heap()->number_string(); | 6188 if (obj->IsNumber()) return isolate->heap()->number_string(); |
| 6193 HeapObject* heap_obj = HeapObject::cast(obj); | 6189 HeapObject* heap_obj = HeapObject::cast(obj); |
| 6194 | 6190 |
| 6195 // typeof an undetectable object is 'undefined' | 6191 // typeof an undetectable object is 'undefined' |
| 6196 if (heap_obj->map()->is_undetectable()) { | 6192 if (heap_obj->map()->is_undetectable()) { |
| 6197 return isolate->heap()->undefined_string(); | 6193 return isolate->heap()->undefined_string(); |
| 6198 } | 6194 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6242 int d = s[from] - '0'; | 6238 int d = s[from] - '0'; |
| 6243 | 6239 |
| 6244 for (int i = from + 1; i < to; i++) { | 6240 for (int i = from + 1; i < to; i++) { |
| 6245 d = 10 * d + (s[i] - '0'); | 6241 d = 10 * d + (s[i] - '0'); |
| 6246 } | 6242 } |
| 6247 | 6243 |
| 6248 return d; | 6244 return d; |
| 6249 } | 6245 } |
| 6250 | 6246 |
| 6251 | 6247 |
| 6252 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToNumber) { | 6248 RUNTIME_FUNCTION(Runtime_StringToNumber) { |
| 6253 HandleScope handle_scope(isolate); | 6249 HandleScope handle_scope(isolate); |
| 6254 ASSERT(args.length() == 1); | 6250 ASSERT(args.length() == 1); |
| 6255 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); | 6251 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); |
| 6256 subject = String::Flatten(subject); | 6252 subject = String::Flatten(subject); |
| 6257 | 6253 |
| 6258 // Fast case: short integer or some sorts of junk values. | 6254 // Fast case: short integer or some sorts of junk values. |
| 6259 if (subject->IsSeqOneByteString()) { | 6255 if (subject->IsSeqOneByteString()) { |
| 6260 int len = subject->length(); | 6256 int len = subject->length(); |
| 6261 if (len == 0) return Smi::FromInt(0); | 6257 if (len == 0) return Smi::FromInt(0); |
| 6262 | 6258 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6305 // The current spec draft has not updated "ToNumber Applied to the String | 6301 // The current spec draft has not updated "ToNumber Applied to the String |
| 6306 // Type", https://bugs.ecmascript.org/show_bug.cgi?id=1584 | 6302 // Type", https://bugs.ecmascript.org/show_bug.cgi?id=1584 |
| 6307 flags |= ALLOW_OCTAL | ALLOW_BINARY; | 6303 flags |= ALLOW_OCTAL | ALLOW_BINARY; |
| 6308 } | 6304 } |
| 6309 | 6305 |
| 6310 return *isolate->factory()->NewNumber(StringToDouble( | 6306 return *isolate->factory()->NewNumber(StringToDouble( |
| 6311 isolate->unicode_cache(), *subject, flags)); | 6307 isolate->unicode_cache(), *subject, flags)); |
| 6312 } | 6308 } |
| 6313 | 6309 |
| 6314 | 6310 |
| 6315 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewString) { | 6311 RUNTIME_FUNCTION(Runtime_NewString) { |
| 6316 HandleScope scope(isolate); | 6312 HandleScope scope(isolate); |
| 6317 ASSERT(args.length() == 2); | 6313 ASSERT(args.length() == 2); |
| 6318 CONVERT_SMI_ARG_CHECKED(length, 0); | 6314 CONVERT_SMI_ARG_CHECKED(length, 0); |
| 6319 CONVERT_BOOLEAN_ARG_CHECKED(is_one_byte, 1); | 6315 CONVERT_BOOLEAN_ARG_CHECKED(is_one_byte, 1); |
| 6320 if (length == 0) return isolate->heap()->empty_string(); | 6316 if (length == 0) return isolate->heap()->empty_string(); |
| 6321 Handle<String> result; | 6317 Handle<String> result; |
| 6322 if (is_one_byte) { | 6318 if (is_one_byte) { |
| 6323 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 6319 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 6324 isolate, result, isolate->factory()->NewRawOneByteString(length)); | 6320 isolate, result, isolate->factory()->NewRawOneByteString(length)); |
| 6325 } else { | 6321 } else { |
| 6326 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 6322 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 6327 isolate, result, isolate->factory()->NewRawTwoByteString(length)); | 6323 isolate, result, isolate->factory()->NewRawTwoByteString(length)); |
| 6328 } | 6324 } |
| 6329 return *result; | 6325 return *result; |
| 6330 } | 6326 } |
| 6331 | 6327 |
| 6332 | 6328 |
| 6333 RUNTIME_FUNCTION(MaybeObject*, Runtime_TruncateString) { | 6329 RUNTIME_FUNCTION(Runtime_TruncateString) { |
| 6334 HandleScope scope(isolate); | 6330 HandleScope scope(isolate); |
| 6335 ASSERT(args.length() == 2); | 6331 ASSERT(args.length() == 2); |
| 6336 CONVERT_ARG_HANDLE_CHECKED(SeqString, string, 0); | 6332 CONVERT_ARG_HANDLE_CHECKED(SeqString, string, 0); |
| 6337 CONVERT_SMI_ARG_CHECKED(new_length, 1); | 6333 CONVERT_SMI_ARG_CHECKED(new_length, 1); |
| 6338 return *SeqString::Truncate(string, new_length); | 6334 return *SeqString::Truncate(string, new_length); |
| 6339 } | 6335 } |
| 6340 | 6336 |
| 6341 | 6337 |
| 6342 RUNTIME_FUNCTION(MaybeObject*, Runtime_URIEscape) { | 6338 RUNTIME_FUNCTION(Runtime_URIEscape) { |
| 6343 HandleScope scope(isolate); | 6339 HandleScope scope(isolate); |
| 6344 ASSERT(args.length() == 1); | 6340 ASSERT(args.length() == 1); |
| 6345 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); | 6341 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); |
| 6346 Handle<String> string = String::Flatten(source); | 6342 Handle<String> string = String::Flatten(source); |
| 6347 ASSERT(string->IsFlat()); | 6343 ASSERT(string->IsFlat()); |
| 6348 Handle<String> result; | 6344 Handle<String> result; |
| 6349 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 6345 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 6350 isolate, result, | 6346 isolate, result, |
| 6351 string->IsOneByteRepresentationUnderneath() | 6347 string->IsOneByteRepresentationUnderneath() |
| 6352 ? URIEscape::Escape<uint8_t>(isolate, source) | 6348 ? URIEscape::Escape<uint8_t>(isolate, source) |
| 6353 : URIEscape::Escape<uc16>(isolate, source)); | 6349 : URIEscape::Escape<uc16>(isolate, source)); |
| 6354 return *result; | 6350 return *result; |
| 6355 } | 6351 } |
| 6356 | 6352 |
| 6357 | 6353 |
| 6358 RUNTIME_FUNCTION(MaybeObject*, Runtime_URIUnescape) { | 6354 RUNTIME_FUNCTION(Runtime_URIUnescape) { |
| 6359 HandleScope scope(isolate); | 6355 HandleScope scope(isolate); |
| 6360 ASSERT(args.length() == 1); | 6356 ASSERT(args.length() == 1); |
| 6361 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); | 6357 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); |
| 6362 Handle<String> string = String::Flatten(source); | 6358 Handle<String> string = String::Flatten(source); |
| 6363 ASSERT(string->IsFlat()); | 6359 ASSERT(string->IsFlat()); |
| 6364 Handle<String> result; | 6360 Handle<String> result; |
| 6365 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 6361 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 6366 isolate, result, | 6362 isolate, result, |
| 6367 string->IsOneByteRepresentationUnderneath() | 6363 string->IsOneByteRepresentationUnderneath() |
| 6368 ? URIUnescape::Unescape<uint8_t>(isolate, source) | 6364 ? URIUnescape::Unescape<uint8_t>(isolate, source) |
| 6369 : URIUnescape::Unescape<uc16>(isolate, source)); | 6365 : URIUnescape::Unescape<uc16>(isolate, source)); |
| 6370 return *result; | 6366 return *result; |
| 6371 } | 6367 } |
| 6372 | 6368 |
| 6373 | 6369 |
| 6374 RUNTIME_FUNCTION(MaybeObject*, Runtime_QuoteJSONString) { | 6370 RUNTIME_FUNCTION(Runtime_QuoteJSONString) { |
| 6375 HandleScope scope(isolate); | 6371 HandleScope scope(isolate); |
| 6376 CONVERT_ARG_HANDLE_CHECKED(String, string, 0); | 6372 CONVERT_ARG_HANDLE_CHECKED(String, string, 0); |
| 6377 ASSERT(args.length() == 1); | 6373 ASSERT(args.length() == 1); |
| 6378 Handle<Object> result; | 6374 Handle<Object> result; |
| 6379 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 6375 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 6380 isolate, result, BasicJsonStringifier::StringifyString(isolate, string)); | 6376 isolate, result, BasicJsonStringifier::StringifyString(isolate, string)); |
| 6381 return *result; | 6377 return *result; |
| 6382 } | 6378 } |
| 6383 | 6379 |
| 6384 | 6380 |
| 6385 RUNTIME_FUNCTION(MaybeObject*, Runtime_BasicJSONStringify) { | 6381 RUNTIME_FUNCTION(Runtime_BasicJSONStringify) { |
| 6386 HandleScope scope(isolate); | 6382 HandleScope scope(isolate); |
| 6387 ASSERT(args.length() == 1); | 6383 ASSERT(args.length() == 1); |
| 6388 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 6384 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
| 6389 BasicJsonStringifier stringifier(isolate); | 6385 BasicJsonStringifier stringifier(isolate); |
| 6390 Handle<Object> result; | 6386 Handle<Object> result; |
| 6391 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 6387 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 6392 isolate, result, stringifier.Stringify(object)); | 6388 isolate, result, stringifier.Stringify(object)); |
| 6393 return *result; | 6389 return *result; |
| 6394 } | 6390 } |
| 6395 | 6391 |
| 6396 | 6392 |
| 6397 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseInt) { | 6393 RUNTIME_FUNCTION(Runtime_StringParseInt) { |
| 6398 HandleScope handle_scope(isolate); | 6394 HandleScope handle_scope(isolate); |
| 6399 ASSERT(args.length() == 2); | 6395 ASSERT(args.length() == 2); |
| 6400 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); | 6396 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); |
| 6401 CONVERT_NUMBER_CHECKED(int, radix, Int32, args[1]); | 6397 CONVERT_NUMBER_CHECKED(int, radix, Int32, args[1]); |
| 6402 RUNTIME_ASSERT(radix == 0 || (2 <= radix && radix <= 36)); | 6398 RUNTIME_ASSERT(radix == 0 || (2 <= radix && radix <= 36)); |
| 6403 | 6399 |
| 6404 subject = String::Flatten(subject); | 6400 subject = String::Flatten(subject); |
| 6405 double value; | 6401 double value; |
| 6406 | 6402 |
| 6407 { DisallowHeapAllocation no_gc; | 6403 { DisallowHeapAllocation no_gc; |
| 6408 String::FlatContent flat = subject->GetFlatContent(); | 6404 String::FlatContent flat = subject->GetFlatContent(); |
| 6409 | 6405 |
| 6410 // ECMA-262 section 15.1.2.3, empty string is NaN | 6406 // ECMA-262 section 15.1.2.3, empty string is NaN |
| 6411 if (flat.IsAscii()) { | 6407 if (flat.IsAscii()) { |
| 6412 value = StringToInt( | 6408 value = StringToInt( |
| 6413 isolate->unicode_cache(), flat.ToOneByteVector(), radix); | 6409 isolate->unicode_cache(), flat.ToOneByteVector(), radix); |
| 6414 } else { | 6410 } else { |
| 6415 value = StringToInt( | 6411 value = StringToInt( |
| 6416 isolate->unicode_cache(), flat.ToUC16Vector(), radix); | 6412 isolate->unicode_cache(), flat.ToUC16Vector(), radix); |
| 6417 } | 6413 } |
| 6418 } | 6414 } |
| 6419 | 6415 |
| 6420 return *isolate->factory()->NewNumber(value); | 6416 return *isolate->factory()->NewNumber(value); |
| 6421 } | 6417 } |
| 6422 | 6418 |
| 6423 | 6419 |
| 6424 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseFloat) { | 6420 RUNTIME_FUNCTION(Runtime_StringParseFloat) { |
| 6425 HandleScope shs(isolate); | 6421 HandleScope shs(isolate); |
| 6426 ASSERT(args.length() == 1); | 6422 ASSERT(args.length() == 1); |
| 6427 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); | 6423 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); |
| 6428 | 6424 |
| 6429 subject = String::Flatten(subject); | 6425 subject = String::Flatten(subject); |
| 6430 double value = StringToDouble( | 6426 double value = StringToDouble( |
| 6431 isolate->unicode_cache(), *subject, ALLOW_TRAILING_JUNK, OS::nan_value()); | 6427 isolate->unicode_cache(), *subject, ALLOW_TRAILING_JUNK, OS::nan_value()); |
| 6432 | 6428 |
| 6433 return *isolate->factory()->NewNumber(value); | 6429 return *isolate->factory()->NewNumber(value); |
| 6434 } | 6430 } |
| 6435 | 6431 |
| 6436 | 6432 |
| 6437 static inline bool ToUpperOverflows(uc32 character) { | 6433 static inline bool ToUpperOverflows(uc32 character) { |
| 6438 // y with umlauts and the micro sign are the only characters that stop | 6434 // y with umlauts and the micro sign are the only characters that stop |
| 6439 // fitting into one-byte when converting to uppercase. | 6435 // fitting into one-byte when converting to uppercase. |
| 6440 static const uc32 yuml_code = 0xff; | 6436 static const uc32 yuml_code = 0xff; |
| 6441 static const uc32 micro_code = 0xb5; | 6437 static const uc32 micro_code = 0xb5; |
| 6442 return (character == yuml_code || character == micro_code); | 6438 return (character == yuml_code || character == micro_code); |
| 6443 } | 6439 } |
| 6444 | 6440 |
| 6445 | 6441 |
| 6446 template <class Converter> | 6442 template <class Converter> |
| 6447 MUST_USE_RESULT static MaybeObject* ConvertCaseHelper( | 6443 MUST_USE_RESULT static Object* ConvertCaseHelper( |
| 6448 Isolate* isolate, | 6444 Isolate* isolate, |
| 6449 String* string, | 6445 String* string, |
| 6450 SeqString* result, | 6446 SeqString* result, |
| 6451 int result_length, | 6447 int result_length, |
| 6452 unibrow::Mapping<Converter, 128>* mapping) { | 6448 unibrow::Mapping<Converter, 128>* mapping) { |
| 6453 DisallowHeapAllocation no_gc; | 6449 DisallowHeapAllocation no_gc; |
| 6454 // We try this twice, once with the assumption that the result is no longer | 6450 // We try this twice, once with the assumption that the result is no longer |
| 6455 // than the input and, if that assumption breaks, again with the exact | 6451 // than the input and, if that assumption breaks, again with the exact |
| 6456 // length. This may not be pretty, but it is nicer than what was here before | 6452 // length. This may not be pretty, but it is nicer than what was here before |
| 6457 // and I hereby claim my vaffel-is. | 6453 // and I hereby claim my vaffel-is. |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6660 saved_dst, saved_src, length, changed, Converter::kIsToLower)); | 6656 saved_dst, saved_src, length, changed, Converter::kIsToLower)); |
| 6661 | 6657 |
| 6662 *changed_out = changed; | 6658 *changed_out = changed; |
| 6663 return true; | 6659 return true; |
| 6664 } | 6660 } |
| 6665 | 6661 |
| 6666 } // namespace | 6662 } // namespace |
| 6667 | 6663 |
| 6668 | 6664 |
| 6669 template <class Converter> | 6665 template <class Converter> |
| 6670 MUST_USE_RESULT static MaybeObject* ConvertCase( | 6666 MUST_USE_RESULT static Object* ConvertCase( |
| 6671 Handle<String> s, | 6667 Handle<String> s, |
| 6672 Isolate* isolate, | 6668 Isolate* isolate, |
| 6673 unibrow::Mapping<Converter, 128>* mapping) { | 6669 unibrow::Mapping<Converter, 128>* mapping) { |
| 6674 s = String::Flatten(s); | 6670 s = String::Flatten(s); |
| 6675 int length = s->length(); | 6671 int length = s->length(); |
| 6676 // Assume that the string is not empty; we need this assumption later | 6672 // Assume that the string is not empty; we need this assumption later |
| 6677 if (length == 0) return *s; | 6673 if (length == 0) return *s; |
| 6678 | 6674 |
| 6679 // Simpler handling of ASCII strings. | 6675 // Simpler handling of ASCII strings. |
| 6680 // | 6676 // |
| (...skipping 18 matching lines...) Expand all Loading... |
| 6699 if (is_ascii) return has_changed_character ? *result : *s; | 6695 if (is_ascii) return has_changed_character ? *result : *s; |
| 6700 } | 6696 } |
| 6701 | 6697 |
| 6702 Handle<SeqString> result; // Same length as input. | 6698 Handle<SeqString> result; // Same length as input. |
| 6703 if (s->IsOneByteRepresentation()) { | 6699 if (s->IsOneByteRepresentation()) { |
| 6704 result = isolate->factory()->NewRawOneByteString(length).ToHandleChecked(); | 6700 result = isolate->factory()->NewRawOneByteString(length).ToHandleChecked(); |
| 6705 } else { | 6701 } else { |
| 6706 result = isolate->factory()->NewRawTwoByteString(length).ToHandleChecked(); | 6702 result = isolate->factory()->NewRawTwoByteString(length).ToHandleChecked(); |
| 6707 } | 6703 } |
| 6708 | 6704 |
| 6709 MaybeObject* maybe = ConvertCaseHelper(isolate, *s, *result, length, mapping); | 6705 Object* answer = ConvertCaseHelper(isolate, *s, *result, length, mapping); |
| 6710 Object* answer; | 6706 if (answer->IsException() || answer->IsString()) return answer; |
| 6711 if (!maybe->ToObject(&answer)) return maybe; | |
| 6712 if (answer->IsString()) return answer; | |
| 6713 | 6707 |
| 6714 ASSERT(answer->IsSmi()); | 6708 ASSERT(answer->IsSmi()); |
| 6715 length = Smi::cast(answer)->value(); | 6709 length = Smi::cast(answer)->value(); |
| 6716 if (s->IsOneByteRepresentation() && length > 0) { | 6710 if (s->IsOneByteRepresentation() && length > 0) { |
| 6717 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 6711 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 6718 isolate, result, isolate->factory()->NewRawOneByteString(length)); | 6712 isolate, result, isolate->factory()->NewRawOneByteString(length)); |
| 6719 } else { | 6713 } else { |
| 6720 if (length < 0) length = -length; | 6714 if (length < 0) length = -length; |
| 6721 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 6715 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 6722 isolate, result, isolate->factory()->NewRawTwoByteString(length)); | 6716 isolate, result, isolate->factory()->NewRawTwoByteString(length)); |
| 6723 } | 6717 } |
| 6724 return ConvertCaseHelper(isolate, *s, *result, length, mapping); | 6718 return ConvertCaseHelper(isolate, *s, *result, length, mapping); |
| 6725 } | 6719 } |
| 6726 | 6720 |
| 6727 | 6721 |
| 6728 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToLowerCase) { | 6722 RUNTIME_FUNCTION(Runtime_StringToLowerCase) { |
| 6729 HandleScope scope(isolate); | 6723 HandleScope scope(isolate); |
| 6730 ASSERT(args.length() == 1); | 6724 ASSERT(args.length() == 1); |
| 6731 CONVERT_ARG_HANDLE_CHECKED(String, s, 0); | 6725 CONVERT_ARG_HANDLE_CHECKED(String, s, 0); |
| 6732 return ConvertCase( | 6726 return ConvertCase( |
| 6733 s, isolate, isolate->runtime_state()->to_lower_mapping()); | 6727 s, isolate, isolate->runtime_state()->to_lower_mapping()); |
| 6734 } | 6728 } |
| 6735 | 6729 |
| 6736 | 6730 |
| 6737 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToUpperCase) { | 6731 RUNTIME_FUNCTION(Runtime_StringToUpperCase) { |
| 6738 HandleScope scope(isolate); | 6732 HandleScope scope(isolate); |
| 6739 ASSERT(args.length() == 1); | 6733 ASSERT(args.length() == 1); |
| 6740 CONVERT_ARG_HANDLE_CHECKED(String, s, 0); | 6734 CONVERT_ARG_HANDLE_CHECKED(String, s, 0); |
| 6741 return ConvertCase( | 6735 return ConvertCase( |
| 6742 s, isolate, isolate->runtime_state()->to_upper_mapping()); | 6736 s, isolate, isolate->runtime_state()->to_upper_mapping()); |
| 6743 } | 6737 } |
| 6744 | 6738 |
| 6745 | 6739 |
| 6746 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringTrim) { | 6740 RUNTIME_FUNCTION(Runtime_StringTrim) { |
| 6747 HandleScope scope(isolate); | 6741 HandleScope scope(isolate); |
| 6748 ASSERT(args.length() == 3); | 6742 ASSERT(args.length() == 3); |
| 6749 | 6743 |
| 6750 CONVERT_ARG_HANDLE_CHECKED(String, string, 0); | 6744 CONVERT_ARG_HANDLE_CHECKED(String, string, 0); |
| 6751 CONVERT_BOOLEAN_ARG_CHECKED(trimLeft, 1); | 6745 CONVERT_BOOLEAN_ARG_CHECKED(trimLeft, 1); |
| 6752 CONVERT_BOOLEAN_ARG_CHECKED(trimRight, 2); | 6746 CONVERT_BOOLEAN_ARG_CHECKED(trimRight, 2); |
| 6753 | 6747 |
| 6754 string = String::Flatten(string); | 6748 string = String::Flatten(string); |
| 6755 int length = string->length(); | 6749 int length = string->length(); |
| 6756 | 6750 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 6769 unicode_cache->IsWhiteSpaceOrLineTerminator( | 6763 unicode_cache->IsWhiteSpaceOrLineTerminator( |
| 6770 string->Get(right - 1))) { | 6764 string->Get(right - 1))) { |
| 6771 right--; | 6765 right--; |
| 6772 } | 6766 } |
| 6773 } | 6767 } |
| 6774 | 6768 |
| 6775 return *isolate->factory()->NewSubString(string, left, right); | 6769 return *isolate->factory()->NewSubString(string, left, right); |
| 6776 } | 6770 } |
| 6777 | 6771 |
| 6778 | 6772 |
| 6779 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringSplit) { | 6773 RUNTIME_FUNCTION(Runtime_StringSplit) { |
| 6780 HandleScope handle_scope(isolate); | 6774 HandleScope handle_scope(isolate); |
| 6781 ASSERT(args.length() == 3); | 6775 ASSERT(args.length() == 3); |
| 6782 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); | 6776 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); |
| 6783 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 1); | 6777 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 1); |
| 6784 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[2]); | 6778 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[2]); |
| 6785 | 6779 |
| 6786 int subject_length = subject->length(); | 6780 int subject_length = subject->length(); |
| 6787 int pattern_length = pattern->length(); | 6781 int pattern_length = pattern->length(); |
| 6788 RUNTIME_ASSERT(pattern_length > 0); | 6782 RUNTIME_ASSERT(pattern_length > 0); |
| 6789 | 6783 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6894 ASSERT(element == Smi::FromInt(0) || | 6888 ASSERT(element == Smi::FromInt(0) || |
| 6895 (element->IsString() && String::cast(element)->LooksValid())); | 6889 (element->IsString() && String::cast(element)->LooksValid())); |
| 6896 } | 6890 } |
| 6897 #endif | 6891 #endif |
| 6898 return i; | 6892 return i; |
| 6899 } | 6893 } |
| 6900 | 6894 |
| 6901 | 6895 |
| 6902 // Converts a String to JSArray. | 6896 // Converts a String to JSArray. |
| 6903 // For example, "foo" => ["f", "o", "o"]. | 6897 // For example, "foo" => ["f", "o", "o"]. |
| 6904 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToArray) { | 6898 RUNTIME_FUNCTION(Runtime_StringToArray) { |
| 6905 HandleScope scope(isolate); | 6899 HandleScope scope(isolate); |
| 6906 ASSERT(args.length() == 2); | 6900 ASSERT(args.length() == 2); |
| 6907 CONVERT_ARG_HANDLE_CHECKED(String, s, 0); | 6901 CONVERT_ARG_HANDLE_CHECKED(String, s, 0); |
| 6908 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]); | 6902 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]); |
| 6909 | 6903 |
| 6910 s = String::Flatten(s); | 6904 s = String::Flatten(s); |
| 6911 const int length = static_cast<int>(Min<uint32_t>(s->length(), limit)); | 6905 const int length = static_cast<int>(Min<uint32_t>(s->length(), limit)); |
| 6912 | 6906 |
| 6913 Handle<FixedArray> elements; | 6907 Handle<FixedArray> elements; |
| 6914 int position = 0; | 6908 int position = 0; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 6943 #ifdef DEBUG | 6937 #ifdef DEBUG |
| 6944 for (int i = 0; i < length; ++i) { | 6938 for (int i = 0; i < length; ++i) { |
| 6945 ASSERT(String::cast(elements->get(i))->length() == 1); | 6939 ASSERT(String::cast(elements->get(i))->length() == 1); |
| 6946 } | 6940 } |
| 6947 #endif | 6941 #endif |
| 6948 | 6942 |
| 6949 return *isolate->factory()->NewJSArrayWithElements(elements); | 6943 return *isolate->factory()->NewJSArrayWithElements(elements); |
| 6950 } | 6944 } |
| 6951 | 6945 |
| 6952 | 6946 |
| 6953 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewStringWrapper) { | 6947 RUNTIME_FUNCTION(Runtime_NewStringWrapper) { |
| 6954 HandleScope scope(isolate); | 6948 HandleScope scope(isolate); |
| 6955 ASSERT(args.length() == 1); | 6949 ASSERT(args.length() == 1); |
| 6956 CONVERT_ARG_HANDLE_CHECKED(String, value, 0); | 6950 CONVERT_ARG_HANDLE_CHECKED(String, value, 0); |
| 6957 return *Object::ToObject(isolate, value).ToHandleChecked(); | 6951 return *Object::ToObject(isolate, value).ToHandleChecked(); |
| 6958 } | 6952 } |
| 6959 | 6953 |
| 6960 | 6954 |
| 6961 bool Runtime::IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch) { | 6955 bool Runtime::IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch) { |
| 6962 unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth]; | 6956 unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth]; |
| 6963 int char_length = runtime_state->to_upper_mapping()->get(ch, 0, chars); | 6957 int char_length = runtime_state->to_upper_mapping()->get(ch, 0, chars); |
| 6964 return char_length == 0; | 6958 return char_length == 0; |
| 6965 } | 6959 } |
| 6966 | 6960 |
| 6967 | 6961 |
| 6968 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NumberToString) { | 6962 RUNTIME_FUNCTION(RuntimeHidden_NumberToString) { |
| 6969 HandleScope scope(isolate); | 6963 HandleScope scope(isolate); |
| 6970 ASSERT(args.length() == 1); | 6964 ASSERT(args.length() == 1); |
| 6971 CONVERT_NUMBER_ARG_HANDLE_CHECKED(number, 0); | 6965 CONVERT_NUMBER_ARG_HANDLE_CHECKED(number, 0); |
| 6972 | 6966 |
| 6973 return *isolate->factory()->NumberToString(number); | 6967 return *isolate->factory()->NumberToString(number); |
| 6974 } | 6968 } |
| 6975 | 6969 |
| 6976 | 6970 |
| 6977 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NumberToStringSkipCache) { | 6971 RUNTIME_FUNCTION(RuntimeHidden_NumberToStringSkipCache) { |
| 6978 HandleScope scope(isolate); | 6972 HandleScope scope(isolate); |
| 6979 ASSERT(args.length() == 1); | 6973 ASSERT(args.length() == 1); |
| 6980 CONVERT_NUMBER_ARG_HANDLE_CHECKED(number, 0); | 6974 CONVERT_NUMBER_ARG_HANDLE_CHECKED(number, 0); |
| 6981 | 6975 |
| 6982 return *isolate->factory()->NumberToString(number, false); | 6976 return *isolate->factory()->NumberToString(number, false); |
| 6983 } | 6977 } |
| 6984 | 6978 |
| 6985 | 6979 |
| 6986 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToInteger) { | 6980 RUNTIME_FUNCTION(Runtime_NumberToInteger) { |
| 6987 HandleScope scope(isolate); | 6981 HandleScope scope(isolate); |
| 6988 ASSERT(args.length() == 1); | 6982 ASSERT(args.length() == 1); |
| 6989 | 6983 |
| 6990 CONVERT_DOUBLE_ARG_CHECKED(number, 0); | 6984 CONVERT_DOUBLE_ARG_CHECKED(number, 0); |
| 6991 return *isolate->factory()->NewNumber(DoubleToInteger(number)); | 6985 return *isolate->factory()->NewNumber(DoubleToInteger(number)); |
| 6992 } | 6986 } |
| 6993 | 6987 |
| 6994 | 6988 |
| 6995 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToIntegerMapMinusZero) { | 6989 RUNTIME_FUNCTION(Runtime_NumberToIntegerMapMinusZero) { |
| 6996 HandleScope scope(isolate); | 6990 HandleScope scope(isolate); |
| 6997 ASSERT(args.length() == 1); | 6991 ASSERT(args.length() == 1); |
| 6998 | 6992 |
| 6999 CONVERT_DOUBLE_ARG_CHECKED(number, 0); | 6993 CONVERT_DOUBLE_ARG_CHECKED(number, 0); |
| 7000 double double_value = DoubleToInteger(number); | 6994 double double_value = DoubleToInteger(number); |
| 7001 // Map both -0 and +0 to +0. | 6995 // Map both -0 and +0 to +0. |
| 7002 if (double_value == 0) double_value = 0; | 6996 if (double_value == 0) double_value = 0; |
| 7003 | 6997 |
| 7004 return *isolate->factory()->NewNumber(double_value); | 6998 return *isolate->factory()->NewNumber(double_value); |
| 7005 } | 6999 } |
| 7006 | 7000 |
| 7007 | 7001 |
| 7008 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToJSUint32) { | 7002 RUNTIME_FUNCTION(Runtime_NumberToJSUint32) { |
| 7009 HandleScope scope(isolate); | 7003 HandleScope scope(isolate); |
| 7010 ASSERT(args.length() == 1); | 7004 ASSERT(args.length() == 1); |
| 7011 | 7005 |
| 7012 CONVERT_NUMBER_CHECKED(int32_t, number, Uint32, args[0]); | 7006 CONVERT_NUMBER_CHECKED(int32_t, number, Uint32, args[0]); |
| 7013 return *isolate->factory()->NewNumberFromUint(number); | 7007 return *isolate->factory()->NewNumberFromUint(number); |
| 7014 } | 7008 } |
| 7015 | 7009 |
| 7016 | 7010 |
| 7017 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToJSInt32) { | 7011 RUNTIME_FUNCTION(Runtime_NumberToJSInt32) { |
| 7018 HandleScope scope(isolate); | 7012 HandleScope scope(isolate); |
| 7019 ASSERT(args.length() == 1); | 7013 ASSERT(args.length() == 1); |
| 7020 | 7014 |
| 7021 CONVERT_DOUBLE_ARG_CHECKED(number, 0); | 7015 CONVERT_DOUBLE_ARG_CHECKED(number, 0); |
| 7022 return *isolate->factory()->NewNumberFromInt(DoubleToInt32(number)); | 7016 return *isolate->factory()->NewNumberFromInt(DoubleToInt32(number)); |
| 7023 } | 7017 } |
| 7024 | 7018 |
| 7025 | 7019 |
| 7026 // Converts a Number to a Smi, if possible. Returns NaN if the number is not | 7020 // Converts a Number to a Smi, if possible. Returns NaN if the number is not |
| 7027 // a small integer. | 7021 // a small integer. |
| 7028 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NumberToSmi) { | 7022 RUNTIME_FUNCTION(RuntimeHidden_NumberToSmi) { |
| 7029 SealHandleScope shs(isolate); | 7023 SealHandleScope shs(isolate); |
| 7030 ASSERT(args.length() == 1); | 7024 ASSERT(args.length() == 1); |
| 7031 CONVERT_ARG_CHECKED(Object, obj, 0); | 7025 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 7032 if (obj->IsSmi()) { | 7026 if (obj->IsSmi()) { |
| 7033 return obj; | 7027 return obj; |
| 7034 } | 7028 } |
| 7035 if (obj->IsHeapNumber()) { | 7029 if (obj->IsHeapNumber()) { |
| 7036 double value = HeapNumber::cast(obj)->value(); | 7030 double value = HeapNumber::cast(obj)->value(); |
| 7037 int int_value = FastD2I(value); | 7031 int int_value = FastD2I(value); |
| 7038 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) { | 7032 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) { |
| 7039 return Smi::FromInt(int_value); | 7033 return Smi::FromInt(int_value); |
| 7040 } | 7034 } |
| 7041 } | 7035 } |
| 7042 return isolate->heap()->nan_value(); | 7036 return isolate->heap()->nan_value(); |
| 7043 } | 7037 } |
| 7044 | 7038 |
| 7045 | 7039 |
| 7046 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_AllocateHeapNumber) { | 7040 RUNTIME_FUNCTION(RuntimeHidden_AllocateHeapNumber) { |
| 7047 HandleScope scope(isolate); | 7041 HandleScope scope(isolate); |
| 7048 ASSERT(args.length() == 0); | 7042 ASSERT(args.length() == 0); |
| 7049 return *isolate->factory()->NewHeapNumber(0); | 7043 return *isolate->factory()->NewHeapNumber(0); |
| 7050 } | 7044 } |
| 7051 | 7045 |
| 7052 | 7046 |
| 7053 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAdd) { | 7047 RUNTIME_FUNCTION(Runtime_NumberAdd) { |
| 7054 HandleScope scope(isolate); | 7048 HandleScope scope(isolate); |
| 7055 ASSERT(args.length() == 2); | 7049 ASSERT(args.length() == 2); |
| 7056 | 7050 |
| 7057 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7051 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7058 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7052 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
| 7059 return *isolate->factory()->NewNumber(x + y); | 7053 return *isolate->factory()->NewNumber(x + y); |
| 7060 } | 7054 } |
| 7061 | 7055 |
| 7062 | 7056 |
| 7063 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberSub) { | 7057 RUNTIME_FUNCTION(Runtime_NumberSub) { |
| 7064 HandleScope scope(isolate); | 7058 HandleScope scope(isolate); |
| 7065 ASSERT(args.length() == 2); | 7059 ASSERT(args.length() == 2); |
| 7066 | 7060 |
| 7067 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7061 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7068 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7062 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
| 7069 return *isolate->factory()->NewNumber(x - y); | 7063 return *isolate->factory()->NewNumber(x - y); |
| 7070 } | 7064 } |
| 7071 | 7065 |
| 7072 | 7066 |
| 7073 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberMul) { | 7067 RUNTIME_FUNCTION(Runtime_NumberMul) { |
| 7074 HandleScope scope(isolate); | 7068 HandleScope scope(isolate); |
| 7075 ASSERT(args.length() == 2); | 7069 ASSERT(args.length() == 2); |
| 7076 | 7070 |
| 7077 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7071 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7078 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7072 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
| 7079 return *isolate->factory()->NewNumber(x * y); | 7073 return *isolate->factory()->NewNumber(x * y); |
| 7080 } | 7074 } |
| 7081 | 7075 |
| 7082 | 7076 |
| 7083 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberUnaryMinus) { | 7077 RUNTIME_FUNCTION(Runtime_NumberUnaryMinus) { |
| 7084 HandleScope scope(isolate); | 7078 HandleScope scope(isolate); |
| 7085 ASSERT(args.length() == 1); | 7079 ASSERT(args.length() == 1); |
| 7086 | 7080 |
| 7087 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7081 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7088 return *isolate->factory()->NewNumber(-x); | 7082 return *isolate->factory()->NewNumber(-x); |
| 7089 } | 7083 } |
| 7090 | 7084 |
| 7091 | 7085 |
| 7092 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberDiv) { | 7086 RUNTIME_FUNCTION(Runtime_NumberDiv) { |
| 7093 HandleScope scope(isolate); | 7087 HandleScope scope(isolate); |
| 7094 ASSERT(args.length() == 2); | 7088 ASSERT(args.length() == 2); |
| 7095 | 7089 |
| 7096 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7090 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7097 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7091 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
| 7098 return *isolate->factory()->NewNumber(x / y); | 7092 return *isolate->factory()->NewNumber(x / y); |
| 7099 } | 7093 } |
| 7100 | 7094 |
| 7101 | 7095 |
| 7102 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberMod) { | 7096 RUNTIME_FUNCTION(Runtime_NumberMod) { |
| 7103 HandleScope scope(isolate); | 7097 HandleScope scope(isolate); |
| 7104 ASSERT(args.length() == 2); | 7098 ASSERT(args.length() == 2); |
| 7105 | 7099 |
| 7106 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7100 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7107 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7101 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
| 7108 return *isolate->factory()->NewNumber(modulo(x, y)); | 7102 return *isolate->factory()->NewNumber(modulo(x, y)); |
| 7109 } | 7103 } |
| 7110 | 7104 |
| 7111 | 7105 |
| 7112 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberImul) { | 7106 RUNTIME_FUNCTION(Runtime_NumberImul) { |
| 7113 HandleScope scope(isolate); | 7107 HandleScope scope(isolate); |
| 7114 ASSERT(args.length() == 2); | 7108 ASSERT(args.length() == 2); |
| 7115 | 7109 |
| 7116 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 7110 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
| 7117 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 7111 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
| 7118 return *isolate->factory()->NewNumberFromInt(x * y); | 7112 return *isolate->factory()->NewNumberFromInt(x * y); |
| 7119 } | 7113 } |
| 7120 | 7114 |
| 7121 | 7115 |
| 7122 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_StringAdd) { | 7116 RUNTIME_FUNCTION(RuntimeHidden_StringAdd) { |
| 7123 HandleScope scope(isolate); | 7117 HandleScope scope(isolate); |
| 7124 ASSERT(args.length() == 2); | 7118 ASSERT(args.length() == 2); |
| 7125 CONVERT_ARG_HANDLE_CHECKED(String, str1, 0); | 7119 CONVERT_ARG_HANDLE_CHECKED(String, str1, 0); |
| 7126 CONVERT_ARG_HANDLE_CHECKED(String, str2, 1); | 7120 CONVERT_ARG_HANDLE_CHECKED(String, str2, 1); |
| 7127 isolate->counters()->string_add_runtime()->Increment(); | 7121 isolate->counters()->string_add_runtime()->Increment(); |
| 7128 Handle<String> result; | 7122 Handle<String> result; |
| 7129 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 7123 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 7130 isolate, result, isolate->factory()->NewConsString(str1, str2)); | 7124 isolate, result, isolate->factory()->NewConsString(str1, str2)); |
| 7131 return *result; | 7125 return *result; |
| 7132 } | 7126 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7220 } | 7214 } |
| 7221 if (increment > String::kMaxLength - position) { | 7215 if (increment > String::kMaxLength - position) { |
| 7222 return kMaxInt; // Provoke throw on allocation. | 7216 return kMaxInt; // Provoke throw on allocation. |
| 7223 } | 7217 } |
| 7224 position += increment; | 7218 position += increment; |
| 7225 } | 7219 } |
| 7226 return position; | 7220 return position; |
| 7227 } | 7221 } |
| 7228 | 7222 |
| 7229 | 7223 |
| 7230 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderConcat) { | 7224 RUNTIME_FUNCTION(Runtime_StringBuilderConcat) { |
| 7231 HandleScope scope(isolate); | 7225 HandleScope scope(isolate); |
| 7232 ASSERT(args.length() == 3); | 7226 ASSERT(args.length() == 3); |
| 7233 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); | 7227 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); |
| 7234 if (!args[1]->IsSmi()) return isolate->ThrowInvalidStringLength(); | 7228 if (!args[1]->IsSmi()) return isolate->ThrowInvalidStringLength(); |
| 7235 CONVERT_SMI_ARG_CHECKED(array_length, 1); | 7229 CONVERT_SMI_ARG_CHECKED(array_length, 1); |
| 7236 CONVERT_ARG_HANDLE_CHECKED(String, special, 2); | 7230 CONVERT_ARG_HANDLE_CHECKED(String, special, 2); |
| 7237 | 7231 |
| 7238 // This assumption is used by the slice encoding in one or two smis. | 7232 // This assumption is used by the slice encoding in one or two smis. |
| 7239 ASSERT(Smi::kMaxValue >= String::kMaxLength); | 7233 ASSERT(Smi::kMaxValue >= String::kMaxLength); |
| 7240 | 7234 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7285 isolate->factory()->NewRawTwoByteString(length)); | 7279 isolate->factory()->NewRawTwoByteString(length)); |
| 7286 StringBuilderConcatHelper(*special, | 7280 StringBuilderConcatHelper(*special, |
| 7287 answer->GetChars(), | 7281 answer->GetChars(), |
| 7288 FixedArray::cast(array->elements()), | 7282 FixedArray::cast(array->elements()), |
| 7289 array_length); | 7283 array_length); |
| 7290 return *answer; | 7284 return *answer; |
| 7291 } | 7285 } |
| 7292 } | 7286 } |
| 7293 | 7287 |
| 7294 | 7288 |
| 7295 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderJoin) { | 7289 RUNTIME_FUNCTION(Runtime_StringBuilderJoin) { |
| 7296 HandleScope scope(isolate); | 7290 HandleScope scope(isolate); |
| 7297 ASSERT(args.length() == 3); | 7291 ASSERT(args.length() == 3); |
| 7298 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); | 7292 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); |
| 7299 if (!args[1]->IsSmi()) return isolate->ThrowInvalidStringLength(); | 7293 if (!args[1]->IsSmi()) return isolate->ThrowInvalidStringLength(); |
| 7300 CONVERT_SMI_ARG_CHECKED(array_length, 1); | 7294 CONVERT_SMI_ARG_CHECKED(array_length, 1); |
| 7301 CONVERT_ARG_HANDLE_CHECKED(String, separator, 2); | 7295 CONVERT_ARG_HANDLE_CHECKED(String, separator, 2); |
| 7302 RUNTIME_ASSERT(array->HasFastObjectElements()); | 7296 RUNTIME_ASSERT(array->HasFastObjectElements()); |
| 7303 | 7297 |
| 7304 Handle<FixedArray> fixed_array(FixedArray::cast(array->elements())); | 7298 Handle<FixedArray> fixed_array(FixedArray::cast(array->elements())); |
| 7305 if (fixed_array->length() < array_length) { | 7299 if (fixed_array->length() < array_length) { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7405 String::WriteToFlat<Char>(separator, &buffer[cursor], | 7399 String::WriteToFlat<Char>(separator, &buffer[cursor], |
| 7406 0, separator_length); | 7400 0, separator_length); |
| 7407 cursor += separator_length; | 7401 cursor += separator_length; |
| 7408 previous_separator_position++; | 7402 previous_separator_position++; |
| 7409 } | 7403 } |
| 7410 } | 7404 } |
| 7411 ASSERT(cursor <= buffer.length()); | 7405 ASSERT(cursor <= buffer.length()); |
| 7412 } | 7406 } |
| 7413 | 7407 |
| 7414 | 7408 |
| 7415 RUNTIME_FUNCTION(MaybeObject*, Runtime_SparseJoinWithSeparator) { | 7409 RUNTIME_FUNCTION(Runtime_SparseJoinWithSeparator) { |
| 7416 HandleScope scope(isolate); | 7410 HandleScope scope(isolate); |
| 7417 ASSERT(args.length() == 3); | 7411 ASSERT(args.length() == 3); |
| 7418 CONVERT_ARG_HANDLE_CHECKED(JSArray, elements_array, 0); | 7412 CONVERT_ARG_HANDLE_CHECKED(JSArray, elements_array, 0); |
| 7419 RUNTIME_ASSERT(elements_array->HasFastSmiOrObjectElements()); | 7413 RUNTIME_ASSERT(elements_array->HasFastSmiOrObjectElements()); |
| 7420 CONVERT_NUMBER_CHECKED(uint32_t, array_length, Uint32, args[1]); | 7414 CONVERT_NUMBER_CHECKED(uint32_t, array_length, Uint32, args[1]); |
| 7421 CONVERT_ARG_HANDLE_CHECKED(String, separator, 2); | 7415 CONVERT_ARG_HANDLE_CHECKED(String, separator, 2); |
| 7422 // elements_array is fast-mode JSarray of alternating positions | 7416 // elements_array is fast-mode JSarray of alternating positions |
| 7423 // (increasing order) and strings. | 7417 // (increasing order) and strings. |
| 7424 // array_length is length of original array (used to add separators); | 7418 // array_length is length of original array (used to add separators); |
| 7425 // separator is string to put between elements. Assumed to be non-empty. | 7419 // separator is string to put between elements. Assumed to be non-empty. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7492 FixedArray::cast(elements_array->elements()), | 7486 FixedArray::cast(elements_array->elements()), |
| 7493 elements_length, | 7487 elements_length, |
| 7494 array_length, | 7488 array_length, |
| 7495 *separator, | 7489 *separator, |
| 7496 Vector<uc16>(result->GetChars(), string_length)); | 7490 Vector<uc16>(result->GetChars(), string_length)); |
| 7497 return *result; | 7491 return *result; |
| 7498 } | 7492 } |
| 7499 } | 7493 } |
| 7500 | 7494 |
| 7501 | 7495 |
| 7502 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberOr) { | 7496 RUNTIME_FUNCTION(Runtime_NumberOr) { |
| 7503 HandleScope scope(isolate); | 7497 HandleScope scope(isolate); |
| 7504 ASSERT(args.length() == 2); | 7498 ASSERT(args.length() == 2); |
| 7505 | 7499 |
| 7506 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 7500 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
| 7507 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 7501 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
| 7508 return *isolate->factory()->NewNumberFromInt(x | y); | 7502 return *isolate->factory()->NewNumberFromInt(x | y); |
| 7509 } | 7503 } |
| 7510 | 7504 |
| 7511 | 7505 |
| 7512 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAnd) { | 7506 RUNTIME_FUNCTION(Runtime_NumberAnd) { |
| 7513 HandleScope scope(isolate); | 7507 HandleScope scope(isolate); |
| 7514 ASSERT(args.length() == 2); | 7508 ASSERT(args.length() == 2); |
| 7515 | 7509 |
| 7516 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 7510 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
| 7517 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 7511 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
| 7518 return *isolate->factory()->NewNumberFromInt(x & y); | 7512 return *isolate->factory()->NewNumberFromInt(x & y); |
| 7519 } | 7513 } |
| 7520 | 7514 |
| 7521 | 7515 |
| 7522 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberXor) { | 7516 RUNTIME_FUNCTION(Runtime_NumberXor) { |
| 7523 HandleScope scope(isolate); | 7517 HandleScope scope(isolate); |
| 7524 ASSERT(args.length() == 2); | 7518 ASSERT(args.length() == 2); |
| 7525 | 7519 |
| 7526 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 7520 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
| 7527 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 7521 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
| 7528 return *isolate->factory()->NewNumberFromInt(x ^ y); | 7522 return *isolate->factory()->NewNumberFromInt(x ^ y); |
| 7529 } | 7523 } |
| 7530 | 7524 |
| 7531 | 7525 |
| 7532 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberShl) { | 7526 RUNTIME_FUNCTION(Runtime_NumberShl) { |
| 7533 HandleScope scope(isolate); | 7527 HandleScope scope(isolate); |
| 7534 ASSERT(args.length() == 2); | 7528 ASSERT(args.length() == 2); |
| 7535 | 7529 |
| 7536 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 7530 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
| 7537 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 7531 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
| 7538 return *isolate->factory()->NewNumberFromInt(x << (y & 0x1f)); | 7532 return *isolate->factory()->NewNumberFromInt(x << (y & 0x1f)); |
| 7539 } | 7533 } |
| 7540 | 7534 |
| 7541 | 7535 |
| 7542 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberShr) { | 7536 RUNTIME_FUNCTION(Runtime_NumberShr) { |
| 7543 HandleScope scope(isolate); | 7537 HandleScope scope(isolate); |
| 7544 ASSERT(args.length() == 2); | 7538 ASSERT(args.length() == 2); |
| 7545 | 7539 |
| 7546 CONVERT_NUMBER_CHECKED(uint32_t, x, Uint32, args[0]); | 7540 CONVERT_NUMBER_CHECKED(uint32_t, x, Uint32, args[0]); |
| 7547 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 7541 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
| 7548 return *isolate->factory()->NewNumberFromUint(x >> (y & 0x1f)); | 7542 return *isolate->factory()->NewNumberFromUint(x >> (y & 0x1f)); |
| 7549 } | 7543 } |
| 7550 | 7544 |
| 7551 | 7545 |
| 7552 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberSar) { | 7546 RUNTIME_FUNCTION(Runtime_NumberSar) { |
| 7553 HandleScope scope(isolate); | 7547 HandleScope scope(isolate); |
| 7554 ASSERT(args.length() == 2); | 7548 ASSERT(args.length() == 2); |
| 7555 | 7549 |
| 7556 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 7550 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
| 7557 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 7551 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
| 7558 return *isolate->factory()->NewNumberFromInt( | 7552 return *isolate->factory()->NewNumberFromInt( |
| 7559 ArithmeticShiftRight(x, y & 0x1f)); | 7553 ArithmeticShiftRight(x, y & 0x1f)); |
| 7560 } | 7554 } |
| 7561 | 7555 |
| 7562 | 7556 |
| 7563 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberEquals) { | 7557 RUNTIME_FUNCTION(Runtime_NumberEquals) { |
| 7564 SealHandleScope shs(isolate); | 7558 SealHandleScope shs(isolate); |
| 7565 ASSERT(args.length() == 2); | 7559 ASSERT(args.length() == 2); |
| 7566 | 7560 |
| 7567 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7561 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7568 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7562 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
| 7569 if (std::isnan(x)) return Smi::FromInt(NOT_EQUAL); | 7563 if (std::isnan(x)) return Smi::FromInt(NOT_EQUAL); |
| 7570 if (std::isnan(y)) return Smi::FromInt(NOT_EQUAL); | 7564 if (std::isnan(y)) return Smi::FromInt(NOT_EQUAL); |
| 7571 if (x == y) return Smi::FromInt(EQUAL); | 7565 if (x == y) return Smi::FromInt(EQUAL); |
| 7572 Object* result; | 7566 Object* result; |
| 7573 if ((fpclassify(x) == FP_ZERO) && (fpclassify(y) == FP_ZERO)) { | 7567 if ((fpclassify(x) == FP_ZERO) && (fpclassify(y) == FP_ZERO)) { |
| 7574 result = Smi::FromInt(EQUAL); | 7568 result = Smi::FromInt(EQUAL); |
| 7575 } else { | 7569 } else { |
| 7576 result = Smi::FromInt(NOT_EQUAL); | 7570 result = Smi::FromInt(NOT_EQUAL); |
| 7577 } | 7571 } |
| 7578 return result; | 7572 return result; |
| 7579 } | 7573 } |
| 7580 | 7574 |
| 7581 | 7575 |
| 7582 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringEquals) { | 7576 RUNTIME_FUNCTION(Runtime_StringEquals) { |
| 7583 HandleScope handle_scope(isolate); | 7577 HandleScope handle_scope(isolate); |
| 7584 ASSERT(args.length() == 2); | 7578 ASSERT(args.length() == 2); |
| 7585 | 7579 |
| 7586 CONVERT_ARG_HANDLE_CHECKED(String, x, 0); | 7580 CONVERT_ARG_HANDLE_CHECKED(String, x, 0); |
| 7587 CONVERT_ARG_HANDLE_CHECKED(String, y, 1); | 7581 CONVERT_ARG_HANDLE_CHECKED(String, y, 1); |
| 7588 | 7582 |
| 7589 bool not_equal = !String::Equals(x, y); | 7583 bool not_equal = !String::Equals(x, y); |
| 7590 // This is slightly convoluted because the value that signifies | 7584 // This is slightly convoluted because the value that signifies |
| 7591 // equality is 0 and inequality is 1 so we have to negate the result | 7585 // equality is 0 and inequality is 1 so we have to negate the result |
| 7592 // from String::Equals. | 7586 // from String::Equals. |
| 7593 ASSERT(not_equal == 0 || not_equal == 1); | 7587 ASSERT(not_equal == 0 || not_equal == 1); |
| 7594 STATIC_CHECK(EQUAL == 0); | 7588 STATIC_CHECK(EQUAL == 0); |
| 7595 STATIC_CHECK(NOT_EQUAL == 1); | 7589 STATIC_CHECK(NOT_EQUAL == 1); |
| 7596 return Smi::FromInt(not_equal); | 7590 return Smi::FromInt(not_equal); |
| 7597 } | 7591 } |
| 7598 | 7592 |
| 7599 | 7593 |
| 7600 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberCompare) { | 7594 RUNTIME_FUNCTION(Runtime_NumberCompare) { |
| 7601 SealHandleScope shs(isolate); | 7595 SealHandleScope shs(isolate); |
| 7602 ASSERT(args.length() == 3); | 7596 ASSERT(args.length() == 3); |
| 7603 | 7597 |
| 7604 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7598 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7605 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7599 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
| 7606 if (std::isnan(x) || std::isnan(y)) return args[2]; | 7600 if (std::isnan(x) || std::isnan(y)) return args[2]; |
| 7607 if (x == y) return Smi::FromInt(EQUAL); | 7601 if (x == y) return Smi::FromInt(EQUAL); |
| 7608 if (isless(x, y)) return Smi::FromInt(LESS); | 7602 if (isless(x, y)) return Smi::FromInt(LESS); |
| 7609 return Smi::FromInt(GREATER); | 7603 return Smi::FromInt(GREATER); |
| 7610 } | 7604 } |
| 7611 | 7605 |
| 7612 | 7606 |
| 7613 // Compare two Smis as if they were converted to strings and then | 7607 // Compare two Smis as if they were converted to strings and then |
| 7614 // compared lexicographically. | 7608 // compared lexicographically. |
| 7615 RUNTIME_FUNCTION(MaybeObject*, Runtime_SmiLexicographicCompare) { | 7609 RUNTIME_FUNCTION(Runtime_SmiLexicographicCompare) { |
| 7616 SealHandleScope shs(isolate); | 7610 SealHandleScope shs(isolate); |
| 7617 ASSERT(args.length() == 2); | 7611 ASSERT(args.length() == 2); |
| 7618 CONVERT_SMI_ARG_CHECKED(x_value, 0); | 7612 CONVERT_SMI_ARG_CHECKED(x_value, 0); |
| 7619 CONVERT_SMI_ARG_CHECKED(y_value, 1); | 7613 CONVERT_SMI_ARG_CHECKED(y_value, 1); |
| 7620 | 7614 |
| 7621 // If the integers are equal so are the string representations. | 7615 // If the integers are equal so are the string representations. |
| 7622 if (x_value == y_value) return Smi::FromInt(EQUAL); | 7616 if (x_value == y_value) return Smi::FromInt(EQUAL); |
| 7623 | 7617 |
| 7624 // If one of the integers is zero the normal integer order is the | 7618 // If one of the integers is zero the normal integer order is the |
| 7625 // same as the lexicographic order of the string representations. | 7619 // same as the lexicographic order of the string representations. |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7680 x_scaled /= 10; | 7674 x_scaled /= 10; |
| 7681 tie = GREATER; | 7675 tie = GREATER; |
| 7682 } | 7676 } |
| 7683 | 7677 |
| 7684 if (x_scaled < y_scaled) return Smi::FromInt(LESS); | 7678 if (x_scaled < y_scaled) return Smi::FromInt(LESS); |
| 7685 if (x_scaled > y_scaled) return Smi::FromInt(GREATER); | 7679 if (x_scaled > y_scaled) return Smi::FromInt(GREATER); |
| 7686 return Smi::FromInt(tie); | 7680 return Smi::FromInt(tie); |
| 7687 } | 7681 } |
| 7688 | 7682 |
| 7689 | 7683 |
| 7690 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_StringCompare) { | 7684 RUNTIME_FUNCTION(RuntimeHidden_StringCompare) { |
| 7691 HandleScope handle_scope(isolate); | 7685 HandleScope handle_scope(isolate); |
| 7692 ASSERT(args.length() == 2); | 7686 ASSERT(args.length() == 2); |
| 7693 | 7687 |
| 7694 CONVERT_ARG_HANDLE_CHECKED(String, x, 0); | 7688 CONVERT_ARG_HANDLE_CHECKED(String, x, 0); |
| 7695 CONVERT_ARG_HANDLE_CHECKED(String, y, 1); | 7689 CONVERT_ARG_HANDLE_CHECKED(String, y, 1); |
| 7696 | 7690 |
| 7697 isolate->counters()->string_compare_runtime()->Increment(); | 7691 isolate->counters()->string_compare_runtime()->Increment(); |
| 7698 | 7692 |
| 7699 // A few fast case tests before we flatten. | 7693 // A few fast case tests before we flatten. |
| 7700 if (x.is_identical_to(y)) return Smi::FromInt(EQUAL); | 7694 if (x.is_identical_to(y)) return Smi::FromInt(EQUAL); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7748 if (r == 0) { | 7742 if (r == 0) { |
| 7749 result = equal_prefix_result; | 7743 result = equal_prefix_result; |
| 7750 } else { | 7744 } else { |
| 7751 result = (r < 0) ? Smi::FromInt(LESS) : Smi::FromInt(GREATER); | 7745 result = (r < 0) ? Smi::FromInt(LESS) : Smi::FromInt(GREATER); |
| 7752 } | 7746 } |
| 7753 return result; | 7747 return result; |
| 7754 } | 7748 } |
| 7755 | 7749 |
| 7756 | 7750 |
| 7757 #define RUNTIME_UNARY_MATH(Name, name) \ | 7751 #define RUNTIME_UNARY_MATH(Name, name) \ |
| 7758 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math##Name) { \ | 7752 RUNTIME_FUNCTION(Runtime_Math##Name) { \ |
| 7759 HandleScope scope(isolate); \ | 7753 HandleScope scope(isolate); \ |
| 7760 ASSERT(args.length() == 1); \ | 7754 ASSERT(args.length() == 1); \ |
| 7761 isolate->counters()->math_##name()->Increment(); \ | 7755 isolate->counters()->math_##name()->Increment(); \ |
| 7762 CONVERT_DOUBLE_ARG_CHECKED(x, 0); \ | 7756 CONVERT_DOUBLE_ARG_CHECKED(x, 0); \ |
| 7763 return *isolate->factory()->NewHeapNumber(std::name(x)); \ | 7757 return *isolate->factory()->NewHeapNumber(std::name(x)); \ |
| 7764 } | 7758 } |
| 7765 | 7759 |
| 7766 RUNTIME_UNARY_MATH(Acos, acos) | 7760 RUNTIME_UNARY_MATH(Acos, acos) |
| 7767 RUNTIME_UNARY_MATH(Asin, asin) | 7761 RUNTIME_UNARY_MATH(Asin, asin) |
| 7768 RUNTIME_UNARY_MATH(Atan, atan) | 7762 RUNTIME_UNARY_MATH(Atan, atan) |
| 7769 RUNTIME_UNARY_MATH(Log, log) | 7763 RUNTIME_UNARY_MATH(Log, log) |
| 7770 #undef RUNTIME_UNARY_MATH | 7764 #undef RUNTIME_UNARY_MATH |
| 7771 | 7765 |
| 7772 | 7766 |
| 7773 RUNTIME_FUNCTION(MaybeObject*, Runtime_DoubleHi) { | 7767 RUNTIME_FUNCTION(Runtime_DoubleHi) { |
| 7774 HandleScope scope(isolate); | 7768 HandleScope scope(isolate); |
| 7775 ASSERT(args.length() == 1); | 7769 ASSERT(args.length() == 1); |
| 7776 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7770 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7777 uint64_t integer = double_to_uint64(x); | 7771 uint64_t integer = double_to_uint64(x); |
| 7778 integer = (integer >> 32) & 0xFFFFFFFFu; | 7772 integer = (integer >> 32) & 0xFFFFFFFFu; |
| 7779 return *isolate->factory()->NewNumber(static_cast<int32_t>(integer)); | 7773 return *isolate->factory()->NewNumber(static_cast<int32_t>(integer)); |
| 7780 } | 7774 } |
| 7781 | 7775 |
| 7782 | 7776 |
| 7783 RUNTIME_FUNCTION(MaybeObject*, Runtime_DoubleLo) { | 7777 RUNTIME_FUNCTION(Runtime_DoubleLo) { |
| 7784 HandleScope scope(isolate); | 7778 HandleScope scope(isolate); |
| 7785 ASSERT(args.length() == 1); | 7779 ASSERT(args.length() == 1); |
| 7786 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7780 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7787 return *isolate->factory()->NewNumber( | 7781 return *isolate->factory()->NewNumber( |
| 7788 static_cast<int32_t>(double_to_uint64(x) & 0xFFFFFFFFu)); | 7782 static_cast<int32_t>(double_to_uint64(x) & 0xFFFFFFFFu)); |
| 7789 } | 7783 } |
| 7790 | 7784 |
| 7791 | 7785 |
| 7792 RUNTIME_FUNCTION(MaybeObject*, Runtime_ConstructDouble) { | 7786 RUNTIME_FUNCTION(Runtime_ConstructDouble) { |
| 7793 HandleScope scope(isolate); | 7787 HandleScope scope(isolate); |
| 7794 ASSERT(args.length() == 2); | 7788 ASSERT(args.length() == 2); |
| 7795 CONVERT_NUMBER_CHECKED(uint32_t, hi, Uint32, args[0]); | 7789 CONVERT_NUMBER_CHECKED(uint32_t, hi, Uint32, args[0]); |
| 7796 CONVERT_NUMBER_CHECKED(uint32_t, lo, Uint32, args[1]); | 7790 CONVERT_NUMBER_CHECKED(uint32_t, lo, Uint32, args[1]); |
| 7797 uint64_t result = (static_cast<uint64_t>(hi) << 32) | lo; | 7791 uint64_t result = (static_cast<uint64_t>(hi) << 32) | lo; |
| 7798 return *isolate->factory()->NewNumber(uint64_to_double(result)); | 7792 return *isolate->factory()->NewNumber(uint64_to_double(result)); |
| 7799 } | 7793 } |
| 7800 | 7794 |
| 7801 | 7795 |
| 7802 static const double kPiDividedBy4 = 0.78539816339744830962; | 7796 static const double kPiDividedBy4 = 0.78539816339744830962; |
| 7803 | 7797 |
| 7804 | 7798 |
| 7805 RUNTIME_FUNCTION(MaybeObject*, Runtime_MathAtan2) { | 7799 RUNTIME_FUNCTION(Runtime_MathAtan2) { |
| 7806 HandleScope scope(isolate); | 7800 HandleScope scope(isolate); |
| 7807 ASSERT(args.length() == 2); | 7801 ASSERT(args.length() == 2); |
| 7808 isolate->counters()->math_atan2()->Increment(); | 7802 isolate->counters()->math_atan2()->Increment(); |
| 7809 | 7803 |
| 7810 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7804 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7811 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7805 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
| 7812 double result; | 7806 double result; |
| 7813 if (std::isinf(x) && std::isinf(y)) { | 7807 if (std::isinf(x) && std::isinf(y)) { |
| 7814 // Make sure that the result in case of two infinite arguments | 7808 // Make sure that the result in case of two infinite arguments |
| 7815 // is a multiple of Pi / 4. The sign of the result is determined | 7809 // is a multiple of Pi / 4. The sign of the result is determined |
| 7816 // by the first argument (x) and the sign of the second argument | 7810 // by the first argument (x) and the sign of the second argument |
| 7817 // determines the multiplier: one or three. | 7811 // determines the multiplier: one or three. |
| 7818 int multiplier = (x < 0) ? -1 : 1; | 7812 int multiplier = (x < 0) ? -1 : 1; |
| 7819 if (y < 0) multiplier *= 3; | 7813 if (y < 0) multiplier *= 3; |
| 7820 result = multiplier * kPiDividedBy4; | 7814 result = multiplier * kPiDividedBy4; |
| 7821 } else { | 7815 } else { |
| 7822 result = std::atan2(x, y); | 7816 result = std::atan2(x, y); |
| 7823 } | 7817 } |
| 7824 return *isolate->factory()->NewNumber(result); | 7818 return *isolate->factory()->NewNumber(result); |
| 7825 } | 7819 } |
| 7826 | 7820 |
| 7827 | 7821 |
| 7828 RUNTIME_FUNCTION(MaybeObject*, Runtime_MathExp) { | 7822 RUNTIME_FUNCTION(Runtime_MathExp) { |
| 7829 HandleScope scope(isolate); | 7823 HandleScope scope(isolate); |
| 7830 ASSERT(args.length() == 1); | 7824 ASSERT(args.length() == 1); |
| 7831 isolate->counters()->math_exp()->Increment(); | 7825 isolate->counters()->math_exp()->Increment(); |
| 7832 | 7826 |
| 7833 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7827 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7834 lazily_initialize_fast_exp(); | 7828 lazily_initialize_fast_exp(); |
| 7835 return *isolate->factory()->NewNumber(fast_exp(x)); | 7829 return *isolate->factory()->NewNumber(fast_exp(x)); |
| 7836 } | 7830 } |
| 7837 | 7831 |
| 7838 | 7832 |
| 7839 RUNTIME_FUNCTION(MaybeObject*, Runtime_MathFloor) { | 7833 RUNTIME_FUNCTION(Runtime_MathFloor) { |
| 7840 HandleScope scope(isolate); | 7834 HandleScope scope(isolate); |
| 7841 ASSERT(args.length() == 1); | 7835 ASSERT(args.length() == 1); |
| 7842 isolate->counters()->math_floor()->Increment(); | 7836 isolate->counters()->math_floor()->Increment(); |
| 7843 | 7837 |
| 7844 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7838 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7845 return *isolate->factory()->NewNumber(std::floor(x)); | 7839 return *isolate->factory()->NewNumber(std::floor(x)); |
| 7846 } | 7840 } |
| 7847 | 7841 |
| 7848 | 7842 |
| 7849 // Slow version of Math.pow. We check for fast paths for special cases. | 7843 // Slow version of Math.pow. We check for fast paths for special cases. |
| 7850 // Used if SSE2/VFP3 is not available. | 7844 // Used if SSE2/VFP3 is not available. |
| 7851 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_MathPowSlow) { | 7845 RUNTIME_FUNCTION(RuntimeHidden_MathPowSlow) { |
| 7852 HandleScope scope(isolate); | 7846 HandleScope scope(isolate); |
| 7853 ASSERT(args.length() == 2); | 7847 ASSERT(args.length() == 2); |
| 7854 isolate->counters()->math_pow()->Increment(); | 7848 isolate->counters()->math_pow()->Increment(); |
| 7855 | 7849 |
| 7856 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7850 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7857 | 7851 |
| 7858 // If the second argument is a smi, it is much faster to call the | 7852 // If the second argument is a smi, it is much faster to call the |
| 7859 // custom powi() function than the generic pow(). | 7853 // custom powi() function than the generic pow(). |
| 7860 if (args[1]->IsSmi()) { | 7854 if (args[1]->IsSmi()) { |
| 7861 int y = args.smi_at(1); | 7855 int y = args.smi_at(1); |
| 7862 return *isolate->factory()->NewNumber(power_double_int(x, y)); | 7856 return *isolate->factory()->NewNumber(power_double_int(x, y)); |
| 7863 } | 7857 } |
| 7864 | 7858 |
| 7865 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7859 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
| 7866 double result = power_helper(x, y); | 7860 double result = power_helper(x, y); |
| 7867 if (std::isnan(result)) return isolate->heap()->nan_value(); | 7861 if (std::isnan(result)) return isolate->heap()->nan_value(); |
| 7868 return *isolate->factory()->NewNumber(result); | 7862 return *isolate->factory()->NewNumber(result); |
| 7869 } | 7863 } |
| 7870 | 7864 |
| 7871 | 7865 |
| 7872 // Fast version of Math.pow if we know that y is not an integer and y is not | 7866 // Fast version of Math.pow if we know that y is not an integer and y is not |
| 7873 // -0.5 or 0.5. Used as slow case from full codegen. | 7867 // -0.5 or 0.5. Used as slow case from full codegen. |
| 7874 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_MathPow) { | 7868 RUNTIME_FUNCTION(RuntimeHidden_MathPow) { |
| 7875 HandleScope scope(isolate); | 7869 HandleScope scope(isolate); |
| 7876 ASSERT(args.length() == 2); | 7870 ASSERT(args.length() == 2); |
| 7877 isolate->counters()->math_pow()->Increment(); | 7871 isolate->counters()->math_pow()->Increment(); |
| 7878 | 7872 |
| 7879 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7873 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7880 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7874 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
| 7881 if (y == 0) { | 7875 if (y == 0) { |
| 7882 return Smi::FromInt(1); | 7876 return Smi::FromInt(1); |
| 7883 } else { | 7877 } else { |
| 7884 double result = power_double_double(x, y); | 7878 double result = power_double_double(x, y); |
| 7885 if (std::isnan(result)) return isolate->heap()->nan_value(); | 7879 if (std::isnan(result)) return isolate->heap()->nan_value(); |
| 7886 return *isolate->factory()->NewNumber(result); | 7880 return *isolate->factory()->NewNumber(result); |
| 7887 } | 7881 } |
| 7888 } | 7882 } |
| 7889 | 7883 |
| 7890 | 7884 |
| 7891 RUNTIME_FUNCTION(MaybeObject*, Runtime_RoundNumber) { | 7885 RUNTIME_FUNCTION(Runtime_RoundNumber) { |
| 7892 HandleScope scope(isolate); | 7886 HandleScope scope(isolate); |
| 7893 ASSERT(args.length() == 1); | 7887 ASSERT(args.length() == 1); |
| 7894 isolate->counters()->math_round()->Increment(); | 7888 isolate->counters()->math_round()->Increment(); |
| 7895 | 7889 |
| 7896 if (!args[0]->IsHeapNumber()) { | 7890 if (!args[0]->IsHeapNumber()) { |
| 7897 // Must be smi. Return the argument unchanged for all the other types | 7891 // Must be smi. Return the argument unchanged for all the other types |
| 7898 // to make fuzz-natives test happy. | 7892 // to make fuzz-natives test happy. |
| 7899 return args[0]; | 7893 return args[0]; |
| 7900 } | 7894 } |
| 7901 | 7895 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 7924 return number; | 7918 return number; |
| 7925 } | 7919 } |
| 7926 | 7920 |
| 7927 if (sign && value >= -0.5) return isolate->heap()->minus_zero_value(); | 7921 if (sign && value >= -0.5) return isolate->heap()->minus_zero_value(); |
| 7928 | 7922 |
| 7929 // Do not call NumberFromDouble() to avoid extra checks. | 7923 // Do not call NumberFromDouble() to avoid extra checks. |
| 7930 return *isolate->factory()->NewNumber(std::floor(value + 0.5)); | 7924 return *isolate->factory()->NewNumber(std::floor(value + 0.5)); |
| 7931 } | 7925 } |
| 7932 | 7926 |
| 7933 | 7927 |
| 7934 RUNTIME_FUNCTION(MaybeObject*, Runtime_MathSqrt) { | 7928 RUNTIME_FUNCTION(Runtime_MathSqrt) { |
| 7935 HandleScope scope(isolate); | 7929 HandleScope scope(isolate); |
| 7936 ASSERT(args.length() == 1); | 7930 ASSERT(args.length() == 1); |
| 7937 isolate->counters()->math_sqrt()->Increment(); | 7931 isolate->counters()->math_sqrt()->Increment(); |
| 7938 | 7932 |
| 7939 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7933 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7940 return *isolate->factory()->NewNumber(fast_sqrt(x)); | 7934 return *isolate->factory()->NewNumber(fast_sqrt(x)); |
| 7941 } | 7935 } |
| 7942 | 7936 |
| 7943 | 7937 |
| 7944 RUNTIME_FUNCTION(MaybeObject*, Runtime_MathFround) { | 7938 RUNTIME_FUNCTION(Runtime_MathFround) { |
| 7945 HandleScope scope(isolate); | 7939 HandleScope scope(isolate); |
| 7946 ASSERT(args.length() == 1); | 7940 ASSERT(args.length() == 1); |
| 7947 | 7941 |
| 7948 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7942 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7949 float xf = static_cast<float>(x); | 7943 float xf = static_cast<float>(x); |
| 7950 return *isolate->factory()->NewNumber(xf); | 7944 return *isolate->factory()->NewNumber(xf); |
| 7951 } | 7945 } |
| 7952 | 7946 |
| 7953 | 7947 |
| 7954 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateMakeDay) { | 7948 RUNTIME_FUNCTION(Runtime_DateMakeDay) { |
| 7955 SealHandleScope shs(isolate); | 7949 SealHandleScope shs(isolate); |
| 7956 ASSERT(args.length() == 2); | 7950 ASSERT(args.length() == 2); |
| 7957 | 7951 |
| 7958 CONVERT_SMI_ARG_CHECKED(year, 0); | 7952 CONVERT_SMI_ARG_CHECKED(year, 0); |
| 7959 CONVERT_SMI_ARG_CHECKED(month, 1); | 7953 CONVERT_SMI_ARG_CHECKED(month, 1); |
| 7960 | 7954 |
| 7961 return Smi::FromInt(isolate->date_cache()->DaysFromYearMonth(year, month)); | 7955 return Smi::FromInt(isolate->date_cache()->DaysFromYearMonth(year, month)); |
| 7962 } | 7956 } |
| 7963 | 7957 |
| 7964 | 7958 |
| 7965 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateSetValue) { | 7959 RUNTIME_FUNCTION(Runtime_DateSetValue) { |
| 7966 HandleScope scope(isolate); | 7960 HandleScope scope(isolate); |
| 7967 ASSERT(args.length() == 3); | 7961 ASSERT(args.length() == 3); |
| 7968 | 7962 |
| 7969 CONVERT_ARG_HANDLE_CHECKED(JSDate, date, 0); | 7963 CONVERT_ARG_HANDLE_CHECKED(JSDate, date, 0); |
| 7970 CONVERT_DOUBLE_ARG_CHECKED(time, 1); | 7964 CONVERT_DOUBLE_ARG_CHECKED(time, 1); |
| 7971 CONVERT_SMI_ARG_CHECKED(is_utc, 2); | 7965 CONVERT_SMI_ARG_CHECKED(is_utc, 2); |
| 7972 | 7966 |
| 7973 DateCache* date_cache = isolate->date_cache(); | 7967 DateCache* date_cache = isolate->date_cache(); |
| 7974 | 7968 |
| 7975 Handle<Object> value;; | 7969 Handle<Object> value;; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 7990 is_value_nan = true; | 7984 is_value_nan = true; |
| 7991 } else { | 7985 } else { |
| 7992 value = isolate->factory()->NewNumber(DoubleToInteger(time)); | 7986 value = isolate->factory()->NewNumber(DoubleToInteger(time)); |
| 7993 } | 7987 } |
| 7994 } | 7988 } |
| 7995 date->SetValue(*value, is_value_nan); | 7989 date->SetValue(*value, is_value_nan); |
| 7996 return *value; | 7990 return *value; |
| 7997 } | 7991 } |
| 7998 | 7992 |
| 7999 | 7993 |
| 8000 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NewArgumentsFast) { | 7994 RUNTIME_FUNCTION(RuntimeHidden_NewArgumentsFast) { |
| 8001 HandleScope scope(isolate); | 7995 HandleScope scope(isolate); |
| 8002 ASSERT(args.length() == 3); | 7996 ASSERT(args.length() == 3); |
| 8003 | 7997 |
| 8004 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0); | 7998 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0); |
| 8005 Object** parameters = reinterpret_cast<Object**>(args[1]); | 7999 Object** parameters = reinterpret_cast<Object**>(args[1]); |
| 8006 CONVERT_SMI_ARG_CHECKED(argument_count, 2); | 8000 CONVERT_SMI_ARG_CHECKED(argument_count, 2); |
| 8007 | 8001 |
| 8008 Handle<JSObject> result = | 8002 Handle<JSObject> result = |
| 8009 isolate->factory()->NewArgumentsObject(callee, argument_count); | 8003 isolate->factory()->NewArgumentsObject(callee, argument_count); |
| 8010 // Allocate the elements if needed. | 8004 // Allocate the elements if needed. |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8084 result->set_elements(*elements); | 8078 result->set_elements(*elements); |
| 8085 for (int i = 0; i < argument_count; ++i) { | 8079 for (int i = 0; i < argument_count; ++i) { |
| 8086 elements->set(i, *(parameters - i - 1)); | 8080 elements->set(i, *(parameters - i - 1)); |
| 8087 } | 8081 } |
| 8088 } | 8082 } |
| 8089 } | 8083 } |
| 8090 return *result; | 8084 return *result; |
| 8091 } | 8085 } |
| 8092 | 8086 |
| 8093 | 8087 |
| 8094 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NewStrictArgumentsFast) { | 8088 RUNTIME_FUNCTION(RuntimeHidden_NewStrictArgumentsFast) { |
| 8095 HandleScope scope(isolate); | 8089 HandleScope scope(isolate); |
| 8096 ASSERT(args.length() == 3); | 8090 ASSERT(args.length() == 3); |
| 8097 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0) | 8091 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0) |
| 8098 Object** parameters = reinterpret_cast<Object**>(args[1]); | 8092 Object** parameters = reinterpret_cast<Object**>(args[1]); |
| 8099 CONVERT_SMI_ARG_CHECKED(length, 2); | 8093 CONVERT_SMI_ARG_CHECKED(length, 2); |
| 8100 | 8094 |
| 8101 Handle<JSObject> result = | 8095 Handle<JSObject> result = |
| 8102 isolate->factory()->NewArgumentsObject(callee, length); | 8096 isolate->factory()->NewArgumentsObject(callee, length); |
| 8103 | 8097 |
| 8104 if (length > 0) { | 8098 if (length > 0) { |
| 8105 Handle<FixedArray> array = | 8099 Handle<FixedArray> array = |
| 8106 isolate->factory()->NewUninitializedFixedArray(length); | 8100 isolate->factory()->NewUninitializedFixedArray(length); |
| 8107 DisallowHeapAllocation no_gc; | 8101 DisallowHeapAllocation no_gc; |
| 8108 WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc); | 8102 WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc); |
| 8109 for (int i = 0; i < length; i++) { | 8103 for (int i = 0; i < length; i++) { |
| 8110 array->set(i, *--parameters, mode); | 8104 array->set(i, *--parameters, mode); |
| 8111 } | 8105 } |
| 8112 result->set_elements(*array); | 8106 result->set_elements(*array); |
| 8113 } | 8107 } |
| 8114 return *result; | 8108 return *result; |
| 8115 } | 8109 } |
| 8116 | 8110 |
| 8117 | 8111 |
| 8118 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NewClosureFromStubFailure) { | 8112 RUNTIME_FUNCTION(RuntimeHidden_NewClosureFromStubFailure) { |
| 8119 HandleScope scope(isolate); | 8113 HandleScope scope(isolate); |
| 8120 ASSERT(args.length() == 1); | 8114 ASSERT(args.length() == 1); |
| 8121 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0); | 8115 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0); |
| 8122 Handle<Context> context(isolate->context()); | 8116 Handle<Context> context(isolate->context()); |
| 8123 PretenureFlag pretenure_flag = NOT_TENURED; | 8117 PretenureFlag pretenure_flag = NOT_TENURED; |
| 8124 return *isolate->factory()->NewFunctionFromSharedFunctionInfo( | 8118 return *isolate->factory()->NewFunctionFromSharedFunctionInfo( |
| 8125 shared, context, pretenure_flag); | 8119 shared, context, pretenure_flag); |
| 8126 } | 8120 } |
| 8127 | 8121 |
| 8128 | 8122 |
| 8129 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NewClosure) { | 8123 RUNTIME_FUNCTION(RuntimeHidden_NewClosure) { |
| 8130 HandleScope scope(isolate); | 8124 HandleScope scope(isolate); |
| 8131 ASSERT(args.length() == 3); | 8125 ASSERT(args.length() == 3); |
| 8132 CONVERT_ARG_HANDLE_CHECKED(Context, context, 0); | 8126 CONVERT_ARG_HANDLE_CHECKED(Context, context, 0); |
| 8133 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 1); | 8127 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 1); |
| 8134 CONVERT_BOOLEAN_ARG_CHECKED(pretenure, 2); | 8128 CONVERT_BOOLEAN_ARG_CHECKED(pretenure, 2); |
| 8135 | 8129 |
| 8136 // The caller ensures that we pretenure closures that are assigned | 8130 // The caller ensures that we pretenure closures that are assigned |
| 8137 // directly to properties. | 8131 // directly to properties. |
| 8138 PretenureFlag pretenure_flag = pretenure ? TENURED : NOT_TENURED; | 8132 PretenureFlag pretenure_flag = pretenure ? TENURED : NOT_TENURED; |
| 8139 return *isolate->factory()->NewFunctionFromSharedFunctionInfo( | 8133 return *isolate->factory()->NewFunctionFromSharedFunctionInfo( |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8184 NewArray<Handle<Object> >(*total_argc)); | 8178 NewArray<Handle<Object> >(*total_argc)); |
| 8185 for (int i = 0; i < args_count; i++) { | 8179 for (int i = 0; i < args_count; i++) { |
| 8186 Handle<Object> val = Handle<Object>(frame->GetParameter(i), isolate); | 8180 Handle<Object> val = Handle<Object>(frame->GetParameter(i), isolate); |
| 8187 param_data[prefix_argc + i] = val; | 8181 param_data[prefix_argc + i] = val; |
| 8188 } | 8182 } |
| 8189 return param_data; | 8183 return param_data; |
| 8190 } | 8184 } |
| 8191 } | 8185 } |
| 8192 | 8186 |
| 8193 | 8187 |
| 8194 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionBindArguments) { | 8188 RUNTIME_FUNCTION(Runtime_FunctionBindArguments) { |
| 8195 HandleScope scope(isolate); | 8189 HandleScope scope(isolate); |
| 8196 ASSERT(args.length() == 4); | 8190 ASSERT(args.length() == 4); |
| 8197 CONVERT_ARG_HANDLE_CHECKED(JSFunction, bound_function, 0); | 8191 CONVERT_ARG_HANDLE_CHECKED(JSFunction, bound_function, 0); |
| 8198 RUNTIME_ASSERT(args[3]->IsNumber()); | 8192 RUNTIME_ASSERT(args[3]->IsNumber()); |
| 8199 Handle<Object> bindee = args.at<Object>(1); | 8193 Handle<Object> bindee = args.at<Object>(1); |
| 8200 | 8194 |
| 8201 // TODO(lrn): Create bound function in C++ code from premade shared info. | 8195 // TODO(lrn): Create bound function in C++ code from premade shared info. |
| 8202 bound_function->shared()->set_bound(true); | 8196 bound_function->shared()->set_bound(true); |
| 8203 // Get all arguments of calling function (Function.prototype.bind). | 8197 // Get all arguments of calling function (Function.prototype.bind). |
| 8204 int argc = 0; | 8198 int argc = 0; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8245 Handle<String> length_string = isolate->factory()->length_string(); | 8239 Handle<String> length_string = isolate->factory()->length_string(); |
| 8246 Handle<Object> new_length(args.at<Object>(3)); | 8240 Handle<Object> new_length(args.at<Object>(3)); |
| 8247 PropertyAttributes attr = | 8241 PropertyAttributes attr = |
| 8248 static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY); | 8242 static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY); |
| 8249 Runtime::ForceSetObjectProperty( | 8243 Runtime::ForceSetObjectProperty( |
| 8250 bound_function, length_string, new_length, attr).Assert(); | 8244 bound_function, length_string, new_length, attr).Assert(); |
| 8251 return *bound_function; | 8245 return *bound_function; |
| 8252 } | 8246 } |
| 8253 | 8247 |
| 8254 | 8248 |
| 8255 RUNTIME_FUNCTION(MaybeObject*, Runtime_BoundFunctionGetBindings) { | 8249 RUNTIME_FUNCTION(Runtime_BoundFunctionGetBindings) { |
| 8256 HandleScope handles(isolate); | 8250 HandleScope handles(isolate); |
| 8257 ASSERT(args.length() == 1); | 8251 ASSERT(args.length() == 1); |
| 8258 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, callable, 0); | 8252 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, callable, 0); |
| 8259 if (callable->IsJSFunction()) { | 8253 if (callable->IsJSFunction()) { |
| 8260 Handle<JSFunction> function = Handle<JSFunction>::cast(callable); | 8254 Handle<JSFunction> function = Handle<JSFunction>::cast(callable); |
| 8261 if (function->shared()->bound()) { | 8255 if (function->shared()->bound()) { |
| 8262 Handle<FixedArray> bindings(function->function_bindings()); | 8256 Handle<FixedArray> bindings(function->function_bindings()); |
| 8263 ASSERT(bindings->map() == isolate->heap()->fixed_cow_array_map()); | 8257 ASSERT(bindings->map() == isolate->heap()->fixed_cow_array_map()); |
| 8264 return *isolate->factory()->NewJSArrayWithElements(bindings); | 8258 return *isolate->factory()->NewJSArrayWithElements(bindings); |
| 8265 } | 8259 } |
| 8266 } | 8260 } |
| 8267 return isolate->heap()->undefined_value(); | 8261 return isolate->heap()->undefined_value(); |
| 8268 } | 8262 } |
| 8269 | 8263 |
| 8270 | 8264 |
| 8271 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewObjectFromBound) { | 8265 RUNTIME_FUNCTION(Runtime_NewObjectFromBound) { |
| 8272 HandleScope scope(isolate); | 8266 HandleScope scope(isolate); |
| 8273 ASSERT(args.length() == 1); | 8267 ASSERT(args.length() == 1); |
| 8274 // First argument is a function to use as a constructor. | 8268 // First argument is a function to use as a constructor. |
| 8275 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8269 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 8276 RUNTIME_ASSERT(function->shared()->bound()); | 8270 RUNTIME_ASSERT(function->shared()->bound()); |
| 8277 | 8271 |
| 8278 // The argument is a bound function. Extract its bound arguments | 8272 // The argument is a bound function. Extract its bound arguments |
| 8279 // and callable. | 8273 // and callable. |
| 8280 Handle<FixedArray> bound_args = | 8274 Handle<FixedArray> bound_args = |
| 8281 Handle<FixedArray>(FixedArray::cast(function->function_bindings())); | 8275 Handle<FixedArray>(FixedArray::cast(function->function_bindings())); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 8303 | 8297 |
| 8304 Handle<Object> result; | 8298 Handle<Object> result; |
| 8305 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 8299 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 8306 isolate, result, | 8300 isolate, result, |
| 8307 Execution::New(Handle<JSFunction>::cast(bound_function), | 8301 Execution::New(Handle<JSFunction>::cast(bound_function), |
| 8308 total_argc, param_data.get())); | 8302 total_argc, param_data.get())); |
| 8309 return *result; | 8303 return *result; |
| 8310 } | 8304 } |
| 8311 | 8305 |
| 8312 | 8306 |
| 8313 static MaybeObject* Runtime_NewObjectHelper(Isolate* isolate, | 8307 static Object* Runtime_NewObjectHelper(Isolate* isolate, |
| 8314 Handle<Object> constructor, | 8308 Handle<Object> constructor, |
| 8315 Handle<AllocationSite> site) { | 8309 Handle<AllocationSite> site) { |
| 8316 // If the constructor isn't a proper function we throw a type error. | 8310 // If the constructor isn't a proper function we throw a type error. |
| 8317 if (!constructor->IsJSFunction()) { | 8311 if (!constructor->IsJSFunction()) { |
| 8318 Vector< Handle<Object> > arguments = HandleVector(&constructor, 1); | 8312 Vector< Handle<Object> > arguments = HandleVector(&constructor, 1); |
| 8319 Handle<Object> type_error = | 8313 Handle<Object> type_error = |
| 8320 isolate->factory()->NewTypeError("not_constructor", arguments); | 8314 isolate->factory()->NewTypeError("not_constructor", arguments); |
| 8321 return isolate->Throw(*type_error); | 8315 return isolate->Throw(*type_error); |
| 8322 } | 8316 } |
| 8323 | 8317 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8377 result = isolate->factory()->NewJSObjectWithMemento(function, site); | 8371 result = isolate->factory()->NewJSObjectWithMemento(function, site); |
| 8378 } | 8372 } |
| 8379 | 8373 |
| 8380 isolate->counters()->constructed_objects()->Increment(); | 8374 isolate->counters()->constructed_objects()->Increment(); |
| 8381 isolate->counters()->constructed_objects_runtime()->Increment(); | 8375 isolate->counters()->constructed_objects_runtime()->Increment(); |
| 8382 | 8376 |
| 8383 return *result; | 8377 return *result; |
| 8384 } | 8378 } |
| 8385 | 8379 |
| 8386 | 8380 |
| 8387 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NewObject) { | 8381 RUNTIME_FUNCTION(RuntimeHidden_NewObject) { |
| 8388 HandleScope scope(isolate); | 8382 HandleScope scope(isolate); |
| 8389 ASSERT(args.length() == 1); | 8383 ASSERT(args.length() == 1); |
| 8390 CONVERT_ARG_HANDLE_CHECKED(Object, constructor, 0); | 8384 CONVERT_ARG_HANDLE_CHECKED(Object, constructor, 0); |
| 8391 return Runtime_NewObjectHelper(isolate, | 8385 return Runtime_NewObjectHelper(isolate, |
| 8392 constructor, | 8386 constructor, |
| 8393 Handle<AllocationSite>::null()); | 8387 Handle<AllocationSite>::null()); |
| 8394 } | 8388 } |
| 8395 | 8389 |
| 8396 | 8390 |
| 8397 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NewObjectWithAllocationSite) { | 8391 RUNTIME_FUNCTION(RuntimeHidden_NewObjectWithAllocationSite) { |
| 8398 HandleScope scope(isolate); | 8392 HandleScope scope(isolate); |
| 8399 ASSERT(args.length() == 2); | 8393 ASSERT(args.length() == 2); |
| 8400 CONVERT_ARG_HANDLE_CHECKED(Object, constructor, 1); | 8394 CONVERT_ARG_HANDLE_CHECKED(Object, constructor, 1); |
| 8401 CONVERT_ARG_HANDLE_CHECKED(Object, feedback, 0); | 8395 CONVERT_ARG_HANDLE_CHECKED(Object, feedback, 0); |
| 8402 Handle<AllocationSite> site; | 8396 Handle<AllocationSite> site; |
| 8403 if (feedback->IsAllocationSite()) { | 8397 if (feedback->IsAllocationSite()) { |
| 8404 // The feedback can be an AllocationSite or undefined. | 8398 // The feedback can be an AllocationSite or undefined. |
| 8405 site = Handle<AllocationSite>::cast(feedback); | 8399 site = Handle<AllocationSite>::cast(feedback); |
| 8406 } | 8400 } |
| 8407 return Runtime_NewObjectHelper(isolate, constructor, site); | 8401 return Runtime_NewObjectHelper(isolate, constructor, site); |
| 8408 } | 8402 } |
| 8409 | 8403 |
| 8410 | 8404 |
| 8411 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_FinalizeInstanceSize) { | 8405 RUNTIME_FUNCTION(RuntimeHidden_FinalizeInstanceSize) { |
| 8412 HandleScope scope(isolate); | 8406 HandleScope scope(isolate); |
| 8413 ASSERT(args.length() == 1); | 8407 ASSERT(args.length() == 1); |
| 8414 | 8408 |
| 8415 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8409 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 8416 function->shared()->CompleteInobjectSlackTracking(); | 8410 function->shared()->CompleteInobjectSlackTracking(); |
| 8417 | 8411 |
| 8418 return isolate->heap()->undefined_value(); | 8412 return isolate->heap()->undefined_value(); |
| 8419 } | 8413 } |
| 8420 | 8414 |
| 8421 | 8415 |
| 8422 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_CompileUnoptimized) { | 8416 RUNTIME_FUNCTION(RuntimeHidden_CompileUnoptimized) { |
| 8423 HandleScope scope(isolate); | 8417 HandleScope scope(isolate); |
| 8424 ASSERT(args.length() == 1); | 8418 ASSERT(args.length() == 1); |
| 8425 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8419 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 8426 #ifdef DEBUG | 8420 #ifdef DEBUG |
| 8427 if (FLAG_trace_lazy && !function->shared()->is_compiled()) { | 8421 if (FLAG_trace_lazy && !function->shared()->is_compiled()) { |
| 8428 PrintF("[unoptimized: "); | 8422 PrintF("[unoptimized: "); |
| 8429 function->PrintName(); | 8423 function->PrintName(); |
| 8430 PrintF("]\n"); | 8424 PrintF("]\n"); |
| 8431 } | 8425 } |
| 8432 #endif | 8426 #endif |
| 8433 | 8427 |
| 8434 // Compile the target function. | 8428 // Compile the target function. |
| 8435 ASSERT(function->shared()->allows_lazy_compilation()); | 8429 ASSERT(function->shared()->allows_lazy_compilation()); |
| 8436 | 8430 |
| 8437 Handle<Code> code = Compiler::GetUnoptimizedCode(function); | 8431 Handle<Code> code = Compiler::GetUnoptimizedCode(function); |
| 8438 RETURN_IF_EMPTY_HANDLE(isolate, code); | 8432 RETURN_IF_EMPTY_HANDLE(isolate, code); |
| 8439 function->ReplaceCode(*code); | 8433 function->ReplaceCode(*code); |
| 8440 | 8434 |
| 8441 // All done. Return the compiled code. | 8435 // All done. Return the compiled code. |
| 8442 ASSERT(function->is_compiled()); | 8436 ASSERT(function->is_compiled()); |
| 8443 ASSERT(function->code()->kind() == Code::FUNCTION || | 8437 ASSERT(function->code()->kind() == Code::FUNCTION || |
| 8444 (FLAG_always_opt && | 8438 (FLAG_always_opt && |
| 8445 function->code()->kind() == Code::OPTIMIZED_FUNCTION)); | 8439 function->code()->kind() == Code::OPTIMIZED_FUNCTION)); |
| 8446 return *code; | 8440 return *code; |
| 8447 } | 8441 } |
| 8448 | 8442 |
| 8449 | 8443 |
| 8450 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_CompileOptimized) { | 8444 RUNTIME_FUNCTION(RuntimeHidden_CompileOptimized) { |
| 8451 HandleScope scope(isolate); | 8445 HandleScope scope(isolate); |
| 8452 ASSERT(args.length() == 2); | 8446 ASSERT(args.length() == 2); |
| 8453 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8447 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 8454 CONVERT_BOOLEAN_ARG_CHECKED(concurrent, 1); | 8448 CONVERT_BOOLEAN_ARG_CHECKED(concurrent, 1); |
| 8455 | 8449 |
| 8456 Handle<Code> unoptimized(function->shared()->code()); | 8450 Handle<Code> unoptimized(function->shared()->code()); |
| 8457 if (!function->shared()->is_compiled()) { | 8451 if (!function->shared()->is_compiled()) { |
| 8458 // If the function is not compiled, do not optimize. | 8452 // If the function is not compiled, do not optimize. |
| 8459 // This can happen if the debugger is activated and | 8453 // This can happen if the debugger is activated and |
| 8460 // the function is returned to the not compiled state. | 8454 // the function is returned to the not compiled state. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8503 | 8497 |
| 8504 void VisitFrames(JavaScriptFrameIterator* it) { | 8498 void VisitFrames(JavaScriptFrameIterator* it) { |
| 8505 for (; !it->done(); it->Advance()) { | 8499 for (; !it->done(); it->Advance()) { |
| 8506 JavaScriptFrame* frame = it->frame(); | 8500 JavaScriptFrame* frame = it->frame(); |
| 8507 if (code_->contains(frame->pc())) has_code_activations_ = true; | 8501 if (code_->contains(frame->pc())) has_code_activations_ = true; |
| 8508 } | 8502 } |
| 8509 } | 8503 } |
| 8510 }; | 8504 }; |
| 8511 | 8505 |
| 8512 | 8506 |
| 8513 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NotifyStubFailure) { | 8507 RUNTIME_FUNCTION(RuntimeHidden_NotifyStubFailure) { |
| 8514 HandleScope scope(isolate); | 8508 HandleScope scope(isolate); |
| 8515 ASSERT(args.length() == 0); | 8509 ASSERT(args.length() == 0); |
| 8516 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); | 8510 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); |
| 8517 ASSERT(AllowHeapAllocation::IsAllowed()); | 8511 ASSERT(AllowHeapAllocation::IsAllowed()); |
| 8518 delete deoptimizer; | 8512 delete deoptimizer; |
| 8519 return isolate->heap()->undefined_value(); | 8513 return isolate->heap()->undefined_value(); |
| 8520 } | 8514 } |
| 8521 | 8515 |
| 8522 | 8516 |
| 8523 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NotifyDeoptimized) { | 8517 RUNTIME_FUNCTION(RuntimeHidden_NotifyDeoptimized) { |
| 8524 HandleScope scope(isolate); | 8518 HandleScope scope(isolate); |
| 8525 ASSERT(args.length() == 1); | 8519 ASSERT(args.length() == 1); |
| 8526 CONVERT_SMI_ARG_CHECKED(type_arg, 0); | 8520 CONVERT_SMI_ARG_CHECKED(type_arg, 0); |
| 8527 Deoptimizer::BailoutType type = | 8521 Deoptimizer::BailoutType type = |
| 8528 static_cast<Deoptimizer::BailoutType>(type_arg); | 8522 static_cast<Deoptimizer::BailoutType>(type_arg); |
| 8529 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); | 8523 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); |
| 8530 ASSERT(AllowHeapAllocation::IsAllowed()); | 8524 ASSERT(AllowHeapAllocation::IsAllowed()); |
| 8531 | 8525 |
| 8532 Handle<JSFunction> function = deoptimizer->function(); | 8526 Handle<JSFunction> function = deoptimizer->function(); |
| 8533 Handle<Code> optimized_code = deoptimizer->compiled_code(); | 8527 Handle<Code> optimized_code = deoptimizer->compiled_code(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8572 // TODO(titzer): we should probably do DeoptimizeCodeList(code) | 8566 // TODO(titzer): we should probably do DeoptimizeCodeList(code) |
| 8573 // unconditionally if the code is not already marked for deoptimization. | 8567 // unconditionally if the code is not already marked for deoptimization. |
| 8574 // If there is an index by shared function info, all the better. | 8568 // If there is an index by shared function info, all the better. |
| 8575 Deoptimizer::DeoptimizeFunction(*function); | 8569 Deoptimizer::DeoptimizeFunction(*function); |
| 8576 } | 8570 } |
| 8577 | 8571 |
| 8578 return isolate->heap()->undefined_value(); | 8572 return isolate->heap()->undefined_value(); |
| 8579 } | 8573 } |
| 8580 | 8574 |
| 8581 | 8575 |
| 8582 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeoptimizeFunction) { | 8576 RUNTIME_FUNCTION(Runtime_DeoptimizeFunction) { |
| 8583 HandleScope scope(isolate); | 8577 HandleScope scope(isolate); |
| 8584 ASSERT(args.length() == 1); | 8578 ASSERT(args.length() == 1); |
| 8585 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8579 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 8586 if (!function->IsOptimized()) return isolate->heap()->undefined_value(); | 8580 if (!function->IsOptimized()) return isolate->heap()->undefined_value(); |
| 8587 | 8581 |
| 8588 Deoptimizer::DeoptimizeFunction(*function); | 8582 Deoptimizer::DeoptimizeFunction(*function); |
| 8589 | 8583 |
| 8590 return isolate->heap()->undefined_value(); | 8584 return isolate->heap()->undefined_value(); |
| 8591 } | 8585 } |
| 8592 | 8586 |
| 8593 | 8587 |
| 8594 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClearFunctionTypeFeedback) { | 8588 RUNTIME_FUNCTION(Runtime_ClearFunctionTypeFeedback) { |
| 8595 HandleScope scope(isolate); | 8589 HandleScope scope(isolate); |
| 8596 ASSERT(args.length() == 1); | 8590 ASSERT(args.length() == 1); |
| 8597 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8591 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 8598 Code* unoptimized = function->shared()->code(); | 8592 Code* unoptimized = function->shared()->code(); |
| 8599 if (unoptimized->kind() == Code::FUNCTION) { | 8593 if (unoptimized->kind() == Code::FUNCTION) { |
| 8600 unoptimized->ClearInlineCaches(); | 8594 unoptimized->ClearInlineCaches(); |
| 8601 unoptimized->ClearTypeFeedbackInfo(isolate->heap()); | 8595 unoptimized->ClearTypeFeedbackInfo(isolate->heap()); |
| 8602 } | 8596 } |
| 8603 return isolate->heap()->undefined_value(); | 8597 return isolate->heap()->undefined_value(); |
| 8604 } | 8598 } |
| 8605 | 8599 |
| 8606 | 8600 |
| 8607 RUNTIME_FUNCTION(MaybeObject*, Runtime_RunningInSimulator) { | 8601 RUNTIME_FUNCTION(Runtime_RunningInSimulator) { |
| 8608 SealHandleScope shs(isolate); | 8602 SealHandleScope shs(isolate); |
| 8609 ASSERT(args.length() == 0); | 8603 ASSERT(args.length() == 0); |
| 8610 #if defined(USE_SIMULATOR) | 8604 #if defined(USE_SIMULATOR) |
| 8611 return isolate->heap()->true_value(); | 8605 return isolate->heap()->true_value(); |
| 8612 #else | 8606 #else |
| 8613 return isolate->heap()->false_value(); | 8607 return isolate->heap()->false_value(); |
| 8614 #endif | 8608 #endif |
| 8615 } | 8609 } |
| 8616 | 8610 |
| 8617 | 8611 |
| 8618 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsConcurrentRecompilationSupported) { | 8612 RUNTIME_FUNCTION(Runtime_IsConcurrentRecompilationSupported) { |
| 8619 SealHandleScope shs(isolate); | 8613 SealHandleScope shs(isolate); |
| 8620 return isolate->heap()->ToBoolean( | 8614 return isolate->heap()->ToBoolean( |
| 8621 isolate->concurrent_recompilation_enabled()); | 8615 isolate->concurrent_recompilation_enabled()); |
| 8622 } | 8616 } |
| 8623 | 8617 |
| 8624 | 8618 |
| 8625 RUNTIME_FUNCTION(MaybeObject*, Runtime_OptimizeFunctionOnNextCall) { | 8619 RUNTIME_FUNCTION(Runtime_OptimizeFunctionOnNextCall) { |
| 8626 HandleScope scope(isolate); | 8620 HandleScope scope(isolate); |
| 8627 RUNTIME_ASSERT(args.length() == 1 || args.length() == 2); | 8621 RUNTIME_ASSERT(args.length() == 1 || args.length() == 2); |
| 8628 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8622 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 8629 | 8623 |
| 8630 if (!function->IsOptimizable() && | 8624 if (!function->IsOptimizable() && |
| 8631 !function->IsMarkedForConcurrentOptimization() && | 8625 !function->IsMarkedForConcurrentOptimization() && |
| 8632 !function->IsInOptimizationQueue()) { | 8626 !function->IsInOptimizationQueue()) { |
| 8633 return isolate->heap()->undefined_value(); | 8627 return isolate->heap()->undefined_value(); |
| 8634 } | 8628 } |
| 8635 | 8629 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 8650 } else if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("concurrent")) && | 8644 } else if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("concurrent")) && |
| 8651 isolate->concurrent_recompilation_enabled()) { | 8645 isolate->concurrent_recompilation_enabled()) { |
| 8652 function->MarkForConcurrentOptimization(); | 8646 function->MarkForConcurrentOptimization(); |
| 8653 } | 8647 } |
| 8654 } | 8648 } |
| 8655 | 8649 |
| 8656 return isolate->heap()->undefined_value(); | 8650 return isolate->heap()->undefined_value(); |
| 8657 } | 8651 } |
| 8658 | 8652 |
| 8659 | 8653 |
| 8660 RUNTIME_FUNCTION(MaybeObject*, Runtime_NeverOptimizeFunction) { | 8654 RUNTIME_FUNCTION(Runtime_NeverOptimizeFunction) { |
| 8661 HandleScope scope(isolate); | 8655 HandleScope scope(isolate); |
| 8662 ASSERT(args.length() == 1); | 8656 ASSERT(args.length() == 1); |
| 8663 CONVERT_ARG_CHECKED(JSFunction, function, 0); | 8657 CONVERT_ARG_CHECKED(JSFunction, function, 0); |
| 8664 function->shared()->set_optimization_disabled(true); | 8658 function->shared()->set_optimization_disabled(true); |
| 8665 return isolate->heap()->undefined_value(); | 8659 return isolate->heap()->undefined_value(); |
| 8666 } | 8660 } |
| 8667 | 8661 |
| 8668 | 8662 |
| 8669 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationStatus) { | 8663 RUNTIME_FUNCTION(Runtime_GetOptimizationStatus) { |
| 8670 HandleScope scope(isolate); | 8664 HandleScope scope(isolate); |
| 8671 RUNTIME_ASSERT(args.length() == 1 || args.length() == 2); | 8665 RUNTIME_ASSERT(args.length() == 1 || args.length() == 2); |
| 8672 if (!isolate->use_crankshaft()) { | 8666 if (!isolate->use_crankshaft()) { |
| 8673 return Smi::FromInt(4); // 4 == "never". | 8667 return Smi::FromInt(4); // 4 == "never". |
| 8674 } | 8668 } |
| 8675 bool sync_with_compiler_thread = true; | 8669 bool sync_with_compiler_thread = true; |
| 8676 if (args.length() == 2) { | 8670 if (args.length() == 2) { |
| 8677 CONVERT_ARG_HANDLE_CHECKED(String, sync, 1); | 8671 CONVERT_ARG_HANDLE_CHECKED(String, sync, 1); |
| 8678 if (sync->IsOneByteEqualTo(STATIC_ASCII_VECTOR("no sync"))) { | 8672 if (sync->IsOneByteEqualTo(STATIC_ASCII_VECTOR("no sync"))) { |
| 8679 sync_with_compiler_thread = false; | 8673 sync_with_compiler_thread = false; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 8694 : Smi::FromInt(2); // 2 == "no". | 8688 : Smi::FromInt(2); // 2 == "no". |
| 8695 } | 8689 } |
| 8696 if (FLAG_deopt_every_n_times) { | 8690 if (FLAG_deopt_every_n_times) { |
| 8697 return Smi::FromInt(6); // 6 == "maybe deopted". | 8691 return Smi::FromInt(6); // 6 == "maybe deopted". |
| 8698 } | 8692 } |
| 8699 return function->IsOptimized() ? Smi::FromInt(1) // 1 == "yes". | 8693 return function->IsOptimized() ? Smi::FromInt(1) // 1 == "yes". |
| 8700 : Smi::FromInt(2); // 2 == "no". | 8694 : Smi::FromInt(2); // 2 == "no". |
| 8701 } | 8695 } |
| 8702 | 8696 |
| 8703 | 8697 |
| 8704 RUNTIME_FUNCTION(MaybeObject*, Runtime_UnblockConcurrentRecompilation) { | 8698 RUNTIME_FUNCTION(Runtime_UnblockConcurrentRecompilation) { |
| 8705 ASSERT(args.length() == 0); | 8699 ASSERT(args.length() == 0); |
| 8706 RUNTIME_ASSERT(FLAG_block_concurrent_recompilation); | 8700 RUNTIME_ASSERT(FLAG_block_concurrent_recompilation); |
| 8707 RUNTIME_ASSERT(isolate->concurrent_recompilation_enabled()); | 8701 RUNTIME_ASSERT(isolate->concurrent_recompilation_enabled()); |
| 8708 isolate->optimizing_compiler_thread()->Unblock(); | 8702 isolate->optimizing_compiler_thread()->Unblock(); |
| 8709 return isolate->heap()->undefined_value(); | 8703 return isolate->heap()->undefined_value(); |
| 8710 } | 8704 } |
| 8711 | 8705 |
| 8712 | 8706 |
| 8713 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationCount) { | 8707 RUNTIME_FUNCTION(Runtime_GetOptimizationCount) { |
| 8714 HandleScope scope(isolate); | 8708 HandleScope scope(isolate); |
| 8715 ASSERT(args.length() == 1); | 8709 ASSERT(args.length() == 1); |
| 8716 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8710 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 8717 return Smi::FromInt(function->shared()->opt_count()); | 8711 return Smi::FromInt(function->shared()->opt_count()); |
| 8718 } | 8712 } |
| 8719 | 8713 |
| 8720 | 8714 |
| 8721 static bool IsSuitableForOnStackReplacement(Isolate* isolate, | 8715 static bool IsSuitableForOnStackReplacement(Isolate* isolate, |
| 8722 Handle<JSFunction> function, | 8716 Handle<JSFunction> function, |
| 8723 Handle<Code> current_code) { | 8717 Handle<Code> current_code) { |
| 8724 // Keep track of whether we've succeeded in optimizing. | 8718 // Keep track of whether we've succeeded in optimizing. |
| 8725 if (!isolate->use_crankshaft() || !current_code->optimizable()) return false; | 8719 if (!isolate->use_crankshaft() || !current_code->optimizable()) return false; |
| 8726 // If we are trying to do OSR when there are already optimized | 8720 // If we are trying to do OSR when there are already optimized |
| 8727 // activations of the function, it means (a) the function is directly or | 8721 // activations of the function, it means (a) the function is directly or |
| 8728 // indirectly recursive and (b) an optimized invocation has been | 8722 // indirectly recursive and (b) an optimized invocation has been |
| 8729 // deoptimized so that we are currently in an unoptimized activation. | 8723 // deoptimized so that we are currently in an unoptimized activation. |
| 8730 // Check for optimized activations of this function. | 8724 // Check for optimized activations of this function. |
| 8731 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) { | 8725 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) { |
| 8732 JavaScriptFrame* frame = it.frame(); | 8726 JavaScriptFrame* frame = it.frame(); |
| 8733 if (frame->is_optimized() && frame->function() == *function) return false; | 8727 if (frame->is_optimized() && frame->function() == *function) return false; |
| 8734 } | 8728 } |
| 8735 | 8729 |
| 8736 return true; | 8730 return true; |
| 8737 } | 8731 } |
| 8738 | 8732 |
| 8739 | 8733 |
| 8740 RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) { | 8734 RUNTIME_FUNCTION(Runtime_CompileForOnStackReplacement) { |
| 8741 HandleScope scope(isolate); | 8735 HandleScope scope(isolate); |
| 8742 ASSERT(args.length() == 1); | 8736 ASSERT(args.length() == 1); |
| 8743 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8737 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 8744 Handle<Code> caller_code(function->shared()->code()); | 8738 Handle<Code> caller_code(function->shared()->code()); |
| 8745 | 8739 |
| 8746 // We're not prepared to handle a function with arguments object. | 8740 // We're not prepared to handle a function with arguments object. |
| 8747 ASSERT(!function->shared()->uses_arguments()); | 8741 ASSERT(!function->shared()->uses_arguments()); |
| 8748 | 8742 |
| 8749 // Passing the PC in the javascript frame from the caller directly is | 8743 // Passing the PC in the javascript frame from the caller directly is |
| 8750 // not GC safe, so we walk the stack to get it. | 8744 // not GC safe, so we walk the stack to get it. |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8843 PrintF(" at AST id %d]\n", ast_id.ToInt()); | 8837 PrintF(" at AST id %d]\n", ast_id.ToInt()); |
| 8844 } | 8838 } |
| 8845 | 8839 |
| 8846 if (!function->IsOptimized()) { | 8840 if (!function->IsOptimized()) { |
| 8847 function->ReplaceCode(function->shared()->code()); | 8841 function->ReplaceCode(function->shared()->code()); |
| 8848 } | 8842 } |
| 8849 return NULL; | 8843 return NULL; |
| 8850 } | 8844 } |
| 8851 | 8845 |
| 8852 | 8846 |
| 8853 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetAllocationTimeout) { | 8847 RUNTIME_FUNCTION(Runtime_SetAllocationTimeout) { |
| 8854 SealHandleScope shs(isolate); | 8848 SealHandleScope shs(isolate); |
| 8855 ASSERT(args.length() == 2 || args.length() == 3); | 8849 ASSERT(args.length() == 2 || args.length() == 3); |
| 8856 #ifdef DEBUG | 8850 #ifdef DEBUG |
| 8857 CONVERT_SMI_ARG_CHECKED(interval, 0); | 8851 CONVERT_SMI_ARG_CHECKED(interval, 0); |
| 8858 CONVERT_SMI_ARG_CHECKED(timeout, 1); | 8852 CONVERT_SMI_ARG_CHECKED(timeout, 1); |
| 8859 isolate->heap()->set_allocation_timeout(timeout); | 8853 isolate->heap()->set_allocation_timeout(timeout); |
| 8860 FLAG_gc_interval = interval; | 8854 FLAG_gc_interval = interval; |
| 8861 if (args.length() == 3) { | 8855 if (args.length() == 3) { |
| 8862 // Enable/disable inline allocation if requested. | 8856 // Enable/disable inline allocation if requested. |
| 8863 CONVERT_BOOLEAN_ARG_CHECKED(inline_allocation, 2); | 8857 CONVERT_BOOLEAN_ARG_CHECKED(inline_allocation, 2); |
| 8864 if (inline_allocation) { | 8858 if (inline_allocation) { |
| 8865 isolate->heap()->EnableInlineAllocation(); | 8859 isolate->heap()->EnableInlineAllocation(); |
| 8866 } else { | 8860 } else { |
| 8867 isolate->heap()->DisableInlineAllocation(); | 8861 isolate->heap()->DisableInlineAllocation(); |
| 8868 } | 8862 } |
| 8869 } | 8863 } |
| 8870 #endif | 8864 #endif |
| 8871 return isolate->heap()->undefined_value(); | 8865 return isolate->heap()->undefined_value(); |
| 8872 } | 8866 } |
| 8873 | 8867 |
| 8874 | 8868 |
| 8875 RUNTIME_FUNCTION(MaybeObject*, Runtime_CheckIsBootstrapping) { | 8869 RUNTIME_FUNCTION(Runtime_CheckIsBootstrapping) { |
| 8876 SealHandleScope shs(isolate); | 8870 SealHandleScope shs(isolate); |
| 8877 ASSERT(args.length() == 0); | 8871 ASSERT(args.length() == 0); |
| 8878 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive()); | 8872 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive()); |
| 8879 return isolate->heap()->undefined_value(); | 8873 return isolate->heap()->undefined_value(); |
| 8880 } | 8874 } |
| 8881 | 8875 |
| 8882 | 8876 |
| 8883 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetRootNaN) { | 8877 RUNTIME_FUNCTION(Runtime_GetRootNaN) { |
| 8884 SealHandleScope shs(isolate); | 8878 SealHandleScope shs(isolate); |
| 8885 ASSERT(args.length() == 0); | 8879 ASSERT(args.length() == 0); |
| 8886 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive()); | 8880 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive()); |
| 8887 return isolate->heap()->nan_value(); | 8881 return isolate->heap()->nan_value(); |
| 8888 } | 8882 } |
| 8889 | 8883 |
| 8890 | 8884 |
| 8891 RUNTIME_FUNCTION(MaybeObject*, Runtime_Call) { | 8885 RUNTIME_FUNCTION(Runtime_Call) { |
| 8892 HandleScope scope(isolate); | 8886 HandleScope scope(isolate); |
| 8893 ASSERT(args.length() >= 2); | 8887 ASSERT(args.length() >= 2); |
| 8894 int argc = args.length() - 2; | 8888 int argc = args.length() - 2; |
| 8895 CONVERT_ARG_CHECKED(JSReceiver, fun, argc + 1); | 8889 CONVERT_ARG_CHECKED(JSReceiver, fun, argc + 1); |
| 8896 Object* receiver = args[0]; | 8890 Object* receiver = args[0]; |
| 8897 | 8891 |
| 8898 // If there are too many arguments, allocate argv via malloc. | 8892 // If there are too many arguments, allocate argv via malloc. |
| 8899 const int argv_small_size = 10; | 8893 const int argv_small_size = 10; |
| 8900 Handle<Object> argv_small_buffer[argv_small_size]; | 8894 Handle<Object> argv_small_buffer[argv_small_size]; |
| 8901 SmartArrayPointer<Handle<Object> > argv_large_buffer; | 8895 SmartArrayPointer<Handle<Object> > argv_large_buffer; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 8913 Handle<JSReceiver> hfun(fun); | 8907 Handle<JSReceiver> hfun(fun); |
| 8914 Handle<Object> hreceiver(receiver, isolate); | 8908 Handle<Object> hreceiver(receiver, isolate); |
| 8915 Handle<Object> result; | 8909 Handle<Object> result; |
| 8916 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 8910 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 8917 isolate, result, | 8911 isolate, result, |
| 8918 Execution::Call(isolate, hfun, hreceiver, argc, argv, true)); | 8912 Execution::Call(isolate, hfun, hreceiver, argc, argv, true)); |
| 8919 return *result; | 8913 return *result; |
| 8920 } | 8914 } |
| 8921 | 8915 |
| 8922 | 8916 |
| 8923 RUNTIME_FUNCTION(MaybeObject*, Runtime_Apply) { | 8917 RUNTIME_FUNCTION(Runtime_Apply) { |
| 8924 HandleScope scope(isolate); | 8918 HandleScope scope(isolate); |
| 8925 ASSERT(args.length() == 5); | 8919 ASSERT(args.length() == 5); |
| 8926 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, fun, 0); | 8920 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, fun, 0); |
| 8927 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 1); | 8921 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 1); |
| 8928 CONVERT_ARG_HANDLE_CHECKED(JSObject, arguments, 2); | 8922 CONVERT_ARG_HANDLE_CHECKED(JSObject, arguments, 2); |
| 8929 CONVERT_SMI_ARG_CHECKED(offset, 3); | 8923 CONVERT_SMI_ARG_CHECKED(offset, 3); |
| 8930 CONVERT_SMI_ARG_CHECKED(argc, 4); | 8924 CONVERT_SMI_ARG_CHECKED(argc, 4); |
| 8931 RUNTIME_ASSERT(offset >= 0); | 8925 RUNTIME_ASSERT(offset >= 0); |
| 8932 RUNTIME_ASSERT(argc >= 0); | 8926 RUNTIME_ASSERT(argc >= 0); |
| 8933 | 8927 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 8949 } | 8943 } |
| 8950 | 8944 |
| 8951 Handle<Object> result; | 8945 Handle<Object> result; |
| 8952 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 8946 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 8953 isolate, result, | 8947 isolate, result, |
| 8954 Execution::Call(isolate, fun, receiver, argc, argv, true)); | 8948 Execution::Call(isolate, fun, receiver, argc, argv, true)); |
| 8955 return *result; | 8949 return *result; |
| 8956 } | 8950 } |
| 8957 | 8951 |
| 8958 | 8952 |
| 8959 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFunctionDelegate) { | 8953 RUNTIME_FUNCTION(Runtime_GetFunctionDelegate) { |
| 8960 HandleScope scope(isolate); | 8954 HandleScope scope(isolate); |
| 8961 ASSERT(args.length() == 1); | 8955 ASSERT(args.length() == 1); |
| 8962 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 8956 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
| 8963 RUNTIME_ASSERT(!object->IsJSFunction()); | 8957 RUNTIME_ASSERT(!object->IsJSFunction()); |
| 8964 return *Execution::GetFunctionDelegate(isolate, object); | 8958 return *Execution::GetFunctionDelegate(isolate, object); |
| 8965 } | 8959 } |
| 8966 | 8960 |
| 8967 | 8961 |
| 8968 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetConstructorDelegate) { | 8962 RUNTIME_FUNCTION(Runtime_GetConstructorDelegate) { |
| 8969 HandleScope scope(isolate); | 8963 HandleScope scope(isolate); |
| 8970 ASSERT(args.length() == 1); | 8964 ASSERT(args.length() == 1); |
| 8971 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 8965 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
| 8972 RUNTIME_ASSERT(!object->IsJSFunction()); | 8966 RUNTIME_ASSERT(!object->IsJSFunction()); |
| 8973 return *Execution::GetConstructorDelegate(isolate, object); | 8967 return *Execution::GetConstructorDelegate(isolate, object); |
| 8974 } | 8968 } |
| 8975 | 8969 |
| 8976 | 8970 |
| 8977 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NewGlobalContext) { | 8971 RUNTIME_FUNCTION(RuntimeHidden_NewGlobalContext) { |
| 8978 HandleScope scope(isolate); | 8972 HandleScope scope(isolate); |
| 8979 ASSERT(args.length() == 2); | 8973 ASSERT(args.length() == 2); |
| 8980 | 8974 |
| 8981 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8975 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 8982 CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 1); | 8976 CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 1); |
| 8983 Handle<Context> result = | 8977 Handle<Context> result = |
| 8984 isolate->factory()->NewGlobalContext(function, scope_info); | 8978 isolate->factory()->NewGlobalContext(function, scope_info); |
| 8985 | 8979 |
| 8986 ASSERT(function->context() == isolate->context()); | 8980 ASSERT(function->context() == isolate->context()); |
| 8987 ASSERT(function->context()->global_object() == result->global_object()); | 8981 ASSERT(function->context()->global_object() == result->global_object()); |
| 8988 result->global_object()->set_global_context(*result); | 8982 result->global_object()->set_global_context(*result); |
| 8989 return *result; | 8983 return *result; |
| 8990 } | 8984 } |
| 8991 | 8985 |
| 8992 | 8986 |
| 8993 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NewFunctionContext) { | 8987 RUNTIME_FUNCTION(RuntimeHidden_NewFunctionContext) { |
| 8994 HandleScope scope(isolate); | 8988 HandleScope scope(isolate); |
| 8995 ASSERT(args.length() == 1); | 8989 ASSERT(args.length() == 1); |
| 8996 | 8990 |
| 8997 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8991 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 8998 int length = function->shared()->scope_info()->ContextLength(); | 8992 int length = function->shared()->scope_info()->ContextLength(); |
| 8999 return *isolate->factory()->NewFunctionContext(length, function); | 8993 return *isolate->factory()->NewFunctionContext(length, function); |
| 9000 } | 8994 } |
| 9001 | 8995 |
| 9002 | 8996 |
| 9003 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_PushWithContext) { | 8997 RUNTIME_FUNCTION(RuntimeHidden_PushWithContext) { |
| 9004 HandleScope scope(isolate); | 8998 HandleScope scope(isolate); |
| 9005 ASSERT(args.length() == 2); | 8999 ASSERT(args.length() == 2); |
| 9006 Handle<JSReceiver> extension_object; | 9000 Handle<JSReceiver> extension_object; |
| 9007 if (args[0]->IsJSReceiver()) { | 9001 if (args[0]->IsJSReceiver()) { |
| 9008 extension_object = args.at<JSReceiver>(0); | 9002 extension_object = args.at<JSReceiver>(0); |
| 9009 } else { | 9003 } else { |
| 9010 // Try to convert the object to a proper JavaScript object. | 9004 // Try to convert the object to a proper JavaScript object. |
| 9011 MaybeHandle<JSReceiver> maybe_object = | 9005 MaybeHandle<JSReceiver> maybe_object = |
| 9012 Object::ToObject(isolate, args.at<Object>(0)); | 9006 Object::ToObject(isolate, args.at<Object>(0)); |
| 9013 if (!maybe_object.ToHandle(&extension_object)) { | 9007 if (!maybe_object.ToHandle(&extension_object)) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 9030 } | 9024 } |
| 9031 | 9025 |
| 9032 Handle<Context> current(isolate->context()); | 9026 Handle<Context> current(isolate->context()); |
| 9033 Handle<Context> context = isolate->factory()->NewWithContext( | 9027 Handle<Context> context = isolate->factory()->NewWithContext( |
| 9034 function, current, extension_object); | 9028 function, current, extension_object); |
| 9035 isolate->set_context(*context); | 9029 isolate->set_context(*context); |
| 9036 return *context; | 9030 return *context; |
| 9037 } | 9031 } |
| 9038 | 9032 |
| 9039 | 9033 |
| 9040 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_PushCatchContext) { | 9034 RUNTIME_FUNCTION(RuntimeHidden_PushCatchContext) { |
| 9041 HandleScope scope(isolate); | 9035 HandleScope scope(isolate); |
| 9042 ASSERT(args.length() == 3); | 9036 ASSERT(args.length() == 3); |
| 9043 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); | 9037 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); |
| 9044 CONVERT_ARG_HANDLE_CHECKED(Object, thrown_object, 1); | 9038 CONVERT_ARG_HANDLE_CHECKED(Object, thrown_object, 1); |
| 9045 Handle<JSFunction> function; | 9039 Handle<JSFunction> function; |
| 9046 if (args[2]->IsSmi()) { | 9040 if (args[2]->IsSmi()) { |
| 9047 // A smi sentinel indicates a context nested inside global code rather | 9041 // A smi sentinel indicates a context nested inside global code rather |
| 9048 // than some function. There is a canonical empty function that can be | 9042 // than some function. There is a canonical empty function that can be |
| 9049 // gotten from the native context. | 9043 // gotten from the native context. |
| 9050 function = handle(isolate->context()->native_context()->closure()); | 9044 function = handle(isolate->context()->native_context()->closure()); |
| 9051 } else { | 9045 } else { |
| 9052 function = args.at<JSFunction>(2); | 9046 function = args.at<JSFunction>(2); |
| 9053 } | 9047 } |
| 9054 Handle<Context> current(isolate->context()); | 9048 Handle<Context> current(isolate->context()); |
| 9055 Handle<Context> context = isolate->factory()->NewCatchContext( | 9049 Handle<Context> context = isolate->factory()->NewCatchContext( |
| 9056 function, current, name, thrown_object); | 9050 function, current, name, thrown_object); |
| 9057 isolate->set_context(*context); | 9051 isolate->set_context(*context); |
| 9058 return *context; | 9052 return *context; |
| 9059 } | 9053 } |
| 9060 | 9054 |
| 9061 | 9055 |
| 9062 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_PushBlockContext) { | 9056 RUNTIME_FUNCTION(RuntimeHidden_PushBlockContext) { |
| 9063 HandleScope scope(isolate); | 9057 HandleScope scope(isolate); |
| 9064 ASSERT(args.length() == 2); | 9058 ASSERT(args.length() == 2); |
| 9065 CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 0); | 9059 CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 0); |
| 9066 Handle<JSFunction> function; | 9060 Handle<JSFunction> function; |
| 9067 if (args[1]->IsSmi()) { | 9061 if (args[1]->IsSmi()) { |
| 9068 // A smi sentinel indicates a context nested inside global code rather | 9062 // A smi sentinel indicates a context nested inside global code rather |
| 9069 // than some function. There is a canonical empty function that can be | 9063 // than some function. There is a canonical empty function that can be |
| 9070 // gotten from the native context. | 9064 // gotten from the native context. |
| 9071 function = handle(isolate->context()->native_context()->closure()); | 9065 function = handle(isolate->context()->native_context()->closure()); |
| 9072 } else { | 9066 } else { |
| 9073 function = args.at<JSFunction>(1); | 9067 function = args.at<JSFunction>(1); |
| 9074 } | 9068 } |
| 9075 Handle<Context> current(isolate->context()); | 9069 Handle<Context> current(isolate->context()); |
| 9076 Handle<Context> context = isolate->factory()->NewBlockContext( | 9070 Handle<Context> context = isolate->factory()->NewBlockContext( |
| 9077 function, current, scope_info); | 9071 function, current, scope_info); |
| 9078 isolate->set_context(*context); | 9072 isolate->set_context(*context); |
| 9079 return *context; | 9073 return *context; |
| 9080 } | 9074 } |
| 9081 | 9075 |
| 9082 | 9076 |
| 9083 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsJSModule) { | 9077 RUNTIME_FUNCTION(Runtime_IsJSModule) { |
| 9084 SealHandleScope shs(isolate); | 9078 SealHandleScope shs(isolate); |
| 9085 ASSERT(args.length() == 1); | 9079 ASSERT(args.length() == 1); |
| 9086 CONVERT_ARG_CHECKED(Object, obj, 0); | 9080 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 9087 return isolate->heap()->ToBoolean(obj->IsJSModule()); | 9081 return isolate->heap()->ToBoolean(obj->IsJSModule()); |
| 9088 } | 9082 } |
| 9089 | 9083 |
| 9090 | 9084 |
| 9091 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_PushModuleContext) { | 9085 RUNTIME_FUNCTION(RuntimeHidden_PushModuleContext) { |
| 9092 SealHandleScope shs(isolate); | 9086 SealHandleScope shs(isolate); |
| 9093 ASSERT(args.length() == 2); | 9087 ASSERT(args.length() == 2); |
| 9094 CONVERT_SMI_ARG_CHECKED(index, 0); | 9088 CONVERT_SMI_ARG_CHECKED(index, 0); |
| 9095 | 9089 |
| 9096 if (!args[1]->IsScopeInfo()) { | 9090 if (!args[1]->IsScopeInfo()) { |
| 9097 // Module already initialized. Find hosting context and retrieve context. | 9091 // Module already initialized. Find hosting context and retrieve context. |
| 9098 Context* host = Context::cast(isolate->context())->global_context(); | 9092 Context* host = Context::cast(isolate->context())->global_context(); |
| 9099 Context* context = Context::cast(host->get(index)); | 9093 Context* context = Context::cast(host->get(index)); |
| 9100 ASSERT(context->previous() == isolate->context()); | 9094 ASSERT(context->previous() == isolate->context()); |
| 9101 isolate->set_context(context); | 9095 isolate->set_context(context); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 9116 context->set_global_object(previous->global_object()); | 9110 context->set_global_object(previous->global_object()); |
| 9117 isolate->set_context(*context); | 9111 isolate->set_context(*context); |
| 9118 | 9112 |
| 9119 // Find hosting scope and initialize internal variable holding module there. | 9113 // Find hosting scope and initialize internal variable holding module there. |
| 9120 previous->global_context()->set(index, *context); | 9114 previous->global_context()->set(index, *context); |
| 9121 | 9115 |
| 9122 return *context; | 9116 return *context; |
| 9123 } | 9117 } |
| 9124 | 9118 |
| 9125 | 9119 |
| 9126 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_DeclareModules) { | 9120 RUNTIME_FUNCTION(RuntimeHidden_DeclareModules) { |
| 9127 HandleScope scope(isolate); | 9121 HandleScope scope(isolate); |
| 9128 ASSERT(args.length() == 1); | 9122 ASSERT(args.length() == 1); |
| 9129 CONVERT_ARG_HANDLE_CHECKED(FixedArray, descriptions, 0); | 9123 CONVERT_ARG_HANDLE_CHECKED(FixedArray, descriptions, 0); |
| 9130 Context* host_context = isolate->context(); | 9124 Context* host_context = isolate->context(); |
| 9131 | 9125 |
| 9132 for (int i = 0; i < descriptions->length(); ++i) { | 9126 for (int i = 0; i < descriptions->length(); ++i) { |
| 9133 Handle<ModuleInfo> description(ModuleInfo::cast(descriptions->get(i))); | 9127 Handle<ModuleInfo> description(ModuleInfo::cast(descriptions->get(i))); |
| 9134 int host_index = description->host_index(); | 9128 int host_index = description->host_index(); |
| 9135 Handle<Context> context(Context::cast(host_context->get(host_index))); | 9129 Handle<Context> context(Context::cast(host_context->get(host_index))); |
| 9136 Handle<JSModule> module(context->module()); | 9130 Handle<JSModule> module(context->module()); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9170 } | 9164 } |
| 9171 | 9165 |
| 9172 JSObject::PreventExtensions(module).Assert(); | 9166 JSObject::PreventExtensions(module).Assert(); |
| 9173 } | 9167 } |
| 9174 | 9168 |
| 9175 ASSERT(!isolate->has_pending_exception()); | 9169 ASSERT(!isolate->has_pending_exception()); |
| 9176 return isolate->heap()->undefined_value(); | 9170 return isolate->heap()->undefined_value(); |
| 9177 } | 9171 } |
| 9178 | 9172 |
| 9179 | 9173 |
| 9180 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_DeleteContextSlot) { | 9174 RUNTIME_FUNCTION(RuntimeHidden_DeleteContextSlot) { |
| 9181 HandleScope scope(isolate); | 9175 HandleScope scope(isolate); |
| 9182 ASSERT(args.length() == 2); | 9176 ASSERT(args.length() == 2); |
| 9183 | 9177 |
| 9184 CONVERT_ARG_HANDLE_CHECKED(Context, context, 0); | 9178 CONVERT_ARG_HANDLE_CHECKED(Context, context, 0); |
| 9185 CONVERT_ARG_HANDLE_CHECKED(String, name, 1); | 9179 CONVERT_ARG_HANDLE_CHECKED(String, name, 1); |
| 9186 | 9180 |
| 9187 int index; | 9181 int index; |
| 9188 PropertyAttributes attributes; | 9182 PropertyAttributes attributes; |
| 9189 ContextLookupFlags flags = FOLLOW_CHAINS; | 9183 ContextLookupFlags flags = FOLLOW_CHAINS; |
| 9190 BindingFlags binding_flags; | 9184 BindingFlags binding_flags; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 9219 // A mechanism to return a pair of Object pointers in registers (if possible). | 9213 // A mechanism to return a pair of Object pointers in registers (if possible). |
| 9220 // How this is achieved is calling convention-dependent. | 9214 // How this is achieved is calling convention-dependent. |
| 9221 // All currently supported x86 compiles uses calling conventions that are cdecl | 9215 // All currently supported x86 compiles uses calling conventions that are cdecl |
| 9222 // variants where a 64-bit value is returned in two 32-bit registers | 9216 // variants where a 64-bit value is returned in two 32-bit registers |
| 9223 // (edx:eax on ia32, r1:r0 on ARM). | 9217 // (edx:eax on ia32, r1:r0 on ARM). |
| 9224 // In AMD-64 calling convention a struct of two pointers is returned in rdx:rax. | 9218 // In AMD-64 calling convention a struct of two pointers is returned in rdx:rax. |
| 9225 // In Win64 calling convention, a struct of two pointers is returned in memory, | 9219 // In Win64 calling convention, a struct of two pointers is returned in memory, |
| 9226 // allocated by the caller, and passed as a pointer in a hidden first parameter. | 9220 // allocated by the caller, and passed as a pointer in a hidden first parameter. |
| 9227 #ifdef V8_HOST_ARCH_64_BIT | 9221 #ifdef V8_HOST_ARCH_64_BIT |
| 9228 struct ObjectPair { | 9222 struct ObjectPair { |
| 9229 MaybeObject* x; | 9223 Object* x; |
| 9230 MaybeObject* y; | 9224 Object* y; |
| 9231 }; | 9225 }; |
| 9232 | 9226 |
| 9233 | 9227 |
| 9234 static inline ObjectPair MakePair(MaybeObject* x, MaybeObject* y) { | 9228 static inline ObjectPair MakePair(Object* x, Object* y) { |
| 9235 ObjectPair result = {x, y}; | 9229 ObjectPair result = {x, y}; |
| 9236 // Pointers x and y returned in rax and rdx, in AMD-x64-abi. | 9230 // Pointers x and y returned in rax and rdx, in AMD-x64-abi. |
| 9237 // In Win64 they are assigned to a hidden first argument. | 9231 // In Win64 they are assigned to a hidden first argument. |
| 9238 return result; | 9232 return result; |
| 9239 } | 9233 } |
| 9240 #else | 9234 #else |
| 9241 typedef uint64_t ObjectPair; | 9235 typedef uint64_t ObjectPair; |
| 9242 static inline ObjectPair MakePair(MaybeObject* x, MaybeObject* y) { | 9236 static inline ObjectPair MakePair(Object* x, Object* y) { |
| 9243 #if defined(V8_TARGET_LITTLE_ENDIAN) | 9237 #if defined(V8_TARGET_LITTLE_ENDIAN) |
| 9244 return reinterpret_cast<uint32_t>(x) | | 9238 return reinterpret_cast<uint32_t>(x) | |
| 9245 (reinterpret_cast<ObjectPair>(y) << 32); | 9239 (reinterpret_cast<ObjectPair>(y) << 32); |
| 9246 #elif defined(V8_TARGET_BIG_ENDIAN) | 9240 #elif defined(V8_TARGET_BIG_ENDIAN) |
| 9247 return reinterpret_cast<uint32_t>(y) | | 9241 return reinterpret_cast<uint32_t>(y) | |
| 9248 (reinterpret_cast<ObjectPair>(x) << 32); | 9242 (reinterpret_cast<ObjectPair>(x) << 32); |
| 9249 #else | 9243 #else |
| 9250 #error Unknown endianness | 9244 #error Unknown endianness |
| 9251 #endif | 9245 #endif |
| 9252 } | 9246 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9288 int index; | 9282 int index; |
| 9289 PropertyAttributes attributes; | 9283 PropertyAttributes attributes; |
| 9290 ContextLookupFlags flags = FOLLOW_CHAINS; | 9284 ContextLookupFlags flags = FOLLOW_CHAINS; |
| 9291 BindingFlags binding_flags; | 9285 BindingFlags binding_flags; |
| 9292 Handle<Object> holder = context->Lookup(name, | 9286 Handle<Object> holder = context->Lookup(name, |
| 9293 flags, | 9287 flags, |
| 9294 &index, | 9288 &index, |
| 9295 &attributes, | 9289 &attributes, |
| 9296 &binding_flags); | 9290 &binding_flags); |
| 9297 if (isolate->has_pending_exception()) { | 9291 if (isolate->has_pending_exception()) { |
| 9298 return MakePair(Failure::Exception(), NULL); | 9292 return MakePair(isolate->heap()->exception(), NULL); |
| 9299 } | 9293 } |
| 9300 | 9294 |
| 9301 // If the index is non-negative, the slot has been found in a context. | 9295 // If the index is non-negative, the slot has been found in a context. |
| 9302 if (index >= 0) { | 9296 if (index >= 0) { |
| 9303 ASSERT(holder->IsContext()); | 9297 ASSERT(holder->IsContext()); |
| 9304 // If the "property" we were looking for is a local variable, the | 9298 // If the "property" we were looking for is a local variable, the |
| 9305 // receiver is the global object; see ECMA-262, 3rd., 10.1.6 and 10.2.3. | 9299 // receiver is the global object; see ECMA-262, 3rd., 10.1.6 and 10.2.3. |
| 9306 Handle<Object> receiver = isolate->factory()->undefined_value(); | 9300 Handle<Object> receiver = isolate->factory()->undefined_value(); |
| 9307 Object* value = Context::cast(*holder)->get(index); | 9301 Object* value = Context::cast(*holder)->get(index); |
| 9308 // Check for uninitialized bindings. | 9302 // Check for uninitialized bindings. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9346 : object->IsJSProxy() ? static_cast<Object*>(*object) | 9340 : object->IsJSProxy() ? static_cast<Object*>(*object) |
| 9347 : ComputeReceiverForNonGlobal(isolate, JSObject::cast(*object)), | 9341 : ComputeReceiverForNonGlobal(isolate, JSObject::cast(*object)), |
| 9348 isolate); | 9342 isolate); |
| 9349 | 9343 |
| 9350 // No need to unhole the value here. This is taken care of by the | 9344 // No need to unhole the value here. This is taken care of by the |
| 9351 // GetProperty function. | 9345 // GetProperty function. |
| 9352 Handle<Object> value; | 9346 Handle<Object> value; |
| 9353 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 9347 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 9354 isolate, value, | 9348 isolate, value, |
| 9355 Object::GetProperty(object, name), | 9349 Object::GetProperty(object, name), |
| 9356 MakePair(Failure::Exception(), NULL)); | 9350 MakePair(isolate->heap()->exception(), NULL)); |
| 9357 return MakePair(*value, *receiver_handle); | 9351 return MakePair(*value, *receiver_handle); |
| 9358 } | 9352 } |
| 9359 | 9353 |
| 9360 if (throw_error) { | 9354 if (throw_error) { |
| 9361 // The property doesn't exist - throw exception. | 9355 // The property doesn't exist - throw exception. |
| 9362 Handle<Object> reference_error = | 9356 Handle<Object> reference_error = |
| 9363 isolate->factory()->NewReferenceError("not_defined", | 9357 isolate->factory()->NewReferenceError("not_defined", |
| 9364 HandleVector(&name, 1)); | 9358 HandleVector(&name, 1)); |
| 9365 return MakePair(isolate->Throw(*reference_error), NULL); | 9359 return MakePair(isolate->Throw(*reference_error), NULL); |
| 9366 } else { | 9360 } else { |
| 9367 // The property doesn't exist - return undefined. | 9361 // The property doesn't exist - return undefined. |
| 9368 return MakePair(isolate->heap()->undefined_value(), | 9362 return MakePair(isolate->heap()->undefined_value(), |
| 9369 isolate->heap()->undefined_value()); | 9363 isolate->heap()->undefined_value()); |
| 9370 } | 9364 } |
| 9371 } | 9365 } |
| 9372 | 9366 |
| 9373 | 9367 |
| 9374 RUNTIME_FUNCTION(ObjectPair, RuntimeHidden_LoadContextSlot) { | 9368 RUNTIME_FUNCTION_RETURN_PAIR(RuntimeHidden_LoadContextSlot) { |
| 9375 return LoadContextSlotHelper(args, isolate, true); | 9369 return LoadContextSlotHelper(args, isolate, true); |
| 9376 } | 9370 } |
| 9377 | 9371 |
| 9378 | 9372 |
| 9379 RUNTIME_FUNCTION(ObjectPair, RuntimeHidden_LoadContextSlotNoReferenceError) { | 9373 RUNTIME_FUNCTION_RETURN_PAIR(RuntimeHidden_LoadContextSlotNoReferenceError) { |
| 9380 return LoadContextSlotHelper(args, isolate, false); | 9374 return LoadContextSlotHelper(args, isolate, false); |
| 9381 } | 9375 } |
| 9382 | 9376 |
| 9383 | 9377 |
| 9384 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_StoreContextSlot) { | 9378 RUNTIME_FUNCTION(RuntimeHidden_StoreContextSlot) { |
| 9385 HandleScope scope(isolate); | 9379 HandleScope scope(isolate); |
| 9386 ASSERT(args.length() == 4); | 9380 ASSERT(args.length() == 4); |
| 9387 | 9381 |
| 9388 CONVERT_ARG_HANDLE_CHECKED(Object, value, 0); | 9382 CONVERT_ARG_HANDLE_CHECKED(Object, value, 0); |
| 9389 CONVERT_ARG_HANDLE_CHECKED(Context, context, 1); | 9383 CONVERT_ARG_HANDLE_CHECKED(Context, context, 1); |
| 9390 CONVERT_ARG_HANDLE_CHECKED(String, name, 2); | 9384 CONVERT_ARG_HANDLE_CHECKED(String, name, 2); |
| 9391 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 3); | 9385 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 3); |
| 9392 | 9386 |
| 9393 int index; | 9387 int index; |
| 9394 PropertyAttributes attributes; | 9388 PropertyAttributes attributes; |
| 9395 ContextLookupFlags flags = FOLLOW_CHAINS; | 9389 ContextLookupFlags flags = FOLLOW_CHAINS; |
| 9396 BindingFlags binding_flags; | 9390 BindingFlags binding_flags; |
| 9397 Handle<Object> holder = context->Lookup(name, | 9391 Handle<Object> holder = context->Lookup(name, |
| 9398 flags, | 9392 flags, |
| 9399 &index, | 9393 &index, |
| 9400 &attributes, | 9394 &attributes, |
| 9401 &binding_flags); | 9395 &binding_flags); |
| 9402 if (isolate->has_pending_exception()) return Failure::Exception(); | 9396 if (isolate->has_pending_exception()) return isolate->heap()->exception(); |
| 9403 | 9397 |
| 9404 if (index >= 0) { | 9398 if (index >= 0) { |
| 9405 // The property was found in a context slot. | 9399 // The property was found in a context slot. |
| 9406 Handle<Context> context = Handle<Context>::cast(holder); | 9400 Handle<Context> context = Handle<Context>::cast(holder); |
| 9407 if (binding_flags == MUTABLE_CHECK_INITIALIZED && | 9401 if (binding_flags == MUTABLE_CHECK_INITIALIZED && |
| 9408 context->get(index)->IsTheHole()) { | 9402 context->get(index)->IsTheHole()) { |
| 9409 Handle<Object> error = | 9403 Handle<Object> error = |
| 9410 isolate->factory()->NewReferenceError("not_defined", | 9404 isolate->factory()->NewReferenceError("not_defined", |
| 9411 HandleVector(&name, 1)); | 9405 HandleVector(&name, 1)); |
| 9412 return isolate->Throw(*error); | 9406 return isolate->Throw(*error); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9459 // Setting read only property in strict mode. | 9453 // Setting read only property in strict mode. |
| 9460 Handle<Object> error = | 9454 Handle<Object> error = |
| 9461 isolate->factory()->NewTypeError( | 9455 isolate->factory()->NewTypeError( |
| 9462 "strict_cannot_assign", HandleVector(&name, 1)); | 9456 "strict_cannot_assign", HandleVector(&name, 1)); |
| 9463 return isolate->Throw(*error); | 9457 return isolate->Throw(*error); |
| 9464 } | 9458 } |
| 9465 return *value; | 9459 return *value; |
| 9466 } | 9460 } |
| 9467 | 9461 |
| 9468 | 9462 |
| 9469 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_Throw) { | 9463 RUNTIME_FUNCTION(RuntimeHidden_Throw) { |
| 9470 HandleScope scope(isolate); | 9464 HandleScope scope(isolate); |
| 9471 ASSERT(args.length() == 1); | 9465 ASSERT(args.length() == 1); |
| 9472 | 9466 |
| 9473 return isolate->Throw(args[0]); | 9467 return isolate->Throw(args[0]); |
| 9474 } | 9468 } |
| 9475 | 9469 |
| 9476 | 9470 |
| 9477 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_ReThrow) { | 9471 RUNTIME_FUNCTION(RuntimeHidden_ReThrow) { |
| 9478 HandleScope scope(isolate); | 9472 HandleScope scope(isolate); |
| 9479 ASSERT(args.length() == 1); | 9473 ASSERT(args.length() == 1); |
| 9480 | 9474 |
| 9481 return isolate->ReThrow(args[0]); | 9475 return isolate->ReThrow(args[0]); |
| 9482 } | 9476 } |
| 9483 | 9477 |
| 9484 | 9478 |
| 9485 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_PromoteScheduledException) { | 9479 RUNTIME_FUNCTION(RuntimeHidden_PromoteScheduledException) { |
| 9486 SealHandleScope shs(isolate); | 9480 SealHandleScope shs(isolate); |
| 9487 ASSERT(args.length() == 0); | 9481 ASSERT(args.length() == 0); |
| 9488 return isolate->PromoteScheduledException(); | 9482 return isolate->PromoteScheduledException(); |
| 9489 } | 9483 } |
| 9490 | 9484 |
| 9491 | 9485 |
| 9492 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_ThrowReferenceError) { | 9486 RUNTIME_FUNCTION(RuntimeHidden_ThrowReferenceError) { |
| 9493 HandleScope scope(isolate); | 9487 HandleScope scope(isolate); |
| 9494 ASSERT(args.length() == 1); | 9488 ASSERT(args.length() == 1); |
| 9495 CONVERT_ARG_HANDLE_CHECKED(Object, name, 0); | 9489 CONVERT_ARG_HANDLE_CHECKED(Object, name, 0); |
| 9496 Handle<Object> reference_error = | 9490 Handle<Object> reference_error = |
| 9497 isolate->factory()->NewReferenceError("not_defined", | 9491 isolate->factory()->NewReferenceError("not_defined", |
| 9498 HandleVector(&name, 1)); | 9492 HandleVector(&name, 1)); |
| 9499 return isolate->Throw(*reference_error); | 9493 return isolate->Throw(*reference_error); |
| 9500 } | 9494 } |
| 9501 | 9495 |
| 9502 | 9496 |
| 9503 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_ThrowNotDateError) { | 9497 RUNTIME_FUNCTION(RuntimeHidden_ThrowNotDateError) { |
| 9504 HandleScope scope(isolate); | 9498 HandleScope scope(isolate); |
| 9505 ASSERT(args.length() == 0); | 9499 ASSERT(args.length() == 0); |
| 9506 return isolate->Throw(*isolate->factory()->NewTypeError( | 9500 return isolate->Throw(*isolate->factory()->NewTypeError( |
| 9507 "not_date_object", HandleVector<Object>(NULL, 0))); | 9501 "not_date_object", HandleVector<Object>(NULL, 0))); |
| 9508 } | 9502 } |
| 9509 | 9503 |
| 9510 | 9504 |
| 9511 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_ThrowMessage) { | 9505 RUNTIME_FUNCTION(RuntimeHidden_ThrowMessage) { |
| 9512 HandleScope scope(isolate); | 9506 HandleScope scope(isolate); |
| 9513 ASSERT(args.length() == 1); | 9507 ASSERT(args.length() == 1); |
| 9514 CONVERT_SMI_ARG_CHECKED(message_id, 0); | 9508 CONVERT_SMI_ARG_CHECKED(message_id, 0); |
| 9515 const char* message = GetBailoutReason( | 9509 const char* message = GetBailoutReason( |
| 9516 static_cast<BailoutReason>(message_id)); | 9510 static_cast<BailoutReason>(message_id)); |
| 9517 Handle<String> message_handle = | 9511 Handle<String> message_handle = |
| 9518 isolate->factory()->NewStringFromAsciiChecked(message); | 9512 isolate->factory()->NewStringFromAsciiChecked(message); |
| 9519 return isolate->Throw(*message_handle); | 9513 return isolate->Throw(*message_handle); |
| 9520 } | 9514 } |
| 9521 | 9515 |
| 9522 | 9516 |
| 9523 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_StackGuard) { | 9517 RUNTIME_FUNCTION(RuntimeHidden_StackGuard) { |
| 9524 SealHandleScope shs(isolate); | 9518 SealHandleScope shs(isolate); |
| 9525 ASSERT(args.length() == 0); | 9519 ASSERT(args.length() == 0); |
| 9526 | 9520 |
| 9527 // First check if this is a real stack overflow. | 9521 // First check if this is a real stack overflow. |
| 9528 if (isolate->stack_guard()->IsStackOverflow()) { | 9522 if (isolate->stack_guard()->IsStackOverflow()) { |
| 9529 return isolate->StackOverflow(); | 9523 return isolate->StackOverflow(); |
| 9530 } | 9524 } |
| 9531 | 9525 |
| 9532 return Execution::HandleStackGuardInterrupt(isolate); | 9526 return Execution::HandleStackGuardInterrupt(isolate); |
| 9533 } | 9527 } |
| 9534 | 9528 |
| 9535 | 9529 |
| 9536 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_TryInstallOptimizedCode) { | 9530 RUNTIME_FUNCTION(RuntimeHidden_TryInstallOptimizedCode) { |
| 9537 HandleScope scope(isolate); | 9531 HandleScope scope(isolate); |
| 9538 ASSERT(args.length() == 1); | 9532 ASSERT(args.length() == 1); |
| 9539 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 9533 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 9540 | 9534 |
| 9541 // First check if this is a real stack overflow. | 9535 // First check if this is a real stack overflow. |
| 9542 if (isolate->stack_guard()->IsStackOverflow()) { | 9536 if (isolate->stack_guard()->IsStackOverflow()) { |
| 9543 SealHandleScope shs(isolate); | 9537 SealHandleScope shs(isolate); |
| 9544 return isolate->StackOverflow(); | 9538 return isolate->StackOverflow(); |
| 9545 } | 9539 } |
| 9546 | 9540 |
| 9547 isolate->optimizing_compiler_thread()->InstallOptimizedFunctions(); | 9541 isolate->optimizing_compiler_thread()->InstallOptimizedFunctions(); |
| 9548 return (function->IsOptimized()) ? function->code() | 9542 return (function->IsOptimized()) ? function->code() |
| 9549 : function->shared()->code(); | 9543 : function->shared()->code(); |
| 9550 } | 9544 } |
| 9551 | 9545 |
| 9552 | 9546 |
| 9553 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_Interrupt) { | 9547 RUNTIME_FUNCTION(RuntimeHidden_Interrupt) { |
| 9554 SealHandleScope shs(isolate); | 9548 SealHandleScope shs(isolate); |
| 9555 ASSERT(args.length() == 0); | 9549 ASSERT(args.length() == 0); |
| 9556 return Execution::HandleStackGuardInterrupt(isolate); | 9550 return Execution::HandleStackGuardInterrupt(isolate); |
| 9557 } | 9551 } |
| 9558 | 9552 |
| 9559 | 9553 |
| 9560 static int StackSize(Isolate* isolate) { | 9554 static int StackSize(Isolate* isolate) { |
| 9561 int n = 0; | 9555 int n = 0; |
| 9562 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) n++; | 9556 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) n++; |
| 9563 return n; | 9557 return n; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 9579 PrintF(" {\n"); | 9573 PrintF(" {\n"); |
| 9580 } else { | 9574 } else { |
| 9581 // function result | 9575 // function result |
| 9582 PrintF("} -> "); | 9576 PrintF("} -> "); |
| 9583 result->ShortPrint(); | 9577 result->ShortPrint(); |
| 9584 PrintF("\n"); | 9578 PrintF("\n"); |
| 9585 } | 9579 } |
| 9586 } | 9580 } |
| 9587 | 9581 |
| 9588 | 9582 |
| 9589 RUNTIME_FUNCTION(MaybeObject*, Runtime_TraceEnter) { | 9583 RUNTIME_FUNCTION(Runtime_TraceEnter) { |
| 9590 SealHandleScope shs(isolate); | 9584 SealHandleScope shs(isolate); |
| 9591 ASSERT(args.length() == 0); | 9585 ASSERT(args.length() == 0); |
| 9592 PrintTransition(isolate, NULL); | 9586 PrintTransition(isolate, NULL); |
| 9593 return isolate->heap()->undefined_value(); | 9587 return isolate->heap()->undefined_value(); |
| 9594 } | 9588 } |
| 9595 | 9589 |
| 9596 | 9590 |
| 9597 RUNTIME_FUNCTION(MaybeObject*, Runtime_TraceExit) { | 9591 RUNTIME_FUNCTION(Runtime_TraceExit) { |
| 9598 SealHandleScope shs(isolate); | 9592 SealHandleScope shs(isolate); |
| 9599 ASSERT(args.length() == 1); | 9593 ASSERT(args.length() == 1); |
| 9600 CONVERT_ARG_CHECKED(Object, obj, 0); | 9594 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 9601 PrintTransition(isolate, obj); | 9595 PrintTransition(isolate, obj); |
| 9602 return obj; // return TOS | 9596 return obj; // return TOS |
| 9603 } | 9597 } |
| 9604 | 9598 |
| 9605 | 9599 |
| 9606 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPrint) { | 9600 RUNTIME_FUNCTION(Runtime_DebugPrint) { |
| 9607 SealHandleScope shs(isolate); | 9601 SealHandleScope shs(isolate); |
| 9608 ASSERT(args.length() == 1); | 9602 ASSERT(args.length() == 1); |
| 9609 | 9603 |
| 9610 #ifdef DEBUG | 9604 #ifdef DEBUG |
| 9611 if (args[0]->IsString()) { | 9605 if (args[0]->IsString()) { |
| 9612 // If we have a string, assume it's a code "marker" | 9606 // If we have a string, assume it's a code "marker" |
| 9613 // and print some interesting cpu debugging info. | 9607 // and print some interesting cpu debugging info. |
| 9614 JavaScriptFrameIterator it(isolate); | 9608 JavaScriptFrameIterator it(isolate); |
| 9615 JavaScriptFrame* frame = it.frame(); | 9609 JavaScriptFrame* frame = it.frame(); |
| 9616 PrintF("fp = %p, sp = %p, caller_sp = %p: ", | 9610 PrintF("fp = %p, sp = %p, caller_sp = %p: ", |
| (...skipping 10 matching lines...) Expand all Loading... |
| 9627 // ShortPrint is available in release mode. Print is not. | 9621 // ShortPrint is available in release mode. Print is not. |
| 9628 args[0]->ShortPrint(); | 9622 args[0]->ShortPrint(); |
| 9629 #endif | 9623 #endif |
| 9630 PrintF("\n"); | 9624 PrintF("\n"); |
| 9631 Flush(); | 9625 Flush(); |
| 9632 | 9626 |
| 9633 return args[0]; // return TOS | 9627 return args[0]; // return TOS |
| 9634 } | 9628 } |
| 9635 | 9629 |
| 9636 | 9630 |
| 9637 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugTrace) { | 9631 RUNTIME_FUNCTION(Runtime_DebugTrace) { |
| 9638 SealHandleScope shs(isolate); | 9632 SealHandleScope shs(isolate); |
| 9639 ASSERT(args.length() == 0); | 9633 ASSERT(args.length() == 0); |
| 9640 isolate->PrintStack(stdout); | 9634 isolate->PrintStack(stdout); |
| 9641 return isolate->heap()->undefined_value(); | 9635 return isolate->heap()->undefined_value(); |
| 9642 } | 9636 } |
| 9643 | 9637 |
| 9644 | 9638 |
| 9645 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateCurrentTime) { | 9639 RUNTIME_FUNCTION(Runtime_DateCurrentTime) { |
| 9646 HandleScope scope(isolate); | 9640 HandleScope scope(isolate); |
| 9647 ASSERT(args.length() == 0); | 9641 ASSERT(args.length() == 0); |
| 9648 | 9642 |
| 9649 // According to ECMA-262, section 15.9.1, page 117, the precision of | 9643 // According to ECMA-262, section 15.9.1, page 117, the precision of |
| 9650 // the number in a Date object representing a particular instant in | 9644 // the number in a Date object representing a particular instant in |
| 9651 // time is milliseconds. Therefore, we floor the result of getting | 9645 // time is milliseconds. Therefore, we floor the result of getting |
| 9652 // the OS time. | 9646 // the OS time. |
| 9653 double millis = std::floor(OS::TimeCurrentMillis()); | 9647 double millis = std::floor(OS::TimeCurrentMillis()); |
| 9654 return *isolate->factory()->NewNumber(millis); | 9648 return *isolate->factory()->NewNumber(millis); |
| 9655 } | 9649 } |
| 9656 | 9650 |
| 9657 | 9651 |
| 9658 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateParseString) { | 9652 RUNTIME_FUNCTION(Runtime_DateParseString) { |
| 9659 HandleScope scope(isolate); | 9653 HandleScope scope(isolate); |
| 9660 ASSERT(args.length() == 2); | 9654 ASSERT(args.length() == 2); |
| 9661 CONVERT_ARG_HANDLE_CHECKED(String, str, 0); | 9655 CONVERT_ARG_HANDLE_CHECKED(String, str, 0); |
| 9662 CONVERT_ARG_HANDLE_CHECKED(JSArray, output, 1); | 9656 CONVERT_ARG_HANDLE_CHECKED(JSArray, output, 1); |
| 9663 | 9657 |
| 9664 JSObject::EnsureCanContainHeapObjectElements(output); | 9658 JSObject::EnsureCanContainHeapObjectElements(output); |
| 9665 RUNTIME_ASSERT(output->HasFastObjectElements()); | 9659 RUNTIME_ASSERT(output->HasFastObjectElements()); |
| 9666 | 9660 |
| 9667 str = String::Flatten(str); | 9661 str = String::Flatten(str); |
| 9668 DisallowHeapAllocation no_gc; | 9662 DisallowHeapAllocation no_gc; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 9683 } | 9677 } |
| 9684 | 9678 |
| 9685 if (result) { | 9679 if (result) { |
| 9686 return *output; | 9680 return *output; |
| 9687 } else { | 9681 } else { |
| 9688 return isolate->heap()->null_value(); | 9682 return isolate->heap()->null_value(); |
| 9689 } | 9683 } |
| 9690 } | 9684 } |
| 9691 | 9685 |
| 9692 | 9686 |
| 9693 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateLocalTimezone) { | 9687 RUNTIME_FUNCTION(Runtime_DateLocalTimezone) { |
| 9694 HandleScope scope(isolate); | 9688 HandleScope scope(isolate); |
| 9695 ASSERT(args.length() == 1); | 9689 ASSERT(args.length() == 1); |
| 9696 | 9690 |
| 9697 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 9691 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 9698 const char* zone = | 9692 const char* zone = |
| 9699 isolate->date_cache()->LocalTimezone(static_cast<int64_t>(x)); | 9693 isolate->date_cache()->LocalTimezone(static_cast<int64_t>(x)); |
| 9700 Handle<String> result = isolate->factory()->NewStringFromUtf8( | 9694 Handle<String> result = isolate->factory()->NewStringFromUtf8( |
| 9701 CStrVector(zone)).ToHandleChecked(); | 9695 CStrVector(zone)).ToHandleChecked(); |
| 9702 return *result; | 9696 return *result; |
| 9703 } | 9697 } |
| 9704 | 9698 |
| 9705 | 9699 |
| 9706 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateToUTC) { | 9700 RUNTIME_FUNCTION(Runtime_DateToUTC) { |
| 9707 HandleScope scope(isolate); | 9701 HandleScope scope(isolate); |
| 9708 ASSERT(args.length() == 1); | 9702 ASSERT(args.length() == 1); |
| 9709 | 9703 |
| 9710 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 9704 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 9711 int64_t time = isolate->date_cache()->ToUTC(static_cast<int64_t>(x)); | 9705 int64_t time = isolate->date_cache()->ToUTC(static_cast<int64_t>(x)); |
| 9712 | 9706 |
| 9713 return *isolate->factory()->NewNumber(static_cast<double>(time)); | 9707 return *isolate->factory()->NewNumber(static_cast<double>(time)); |
| 9714 } | 9708 } |
| 9715 | 9709 |
| 9716 | 9710 |
| 9717 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateCacheVersion) { | 9711 RUNTIME_FUNCTION(Runtime_DateCacheVersion) { |
| 9718 HandleScope hs(isolate); | 9712 HandleScope hs(isolate); |
| 9719 ASSERT(args.length() == 0); | 9713 ASSERT(args.length() == 0); |
| 9720 if (!isolate->eternal_handles()->Exists(EternalHandles::DATE_CACHE_VERSION)) { | 9714 if (!isolate->eternal_handles()->Exists(EternalHandles::DATE_CACHE_VERSION)) { |
| 9721 Handle<FixedArray> date_cache_version = | 9715 Handle<FixedArray> date_cache_version = |
| 9722 isolate->factory()->NewFixedArray(1, TENURED); | 9716 isolate->factory()->NewFixedArray(1, TENURED); |
| 9723 date_cache_version->set(0, Smi::FromInt(0)); | 9717 date_cache_version->set(0, Smi::FromInt(0)); |
| 9724 isolate->eternal_handles()->CreateSingleton( | 9718 isolate->eternal_handles()->CreateSingleton( |
| 9725 isolate, *date_cache_version, EternalHandles::DATE_CACHE_VERSION); | 9719 isolate, *date_cache_version, EternalHandles::DATE_CACHE_VERSION); |
| 9726 } | 9720 } |
| 9727 Handle<FixedArray> date_cache_version = | 9721 Handle<FixedArray> date_cache_version = |
| 9728 Handle<FixedArray>::cast(isolate->eternal_handles()->GetSingleton( | 9722 Handle<FixedArray>::cast(isolate->eternal_handles()->GetSingleton( |
| 9729 EternalHandles::DATE_CACHE_VERSION)); | 9723 EternalHandles::DATE_CACHE_VERSION)); |
| 9730 // Return result as a JS array. | 9724 // Return result as a JS array. |
| 9731 Handle<JSObject> result = | 9725 Handle<JSObject> result = |
| 9732 isolate->factory()->NewJSObject(isolate->array_function()); | 9726 isolate->factory()->NewJSObject(isolate->array_function()); |
| 9733 JSArray::SetContent(Handle<JSArray>::cast(result), date_cache_version); | 9727 JSArray::SetContent(Handle<JSArray>::cast(result), date_cache_version); |
| 9734 return *result; | 9728 return *result; |
| 9735 } | 9729 } |
| 9736 | 9730 |
| 9737 | 9731 |
| 9738 RUNTIME_FUNCTION(MaybeObject*, Runtime_GlobalReceiver) { | 9732 RUNTIME_FUNCTION(Runtime_GlobalReceiver) { |
| 9739 SealHandleScope shs(isolate); | 9733 SealHandleScope shs(isolate); |
| 9740 ASSERT(args.length() == 1); | 9734 ASSERT(args.length() == 1); |
| 9741 CONVERT_ARG_CHECKED(Object, global, 0); | 9735 CONVERT_ARG_CHECKED(Object, global, 0); |
| 9742 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value(); | 9736 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value(); |
| 9743 return JSGlobalObject::cast(global)->global_receiver(); | 9737 return JSGlobalObject::cast(global)->global_receiver(); |
| 9744 } | 9738 } |
| 9745 | 9739 |
| 9746 | 9740 |
| 9747 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsAttachedGlobal) { | 9741 RUNTIME_FUNCTION(Runtime_IsAttachedGlobal) { |
| 9748 SealHandleScope shs(isolate); | 9742 SealHandleScope shs(isolate); |
| 9749 ASSERT(args.length() == 1); | 9743 ASSERT(args.length() == 1); |
| 9750 CONVERT_ARG_CHECKED(Object, global, 0); | 9744 CONVERT_ARG_CHECKED(Object, global, 0); |
| 9751 if (!global->IsJSGlobalObject()) return isolate->heap()->false_value(); | 9745 if (!global->IsJSGlobalObject()) return isolate->heap()->false_value(); |
| 9752 return isolate->heap()->ToBoolean( | 9746 return isolate->heap()->ToBoolean( |
| 9753 !JSGlobalObject::cast(global)->IsDetached()); | 9747 !JSGlobalObject::cast(global)->IsDetached()); |
| 9754 } | 9748 } |
| 9755 | 9749 |
| 9756 | 9750 |
| 9757 RUNTIME_FUNCTION(MaybeObject*, Runtime_ParseJson) { | 9751 RUNTIME_FUNCTION(Runtime_ParseJson) { |
| 9758 HandleScope scope(isolate); | 9752 HandleScope scope(isolate); |
| 9759 ASSERT(args.length() == 1); | 9753 ASSERT(args.length() == 1); |
| 9760 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); | 9754 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); |
| 9761 | 9755 |
| 9762 source = String::Flatten(source); | 9756 source = String::Flatten(source); |
| 9763 // Optimized fast case where we only have ASCII characters. | 9757 // Optimized fast case where we only have ASCII characters. |
| 9764 Handle<Object> result; | 9758 Handle<Object> result; |
| 9765 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 9759 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 9766 isolate, result, | 9760 isolate, result, |
| 9767 source->IsSeqOneByteString() ? JsonParser<true>::Parse(source) | 9761 source->IsSeqOneByteString() ? JsonParser<true>::Parse(source) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 9780 // No callback set and code generation disallowed. | 9774 // No callback set and code generation disallowed. |
| 9781 return false; | 9775 return false; |
| 9782 } else { | 9776 } else { |
| 9783 // Callback set. Let it decide if code generation is allowed. | 9777 // Callback set. Let it decide if code generation is allowed. |
| 9784 VMState<EXTERNAL> state(isolate); | 9778 VMState<EXTERNAL> state(isolate); |
| 9785 return callback(v8::Utils::ToLocal(context)); | 9779 return callback(v8::Utils::ToLocal(context)); |
| 9786 } | 9780 } |
| 9787 } | 9781 } |
| 9788 | 9782 |
| 9789 | 9783 |
| 9790 RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileString) { | 9784 RUNTIME_FUNCTION(Runtime_CompileString) { |
| 9791 HandleScope scope(isolate); | 9785 HandleScope scope(isolate); |
| 9792 ASSERT(args.length() == 2); | 9786 ASSERT(args.length() == 2); |
| 9793 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); | 9787 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); |
| 9794 CONVERT_BOOLEAN_ARG_CHECKED(function_literal_only, 1); | 9788 CONVERT_BOOLEAN_ARG_CHECKED(function_literal_only, 1); |
| 9795 | 9789 |
| 9796 // Extract native context. | 9790 // Extract native context. |
| 9797 Handle<Context> context(isolate->context()->native_context()); | 9791 Handle<Context> context(isolate->context()->native_context()); |
| 9798 | 9792 |
| 9799 // Check if native context allows code generation from | 9793 // Check if native context allows code generation from |
| 9800 // strings. Throw an exception if it doesn't. | 9794 // strings. Throw an exception if it doesn't. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 9827 Handle<Context> native_context = Handle<Context>(context->native_context()); | 9821 Handle<Context> native_context = Handle<Context>(context->native_context()); |
| 9828 | 9822 |
| 9829 // Check if native context allows code generation from | 9823 // Check if native context allows code generation from |
| 9830 // strings. Throw an exception if it doesn't. | 9824 // strings. Throw an exception if it doesn't. |
| 9831 if (native_context->allow_code_gen_from_strings()->IsFalse() && | 9825 if (native_context->allow_code_gen_from_strings()->IsFalse() && |
| 9832 !CodeGenerationFromStringsAllowed(isolate, native_context)) { | 9826 !CodeGenerationFromStringsAllowed(isolate, native_context)) { |
| 9833 Handle<Object> error_message = | 9827 Handle<Object> error_message = |
| 9834 native_context->ErrorMessageForCodeGenerationFromStrings(); | 9828 native_context->ErrorMessageForCodeGenerationFromStrings(); |
| 9835 isolate->Throw(*isolate->factory()->NewEvalError( | 9829 isolate->Throw(*isolate->factory()->NewEvalError( |
| 9836 "code_gen_from_strings", HandleVector<Object>(&error_message, 1))); | 9830 "code_gen_from_strings", HandleVector<Object>(&error_message, 1))); |
| 9837 return MakePair(Failure::Exception(), NULL); | 9831 return MakePair(isolate->heap()->exception(), NULL); |
| 9838 } | 9832 } |
| 9839 | 9833 |
| 9840 // Deal with a normal eval call with a string argument. Compile it | 9834 // Deal with a normal eval call with a string argument. Compile it |
| 9841 // and return the compiled function bound in the local context. | 9835 // and return the compiled function bound in the local context. |
| 9842 static const ParseRestriction restriction = NO_PARSE_RESTRICTION; | 9836 static const ParseRestriction restriction = NO_PARSE_RESTRICTION; |
| 9843 Handle<JSFunction> compiled; | 9837 Handle<JSFunction> compiled; |
| 9844 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 9838 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 9845 isolate, compiled, | 9839 isolate, compiled, |
| 9846 Compiler::GetFunctionFromEval( | 9840 Compiler::GetFunctionFromEval( |
| 9847 source, context, strict_mode, restriction, scope_position), | 9841 source, context, strict_mode, restriction, scope_position), |
| 9848 MakePair(Failure::Exception(), NULL)); | 9842 MakePair(isolate->heap()->exception(), NULL)); |
| 9849 return MakePair(*compiled, *receiver); | 9843 return MakePair(*compiled, *receiver); |
| 9850 } | 9844 } |
| 9851 | 9845 |
| 9852 | 9846 |
| 9853 RUNTIME_FUNCTION(ObjectPair, RuntimeHidden_ResolvePossiblyDirectEval) { | 9847 RUNTIME_FUNCTION_RETURN_PAIR(RuntimeHidden_ResolvePossiblyDirectEval) { |
| 9854 HandleScope scope(isolate); | 9848 HandleScope scope(isolate); |
| 9855 ASSERT(args.length() == 5); | 9849 ASSERT(args.length() == 5); |
| 9856 | 9850 |
| 9857 Handle<Object> callee = args.at<Object>(0); | 9851 Handle<Object> callee = args.at<Object>(0); |
| 9858 | 9852 |
| 9859 // If "eval" didn't refer to the original GlobalEval, it's not a | 9853 // If "eval" didn't refer to the original GlobalEval, it's not a |
| 9860 // direct call to eval. | 9854 // direct call to eval. |
| 9861 // (And even if it is, but the first argument isn't a string, just let | 9855 // (And even if it is, but the first argument isn't a string, just let |
| 9862 // execution default to an indirect call to eval, which will also return | 9856 // execution default to an indirect call to eval, which will also return |
| 9863 // the first argument without doing anything). | 9857 // the first argument without doing anything). |
| 9864 if (*callee != isolate->native_context()->global_eval_fun() || | 9858 if (*callee != isolate->native_context()->global_eval_fun() || |
| 9865 !args[1]->IsString()) { | 9859 !args[1]->IsString()) { |
| 9866 return MakePair(*callee, isolate->heap()->undefined_value()); | 9860 return MakePair(*callee, isolate->heap()->undefined_value()); |
| 9867 } | 9861 } |
| 9868 | 9862 |
| 9869 ASSERT(args[3]->IsSmi()); | 9863 ASSERT(args[3]->IsSmi()); |
| 9870 ASSERT(args.smi_at(3) == SLOPPY || args.smi_at(3) == STRICT); | 9864 ASSERT(args.smi_at(3) == SLOPPY || args.smi_at(3) == STRICT); |
| 9871 StrictMode strict_mode = static_cast<StrictMode>(args.smi_at(3)); | 9865 StrictMode strict_mode = static_cast<StrictMode>(args.smi_at(3)); |
| 9872 ASSERT(args[4]->IsSmi()); | 9866 ASSERT(args[4]->IsSmi()); |
| 9873 return CompileGlobalEval(isolate, | 9867 return CompileGlobalEval(isolate, |
| 9874 args.at<String>(1), | 9868 args.at<String>(1), |
| 9875 args.at<Object>(2), | 9869 args.at<Object>(2), |
| 9876 strict_mode, | 9870 strict_mode, |
| 9877 args.smi_at(4)); | 9871 args.smi_at(4)); |
| 9878 } | 9872 } |
| 9879 | 9873 |
| 9880 | 9874 |
| 9881 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_AllocateInNewSpace) { | 9875 RUNTIME_FUNCTION(RuntimeHidden_AllocateInNewSpace) { |
| 9882 HandleScope scope(isolate); | 9876 HandleScope scope(isolate); |
| 9883 ASSERT(args.length() == 1); | 9877 ASSERT(args.length() == 1); |
| 9884 CONVERT_SMI_ARG_CHECKED(size, 0); | 9878 CONVERT_SMI_ARG_CHECKED(size, 0); |
| 9885 RUNTIME_ASSERT(IsAligned(size, kPointerSize)); | 9879 RUNTIME_ASSERT(IsAligned(size, kPointerSize)); |
| 9886 RUNTIME_ASSERT(size > 0); | 9880 RUNTIME_ASSERT(size > 0); |
| 9887 RUNTIME_ASSERT(size <= Page::kMaxRegularHeapObjectSize); | 9881 RUNTIME_ASSERT(size <= Page::kMaxRegularHeapObjectSize); |
| 9888 return *isolate->factory()->NewFillerObject(size, false, NEW_SPACE); | 9882 return *isolate->factory()->NewFillerObject(size, false, NEW_SPACE); |
| 9889 } | 9883 } |
| 9890 | 9884 |
| 9891 | 9885 |
| 9892 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_AllocateInTargetSpace) { | 9886 RUNTIME_FUNCTION(RuntimeHidden_AllocateInTargetSpace) { |
| 9893 HandleScope scope(isolate); | 9887 HandleScope scope(isolate); |
| 9894 ASSERT(args.length() == 2); | 9888 ASSERT(args.length() == 2); |
| 9895 CONVERT_SMI_ARG_CHECKED(size, 0); | 9889 CONVERT_SMI_ARG_CHECKED(size, 0); |
| 9896 CONVERT_SMI_ARG_CHECKED(flags, 1); | 9890 CONVERT_SMI_ARG_CHECKED(flags, 1); |
| 9897 RUNTIME_ASSERT(IsAligned(size, kPointerSize)); | 9891 RUNTIME_ASSERT(IsAligned(size, kPointerSize)); |
| 9898 RUNTIME_ASSERT(size > 0); | 9892 RUNTIME_ASSERT(size > 0); |
| 9899 RUNTIME_ASSERT(size <= Page::kMaxRegularHeapObjectSize); | 9893 RUNTIME_ASSERT(size <= Page::kMaxRegularHeapObjectSize); |
| 9900 bool double_align = AllocateDoubleAlignFlag::decode(flags); | 9894 bool double_align = AllocateDoubleAlignFlag::decode(flags); |
| 9901 AllocationSpace space = AllocateTargetSpace::decode(flags); | 9895 AllocationSpace space = AllocateTargetSpace::decode(flags); |
| 9902 return *isolate->factory()->NewFillerObject(size, double_align, space); | 9896 return *isolate->factory()->NewFillerObject(size, double_align, space); |
| 9903 } | 9897 } |
| 9904 | 9898 |
| 9905 | 9899 |
| 9906 // Push an object unto an array of objects if it is not already in the | 9900 // Push an object unto an array of objects if it is not already in the |
| 9907 // array. Returns true if the element was pushed on the stack and | 9901 // array. Returns true if the element was pushed on the stack and |
| 9908 // false otherwise. | 9902 // false otherwise. |
| 9909 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushIfAbsent) { | 9903 RUNTIME_FUNCTION(Runtime_PushIfAbsent) { |
| 9910 HandleScope scope(isolate); | 9904 HandleScope scope(isolate); |
| 9911 ASSERT(args.length() == 2); | 9905 ASSERT(args.length() == 2); |
| 9912 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); | 9906 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); |
| 9913 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, element, 1); | 9907 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, element, 1); |
| 9914 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements()); | 9908 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements()); |
| 9915 int length = Smi::cast(array->length())->value(); | 9909 int length = Smi::cast(array->length())->value(); |
| 9916 FixedArray* elements = FixedArray::cast(array->elements()); | 9910 FixedArray* elements = FixedArray::cast(array->elements()); |
| 9917 for (int i = 0; i < length; i++) { | 9911 for (int i = 0; i < length; i++) { |
| 9918 if (elements->get(i) == *element) return isolate->heap()->false_value(); | 9912 if (elements->get(i) == *element) return isolate->heap()->false_value(); |
| 9919 } | 9913 } |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10407 return true; | 10401 return true; |
| 10408 } | 10402 } |
| 10409 | 10403 |
| 10410 | 10404 |
| 10411 /** | 10405 /** |
| 10412 * Array::concat implementation. | 10406 * Array::concat implementation. |
| 10413 * See ECMAScript 262, 15.4.4.4. | 10407 * See ECMAScript 262, 15.4.4.4. |
| 10414 * TODO(581): Fix non-compliance for very large concatenations and update to | 10408 * TODO(581): Fix non-compliance for very large concatenations and update to |
| 10415 * following the ECMAScript 5 specification. | 10409 * following the ECMAScript 5 specification. |
| 10416 */ | 10410 */ |
| 10417 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayConcat) { | 10411 RUNTIME_FUNCTION(Runtime_ArrayConcat) { |
| 10418 HandleScope handle_scope(isolate); | 10412 HandleScope handle_scope(isolate); |
| 10419 ASSERT(args.length() == 1); | 10413 ASSERT(args.length() == 1); |
| 10420 | 10414 |
| 10421 CONVERT_ARG_HANDLE_CHECKED(JSArray, arguments, 0); | 10415 CONVERT_ARG_HANDLE_CHECKED(JSArray, arguments, 0); |
| 10422 int argument_count = static_cast<int>(arguments->length()->Number()); | 10416 int argument_count = static_cast<int>(arguments->length()->Number()); |
| 10423 RUNTIME_ASSERT(arguments->HasFastObjectElements()); | 10417 RUNTIME_ASSERT(arguments->HasFastObjectElements()); |
| 10424 Handle<FixedArray> elements(FixedArray::cast(arguments->elements())); | 10418 Handle<FixedArray> elements(FixedArray::cast(arguments->elements())); |
| 10425 | 10419 |
| 10426 // Pass 1: estimate the length and number of elements of the result. | 10420 // Pass 1: estimate the length and number of elements of the result. |
| 10427 // The actual length can be larger if any of the arguments have getters | 10421 // The actual length can be larger if any of the arguments have getters |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10563 isolate->factory()->NewSeededNumberDictionary(at_least_space_for)); | 10557 isolate->factory()->NewSeededNumberDictionary(at_least_space_for)); |
| 10564 } | 10558 } |
| 10565 | 10559 |
| 10566 ArrayConcatVisitor visitor(isolate, storage, fast_case); | 10560 ArrayConcatVisitor visitor(isolate, storage, fast_case); |
| 10567 | 10561 |
| 10568 for (int i = 0; i < argument_count; i++) { | 10562 for (int i = 0; i < argument_count; i++) { |
| 10569 Handle<Object> obj(elements->get(i), isolate); | 10563 Handle<Object> obj(elements->get(i), isolate); |
| 10570 if (obj->IsJSArray()) { | 10564 if (obj->IsJSArray()) { |
| 10571 Handle<JSArray> array = Handle<JSArray>::cast(obj); | 10565 Handle<JSArray> array = Handle<JSArray>::cast(obj); |
| 10572 if (!IterateElements(isolate, array, &visitor)) { | 10566 if (!IterateElements(isolate, array, &visitor)) { |
| 10573 return Failure::Exception(); | 10567 return isolate->heap()->exception(); |
| 10574 } | 10568 } |
| 10575 } else { | 10569 } else { |
| 10576 visitor.visit(0, obj); | 10570 visitor.visit(0, obj); |
| 10577 visitor.increase_index_offset(1); | 10571 visitor.increase_index_offset(1); |
| 10578 } | 10572 } |
| 10579 } | 10573 } |
| 10580 | 10574 |
| 10581 if (visitor.exceeds_array_limit()) { | 10575 if (visitor.exceeds_array_limit()) { |
| 10582 return isolate->Throw( | 10576 return isolate->Throw( |
| 10583 *isolate->factory()->NewRangeError("invalid_array_length", | 10577 *isolate->factory()->NewRangeError("invalid_array_length", |
| 10584 HandleVector<Object>(NULL, 0))); | 10578 HandleVector<Object>(NULL, 0))); |
| 10585 } | 10579 } |
| 10586 return *visitor.ToArray(); | 10580 return *visitor.ToArray(); |
| 10587 } | 10581 } |
| 10588 | 10582 |
| 10589 | 10583 |
| 10590 // This will not allocate (flatten the string), but it may run | 10584 // This will not allocate (flatten the string), but it may run |
| 10591 // very slowly for very deeply nested ConsStrings. For debugging use only. | 10585 // very slowly for very deeply nested ConsStrings. For debugging use only. |
| 10592 RUNTIME_FUNCTION(MaybeObject*, Runtime_GlobalPrint) { | 10586 RUNTIME_FUNCTION(Runtime_GlobalPrint) { |
| 10593 SealHandleScope shs(isolate); | 10587 SealHandleScope shs(isolate); |
| 10594 ASSERT(args.length() == 1); | 10588 ASSERT(args.length() == 1); |
| 10595 | 10589 |
| 10596 CONVERT_ARG_CHECKED(String, string, 0); | 10590 CONVERT_ARG_CHECKED(String, string, 0); |
| 10597 ConsStringIteratorOp op; | 10591 ConsStringIteratorOp op; |
| 10598 StringCharacterStream stream(string, &op); | 10592 StringCharacterStream stream(string, &op); |
| 10599 while (stream.HasMore()) { | 10593 while (stream.HasMore()) { |
| 10600 uint16_t character = stream.GetNext(); | 10594 uint16_t character = stream.GetNext(); |
| 10601 PrintF("%c", character); | 10595 PrintF("%c", character); |
| 10602 } | 10596 } |
| 10603 return string; | 10597 return string; |
| 10604 } | 10598 } |
| 10605 | 10599 |
| 10606 | 10600 |
| 10607 // Moves all own elements of an object, that are below a limit, to positions | 10601 // Moves all own elements of an object, that are below a limit, to positions |
| 10608 // starting at zero. All undefined values are placed after non-undefined values, | 10602 // starting at zero. All undefined values are placed after non-undefined values, |
| 10609 // and are followed by non-existing element. Does not change the length | 10603 // and are followed by non-existing element. Does not change the length |
| 10610 // property. | 10604 // property. |
| 10611 // Returns the number of non-undefined elements collected. | 10605 // Returns the number of non-undefined elements collected. |
| 10612 // Returns -1 if hole removal is not supported by this method. | 10606 // Returns -1 if hole removal is not supported by this method. |
| 10613 RUNTIME_FUNCTION(MaybeObject*, Runtime_RemoveArrayHoles) { | 10607 RUNTIME_FUNCTION(Runtime_RemoveArrayHoles) { |
| 10614 HandleScope scope(isolate); | 10608 HandleScope scope(isolate); |
| 10615 ASSERT(args.length() == 2); | 10609 ASSERT(args.length() == 2); |
| 10616 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 10610 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
| 10617 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]); | 10611 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]); |
| 10618 return *JSObject::PrepareElementsForSort(object, limit); | 10612 return *JSObject::PrepareElementsForSort(object, limit); |
| 10619 } | 10613 } |
| 10620 | 10614 |
| 10621 | 10615 |
| 10622 // Move contents of argument 0 (an array) to argument 1 (an array) | 10616 // Move contents of argument 0 (an array) to argument 1 (an array) |
| 10623 RUNTIME_FUNCTION(MaybeObject*, Runtime_MoveArrayContents) { | 10617 RUNTIME_FUNCTION(Runtime_MoveArrayContents) { |
| 10624 HandleScope scope(isolate); | 10618 HandleScope scope(isolate); |
| 10625 ASSERT(args.length() == 2); | 10619 ASSERT(args.length() == 2); |
| 10626 CONVERT_ARG_HANDLE_CHECKED(JSArray, from, 0); | 10620 CONVERT_ARG_HANDLE_CHECKED(JSArray, from, 0); |
| 10627 CONVERT_ARG_HANDLE_CHECKED(JSArray, to, 1); | 10621 CONVERT_ARG_HANDLE_CHECKED(JSArray, to, 1); |
| 10628 JSObject::ValidateElements(from); | 10622 JSObject::ValidateElements(from); |
| 10629 JSObject::ValidateElements(to); | 10623 JSObject::ValidateElements(to); |
| 10630 | 10624 |
| 10631 Handle<FixedArrayBase> new_elements(from->elements()); | 10625 Handle<FixedArrayBase> new_elements(from->elements()); |
| 10632 ElementsKind from_kind = from->GetElementsKind(); | 10626 ElementsKind from_kind = from->GetElementsKind(); |
| 10633 Handle<Map> new_map = JSObject::GetElementsTransitionMap(to, from_kind); | 10627 Handle<Map> new_map = JSObject::GetElementsTransitionMap(to, from_kind); |
| 10634 JSObject::SetMapAndElements(to, new_map, new_elements); | 10628 JSObject::SetMapAndElements(to, new_map, new_elements); |
| 10635 to->set_length(from->length()); | 10629 to->set_length(from->length()); |
| 10636 | 10630 |
| 10637 JSObject::ResetElements(from); | 10631 JSObject::ResetElements(from); |
| 10638 from->set_length(Smi::FromInt(0)); | 10632 from->set_length(Smi::FromInt(0)); |
| 10639 | 10633 |
| 10640 JSObject::ValidateElements(to); | 10634 JSObject::ValidateElements(to); |
| 10641 return *to; | 10635 return *to; |
| 10642 } | 10636 } |
| 10643 | 10637 |
| 10644 | 10638 |
| 10645 // How many elements does this object/array have? | 10639 // How many elements does this object/array have? |
| 10646 RUNTIME_FUNCTION(MaybeObject*, Runtime_EstimateNumberOfElements) { | 10640 RUNTIME_FUNCTION(Runtime_EstimateNumberOfElements) { |
| 10647 SealHandleScope shs(isolate); | 10641 SealHandleScope shs(isolate); |
| 10648 ASSERT(args.length() == 1); | 10642 ASSERT(args.length() == 1); |
| 10649 CONVERT_ARG_CHECKED(JSObject, object, 0); | 10643 CONVERT_ARG_CHECKED(JSObject, object, 0); |
| 10650 HeapObject* elements = object->elements(); | 10644 HeapObject* elements = object->elements(); |
| 10651 if (elements->IsDictionary()) { | 10645 if (elements->IsDictionary()) { |
| 10652 int result = SeededNumberDictionary::cast(elements)->NumberOfElements(); | 10646 int result = SeededNumberDictionary::cast(elements)->NumberOfElements(); |
| 10653 return Smi::FromInt(result); | 10647 return Smi::FromInt(result); |
| 10654 } else if (object->IsJSArray()) { | 10648 } else if (object->IsJSArray()) { |
| 10655 return JSArray::cast(object)->length(); | 10649 return JSArray::cast(object)->length(); |
| 10656 } else { | 10650 } else { |
| 10657 return Smi::FromInt(FixedArray::cast(elements)->length()); | 10651 return Smi::FromInt(FixedArray::cast(elements)->length()); |
| 10658 } | 10652 } |
| 10659 } | 10653 } |
| 10660 | 10654 |
| 10661 | 10655 |
| 10662 // Returns an array that tells you where in the [0, length) interval an array | 10656 // Returns an array that tells you where in the [0, length) interval an array |
| 10663 // might have elements. Can either return an array of keys (positive integers | 10657 // might have elements. Can either return an array of keys (positive integers |
| 10664 // or undefined) or a number representing the positive length of an interval | 10658 // or undefined) or a number representing the positive length of an interval |
| 10665 // starting at index 0. | 10659 // starting at index 0. |
| 10666 // Intervals can span over some keys that are not in the object. | 10660 // Intervals can span over some keys that are not in the object. |
| 10667 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArrayKeys) { | 10661 RUNTIME_FUNCTION(Runtime_GetArrayKeys) { |
| 10668 HandleScope scope(isolate); | 10662 HandleScope scope(isolate); |
| 10669 ASSERT(args.length() == 2); | 10663 ASSERT(args.length() == 2); |
| 10670 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0); | 10664 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0); |
| 10671 CONVERT_NUMBER_CHECKED(uint32_t, length, Uint32, args[1]); | 10665 CONVERT_NUMBER_CHECKED(uint32_t, length, Uint32, args[1]); |
| 10672 if (array->elements()->IsDictionary()) { | 10666 if (array->elements()->IsDictionary()) { |
| 10673 Handle<FixedArray> keys = isolate->factory()->empty_fixed_array(); | 10667 Handle<FixedArray> keys = isolate->factory()->empty_fixed_array(); |
| 10674 for (Handle<Object> p = array; | 10668 for (Handle<Object> p = array; |
| 10675 !p->IsNull(); | 10669 !p->IsNull(); |
| 10676 p = Handle<Object>(p->GetPrototype(isolate), isolate)) { | 10670 p = Handle<Object>(p->GetPrototype(isolate), isolate)) { |
| 10677 if (p->IsJSProxy() || JSObject::cast(*p)->HasIndexedInterceptor()) { | 10671 if (p->IsJSProxy() || JSObject::cast(*p)->HasIndexedInterceptor()) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 10696 return *isolate->factory()->NewJSArrayWithElements(keys); | 10690 return *isolate->factory()->NewJSArrayWithElements(keys); |
| 10697 } else { | 10691 } else { |
| 10698 ASSERT(array->HasFastSmiOrObjectElements() || | 10692 ASSERT(array->HasFastSmiOrObjectElements() || |
| 10699 array->HasFastDoubleElements()); | 10693 array->HasFastDoubleElements()); |
| 10700 uint32_t actual_length = static_cast<uint32_t>(array->elements()->length()); | 10694 uint32_t actual_length = static_cast<uint32_t>(array->elements()->length()); |
| 10701 return *isolate->factory()->NewNumberFromUint(Min(actual_length, length)); | 10695 return *isolate->factory()->NewNumberFromUint(Min(actual_length, length)); |
| 10702 } | 10696 } |
| 10703 } | 10697 } |
| 10704 | 10698 |
| 10705 | 10699 |
| 10706 RUNTIME_FUNCTION(MaybeObject*, Runtime_LookupAccessor) { | 10700 RUNTIME_FUNCTION(Runtime_LookupAccessor) { |
| 10707 HandleScope scope(isolate); | 10701 HandleScope scope(isolate); |
| 10708 ASSERT(args.length() == 3); | 10702 ASSERT(args.length() == 3); |
| 10709 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); | 10703 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); |
| 10710 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 10704 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
| 10711 CONVERT_SMI_ARG_CHECKED(flag, 2); | 10705 CONVERT_SMI_ARG_CHECKED(flag, 2); |
| 10712 AccessorComponent component = flag == 0 ? ACCESSOR_GETTER : ACCESSOR_SETTER; | 10706 AccessorComponent component = flag == 0 ? ACCESSOR_GETTER : ACCESSOR_SETTER; |
| 10713 if (!receiver->IsJSObject()) return isolate->heap()->undefined_value(); | 10707 if (!receiver->IsJSObject()) return isolate->heap()->undefined_value(); |
| 10714 Handle<Object> result; | 10708 Handle<Object> result; |
| 10715 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 10709 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 10716 isolate, result, | 10710 isolate, result, |
| 10717 JSObject::GetAccessor(Handle<JSObject>::cast(receiver), name, component)); | 10711 JSObject::GetAccessor(Handle<JSObject>::cast(receiver), name, component)); |
| 10718 return *result; | 10712 return *result; |
| 10719 } | 10713 } |
| 10720 | 10714 |
| 10721 | 10715 |
| 10722 #ifdef ENABLE_DEBUGGER_SUPPORT | 10716 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 10723 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugBreak) { | 10717 RUNTIME_FUNCTION(Runtime_DebugBreak) { |
| 10724 SealHandleScope shs(isolate); | 10718 SealHandleScope shs(isolate); |
| 10725 ASSERT(args.length() == 0); | 10719 ASSERT(args.length() == 0); |
| 10726 return Execution::DebugBreakHelper(isolate); | 10720 return Execution::DebugBreakHelper(isolate); |
| 10727 } | 10721 } |
| 10728 | 10722 |
| 10729 | 10723 |
| 10730 // Helper functions for wrapping and unwrapping stack frame ids. | 10724 // Helper functions for wrapping and unwrapping stack frame ids. |
| 10731 static Smi* WrapFrameId(StackFrame::Id id) { | 10725 static Smi* WrapFrameId(StackFrame::Id id) { |
| 10732 ASSERT(IsAligned(OffsetFrom(id), static_cast<intptr_t>(4))); | 10726 ASSERT(IsAligned(OffsetFrom(id), static_cast<intptr_t>(4))); |
| 10733 return Smi::FromInt(id >> 2); | 10727 return Smi::FromInt(id >> 2); |
| 10734 } | 10728 } |
| 10735 | 10729 |
| 10736 | 10730 |
| 10737 static StackFrame::Id UnwrapFrameId(int wrapped) { | 10731 static StackFrame::Id UnwrapFrameId(int wrapped) { |
| 10738 return static_cast<StackFrame::Id>(wrapped << 2); | 10732 return static_cast<StackFrame::Id>(wrapped << 2); |
| 10739 } | 10733 } |
| 10740 | 10734 |
| 10741 | 10735 |
| 10742 // Adds a JavaScript function as a debug event listener. | 10736 // Adds a JavaScript function as a debug event listener. |
| 10743 // args[0]: debug event listener function to set or null or undefined for | 10737 // args[0]: debug event listener function to set or null or undefined for |
| 10744 // clearing the event listener function | 10738 // clearing the event listener function |
| 10745 // args[1]: object supplied during callback | 10739 // args[1]: object supplied during callback |
| 10746 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDebugEventListener) { | 10740 RUNTIME_FUNCTION(Runtime_SetDebugEventListener) { |
| 10747 SealHandleScope shs(isolate); | 10741 SealHandleScope shs(isolate); |
| 10748 ASSERT(args.length() == 2); | 10742 ASSERT(args.length() == 2); |
| 10749 RUNTIME_ASSERT(args[0]->IsJSFunction() || | 10743 RUNTIME_ASSERT(args[0]->IsJSFunction() || |
| 10750 args[0]->IsUndefined() || | 10744 args[0]->IsUndefined() || |
| 10751 args[0]->IsNull()); | 10745 args[0]->IsNull()); |
| 10752 CONVERT_ARG_HANDLE_CHECKED(Object, callback, 0); | 10746 CONVERT_ARG_HANDLE_CHECKED(Object, callback, 0); |
| 10753 CONVERT_ARG_HANDLE_CHECKED(Object, data, 1); | 10747 CONVERT_ARG_HANDLE_CHECKED(Object, data, 1); |
| 10754 isolate->debugger()->SetEventListener(callback, data); | 10748 isolate->debugger()->SetEventListener(callback, data); |
| 10755 | 10749 |
| 10756 return isolate->heap()->undefined_value(); | 10750 return isolate->heap()->undefined_value(); |
| 10757 } | 10751 } |
| 10758 | 10752 |
| 10759 | 10753 |
| 10760 RUNTIME_FUNCTION(MaybeObject*, Runtime_Break) { | 10754 RUNTIME_FUNCTION(Runtime_Break) { |
| 10761 SealHandleScope shs(isolate); | 10755 SealHandleScope shs(isolate); |
| 10762 ASSERT(args.length() == 0); | 10756 ASSERT(args.length() == 0); |
| 10763 isolate->stack_guard()->DebugBreak(); | 10757 isolate->stack_guard()->DebugBreak(); |
| 10764 return isolate->heap()->undefined_value(); | 10758 return isolate->heap()->undefined_value(); |
| 10765 } | 10759 } |
| 10766 | 10760 |
| 10767 | 10761 |
| 10768 static Handle<Object> DebugLookupResultValue(Isolate* isolate, | 10762 static Handle<Object> DebugLookupResultValue(Isolate* isolate, |
| 10769 Handle<Object> receiver, | 10763 Handle<Object> receiver, |
| 10770 Handle<Name> name, | 10764 Handle<Name> name, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10816 // args[1]: name of the property | 10810 // args[1]: name of the property |
| 10817 // | 10811 // |
| 10818 // The array returned contains the following information: | 10812 // The array returned contains the following information: |
| 10819 // 0: Property value | 10813 // 0: Property value |
| 10820 // 1: Property details | 10814 // 1: Property details |
| 10821 // 2: Property value is exception | 10815 // 2: Property value is exception |
| 10822 // 3: Getter function if defined | 10816 // 3: Getter function if defined |
| 10823 // 4: Setter function if defined | 10817 // 4: Setter function if defined |
| 10824 // Items 2-4 are only filled if the property has either a getter or a setter | 10818 // Items 2-4 are only filled if the property has either a getter or a setter |
| 10825 // defined through __defineGetter__ and/or __defineSetter__. | 10819 // defined through __defineGetter__ and/or __defineSetter__. |
| 10826 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetPropertyDetails) { | 10820 RUNTIME_FUNCTION(Runtime_DebugGetPropertyDetails) { |
| 10827 HandleScope scope(isolate); | 10821 HandleScope scope(isolate); |
| 10828 | 10822 |
| 10829 ASSERT(args.length() == 2); | 10823 ASSERT(args.length() == 2); |
| 10830 | 10824 |
| 10831 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 10825 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
| 10832 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 10826 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
| 10833 | 10827 |
| 10834 // Make sure to set the current context to the context before the debugger was | 10828 // Make sure to set the current context to the context before the debugger was |
| 10835 // entered (if the debugger is entered). The reason for switching context here | 10829 // entered (if the debugger is entered). The reason for switching context here |
| 10836 // is that for some property lookups (accessors and interceptors) callbacks | 10830 // is that for some property lookups (accessors and interceptors) callbacks |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10906 } | 10900 } |
| 10907 if (i < length - 1) { | 10901 if (i < length - 1) { |
| 10908 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); | 10902 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); |
| 10909 } | 10903 } |
| 10910 } | 10904 } |
| 10911 | 10905 |
| 10912 return isolate->heap()->undefined_value(); | 10906 return isolate->heap()->undefined_value(); |
| 10913 } | 10907 } |
| 10914 | 10908 |
| 10915 | 10909 |
| 10916 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetProperty) { | 10910 RUNTIME_FUNCTION(Runtime_DebugGetProperty) { |
| 10917 HandleScope scope(isolate); | 10911 HandleScope scope(isolate); |
| 10918 | 10912 |
| 10919 ASSERT(args.length() == 2); | 10913 ASSERT(args.length() == 2); |
| 10920 | 10914 |
| 10921 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 10915 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
| 10922 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 10916 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
| 10923 | 10917 |
| 10924 LookupResult result(isolate); | 10918 LookupResult result(isolate); |
| 10925 obj->Lookup(*name, &result); | 10919 obj->Lookup(*name, &result); |
| 10926 return *DebugLookupResultValue(isolate, obj, name, &result); | 10920 return *DebugLookupResultValue(isolate, obj, name, &result); |
| 10927 } | 10921 } |
| 10928 | 10922 |
| 10929 | 10923 |
| 10930 // Return the property type calculated from the property details. | 10924 // Return the property type calculated from the property details. |
| 10931 // args[0]: smi with property details. | 10925 // args[0]: smi with property details. |
| 10932 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyTypeFromDetails) { | 10926 RUNTIME_FUNCTION(Runtime_DebugPropertyTypeFromDetails) { |
| 10933 SealHandleScope shs(isolate); | 10927 SealHandleScope shs(isolate); |
| 10934 ASSERT(args.length() == 1); | 10928 ASSERT(args.length() == 1); |
| 10935 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); | 10929 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); |
| 10936 return Smi::FromInt(static_cast<int>(details.type())); | 10930 return Smi::FromInt(static_cast<int>(details.type())); |
| 10937 } | 10931 } |
| 10938 | 10932 |
| 10939 | 10933 |
| 10940 // Return the property attribute calculated from the property details. | 10934 // Return the property attribute calculated from the property details. |
| 10941 // args[0]: smi with property details. | 10935 // args[0]: smi with property details. |
| 10942 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyAttributesFromDetails) { | 10936 RUNTIME_FUNCTION(Runtime_DebugPropertyAttributesFromDetails) { |
| 10943 SealHandleScope shs(isolate); | 10937 SealHandleScope shs(isolate); |
| 10944 ASSERT(args.length() == 1); | 10938 ASSERT(args.length() == 1); |
| 10945 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); | 10939 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); |
| 10946 return Smi::FromInt(static_cast<int>(details.attributes())); | 10940 return Smi::FromInt(static_cast<int>(details.attributes())); |
| 10947 } | 10941 } |
| 10948 | 10942 |
| 10949 | 10943 |
| 10950 // Return the property insertion index calculated from the property details. | 10944 // Return the property insertion index calculated from the property details. |
| 10951 // args[0]: smi with property details. | 10945 // args[0]: smi with property details. |
| 10952 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyIndexFromDetails) { | 10946 RUNTIME_FUNCTION(Runtime_DebugPropertyIndexFromDetails) { |
| 10953 SealHandleScope shs(isolate); | 10947 SealHandleScope shs(isolate); |
| 10954 ASSERT(args.length() == 1); | 10948 ASSERT(args.length() == 1); |
| 10955 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); | 10949 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); |
| 10956 // TODO(verwaest): Depends on the type of details. | 10950 // TODO(verwaest): Depends on the type of details. |
| 10957 return Smi::FromInt(details.dictionary_index()); | 10951 return Smi::FromInt(details.dictionary_index()); |
| 10958 } | 10952 } |
| 10959 | 10953 |
| 10960 | 10954 |
| 10961 // Return property value from named interceptor. | 10955 // Return property value from named interceptor. |
| 10962 // args[0]: object | 10956 // args[0]: object |
| 10963 // args[1]: property name | 10957 // args[1]: property name |
| 10964 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugNamedInterceptorPropertyValue) { | 10958 RUNTIME_FUNCTION(Runtime_DebugNamedInterceptorPropertyValue) { |
| 10965 HandleScope scope(isolate); | 10959 HandleScope scope(isolate); |
| 10966 ASSERT(args.length() == 2); | 10960 ASSERT(args.length() == 2); |
| 10967 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 10961 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
| 10968 RUNTIME_ASSERT(obj->HasNamedInterceptor()); | 10962 RUNTIME_ASSERT(obj->HasNamedInterceptor()); |
| 10969 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 10963 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
| 10970 | 10964 |
| 10971 PropertyAttributes attributes; | 10965 PropertyAttributes attributes; |
| 10972 Handle<Object> result; | 10966 Handle<Object> result; |
| 10973 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 10967 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 10974 isolate, result, | 10968 isolate, result, |
| 10975 JSObject::GetPropertyWithInterceptor(obj, obj, name, &attributes)); | 10969 JSObject::GetPropertyWithInterceptor(obj, obj, name, &attributes)); |
| 10976 return *result; | 10970 return *result; |
| 10977 } | 10971 } |
| 10978 | 10972 |
| 10979 | 10973 |
| 10980 // Return element value from indexed interceptor. | 10974 // Return element value from indexed interceptor. |
| 10981 // args[0]: object | 10975 // args[0]: object |
| 10982 // args[1]: index | 10976 // args[1]: index |
| 10983 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugIndexedInterceptorElementValue) { | 10977 RUNTIME_FUNCTION(Runtime_DebugIndexedInterceptorElementValue) { |
| 10984 HandleScope scope(isolate); | 10978 HandleScope scope(isolate); |
| 10985 ASSERT(args.length() == 2); | 10979 ASSERT(args.length() == 2); |
| 10986 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 10980 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
| 10987 RUNTIME_ASSERT(obj->HasIndexedInterceptor()); | 10981 RUNTIME_ASSERT(obj->HasIndexedInterceptor()); |
| 10988 CONVERT_NUMBER_CHECKED(uint32_t, index, Uint32, args[1]); | 10982 CONVERT_NUMBER_CHECKED(uint32_t, index, Uint32, args[1]); |
| 10989 Handle<Object> result; | 10983 Handle<Object> result; |
| 10990 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 10984 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 10991 isolate, result, JSObject::GetElementWithInterceptor(obj, obj, index)); | 10985 isolate, result, JSObject::GetElementWithInterceptor(obj, obj, index)); |
| 10992 return *result; | 10986 return *result; |
| 10993 } | 10987 } |
| 10994 | 10988 |
| 10995 | 10989 |
| 10996 static bool CheckExecutionState(Isolate* isolate, int break_id) { | 10990 static bool CheckExecutionState(Isolate* isolate, int break_id) { |
| 10997 return (isolate->debug()->break_id() != 0 && | 10991 return (isolate->debug()->break_id() != 0 && |
| 10998 break_id == isolate->debug()->break_id()); | 10992 break_id == isolate->debug()->break_id()); |
| 10999 } | 10993 } |
| 11000 | 10994 |
| 11001 | 10995 |
| 11002 RUNTIME_FUNCTION(MaybeObject*, Runtime_CheckExecutionState) { | 10996 RUNTIME_FUNCTION(Runtime_CheckExecutionState) { |
| 11003 SealHandleScope shs(isolate); | 10997 SealHandleScope shs(isolate); |
| 11004 ASSERT(args.length() == 1); | 10998 ASSERT(args.length() == 1); |
| 11005 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 10999 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
| 11006 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 11000 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
| 11007 return isolate->heap()->true_value(); | 11001 return isolate->heap()->true_value(); |
| 11008 } | 11002 } |
| 11009 | 11003 |
| 11010 | 11004 |
| 11011 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFrameCount) { | 11005 RUNTIME_FUNCTION(Runtime_GetFrameCount) { |
| 11012 HandleScope scope(isolate); | 11006 HandleScope scope(isolate); |
| 11013 ASSERT(args.length() == 1); | 11007 ASSERT(args.length() == 1); |
| 11014 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 11008 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
| 11015 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 11009 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
| 11016 | 11010 |
| 11017 // Count all frames which are relevant to debugging stack trace. | 11011 // Count all frames which are relevant to debugging stack trace. |
| 11018 int n = 0; | 11012 int n = 0; |
| 11019 StackFrame::Id id = isolate->debug()->break_frame_id(); | 11013 StackFrame::Id id = isolate->debug()->break_frame_id(); |
| 11020 if (id == StackFrame::NO_ID) { | 11014 if (id == StackFrame::NO_ID) { |
| 11021 // If there is no JavaScript stack frame count is 0. | 11015 // If there is no JavaScript stack frame count is 0. |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11139 // 2: Function | 11133 // 2: Function |
| 11140 // 3: Argument count | 11134 // 3: Argument count |
| 11141 // 4: Local count | 11135 // 4: Local count |
| 11142 // 5: Source position | 11136 // 5: Source position |
| 11143 // 6: Constructor call | 11137 // 6: Constructor call |
| 11144 // 7: Is at return | 11138 // 7: Is at return |
| 11145 // 8: Flags | 11139 // 8: Flags |
| 11146 // Arguments name, value | 11140 // Arguments name, value |
| 11147 // Locals name, value | 11141 // Locals name, value |
| 11148 // Return value if any | 11142 // Return value if any |
| 11149 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFrameDetails) { | 11143 RUNTIME_FUNCTION(Runtime_GetFrameDetails) { |
| 11150 HandleScope scope(isolate); | 11144 HandleScope scope(isolate); |
| 11151 ASSERT(args.length() == 2); | 11145 ASSERT(args.length() == 2); |
| 11152 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 11146 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
| 11153 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 11147 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
| 11154 | 11148 |
| 11155 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); | 11149 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); |
| 11156 Heap* heap = isolate->heap(); | 11150 Heap* heap = isolate->heap(); |
| 11157 | 11151 |
| 11158 // Find the relevant frame with the requested index. | 11152 // Find the relevant frame with the requested index. |
| 11159 StackFrame::Id id = isolate->debug()->break_frame_id(); | 11153 StackFrame::Id id = isolate->debug()->break_frame_id(); |
| (...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12165 // Or it could be due to stack overflow. | 12159 // Or it could be due to stack overflow. |
| 12166 ASSERT(isolate_->has_pending_exception()); | 12160 ASSERT(isolate_->has_pending_exception()); |
| 12167 failed_ = true; | 12161 failed_ = true; |
| 12168 } | 12162 } |
| 12169 } | 12163 } |
| 12170 | 12164 |
| 12171 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopeIterator); | 12165 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopeIterator); |
| 12172 }; | 12166 }; |
| 12173 | 12167 |
| 12174 | 12168 |
| 12175 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeCount) { | 12169 RUNTIME_FUNCTION(Runtime_GetScopeCount) { |
| 12176 HandleScope scope(isolate); | 12170 HandleScope scope(isolate); |
| 12177 ASSERT(args.length() == 2); | 12171 ASSERT(args.length() == 2); |
| 12178 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 12172 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
| 12179 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 12173 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
| 12180 | 12174 |
| 12181 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); | 12175 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); |
| 12182 | 12176 |
| 12183 // Get the frame where the debugging is performed. | 12177 // Get the frame where the debugging is performed. |
| 12184 StackFrame::Id id = UnwrapFrameId(wrapped_id); | 12178 StackFrame::Id id = UnwrapFrameId(wrapped_id); |
| 12185 JavaScriptFrameIterator it(isolate, id); | 12179 JavaScriptFrameIterator it(isolate, id); |
| 12186 JavaScriptFrame* frame = it.frame(); | 12180 JavaScriptFrame* frame = it.frame(); |
| 12187 | 12181 |
| 12188 // Count the visible scopes. | 12182 // Count the visible scopes. |
| 12189 int n = 0; | 12183 int n = 0; |
| 12190 for (ScopeIterator it(isolate, frame, 0); | 12184 for (ScopeIterator it(isolate, frame, 0); |
| 12191 !it.Done(); | 12185 !it.Done(); |
| 12192 it.Next()) { | 12186 it.Next()) { |
| 12193 n++; | 12187 n++; |
| 12194 } | 12188 } |
| 12195 | 12189 |
| 12196 return Smi::FromInt(n); | 12190 return Smi::FromInt(n); |
| 12197 } | 12191 } |
| 12198 | 12192 |
| 12199 | 12193 |
| 12200 // Returns the list of step-in positions (text offset) in a function of the | 12194 // Returns the list of step-in positions (text offset) in a function of the |
| 12201 // stack frame in a range from the current debug break position to the end | 12195 // stack frame in a range from the current debug break position to the end |
| 12202 // of the corresponding statement. | 12196 // of the corresponding statement. |
| 12203 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetStepInPositions) { | 12197 RUNTIME_FUNCTION(Runtime_GetStepInPositions) { |
| 12204 HandleScope scope(isolate); | 12198 HandleScope scope(isolate); |
| 12205 ASSERT(args.length() == 2); | 12199 ASSERT(args.length() == 2); |
| 12206 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 12200 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
| 12207 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 12201 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
| 12208 | 12202 |
| 12209 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); | 12203 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); |
| 12210 | 12204 |
| 12211 // Get the frame where the debugging is performed. | 12205 // Get the frame where the debugging is performed. |
| 12212 StackFrame::Id id = UnwrapFrameId(wrapped_id); | 12206 StackFrame::Id id = UnwrapFrameId(wrapped_id); |
| 12213 JavaScriptFrameIterator frame_it(isolate, id); | 12207 JavaScriptFrameIterator frame_it(isolate, id); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12300 | 12294 |
| 12301 // Return an array with scope details | 12295 // Return an array with scope details |
| 12302 // args[0]: number: break id | 12296 // args[0]: number: break id |
| 12303 // args[1]: number: frame index | 12297 // args[1]: number: frame index |
| 12304 // args[2]: number: inlined frame index | 12298 // args[2]: number: inlined frame index |
| 12305 // args[3]: number: scope index | 12299 // args[3]: number: scope index |
| 12306 // | 12300 // |
| 12307 // The array returned contains the following information: | 12301 // The array returned contains the following information: |
| 12308 // 0: Scope type | 12302 // 0: Scope type |
| 12309 // 1: Scope object | 12303 // 1: Scope object |
| 12310 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeDetails) { | 12304 RUNTIME_FUNCTION(Runtime_GetScopeDetails) { |
| 12311 HandleScope scope(isolate); | 12305 HandleScope scope(isolate); |
| 12312 ASSERT(args.length() == 4); | 12306 ASSERT(args.length() == 4); |
| 12313 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 12307 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
| 12314 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 12308 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
| 12315 | 12309 |
| 12316 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); | 12310 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); |
| 12317 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); | 12311 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); |
| 12318 CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]); | 12312 CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]); |
| 12319 | 12313 |
| 12320 // Get the frame where the debugging is performed. | 12314 // Get the frame where the debugging is performed. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 12340 | 12334 |
| 12341 // Return an array of scope details | 12335 // Return an array of scope details |
| 12342 // args[0]: number: break id | 12336 // args[0]: number: break id |
| 12343 // args[1]: number: frame index | 12337 // args[1]: number: frame index |
| 12344 // args[2]: number: inlined frame index | 12338 // args[2]: number: inlined frame index |
| 12345 // args[3]: boolean: ignore nested scopes | 12339 // args[3]: boolean: ignore nested scopes |
| 12346 // | 12340 // |
| 12347 // The array returned contains arrays with the following information: | 12341 // The array returned contains arrays with the following information: |
| 12348 // 0: Scope type | 12342 // 0: Scope type |
| 12349 // 1: Scope object | 12343 // 1: Scope object |
| 12350 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetAllScopesDetails) { | 12344 RUNTIME_FUNCTION(Runtime_GetAllScopesDetails) { |
| 12351 HandleScope scope(isolate); | 12345 HandleScope scope(isolate); |
| 12352 ASSERT(args.length() == 3 || args.length() == 4); | 12346 ASSERT(args.length() == 3 || args.length() == 4); |
| 12353 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 12347 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
| 12354 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 12348 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
| 12355 | 12349 |
| 12356 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); | 12350 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); |
| 12357 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); | 12351 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); |
| 12358 | 12352 |
| 12359 bool ignore_nested_scopes = false; | 12353 bool ignore_nested_scopes = false; |
| 12360 if (args.length() == 4) { | 12354 if (args.length() == 4) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 12377 } | 12371 } |
| 12378 | 12372 |
| 12379 Handle<FixedArray> array = isolate->factory()->NewFixedArray(result.length()); | 12373 Handle<FixedArray> array = isolate->factory()->NewFixedArray(result.length()); |
| 12380 for (int i = 0; i < result.length(); ++i) { | 12374 for (int i = 0; i < result.length(); ++i) { |
| 12381 array->set(i, *result[i]); | 12375 array->set(i, *result[i]); |
| 12382 } | 12376 } |
| 12383 return *isolate->factory()->NewJSArrayWithElements(array); | 12377 return *isolate->factory()->NewJSArrayWithElements(array); |
| 12384 } | 12378 } |
| 12385 | 12379 |
| 12386 | 12380 |
| 12387 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFunctionScopeCount) { | 12381 RUNTIME_FUNCTION(Runtime_GetFunctionScopeCount) { |
| 12388 HandleScope scope(isolate); | 12382 HandleScope scope(isolate); |
| 12389 ASSERT(args.length() == 1); | 12383 ASSERT(args.length() == 1); |
| 12390 | 12384 |
| 12391 // Check arguments. | 12385 // Check arguments. |
| 12392 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); | 12386 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); |
| 12393 | 12387 |
| 12394 // Count the visible scopes. | 12388 // Count the visible scopes. |
| 12395 int n = 0; | 12389 int n = 0; |
| 12396 for (ScopeIterator it(isolate, fun); !it.Done(); it.Next()) { | 12390 for (ScopeIterator it(isolate, fun); !it.Done(); it.Next()) { |
| 12397 n++; | 12391 n++; |
| 12398 } | 12392 } |
| 12399 | 12393 |
| 12400 return Smi::FromInt(n); | 12394 return Smi::FromInt(n); |
| 12401 } | 12395 } |
| 12402 | 12396 |
| 12403 | 12397 |
| 12404 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFunctionScopeDetails) { | 12398 RUNTIME_FUNCTION(Runtime_GetFunctionScopeDetails) { |
| 12405 HandleScope scope(isolate); | 12399 HandleScope scope(isolate); |
| 12406 ASSERT(args.length() == 2); | 12400 ASSERT(args.length() == 2); |
| 12407 | 12401 |
| 12408 // Check arguments. | 12402 // Check arguments. |
| 12409 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); | 12403 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); |
| 12410 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); | 12404 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); |
| 12411 | 12405 |
| 12412 // Find the requested scope. | 12406 // Find the requested scope. |
| 12413 int n = 0; | 12407 int n = 0; |
| 12414 ScopeIterator it(isolate, fun); | 12408 ScopeIterator it(isolate, fun); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 12441 | 12435 |
| 12442 // Change variable value in closure or local scope | 12436 // Change variable value in closure or local scope |
| 12443 // args[0]: number or JsFunction: break id or function | 12437 // args[0]: number or JsFunction: break id or function |
| 12444 // args[1]: number: frame index (when arg[0] is break id) | 12438 // args[1]: number: frame index (when arg[0] is break id) |
| 12445 // args[2]: number: inlined frame index (when arg[0] is break id) | 12439 // args[2]: number: inlined frame index (when arg[0] is break id) |
| 12446 // args[3]: number: scope index | 12440 // args[3]: number: scope index |
| 12447 // args[4]: string: variable name | 12441 // args[4]: string: variable name |
| 12448 // args[5]: object: new value | 12442 // args[5]: object: new value |
| 12449 // | 12443 // |
| 12450 // Return true if success and false otherwise | 12444 // Return true if success and false otherwise |
| 12451 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetScopeVariableValue) { | 12445 RUNTIME_FUNCTION(Runtime_SetScopeVariableValue) { |
| 12452 HandleScope scope(isolate); | 12446 HandleScope scope(isolate); |
| 12453 ASSERT(args.length() == 6); | 12447 ASSERT(args.length() == 6); |
| 12454 | 12448 |
| 12455 // Check arguments. | 12449 // Check arguments. |
| 12456 CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]); | 12450 CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]); |
| 12457 CONVERT_ARG_HANDLE_CHECKED(String, variable_name, 4); | 12451 CONVERT_ARG_HANDLE_CHECKED(String, variable_name, 4); |
| 12458 CONVERT_ARG_HANDLE_CHECKED(Object, new_value, 5); | 12452 CONVERT_ARG_HANDLE_CHECKED(Object, new_value, 5); |
| 12459 | 12453 |
| 12460 bool res; | 12454 bool res; |
| 12461 if (args[0]->IsNumber()) { | 12455 if (args[0]->IsNumber()) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 12475 } else { | 12469 } else { |
| 12476 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); | 12470 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); |
| 12477 ScopeIterator it(isolate, fun); | 12471 ScopeIterator it(isolate, fun); |
| 12478 res = SetScopeVariableValue(&it, index, variable_name, new_value); | 12472 res = SetScopeVariableValue(&it, index, variable_name, new_value); |
| 12479 } | 12473 } |
| 12480 | 12474 |
| 12481 return isolate->heap()->ToBoolean(res); | 12475 return isolate->heap()->ToBoolean(res); |
| 12482 } | 12476 } |
| 12483 | 12477 |
| 12484 | 12478 |
| 12485 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPrintScopes) { | 12479 RUNTIME_FUNCTION(Runtime_DebugPrintScopes) { |
| 12486 HandleScope scope(isolate); | 12480 HandleScope scope(isolate); |
| 12487 ASSERT(args.length() == 0); | 12481 ASSERT(args.length() == 0); |
| 12488 | 12482 |
| 12489 #ifdef DEBUG | 12483 #ifdef DEBUG |
| 12490 // Print the scopes for the top frame. | 12484 // Print the scopes for the top frame. |
| 12491 StackFrameLocator locator(isolate); | 12485 StackFrameLocator locator(isolate); |
| 12492 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0); | 12486 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0); |
| 12493 for (ScopeIterator it(isolate, frame, 0); | 12487 for (ScopeIterator it(isolate, frame, 0); |
| 12494 !it.Done(); | 12488 !it.Done(); |
| 12495 it.Next()) { | 12489 it.Next()) { |
| 12496 it.DebugPrint(); | 12490 it.DebugPrint(); |
| 12497 } | 12491 } |
| 12498 #endif | 12492 #endif |
| 12499 return isolate->heap()->undefined_value(); | 12493 return isolate->heap()->undefined_value(); |
| 12500 } | 12494 } |
| 12501 | 12495 |
| 12502 | 12496 |
| 12503 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetThreadCount) { | 12497 RUNTIME_FUNCTION(Runtime_GetThreadCount) { |
| 12504 HandleScope scope(isolate); | 12498 HandleScope scope(isolate); |
| 12505 ASSERT(args.length() == 1); | 12499 ASSERT(args.length() == 1); |
| 12506 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 12500 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
| 12507 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 12501 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
| 12508 | 12502 |
| 12509 // Count all archived V8 threads. | 12503 // Count all archived V8 threads. |
| 12510 int n = 0; | 12504 int n = 0; |
| 12511 for (ThreadState* thread = | 12505 for (ThreadState* thread = |
| 12512 isolate->thread_manager()->FirstThreadStateInUse(); | 12506 isolate->thread_manager()->FirstThreadStateInUse(); |
| 12513 thread != NULL; | 12507 thread != NULL; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 12524 static const int kThreadDetailsThreadIdIndex = 1; | 12518 static const int kThreadDetailsThreadIdIndex = 1; |
| 12525 static const int kThreadDetailsSize = 2; | 12519 static const int kThreadDetailsSize = 2; |
| 12526 | 12520 |
| 12527 // Return an array with thread details | 12521 // Return an array with thread details |
| 12528 // args[0]: number: break id | 12522 // args[0]: number: break id |
| 12529 // args[1]: number: thread index | 12523 // args[1]: number: thread index |
| 12530 // | 12524 // |
| 12531 // The array returned contains the following information: | 12525 // The array returned contains the following information: |
| 12532 // 0: Is current thread? | 12526 // 0: Is current thread? |
| 12533 // 1: Thread id | 12527 // 1: Thread id |
| 12534 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetThreadDetails) { | 12528 RUNTIME_FUNCTION(Runtime_GetThreadDetails) { |
| 12535 HandleScope scope(isolate); | 12529 HandleScope scope(isolate); |
| 12536 ASSERT(args.length() == 2); | 12530 ASSERT(args.length() == 2); |
| 12537 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 12531 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
| 12538 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 12532 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
| 12539 | 12533 |
| 12540 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); | 12534 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); |
| 12541 | 12535 |
| 12542 // Allocate array for result. | 12536 // Allocate array for result. |
| 12543 Handle<FixedArray> details = | 12537 Handle<FixedArray> details = |
| 12544 isolate->factory()->NewFixedArray(kThreadDetailsSize); | 12538 isolate->factory()->NewFixedArray(kThreadDetailsSize); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 12570 Smi::FromInt(thread->id().ToInteger())); | 12564 Smi::FromInt(thread->id().ToInteger())); |
| 12571 } | 12565 } |
| 12572 | 12566 |
| 12573 // Convert to JS array and return. | 12567 // Convert to JS array and return. |
| 12574 return *isolate->factory()->NewJSArrayWithElements(details); | 12568 return *isolate->factory()->NewJSArrayWithElements(details); |
| 12575 } | 12569 } |
| 12576 | 12570 |
| 12577 | 12571 |
| 12578 // Sets the disable break state | 12572 // Sets the disable break state |
| 12579 // args[0]: disable break state | 12573 // args[0]: disable break state |
| 12580 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDisableBreak) { | 12574 RUNTIME_FUNCTION(Runtime_SetDisableBreak) { |
| 12581 HandleScope scope(isolate); | 12575 HandleScope scope(isolate); |
| 12582 ASSERT(args.length() == 1); | 12576 ASSERT(args.length() == 1); |
| 12583 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 0); | 12577 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 0); |
| 12584 isolate->debug()->set_disable_break(disable_break); | 12578 isolate->debug()->set_disable_break(disable_break); |
| 12585 return isolate->heap()->undefined_value(); | 12579 return isolate->heap()->undefined_value(); |
| 12586 } | 12580 } |
| 12587 | 12581 |
| 12588 | 12582 |
| 12589 static bool IsPositionAlignmentCodeCorrect(int alignment) { | 12583 static bool IsPositionAlignmentCodeCorrect(int alignment) { |
| 12590 return alignment == STATEMENT_ALIGNED || alignment == BREAK_POSITION_ALIGNED; | 12584 return alignment == STATEMENT_ALIGNED || alignment == BREAK_POSITION_ALIGNED; |
| 12591 } | 12585 } |
| 12592 | 12586 |
| 12593 | 12587 |
| 12594 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetBreakLocations) { | 12588 RUNTIME_FUNCTION(Runtime_GetBreakLocations) { |
| 12595 HandleScope scope(isolate); | 12589 HandleScope scope(isolate); |
| 12596 ASSERT(args.length() == 2); | 12590 ASSERT(args.length() == 2); |
| 12597 | 12591 |
| 12598 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); | 12592 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); |
| 12599 CONVERT_NUMBER_CHECKED(int32_t, statement_aligned_code, Int32, args[1]); | 12593 CONVERT_NUMBER_CHECKED(int32_t, statement_aligned_code, Int32, args[1]); |
| 12600 | 12594 |
| 12601 if (!IsPositionAlignmentCodeCorrect(statement_aligned_code)) { | 12595 if (!IsPositionAlignmentCodeCorrect(statement_aligned_code)) { |
| 12602 return isolate->ThrowIllegalOperation(); | 12596 return isolate->ThrowIllegalOperation(); |
| 12603 } | 12597 } |
| 12604 BreakPositionAlignment alignment = | 12598 BreakPositionAlignment alignment = |
| 12605 static_cast<BreakPositionAlignment>(statement_aligned_code); | 12599 static_cast<BreakPositionAlignment>(statement_aligned_code); |
| 12606 | 12600 |
| 12607 Handle<SharedFunctionInfo> shared(fun->shared()); | 12601 Handle<SharedFunctionInfo> shared(fun->shared()); |
| 12608 // Find the number of break points | 12602 // Find the number of break points |
| 12609 Handle<Object> break_locations = | 12603 Handle<Object> break_locations = |
| 12610 Debug::GetSourceBreakLocations(shared, alignment); | 12604 Debug::GetSourceBreakLocations(shared, alignment); |
| 12611 if (break_locations->IsUndefined()) return isolate->heap()->undefined_value(); | 12605 if (break_locations->IsUndefined()) return isolate->heap()->undefined_value(); |
| 12612 // Return array as JS array | 12606 // Return array as JS array |
| 12613 return *isolate->factory()->NewJSArrayWithElements( | 12607 return *isolate->factory()->NewJSArrayWithElements( |
| 12614 Handle<FixedArray>::cast(break_locations)); | 12608 Handle<FixedArray>::cast(break_locations)); |
| 12615 } | 12609 } |
| 12616 | 12610 |
| 12617 | 12611 |
| 12618 // Set a break point in a function. | 12612 // Set a break point in a function. |
| 12619 // args[0]: function | 12613 // args[0]: function |
| 12620 // args[1]: number: break source position (within the function source) | 12614 // args[1]: number: break source position (within the function source) |
| 12621 // args[2]: number: break point object | 12615 // args[2]: number: break point object |
| 12622 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetFunctionBreakPoint) { | 12616 RUNTIME_FUNCTION(Runtime_SetFunctionBreakPoint) { |
| 12623 HandleScope scope(isolate); | 12617 HandleScope scope(isolate); |
| 12624 ASSERT(args.length() == 3); | 12618 ASSERT(args.length() == 3); |
| 12625 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 12619 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 12626 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); | 12620 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); |
| 12627 RUNTIME_ASSERT(source_position >= 0); | 12621 RUNTIME_ASSERT(source_position >= 0); |
| 12628 CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 2); | 12622 CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 2); |
| 12629 | 12623 |
| 12630 // Set break point. | 12624 // Set break point. |
| 12631 isolate->debug()->SetBreakPoint(function, break_point_object_arg, | 12625 isolate->debug()->SetBreakPoint(function, break_point_object_arg, |
| 12632 &source_position); | 12626 &source_position); |
| 12633 | 12627 |
| 12634 return Smi::FromInt(source_position); | 12628 return Smi::FromInt(source_position); |
| 12635 } | 12629 } |
| 12636 | 12630 |
| 12637 | 12631 |
| 12638 // Changes the state of a break point in a script and returns source position | 12632 // Changes the state of a break point in a script and returns source position |
| 12639 // where break point was set. NOTE: Regarding performance see the NOTE for | 12633 // where break point was set. NOTE: Regarding performance see the NOTE for |
| 12640 // GetScriptFromScriptData. | 12634 // GetScriptFromScriptData. |
| 12641 // args[0]: script to set break point in | 12635 // args[0]: script to set break point in |
| 12642 // args[1]: number: break source position (within the script source) | 12636 // args[1]: number: break source position (within the script source) |
| 12643 // args[2]: number, breakpoint position alignment | 12637 // args[2]: number, breakpoint position alignment |
| 12644 // args[3]: number: break point object | 12638 // args[3]: number: break point object |
| 12645 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetScriptBreakPoint) { | 12639 RUNTIME_FUNCTION(Runtime_SetScriptBreakPoint) { |
| 12646 HandleScope scope(isolate); | 12640 HandleScope scope(isolate); |
| 12647 ASSERT(args.length() == 4); | 12641 ASSERT(args.length() == 4); |
| 12648 CONVERT_ARG_HANDLE_CHECKED(JSValue, wrapper, 0); | 12642 CONVERT_ARG_HANDLE_CHECKED(JSValue, wrapper, 0); |
| 12649 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); | 12643 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); |
| 12650 RUNTIME_ASSERT(source_position >= 0); | 12644 RUNTIME_ASSERT(source_position >= 0); |
| 12651 CONVERT_NUMBER_CHECKED(int32_t, statement_aligned_code, Int32, args[2]); | 12645 CONVERT_NUMBER_CHECKED(int32_t, statement_aligned_code, Int32, args[2]); |
| 12652 CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 3); | 12646 CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 3); |
| 12653 | 12647 |
| 12654 if (!IsPositionAlignmentCodeCorrect(statement_aligned_code)) { | 12648 if (!IsPositionAlignmentCodeCorrect(statement_aligned_code)) { |
| 12655 return isolate->ThrowIllegalOperation(); | 12649 return isolate->ThrowIllegalOperation(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 12667 alignment)) { | 12661 alignment)) { |
| 12668 return isolate->heap()->undefined_value(); | 12662 return isolate->heap()->undefined_value(); |
| 12669 } | 12663 } |
| 12670 | 12664 |
| 12671 return Smi::FromInt(source_position); | 12665 return Smi::FromInt(source_position); |
| 12672 } | 12666 } |
| 12673 | 12667 |
| 12674 | 12668 |
| 12675 // Clear a break point | 12669 // Clear a break point |
| 12676 // args[0]: number: break point object | 12670 // args[0]: number: break point object |
| 12677 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClearBreakPoint) { | 12671 RUNTIME_FUNCTION(Runtime_ClearBreakPoint) { |
| 12678 HandleScope scope(isolate); | 12672 HandleScope scope(isolate); |
| 12679 ASSERT(args.length() == 1); | 12673 ASSERT(args.length() == 1); |
| 12680 CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 0); | 12674 CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 0); |
| 12681 | 12675 |
| 12682 // Clear break point. | 12676 // Clear break point. |
| 12683 isolate->debug()->ClearBreakPoint(break_point_object_arg); | 12677 isolate->debug()->ClearBreakPoint(break_point_object_arg); |
| 12684 | 12678 |
| 12685 return isolate->heap()->undefined_value(); | 12679 return isolate->heap()->undefined_value(); |
| 12686 } | 12680 } |
| 12687 | 12681 |
| 12688 | 12682 |
| 12689 // Change the state of break on exceptions. | 12683 // Change the state of break on exceptions. |
| 12690 // args[0]: Enum value indicating whether to affect caught/uncaught exceptions. | 12684 // args[0]: Enum value indicating whether to affect caught/uncaught exceptions. |
| 12691 // args[1]: Boolean indicating on/off. | 12685 // args[1]: Boolean indicating on/off. |
| 12692 RUNTIME_FUNCTION(MaybeObject*, Runtime_ChangeBreakOnException) { | 12686 RUNTIME_FUNCTION(Runtime_ChangeBreakOnException) { |
| 12693 HandleScope scope(isolate); | 12687 HandleScope scope(isolate); |
| 12694 ASSERT(args.length() == 2); | 12688 ASSERT(args.length() == 2); |
| 12695 CONVERT_NUMBER_CHECKED(uint32_t, type_arg, Uint32, args[0]); | 12689 CONVERT_NUMBER_CHECKED(uint32_t, type_arg, Uint32, args[0]); |
| 12696 CONVERT_BOOLEAN_ARG_CHECKED(enable, 1); | 12690 CONVERT_BOOLEAN_ARG_CHECKED(enable, 1); |
| 12697 | 12691 |
| 12698 // If the number doesn't match an enum value, the ChangeBreakOnException | 12692 // If the number doesn't match an enum value, the ChangeBreakOnException |
| 12699 // function will default to affecting caught exceptions. | 12693 // function will default to affecting caught exceptions. |
| 12700 ExceptionBreakType type = static_cast<ExceptionBreakType>(type_arg); | 12694 ExceptionBreakType type = static_cast<ExceptionBreakType>(type_arg); |
| 12701 // Update break point state. | 12695 // Update break point state. |
| 12702 isolate->debug()->ChangeBreakOnException(type, enable); | 12696 isolate->debug()->ChangeBreakOnException(type, enable); |
| 12703 return isolate->heap()->undefined_value(); | 12697 return isolate->heap()->undefined_value(); |
| 12704 } | 12698 } |
| 12705 | 12699 |
| 12706 | 12700 |
| 12707 // Returns the state of break on exceptions | 12701 // Returns the state of break on exceptions |
| 12708 // args[0]: boolean indicating uncaught exceptions | 12702 // args[0]: boolean indicating uncaught exceptions |
| 12709 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsBreakOnException) { | 12703 RUNTIME_FUNCTION(Runtime_IsBreakOnException) { |
| 12710 HandleScope scope(isolate); | 12704 HandleScope scope(isolate); |
| 12711 ASSERT(args.length() == 1); | 12705 ASSERT(args.length() == 1); |
| 12712 CONVERT_NUMBER_CHECKED(uint32_t, type_arg, Uint32, args[0]); | 12706 CONVERT_NUMBER_CHECKED(uint32_t, type_arg, Uint32, args[0]); |
| 12713 | 12707 |
| 12714 ExceptionBreakType type = static_cast<ExceptionBreakType>(type_arg); | 12708 ExceptionBreakType type = static_cast<ExceptionBreakType>(type_arg); |
| 12715 bool result = isolate->debug()->IsBreakOnException(type); | 12709 bool result = isolate->debug()->IsBreakOnException(type); |
| 12716 return Smi::FromInt(result); | 12710 return Smi::FromInt(result); |
| 12717 } | 12711 } |
| 12718 | 12712 |
| 12719 | 12713 |
| 12720 // Prepare for stepping | 12714 // Prepare for stepping |
| 12721 // args[0]: break id for checking execution state | 12715 // args[0]: break id for checking execution state |
| 12722 // args[1]: step action from the enumeration StepAction | 12716 // args[1]: step action from the enumeration StepAction |
| 12723 // args[2]: number of times to perform the step, for step out it is the number | 12717 // args[2]: number of times to perform the step, for step out it is the number |
| 12724 // of frames to step down. | 12718 // of frames to step down. |
| 12725 RUNTIME_FUNCTION(MaybeObject*, Runtime_PrepareStep) { | 12719 RUNTIME_FUNCTION(Runtime_PrepareStep) { |
| 12726 HandleScope scope(isolate); | 12720 HandleScope scope(isolate); |
| 12727 ASSERT(args.length() == 4); | 12721 ASSERT(args.length() == 4); |
| 12728 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 12722 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
| 12729 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 12723 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
| 12730 | 12724 |
| 12731 if (!args[1]->IsNumber() || !args[2]->IsNumber()) { | 12725 if (!args[1]->IsNumber() || !args[2]->IsNumber()) { |
| 12732 return isolate->Throw(isolate->heap()->illegal_argument_string()); | 12726 return isolate->Throw(isolate->heap()->illegal_argument_string()); |
| 12733 } | 12727 } |
| 12734 | 12728 |
| 12735 CONVERT_NUMBER_CHECKED(int, wrapped_frame_id, Int32, args[3]); | 12729 CONVERT_NUMBER_CHECKED(int, wrapped_frame_id, Int32, args[3]); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12767 | 12761 |
| 12768 // Prepare step. | 12762 // Prepare step. |
| 12769 isolate->debug()->PrepareStep(static_cast<StepAction>(step_action), | 12763 isolate->debug()->PrepareStep(static_cast<StepAction>(step_action), |
| 12770 step_count, | 12764 step_count, |
| 12771 frame_id); | 12765 frame_id); |
| 12772 return isolate->heap()->undefined_value(); | 12766 return isolate->heap()->undefined_value(); |
| 12773 } | 12767 } |
| 12774 | 12768 |
| 12775 | 12769 |
| 12776 // Clear all stepping set by PrepareStep. | 12770 // Clear all stepping set by PrepareStep. |
| 12777 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClearStepping) { | 12771 RUNTIME_FUNCTION(Runtime_ClearStepping) { |
| 12778 HandleScope scope(isolate); | 12772 HandleScope scope(isolate); |
| 12779 ASSERT(args.length() == 0); | 12773 ASSERT(args.length() == 0); |
| 12780 isolate->debug()->ClearStepping(); | 12774 isolate->debug()->ClearStepping(); |
| 12781 return isolate->heap()->undefined_value(); | 12775 return isolate->heap()->undefined_value(); |
| 12782 } | 12776 } |
| 12783 | 12777 |
| 12784 | 12778 |
| 12785 // Helper function to find or create the arguments object for | 12779 // Helper function to find or create the arguments object for |
| 12786 // Runtime_DebugEvaluate. | 12780 // Runtime_DebugEvaluate. |
| 12787 MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeArgumentsObject( | 12781 MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeArgumentsObject( |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12847 isolate->debug()->ClearStepping(); | 12841 isolate->debug()->ClearStepping(); |
| 12848 return result; | 12842 return result; |
| 12849 } | 12843 } |
| 12850 | 12844 |
| 12851 | 12845 |
| 12852 // Evaluate a piece of JavaScript in the context of a stack frame for | 12846 // Evaluate a piece of JavaScript in the context of a stack frame for |
| 12853 // debugging. Things that need special attention are: | 12847 // debugging. Things that need special attention are: |
| 12854 // - Parameters and stack-allocated locals need to be materialized. Altered | 12848 // - Parameters and stack-allocated locals need to be materialized. Altered |
| 12855 // values need to be written back to the stack afterwards. | 12849 // values need to be written back to the stack afterwards. |
| 12856 // - The arguments object needs to materialized. | 12850 // - The arguments object needs to materialized. |
| 12857 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugEvaluate) { | 12851 RUNTIME_FUNCTION(Runtime_DebugEvaluate) { |
| 12858 HandleScope scope(isolate); | 12852 HandleScope scope(isolate); |
| 12859 | 12853 |
| 12860 // Check the execution state and decode arguments frame and source to be | 12854 // Check the execution state and decode arguments frame and source to be |
| 12861 // evaluated. | 12855 // evaluated. |
| 12862 ASSERT(args.length() == 6); | 12856 ASSERT(args.length() == 6); |
| 12863 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 12857 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
| 12864 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 12858 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
| 12865 | 12859 |
| 12866 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); | 12860 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); |
| 12867 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); | 12861 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12913 DebugEvaluate(isolate, context, context_extension, receiver, source)); | 12907 DebugEvaluate(isolate, context, context_extension, receiver, source)); |
| 12914 | 12908 |
| 12915 // Write back potential changes to materialized stack locals to the stack. | 12909 // Write back potential changes to materialized stack locals to the stack. |
| 12916 UpdateStackLocalsFromMaterializedObject( | 12910 UpdateStackLocalsFromMaterializedObject( |
| 12917 isolate, materialized, function, frame, inlined_jsframe_index); | 12911 isolate, materialized, function, frame, inlined_jsframe_index); |
| 12918 | 12912 |
| 12919 return *result; | 12913 return *result; |
| 12920 } | 12914 } |
| 12921 | 12915 |
| 12922 | 12916 |
| 12923 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugEvaluateGlobal) { | 12917 RUNTIME_FUNCTION(Runtime_DebugEvaluateGlobal) { |
| 12924 HandleScope scope(isolate); | 12918 HandleScope scope(isolate); |
| 12925 | 12919 |
| 12926 // Check the execution state and decode arguments frame and source to be | 12920 // Check the execution state and decode arguments frame and source to be |
| 12927 // evaluated. | 12921 // evaluated. |
| 12928 ASSERT(args.length() == 4); | 12922 ASSERT(args.length() == 4); |
| 12929 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 12923 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
| 12930 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 12924 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
| 12931 | 12925 |
| 12932 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); | 12926 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); |
| 12933 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 2); | 12927 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 2); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 12951 Handle<Context> context = isolate->native_context(); | 12945 Handle<Context> context = isolate->native_context(); |
| 12952 Handle<Object> receiver = isolate->global_object(); | 12946 Handle<Object> receiver = isolate->global_object(); |
| 12953 Handle<Object> result; | 12947 Handle<Object> result; |
| 12954 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 12948 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 12955 isolate, result, | 12949 isolate, result, |
| 12956 DebugEvaluate(isolate, context, context_extension, receiver, source)); | 12950 DebugEvaluate(isolate, context, context_extension, receiver, source)); |
| 12957 return *result; | 12951 return *result; |
| 12958 } | 12952 } |
| 12959 | 12953 |
| 12960 | 12954 |
| 12961 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetLoadedScripts) { | 12955 RUNTIME_FUNCTION(Runtime_DebugGetLoadedScripts) { |
| 12962 HandleScope scope(isolate); | 12956 HandleScope scope(isolate); |
| 12963 ASSERT(args.length() == 0); | 12957 ASSERT(args.length() == 0); |
| 12964 | 12958 |
| 12965 // Fill the script objects. | 12959 // Fill the script objects. |
| 12966 Handle<FixedArray> instances = isolate->debug()->GetLoadedScripts(); | 12960 Handle<FixedArray> instances = isolate->debug()->GetLoadedScripts(); |
| 12967 | 12961 |
| 12968 // Convert the script objects to proper JS objects. | 12962 // Convert the script objects to proper JS objects. |
| 12969 for (int i = 0; i < instances->length(); i++) { | 12963 for (int i = 0; i < instances->length(); i++) { |
| 12970 Handle<Script> script = Handle<Script>(Script::cast(instances->get(i))); | 12964 Handle<Script> script = Handle<Script>(Script::cast(instances->get(i))); |
| 12971 // Get the script wrapper in a local handle before calling GetScriptWrapper, | 12965 // Get the script wrapper in a local handle before calling GetScriptWrapper, |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13053 | 13047 |
| 13054 // Return the number of referencing objects found. | 13048 // Return the number of referencing objects found. |
| 13055 return count; | 13049 return count; |
| 13056 } | 13050 } |
| 13057 | 13051 |
| 13058 | 13052 |
| 13059 // Scan the heap for objects with direct references to an object | 13053 // Scan the heap for objects with direct references to an object |
| 13060 // args[0]: the object to find references to | 13054 // args[0]: the object to find references to |
| 13061 // args[1]: constructor function for instances to exclude (Mirror) | 13055 // args[1]: constructor function for instances to exclude (Mirror) |
| 13062 // args[2]: the the maximum number of objects to return | 13056 // args[2]: the the maximum number of objects to return |
| 13063 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugReferencedBy) { | 13057 RUNTIME_FUNCTION(Runtime_DebugReferencedBy) { |
| 13064 HandleScope scope(isolate); | 13058 HandleScope scope(isolate); |
| 13065 ASSERT(args.length() == 3); | 13059 ASSERT(args.length() == 3); |
| 13066 | 13060 |
| 13067 // First perform a full GC in order to avoid references from dead objects. | 13061 // First perform a full GC in order to avoid references from dead objects. |
| 13068 Heap* heap = isolate->heap(); | 13062 Heap* heap = isolate->heap(); |
| 13069 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, "%DebugReferencedBy"); | 13063 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, "%DebugReferencedBy"); |
| 13070 // The heap iterator reserves the right to do a GC to make the heap iterable. | 13064 // The heap iterator reserves the right to do a GC to make the heap iterable. |
| 13071 // Due to the GC above we know it won't need to do that, but it seems cleaner | 13065 // Due to the GC above we know it won't need to do that, but it seems cleaner |
| 13072 // to get the heap iterator constructed before we start having unprotected | 13066 // to get the heap iterator constructed before we start having unprotected |
| 13073 // Object* locals that are not protected by handles. | 13067 // Object* locals that are not protected by handles. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13143 } | 13137 } |
| 13144 | 13138 |
| 13145 // Return the number of referencing objects found. | 13139 // Return the number of referencing objects found. |
| 13146 return count; | 13140 return count; |
| 13147 } | 13141 } |
| 13148 | 13142 |
| 13149 | 13143 |
| 13150 // Scan the heap for objects constructed by a specific function. | 13144 // Scan the heap for objects constructed by a specific function. |
| 13151 // args[0]: the constructor to find instances of | 13145 // args[0]: the constructor to find instances of |
| 13152 // args[1]: the the maximum number of objects to return | 13146 // args[1]: the the maximum number of objects to return |
| 13153 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugConstructedBy) { | 13147 RUNTIME_FUNCTION(Runtime_DebugConstructedBy) { |
| 13154 HandleScope scope(isolate); | 13148 HandleScope scope(isolate); |
| 13155 ASSERT(args.length() == 2); | 13149 ASSERT(args.length() == 2); |
| 13156 | 13150 |
| 13157 // First perform a full GC in order to avoid dead objects. | 13151 // First perform a full GC in order to avoid dead objects. |
| 13158 Heap* heap = isolate->heap(); | 13152 Heap* heap = isolate->heap(); |
| 13159 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, "%DebugConstructedBy"); | 13153 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, "%DebugConstructedBy"); |
| 13160 | 13154 |
| 13161 // Check parameters. | 13155 // Check parameters. |
| 13162 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, 0); | 13156 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, 0); |
| 13163 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[1]); | 13157 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[1]); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 13188 Handle<JSFunction> array_function( | 13182 Handle<JSFunction> array_function( |
| 13189 isolate->context()->native_context()->array_function()); | 13183 isolate->context()->native_context()->array_function()); |
| 13190 Handle<JSObject> result = isolate->factory()->NewJSObject(array_function); | 13184 Handle<JSObject> result = isolate->factory()->NewJSObject(array_function); |
| 13191 JSArray::SetContent(Handle<JSArray>::cast(result), instances); | 13185 JSArray::SetContent(Handle<JSArray>::cast(result), instances); |
| 13192 return *result; | 13186 return *result; |
| 13193 } | 13187 } |
| 13194 | 13188 |
| 13195 | 13189 |
| 13196 // Find the effective prototype object as returned by __proto__. | 13190 // Find the effective prototype object as returned by __proto__. |
| 13197 // args[0]: the object to find the prototype for. | 13191 // args[0]: the object to find the prototype for. |
| 13198 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetPrototype) { | 13192 RUNTIME_FUNCTION(Runtime_DebugGetPrototype) { |
| 13199 HandleScope shs(isolate); | 13193 HandleScope shs(isolate); |
| 13200 ASSERT(args.length() == 1); | 13194 ASSERT(args.length() == 1); |
| 13201 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 13195 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
| 13202 return *GetPrototypeSkipHiddenPrototypes(isolate, obj); | 13196 return *GetPrototypeSkipHiddenPrototypes(isolate, obj); |
| 13203 } | 13197 } |
| 13204 | 13198 |
| 13205 | 13199 |
| 13206 // Patches script source (should be called upon BeforeCompile event). | 13200 // Patches script source (should be called upon BeforeCompile event). |
| 13207 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugSetScriptSource) { | 13201 RUNTIME_FUNCTION(Runtime_DebugSetScriptSource) { |
| 13208 HandleScope scope(isolate); | 13202 HandleScope scope(isolate); |
| 13209 ASSERT(args.length() == 2); | 13203 ASSERT(args.length() == 2); |
| 13210 | 13204 |
| 13211 CONVERT_ARG_HANDLE_CHECKED(JSValue, script_wrapper, 0); | 13205 CONVERT_ARG_HANDLE_CHECKED(JSValue, script_wrapper, 0); |
| 13212 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); | 13206 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); |
| 13213 | 13207 |
| 13214 RUNTIME_ASSERT(script_wrapper->value()->IsScript()); | 13208 RUNTIME_ASSERT(script_wrapper->value()->IsScript()); |
| 13215 Handle<Script> script(Script::cast(script_wrapper->value())); | 13209 Handle<Script> script(Script::cast(script_wrapper->value())); |
| 13216 | 13210 |
| 13217 int compilation_state = script->compilation_state(); | 13211 int compilation_state = script->compilation_state(); |
| 13218 RUNTIME_ASSERT(compilation_state == Script::COMPILATION_STATE_INITIAL); | 13212 RUNTIME_ASSERT(compilation_state == Script::COMPILATION_STATE_INITIAL); |
| 13219 script->set_source(*source); | 13213 script->set_source(*source); |
| 13220 | 13214 |
| 13221 return isolate->heap()->undefined_value(); | 13215 return isolate->heap()->undefined_value(); |
| 13222 } | 13216 } |
| 13223 | 13217 |
| 13224 | 13218 |
| 13225 RUNTIME_FUNCTION(MaybeObject*, Runtime_SystemBreak) { | 13219 RUNTIME_FUNCTION(Runtime_SystemBreak) { |
| 13226 SealHandleScope shs(isolate); | 13220 SealHandleScope shs(isolate); |
| 13227 ASSERT(args.length() == 0); | 13221 ASSERT(args.length() == 0); |
| 13228 OS::DebugBreak(); | 13222 OS::DebugBreak(); |
| 13229 return isolate->heap()->undefined_value(); | 13223 return isolate->heap()->undefined_value(); |
| 13230 } | 13224 } |
| 13231 | 13225 |
| 13232 | 13226 |
| 13233 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugDisassembleFunction) { | 13227 RUNTIME_FUNCTION(Runtime_DebugDisassembleFunction) { |
| 13234 HandleScope scope(isolate); | 13228 HandleScope scope(isolate); |
| 13235 #ifdef DEBUG | 13229 #ifdef DEBUG |
| 13236 ASSERT(args.length() == 1); | 13230 ASSERT(args.length() == 1); |
| 13237 // Get the function and make sure it is compiled. | 13231 // Get the function and make sure it is compiled. |
| 13238 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); | 13232 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); |
| 13239 if (!Compiler::EnsureCompiled(func, KEEP_EXCEPTION)) { | 13233 if (!Compiler::EnsureCompiled(func, KEEP_EXCEPTION)) { |
| 13240 return Failure::Exception(); | 13234 return isolate->heap()->exception(); |
| 13241 } | 13235 } |
| 13242 func->code()->PrintLn(); | 13236 func->code()->PrintLn(); |
| 13243 #endif // DEBUG | 13237 #endif // DEBUG |
| 13244 return isolate->heap()->undefined_value(); | 13238 return isolate->heap()->undefined_value(); |
| 13245 } | 13239 } |
| 13246 | 13240 |
| 13247 | 13241 |
| 13248 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugDisassembleConstructor) { | 13242 RUNTIME_FUNCTION(Runtime_DebugDisassembleConstructor) { |
| 13249 HandleScope scope(isolate); | 13243 HandleScope scope(isolate); |
| 13250 #ifdef DEBUG | 13244 #ifdef DEBUG |
| 13251 ASSERT(args.length() == 1); | 13245 ASSERT(args.length() == 1); |
| 13252 // Get the function and make sure it is compiled. | 13246 // Get the function and make sure it is compiled. |
| 13253 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); | 13247 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); |
| 13254 if (!Compiler::EnsureCompiled(func, KEEP_EXCEPTION)) { | 13248 if (!Compiler::EnsureCompiled(func, KEEP_EXCEPTION)) { |
| 13255 return Failure::Exception(); | 13249 return isolate->heap()->exception(); |
| 13256 } | 13250 } |
| 13257 func->shared()->construct_stub()->PrintLn(); | 13251 func->shared()->construct_stub()->PrintLn(); |
| 13258 #endif // DEBUG | 13252 #endif // DEBUG |
| 13259 return isolate->heap()->undefined_value(); | 13253 return isolate->heap()->undefined_value(); |
| 13260 } | 13254 } |
| 13261 | 13255 |
| 13262 | 13256 |
| 13263 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetInferredName) { | 13257 RUNTIME_FUNCTION(Runtime_FunctionGetInferredName) { |
| 13264 SealHandleScope shs(isolate); | 13258 SealHandleScope shs(isolate); |
| 13265 ASSERT(args.length() == 1); | 13259 ASSERT(args.length() == 1); |
| 13266 | 13260 |
| 13267 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 13261 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
| 13268 return f->shared()->inferred_name(); | 13262 return f->shared()->inferred_name(); |
| 13269 } | 13263 } |
| 13270 | 13264 |
| 13271 | 13265 |
| 13272 static int FindSharedFunctionInfosForScript(HeapIterator* iterator, | 13266 static int FindSharedFunctionInfosForScript(HeapIterator* iterator, |
| 13273 Script* script, | 13267 Script* script, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 13291 } | 13285 } |
| 13292 counter++; | 13286 counter++; |
| 13293 } | 13287 } |
| 13294 return counter; | 13288 return counter; |
| 13295 } | 13289 } |
| 13296 | 13290 |
| 13297 | 13291 |
| 13298 // For a script finds all SharedFunctionInfo's in the heap that points | 13292 // For a script finds all SharedFunctionInfo's in the heap that points |
| 13299 // to this script. Returns JSArray of SharedFunctionInfo wrapped | 13293 // to this script. Returns JSArray of SharedFunctionInfo wrapped |
| 13300 // in OpaqueReferences. | 13294 // in OpaqueReferences. |
| 13301 RUNTIME_FUNCTION(MaybeObject*, | 13295 RUNTIME_FUNCTION(Runtime_LiveEditFindSharedFunctionInfosForScript) { |
| 13302 Runtime_LiveEditFindSharedFunctionInfosForScript) { | |
| 13303 HandleScope scope(isolate); | 13296 HandleScope scope(isolate); |
| 13304 CHECK(isolate->debugger()->live_edit_enabled()); | 13297 CHECK(isolate->debugger()->live_edit_enabled()); |
| 13305 ASSERT(args.length() == 1); | 13298 ASSERT(args.length() == 1); |
| 13306 CONVERT_ARG_CHECKED(JSValue, script_value, 0); | 13299 CONVERT_ARG_CHECKED(JSValue, script_value, 0); |
| 13307 | 13300 |
| 13308 RUNTIME_ASSERT(script_value->value()->IsScript()); | 13301 RUNTIME_ASSERT(script_value->value()->IsScript()); |
| 13309 Handle<Script> script = Handle<Script>(Script::cast(script_value->value())); | 13302 Handle<Script> script = Handle<Script>(Script::cast(script_value->value())); |
| 13310 | 13303 |
| 13311 const int kBufferSize = 32; | 13304 const int kBufferSize = 32; |
| 13312 | 13305 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 13341 } | 13334 } |
| 13342 | 13335 |
| 13343 | 13336 |
| 13344 // For a script calculates compilation information about all its functions. | 13337 // For a script calculates compilation information about all its functions. |
| 13345 // The script source is explicitly specified by the second argument. | 13338 // The script source is explicitly specified by the second argument. |
| 13346 // The source of the actual script is not used, however it is important that | 13339 // The source of the actual script is not used, however it is important that |
| 13347 // all generated code keeps references to this particular instance of script. | 13340 // all generated code keeps references to this particular instance of script. |
| 13348 // Returns a JSArray of compilation infos. The array is ordered so that | 13341 // Returns a JSArray of compilation infos. The array is ordered so that |
| 13349 // each function with all its descendant is always stored in a continues range | 13342 // each function with all its descendant is always stored in a continues range |
| 13350 // with the function itself going first. The root function is a script function. | 13343 // with the function itself going first. The root function is a script function. |
| 13351 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditGatherCompileInfo) { | 13344 RUNTIME_FUNCTION(Runtime_LiveEditGatherCompileInfo) { |
| 13352 HandleScope scope(isolate); | 13345 HandleScope scope(isolate); |
| 13353 CHECK(isolate->debugger()->live_edit_enabled()); | 13346 CHECK(isolate->debugger()->live_edit_enabled()); |
| 13354 ASSERT(args.length() == 2); | 13347 ASSERT(args.length() == 2); |
| 13355 CONVERT_ARG_CHECKED(JSValue, script, 0); | 13348 CONVERT_ARG_CHECKED(JSValue, script, 0); |
| 13356 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); | 13349 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); |
| 13357 | 13350 |
| 13358 RUNTIME_ASSERT(script->value()->IsScript()); | 13351 RUNTIME_ASSERT(script->value()->IsScript()); |
| 13359 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); | 13352 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); |
| 13360 | 13353 |
| 13361 Handle<JSArray> result; | 13354 Handle<JSArray> result; |
| 13362 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 13355 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 13363 isolate, result, LiveEdit::GatherCompileInfo(script_handle, source)); | 13356 isolate, result, LiveEdit::GatherCompileInfo(script_handle, source)); |
| 13364 return *result; | 13357 return *result; |
| 13365 } | 13358 } |
| 13366 | 13359 |
| 13367 | 13360 |
| 13368 // Changes the source of the script to a new_source. | 13361 // Changes the source of the script to a new_source. |
| 13369 // If old_script_name is provided (i.e. is a String), also creates a copy of | 13362 // If old_script_name is provided (i.e. is a String), also creates a copy of |
| 13370 // the script with its original source and sends notification to debugger. | 13363 // the script with its original source and sends notification to debugger. |
| 13371 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditReplaceScript) { | 13364 RUNTIME_FUNCTION(Runtime_LiveEditReplaceScript) { |
| 13372 HandleScope scope(isolate); | 13365 HandleScope scope(isolate); |
| 13373 CHECK(isolate->debugger()->live_edit_enabled()); | 13366 CHECK(isolate->debugger()->live_edit_enabled()); |
| 13374 ASSERT(args.length() == 3); | 13367 ASSERT(args.length() == 3); |
| 13375 CONVERT_ARG_CHECKED(JSValue, original_script_value, 0); | 13368 CONVERT_ARG_CHECKED(JSValue, original_script_value, 0); |
| 13376 CONVERT_ARG_HANDLE_CHECKED(String, new_source, 1); | 13369 CONVERT_ARG_HANDLE_CHECKED(String, new_source, 1); |
| 13377 CONVERT_ARG_HANDLE_CHECKED(Object, old_script_name, 2); | 13370 CONVERT_ARG_HANDLE_CHECKED(Object, old_script_name, 2); |
| 13378 | 13371 |
| 13379 RUNTIME_ASSERT(original_script_value->value()->IsScript()); | 13372 RUNTIME_ASSERT(original_script_value->value()->IsScript()); |
| 13380 Handle<Script> original_script(Script::cast(original_script_value->value())); | 13373 Handle<Script> original_script(Script::cast(original_script_value->value())); |
| 13381 | 13374 |
| 13382 Handle<Object> old_script = LiveEdit::ChangeScriptSource( | 13375 Handle<Object> old_script = LiveEdit::ChangeScriptSource( |
| 13383 original_script, new_source, old_script_name); | 13376 original_script, new_source, old_script_name); |
| 13384 | 13377 |
| 13385 if (old_script->IsScript()) { | 13378 if (old_script->IsScript()) { |
| 13386 Handle<Script> script_handle = Handle<Script>::cast(old_script); | 13379 Handle<Script> script_handle = Handle<Script>::cast(old_script); |
| 13387 return *Script::GetWrapper(script_handle); | 13380 return *Script::GetWrapper(script_handle); |
| 13388 } else { | 13381 } else { |
| 13389 return isolate->heap()->null_value(); | 13382 return isolate->heap()->null_value(); |
| 13390 } | 13383 } |
| 13391 } | 13384 } |
| 13392 | 13385 |
| 13393 | 13386 |
| 13394 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditFunctionSourceUpdated) { | 13387 RUNTIME_FUNCTION(Runtime_LiveEditFunctionSourceUpdated) { |
| 13395 HandleScope scope(isolate); | 13388 HandleScope scope(isolate); |
| 13396 CHECK(isolate->debugger()->live_edit_enabled()); | 13389 CHECK(isolate->debugger()->live_edit_enabled()); |
| 13397 ASSERT(args.length() == 1); | 13390 ASSERT(args.length() == 1); |
| 13398 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_info, 0); | 13391 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_info, 0); |
| 13399 RUNTIME_ASSERT(SharedInfoWrapper::IsInstance(shared_info)); | 13392 RUNTIME_ASSERT(SharedInfoWrapper::IsInstance(shared_info)); |
| 13400 | 13393 |
| 13401 LiveEdit::FunctionSourceUpdated(shared_info); | 13394 LiveEdit::FunctionSourceUpdated(shared_info); |
| 13402 return isolate->heap()->undefined_value(); | 13395 return isolate->heap()->undefined_value(); |
| 13403 } | 13396 } |
| 13404 | 13397 |
| 13405 | 13398 |
| 13406 // Replaces code of SharedFunctionInfo with a new one. | 13399 // Replaces code of SharedFunctionInfo with a new one. |
| 13407 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditReplaceFunctionCode) { | 13400 RUNTIME_FUNCTION(Runtime_LiveEditReplaceFunctionCode) { |
| 13408 HandleScope scope(isolate); | 13401 HandleScope scope(isolate); |
| 13409 CHECK(isolate->debugger()->live_edit_enabled()); | 13402 CHECK(isolate->debugger()->live_edit_enabled()); |
| 13410 ASSERT(args.length() == 2); | 13403 ASSERT(args.length() == 2); |
| 13411 CONVERT_ARG_HANDLE_CHECKED(JSArray, new_compile_info, 0); | 13404 CONVERT_ARG_HANDLE_CHECKED(JSArray, new_compile_info, 0); |
| 13412 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_info, 1); | 13405 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_info, 1); |
| 13413 RUNTIME_ASSERT(SharedInfoWrapper::IsInstance(shared_info)); | 13406 RUNTIME_ASSERT(SharedInfoWrapper::IsInstance(shared_info)); |
| 13414 | 13407 |
| 13415 LiveEdit::ReplaceFunctionCode(new_compile_info, shared_info); | 13408 LiveEdit::ReplaceFunctionCode(new_compile_info, shared_info); |
| 13416 return isolate->heap()->undefined_value(); | 13409 return isolate->heap()->undefined_value(); |
| 13417 } | 13410 } |
| 13418 | 13411 |
| 13419 | 13412 |
| 13420 // Connects SharedFunctionInfo to another script. | 13413 // Connects SharedFunctionInfo to another script. |
| 13421 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditFunctionSetScript) { | 13414 RUNTIME_FUNCTION(Runtime_LiveEditFunctionSetScript) { |
| 13422 HandleScope scope(isolate); | 13415 HandleScope scope(isolate); |
| 13423 CHECK(isolate->debugger()->live_edit_enabled()); | 13416 CHECK(isolate->debugger()->live_edit_enabled()); |
| 13424 ASSERT(args.length() == 2); | 13417 ASSERT(args.length() == 2); |
| 13425 CONVERT_ARG_HANDLE_CHECKED(Object, function_object, 0); | 13418 CONVERT_ARG_HANDLE_CHECKED(Object, function_object, 0); |
| 13426 CONVERT_ARG_HANDLE_CHECKED(Object, script_object, 1); | 13419 CONVERT_ARG_HANDLE_CHECKED(Object, script_object, 1); |
| 13427 | 13420 |
| 13428 if (function_object->IsJSValue()) { | 13421 if (function_object->IsJSValue()) { |
| 13429 Handle<JSValue> function_wrapper = Handle<JSValue>::cast(function_object); | 13422 Handle<JSValue> function_wrapper = Handle<JSValue>::cast(function_object); |
| 13430 if (script_object->IsJSValue()) { | 13423 if (script_object->IsJSValue()) { |
| 13431 RUNTIME_ASSERT(JSValue::cast(*script_object)->value()->IsScript()); | 13424 RUNTIME_ASSERT(JSValue::cast(*script_object)->value()->IsScript()); |
| 13432 Script* script = Script::cast(JSValue::cast(*script_object)->value()); | 13425 Script* script = Script::cast(JSValue::cast(*script_object)->value()); |
| 13433 script_object = Handle<Object>(script, isolate); | 13426 script_object = Handle<Object>(script, isolate); |
| 13434 } | 13427 } |
| 13435 | 13428 |
| 13436 LiveEdit::SetFunctionScript(function_wrapper, script_object); | 13429 LiveEdit::SetFunctionScript(function_wrapper, script_object); |
| 13437 } else { | 13430 } else { |
| 13438 // Just ignore this. We may not have a SharedFunctionInfo for some functions | 13431 // Just ignore this. We may not have a SharedFunctionInfo for some functions |
| 13439 // and we check it in this function. | 13432 // and we check it in this function. |
| 13440 } | 13433 } |
| 13441 | 13434 |
| 13442 return isolate->heap()->undefined_value(); | 13435 return isolate->heap()->undefined_value(); |
| 13443 } | 13436 } |
| 13444 | 13437 |
| 13445 | 13438 |
| 13446 // In a code of a parent function replaces original function as embedded object | 13439 // In a code of a parent function replaces original function as embedded object |
| 13447 // with a substitution one. | 13440 // with a substitution one. |
| 13448 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditReplaceRefToNestedFunction) { | 13441 RUNTIME_FUNCTION(Runtime_LiveEditReplaceRefToNestedFunction) { |
| 13449 HandleScope scope(isolate); | 13442 HandleScope scope(isolate); |
| 13450 CHECK(isolate->debugger()->live_edit_enabled()); | 13443 CHECK(isolate->debugger()->live_edit_enabled()); |
| 13451 ASSERT(args.length() == 3); | 13444 ASSERT(args.length() == 3); |
| 13452 | 13445 |
| 13453 CONVERT_ARG_HANDLE_CHECKED(JSValue, parent_wrapper, 0); | 13446 CONVERT_ARG_HANDLE_CHECKED(JSValue, parent_wrapper, 0); |
| 13454 CONVERT_ARG_HANDLE_CHECKED(JSValue, orig_wrapper, 1); | 13447 CONVERT_ARG_HANDLE_CHECKED(JSValue, orig_wrapper, 1); |
| 13455 CONVERT_ARG_HANDLE_CHECKED(JSValue, subst_wrapper, 2); | 13448 CONVERT_ARG_HANDLE_CHECKED(JSValue, subst_wrapper, 2); |
| 13456 | 13449 |
| 13457 LiveEdit::ReplaceRefToNestedFunction( | 13450 LiveEdit::ReplaceRefToNestedFunction( |
| 13458 parent_wrapper, orig_wrapper, subst_wrapper); | 13451 parent_wrapper, orig_wrapper, subst_wrapper); |
| 13459 return isolate->heap()->undefined_value(); | 13452 return isolate->heap()->undefined_value(); |
| 13460 } | 13453 } |
| 13461 | 13454 |
| 13462 | 13455 |
| 13463 // Updates positions of a shared function info (first parameter) according | 13456 // Updates positions of a shared function info (first parameter) according |
| 13464 // to script source change. Text change is described in second parameter as | 13457 // to script source change. Text change is described in second parameter as |
| 13465 // array of groups of 3 numbers: | 13458 // array of groups of 3 numbers: |
| 13466 // (change_begin, change_end, change_end_new_position). | 13459 // (change_begin, change_end, change_end_new_position). |
| 13467 // Each group describes a change in text; groups are sorted by change_begin. | 13460 // Each group describes a change in text; groups are sorted by change_begin. |
| 13468 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditPatchFunctionPositions) { | 13461 RUNTIME_FUNCTION(Runtime_LiveEditPatchFunctionPositions) { |
| 13469 HandleScope scope(isolate); | 13462 HandleScope scope(isolate); |
| 13470 CHECK(isolate->debugger()->live_edit_enabled()); | 13463 CHECK(isolate->debugger()->live_edit_enabled()); |
| 13471 ASSERT(args.length() == 2); | 13464 ASSERT(args.length() == 2); |
| 13472 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_array, 0); | 13465 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_array, 0); |
| 13473 CONVERT_ARG_HANDLE_CHECKED(JSArray, position_change_array, 1); | 13466 CONVERT_ARG_HANDLE_CHECKED(JSArray, position_change_array, 1); |
| 13474 RUNTIME_ASSERT(SharedInfoWrapper::IsInstance(shared_array)) | 13467 RUNTIME_ASSERT(SharedInfoWrapper::IsInstance(shared_array)) |
| 13475 | 13468 |
| 13476 LiveEdit::PatchFunctionPositions(shared_array, position_change_array); | 13469 LiveEdit::PatchFunctionPositions(shared_array, position_change_array); |
| 13477 return isolate->heap()->undefined_value(); | 13470 return isolate->heap()->undefined_value(); |
| 13478 } | 13471 } |
| 13479 | 13472 |
| 13480 | 13473 |
| 13481 // For array of SharedFunctionInfo's (each wrapped in JSValue) | 13474 // For array of SharedFunctionInfo's (each wrapped in JSValue) |
| 13482 // checks that none of them have activations on stacks (of any thread). | 13475 // checks that none of them have activations on stacks (of any thread). |
| 13483 // Returns array of the same length with corresponding results of | 13476 // Returns array of the same length with corresponding results of |
| 13484 // LiveEdit::FunctionPatchabilityStatus type. | 13477 // LiveEdit::FunctionPatchabilityStatus type. |
| 13485 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCheckAndDropActivations) { | 13478 RUNTIME_FUNCTION(Runtime_LiveEditCheckAndDropActivations) { |
| 13486 HandleScope scope(isolate); | 13479 HandleScope scope(isolate); |
| 13487 CHECK(isolate->debugger()->live_edit_enabled()); | 13480 CHECK(isolate->debugger()->live_edit_enabled()); |
| 13488 ASSERT(args.length() == 2); | 13481 ASSERT(args.length() == 2); |
| 13489 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_array, 0); | 13482 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_array, 0); |
| 13490 CONVERT_BOOLEAN_ARG_CHECKED(do_drop, 1); | 13483 CONVERT_BOOLEAN_ARG_CHECKED(do_drop, 1); |
| 13491 | 13484 |
| 13492 return *LiveEdit::CheckAndDropActivations(shared_array, do_drop); | 13485 return *LiveEdit::CheckAndDropActivations(shared_array, do_drop); |
| 13493 } | 13486 } |
| 13494 | 13487 |
| 13495 | 13488 |
| 13496 // Compares 2 strings line-by-line, then token-wise and returns diff in form | 13489 // Compares 2 strings line-by-line, then token-wise and returns diff in form |
| 13497 // of JSArray of triplets (pos1, pos1_end, pos2_end) describing list | 13490 // of JSArray of triplets (pos1, pos1_end, pos2_end) describing list |
| 13498 // of diff chunks. | 13491 // of diff chunks. |
| 13499 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCompareStrings) { | 13492 RUNTIME_FUNCTION(Runtime_LiveEditCompareStrings) { |
| 13500 HandleScope scope(isolate); | 13493 HandleScope scope(isolate); |
| 13501 CHECK(isolate->debugger()->live_edit_enabled()); | 13494 CHECK(isolate->debugger()->live_edit_enabled()); |
| 13502 ASSERT(args.length() == 2); | 13495 ASSERT(args.length() == 2); |
| 13503 CONVERT_ARG_HANDLE_CHECKED(String, s1, 0); | 13496 CONVERT_ARG_HANDLE_CHECKED(String, s1, 0); |
| 13504 CONVERT_ARG_HANDLE_CHECKED(String, s2, 1); | 13497 CONVERT_ARG_HANDLE_CHECKED(String, s2, 1); |
| 13505 | 13498 |
| 13506 return *LiveEdit::CompareStrings(s1, s2); | 13499 return *LiveEdit::CompareStrings(s1, s2); |
| 13507 } | 13500 } |
| 13508 | 13501 |
| 13509 | 13502 |
| 13510 // Restarts a call frame and completely drops all frames above. | 13503 // Restarts a call frame and completely drops all frames above. |
| 13511 // Returns true if successful. Otherwise returns undefined or an error message. | 13504 // Returns true if successful. Otherwise returns undefined or an error message. |
| 13512 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditRestartFrame) { | 13505 RUNTIME_FUNCTION(Runtime_LiveEditRestartFrame) { |
| 13513 HandleScope scope(isolate); | 13506 HandleScope scope(isolate); |
| 13514 CHECK(isolate->debugger()->live_edit_enabled()); | 13507 CHECK(isolate->debugger()->live_edit_enabled()); |
| 13515 ASSERT(args.length() == 2); | 13508 ASSERT(args.length() == 2); |
| 13516 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 13509 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
| 13517 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 13510 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
| 13518 | 13511 |
| 13519 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); | 13512 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); |
| 13520 Heap* heap = isolate->heap(); | 13513 Heap* heap = isolate->heap(); |
| 13521 | 13514 |
| 13522 // Find the relevant frame with the requested index. | 13515 // Find the relevant frame with the requested index. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 13537 const char* error_message = LiveEdit::RestartFrame(it.frame()); | 13530 const char* error_message = LiveEdit::RestartFrame(it.frame()); |
| 13538 if (error_message) { | 13531 if (error_message) { |
| 13539 return *(isolate->factory()->InternalizeUtf8String(error_message)); | 13532 return *(isolate->factory()->InternalizeUtf8String(error_message)); |
| 13540 } | 13533 } |
| 13541 return heap->true_value(); | 13534 return heap->true_value(); |
| 13542 } | 13535 } |
| 13543 | 13536 |
| 13544 | 13537 |
| 13545 // A testing entry. Returns statement position which is the closest to | 13538 // A testing entry. Returns statement position which is the closest to |
| 13546 // source_position. | 13539 // source_position. |
| 13547 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFunctionCodePositionFromSource) { | 13540 RUNTIME_FUNCTION(Runtime_GetFunctionCodePositionFromSource) { |
| 13548 HandleScope scope(isolate); | 13541 HandleScope scope(isolate); |
| 13549 CHECK(isolate->debugger()->live_edit_enabled()); | 13542 CHECK(isolate->debugger()->live_edit_enabled()); |
| 13550 ASSERT(args.length() == 2); | 13543 ASSERT(args.length() == 2); |
| 13551 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 13544 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 13552 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); | 13545 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); |
| 13553 | 13546 |
| 13554 Handle<Code> code(function->code(), isolate); | 13547 Handle<Code> code(function->code(), isolate); |
| 13555 | 13548 |
| 13556 if (code->kind() != Code::FUNCTION && | 13549 if (code->kind() != Code::FUNCTION && |
| 13557 code->kind() != Code::OPTIMIZED_FUNCTION) { | 13550 code->kind() != Code::OPTIMIZED_FUNCTION) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 13575 it.next(); | 13568 it.next(); |
| 13576 } | 13569 } |
| 13577 | 13570 |
| 13578 return Smi::FromInt(closest_pc); | 13571 return Smi::FromInt(closest_pc); |
| 13579 } | 13572 } |
| 13580 | 13573 |
| 13581 | 13574 |
| 13582 // Calls specified function with or without entering the debugger. | 13575 // Calls specified function with or without entering the debugger. |
| 13583 // This is used in unit tests to run code as if debugger is entered or simply | 13576 // This is used in unit tests to run code as if debugger is entered or simply |
| 13584 // to have a stack with C++ frame in the middle. | 13577 // to have a stack with C++ frame in the middle. |
| 13585 RUNTIME_FUNCTION(MaybeObject*, Runtime_ExecuteInDebugContext) { | 13578 RUNTIME_FUNCTION(Runtime_ExecuteInDebugContext) { |
| 13586 HandleScope scope(isolate); | 13579 HandleScope scope(isolate); |
| 13587 ASSERT(args.length() == 2); | 13580 ASSERT(args.length() == 2); |
| 13588 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 13581 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 13589 CONVERT_BOOLEAN_ARG_CHECKED(without_debugger, 1); | 13582 CONVERT_BOOLEAN_ARG_CHECKED(without_debugger, 1); |
| 13590 | 13583 |
| 13591 MaybeHandle<Object> maybe_result; | 13584 MaybeHandle<Object> maybe_result; |
| 13592 if (without_debugger) { | 13585 if (without_debugger) { |
| 13593 maybe_result = Execution::Call(isolate, | 13586 maybe_result = Execution::Call(isolate, |
| 13594 function, | 13587 function, |
| 13595 isolate->global_object(), | 13588 isolate->global_object(), |
| 13596 0, | 13589 0, |
| 13597 NULL); | 13590 NULL); |
| 13598 } else { | 13591 } else { |
| 13599 EnterDebugger enter_debugger(isolate); | 13592 EnterDebugger enter_debugger(isolate); |
| 13600 maybe_result = Execution::Call(isolate, | 13593 maybe_result = Execution::Call(isolate, |
| 13601 function, | 13594 function, |
| 13602 isolate->global_object(), | 13595 isolate->global_object(), |
| 13603 0, | 13596 0, |
| 13604 NULL); | 13597 NULL); |
| 13605 } | 13598 } |
| 13606 Handle<Object> result; | 13599 Handle<Object> result; |
| 13607 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, maybe_result); | 13600 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, maybe_result); |
| 13608 return *result; | 13601 return *result; |
| 13609 } | 13602 } |
| 13610 | 13603 |
| 13611 | 13604 |
| 13612 // Sets a v8 flag. | 13605 // Sets a v8 flag. |
| 13613 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetFlags) { | 13606 RUNTIME_FUNCTION(Runtime_SetFlags) { |
| 13614 SealHandleScope shs(isolate); | 13607 SealHandleScope shs(isolate); |
| 13615 ASSERT(args.length() == 1); | 13608 ASSERT(args.length() == 1); |
| 13616 CONVERT_ARG_CHECKED(String, arg, 0); | 13609 CONVERT_ARG_CHECKED(String, arg, 0); |
| 13617 SmartArrayPointer<char> flags = | 13610 SmartArrayPointer<char> flags = |
| 13618 arg->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 13611 arg->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
| 13619 FlagList::SetFlagsFromString(flags.get(), StrLength(flags.get())); | 13612 FlagList::SetFlagsFromString(flags.get(), StrLength(flags.get())); |
| 13620 return isolate->heap()->undefined_value(); | 13613 return isolate->heap()->undefined_value(); |
| 13621 } | 13614 } |
| 13622 | 13615 |
| 13623 | 13616 |
| 13624 // Performs a GC. | 13617 // Performs a GC. |
| 13625 // Presently, it only does a full GC. | 13618 // Presently, it only does a full GC. |
| 13626 RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectGarbage) { | 13619 RUNTIME_FUNCTION(Runtime_CollectGarbage) { |
| 13627 SealHandleScope shs(isolate); | 13620 SealHandleScope shs(isolate); |
| 13628 ASSERT(args.length() == 1); | 13621 ASSERT(args.length() == 1); |
| 13629 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, "%CollectGarbage"); | 13622 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, "%CollectGarbage"); |
| 13630 return isolate->heap()->undefined_value(); | 13623 return isolate->heap()->undefined_value(); |
| 13631 } | 13624 } |
| 13632 | 13625 |
| 13633 | 13626 |
| 13634 // Gets the current heap usage. | 13627 // Gets the current heap usage. |
| 13635 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetHeapUsage) { | 13628 RUNTIME_FUNCTION(Runtime_GetHeapUsage) { |
| 13636 SealHandleScope shs(isolate); | 13629 SealHandleScope shs(isolate); |
| 13637 ASSERT(args.length() == 0); | 13630 ASSERT(args.length() == 0); |
| 13638 int usage = static_cast<int>(isolate->heap()->SizeOfObjects()); | 13631 int usage = static_cast<int>(isolate->heap()->SizeOfObjects()); |
| 13639 if (!Smi::IsValid(usage)) { | 13632 if (!Smi::IsValid(usage)) { |
| 13640 return *isolate->factory()->NewNumberFromInt(usage); | 13633 return *isolate->factory()->NewNumberFromInt(usage); |
| 13641 } | 13634 } |
| 13642 return Smi::FromInt(usage); | 13635 return Smi::FromInt(usage); |
| 13643 } | 13636 } |
| 13644 | 13637 |
| 13645 #endif // ENABLE_DEBUGGER_SUPPORT | 13638 #endif // ENABLE_DEBUGGER_SUPPORT |
| 13646 | 13639 |
| 13647 | 13640 |
| 13648 #ifdef V8_I18N_SUPPORT | 13641 #ifdef V8_I18N_SUPPORT |
| 13649 RUNTIME_FUNCTION(MaybeObject*, Runtime_CanonicalizeLanguageTag) { | 13642 RUNTIME_FUNCTION(Runtime_CanonicalizeLanguageTag) { |
| 13650 HandleScope scope(isolate); | 13643 HandleScope scope(isolate); |
| 13651 Factory* factory = isolate->factory(); | 13644 Factory* factory = isolate->factory(); |
| 13652 | 13645 |
| 13653 ASSERT(args.length() == 1); | 13646 ASSERT(args.length() == 1); |
| 13654 CONVERT_ARG_HANDLE_CHECKED(String, locale_id_str, 0); | 13647 CONVERT_ARG_HANDLE_CHECKED(String, locale_id_str, 0); |
| 13655 | 13648 |
| 13656 v8::String::Utf8Value locale_id(v8::Utils::ToLocal(locale_id_str)); | 13649 v8::String::Utf8Value locale_id(v8::Utils::ToLocal(locale_id_str)); |
| 13657 | 13650 |
| 13658 // Return value which denotes invalid language tag. | 13651 // Return value which denotes invalid language tag. |
| 13659 const char* const kInvalidTag = "invalid-tag"; | 13652 const char* const kInvalidTag = "invalid-tag"; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 13674 uloc_toLanguageTag(icu_result, result, ULOC_FULLNAME_CAPACITY, TRUE, &error); | 13667 uloc_toLanguageTag(icu_result, result, ULOC_FULLNAME_CAPACITY, TRUE, &error); |
| 13675 | 13668 |
| 13676 if (U_FAILURE(error)) { | 13669 if (U_FAILURE(error)) { |
| 13677 return *factory->NewStringFromAsciiChecked(kInvalidTag); | 13670 return *factory->NewStringFromAsciiChecked(kInvalidTag); |
| 13678 } | 13671 } |
| 13679 | 13672 |
| 13680 return *factory->NewStringFromAsciiChecked(result); | 13673 return *factory->NewStringFromAsciiChecked(result); |
| 13681 } | 13674 } |
| 13682 | 13675 |
| 13683 | 13676 |
| 13684 RUNTIME_FUNCTION(MaybeObject*, Runtime_AvailableLocalesOf) { | 13677 RUNTIME_FUNCTION(Runtime_AvailableLocalesOf) { |
| 13685 HandleScope scope(isolate); | 13678 HandleScope scope(isolate); |
| 13686 Factory* factory = isolate->factory(); | 13679 Factory* factory = isolate->factory(); |
| 13687 | 13680 |
| 13688 ASSERT(args.length() == 1); | 13681 ASSERT(args.length() == 1); |
| 13689 CONVERT_ARG_HANDLE_CHECKED(String, service, 0); | 13682 CONVERT_ARG_HANDLE_CHECKED(String, service, 0); |
| 13690 | 13683 |
| 13691 const icu::Locale* available_locales = NULL; | 13684 const icu::Locale* available_locales = NULL; |
| 13692 int32_t count = 0; | 13685 int32_t count = 0; |
| 13693 | 13686 |
| 13694 if (service->IsUtf8EqualTo(CStrVector("collator"))) { | 13687 if (service->IsUtf8EqualTo(CStrVector("collator"))) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 13722 locales, | 13715 locales, |
| 13723 factory->NewStringFromAsciiChecked(result), | 13716 factory->NewStringFromAsciiChecked(result), |
| 13724 factory->NewNumber(i), | 13717 factory->NewNumber(i), |
| 13725 NONE)); | 13718 NONE)); |
| 13726 } | 13719 } |
| 13727 | 13720 |
| 13728 return *locales; | 13721 return *locales; |
| 13729 } | 13722 } |
| 13730 | 13723 |
| 13731 | 13724 |
| 13732 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDefaultICULocale) { | 13725 RUNTIME_FUNCTION(Runtime_GetDefaultICULocale) { |
| 13733 HandleScope scope(isolate); | 13726 HandleScope scope(isolate); |
| 13734 Factory* factory = isolate->factory(); | 13727 Factory* factory = isolate->factory(); |
| 13735 | 13728 |
| 13736 ASSERT(args.length() == 0); | 13729 ASSERT(args.length() == 0); |
| 13737 | 13730 |
| 13738 icu::Locale default_locale; | 13731 icu::Locale default_locale; |
| 13739 | 13732 |
| 13740 // Set the locale | 13733 // Set the locale |
| 13741 char result[ULOC_FULLNAME_CAPACITY]; | 13734 char result[ULOC_FULLNAME_CAPACITY]; |
| 13742 UErrorCode status = U_ZERO_ERROR; | 13735 UErrorCode status = U_ZERO_ERROR; |
| 13743 uloc_toLanguageTag( | 13736 uloc_toLanguageTag( |
| 13744 default_locale.getName(), result, ULOC_FULLNAME_CAPACITY, FALSE, &status); | 13737 default_locale.getName(), result, ULOC_FULLNAME_CAPACITY, FALSE, &status); |
| 13745 if (U_SUCCESS(status)) { | 13738 if (U_SUCCESS(status)) { |
| 13746 return *factory->NewStringFromAsciiChecked(result); | 13739 return *factory->NewStringFromAsciiChecked(result); |
| 13747 } | 13740 } |
| 13748 | 13741 |
| 13749 return *factory->NewStringFromStaticAscii("und"); | 13742 return *factory->NewStringFromStaticAscii("und"); |
| 13750 } | 13743 } |
| 13751 | 13744 |
| 13752 | 13745 |
| 13753 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLanguageTagVariants) { | 13746 RUNTIME_FUNCTION(Runtime_GetLanguageTagVariants) { |
| 13754 HandleScope scope(isolate); | 13747 HandleScope scope(isolate); |
| 13755 Factory* factory = isolate->factory(); | 13748 Factory* factory = isolate->factory(); |
| 13756 | 13749 |
| 13757 ASSERT(args.length() == 1); | 13750 ASSERT(args.length() == 1); |
| 13758 | 13751 |
| 13759 CONVERT_ARG_HANDLE_CHECKED(JSArray, input, 0); | 13752 CONVERT_ARG_HANDLE_CHECKED(JSArray, input, 0); |
| 13760 | 13753 |
| 13761 uint32_t length = static_cast<uint32_t>(input->length()->Number()); | 13754 uint32_t length = static_cast<uint32_t>(input->length()->Number()); |
| 13762 Handle<FixedArray> output = factory->NewFixedArray(length); | 13755 Handle<FixedArray> output = factory->NewFixedArray(length); |
| 13763 Handle<Name> maximized = factory->NewStringFromStaticAscii("maximized"); | 13756 Handle<Name> maximized = factory->NewStringFromStaticAscii("maximized"); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13833 NONE)); | 13826 NONE)); |
| 13834 output->set(i, *result); | 13827 output->set(i, *result); |
| 13835 } | 13828 } |
| 13836 | 13829 |
| 13837 Handle<JSArray> result = factory->NewJSArrayWithElements(output); | 13830 Handle<JSArray> result = factory->NewJSArrayWithElements(output); |
| 13838 result->set_length(Smi::FromInt(length)); | 13831 result->set_length(Smi::FromInt(length)); |
| 13839 return *result; | 13832 return *result; |
| 13840 } | 13833 } |
| 13841 | 13834 |
| 13842 | 13835 |
| 13843 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsInitializedIntlObject) { | 13836 RUNTIME_FUNCTION(Runtime_IsInitializedIntlObject) { |
| 13844 HandleScope scope(isolate); | 13837 HandleScope scope(isolate); |
| 13845 | 13838 |
| 13846 ASSERT(args.length() == 1); | 13839 ASSERT(args.length() == 1); |
| 13847 | 13840 |
| 13848 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); | 13841 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); |
| 13849 | 13842 |
| 13850 if (!input->IsJSObject()) return isolate->heap()->false_value(); | 13843 if (!input->IsJSObject()) return isolate->heap()->false_value(); |
| 13851 Handle<JSObject> obj = Handle<JSObject>::cast(input); | 13844 Handle<JSObject> obj = Handle<JSObject>::cast(input); |
| 13852 | 13845 |
| 13853 Handle<String> marker = isolate->factory()->intl_initialized_marker_string(); | 13846 Handle<String> marker = isolate->factory()->intl_initialized_marker_string(); |
| 13854 Handle<Object> tag(obj->GetHiddenProperty(*marker), isolate); | 13847 Handle<Object> tag(obj->GetHiddenProperty(*marker), isolate); |
| 13855 return isolate->heap()->ToBoolean(!tag->IsTheHole()); | 13848 return isolate->heap()->ToBoolean(!tag->IsTheHole()); |
| 13856 } | 13849 } |
| 13857 | 13850 |
| 13858 | 13851 |
| 13859 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsInitializedIntlObjectOfType) { | 13852 RUNTIME_FUNCTION(Runtime_IsInitializedIntlObjectOfType) { |
| 13860 HandleScope scope(isolate); | 13853 HandleScope scope(isolate); |
| 13861 | 13854 |
| 13862 ASSERT(args.length() == 2); | 13855 ASSERT(args.length() == 2); |
| 13863 | 13856 |
| 13864 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); | 13857 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); |
| 13865 CONVERT_ARG_HANDLE_CHECKED(String, expected_type, 1); | 13858 CONVERT_ARG_HANDLE_CHECKED(String, expected_type, 1); |
| 13866 | 13859 |
| 13867 if (!input->IsJSObject()) return isolate->heap()->false_value(); | 13860 if (!input->IsJSObject()) return isolate->heap()->false_value(); |
| 13868 Handle<JSObject> obj = Handle<JSObject>::cast(input); | 13861 Handle<JSObject> obj = Handle<JSObject>::cast(input); |
| 13869 | 13862 |
| 13870 Handle<String> marker = isolate->factory()->intl_initialized_marker_string(); | 13863 Handle<String> marker = isolate->factory()->intl_initialized_marker_string(); |
| 13871 Handle<Object> tag(obj->GetHiddenProperty(*marker), isolate); | 13864 Handle<Object> tag(obj->GetHiddenProperty(*marker), isolate); |
| 13872 return isolate->heap()->ToBoolean( | 13865 return isolate->heap()->ToBoolean( |
| 13873 tag->IsString() && String::cast(*tag)->Equals(*expected_type)); | 13866 tag->IsString() && String::cast(*tag)->Equals(*expected_type)); |
| 13874 } | 13867 } |
| 13875 | 13868 |
| 13876 | 13869 |
| 13877 RUNTIME_FUNCTION(MaybeObject*, Runtime_MarkAsInitializedIntlObjectOfType) { | 13870 RUNTIME_FUNCTION(Runtime_MarkAsInitializedIntlObjectOfType) { |
| 13878 HandleScope scope(isolate); | 13871 HandleScope scope(isolate); |
| 13879 | 13872 |
| 13880 ASSERT(args.length() == 3); | 13873 ASSERT(args.length() == 3); |
| 13881 | 13874 |
| 13882 CONVERT_ARG_HANDLE_CHECKED(JSObject, input, 0); | 13875 CONVERT_ARG_HANDLE_CHECKED(JSObject, input, 0); |
| 13883 CONVERT_ARG_HANDLE_CHECKED(String, type, 1); | 13876 CONVERT_ARG_HANDLE_CHECKED(String, type, 1); |
| 13884 CONVERT_ARG_HANDLE_CHECKED(JSObject, impl, 2); | 13877 CONVERT_ARG_HANDLE_CHECKED(JSObject, impl, 2); |
| 13885 | 13878 |
| 13886 Handle<String> marker = isolate->factory()->intl_initialized_marker_string(); | 13879 Handle<String> marker = isolate->factory()->intl_initialized_marker_string(); |
| 13887 JSObject::SetHiddenProperty(input, marker, type); | 13880 JSObject::SetHiddenProperty(input, marker, type); |
| 13888 | 13881 |
| 13889 marker = isolate->factory()->intl_impl_object_string(); | 13882 marker = isolate->factory()->intl_impl_object_string(); |
| 13890 JSObject::SetHiddenProperty(input, marker, impl); | 13883 JSObject::SetHiddenProperty(input, marker, impl); |
| 13891 | 13884 |
| 13892 return isolate->heap()->undefined_value(); | 13885 return isolate->heap()->undefined_value(); |
| 13893 } | 13886 } |
| 13894 | 13887 |
| 13895 | 13888 |
| 13896 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetImplFromInitializedIntlObject) { | 13889 RUNTIME_FUNCTION(Runtime_GetImplFromInitializedIntlObject) { |
| 13897 HandleScope scope(isolate); | 13890 HandleScope scope(isolate); |
| 13898 | 13891 |
| 13899 ASSERT(args.length() == 1); | 13892 ASSERT(args.length() == 1); |
| 13900 | 13893 |
| 13901 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); | 13894 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); |
| 13902 | 13895 |
| 13903 if (!input->IsJSObject()) { | 13896 if (!input->IsJSObject()) { |
| 13904 Vector< Handle<Object> > arguments = HandleVector(&input, 1); | 13897 Vector< Handle<Object> > arguments = HandleVector(&input, 1); |
| 13905 Handle<Object> type_error = | 13898 Handle<Object> type_error = |
| 13906 isolate->factory()->NewTypeError("not_intl_object", arguments); | 13899 isolate->factory()->NewTypeError("not_intl_object", arguments); |
| 13907 return isolate->Throw(*type_error); | 13900 return isolate->Throw(*type_error); |
| 13908 } | 13901 } |
| 13909 | 13902 |
| 13910 Handle<JSObject> obj = Handle<JSObject>::cast(input); | 13903 Handle<JSObject> obj = Handle<JSObject>::cast(input); |
| 13911 | 13904 |
| 13912 Handle<String> marker = isolate->factory()->intl_impl_object_string(); | 13905 Handle<String> marker = isolate->factory()->intl_impl_object_string(); |
| 13913 Handle<Object> impl(obj->GetHiddenProperty(*marker), isolate); | 13906 Handle<Object> impl(obj->GetHiddenProperty(*marker), isolate); |
| 13914 if (impl->IsTheHole()) { | 13907 if (impl->IsTheHole()) { |
| 13915 Vector< Handle<Object> > arguments = HandleVector(&obj, 1); | 13908 Vector< Handle<Object> > arguments = HandleVector(&obj, 1); |
| 13916 Handle<Object> type_error = | 13909 Handle<Object> type_error = |
| 13917 isolate->factory()->NewTypeError("not_intl_object", arguments); | 13910 isolate->factory()->NewTypeError("not_intl_object", arguments); |
| 13918 return isolate->Throw(*type_error); | 13911 return isolate->Throw(*type_error); |
| 13919 } | 13912 } |
| 13920 return *impl; | 13913 return *impl; |
| 13921 } | 13914 } |
| 13922 | 13915 |
| 13923 | 13916 |
| 13924 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateDateTimeFormat) { | 13917 RUNTIME_FUNCTION(Runtime_CreateDateTimeFormat) { |
| 13925 HandleScope scope(isolate); | 13918 HandleScope scope(isolate); |
| 13926 | 13919 |
| 13927 ASSERT(args.length() == 3); | 13920 ASSERT(args.length() == 3); |
| 13928 | 13921 |
| 13929 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); | 13922 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); |
| 13930 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); | 13923 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); |
| 13931 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); | 13924 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); |
| 13932 | 13925 |
| 13933 Handle<ObjectTemplateInfo> date_format_template = | 13926 Handle<ObjectTemplateInfo> date_format_template = |
| 13934 I18N::GetTemplate(isolate); | 13927 I18N::GetTemplate(isolate); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 13956 | 13949 |
| 13957 // Make object handle weak so we can delete the data format once GC kicks in. | 13950 // Make object handle weak so we can delete the data format once GC kicks in. |
| 13958 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); | 13951 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); |
| 13959 GlobalHandles::MakeWeak(wrapper.location(), | 13952 GlobalHandles::MakeWeak(wrapper.location(), |
| 13960 reinterpret_cast<void*>(wrapper.location()), | 13953 reinterpret_cast<void*>(wrapper.location()), |
| 13961 DateFormat::DeleteDateFormat); | 13954 DateFormat::DeleteDateFormat); |
| 13962 return *local_object; | 13955 return *local_object; |
| 13963 } | 13956 } |
| 13964 | 13957 |
| 13965 | 13958 |
| 13966 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalDateFormat) { | 13959 RUNTIME_FUNCTION(Runtime_InternalDateFormat) { |
| 13967 HandleScope scope(isolate); | 13960 HandleScope scope(isolate); |
| 13968 | 13961 |
| 13969 ASSERT(args.length() == 2); | 13962 ASSERT(args.length() == 2); |
| 13970 | 13963 |
| 13971 CONVERT_ARG_HANDLE_CHECKED(JSObject, date_format_holder, 0); | 13964 CONVERT_ARG_HANDLE_CHECKED(JSObject, date_format_holder, 0); |
| 13972 CONVERT_ARG_HANDLE_CHECKED(JSDate, date, 1); | 13965 CONVERT_ARG_HANDLE_CHECKED(JSDate, date, 1); |
| 13973 | 13966 |
| 13974 Handle<Object> value; | 13967 Handle<Object> value; |
| 13975 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 13968 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 13976 isolate, value, Execution::ToNumber(isolate, date)); | 13969 isolate, value, Execution::ToNumber(isolate, date)); |
| 13977 | 13970 |
| 13978 icu::SimpleDateFormat* date_format = | 13971 icu::SimpleDateFormat* date_format = |
| 13979 DateFormat::UnpackDateFormat(isolate, date_format_holder); | 13972 DateFormat::UnpackDateFormat(isolate, date_format_holder); |
| 13980 if (!date_format) return isolate->ThrowIllegalOperation(); | 13973 if (!date_format) return isolate->ThrowIllegalOperation(); |
| 13981 | 13974 |
| 13982 icu::UnicodeString result; | 13975 icu::UnicodeString result; |
| 13983 date_format->format(value->Number(), result); | 13976 date_format->format(value->Number(), result); |
| 13984 | 13977 |
| 13985 Handle<String> result_str; | 13978 Handle<String> result_str; |
| 13986 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 13979 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 13987 isolate, result_str, | 13980 isolate, result_str, |
| 13988 isolate->factory()->NewStringFromTwoByte( | 13981 isolate->factory()->NewStringFromTwoByte( |
| 13989 Vector<const uint16_t>( | 13982 Vector<const uint16_t>( |
| 13990 reinterpret_cast<const uint16_t*>(result.getBuffer()), | 13983 reinterpret_cast<const uint16_t*>(result.getBuffer()), |
| 13991 result.length()))); | 13984 result.length()))); |
| 13992 return *result_str; | 13985 return *result_str; |
| 13993 } | 13986 } |
| 13994 | 13987 |
| 13995 | 13988 |
| 13996 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalDateParse) { | 13989 RUNTIME_FUNCTION(Runtime_InternalDateParse) { |
| 13997 HandleScope scope(isolate); | 13990 HandleScope scope(isolate); |
| 13998 | 13991 |
| 13999 ASSERT(args.length() == 2); | 13992 ASSERT(args.length() == 2); |
| 14000 | 13993 |
| 14001 CONVERT_ARG_HANDLE_CHECKED(JSObject, date_format_holder, 0); | 13994 CONVERT_ARG_HANDLE_CHECKED(JSObject, date_format_holder, 0); |
| 14002 CONVERT_ARG_HANDLE_CHECKED(String, date_string, 1); | 13995 CONVERT_ARG_HANDLE_CHECKED(String, date_string, 1); |
| 14003 | 13996 |
| 14004 v8::String::Utf8Value utf8_date(v8::Utils::ToLocal(date_string)); | 13997 v8::String::Utf8Value utf8_date(v8::Utils::ToLocal(date_string)); |
| 14005 icu::UnicodeString u_date(icu::UnicodeString::fromUTF8(*utf8_date)); | 13998 icu::UnicodeString u_date(icu::UnicodeString::fromUTF8(*utf8_date)); |
| 14006 icu::SimpleDateFormat* date_format = | 13999 icu::SimpleDateFormat* date_format = |
| 14007 DateFormat::UnpackDateFormat(isolate, date_format_holder); | 14000 DateFormat::UnpackDateFormat(isolate, date_format_holder); |
| 14008 if (!date_format) return isolate->ThrowIllegalOperation(); | 14001 if (!date_format) return isolate->ThrowIllegalOperation(); |
| 14009 | 14002 |
| 14010 UErrorCode status = U_ZERO_ERROR; | 14003 UErrorCode status = U_ZERO_ERROR; |
| 14011 UDate date = date_format->parse(u_date, status); | 14004 UDate date = date_format->parse(u_date, status); |
| 14012 if (U_FAILURE(status)) return isolate->heap()->undefined_value(); | 14005 if (U_FAILURE(status)) return isolate->heap()->undefined_value(); |
| 14013 | 14006 |
| 14014 Handle<Object> result; | 14007 Handle<Object> result; |
| 14015 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 14008 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 14016 isolate, result, | 14009 isolate, result, |
| 14017 Execution::NewDate(isolate, static_cast<double>(date))); | 14010 Execution::NewDate(isolate, static_cast<double>(date))); |
| 14018 ASSERT(result->IsJSDate()); | 14011 ASSERT(result->IsJSDate()); |
| 14019 return *result; | 14012 return *result; |
| 14020 } | 14013 } |
| 14021 | 14014 |
| 14022 | 14015 |
| 14023 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateNumberFormat) { | 14016 RUNTIME_FUNCTION(Runtime_CreateNumberFormat) { |
| 14024 HandleScope scope(isolate); | 14017 HandleScope scope(isolate); |
| 14025 | 14018 |
| 14026 ASSERT(args.length() == 3); | 14019 ASSERT(args.length() == 3); |
| 14027 | 14020 |
| 14028 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); | 14021 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); |
| 14029 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); | 14022 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); |
| 14030 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); | 14023 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); |
| 14031 | 14024 |
| 14032 Handle<ObjectTemplateInfo> number_format_template = | 14025 Handle<ObjectTemplateInfo> number_format_template = |
| 14033 I18N::GetTemplate(isolate); | 14026 I18N::GetTemplate(isolate); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 14054 NONE)); | 14047 NONE)); |
| 14055 | 14048 |
| 14056 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); | 14049 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); |
| 14057 GlobalHandles::MakeWeak(wrapper.location(), | 14050 GlobalHandles::MakeWeak(wrapper.location(), |
| 14058 reinterpret_cast<void*>(wrapper.location()), | 14051 reinterpret_cast<void*>(wrapper.location()), |
| 14059 NumberFormat::DeleteNumberFormat); | 14052 NumberFormat::DeleteNumberFormat); |
| 14060 return *local_object; | 14053 return *local_object; |
| 14061 } | 14054 } |
| 14062 | 14055 |
| 14063 | 14056 |
| 14064 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalNumberFormat) { | 14057 RUNTIME_FUNCTION(Runtime_InternalNumberFormat) { |
| 14065 HandleScope scope(isolate); | 14058 HandleScope scope(isolate); |
| 14066 | 14059 |
| 14067 ASSERT(args.length() == 2); | 14060 ASSERT(args.length() == 2); |
| 14068 | 14061 |
| 14069 CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0); | 14062 CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0); |
| 14070 CONVERT_ARG_HANDLE_CHECKED(Object, number, 1); | 14063 CONVERT_ARG_HANDLE_CHECKED(Object, number, 1); |
| 14071 | 14064 |
| 14072 Handle<Object> value; | 14065 Handle<Object> value; |
| 14073 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 14066 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 14074 isolate, value, Execution::ToNumber(isolate, number)); | 14067 isolate, value, Execution::ToNumber(isolate, number)); |
| 14075 | 14068 |
| 14076 icu::DecimalFormat* number_format = | 14069 icu::DecimalFormat* number_format = |
| 14077 NumberFormat::UnpackNumberFormat(isolate, number_format_holder); | 14070 NumberFormat::UnpackNumberFormat(isolate, number_format_holder); |
| 14078 if (!number_format) return isolate->ThrowIllegalOperation(); | 14071 if (!number_format) return isolate->ThrowIllegalOperation(); |
| 14079 | 14072 |
| 14080 icu::UnicodeString result; | 14073 icu::UnicodeString result; |
| 14081 number_format->format(value->Number(), result); | 14074 number_format->format(value->Number(), result); |
| 14082 | 14075 |
| 14083 Handle<String> result_str; | 14076 Handle<String> result_str; |
| 14084 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 14077 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 14085 isolate, result_str, | 14078 isolate, result_str, |
| 14086 isolate->factory()->NewStringFromTwoByte( | 14079 isolate->factory()->NewStringFromTwoByte( |
| 14087 Vector<const uint16_t>( | 14080 Vector<const uint16_t>( |
| 14088 reinterpret_cast<const uint16_t*>(result.getBuffer()), | 14081 reinterpret_cast<const uint16_t*>(result.getBuffer()), |
| 14089 result.length()))); | 14082 result.length()))); |
| 14090 return *result_str; | 14083 return *result_str; |
| 14091 } | 14084 } |
| 14092 | 14085 |
| 14093 | 14086 |
| 14094 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalNumberParse) { | 14087 RUNTIME_FUNCTION(Runtime_InternalNumberParse) { |
| 14095 HandleScope scope(isolate); | 14088 HandleScope scope(isolate); |
| 14096 | 14089 |
| 14097 ASSERT(args.length() == 2); | 14090 ASSERT(args.length() == 2); |
| 14098 | 14091 |
| 14099 CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0); | 14092 CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0); |
| 14100 CONVERT_ARG_HANDLE_CHECKED(String, number_string, 1); | 14093 CONVERT_ARG_HANDLE_CHECKED(String, number_string, 1); |
| 14101 | 14094 |
| 14102 v8::String::Utf8Value utf8_number(v8::Utils::ToLocal(number_string)); | 14095 v8::String::Utf8Value utf8_number(v8::Utils::ToLocal(number_string)); |
| 14103 icu::UnicodeString u_number(icu::UnicodeString::fromUTF8(*utf8_number)); | 14096 icu::UnicodeString u_number(icu::UnicodeString::fromUTF8(*utf8_number)); |
| 14104 icu::DecimalFormat* number_format = | 14097 icu::DecimalFormat* number_format = |
| (...skipping 18 matching lines...) Expand all Loading... |
| 14123 return *isolate->factory()->NewNumberFromInt(result.getLong()); | 14116 return *isolate->factory()->NewNumberFromInt(result.getLong()); |
| 14124 case icu::Formattable::kInt64: | 14117 case icu::Formattable::kInt64: |
| 14125 return *isolate->factory()->NewNumber( | 14118 return *isolate->factory()->NewNumber( |
| 14126 static_cast<double>(result.getInt64())); | 14119 static_cast<double>(result.getInt64())); |
| 14127 default: | 14120 default: |
| 14128 return isolate->heap()->undefined_value(); | 14121 return isolate->heap()->undefined_value(); |
| 14129 } | 14122 } |
| 14130 } | 14123 } |
| 14131 | 14124 |
| 14132 | 14125 |
| 14133 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateCollator) { | 14126 RUNTIME_FUNCTION(Runtime_CreateCollator) { |
| 14134 HandleScope scope(isolate); | 14127 HandleScope scope(isolate); |
| 14135 | 14128 |
| 14136 ASSERT(args.length() == 3); | 14129 ASSERT(args.length() == 3); |
| 14137 | 14130 |
| 14138 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); | 14131 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); |
| 14139 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); | 14132 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); |
| 14140 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); | 14133 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); |
| 14141 | 14134 |
| 14142 Handle<ObjectTemplateInfo> collator_template = I18N::GetTemplate(isolate); | 14135 Handle<ObjectTemplateInfo> collator_template = I18N::GetTemplate(isolate); |
| 14143 | 14136 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 14162 NONE)); | 14155 NONE)); |
| 14163 | 14156 |
| 14164 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); | 14157 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); |
| 14165 GlobalHandles::MakeWeak(wrapper.location(), | 14158 GlobalHandles::MakeWeak(wrapper.location(), |
| 14166 reinterpret_cast<void*>(wrapper.location()), | 14159 reinterpret_cast<void*>(wrapper.location()), |
| 14167 Collator::DeleteCollator); | 14160 Collator::DeleteCollator); |
| 14168 return *local_object; | 14161 return *local_object; |
| 14169 } | 14162 } |
| 14170 | 14163 |
| 14171 | 14164 |
| 14172 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalCompare) { | 14165 RUNTIME_FUNCTION(Runtime_InternalCompare) { |
| 14173 HandleScope scope(isolate); | 14166 HandleScope scope(isolate); |
| 14174 | 14167 |
| 14175 ASSERT(args.length() == 3); | 14168 ASSERT(args.length() == 3); |
| 14176 | 14169 |
| 14177 CONVERT_ARG_HANDLE_CHECKED(JSObject, collator_holder, 0); | 14170 CONVERT_ARG_HANDLE_CHECKED(JSObject, collator_holder, 0); |
| 14178 CONVERT_ARG_HANDLE_CHECKED(String, string1, 1); | 14171 CONVERT_ARG_HANDLE_CHECKED(String, string1, 1); |
| 14179 CONVERT_ARG_HANDLE_CHECKED(String, string2, 2); | 14172 CONVERT_ARG_HANDLE_CHECKED(String, string2, 2); |
| 14180 | 14173 |
| 14181 icu::Collator* collator = Collator::UnpackCollator(isolate, collator_holder); | 14174 icu::Collator* collator = Collator::UnpackCollator(isolate, collator_holder); |
| 14182 if (!collator) return isolate->ThrowIllegalOperation(); | 14175 if (!collator) return isolate->ThrowIllegalOperation(); |
| 14183 | 14176 |
| 14184 v8::String::Value string_value1(v8::Utils::ToLocal(string1)); | 14177 v8::String::Value string_value1(v8::Utils::ToLocal(string1)); |
| 14185 v8::String::Value string_value2(v8::Utils::ToLocal(string2)); | 14178 v8::String::Value string_value2(v8::Utils::ToLocal(string2)); |
| 14186 const UChar* u_string1 = reinterpret_cast<const UChar*>(*string_value1); | 14179 const UChar* u_string1 = reinterpret_cast<const UChar*>(*string_value1); |
| 14187 const UChar* u_string2 = reinterpret_cast<const UChar*>(*string_value2); | 14180 const UChar* u_string2 = reinterpret_cast<const UChar*>(*string_value2); |
| 14188 UErrorCode status = U_ZERO_ERROR; | 14181 UErrorCode status = U_ZERO_ERROR; |
| 14189 UCollationResult result = collator->compare(u_string1, | 14182 UCollationResult result = collator->compare(u_string1, |
| 14190 string_value1.length(), | 14183 string_value1.length(), |
| 14191 u_string2, | 14184 u_string2, |
| 14192 string_value2.length(), | 14185 string_value2.length(), |
| 14193 status); | 14186 status); |
| 14194 if (U_FAILURE(status)) return isolate->ThrowIllegalOperation(); | 14187 if (U_FAILURE(status)) return isolate->ThrowIllegalOperation(); |
| 14195 | 14188 |
| 14196 return *isolate->factory()->NewNumberFromInt(result); | 14189 return *isolate->factory()->NewNumberFromInt(result); |
| 14197 } | 14190 } |
| 14198 | 14191 |
| 14199 | 14192 |
| 14200 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringNormalize) { | 14193 RUNTIME_FUNCTION(Runtime_StringNormalize) { |
| 14201 HandleScope scope(isolate); | 14194 HandleScope scope(isolate); |
| 14202 static const UNormalizationMode normalizationForms[] = | 14195 static const UNormalizationMode normalizationForms[] = |
| 14203 { UNORM_NFC, UNORM_NFD, UNORM_NFKC, UNORM_NFKD }; | 14196 { UNORM_NFC, UNORM_NFD, UNORM_NFKC, UNORM_NFKD }; |
| 14204 | 14197 |
| 14205 ASSERT(args.length() == 2); | 14198 ASSERT(args.length() == 2); |
| 14206 | 14199 |
| 14207 CONVERT_ARG_HANDLE_CHECKED(String, stringValue, 0); | 14200 CONVERT_ARG_HANDLE_CHECKED(String, stringValue, 0); |
| 14208 CONVERT_NUMBER_CHECKED(int, form_id, Int32, args[1]); | 14201 CONVERT_NUMBER_CHECKED(int, form_id, Int32, args[1]); |
| 14209 | 14202 |
| 14210 v8::String::Value string_value(v8::Utils::ToLocal(stringValue)); | 14203 v8::String::Value string_value(v8::Utils::ToLocal(stringValue)); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 14223 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 14216 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 14224 isolate, result_str, | 14217 isolate, result_str, |
| 14225 isolate->factory()->NewStringFromTwoByte( | 14218 isolate->factory()->NewStringFromTwoByte( |
| 14226 Vector<const uint16_t>( | 14219 Vector<const uint16_t>( |
| 14227 reinterpret_cast<const uint16_t*>(result.getBuffer()), | 14220 reinterpret_cast<const uint16_t*>(result.getBuffer()), |
| 14228 result.length()))); | 14221 result.length()))); |
| 14229 return *result_str; | 14222 return *result_str; |
| 14230 } | 14223 } |
| 14231 | 14224 |
| 14232 | 14225 |
| 14233 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateBreakIterator) { | 14226 RUNTIME_FUNCTION(Runtime_CreateBreakIterator) { |
| 14234 HandleScope scope(isolate); | 14227 HandleScope scope(isolate); |
| 14235 | 14228 |
| 14236 ASSERT(args.length() == 3); | 14229 ASSERT(args.length() == 3); |
| 14237 | 14230 |
| 14238 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); | 14231 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); |
| 14239 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); | 14232 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); |
| 14240 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); | 14233 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); |
| 14241 | 14234 |
| 14242 Handle<ObjectTemplateInfo> break_iterator_template = | 14235 Handle<ObjectTemplateInfo> break_iterator_template = |
| 14243 I18N::GetTemplate2(isolate); | 14236 I18N::GetTemplate2(isolate); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 14268 // Make object handle weak so we can delete the break iterator once GC kicks | 14261 // Make object handle weak so we can delete the break iterator once GC kicks |
| 14269 // in. | 14262 // in. |
| 14270 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); | 14263 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); |
| 14271 GlobalHandles::MakeWeak(wrapper.location(), | 14264 GlobalHandles::MakeWeak(wrapper.location(), |
| 14272 reinterpret_cast<void*>(wrapper.location()), | 14265 reinterpret_cast<void*>(wrapper.location()), |
| 14273 BreakIterator::DeleteBreakIterator); | 14266 BreakIterator::DeleteBreakIterator); |
| 14274 return *local_object; | 14267 return *local_object; |
| 14275 } | 14268 } |
| 14276 | 14269 |
| 14277 | 14270 |
| 14278 RUNTIME_FUNCTION(MaybeObject*, Runtime_BreakIteratorAdoptText) { | 14271 RUNTIME_FUNCTION(Runtime_BreakIteratorAdoptText) { |
| 14279 HandleScope scope(isolate); | 14272 HandleScope scope(isolate); |
| 14280 | 14273 |
| 14281 ASSERT(args.length() == 2); | 14274 ASSERT(args.length() == 2); |
| 14282 | 14275 |
| 14283 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); | 14276 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); |
| 14284 CONVERT_ARG_HANDLE_CHECKED(String, text, 1); | 14277 CONVERT_ARG_HANDLE_CHECKED(String, text, 1); |
| 14285 | 14278 |
| 14286 icu::BreakIterator* break_iterator = | 14279 icu::BreakIterator* break_iterator = |
| 14287 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); | 14280 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); |
| 14288 if (!break_iterator) return isolate->ThrowIllegalOperation(); | 14281 if (!break_iterator) return isolate->ThrowIllegalOperation(); |
| 14289 | 14282 |
| 14290 icu::UnicodeString* u_text = reinterpret_cast<icu::UnicodeString*>( | 14283 icu::UnicodeString* u_text = reinterpret_cast<icu::UnicodeString*>( |
| 14291 break_iterator_holder->GetInternalField(1)); | 14284 break_iterator_holder->GetInternalField(1)); |
| 14292 delete u_text; | 14285 delete u_text; |
| 14293 | 14286 |
| 14294 v8::String::Value text_value(v8::Utils::ToLocal(text)); | 14287 v8::String::Value text_value(v8::Utils::ToLocal(text)); |
| 14295 u_text = new icu::UnicodeString( | 14288 u_text = new icu::UnicodeString( |
| 14296 reinterpret_cast<const UChar*>(*text_value), text_value.length()); | 14289 reinterpret_cast<const UChar*>(*text_value), text_value.length()); |
| 14297 break_iterator_holder->SetInternalField(1, reinterpret_cast<Smi*>(u_text)); | 14290 break_iterator_holder->SetInternalField(1, reinterpret_cast<Smi*>(u_text)); |
| 14298 | 14291 |
| 14299 break_iterator->setText(*u_text); | 14292 break_iterator->setText(*u_text); |
| 14300 | 14293 |
| 14301 return isolate->heap()->undefined_value(); | 14294 return isolate->heap()->undefined_value(); |
| 14302 } | 14295 } |
| 14303 | 14296 |
| 14304 | 14297 |
| 14305 RUNTIME_FUNCTION(MaybeObject*, Runtime_BreakIteratorFirst) { | 14298 RUNTIME_FUNCTION(Runtime_BreakIteratorFirst) { |
| 14306 HandleScope scope(isolate); | 14299 HandleScope scope(isolate); |
| 14307 | 14300 |
| 14308 ASSERT(args.length() == 1); | 14301 ASSERT(args.length() == 1); |
| 14309 | 14302 |
| 14310 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); | 14303 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); |
| 14311 | 14304 |
| 14312 icu::BreakIterator* break_iterator = | 14305 icu::BreakIterator* break_iterator = |
| 14313 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); | 14306 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); |
| 14314 if (!break_iterator) return isolate->ThrowIllegalOperation(); | 14307 if (!break_iterator) return isolate->ThrowIllegalOperation(); |
| 14315 | 14308 |
| 14316 return *isolate->factory()->NewNumberFromInt(break_iterator->first()); | 14309 return *isolate->factory()->NewNumberFromInt(break_iterator->first()); |
| 14317 } | 14310 } |
| 14318 | 14311 |
| 14319 | 14312 |
| 14320 RUNTIME_FUNCTION(MaybeObject*, Runtime_BreakIteratorNext) { | 14313 RUNTIME_FUNCTION(Runtime_BreakIteratorNext) { |
| 14321 HandleScope scope(isolate); | 14314 HandleScope scope(isolate); |
| 14322 | 14315 |
| 14323 ASSERT(args.length() == 1); | 14316 ASSERT(args.length() == 1); |
| 14324 | 14317 |
| 14325 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); | 14318 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); |
| 14326 | 14319 |
| 14327 icu::BreakIterator* break_iterator = | 14320 icu::BreakIterator* break_iterator = |
| 14328 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); | 14321 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); |
| 14329 if (!break_iterator) return isolate->ThrowIllegalOperation(); | 14322 if (!break_iterator) return isolate->ThrowIllegalOperation(); |
| 14330 | 14323 |
| 14331 return *isolate->factory()->NewNumberFromInt(break_iterator->next()); | 14324 return *isolate->factory()->NewNumberFromInt(break_iterator->next()); |
| 14332 } | 14325 } |
| 14333 | 14326 |
| 14334 | 14327 |
| 14335 RUNTIME_FUNCTION(MaybeObject*, Runtime_BreakIteratorCurrent) { | 14328 RUNTIME_FUNCTION(Runtime_BreakIteratorCurrent) { |
| 14336 HandleScope scope(isolate); | 14329 HandleScope scope(isolate); |
| 14337 | 14330 |
| 14338 ASSERT(args.length() == 1); | 14331 ASSERT(args.length() == 1); |
| 14339 | 14332 |
| 14340 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); | 14333 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); |
| 14341 | 14334 |
| 14342 icu::BreakIterator* break_iterator = | 14335 icu::BreakIterator* break_iterator = |
| 14343 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); | 14336 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); |
| 14344 if (!break_iterator) return isolate->ThrowIllegalOperation(); | 14337 if (!break_iterator) return isolate->ThrowIllegalOperation(); |
| 14345 | 14338 |
| 14346 return *isolate->factory()->NewNumberFromInt(break_iterator->current()); | 14339 return *isolate->factory()->NewNumberFromInt(break_iterator->current()); |
| 14347 } | 14340 } |
| 14348 | 14341 |
| 14349 | 14342 |
| 14350 RUNTIME_FUNCTION(MaybeObject*, Runtime_BreakIteratorBreakType) { | 14343 RUNTIME_FUNCTION(Runtime_BreakIteratorBreakType) { |
| 14351 HandleScope scope(isolate); | 14344 HandleScope scope(isolate); |
| 14352 | 14345 |
| 14353 ASSERT(args.length() == 1); | 14346 ASSERT(args.length() == 1); |
| 14354 | 14347 |
| 14355 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); | 14348 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); |
| 14356 | 14349 |
| 14357 icu::BreakIterator* break_iterator = | 14350 icu::BreakIterator* break_iterator = |
| 14358 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); | 14351 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); |
| 14359 if (!break_iterator) return isolate->ThrowIllegalOperation(); | 14352 if (!break_iterator) return isolate->ThrowIllegalOperation(); |
| 14360 | 14353 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14412 if (script.is_null()) return factory->undefined_value(); | 14405 if (script.is_null()) return factory->undefined_value(); |
| 14413 | 14406 |
| 14414 // Return the script found. | 14407 // Return the script found. |
| 14415 return Script::GetWrapper(script); | 14408 return Script::GetWrapper(script); |
| 14416 } | 14409 } |
| 14417 | 14410 |
| 14418 | 14411 |
| 14419 // Get the script object from script data. NOTE: Regarding performance | 14412 // Get the script object from script data. NOTE: Regarding performance |
| 14420 // see the NOTE for GetScriptFromScriptData. | 14413 // see the NOTE for GetScriptFromScriptData. |
| 14421 // args[0]: script data for the script to find the source for | 14414 // args[0]: script data for the script to find the source for |
| 14422 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScript) { | 14415 RUNTIME_FUNCTION(Runtime_GetScript) { |
| 14423 HandleScope scope(isolate); | 14416 HandleScope scope(isolate); |
| 14424 | 14417 |
| 14425 ASSERT(args.length() == 1); | 14418 ASSERT(args.length() == 1); |
| 14426 | 14419 |
| 14427 CONVERT_ARG_CHECKED(String, script_name, 0); | 14420 CONVERT_ARG_CHECKED(String, script_name, 0); |
| 14428 | 14421 |
| 14429 // Find the requested script. | 14422 // Find the requested script. |
| 14430 Handle<Object> result = | 14423 Handle<Object> result = |
| 14431 Runtime_GetScriptFromScriptName(Handle<String>(script_name)); | 14424 Runtime_GetScriptFromScriptName(Handle<String>(script_name)); |
| 14432 return *result; | 14425 return *result; |
| 14433 } | 14426 } |
| 14434 | 14427 |
| 14435 | 14428 |
| 14436 // Collect the raw data for a stack trace. Returns an array of 4 | 14429 // Collect the raw data for a stack trace. Returns an array of 4 |
| 14437 // element segments each containing a receiver, function, code and | 14430 // element segments each containing a receiver, function, code and |
| 14438 // native code offset. | 14431 // native code offset. |
| 14439 RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectStackTrace) { | 14432 RUNTIME_FUNCTION(Runtime_CollectStackTrace) { |
| 14440 HandleScope scope(isolate); | 14433 HandleScope scope(isolate); |
| 14441 ASSERT(args.length() == 3); | 14434 ASSERT(args.length() == 3); |
| 14442 CONVERT_ARG_HANDLE_CHECKED(JSObject, error_object, 0); | 14435 CONVERT_ARG_HANDLE_CHECKED(JSObject, error_object, 0); |
| 14443 CONVERT_ARG_HANDLE_CHECKED(Object, caller, 1); | 14436 CONVERT_ARG_HANDLE_CHECKED(Object, caller, 1); |
| 14444 CONVERT_NUMBER_CHECKED(int32_t, limit, Int32, args[2]); | 14437 CONVERT_NUMBER_CHECKED(int32_t, limit, Int32, args[2]); |
| 14445 | 14438 |
| 14446 // Optionally capture a more detailed stack trace for the message. | 14439 // Optionally capture a more detailed stack trace for the message. |
| 14447 isolate->CaptureAndSetDetailedStackTrace(error_object); | 14440 isolate->CaptureAndSetDetailedStackTrace(error_object); |
| 14448 // Capture a simple stack trace for the stack property. | 14441 // Capture a simple stack trace for the stack property. |
| 14449 return *isolate->CaptureSimpleStackTrace(error_object, caller, limit); | 14442 return *isolate->CaptureSimpleStackTrace(error_object, caller, limit); |
| 14450 } | 14443 } |
| 14451 | 14444 |
| 14452 | 14445 |
| 14453 // Retrieve the stack trace. This is the raw stack trace that yet has to | 14446 // Retrieve the stack trace. This is the raw stack trace that yet has to |
| 14454 // be formatted. Since we only need this once, clear it afterwards. | 14447 // be formatted. Since we only need this once, clear it afterwards. |
| 14455 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetAndClearOverflowedStackTrace) { | 14448 RUNTIME_FUNCTION(Runtime_GetAndClearOverflowedStackTrace) { |
| 14456 HandleScope scope(isolate); | 14449 HandleScope scope(isolate); |
| 14457 ASSERT(args.length() == 1); | 14450 ASSERT(args.length() == 1); |
| 14458 CONVERT_ARG_HANDLE_CHECKED(JSObject, error_object, 0); | 14451 CONVERT_ARG_HANDLE_CHECKED(JSObject, error_object, 0); |
| 14459 Handle<String> key = isolate->factory()->hidden_stack_trace_string(); | 14452 Handle<String> key = isolate->factory()->hidden_stack_trace_string(); |
| 14460 Handle<Object> result(error_object->GetHiddenProperty(*key), isolate); | 14453 Handle<Object> result(error_object->GetHiddenProperty(*key), isolate); |
| 14461 if (result->IsTheHole()) return isolate->heap()->undefined_value(); | 14454 if (result->IsTheHole()) return isolate->heap()->undefined_value(); |
| 14462 RUNTIME_ASSERT(result->IsJSArray() || result->IsUndefined()); | 14455 RUNTIME_ASSERT(result->IsJSArray() || result->IsUndefined()); |
| 14463 JSObject::DeleteHiddenProperty(error_object, key); | 14456 JSObject::DeleteHiddenProperty(error_object, key); |
| 14464 return *result; | 14457 return *result; |
| 14465 } | 14458 } |
| 14466 | 14459 |
| 14467 | 14460 |
| 14468 // Returns V8 version as a string. | 14461 // Returns V8 version as a string. |
| 14469 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetV8Version) { | 14462 RUNTIME_FUNCTION(Runtime_GetV8Version) { |
| 14470 HandleScope scope(isolate); | 14463 HandleScope scope(isolate); |
| 14471 ASSERT(args.length() == 0); | 14464 ASSERT(args.length() == 0); |
| 14472 | 14465 |
| 14473 const char* version_string = v8::V8::GetVersion(); | 14466 const char* version_string = v8::V8::GetVersion(); |
| 14474 | 14467 |
| 14475 return *isolate->factory()->NewStringFromAsciiChecked(version_string); | 14468 return *isolate->factory()->NewStringFromAsciiChecked(version_string); |
| 14476 } | 14469 } |
| 14477 | 14470 |
| 14478 | 14471 |
| 14479 RUNTIME_FUNCTION(MaybeObject*, Runtime_Abort) { | 14472 RUNTIME_FUNCTION(Runtime_Abort) { |
| 14480 SealHandleScope shs(isolate); | 14473 SealHandleScope shs(isolate); |
| 14481 ASSERT(args.length() == 1); | 14474 ASSERT(args.length() == 1); |
| 14482 CONVERT_SMI_ARG_CHECKED(message_id, 0); | 14475 CONVERT_SMI_ARG_CHECKED(message_id, 0); |
| 14483 const char* message = GetBailoutReason( | 14476 const char* message = GetBailoutReason( |
| 14484 static_cast<BailoutReason>(message_id)); | 14477 static_cast<BailoutReason>(message_id)); |
| 14485 OS::PrintError("abort: %s\n", message); | 14478 OS::PrintError("abort: %s\n", message); |
| 14486 isolate->PrintStack(stderr); | 14479 isolate->PrintStack(stderr); |
| 14487 OS::Abort(); | 14480 OS::Abort(); |
| 14488 UNREACHABLE(); | 14481 UNREACHABLE(); |
| 14489 return NULL; | 14482 return NULL; |
| 14490 } | 14483 } |
| 14491 | 14484 |
| 14492 | 14485 |
| 14493 RUNTIME_FUNCTION(MaybeObject*, Runtime_AbortJS) { | 14486 RUNTIME_FUNCTION(Runtime_AbortJS) { |
| 14494 HandleScope scope(isolate); | 14487 HandleScope scope(isolate); |
| 14495 ASSERT(args.length() == 1); | 14488 ASSERT(args.length() == 1); |
| 14496 CONVERT_ARG_HANDLE_CHECKED(String, message, 0); | 14489 CONVERT_ARG_HANDLE_CHECKED(String, message, 0); |
| 14497 OS::PrintError("abort: %s\n", message->ToCString().get()); | 14490 OS::PrintError("abort: %s\n", message->ToCString().get()); |
| 14498 isolate->PrintStack(stderr); | 14491 isolate->PrintStack(stderr); |
| 14499 OS::Abort(); | 14492 OS::Abort(); |
| 14500 UNREACHABLE(); | 14493 UNREACHABLE(); |
| 14501 return NULL; | 14494 return NULL; |
| 14502 } | 14495 } |
| 14503 | 14496 |
| 14504 | 14497 |
| 14505 RUNTIME_FUNCTION(MaybeObject*, Runtime_FlattenString) { | 14498 RUNTIME_FUNCTION(Runtime_FlattenString) { |
| 14506 HandleScope scope(isolate); | 14499 HandleScope scope(isolate); |
| 14507 ASSERT(args.length() == 1); | 14500 ASSERT(args.length() == 1); |
| 14508 CONVERT_ARG_HANDLE_CHECKED(String, str, 0); | 14501 CONVERT_ARG_HANDLE_CHECKED(String, str, 0); |
| 14509 return *String::Flatten(str); | 14502 return *String::Flatten(str); |
| 14510 } | 14503 } |
| 14511 | 14504 |
| 14512 | 14505 |
| 14513 RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyContextDisposed) { | 14506 RUNTIME_FUNCTION(Runtime_NotifyContextDisposed) { |
| 14514 HandleScope scope(isolate); | 14507 HandleScope scope(isolate); |
| 14515 ASSERT(args.length() == 0); | 14508 ASSERT(args.length() == 0); |
| 14516 isolate->heap()->NotifyContextDisposed(); | 14509 isolate->heap()->NotifyContextDisposed(); |
| 14517 return isolate->heap()->undefined_value(); | 14510 return isolate->heap()->undefined_value(); |
| 14518 } | 14511 } |
| 14519 | 14512 |
| 14520 | 14513 |
| 14521 RUNTIME_FUNCTION(MaybeObject*, Runtime_LoadMutableDouble) { | 14514 RUNTIME_FUNCTION(Runtime_LoadMutableDouble) { |
| 14522 HandleScope scope(isolate); | 14515 HandleScope scope(isolate); |
| 14523 ASSERT(args.length() == 2); | 14516 ASSERT(args.length() == 2); |
| 14524 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 14517 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
| 14525 CONVERT_ARG_HANDLE_CHECKED(Smi, index, 1); | 14518 CONVERT_ARG_HANDLE_CHECKED(Smi, index, 1); |
| 14526 int idx = index->value() >> 1; | 14519 int idx = index->value() >> 1; |
| 14527 if (idx < 0) { | 14520 if (idx < 0) { |
| 14528 idx = -idx + object->map()->inobject_properties() - 1; | 14521 idx = -idx + object->map()->inobject_properties() - 1; |
| 14529 } | 14522 } |
| 14530 return *JSObject::FastPropertyAt(object, Representation::Double(), idx); | 14523 return *JSObject::FastPropertyAt(object, Representation::Double(), idx); |
| 14531 } | 14524 } |
| 14532 | 14525 |
| 14533 | 14526 |
| 14534 RUNTIME_FUNCTION(MaybeObject*, Runtime_TryMigrateInstance) { | 14527 RUNTIME_FUNCTION(Runtime_TryMigrateInstance) { |
| 14535 HandleScope scope(isolate); | 14528 HandleScope scope(isolate); |
| 14536 ASSERT(args.length() == 1); | 14529 ASSERT(args.length() == 1); |
| 14537 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 14530 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
| 14538 if (!object->IsJSObject()) return Smi::FromInt(0); | 14531 if (!object->IsJSObject()) return Smi::FromInt(0); |
| 14539 Handle<JSObject> js_object = Handle<JSObject>::cast(object); | 14532 Handle<JSObject> js_object = Handle<JSObject>::cast(object); |
| 14540 if (!js_object->map()->is_deprecated()) return Smi::FromInt(0); | 14533 if (!js_object->map()->is_deprecated()) return Smi::FromInt(0); |
| 14541 // This call must not cause lazy deopts, because it's called from deferred | 14534 // This call must not cause lazy deopts, because it's called from deferred |
| 14542 // code where we can't handle lazy deopts for lack of a suitable bailout | 14535 // code where we can't handle lazy deopts for lack of a suitable bailout |
| 14543 // ID. So we just try migration and signal failure if necessary, | 14536 // ID. So we just try migration and signal failure if necessary, |
| 14544 // which will also trigger a deopt. | 14537 // which will also trigger a deopt. |
| 14545 Handle<Object> result = JSObject::TryMigrateInstance(js_object); | 14538 Handle<Object> result = JSObject::TryMigrateInstance(js_object); |
| 14546 if (result.is_null()) return Smi::FromInt(0); | 14539 if (result.is_null()) return Smi::FromInt(0); |
| 14547 return *object; | 14540 return *object; |
| 14548 } | 14541 } |
| 14549 | 14542 |
| 14550 | 14543 |
| 14551 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_GetFromCache) { | 14544 RUNTIME_FUNCTION(RuntimeHidden_GetFromCache) { |
| 14552 SealHandleScope shs(isolate); | 14545 SealHandleScope shs(isolate); |
| 14553 // This is only called from codegen, so checks might be more lax. | 14546 // This is only called from codegen, so checks might be more lax. |
| 14554 CONVERT_ARG_CHECKED(JSFunctionResultCache, cache, 0); | 14547 CONVERT_ARG_CHECKED(JSFunctionResultCache, cache, 0); |
| 14555 CONVERT_ARG_CHECKED(Object, key, 1); | 14548 CONVERT_ARG_CHECKED(Object, key, 1); |
| 14556 | 14549 |
| 14557 { | 14550 { |
| 14558 DisallowHeapAllocation no_alloc; | 14551 DisallowHeapAllocation no_alloc; |
| 14559 | 14552 |
| 14560 int finger_index = cache->finger_index(); | 14553 int finger_index = cache->finger_index(); |
| 14561 Object* o = cache->get(finger_index); | 14554 Object* o = cache->get(finger_index); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14639 #ifdef VERIFY_HEAP | 14632 #ifdef VERIFY_HEAP |
| 14640 if (FLAG_verify_heap) { | 14633 if (FLAG_verify_heap) { |
| 14641 cache_handle->JSFunctionResultCacheVerify(); | 14634 cache_handle->JSFunctionResultCacheVerify(); |
| 14642 } | 14635 } |
| 14643 #endif | 14636 #endif |
| 14644 | 14637 |
| 14645 return *value; | 14638 return *value; |
| 14646 } | 14639 } |
| 14647 | 14640 |
| 14648 | 14641 |
| 14649 RUNTIME_FUNCTION(MaybeObject*, Runtime_MessageGetStartPosition) { | 14642 RUNTIME_FUNCTION(Runtime_MessageGetStartPosition) { |
| 14650 SealHandleScope shs(isolate); | 14643 SealHandleScope shs(isolate); |
| 14651 ASSERT(args.length() == 1); | 14644 ASSERT(args.length() == 1); |
| 14652 CONVERT_ARG_CHECKED(JSMessageObject, message, 0); | 14645 CONVERT_ARG_CHECKED(JSMessageObject, message, 0); |
| 14653 return Smi::FromInt(message->start_position()); | 14646 return Smi::FromInt(message->start_position()); |
| 14654 } | 14647 } |
| 14655 | 14648 |
| 14656 | 14649 |
| 14657 RUNTIME_FUNCTION(MaybeObject*, Runtime_MessageGetScript) { | 14650 RUNTIME_FUNCTION(Runtime_MessageGetScript) { |
| 14658 SealHandleScope shs(isolate); | 14651 SealHandleScope shs(isolate); |
| 14659 ASSERT(args.length() == 1); | 14652 ASSERT(args.length() == 1); |
| 14660 CONVERT_ARG_CHECKED(JSMessageObject, message, 0); | 14653 CONVERT_ARG_CHECKED(JSMessageObject, message, 0); |
| 14661 return message->script(); | 14654 return message->script(); |
| 14662 } | 14655 } |
| 14663 | 14656 |
| 14664 | 14657 |
| 14665 #ifdef DEBUG | 14658 #ifdef DEBUG |
| 14666 // ListNatives is ONLY used by the fuzz-natives.js in debug mode | 14659 // ListNatives is ONLY used by the fuzz-natives.js in debug mode |
| 14667 // Exclude the code in release mode. | 14660 // Exclude the code in release mode. |
| 14668 RUNTIME_FUNCTION(MaybeObject*, Runtime_ListNatives) { | 14661 RUNTIME_FUNCTION(Runtime_ListNatives) { |
| 14669 HandleScope scope(isolate); | 14662 HandleScope scope(isolate); |
| 14670 ASSERT(args.length() == 0); | 14663 ASSERT(args.length() == 0); |
| 14671 #define COUNT_ENTRY(Name, argc, ressize) + 1 | 14664 #define COUNT_ENTRY(Name, argc, ressize) + 1 |
| 14672 int entry_count = 0 | 14665 int entry_count = 0 |
| 14673 RUNTIME_FUNCTION_LIST(COUNT_ENTRY) | 14666 RUNTIME_FUNCTION_LIST(COUNT_ENTRY) |
| 14674 RUNTIME_HIDDEN_FUNCTION_LIST(COUNT_ENTRY) | 14667 RUNTIME_HIDDEN_FUNCTION_LIST(COUNT_ENTRY) |
| 14675 INLINE_FUNCTION_LIST(COUNT_ENTRY); | 14668 INLINE_FUNCTION_LIST(COUNT_ENTRY); |
| 14676 #undef COUNT_ENTRY | 14669 #undef COUNT_ENTRY |
| 14677 Factory* factory = isolate->factory(); | 14670 Factory* factory = isolate->factory(); |
| 14678 Handle<FixedArray> elements = factory->NewFixedArray(entry_count); | 14671 Handle<FixedArray> elements = factory->NewFixedArray(entry_count); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 14701 inline_runtime_functions = true; | 14694 inline_runtime_functions = true; |
| 14702 INLINE_FUNCTION_LIST(ADD_ENTRY) | 14695 INLINE_FUNCTION_LIST(ADD_ENTRY) |
| 14703 #undef ADD_ENTRY | 14696 #undef ADD_ENTRY |
| 14704 ASSERT_EQ(index, entry_count); | 14697 ASSERT_EQ(index, entry_count); |
| 14705 Handle<JSArray> result = factory->NewJSArrayWithElements(elements); | 14698 Handle<JSArray> result = factory->NewJSArrayWithElements(elements); |
| 14706 return *result; | 14699 return *result; |
| 14707 } | 14700 } |
| 14708 #endif | 14701 #endif |
| 14709 | 14702 |
| 14710 | 14703 |
| 14711 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_Log) { | 14704 RUNTIME_FUNCTION(RuntimeHidden_Log) { |
| 14712 HandleScope handle_scope(isolate); | 14705 HandleScope handle_scope(isolate); |
| 14713 ASSERT(args.length() == 2); | 14706 ASSERT(args.length() == 2); |
| 14714 CONVERT_ARG_HANDLE_CHECKED(String, format, 0); | 14707 CONVERT_ARG_HANDLE_CHECKED(String, format, 0); |
| 14715 CONVERT_ARG_HANDLE_CHECKED(JSArray, elms, 1); | 14708 CONVERT_ARG_HANDLE_CHECKED(JSArray, elms, 1); |
| 14716 | 14709 |
| 14717 SmartArrayPointer<char> format_chars = format->ToCString(); | 14710 SmartArrayPointer<char> format_chars = format->ToCString(); |
| 14718 isolate->logger()->LogRuntime( | 14711 isolate->logger()->LogRuntime( |
| 14719 Vector<const char>(format_chars.get(), format->length()), elms); | 14712 Vector<const char>(format_chars.get(), format->length()), elms); |
| 14720 return isolate->heap()->undefined_value(); | 14713 return isolate->heap()->undefined_value(); |
| 14721 } | 14714 } |
| 14722 | 14715 |
| 14723 | 14716 |
| 14724 RUNTIME_FUNCTION(MaybeObject*, Runtime_IS_VAR) { | 14717 RUNTIME_FUNCTION(Runtime_IS_VAR) { |
| 14725 UNREACHABLE(); // implemented as macro in the parser | 14718 UNREACHABLE(); // implemented as macro in the parser |
| 14726 return NULL; | 14719 return NULL; |
| 14727 } | 14720 } |
| 14728 | 14721 |
| 14729 | 14722 |
| 14730 #define ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(Name) \ | 14723 #define ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(Name) \ |
| 14731 RUNTIME_FUNCTION(MaybeObject*, Runtime_Has##Name) { \ | 14724 RUNTIME_FUNCTION(Runtime_Has##Name) { \ |
| 14732 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ | 14725 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ |
| 14733 return isolate->heap()->ToBoolean(obj->Has##Name()); \ | 14726 return isolate->heap()->ToBoolean(obj->Has##Name()); \ |
| 14734 } | 14727 } |
| 14735 | 14728 |
| 14736 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastSmiElements) | 14729 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastSmiElements) |
| 14737 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastObjectElements) | 14730 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastObjectElements) |
| 14738 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastSmiOrObjectElements) | 14731 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastSmiOrObjectElements) |
| 14739 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastDoubleElements) | 14732 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastDoubleElements) |
| 14740 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastHoleyElements) | 14733 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastHoleyElements) |
| 14741 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(DictionaryElements) | 14734 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(DictionaryElements) |
| 14742 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(SloppyArgumentsElements) | 14735 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(SloppyArgumentsElements) |
| 14743 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalArrayElements) | 14736 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalArrayElements) |
| 14744 // Properties test sitting with elements tests - not fooling anyone. | 14737 // Properties test sitting with elements tests - not fooling anyone. |
| 14745 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastProperties) | 14738 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastProperties) |
| 14746 | 14739 |
| 14747 #undef ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION | 14740 #undef ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION |
| 14748 | 14741 |
| 14749 | 14742 |
| 14750 #define TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION(Type, type, TYPE, ctype, size) \ | 14743 #define TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION(Type, type, TYPE, ctype, size) \ |
| 14751 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasExternal##Type##Elements) { \ | 14744 RUNTIME_FUNCTION(Runtime_HasExternal##Type##Elements) { \ |
| 14752 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ | 14745 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ |
| 14753 return isolate->heap()->ToBoolean(obj->HasExternal##Type##Elements()); \ | 14746 return isolate->heap()->ToBoolean(obj->HasExternal##Type##Elements()); \ |
| 14754 } | 14747 } |
| 14755 | 14748 |
| 14756 TYPED_ARRAYS(TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION) | 14749 TYPED_ARRAYS(TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION) |
| 14757 | 14750 |
| 14758 #undef TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION | 14751 #undef TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION |
| 14759 | 14752 |
| 14760 | 14753 |
| 14761 #define FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION(Type, type, TYPE, ctype, s) \ | 14754 #define FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION(Type, type, TYPE, ctype, s) \ |
| 14762 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasFixed##Type##Elements) { \ | 14755 RUNTIME_FUNCTION(Runtime_HasFixed##Type##Elements) { \ |
| 14763 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ | 14756 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ |
| 14764 return isolate->heap()->ToBoolean(obj->HasFixed##Type##Elements()); \ | 14757 return isolate->heap()->ToBoolean(obj->HasFixed##Type##Elements()); \ |
| 14765 } | 14758 } |
| 14766 | 14759 |
| 14767 TYPED_ARRAYS(FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION) | 14760 TYPED_ARRAYS(FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION) |
| 14768 | 14761 |
| 14769 #undef FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION | 14762 #undef FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION |
| 14770 | 14763 |
| 14771 | 14764 |
| 14772 RUNTIME_FUNCTION(MaybeObject*, Runtime_HaveSameMap) { | 14765 RUNTIME_FUNCTION(Runtime_HaveSameMap) { |
| 14773 SealHandleScope shs(isolate); | 14766 SealHandleScope shs(isolate); |
| 14774 ASSERT(args.length() == 2); | 14767 ASSERT(args.length() == 2); |
| 14775 CONVERT_ARG_CHECKED(JSObject, obj1, 0); | 14768 CONVERT_ARG_CHECKED(JSObject, obj1, 0); |
| 14776 CONVERT_ARG_CHECKED(JSObject, obj2, 1); | 14769 CONVERT_ARG_CHECKED(JSObject, obj2, 1); |
| 14777 return isolate->heap()->ToBoolean(obj1->map() == obj2->map()); | 14770 return isolate->heap()->ToBoolean(obj1->map() == obj2->map()); |
| 14778 } | 14771 } |
| 14779 | 14772 |
| 14780 | 14773 |
| 14781 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsAccessCheckNeeded) { | 14774 RUNTIME_FUNCTION(Runtime_IsAccessCheckNeeded) { |
| 14782 SealHandleScope shs(isolate); | 14775 SealHandleScope shs(isolate); |
| 14783 ASSERT(args.length() == 1); | 14776 ASSERT(args.length() == 1); |
| 14784 CONVERT_ARG_CHECKED(HeapObject, obj, 0); | 14777 CONVERT_ARG_CHECKED(HeapObject, obj, 0); |
| 14785 return isolate->heap()->ToBoolean(obj->IsAccessCheckNeeded()); | 14778 return isolate->heap()->ToBoolean(obj->IsAccessCheckNeeded()); |
| 14786 } | 14779 } |
| 14787 | 14780 |
| 14788 | 14781 |
| 14789 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsObserved) { | 14782 RUNTIME_FUNCTION(Runtime_IsObserved) { |
| 14790 SealHandleScope shs(isolate); | 14783 SealHandleScope shs(isolate); |
| 14791 ASSERT(args.length() == 1); | 14784 ASSERT(args.length() == 1); |
| 14792 | 14785 |
| 14793 if (!args[0]->IsJSReceiver()) return isolate->heap()->false_value(); | 14786 if (!args[0]->IsJSReceiver()) return isolate->heap()->false_value(); |
| 14794 CONVERT_ARG_CHECKED(JSReceiver, obj, 0); | 14787 CONVERT_ARG_CHECKED(JSReceiver, obj, 0); |
| 14795 if (obj->IsJSGlobalProxy()) { | 14788 if (obj->IsJSGlobalProxy()) { |
| 14796 Object* proto = obj->GetPrototype(); | 14789 Object* proto = obj->GetPrototype(); |
| 14797 if (proto->IsNull()) return isolate->heap()->false_value(); | 14790 if (proto->IsNull()) return isolate->heap()->false_value(); |
| 14798 ASSERT(proto->IsJSGlobalObject()); | 14791 ASSERT(proto->IsJSGlobalObject()); |
| 14799 obj = JSReceiver::cast(proto); | 14792 obj = JSReceiver::cast(proto); |
| 14800 } | 14793 } |
| 14801 return isolate->heap()->ToBoolean(obj->map()->is_observed()); | 14794 return isolate->heap()->ToBoolean(obj->map()->is_observed()); |
| 14802 } | 14795 } |
| 14803 | 14796 |
| 14804 | 14797 |
| 14805 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetIsObserved) { | 14798 RUNTIME_FUNCTION(Runtime_SetIsObserved) { |
| 14806 HandleScope scope(isolate); | 14799 HandleScope scope(isolate); |
| 14807 ASSERT(args.length() == 1); | 14800 ASSERT(args.length() == 1); |
| 14808 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, obj, 0); | 14801 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, obj, 0); |
| 14809 if (obj->IsJSGlobalProxy()) { | 14802 if (obj->IsJSGlobalProxy()) { |
| 14810 Object* proto = obj->GetPrototype(); | 14803 Object* proto = obj->GetPrototype(); |
| 14811 if (proto->IsNull()) return isolate->heap()->undefined_value(); | 14804 if (proto->IsNull()) return isolate->heap()->undefined_value(); |
| 14812 ASSERT(proto->IsJSGlobalObject()); | 14805 ASSERT(proto->IsJSGlobalObject()); |
| 14813 obj = handle(JSReceiver::cast(proto)); | 14806 obj = handle(JSReceiver::cast(proto)); |
| 14814 } | 14807 } |
| 14815 if (obj->IsJSProxy()) | 14808 if (obj->IsJSProxy()) |
| 14816 return isolate->heap()->undefined_value(); | 14809 return isolate->heap()->undefined_value(); |
| 14817 | 14810 |
| 14818 ASSERT(obj->IsJSObject()); | 14811 ASSERT(obj->IsJSObject()); |
| 14819 JSObject::SetObserved(Handle<JSObject>::cast(obj)); | 14812 JSObject::SetObserved(Handle<JSObject>::cast(obj)); |
| 14820 return isolate->heap()->undefined_value(); | 14813 return isolate->heap()->undefined_value(); |
| 14821 } | 14814 } |
| 14822 | 14815 |
| 14823 | 14816 |
| 14824 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetMicrotaskPending) { | 14817 RUNTIME_FUNCTION(Runtime_SetMicrotaskPending) { |
| 14825 SealHandleScope shs(isolate); | 14818 SealHandleScope shs(isolate); |
| 14826 ASSERT(args.length() == 1); | 14819 ASSERT(args.length() == 1); |
| 14827 CONVERT_BOOLEAN_ARG_CHECKED(new_state, 0); | 14820 CONVERT_BOOLEAN_ARG_CHECKED(new_state, 0); |
| 14828 bool old_state = isolate->microtask_pending(); | 14821 bool old_state = isolate->microtask_pending(); |
| 14829 isolate->set_microtask_pending(new_state); | 14822 isolate->set_microtask_pending(new_state); |
| 14830 return isolate->heap()->ToBoolean(old_state); | 14823 return isolate->heap()->ToBoolean(old_state); |
| 14831 } | 14824 } |
| 14832 | 14825 |
| 14833 | 14826 |
| 14834 RUNTIME_FUNCTION(MaybeObject*, Runtime_RunMicrotasks) { | 14827 RUNTIME_FUNCTION(Runtime_RunMicrotasks) { |
| 14835 HandleScope scope(isolate); | 14828 HandleScope scope(isolate); |
| 14836 ASSERT(args.length() == 0); | 14829 ASSERT(args.length() == 0); |
| 14837 if (isolate->microtask_pending()) Execution::RunMicrotasks(isolate); | 14830 if (isolate->microtask_pending()) Execution::RunMicrotasks(isolate); |
| 14838 return isolate->heap()->undefined_value(); | 14831 return isolate->heap()->undefined_value(); |
| 14839 } | 14832 } |
| 14840 | 14833 |
| 14841 | 14834 |
| 14842 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetMicrotaskState) { | 14835 RUNTIME_FUNCTION(Runtime_GetMicrotaskState) { |
| 14843 SealHandleScope shs(isolate); | 14836 SealHandleScope shs(isolate); |
| 14844 ASSERT(args.length() == 0); | 14837 ASSERT(args.length() == 0); |
| 14845 return isolate->heap()->microtask_state(); | 14838 return isolate->heap()->microtask_state(); |
| 14846 } | 14839 } |
| 14847 | 14840 |
| 14848 | 14841 |
| 14849 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetObservationState) { | 14842 RUNTIME_FUNCTION(Runtime_GetObservationState) { |
| 14850 SealHandleScope shs(isolate); | 14843 SealHandleScope shs(isolate); |
| 14851 ASSERT(args.length() == 0); | 14844 ASSERT(args.length() == 0); |
| 14852 return isolate->heap()->observation_state(); | 14845 return isolate->heap()->observation_state(); |
| 14853 } | 14846 } |
| 14854 | 14847 |
| 14855 | 14848 |
| 14856 RUNTIME_FUNCTION(MaybeObject*, Runtime_ObservationWeakMapCreate) { | 14849 RUNTIME_FUNCTION(Runtime_ObservationWeakMapCreate) { |
| 14857 HandleScope scope(isolate); | 14850 HandleScope scope(isolate); |
| 14858 ASSERT(args.length() == 0); | 14851 ASSERT(args.length() == 0); |
| 14859 // TODO(adamk): Currently this runtime function is only called three times per | 14852 // TODO(adamk): Currently this runtime function is only called three times per |
| 14860 // isolate. If it's called more often, the map should be moved into the | 14853 // isolate. If it's called more often, the map should be moved into the |
| 14861 // strong root list. | 14854 // strong root list. |
| 14862 Handle<Map> map = | 14855 Handle<Map> map = |
| 14863 isolate->factory()->NewMap(JS_WEAK_MAP_TYPE, JSWeakMap::kSize); | 14856 isolate->factory()->NewMap(JS_WEAK_MAP_TYPE, JSWeakMap::kSize); |
| 14864 Handle<JSWeakMap> weakmap = | 14857 Handle<JSWeakMap> weakmap = |
| 14865 Handle<JSWeakMap>::cast(isolate->factory()->NewJSObjectFromMap(map)); | 14858 Handle<JSWeakMap>::cast(isolate->factory()->NewJSObjectFromMap(map)); |
| 14866 return WeakCollectionInitialize(isolate, weakmap); | 14859 return *WeakCollectionInitialize(isolate, weakmap); |
| 14867 } | 14860 } |
| 14868 | 14861 |
| 14869 | 14862 |
| 14870 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsAccessAllowedForObserver) { | 14863 RUNTIME_FUNCTION(Runtime_IsAccessAllowedForObserver) { |
| 14871 HandleScope scope(isolate); | 14864 HandleScope scope(isolate); |
| 14872 ASSERT(args.length() == 3); | 14865 ASSERT(args.length() == 3); |
| 14873 CONVERT_ARG_HANDLE_CHECKED(JSFunction, observer, 0); | 14866 CONVERT_ARG_HANDLE_CHECKED(JSFunction, observer, 0); |
| 14874 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 1); | 14867 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 1); |
| 14875 ASSERT(object->map()->is_access_check_needed()); | 14868 ASSERT(object->map()->is_access_check_needed()); |
| 14876 CONVERT_ARG_HANDLE_CHECKED(Object, key, 2); | 14869 CONVERT_ARG_HANDLE_CHECKED(Object, key, 2); |
| 14877 SaveContext save(isolate); | 14870 SaveContext save(isolate); |
| 14878 isolate->set_context(observer->context()); | 14871 isolate->set_context(observer->context()); |
| 14879 if (!isolate->MayNamedAccess( | 14872 if (!isolate->MayNamedAccess( |
| 14880 object, isolate->factory()->undefined_value(), v8::ACCESS_KEYS)) { | 14873 object, isolate->factory()->undefined_value(), v8::ACCESS_KEYS)) { |
| 14881 return isolate->heap()->false_value(); | 14874 return isolate->heap()->false_value(); |
| 14882 } | 14875 } |
| 14883 bool access_allowed = false; | 14876 bool access_allowed = false; |
| 14884 uint32_t index = 0; | 14877 uint32_t index = 0; |
| 14885 if (key->ToArrayIndex(&index) || | 14878 if (key->ToArrayIndex(&index) || |
| 14886 (key->IsString() && String::cast(*key)->AsArrayIndex(&index))) { | 14879 (key->IsString() && String::cast(*key)->AsArrayIndex(&index))) { |
| 14887 access_allowed = | 14880 access_allowed = |
| 14888 isolate->MayIndexedAccess(object, index, v8::ACCESS_GET) && | 14881 isolate->MayIndexedAccess(object, index, v8::ACCESS_GET) && |
| 14889 isolate->MayIndexedAccess(object, index, v8::ACCESS_HAS); | 14882 isolate->MayIndexedAccess(object, index, v8::ACCESS_HAS); |
| 14890 } else { | 14883 } else { |
| 14891 access_allowed = | 14884 access_allowed = |
| 14892 isolate->MayNamedAccess(object, key, v8::ACCESS_GET) && | 14885 isolate->MayNamedAccess(object, key, v8::ACCESS_GET) && |
| 14893 isolate->MayNamedAccess(object, key, v8::ACCESS_HAS); | 14886 isolate->MayNamedAccess(object, key, v8::ACCESS_HAS); |
| 14894 } | 14887 } |
| 14895 return isolate->heap()->ToBoolean(access_allowed); | 14888 return isolate->heap()->ToBoolean(access_allowed); |
| 14896 } | 14889 } |
| 14897 | 14890 |
| 14898 | 14891 |
| 14899 static MaybeObject* ArrayConstructorCommon(Isolate* isolate, | 14892 static Object* ArrayConstructorCommon(Isolate* isolate, |
| 14900 Handle<JSFunction> constructor, | 14893 Handle<JSFunction> constructor, |
| 14901 Handle<AllocationSite> site, | 14894 Handle<AllocationSite> site, |
| 14902 Arguments* caller_args) { | 14895 Arguments* caller_args) { |
| 14903 Factory* factory = isolate->factory(); | 14896 Factory* factory = isolate->factory(); |
| 14904 | 14897 |
| 14905 bool holey = false; | 14898 bool holey = false; |
| 14906 bool can_use_type_feedback = true; | 14899 bool can_use_type_feedback = true; |
| 14907 if (caller_args->length() == 1) { | 14900 if (caller_args->length() == 1) { |
| 14908 Handle<Object> argument_one = caller_args->at<Object>(0); | 14901 Handle<Object> argument_one = caller_args->at<Object>(0); |
| 14909 if (argument_one->IsSmi()) { | 14902 if (argument_one->IsSmi()) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14967 !can_use_type_feedback)) { | 14960 !can_use_type_feedback)) { |
| 14968 // The arguments passed in caused a transition. This kind of complexity | 14961 // The arguments passed in caused a transition. This kind of complexity |
| 14969 // can't be dealt with in the inlined hydrogen array constructor case. | 14962 // can't be dealt with in the inlined hydrogen array constructor case. |
| 14970 // We must mark the allocationsite as un-inlinable. | 14963 // We must mark the allocationsite as un-inlinable. |
| 14971 site->SetDoNotInlineCall(); | 14964 site->SetDoNotInlineCall(); |
| 14972 } | 14965 } |
| 14973 return *array; | 14966 return *array; |
| 14974 } | 14967 } |
| 14975 | 14968 |
| 14976 | 14969 |
| 14977 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_ArrayConstructor) { | 14970 RUNTIME_FUNCTION(RuntimeHidden_ArrayConstructor) { |
| 14978 HandleScope scope(isolate); | 14971 HandleScope scope(isolate); |
| 14979 // If we get 2 arguments then they are the stub parameters (constructor, type | 14972 // If we get 2 arguments then they are the stub parameters (constructor, type |
| 14980 // info). If we get 4, then the first one is a pointer to the arguments | 14973 // info). If we get 4, then the first one is a pointer to the arguments |
| 14981 // passed by the caller, and the last one is the length of the arguments | 14974 // passed by the caller, and the last one is the length of the arguments |
| 14982 // passed to the caller (redundant, but useful to check on the deoptimizer | 14975 // passed to the caller (redundant, but useful to check on the deoptimizer |
| 14983 // with an assert). | 14976 // with an assert). |
| 14984 Arguments empty_args(0, NULL); | 14977 Arguments empty_args(0, NULL); |
| 14985 bool no_caller_args = args.length() == 2; | 14978 bool no_caller_args = args.length() == 2; |
| 14986 ASSERT(no_caller_args || args.length() == 4); | 14979 ASSERT(no_caller_args || args.length() == 4); |
| 14987 int parameters_start = no_caller_args ? 0 : 1; | 14980 int parameters_start = no_caller_args ? 0 : 1; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 15004 ASSERT(!site->SitePointsToLiteral()); | 14997 ASSERT(!site->SitePointsToLiteral()); |
| 15005 } | 14998 } |
| 15006 | 14999 |
| 15007 return ArrayConstructorCommon(isolate, | 15000 return ArrayConstructorCommon(isolate, |
| 15008 constructor, | 15001 constructor, |
| 15009 site, | 15002 site, |
| 15010 caller_args); | 15003 caller_args); |
| 15011 } | 15004 } |
| 15012 | 15005 |
| 15013 | 15006 |
| 15014 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_InternalArrayConstructor) { | 15007 RUNTIME_FUNCTION(RuntimeHidden_InternalArrayConstructor) { |
| 15015 HandleScope scope(isolate); | 15008 HandleScope scope(isolate); |
| 15016 Arguments empty_args(0, NULL); | 15009 Arguments empty_args(0, NULL); |
| 15017 bool no_caller_args = args.length() == 1; | 15010 bool no_caller_args = args.length() == 1; |
| 15018 ASSERT(no_caller_args || args.length() == 3); | 15011 ASSERT(no_caller_args || args.length() == 3); |
| 15019 int parameters_start = no_caller_args ? 0 : 1; | 15012 int parameters_start = no_caller_args ? 0 : 1; |
| 15020 Arguments* caller_args = no_caller_args | 15013 Arguments* caller_args = no_caller_args |
| 15021 ? &empty_args | 15014 ? &empty_args |
| 15022 : reinterpret_cast<Arguments*>(args[0]); | 15015 : reinterpret_cast<Arguments*>(args[0]); |
| 15023 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, parameters_start); | 15016 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, parameters_start); |
| 15024 #ifdef DEBUG | 15017 #ifdef DEBUG |
| 15025 if (!no_caller_args) { | 15018 if (!no_caller_args) { |
| 15026 CONVERT_SMI_ARG_CHECKED(arg_count, parameters_start + 1); | 15019 CONVERT_SMI_ARG_CHECKED(arg_count, parameters_start + 1); |
| 15027 ASSERT(arg_count == caller_args->length()); | 15020 ASSERT(arg_count == caller_args->length()); |
| 15028 } | 15021 } |
| 15029 #endif | 15022 #endif |
| 15030 return ArrayConstructorCommon(isolate, | 15023 return ArrayConstructorCommon(isolate, |
| 15031 constructor, | 15024 constructor, |
| 15032 Handle<AllocationSite>::null(), | 15025 Handle<AllocationSite>::null(), |
| 15033 caller_args); | 15026 caller_args); |
| 15034 } | 15027 } |
| 15035 | 15028 |
| 15036 | 15029 |
| 15037 RUNTIME_FUNCTION(MaybeObject*, Runtime_MaxSmi) { | 15030 RUNTIME_FUNCTION(Runtime_MaxSmi) { |
| 15038 ASSERT(args.length() == 0); | 15031 ASSERT(args.length() == 0); |
| 15039 return Smi::FromInt(Smi::kMaxValue); | 15032 return Smi::FromInt(Smi::kMaxValue); |
| 15040 } | 15033 } |
| 15041 | 15034 |
| 15042 | 15035 |
| 15043 // ---------------------------------------------------------------------------- | 15036 // ---------------------------------------------------------------------------- |
| 15044 // Implementation of Runtime | 15037 // Implementation of Runtime |
| 15045 | 15038 |
| 15046 #define F(name, number_of_args, result_size) \ | 15039 #define F(name, number_of_args, result_size) \ |
| 15047 { Runtime::k##name, Runtime::RUNTIME, #name, \ | 15040 { Runtime::k##name, Runtime::RUNTIME, #name, \ |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15103 return &(kIntrinsicFunctions[function_index]); | 15096 return &(kIntrinsicFunctions[function_index]); |
| 15104 } | 15097 } |
| 15105 return NULL; | 15098 return NULL; |
| 15106 } | 15099 } |
| 15107 | 15100 |
| 15108 | 15101 |
| 15109 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { | 15102 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { |
| 15110 return &(kIntrinsicFunctions[static_cast<int>(id)]); | 15103 return &(kIntrinsicFunctions[static_cast<int>(id)]); |
| 15111 } | 15104 } |
| 15112 | 15105 |
| 15113 | |
| 15114 void Runtime::PerformGC(Object* result, Isolate* isolate) { | |
| 15115 Failure* failure = Failure::cast(result); | |
| 15116 if (failure->IsRetryAfterGC()) { | |
| 15117 if (isolate->heap()->new_space()->AddFreshPage()) { | |
| 15118 return; | |
| 15119 } | |
| 15120 | |
| 15121 // Try to do a garbage collection; ignore it if it fails. The C | |
| 15122 // entry stub will throw an out-of-memory exception in that case. | |
| 15123 isolate->heap()->CollectGarbage(failure->allocation_space(), | |
| 15124 "Runtime::PerformGC"); | |
| 15125 } else { | |
| 15126 // Handle last resort GC and make sure to allow future allocations | |
| 15127 // to grow the heap without causing GCs (if possible). | |
| 15128 isolate->counters()->gc_last_resort_from_js()->Increment(); | |
| 15129 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | |
| 15130 "Runtime::PerformGC"); | |
| 15131 } | |
| 15132 } | |
| 15133 | |
| 15134 | |
| 15135 void Runtime::OutOfMemory() { | |
| 15136 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); | |
| 15137 UNREACHABLE(); | |
| 15138 } | |
| 15139 | |
| 15140 } } // namespace v8::internal | 15106 } } // namespace v8::internal |
| OLD | NEW |