| 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 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 | 547 |
| 548 literals->set(literals_index, *site); | 548 literals->set(literals_index, *site); |
| 549 } else { | 549 } else { |
| 550 site = Handle<AllocationSite>::cast(literal_site); | 550 site = Handle<AllocationSite>::cast(literal_site); |
| 551 } | 551 } |
| 552 | 552 |
| 553 return site; | 553 return site; |
| 554 } | 554 } |
| 555 | 555 |
| 556 | 556 |
| 557 static MaybeObject* CreateArrayLiteralImpl(Isolate* isolate, |
| 558 Handle<FixedArray> literals, |
| 559 int literals_index, |
| 560 Handle<FixedArray> elements, |
| 561 int flags) { |
| 562 Handle<AllocationSite> site = GetLiteralAllocationSite(isolate, literals, |
| 563 literals_index, elements); |
| 564 RETURN_IF_EMPTY_HANDLE(isolate, site); |
| 565 |
| 566 bool enable_mementos = (flags & ArrayLiteral::kDisableMementos) == 0; |
| 567 Handle<JSObject> boilerplate(JSObject::cast(site->transition_info())); |
| 568 AllocationSiteUsageContext usage_context(isolate, site, enable_mementos); |
| 569 usage_context.EnterNewScope(); |
| 570 JSObject::DeepCopyHints hints = (flags & ArrayLiteral::kShallowElements) == 0 |
| 571 ? JSObject::kNoHints |
| 572 : JSObject::kObjectIsShallowArray; |
| 573 Handle<JSObject> copy = JSObject::DeepCopy(boilerplate, &usage_context, |
| 574 hints); |
| 575 usage_context.ExitScope(site, boilerplate); |
| 576 RETURN_IF_EMPTY_HANDLE(isolate, copy); |
| 577 return *copy; |
| 578 } |
| 579 |
| 580 |
| 557 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteral) { | 581 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteral) { |
| 558 HandleScope scope(isolate); | 582 HandleScope scope(isolate); |
| 583 ASSERT(args.length() == 4); |
| 584 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); |
| 585 CONVERT_SMI_ARG_CHECKED(literals_index, 1); |
| 586 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); |
| 587 CONVERT_SMI_ARG_CHECKED(flags, 3); |
| 588 |
| 589 return CreateArrayLiteralImpl(isolate, literals, literals_index, elements, |
| 590 flags); |
| 591 } |
| 592 |
| 593 |
| 594 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteralStubBailout) { |
| 595 HandleScope scope(isolate); |
| 559 ASSERT(args.length() == 3); | 596 ASSERT(args.length() == 3); |
| 560 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); | 597 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); |
| 561 CONVERT_SMI_ARG_CHECKED(literals_index, 1); | 598 CONVERT_SMI_ARG_CHECKED(literals_index, 1); |
| 562 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); | 599 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); |
| 563 | 600 |
| 564 Handle<AllocationSite> site = GetLiteralAllocationSite(isolate, literals, | 601 return CreateArrayLiteralImpl(isolate, literals, literals_index, elements, |
| 565 literals_index, elements); | 602 ArrayLiteral::kShallowElements); |
| 566 RETURN_IF_EMPTY_HANDLE(isolate, site); | |
| 567 | |
| 568 Handle<JSObject> boilerplate(JSObject::cast(site->transition_info())); | |
| 569 AllocationSiteUsageContext usage_context(isolate, site, true); | |
| 570 usage_context.EnterNewScope(); | |
| 571 Handle<JSObject> copy = JSObject::DeepCopy(boilerplate, &usage_context); | |
| 572 usage_context.ExitScope(site, boilerplate); | |
| 573 RETURN_IF_EMPTY_HANDLE(isolate, copy); | |
| 574 return *copy; | |
| 575 } | 603 } |
| 576 | 604 |
| 577 | 605 |
| 578 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateSymbol) { | 606 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateSymbol) { |
| 579 HandleScope scope(isolate); | 607 HandleScope scope(isolate); |
| 580 ASSERT(args.length() == 1); | 608 ASSERT(args.length() == 1); |
| 581 Handle<Object> name(args[0], isolate); | 609 Handle<Object> name(args[0], isolate); |
| 582 RUNTIME_ASSERT(name->IsString() || name->IsUndefined()); | 610 RUNTIME_ASSERT(name->IsString() || name->IsUndefined()); |
| 583 Symbol* symbol; | 611 Symbol* symbol; |
| 584 MaybeObject* maybe = isolate->heap()->AllocateSymbol(); | 612 MaybeObject* maybe = isolate->heap()->AllocateSymbol(); |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayBufferIsView) { | 856 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayBufferIsView) { |
| 829 HandleScope scope(isolate); | 857 HandleScope scope(isolate); |
| 830 ASSERT(args.length() == 1); | 858 ASSERT(args.length() == 1); |
| 831 CONVERT_ARG_CHECKED(Object, object, 0); | 859 CONVERT_ARG_CHECKED(Object, object, 0); |
| 832 return object->IsJSArrayBufferView() | 860 return object->IsJSArrayBufferView() |
| 833 ? isolate->heap()->true_value() | 861 ? isolate->heap()->true_value() |
| 834 : isolate->heap()->false_value(); | 862 : isolate->heap()->false_value(); |
| 835 } | 863 } |
| 836 | 864 |
| 837 | 865 |
| 838 enum TypedArrayId { | 866 void Runtime::ArrayIdToTypeAndSize( |
| 839 // arrayIds below should be synchromized with typedarray.js natives. | |
| 840 ARRAY_ID_UINT8 = 1, | |
| 841 ARRAY_ID_INT8 = 2, | |
| 842 ARRAY_ID_UINT16 = 3, | |
| 843 ARRAY_ID_INT16 = 4, | |
| 844 ARRAY_ID_UINT32 = 5, | |
| 845 ARRAY_ID_INT32 = 6, | |
| 846 ARRAY_ID_FLOAT32 = 7, | |
| 847 ARRAY_ID_FLOAT64 = 8, | |
| 848 ARRAY_ID_UINT8C = 9 | |
| 849 }; | |
| 850 | |
| 851 static void ArrayIdToTypeAndSize( | |
| 852 int arrayId, ExternalArrayType* array_type, size_t* element_size) { | 867 int arrayId, ExternalArrayType* array_type, size_t* element_size) { |
| 853 switch (arrayId) { | 868 switch (arrayId) { |
| 854 case ARRAY_ID_UINT8: | 869 case ARRAY_ID_UINT8: |
| 855 *array_type = kExternalUnsignedByteArray; | 870 *array_type = kExternalUnsignedByteArray; |
| 856 *element_size = 1; | 871 *element_size = 1; |
| 857 break; | 872 break; |
| 858 case ARRAY_ID_INT8: | 873 case ARRAY_ID_INT8: |
| 859 *array_type = kExternalByteArray; | 874 *array_type = kExternalByteArray; |
| 860 *element_size = 1; | 875 *element_size = 1; |
| 861 break; | 876 break; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 903 CONVERT_ARG_HANDLE_CHECKED(Object, byte_length_object, 4); | 918 CONVERT_ARG_HANDLE_CHECKED(Object, byte_length_object, 4); |
| 904 | 919 |
| 905 ASSERT(holder->GetInternalFieldCount() == | 920 ASSERT(holder->GetInternalFieldCount() == |
| 906 v8::ArrayBufferView::kInternalFieldCount); | 921 v8::ArrayBufferView::kInternalFieldCount); |
| 907 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { | 922 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { |
| 908 holder->SetInternalField(i, Smi::FromInt(0)); | 923 holder->SetInternalField(i, Smi::FromInt(0)); |
| 909 } | 924 } |
| 910 | 925 |
| 911 ExternalArrayType array_type = kExternalByteArray; // Bogus initialization. | 926 ExternalArrayType array_type = kExternalByteArray; // Bogus initialization. |
| 912 size_t element_size = 1; // Bogus initialization. | 927 size_t element_size = 1; // Bogus initialization. |
| 913 ArrayIdToTypeAndSize(arrayId, &array_type, &element_size); | 928 Runtime::ArrayIdToTypeAndSize(arrayId, &array_type, &element_size); |
| 914 | 929 |
| 915 holder->set_buffer(*buffer); | 930 holder->set_buffer(*buffer); |
| 916 holder->set_byte_offset(*byte_offset_object); | 931 holder->set_byte_offset(*byte_offset_object); |
| 917 holder->set_byte_length(*byte_length_object); | 932 holder->set_byte_length(*byte_length_object); |
| 918 | 933 |
| 919 size_t byte_offset = NumberToSize(isolate, *byte_offset_object); | 934 size_t byte_offset = NumberToSize(isolate, *byte_offset_object); |
| 920 size_t byte_length = NumberToSize(isolate, *byte_length_object); | 935 size_t byte_length = NumberToSize(isolate, *byte_length_object); |
| 921 ASSERT(byte_length % element_size == 0); | 936 ASSERT(byte_length % element_size == 0); |
| 922 size_t length = byte_length / element_size; | 937 size_t length = byte_length / element_size; |
| 923 | 938 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 955 CONVERT_ARG_HANDLE_CHECKED(Object, length_obj, 3); | 970 CONVERT_ARG_HANDLE_CHECKED(Object, length_obj, 3); |
| 956 | 971 |
| 957 ASSERT(holder->GetInternalFieldCount() == | 972 ASSERT(holder->GetInternalFieldCount() == |
| 958 v8::ArrayBufferView::kInternalFieldCount); | 973 v8::ArrayBufferView::kInternalFieldCount); |
| 959 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { | 974 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { |
| 960 holder->SetInternalField(i, Smi::FromInt(0)); | 975 holder->SetInternalField(i, Smi::FromInt(0)); |
| 961 } | 976 } |
| 962 | 977 |
| 963 ExternalArrayType array_type = kExternalByteArray; // Bogus initialization. | 978 ExternalArrayType array_type = kExternalByteArray; // Bogus initialization. |
| 964 size_t element_size = 1; // Bogus initialization. | 979 size_t element_size = 1; // Bogus initialization. |
| 965 ArrayIdToTypeAndSize(arrayId, &array_type, &element_size); | 980 Runtime::ArrayIdToTypeAndSize(arrayId, &array_type, &element_size); |
| 966 | 981 |
| 967 Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer(); | 982 Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer(); |
| 968 size_t length = NumberToSize(isolate, *length_obj); | 983 size_t length = NumberToSize(isolate, *length_obj); |
| 969 | 984 |
| 970 if ((length > static_cast<unsigned>(Smi::kMaxValue)) || | 985 if ((length > static_cast<unsigned>(Smi::kMaxValue)) || |
| 971 (length > (kMaxInt / element_size))) { | 986 (length > (kMaxInt / element_size))) { |
| 972 return isolate->Throw(*isolate->factory()-> | 987 return isolate->Throw(*isolate->factory()-> |
| 973 NewRangeError("invalid_typed_array_length", | 988 NewRangeError("invalid_typed_array_length", |
| 974 HandleVector<Object>(NULL, 0))); | 989 HandleVector<Object>(NULL, 0))); |
| 975 } | 990 } |
| (...skipping 1665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2641 InstallBuiltin(isolate, holder, "shift", Builtins::kArrayShift); | 2656 InstallBuiltin(isolate, holder, "shift", Builtins::kArrayShift); |
| 2642 InstallBuiltin(isolate, holder, "unshift", Builtins::kArrayUnshift); | 2657 InstallBuiltin(isolate, holder, "unshift", Builtins::kArrayUnshift); |
| 2643 InstallBuiltin(isolate, holder, "slice", Builtins::kArraySlice); | 2658 InstallBuiltin(isolate, holder, "slice", Builtins::kArraySlice); |
| 2644 InstallBuiltin(isolate, holder, "splice", Builtins::kArraySplice); | 2659 InstallBuiltin(isolate, holder, "splice", Builtins::kArraySplice); |
| 2645 InstallBuiltin(isolate, holder, "concat", Builtins::kArrayConcat); | 2660 InstallBuiltin(isolate, holder, "concat", Builtins::kArrayConcat); |
| 2646 | 2661 |
| 2647 return *holder; | 2662 return *holder; |
| 2648 } | 2663 } |
| 2649 | 2664 |
| 2650 | 2665 |
| 2666 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsCallable) { |
| 2667 SealHandleScope shs(isolate); |
| 2668 ASSERT(args.length() == 1); |
| 2669 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 2670 return isolate->heap()->ToBoolean(obj->IsCallable()); |
| 2671 } |
| 2672 |
| 2673 |
| 2651 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsClassicModeFunction) { | 2674 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsClassicModeFunction) { |
| 2652 SealHandleScope shs(isolate); | 2675 SealHandleScope shs(isolate); |
| 2653 ASSERT(args.length() == 1); | 2676 ASSERT(args.length() == 1); |
| 2654 CONVERT_ARG_CHECKED(JSReceiver, callable, 0); | 2677 CONVERT_ARG_CHECKED(JSReceiver, callable, 0); |
| 2655 if (!callable->IsJSFunction()) { | 2678 if (!callable->IsJSFunction()) { |
| 2656 HandleScope scope(isolate); | 2679 HandleScope scope(isolate); |
| 2657 bool threw = false; | 2680 bool threw = false; |
| 2658 Handle<Object> delegate = Execution::TryGetFunctionDelegate( | 2681 Handle<Object> delegate = Execution::TryGetFunctionDelegate( |
| 2659 isolate, Handle<JSReceiver>(callable), &threw); | 2682 isolate, Handle<JSReceiver>(callable), &threw); |
| 2660 if (threw) return Failure::Exception(); | 2683 if (threw) return Failure::Exception(); |
| (...skipping 1780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4441 } else { | 4464 } else { |
| 4442 CONVERT_DOUBLE_ARG_CHECKED(from_number, 1); | 4465 CONVERT_DOUBLE_ARG_CHECKED(from_number, 1); |
| 4443 CONVERT_DOUBLE_ARG_CHECKED(to_number, 2); | 4466 CONVERT_DOUBLE_ARG_CHECKED(to_number, 2); |
| 4444 start = FastD2IChecked(from_number); | 4467 start = FastD2IChecked(from_number); |
| 4445 end = FastD2IChecked(to_number); | 4468 end = FastD2IChecked(to_number); |
| 4446 } | 4469 } |
| 4447 RUNTIME_ASSERT(end >= start); | 4470 RUNTIME_ASSERT(end >= start); |
| 4448 RUNTIME_ASSERT(start >= 0); | 4471 RUNTIME_ASSERT(start >= 0); |
| 4449 RUNTIME_ASSERT(end <= value->length()); | 4472 RUNTIME_ASSERT(end <= value->length()); |
| 4450 isolate->counters()->sub_string_runtime()->Increment(); | 4473 isolate->counters()->sub_string_runtime()->Increment(); |
| 4451 if (end - start == 1) { | |
| 4452 return isolate->heap()->LookupSingleCharacterStringFromCode( | |
| 4453 value->Get(start)); | |
| 4454 } | |
| 4455 return value->SubString(start, end); | 4474 return value->SubString(start, end); |
| 4456 } | 4475 } |
| 4457 | 4476 |
| 4458 | 4477 |
| 4459 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringMatch) { | 4478 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringMatch) { |
| 4460 HandleScope handles(isolate); | 4479 HandleScope handles(isolate); |
| 4461 ASSERT_EQ(3, args.length()); | 4480 ASSERT_EQ(3, args.length()); |
| 4462 | 4481 |
| 4463 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); | 4482 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); |
| 4464 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1); | 4483 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1); |
| (...skipping 3164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7629 : StringCharacterStreamCompare(isolate->runtime_state(), x, y); | 7648 : StringCharacterStreamCompare(isolate->runtime_state(), x, y); |
| 7630 } | 7649 } |
| 7631 | 7650 |
| 7632 | 7651 |
| 7633 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_acos) { | 7652 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_acos) { |
| 7634 SealHandleScope shs(isolate); | 7653 SealHandleScope shs(isolate); |
| 7635 ASSERT(args.length() == 1); | 7654 ASSERT(args.length() == 1); |
| 7636 isolate->counters()->math_acos()->Increment(); | 7655 isolate->counters()->math_acos()->Increment(); |
| 7637 | 7656 |
| 7638 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7657 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7639 return isolate->transcendental_cache()->Get(TranscendentalCache::ACOS, x); | 7658 return isolate->heap()->AllocateHeapNumber(acos(x)); |
| 7640 } | 7659 } |
| 7641 | 7660 |
| 7642 | 7661 |
| 7643 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_asin) { | 7662 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_asin) { |
| 7644 SealHandleScope shs(isolate); | 7663 SealHandleScope shs(isolate); |
| 7645 ASSERT(args.length() == 1); | 7664 ASSERT(args.length() == 1); |
| 7646 isolate->counters()->math_asin()->Increment(); | 7665 isolate->counters()->math_asin()->Increment(); |
| 7647 | 7666 |
| 7648 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7667 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7649 return isolate->transcendental_cache()->Get(TranscendentalCache::ASIN, x); | 7668 return isolate->heap()->AllocateHeapNumber(asin(x)); |
| 7650 } | 7669 } |
| 7651 | 7670 |
| 7652 | 7671 |
| 7653 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan) { | 7672 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan) { |
| 7654 SealHandleScope shs(isolate); | 7673 SealHandleScope shs(isolate); |
| 7655 ASSERT(args.length() == 1); | 7674 ASSERT(args.length() == 1); |
| 7656 isolate->counters()->math_atan()->Increment(); | 7675 isolate->counters()->math_atan()->Increment(); |
| 7657 | 7676 |
| 7658 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7677 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7659 return isolate->transcendental_cache()->Get(TranscendentalCache::ATAN, x); | 7678 return isolate->heap()->AllocateHeapNumber(atan(x)); |
| 7660 } | 7679 } |
| 7661 | 7680 |
| 7662 | 7681 |
| 7663 static const double kPiDividedBy4 = 0.78539816339744830962; | 7682 static const double kPiDividedBy4 = 0.78539816339744830962; |
| 7664 | 7683 |
| 7665 | 7684 |
| 7666 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan2) { | 7685 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan2) { |
| 7667 SealHandleScope shs(isolate); | 7686 SealHandleScope shs(isolate); |
| 7668 ASSERT(args.length() == 2); | 7687 ASSERT(args.length() == 2); |
| 7669 isolate->counters()->math_atan2()->Increment(); | 7688 isolate->counters()->math_atan2()->Increment(); |
| 7670 | 7689 |
| 7671 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7690 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7672 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7691 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
| 7673 double result; | 7692 double result; |
| 7674 if (std::isinf(x) && std::isinf(y)) { | 7693 if (std::isinf(x) && std::isinf(y)) { |
| 7675 // Make sure that the result in case of two infinite arguments | 7694 // Make sure that the result in case of two infinite arguments |
| 7676 // is a multiple of Pi / 4. The sign of the result is determined | 7695 // is a multiple of Pi / 4. The sign of the result is determined |
| 7677 // by the first argument (x) and the sign of the second argument | 7696 // by the first argument (x) and the sign of the second argument |
| 7678 // determines the multiplier: one or three. | 7697 // determines the multiplier: one or three. |
| 7679 int multiplier = (x < 0) ? -1 : 1; | 7698 int multiplier = (x < 0) ? -1 : 1; |
| 7680 if (y < 0) multiplier *= 3; | 7699 if (y < 0) multiplier *= 3; |
| 7681 result = multiplier * kPiDividedBy4; | 7700 result = multiplier * kPiDividedBy4; |
| 7682 } else { | 7701 } else { |
| 7683 result = atan2(x, y); | 7702 result = atan2(x, y); |
| 7684 } | 7703 } |
| 7685 return isolate->heap()->AllocateHeapNumber(result); | 7704 return isolate->heap()->AllocateHeapNumber(result); |
| 7686 } | 7705 } |
| 7687 | 7706 |
| 7688 | 7707 |
| 7689 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_ceil) { | |
| 7690 SealHandleScope shs(isolate); | |
| 7691 ASSERT(args.length() == 1); | |
| 7692 isolate->counters()->math_ceil()->Increment(); | |
| 7693 | |
| 7694 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | |
| 7695 return isolate->heap()->NumberFromDouble(ceiling(x)); | |
| 7696 } | |
| 7697 | |
| 7698 | |
| 7699 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_cos) { | |
| 7700 SealHandleScope shs(isolate); | |
| 7701 ASSERT(args.length() == 1); | |
| 7702 isolate->counters()->math_cos()->Increment(); | |
| 7703 | |
| 7704 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | |
| 7705 return isolate->transcendental_cache()->Get(TranscendentalCache::COS, x); | |
| 7706 } | |
| 7707 | |
| 7708 | |
| 7709 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_exp) { | 7708 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_exp) { |
| 7710 SealHandleScope shs(isolate); | 7709 SealHandleScope shs(isolate); |
| 7711 ASSERT(args.length() == 1); | 7710 ASSERT(args.length() == 1); |
| 7712 isolate->counters()->math_exp()->Increment(); | 7711 isolate->counters()->math_exp()->Increment(); |
| 7713 | 7712 |
| 7714 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7713 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7715 lazily_initialize_fast_exp(); | 7714 lazily_initialize_fast_exp(); |
| 7716 return isolate->heap()->NumberFromDouble(fast_exp(x)); | 7715 return isolate->heap()->NumberFromDouble(fast_exp(x)); |
| 7717 } | 7716 } |
| 7718 | 7717 |
| 7719 | 7718 |
| 7720 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_floor) { | 7719 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_floor) { |
| 7721 SealHandleScope shs(isolate); | 7720 SealHandleScope shs(isolate); |
| 7722 ASSERT(args.length() == 1); | 7721 ASSERT(args.length() == 1); |
| 7723 isolate->counters()->math_floor()->Increment(); | 7722 isolate->counters()->math_floor()->Increment(); |
| 7724 | 7723 |
| 7725 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7724 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7726 return isolate->heap()->NumberFromDouble(floor(x)); | 7725 return isolate->heap()->NumberFromDouble(floor(x)); |
| 7727 } | 7726 } |
| 7728 | 7727 |
| 7729 | 7728 |
| 7730 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_log) { | 7729 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_log) { |
| 7731 SealHandleScope shs(isolate); | 7730 SealHandleScope shs(isolate); |
| 7732 ASSERT(args.length() == 1); | 7731 ASSERT(args.length() == 1); |
| 7733 isolate->counters()->math_log()->Increment(); | 7732 isolate->counters()->math_log()->Increment(); |
| 7734 | 7733 |
| 7735 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7734 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7736 return isolate->transcendental_cache()->Get(TranscendentalCache::LOG, x); | 7735 return isolate->heap()->AllocateHeapNumber(fast_log(x)); |
| 7737 } | 7736 } |
| 7738 | 7737 |
| 7739 | 7738 |
| 7740 // Slow version of Math.pow. We check for fast paths for special cases. | 7739 // Slow version of Math.pow. We check for fast paths for special cases. |
| 7741 // Used if SSE2/VFP3 is not available. | 7740 // Used if SSE2/VFP3 is not available. |
| 7742 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow) { | 7741 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow) { |
| 7743 SealHandleScope shs(isolate); | 7742 SealHandleScope shs(isolate); |
| 7744 ASSERT(args.length() == 2); | 7743 ASSERT(args.length() == 2); |
| 7745 isolate->counters()->math_pow()->Increment(); | 7744 isolate->counters()->math_pow()->Increment(); |
| 7746 | 7745 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7815 return number; | 7814 return number; |
| 7816 } | 7815 } |
| 7817 | 7816 |
| 7818 if (sign && value >= -0.5) return isolate->heap()->minus_zero_value(); | 7817 if (sign && value >= -0.5) return isolate->heap()->minus_zero_value(); |
| 7819 | 7818 |
| 7820 // Do not call NumberFromDouble() to avoid extra checks. | 7819 // Do not call NumberFromDouble() to avoid extra checks. |
| 7821 return isolate->heap()->AllocateHeapNumber(floor(value + 0.5)); | 7820 return isolate->heap()->AllocateHeapNumber(floor(value + 0.5)); |
| 7822 } | 7821 } |
| 7823 | 7822 |
| 7824 | 7823 |
| 7825 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_sin) { | |
| 7826 SealHandleScope shs(isolate); | |
| 7827 ASSERT(args.length() == 1); | |
| 7828 isolate->counters()->math_sin()->Increment(); | |
| 7829 | |
| 7830 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | |
| 7831 return isolate->transcendental_cache()->Get(TranscendentalCache::SIN, x); | |
| 7832 } | |
| 7833 | |
| 7834 | |
| 7835 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_sqrt) { | 7824 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_sqrt) { |
| 7836 SealHandleScope shs(isolate); | 7825 SealHandleScope shs(isolate); |
| 7837 ASSERT(args.length() == 1); | 7826 ASSERT(args.length() == 1); |
| 7838 isolate->counters()->math_sqrt()->Increment(); | 7827 isolate->counters()->math_sqrt()->Increment(); |
| 7839 | 7828 |
| 7840 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7829 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7841 return isolate->heap()->AllocateHeapNumber(fast_sqrt(x)); | 7830 return isolate->heap()->AllocateHeapNumber(fast_sqrt(x)); |
| 7842 } | 7831 } |
| 7843 | 7832 |
| 7844 | 7833 |
| 7845 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_tan) { | |
| 7846 SealHandleScope shs(isolate); | |
| 7847 ASSERT(args.length() == 1); | |
| 7848 isolate->counters()->math_tan()->Increment(); | |
| 7849 | |
| 7850 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | |
| 7851 return isolate->transcendental_cache()->Get(TranscendentalCache::TAN, x); | |
| 7852 } | |
| 7853 | |
| 7854 | |
| 7855 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateMakeDay) { | 7834 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateMakeDay) { |
| 7856 SealHandleScope shs(isolate); | 7835 SealHandleScope shs(isolate); |
| 7857 ASSERT(args.length() == 2); | 7836 ASSERT(args.length() == 2); |
| 7858 | 7837 |
| 7859 CONVERT_SMI_ARG_CHECKED(year, 0); | 7838 CONVERT_SMI_ARG_CHECKED(year, 0); |
| 7860 CONVERT_SMI_ARG_CHECKED(month, 1); | 7839 CONVERT_SMI_ARG_CHECKED(month, 1); |
| 7861 | 7840 |
| 7862 return Smi::FromInt(isolate->date_cache()->DaysFromYearMonth(year, month)); | 7841 return Smi::FromInt(isolate->date_cache()->DaysFromYearMonth(year, month)); |
| 7863 } | 7842 } |
| 7864 | 7843 |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8218 bound_function = Execution::TryGetConstructorDelegate(isolate, | 8197 bound_function = Execution::TryGetConstructorDelegate(isolate, |
| 8219 bound_function, | 8198 bound_function, |
| 8220 &exception_thrown); | 8199 &exception_thrown); |
| 8221 if (exception_thrown) return Failure::Exception(); | 8200 if (exception_thrown) return Failure::Exception(); |
| 8222 } | 8201 } |
| 8223 ASSERT(bound_function->IsJSFunction()); | 8202 ASSERT(bound_function->IsJSFunction()); |
| 8224 | 8203 |
| 8225 bool exception = false; | 8204 bool exception = false; |
| 8226 Handle<Object> result = | 8205 Handle<Object> result = |
| 8227 Execution::New(Handle<JSFunction>::cast(bound_function), | 8206 Execution::New(Handle<JSFunction>::cast(bound_function), |
| 8228 total_argc, *param_data, &exception); | 8207 total_argc, param_data.get(), &exception); |
| 8229 if (exception) { | 8208 if (exception) { |
| 8230 return Failure::Exception(); | 8209 return Failure::Exception(); |
| 8231 } | 8210 } |
| 8232 ASSERT(!result.is_null()); | 8211 ASSERT(!result.is_null()); |
| 8233 return *result; | 8212 return *result; |
| 8234 } | 8213 } |
| 8235 | 8214 |
| 8236 | 8215 |
| 8237 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewObject) { | 8216 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewObject) { |
| 8238 HandleScope scope(isolate); | 8217 HandleScope scope(isolate); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8391 | 8370 |
| 8392 | 8371 |
| 8393 RUNTIME_FUNCTION(MaybeObject*, Runtime_ConcurrentRecompile) { | 8372 RUNTIME_FUNCTION(MaybeObject*, Runtime_ConcurrentRecompile) { |
| 8394 HandleScope handle_scope(isolate); | 8373 HandleScope handle_scope(isolate); |
| 8395 ASSERT(args.length() == 1); | 8374 ASSERT(args.length() == 1); |
| 8396 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8375 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 8397 if (!AllowOptimization(isolate, function)) { | 8376 if (!AllowOptimization(isolate, function)) { |
| 8398 function->ReplaceCode(function->shared()->code()); | 8377 function->ReplaceCode(function->shared()->code()); |
| 8399 return isolate->heap()->undefined_value(); | 8378 return isolate->heap()->undefined_value(); |
| 8400 } | 8379 } |
| 8401 function->shared()->code()->set_profiler_ticks(0); | 8380 Handle<Code> shared_code(function->shared()->code()); |
| 8381 shared_code->set_profiler_ticks(0); |
| 8402 ASSERT(isolate->concurrent_recompilation_enabled()); | 8382 ASSERT(isolate->concurrent_recompilation_enabled()); |
| 8403 if (!Compiler::RecompileConcurrent(function)) { | 8383 if (!Compiler::RecompileConcurrent(function, shared_code)) { |
| 8404 function->ReplaceCode(function->shared()->code()); | 8384 function->ReplaceCode(*shared_code); |
| 8405 } | 8385 } |
| 8406 return isolate->heap()->undefined_value(); | 8386 return isolate->heap()->undefined_value(); |
| 8407 } | 8387 } |
| 8408 | 8388 |
| 8409 | 8389 |
| 8410 class ActivationsFinder : public ThreadVisitor { | 8390 class ActivationsFinder : public ThreadVisitor { |
| 8411 public: | 8391 public: |
| 8412 Code* code_; | 8392 Code* code_; |
| 8413 bool has_code_activations_; | 8393 bool has_code_activations_; |
| 8414 | 8394 |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8644 JavaScriptFrame* frame = it.frame(); | 8624 JavaScriptFrame* frame = it.frame(); |
| 8645 if (frame->is_optimized() && frame->function() == *function) return false; | 8625 if (frame->is_optimized() && frame->function() == *function) return false; |
| 8646 } | 8626 } |
| 8647 | 8627 |
| 8648 return true; | 8628 return true; |
| 8649 } | 8629 } |
| 8650 | 8630 |
| 8651 | 8631 |
| 8652 RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) { | 8632 RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) { |
| 8653 HandleScope scope(isolate); | 8633 HandleScope scope(isolate); |
| 8654 ASSERT(args.length() == 2); | 8634 ASSERT(args.length() == 1); |
| 8655 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8635 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 8656 CONVERT_NUMBER_CHECKED(uint32_t, pc_offset, Uint32, args[1]); | |
| 8657 Handle<Code> unoptimized(function->shared()->code(), isolate); | 8636 Handle<Code> unoptimized(function->shared()->code(), isolate); |
| 8658 | 8637 |
| 8659 #ifdef DEBUG | 8638 // Passing the PC in the javascript frame from the caller directly is |
| 8639 // not GC safe, so we walk the stack to get it. |
| 8660 JavaScriptFrameIterator it(isolate); | 8640 JavaScriptFrameIterator it(isolate); |
| 8661 JavaScriptFrame* frame = it.frame(); | 8641 JavaScriptFrame* frame = it.frame(); |
| 8642 if (!unoptimized->contains(frame->pc())) { |
| 8643 // Code on the stack may not be the code object referenced by the shared |
| 8644 // function info. It may have been replaced to include deoptimization data. |
| 8645 unoptimized = Handle<Code>(frame->LookupCode()); |
| 8646 } |
| 8647 |
| 8648 uint32_t pc_offset = static_cast<uint32_t>(frame->pc() - |
| 8649 unoptimized->instruction_start()); |
| 8650 |
| 8651 #ifdef DEBUG |
| 8662 ASSERT_EQ(frame->function(), *function); | 8652 ASSERT_EQ(frame->function(), *function); |
| 8663 ASSERT_EQ(frame->LookupCode(), *unoptimized); | 8653 ASSERT_EQ(frame->LookupCode(), *unoptimized); |
| 8664 ASSERT(unoptimized->contains(frame->pc())); | 8654 ASSERT(unoptimized->contains(frame->pc())); |
| 8665 | |
| 8666 ASSERT(pc_offset == | |
| 8667 static_cast<uint32_t>(frame->pc() - unoptimized->instruction_start())); | |
| 8668 #endif // DEBUG | 8655 #endif // DEBUG |
| 8669 | 8656 |
| 8670 // We're not prepared to handle a function with arguments object. | 8657 // We're not prepared to handle a function with arguments object. |
| 8671 ASSERT(!function->shared()->uses_arguments()); | 8658 ASSERT(!function->shared()->uses_arguments()); |
| 8672 | 8659 |
| 8673 Handle<Code> result = Handle<Code>::null(); | 8660 Handle<Code> result = Handle<Code>::null(); |
| 8674 BailoutId ast_id = BailoutId::None(); | 8661 BailoutId ast_id = BailoutId::None(); |
| 8675 | 8662 |
| 8676 if (isolate->concurrent_osr_enabled()) { | 8663 if (isolate->concurrent_osr_enabled()) { |
| 8677 if (isolate->optimizing_compiler_thread()-> | 8664 if (isolate->optimizing_compiler_thread()-> |
| 8678 IsQueuedForOSR(function, pc_offset)) { | 8665 IsQueuedForOSR(function, pc_offset)) { |
| 8679 // Still waiting for the optimizing compiler thread to finish. Carry on. | 8666 // Still waiting for the optimizing compiler thread to finish. Carry on. |
| 8680 if (FLAG_trace_osr) { | 8667 if (FLAG_trace_osr) { |
| 8681 PrintF("[COSR - polling recompile tasks for "); | 8668 PrintF("[COSR - polling recompile tasks for "); |
| 8682 function->PrintName(); | 8669 function->PrintName(); |
| 8683 PrintF("]\n"); | 8670 PrintF("]\n"); |
| 8684 } | 8671 } |
| 8685 return NULL; | 8672 return NULL; |
| 8686 } | 8673 } |
| 8687 | 8674 |
| 8688 RecompileJob* job = isolate->optimizing_compiler_thread()-> | 8675 RecompileJob* job = isolate->optimizing_compiler_thread()-> |
| 8689 FindReadyOSRCandidate(function, pc_offset); | 8676 FindReadyOSRCandidate(function, pc_offset); |
| 8690 | 8677 |
| 8691 if (job == NULL) { | 8678 if (job == NULL) { |
| 8692 if (IsSuitableForOnStackReplacement(isolate, function, unoptimized) && | 8679 if (IsSuitableForOnStackReplacement(isolate, function, unoptimized) && |
| 8693 Compiler::RecompileConcurrent(function, pc_offset)) { | 8680 Compiler::RecompileConcurrent(function, unoptimized, pc_offset)) { |
| 8694 if (function->IsMarkedForLazyRecompilation() || | 8681 if (function->IsMarkedForLazyRecompilation() || |
| 8695 function->IsMarkedForConcurrentRecompilation()) { | 8682 function->IsMarkedForConcurrentRecompilation()) { |
| 8696 // Prevent regular recompilation if we queue this for OSR. | 8683 // Prevent regular recompilation if we queue this for OSR. |
| 8697 // TODO(yangguo): remove this as soon as OSR becomes one-shot. | 8684 // TODO(yangguo): remove this as soon as OSR becomes one-shot. |
| 8698 function->ReplaceCode(*unoptimized); | 8685 function->ReplaceCode(function->shared()->code()); |
| 8699 } | 8686 } |
| 8700 return NULL; | 8687 return NULL; |
| 8701 } | 8688 } |
| 8702 // Fall through to the end in case of failure. | 8689 // Fall through to the end in case of failure. |
| 8703 } else { | 8690 } else { |
| 8704 // TODO(titzer): don't install the OSR code into the function. | 8691 // TODO(titzer): don't install the OSR code into the function. |
| 8705 ast_id = job->info()->osr_ast_id(); | 8692 ast_id = job->info()->osr_ast_id(); |
| 8706 result = Compiler::InstallOptimizedCode(job); | 8693 result = Compiler::InstallOptimizedCode(job); |
| 8707 } | 8694 } |
| 8708 } else if (IsSuitableForOnStackReplacement(isolate, function, unoptimized)) { | 8695 } else if (IsSuitableForOnStackReplacement(isolate, function, unoptimized)) { |
| (...skipping 4835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13544 } | 13531 } |
| 13545 } | 13532 } |
| 13546 | 13533 |
| 13547 | 13534 |
| 13548 // Sets a v8 flag. | 13535 // Sets a v8 flag. |
| 13549 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetFlags) { | 13536 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetFlags) { |
| 13550 SealHandleScope shs(isolate); | 13537 SealHandleScope shs(isolate); |
| 13551 CONVERT_ARG_CHECKED(String, arg, 0); | 13538 CONVERT_ARG_CHECKED(String, arg, 0); |
| 13552 SmartArrayPointer<char> flags = | 13539 SmartArrayPointer<char> flags = |
| 13553 arg->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 13540 arg->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
| 13554 FlagList::SetFlagsFromString(*flags, StrLength(*flags)); | 13541 FlagList::SetFlagsFromString(flags.get(), StrLength(flags.get())); |
| 13555 return isolate->heap()->undefined_value(); | 13542 return isolate->heap()->undefined_value(); |
| 13556 } | 13543 } |
| 13557 | 13544 |
| 13558 | 13545 |
| 13559 // Performs a GC. | 13546 // Performs a GC. |
| 13560 // Presently, it only does a full GC. | 13547 // Presently, it only does a full GC. |
| 13561 RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectGarbage) { | 13548 RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectGarbage) { |
| 13562 SealHandleScope shs(isolate); | 13549 SealHandleScope shs(isolate); |
| 13563 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, "%CollectGarbage"); | 13550 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, "%CollectGarbage"); |
| 13564 return isolate->heap()->undefined_value(); | 13551 return isolate->heap()->undefined_value(); |
| (...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14315 ASSERT(args.length() == 2); | 14302 ASSERT(args.length() == 2); |
| 14316 OS::PrintError("abort: %s\n", | 14303 OS::PrintError("abort: %s\n", |
| 14317 reinterpret_cast<char*>(args[0]) + args.smi_at(1)); | 14304 reinterpret_cast<char*>(args[0]) + args.smi_at(1)); |
| 14318 isolate->PrintStack(stderr); | 14305 isolate->PrintStack(stderr); |
| 14319 OS::Abort(); | 14306 OS::Abort(); |
| 14320 UNREACHABLE(); | 14307 UNREACHABLE(); |
| 14321 return NULL; | 14308 return NULL; |
| 14322 } | 14309 } |
| 14323 | 14310 |
| 14324 | 14311 |
| 14312 RUNTIME_FUNCTION(MaybeObject*, Runtime_AbortJS) { |
| 14313 HandleScope scope(isolate); |
| 14314 ASSERT(args.length() == 1); |
| 14315 CONVERT_ARG_HANDLE_CHECKED(String, message, 0); |
| 14316 OS::PrintError("abort: %s\n", message->ToCString().get()); |
| 14317 isolate->PrintStack(stderr); |
| 14318 OS::Abort(); |
| 14319 UNREACHABLE(); |
| 14320 return NULL; |
| 14321 } |
| 14322 |
| 14323 |
| 14325 RUNTIME_FUNCTION(MaybeObject*, Runtime_FlattenString) { | 14324 RUNTIME_FUNCTION(MaybeObject*, Runtime_FlattenString) { |
| 14326 HandleScope scope(isolate); | 14325 HandleScope scope(isolate); |
| 14327 ASSERT(args.length() == 1); | 14326 ASSERT(args.length() == 1); |
| 14328 CONVERT_ARG_HANDLE_CHECKED(String, str, 0); | 14327 CONVERT_ARG_HANDLE_CHECKED(String, str, 0); |
| 14329 FlattenString(str); | 14328 FlattenString(str); |
| 14330 return isolate->heap()->undefined_value(); | 14329 return isolate->heap()->undefined_value(); |
| 14331 } | 14330 } |
| 14332 | 14331 |
| 14333 | 14332 |
| 14334 RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyContextDisposed) { | 14333 RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyContextDisposed) { |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14607 return isolate->heap()->undefined_value(); | 14606 return isolate->heap()->undefined_value(); |
| 14608 | 14607 |
| 14609 ASSERT(!(obj->map()->is_observed() && obj->IsJSObject() && | 14608 ASSERT(!(obj->map()->is_observed() && obj->IsJSObject() && |
| 14610 Handle<JSObject>::cast(obj)->HasFastElements())); | 14609 Handle<JSObject>::cast(obj)->HasFastElements())); |
| 14611 ASSERT(obj->IsJSObject()); | 14610 ASSERT(obj->IsJSObject()); |
| 14612 JSObject::SetObserved(Handle<JSObject>::cast(obj)); | 14611 JSObject::SetObserved(Handle<JSObject>::cast(obj)); |
| 14613 return isolate->heap()->undefined_value(); | 14612 return isolate->heap()->undefined_value(); |
| 14614 } | 14613 } |
| 14615 | 14614 |
| 14616 | 14615 |
| 14617 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetObserverDeliveryPending) { | 14616 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetMicrotaskPending) { |
| 14618 SealHandleScope shs(isolate); | 14617 SealHandleScope shs(isolate); |
| 14619 ASSERT(args.length() == 0); | 14618 ASSERT(args.length() == 1); |
| 14620 isolate->set_observer_delivery_pending(true); | 14619 CONVERT_BOOLEAN_ARG_CHECKED(new_state, 0); |
| 14621 return isolate->heap()->undefined_value(); | 14620 bool old_state = isolate->microtask_pending(); |
| 14621 isolate->set_microtask_pending(new_state); |
| 14622 return isolate->heap()->ToBoolean(old_state); |
| 14622 } | 14623 } |
| 14623 | 14624 |
| 14624 | 14625 |
| 14625 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetObservationState) { | 14626 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetObservationState) { |
| 14626 SealHandleScope shs(isolate); | 14627 SealHandleScope shs(isolate); |
| 14627 ASSERT(args.length() == 0); | 14628 ASSERT(args.length() == 0); |
| 14628 return isolate->heap()->observation_state(); | 14629 return isolate->heap()->observation_state(); |
| 14629 } | 14630 } |
| 14630 | 14631 |
| 14631 | 14632 |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14892 // Handle last resort GC and make sure to allow future allocations | 14893 // Handle last resort GC and make sure to allow future allocations |
| 14893 // to grow the heap without causing GCs (if possible). | 14894 // to grow the heap without causing GCs (if possible). |
| 14894 isolate->counters()->gc_last_resort_from_js()->Increment(); | 14895 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 14895 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 14896 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 14896 "Runtime::PerformGC"); | 14897 "Runtime::PerformGC"); |
| 14897 } | 14898 } |
| 14898 } | 14899 } |
| 14899 | 14900 |
| 14900 | 14901 |
| 14901 } } // namespace v8::internal | 14902 } } // namespace v8::internal |
| OLD | NEW |