OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 value = CreateLiteralBoilerplate(literals, array); | 284 value = CreateLiteralBoilerplate(literals, array); |
285 if (value.is_null()) return value; | 285 if (value.is_null()) return value; |
286 } | 286 } |
287 Handle<Object> result; | 287 Handle<Object> result; |
288 uint32_t element_index = 0; | 288 uint32_t element_index = 0; |
289 if (key->IsSymbol()) { | 289 if (key->IsSymbol()) { |
290 // If key is a symbol it is not an array element. | 290 // If key is a symbol it is not an array element. |
291 Handle<String> name(String::cast(*key)); | 291 Handle<String> name(String::cast(*key)); |
292 ASSERT(!name->AsArrayIndex(&element_index)); | 292 ASSERT(!name->AsArrayIndex(&element_index)); |
293 result = SetProperty(boilerplate, name, value, NONE); | 293 result = SetProperty(boilerplate, name, value, NONE); |
294 } else if (Array::IndexFromObject(*key, &element_index)) { | 294 } else if (key->ToArrayIndex(&element_index)) { |
295 // Array index (uint32). | 295 // Array index (uint32). |
296 result = SetElement(boilerplate, element_index, value); | 296 result = SetElement(boilerplate, element_index, value); |
297 } else { | 297 } else { |
298 // Non-uint32 number. | 298 // Non-uint32 number. |
299 ASSERT(key->IsNumber()); | 299 ASSERT(key->IsNumber()); |
300 double num = key->Number(); | 300 double num = key->Number(); |
301 char arr[100]; | 301 char arr[100]; |
302 Vector<char> buffer(arr, ARRAY_SIZE(arr)); | 302 Vector<char> buffer(arr, ARRAY_SIZE(arr)); |
303 const char* str = DoubleToCString(num, buffer); | 303 const char* str = DoubleToCString(num, buffer); |
304 Handle<String> name = Factory::NewStringFromAscii(CStrVector(str)); | 304 Handle<String> name = Factory::NewStringFromAscii(CStrVector(str)); |
(...skipping 1328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1633 target->set_literals(*literals, SKIP_WRITE_BARRIER); | 1633 target->set_literals(*literals, SKIP_WRITE_BARRIER); |
1634 } | 1634 } |
1635 | 1635 |
1636 target->set_context(*context); | 1636 target->set_context(*context); |
1637 return *target; | 1637 return *target; |
1638 } | 1638 } |
1639 | 1639 |
1640 | 1640 |
1641 static Object* CharCodeAt(String* subject, Object* index) { | 1641 static Object* CharCodeAt(String* subject, Object* index) { |
1642 uint32_t i = 0; | 1642 uint32_t i = 0; |
1643 if (!Array::IndexFromObject(index, &i)) return Heap::nan_value(); | 1643 if (!index->ToArrayIndex(&i)) return Heap::nan_value(); |
1644 // Flatten the string. If someone wants to get a char at an index | 1644 // Flatten the string. If someone wants to get a char at an index |
1645 // in a cons string, it is likely that more indices will be | 1645 // in a cons string, it is likely that more indices will be |
1646 // accessed. | 1646 // accessed. |
1647 Object* flat = subject->TryFlatten(); | 1647 Object* flat = subject->TryFlatten(); |
1648 if (flat->IsFailure()) return flat; | 1648 if (flat->IsFailure()) return flat; |
1649 subject = String::cast(flat); | 1649 subject = String::cast(flat); |
1650 if (i >= static_cast<uint32_t>(subject->length())) { | 1650 if (i >= static_cast<uint32_t>(subject->length())) { |
1651 return Heap::nan_value(); | 1651 return Heap::nan_value(); |
1652 } | 1652 } |
1653 return Smi::FromInt(subject->Get(i)); | 1653 return Smi::FromInt(subject->Get(i)); |
1654 } | 1654 } |
1655 | 1655 |
1656 | 1656 |
1657 static Object* CharFromCode(Object* char_code) { | 1657 static Object* CharFromCode(Object* char_code) { |
1658 uint32_t code; | 1658 uint32_t code; |
1659 if (Array::IndexFromObject(char_code, &code)) { | 1659 if (char_code->ToArrayIndex(&code)) { |
1660 if (code <= 0xffff) { | 1660 if (code <= 0xffff) { |
1661 return Heap::LookupSingleCharacterStringFromCode(code); | 1661 return Heap::LookupSingleCharacterStringFromCode(code); |
1662 } | 1662 } |
1663 } | 1663 } |
1664 return Heap::empty_string(); | 1664 return Heap::empty_string(); |
1665 } | 1665 } |
1666 | 1666 |
1667 | 1667 |
1668 static Object* Runtime_StringCharCodeAt(Arguments args) { | 1668 static Object* Runtime_StringCharCodeAt(Arguments args) { |
1669 NoHandleAllocation ha; | 1669 NoHandleAllocation ha; |
(...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2830 | 2830 |
2831 static Object* Runtime_StringIndexOf(Arguments args) { | 2831 static Object* Runtime_StringIndexOf(Arguments args) { |
2832 HandleScope scope; // create a new handle scope | 2832 HandleScope scope; // create a new handle scope |
2833 ASSERT(args.length() == 3); | 2833 ASSERT(args.length() == 3); |
2834 | 2834 |
2835 CONVERT_ARG_CHECKED(String, sub, 0); | 2835 CONVERT_ARG_CHECKED(String, sub, 0); |
2836 CONVERT_ARG_CHECKED(String, pat, 1); | 2836 CONVERT_ARG_CHECKED(String, pat, 1); |
2837 | 2837 |
2838 Object* index = args[2]; | 2838 Object* index = args[2]; |
2839 uint32_t start_index; | 2839 uint32_t start_index; |
2840 if (!Array::IndexFromObject(index, &start_index)) return Smi::FromInt(-1); | 2840 if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1); |
2841 | 2841 |
2842 RUNTIME_ASSERT(start_index <= static_cast<uint32_t>(sub->length())); | 2842 RUNTIME_ASSERT(start_index <= static_cast<uint32_t>(sub->length())); |
2843 int position = Runtime::StringMatch(sub, pat, start_index); | 2843 int position = Runtime::StringMatch(sub, pat, start_index); |
2844 return Smi::FromInt(position); | 2844 return Smi::FromInt(position); |
2845 } | 2845 } |
2846 | 2846 |
2847 | 2847 |
2848 template <typename schar, typename pchar> | 2848 template <typename schar, typename pchar> |
2849 static int StringMatchBackwards(Vector<const schar> sub, | 2849 static int StringMatchBackwards(Vector<const schar> sub, |
2850 Vector<const pchar> pat, | 2850 Vector<const pchar> pat, |
(...skipping 29 matching lines...) Expand all Loading... |
2880 | 2880 |
2881 static Object* Runtime_StringLastIndexOf(Arguments args) { | 2881 static Object* Runtime_StringLastIndexOf(Arguments args) { |
2882 HandleScope scope; // create a new handle scope | 2882 HandleScope scope; // create a new handle scope |
2883 ASSERT(args.length() == 3); | 2883 ASSERT(args.length() == 3); |
2884 | 2884 |
2885 CONVERT_ARG_CHECKED(String, sub, 0); | 2885 CONVERT_ARG_CHECKED(String, sub, 0); |
2886 CONVERT_ARG_CHECKED(String, pat, 1); | 2886 CONVERT_ARG_CHECKED(String, pat, 1); |
2887 | 2887 |
2888 Object* index = args[2]; | 2888 Object* index = args[2]; |
2889 uint32_t start_index; | 2889 uint32_t start_index; |
2890 if (!Array::IndexFromObject(index, &start_index)) return Smi::FromInt(-1); | 2890 if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1); |
2891 | 2891 |
2892 uint32_t pat_length = pat->length(); | 2892 uint32_t pat_length = pat->length(); |
2893 uint32_t sub_length = sub->length(); | 2893 uint32_t sub_length = sub->length(); |
2894 | 2894 |
2895 if (start_index + pat_length > sub_length) { | 2895 if (start_index + pat_length > sub_length) { |
2896 start_index = sub_length - pat_length; | 2896 start_index = sub_length - pat_length; |
2897 } | 2897 } |
2898 | 2898 |
2899 if (pat_length == 0) { | 2899 if (pat_length == 0) { |
2900 return Smi::FromInt(start_index); | 2900 return Smi::FromInt(start_index); |
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3707 if (object->IsUndefined() || object->IsNull()) { | 3707 if (object->IsUndefined() || object->IsNull()) { |
3708 Handle<Object> args[2] = { key, object }; | 3708 Handle<Object> args[2] = { key, object }; |
3709 Handle<Object> error = | 3709 Handle<Object> error = |
3710 Factory::NewTypeError("non_object_property_load", | 3710 Factory::NewTypeError("non_object_property_load", |
3711 HandleVector(args, 2)); | 3711 HandleVector(args, 2)); |
3712 return Top::Throw(*error); | 3712 return Top::Throw(*error); |
3713 } | 3713 } |
3714 | 3714 |
3715 // Check if the given key is an array index. | 3715 // Check if the given key is an array index. |
3716 uint32_t index; | 3716 uint32_t index; |
3717 if (Array::IndexFromObject(*key, &index)) { | 3717 if (key->ToArrayIndex(&index)) { |
3718 return GetElementOrCharAt(object, index); | 3718 return GetElementOrCharAt(object, index); |
3719 } | 3719 } |
3720 | 3720 |
3721 // Convert the key to a string - possibly by calling back into JavaScript. | 3721 // Convert the key to a string - possibly by calling back into JavaScript. |
3722 Handle<String> name; | 3722 Handle<String> name; |
3723 if (key->IsString()) { | 3723 if (key->IsString()) { |
3724 name = Handle<String>::cast(key); | 3724 name = Handle<String>::cast(key); |
3725 } else { | 3725 } else { |
3726 bool has_pending_exception = false; | 3726 bool has_pending_exception = false; |
3727 Handle<Object> converted = | 3727 Handle<Object> converted = |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3893 return Top::Throw(*error); | 3893 return Top::Throw(*error); |
3894 } | 3894 } |
3895 | 3895 |
3896 // If the object isn't a JavaScript object, we ignore the store. | 3896 // If the object isn't a JavaScript object, we ignore the store. |
3897 if (!object->IsJSObject()) return *value; | 3897 if (!object->IsJSObject()) return *value; |
3898 | 3898 |
3899 Handle<JSObject> js_object = Handle<JSObject>::cast(object); | 3899 Handle<JSObject> js_object = Handle<JSObject>::cast(object); |
3900 | 3900 |
3901 // Check if the given key is an array index. | 3901 // Check if the given key is an array index. |
3902 uint32_t index; | 3902 uint32_t index; |
3903 if (Array::IndexFromObject(*key, &index)) { | 3903 if (key->ToArrayIndex(&index)) { |
3904 // In Firefox/SpiderMonkey, Safari and Opera you can access the characters | 3904 // In Firefox/SpiderMonkey, Safari and Opera you can access the characters |
3905 // of a string using [] notation. We need to support this too in | 3905 // of a string using [] notation. We need to support this too in |
3906 // JavaScript. | 3906 // JavaScript. |
3907 // In the case of a String object we just need to redirect the assignment to | 3907 // In the case of a String object we just need to redirect the assignment to |
3908 // the underlying string if the index is in range. Since the underlying | 3908 // the underlying string if the index is in range. Since the underlying |
3909 // string does nothing with the assignment then we can ignore such | 3909 // string does nothing with the assignment then we can ignore such |
3910 // assignments. | 3910 // assignments. |
3911 if (js_object->IsStringObjectWithCharacterAt(index)) { | 3911 if (js_object->IsStringObjectWithCharacterAt(index)) { |
3912 return *value; | 3912 return *value; |
3913 } | 3913 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3945 | 3945 |
3946 | 3946 |
3947 Object* Runtime::ForceSetObjectProperty(Handle<JSObject> js_object, | 3947 Object* Runtime::ForceSetObjectProperty(Handle<JSObject> js_object, |
3948 Handle<Object> key, | 3948 Handle<Object> key, |
3949 Handle<Object> value, | 3949 Handle<Object> value, |
3950 PropertyAttributes attr) { | 3950 PropertyAttributes attr) { |
3951 HandleScope scope; | 3951 HandleScope scope; |
3952 | 3952 |
3953 // Check if the given key is an array index. | 3953 // Check if the given key is an array index. |
3954 uint32_t index; | 3954 uint32_t index; |
3955 if (Array::IndexFromObject(*key, &index)) { | 3955 if (key->ToArrayIndex(&index)) { |
3956 // In Firefox/SpiderMonkey, Safari and Opera you can access the characters | 3956 // In Firefox/SpiderMonkey, Safari and Opera you can access the characters |
3957 // of a string using [] notation. We need to support this too in | 3957 // of a string using [] notation. We need to support this too in |
3958 // JavaScript. | 3958 // JavaScript. |
3959 // In the case of a String object we just need to redirect the assignment to | 3959 // In the case of a String object we just need to redirect the assignment to |
3960 // the underlying string if the index is in range. Since the underlying | 3960 // the underlying string if the index is in range. Since the underlying |
3961 // string does nothing with the assignment then we can ignore such | 3961 // string does nothing with the assignment then we can ignore such |
3962 // assignments. | 3962 // assignments. |
3963 if (js_object->IsStringObjectWithCharacterAt(index)) { | 3963 if (js_object->IsStringObjectWithCharacterAt(index)) { |
3964 return *value; | 3964 return *value; |
3965 } | 3965 } |
(...skipping 26 matching lines...) Expand all Loading... |
3992 } | 3992 } |
3993 } | 3993 } |
3994 | 3994 |
3995 | 3995 |
3996 Object* Runtime::ForceDeleteObjectProperty(Handle<JSObject> js_object, | 3996 Object* Runtime::ForceDeleteObjectProperty(Handle<JSObject> js_object, |
3997 Handle<Object> key) { | 3997 Handle<Object> key) { |
3998 HandleScope scope; | 3998 HandleScope scope; |
3999 | 3999 |
4000 // Check if the given key is an array index. | 4000 // Check if the given key is an array index. |
4001 uint32_t index; | 4001 uint32_t index; |
4002 if (Array::IndexFromObject(*key, &index)) { | 4002 if (key->ToArrayIndex(&index)) { |
4003 // In Firefox/SpiderMonkey, Safari and Opera you can access the | 4003 // In Firefox/SpiderMonkey, Safari and Opera you can access the |
4004 // characters of a string using [] notation. In the case of a | 4004 // characters of a string using [] notation. In the case of a |
4005 // String object we just need to redirect the deletion to the | 4005 // String object we just need to redirect the deletion to the |
4006 // underlying string if the index is in range. Since the | 4006 // underlying string if the index is in range. Since the |
4007 // underlying string does nothing with the deletion, we can ignore | 4007 // underlying string does nothing with the deletion, we can ignore |
4008 // such deletions. | 4008 // such deletions. |
4009 if (js_object->IsStringObjectWithCharacterAt(index)) { | 4009 if (js_object->IsStringObjectWithCharacterAt(index)) { |
4010 return Heap::true_value(); | 4010 return Heap::true_value(); |
4011 } | 4011 } |
4012 | 4012 |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4405 JavaScriptFrameIterator it; | 4405 JavaScriptFrameIterator it; |
4406 it.AdvanceToArgumentsFrame(); | 4406 it.AdvanceToArgumentsFrame(); |
4407 JavaScriptFrame* frame = it.frame(); | 4407 JavaScriptFrame* frame = it.frame(); |
4408 | 4408 |
4409 // Get the actual number of provided arguments. | 4409 // Get the actual number of provided arguments. |
4410 const uint32_t n = frame->GetProvidedParametersCount(); | 4410 const uint32_t n = frame->GetProvidedParametersCount(); |
4411 | 4411 |
4412 // Try to convert the key to an index. If successful and within | 4412 // Try to convert the key to an index. If successful and within |
4413 // index return the the argument from the frame. | 4413 // index return the the argument from the frame. |
4414 uint32_t index; | 4414 uint32_t index; |
4415 if (Array::IndexFromObject(args[0], &index) && index < n) { | 4415 if (args[0]->ToArrayIndex(&index) && index < n) { |
4416 return frame->GetParameter(index); | 4416 return frame->GetParameter(index); |
4417 } | 4417 } |
4418 | 4418 |
4419 // Convert the key to a string. | 4419 // Convert the key to a string. |
4420 HandleScope scope; | 4420 HandleScope scope; |
4421 bool exception = false; | 4421 bool exception = false; |
4422 Handle<Object> converted = | 4422 Handle<Object> converted = |
4423 Execution::ToString(args.at<Object>(0), &exception); | 4423 Execution::ToString(args.at<Object>(0), &exception); |
4424 if (exception) return Failure::Exception(); | 4424 if (exception) return Failure::Exception(); |
4425 Handle<String> key = Handle<String>::cast(converted); | 4425 Handle<String> key = Handle<String>::cast(converted); |
(...skipping 2100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6526 | 6526 |
6527 Object* result = Heap::AllocateArgumentsObject(callee, length); | 6527 Object* result = Heap::AllocateArgumentsObject(callee, length); |
6528 if (result->IsFailure()) return result; | 6528 if (result->IsFailure()) return result; |
6529 // Allocate the elements if needed. | 6529 // Allocate the elements if needed. |
6530 if (length > 0) { | 6530 if (length > 0) { |
6531 // Allocate the fixed array. | 6531 // Allocate the fixed array. |
6532 Object* obj = Heap::AllocateRawFixedArray(length); | 6532 Object* obj = Heap::AllocateRawFixedArray(length); |
6533 if (obj->IsFailure()) return obj; | 6533 if (obj->IsFailure()) return obj; |
6534 | 6534 |
6535 AssertNoAllocation no_gc; | 6535 AssertNoAllocation no_gc; |
6536 reinterpret_cast<Array*>(obj)->set_map(Heap::fixed_array_map()); | 6536 FixedArray* array = reinterpret_cast<FixedArray*>(obj); |
6537 FixedArray* array = FixedArray::cast(obj); | 6537 array->set_map(Heap::fixed_array_map()); |
6538 array->set_length(length); | 6538 array->set_length(length); |
6539 | 6539 |
6540 WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc); | 6540 WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc); |
6541 for (int i = 0; i < length; i++) { | 6541 for (int i = 0; i < length; i++) { |
6542 array->set(i, *--parameters, mode); | 6542 array->set(i, *--parameters, mode); |
6543 } | 6543 } |
6544 JSObject::cast(result)->set_elements(FixedArray::cast(obj)); | 6544 JSObject::cast(result)->set_elements(FixedArray::cast(obj)); |
6545 } | 6545 } |
6546 return result; | 6546 return result; |
6547 } | 6547 } |
(...skipping 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7816 static Object* Runtime_SwapElements(Arguments args) { | 7816 static Object* Runtime_SwapElements(Arguments args) { |
7817 HandleScope handle_scope; | 7817 HandleScope handle_scope; |
7818 | 7818 |
7819 ASSERT_EQ(3, args.length()); | 7819 ASSERT_EQ(3, args.length()); |
7820 | 7820 |
7821 CONVERT_ARG_CHECKED(JSObject, object, 0); | 7821 CONVERT_ARG_CHECKED(JSObject, object, 0); |
7822 Handle<Object> key1 = args.at<Object>(1); | 7822 Handle<Object> key1 = args.at<Object>(1); |
7823 Handle<Object> key2 = args.at<Object>(2); | 7823 Handle<Object> key2 = args.at<Object>(2); |
7824 | 7824 |
7825 uint32_t index1, index2; | 7825 uint32_t index1, index2; |
7826 if (!Array::IndexFromObject(*key1, &index1) | 7826 if (!key1->ToArrayIndex(&index1) |
7827 || !Array::IndexFromObject(*key2, &index2)) { | 7827 || !key2->ToArrayIndex(&index2)) { |
7828 return Top::ThrowIllegalOperation(); | 7828 return Top::ThrowIllegalOperation(); |
7829 } | 7829 } |
7830 | 7830 |
7831 Handle<JSObject> jsobject = Handle<JSObject>::cast(object); | 7831 Handle<JSObject> jsobject = Handle<JSObject>::cast(object); |
7832 Handle<Object> tmp1 = GetElement(jsobject, index1); | 7832 Handle<Object> tmp1 = GetElement(jsobject, index1); |
7833 Handle<Object> tmp2 = GetElement(jsobject, index2); | 7833 Handle<Object> tmp2 = GetElement(jsobject, index2); |
7834 | 7834 |
7835 SetElement(jsobject, index1, tmp2); | 7835 SetElement(jsobject, index1, tmp2); |
7836 SetElement(jsobject, index2, tmp1); | 7836 SetElement(jsobject, index2, tmp1); |
7837 | 7837 |
(...skipping 10 matching lines...) Expand all Loading... |
7848 CONVERT_ARG_CHECKED(JSObject, array, 0); | 7848 CONVERT_ARG_CHECKED(JSObject, array, 0); |
7849 CONVERT_NUMBER_CHECKED(uint32_t, length, Uint32, args[1]); | 7849 CONVERT_NUMBER_CHECKED(uint32_t, length, Uint32, args[1]); |
7850 if (array->elements()->IsDictionary()) { | 7850 if (array->elements()->IsDictionary()) { |
7851 // Create an array and get all the keys into it, then remove all the | 7851 // Create an array and get all the keys into it, then remove all the |
7852 // keys that are not integers in the range 0 to length-1. | 7852 // keys that are not integers in the range 0 to length-1. |
7853 Handle<FixedArray> keys = GetKeysInFixedArrayFor(array, INCLUDE_PROTOS); | 7853 Handle<FixedArray> keys = GetKeysInFixedArrayFor(array, INCLUDE_PROTOS); |
7854 int keys_length = keys->length(); | 7854 int keys_length = keys->length(); |
7855 for (int i = 0; i < keys_length; i++) { | 7855 for (int i = 0; i < keys_length; i++) { |
7856 Object* key = keys->get(i); | 7856 Object* key = keys->get(i); |
7857 uint32_t index; | 7857 uint32_t index; |
7858 if (!Array::IndexFromObject(key, &index) || index >= length) { | 7858 if (!key->ToArrayIndex(&index) || index >= length) { |
7859 // Zap invalid keys. | 7859 // Zap invalid keys. |
7860 keys->set_undefined(i); | 7860 keys->set_undefined(i); |
7861 } | 7861 } |
7862 } | 7862 } |
7863 return *Factory::NewJSArrayWithElements(keys); | 7863 return *Factory::NewJSArrayWithElements(keys); |
7864 } else { | 7864 } else { |
| 7865 ASSERT(array->HasFastElements()); |
7865 Handle<FixedArray> single_interval = Factory::NewFixedArray(2); | 7866 Handle<FixedArray> single_interval = Factory::NewFixedArray(2); |
7866 // -1 means start of array. | 7867 // -1 means start of array. |
7867 single_interval->set(0, Smi::FromInt(-1)); | 7868 single_interval->set(0, Smi::FromInt(-1)); |
7868 uint32_t actual_length = static_cast<uint32_t>(array->elements()->length()); | 7869 uint32_t actual_length = |
| 7870 static_cast<uint32_t>(FixedArray::cast(array->elements())->length()); |
7869 uint32_t min_length = actual_length < length ? actual_length : length; | 7871 uint32_t min_length = actual_length < length ? actual_length : length; |
7870 Handle<Object> length_object = | 7872 Handle<Object> length_object = |
7871 Factory::NewNumber(static_cast<double>(min_length)); | 7873 Factory::NewNumber(static_cast<double>(min_length)); |
7872 single_interval->set(1, *length_object); | 7874 single_interval->set(1, *length_object); |
7873 return *Factory::NewJSArrayWithElements(single_interval); | 7875 return *Factory::NewJSArrayWithElements(single_interval); |
7874 } | 7876 } |
7875 } | 7877 } |
7876 | 7878 |
7877 | 7879 |
7878 // DefineAccessor takes an optional final argument which is the | 7880 // DefineAccessor takes an optional final argument which is the |
(...skipping 2426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10305 } else { | 10307 } else { |
10306 // Handle last resort GC and make sure to allow future allocations | 10308 // Handle last resort GC and make sure to allow future allocations |
10307 // to grow the heap without causing GCs (if possible). | 10309 // to grow the heap without causing GCs (if possible). |
10308 Counters::gc_last_resort_from_js.Increment(); | 10310 Counters::gc_last_resort_from_js.Increment(); |
10309 Heap::CollectAllGarbage(false); | 10311 Heap::CollectAllGarbage(false); |
10310 } | 10312 } |
10311 } | 10313 } |
10312 | 10314 |
10313 | 10315 |
10314 } } // namespace v8::internal | 10316 } } // namespace v8::internal |
OLD | NEW |