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 (key->ToArrayIndex(&element_index)) { | 294 } else if (Array::IndexFromObject(*key, &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 1271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1576 target->set_literals(*literals, SKIP_WRITE_BARRIER); | 1576 target->set_literals(*literals, SKIP_WRITE_BARRIER); |
1577 } | 1577 } |
1578 | 1578 |
1579 target->set_context(*context); | 1579 target->set_context(*context); |
1580 return *target; | 1580 return *target; |
1581 } | 1581 } |
1582 | 1582 |
1583 | 1583 |
1584 static Object* CharCodeAt(String* subject, Object* index) { | 1584 static Object* CharCodeAt(String* subject, Object* index) { |
1585 uint32_t i = 0; | 1585 uint32_t i = 0; |
1586 if (!index->ToArrayIndex(&i)) return Heap::nan_value(); | 1586 if (!Array::IndexFromObject(index, &i)) return Heap::nan_value(); |
1587 // Flatten the string. If someone wants to get a char at an index | 1587 // Flatten the string. If someone wants to get a char at an index |
1588 // in a cons string, it is likely that more indices will be | 1588 // in a cons string, it is likely that more indices will be |
1589 // accessed. | 1589 // accessed. |
1590 Object* flat = subject->TryFlatten(); | 1590 Object* flat = subject->TryFlatten(); |
1591 if (flat->IsFailure()) return flat; | 1591 if (flat->IsFailure()) return flat; |
1592 subject = String::cast(flat); | 1592 subject = String::cast(flat); |
1593 if (i >= static_cast<uint32_t>(subject->length())) { | 1593 if (i >= static_cast<uint32_t>(subject->length())) { |
1594 return Heap::nan_value(); | 1594 return Heap::nan_value(); |
1595 } | 1595 } |
1596 return Smi::FromInt(subject->Get(i)); | 1596 return Smi::FromInt(subject->Get(i)); |
1597 } | 1597 } |
1598 | 1598 |
1599 | 1599 |
1600 static Object* CharFromCode(Object* char_code) { | 1600 static Object* CharFromCode(Object* char_code) { |
1601 uint32_t code; | 1601 uint32_t code; |
1602 if (char_code->ToArrayIndex(&code)) { | 1602 if (Array::IndexFromObject(char_code, &code)) { |
1603 if (code <= 0xffff) { | 1603 if (code <= 0xffff) { |
1604 return Heap::LookupSingleCharacterStringFromCode(code); | 1604 return Heap::LookupSingleCharacterStringFromCode(code); |
1605 } | 1605 } |
1606 } | 1606 } |
1607 return Heap::empty_string(); | 1607 return Heap::empty_string(); |
1608 } | 1608 } |
1609 | 1609 |
1610 | 1610 |
1611 static Object* Runtime_StringCharCodeAt(Arguments args) { | 1611 static Object* Runtime_StringCharCodeAt(Arguments args) { |
1612 NoHandleAllocation ha; | 1612 NoHandleAllocation ha; |
(...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2773 | 2773 |
2774 static Object* Runtime_StringIndexOf(Arguments args) { | 2774 static Object* Runtime_StringIndexOf(Arguments args) { |
2775 HandleScope scope; // create a new handle scope | 2775 HandleScope scope; // create a new handle scope |
2776 ASSERT(args.length() == 3); | 2776 ASSERT(args.length() == 3); |
2777 | 2777 |
2778 CONVERT_ARG_CHECKED(String, sub, 0); | 2778 CONVERT_ARG_CHECKED(String, sub, 0); |
2779 CONVERT_ARG_CHECKED(String, pat, 1); | 2779 CONVERT_ARG_CHECKED(String, pat, 1); |
2780 | 2780 |
2781 Object* index = args[2]; | 2781 Object* index = args[2]; |
2782 uint32_t start_index; | 2782 uint32_t start_index; |
2783 if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1); | 2783 if (!Array::IndexFromObject(index, &start_index)) return Smi::FromInt(-1); |
2784 | 2784 |
2785 RUNTIME_ASSERT(start_index <= static_cast<uint32_t>(sub->length())); | 2785 RUNTIME_ASSERT(start_index <= static_cast<uint32_t>(sub->length())); |
2786 int position = Runtime::StringMatch(sub, pat, start_index); | 2786 int position = Runtime::StringMatch(sub, pat, start_index); |
2787 return Smi::FromInt(position); | 2787 return Smi::FromInt(position); |
2788 } | 2788 } |
2789 | 2789 |
2790 | 2790 |
2791 template <typename schar, typename pchar> | 2791 template <typename schar, typename pchar> |
2792 static int StringMatchBackwards(Vector<const schar> sub, | 2792 static int StringMatchBackwards(Vector<const schar> sub, |
2793 Vector<const pchar> pat, | 2793 Vector<const pchar> pat, |
(...skipping 29 matching lines...) Expand all Loading... |
2823 | 2823 |
2824 static Object* Runtime_StringLastIndexOf(Arguments args) { | 2824 static Object* Runtime_StringLastIndexOf(Arguments args) { |
2825 HandleScope scope; // create a new handle scope | 2825 HandleScope scope; // create a new handle scope |
2826 ASSERT(args.length() == 3); | 2826 ASSERT(args.length() == 3); |
2827 | 2827 |
2828 CONVERT_ARG_CHECKED(String, sub, 0); | 2828 CONVERT_ARG_CHECKED(String, sub, 0); |
2829 CONVERT_ARG_CHECKED(String, pat, 1); | 2829 CONVERT_ARG_CHECKED(String, pat, 1); |
2830 | 2830 |
2831 Object* index = args[2]; | 2831 Object* index = args[2]; |
2832 uint32_t start_index; | 2832 uint32_t start_index; |
2833 if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1); | 2833 if (!Array::IndexFromObject(index, &start_index)) return Smi::FromInt(-1); |
2834 | 2834 |
2835 uint32_t pat_length = pat->length(); | 2835 uint32_t pat_length = pat->length(); |
2836 uint32_t sub_length = sub->length(); | 2836 uint32_t sub_length = sub->length(); |
2837 | 2837 |
2838 if (start_index + pat_length > sub_length) { | 2838 if (start_index + pat_length > sub_length) { |
2839 start_index = sub_length - pat_length; | 2839 start_index = sub_length - pat_length; |
2840 } | 2840 } |
2841 | 2841 |
2842 if (pat_length == 0) { | 2842 if (pat_length == 0) { |
2843 return Smi::FromInt(start_index); | 2843 return Smi::FromInt(start_index); |
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3650 if (object->IsUndefined() || object->IsNull()) { | 3650 if (object->IsUndefined() || object->IsNull()) { |
3651 Handle<Object> args[2] = { key, object }; | 3651 Handle<Object> args[2] = { key, object }; |
3652 Handle<Object> error = | 3652 Handle<Object> error = |
3653 Factory::NewTypeError("non_object_property_load", | 3653 Factory::NewTypeError("non_object_property_load", |
3654 HandleVector(args, 2)); | 3654 HandleVector(args, 2)); |
3655 return Top::Throw(*error); | 3655 return Top::Throw(*error); |
3656 } | 3656 } |
3657 | 3657 |
3658 // Check if the given key is an array index. | 3658 // Check if the given key is an array index. |
3659 uint32_t index; | 3659 uint32_t index; |
3660 if (key->ToArrayIndex(&index)) { | 3660 if (Array::IndexFromObject(*key, &index)) { |
3661 return GetElementOrCharAt(object, index); | 3661 return GetElementOrCharAt(object, index); |
3662 } | 3662 } |
3663 | 3663 |
3664 // Convert the key to a string - possibly by calling back into JavaScript. | 3664 // Convert the key to a string - possibly by calling back into JavaScript. |
3665 Handle<String> name; | 3665 Handle<String> name; |
3666 if (key->IsString()) { | 3666 if (key->IsString()) { |
3667 name = Handle<String>::cast(key); | 3667 name = Handle<String>::cast(key); |
3668 } else { | 3668 } else { |
3669 bool has_pending_exception = false; | 3669 bool has_pending_exception = false; |
3670 Handle<Object> converted = | 3670 Handle<Object> converted = |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3836 return Top::Throw(*error); | 3836 return Top::Throw(*error); |
3837 } | 3837 } |
3838 | 3838 |
3839 // If the object isn't a JavaScript object, we ignore the store. | 3839 // If the object isn't a JavaScript object, we ignore the store. |
3840 if (!object->IsJSObject()) return *value; | 3840 if (!object->IsJSObject()) return *value; |
3841 | 3841 |
3842 Handle<JSObject> js_object = Handle<JSObject>::cast(object); | 3842 Handle<JSObject> js_object = Handle<JSObject>::cast(object); |
3843 | 3843 |
3844 // Check if the given key is an array index. | 3844 // Check if the given key is an array index. |
3845 uint32_t index; | 3845 uint32_t index; |
3846 if (key->ToArrayIndex(&index)) { | 3846 if (Array::IndexFromObject(*key, &index)) { |
3847 // In Firefox/SpiderMonkey, Safari and Opera you can access the characters | 3847 // In Firefox/SpiderMonkey, Safari and Opera you can access the characters |
3848 // of a string using [] notation. We need to support this too in | 3848 // of a string using [] notation. We need to support this too in |
3849 // JavaScript. | 3849 // JavaScript. |
3850 // In the case of a String object we just need to redirect the assignment to | 3850 // In the case of a String object we just need to redirect the assignment to |
3851 // the underlying string if the index is in range. Since the underlying | 3851 // the underlying string if the index is in range. Since the underlying |
3852 // string does nothing with the assignment then we can ignore such | 3852 // string does nothing with the assignment then we can ignore such |
3853 // assignments. | 3853 // assignments. |
3854 if (js_object->IsStringObjectWithCharacterAt(index)) { | 3854 if (js_object->IsStringObjectWithCharacterAt(index)) { |
3855 return *value; | 3855 return *value; |
3856 } | 3856 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3888 | 3888 |
3889 | 3889 |
3890 Object* Runtime::ForceSetObjectProperty(Handle<JSObject> js_object, | 3890 Object* Runtime::ForceSetObjectProperty(Handle<JSObject> js_object, |
3891 Handle<Object> key, | 3891 Handle<Object> key, |
3892 Handle<Object> value, | 3892 Handle<Object> value, |
3893 PropertyAttributes attr) { | 3893 PropertyAttributes attr) { |
3894 HandleScope scope; | 3894 HandleScope scope; |
3895 | 3895 |
3896 // Check if the given key is an array index. | 3896 // Check if the given key is an array index. |
3897 uint32_t index; | 3897 uint32_t index; |
3898 if (key->ToArrayIndex(&index)) { | 3898 if (Array::IndexFromObject(*key, &index)) { |
3899 // In Firefox/SpiderMonkey, Safari and Opera you can access the characters | 3899 // In Firefox/SpiderMonkey, Safari and Opera you can access the characters |
3900 // of a string using [] notation. We need to support this too in | 3900 // of a string using [] notation. We need to support this too in |
3901 // JavaScript. | 3901 // JavaScript. |
3902 // In the case of a String object we just need to redirect the assignment to | 3902 // In the case of a String object we just need to redirect the assignment to |
3903 // the underlying string if the index is in range. Since the underlying | 3903 // the underlying string if the index is in range. Since the underlying |
3904 // string does nothing with the assignment then we can ignore such | 3904 // string does nothing with the assignment then we can ignore such |
3905 // assignments. | 3905 // assignments. |
3906 if (js_object->IsStringObjectWithCharacterAt(index)) { | 3906 if (js_object->IsStringObjectWithCharacterAt(index)) { |
3907 return *value; | 3907 return *value; |
3908 } | 3908 } |
(...skipping 26 matching lines...) Expand all Loading... |
3935 } | 3935 } |
3936 } | 3936 } |
3937 | 3937 |
3938 | 3938 |
3939 Object* Runtime::ForceDeleteObjectProperty(Handle<JSObject> js_object, | 3939 Object* Runtime::ForceDeleteObjectProperty(Handle<JSObject> js_object, |
3940 Handle<Object> key) { | 3940 Handle<Object> key) { |
3941 HandleScope scope; | 3941 HandleScope scope; |
3942 | 3942 |
3943 // Check if the given key is an array index. | 3943 // Check if the given key is an array index. |
3944 uint32_t index; | 3944 uint32_t index; |
3945 if (key->ToArrayIndex(&index)) { | 3945 if (Array::IndexFromObject(*key, &index)) { |
3946 // In Firefox/SpiderMonkey, Safari and Opera you can access the | 3946 // In Firefox/SpiderMonkey, Safari and Opera you can access the |
3947 // characters of a string using [] notation. In the case of a | 3947 // characters of a string using [] notation. In the case of a |
3948 // String object we just need to redirect the deletion to the | 3948 // String object we just need to redirect the deletion to the |
3949 // underlying string if the index is in range. Since the | 3949 // underlying string if the index is in range. Since the |
3950 // underlying string does nothing with the deletion, we can ignore | 3950 // underlying string does nothing with the deletion, we can ignore |
3951 // such deletions. | 3951 // such deletions. |
3952 if (js_object->IsStringObjectWithCharacterAt(index)) { | 3952 if (js_object->IsStringObjectWithCharacterAt(index)) { |
3953 return Heap::true_value(); | 3953 return Heap::true_value(); |
3954 } | 3954 } |
3955 | 3955 |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4348 JavaScriptFrameIterator it; | 4348 JavaScriptFrameIterator it; |
4349 it.AdvanceToArgumentsFrame(); | 4349 it.AdvanceToArgumentsFrame(); |
4350 JavaScriptFrame* frame = it.frame(); | 4350 JavaScriptFrame* frame = it.frame(); |
4351 | 4351 |
4352 // Get the actual number of provided arguments. | 4352 // Get the actual number of provided arguments. |
4353 const uint32_t n = frame->GetProvidedParametersCount(); | 4353 const uint32_t n = frame->GetProvidedParametersCount(); |
4354 | 4354 |
4355 // Try to convert the key to an index. If successful and within | 4355 // Try to convert the key to an index. If successful and within |
4356 // index return the the argument from the frame. | 4356 // index return the the argument from the frame. |
4357 uint32_t index; | 4357 uint32_t index; |
4358 if (args[0]->ToArrayIndex(&index) && index < n) { | 4358 if (Array::IndexFromObject(args[0], &index) && index < n) { |
4359 return frame->GetParameter(index); | 4359 return frame->GetParameter(index); |
4360 } | 4360 } |
4361 | 4361 |
4362 // Convert the key to a string. | 4362 // Convert the key to a string. |
4363 HandleScope scope; | 4363 HandleScope scope; |
4364 bool exception = false; | 4364 bool exception = false; |
4365 Handle<Object> converted = | 4365 Handle<Object> converted = |
4366 Execution::ToString(args.at<Object>(0), &exception); | 4366 Execution::ToString(args.at<Object>(0), &exception); |
4367 if (exception) return Failure::Exception(); | 4367 if (exception) return Failure::Exception(); |
4368 Handle<String> key = Handle<String>::cast(converted); | 4368 Handle<String> key = Handle<String>::cast(converted); |
(...skipping 2081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6450 | 6450 |
6451 Object* result = Heap::AllocateArgumentsObject(callee, length); | 6451 Object* result = Heap::AllocateArgumentsObject(callee, length); |
6452 if (result->IsFailure()) return result; | 6452 if (result->IsFailure()) return result; |
6453 // Allocate the elements if needed. | 6453 // Allocate the elements if needed. |
6454 if (length > 0) { | 6454 if (length > 0) { |
6455 // Allocate the fixed array. | 6455 // Allocate the fixed array. |
6456 Object* obj = Heap::AllocateRawFixedArray(length); | 6456 Object* obj = Heap::AllocateRawFixedArray(length); |
6457 if (obj->IsFailure()) return obj; | 6457 if (obj->IsFailure()) return obj; |
6458 | 6458 |
6459 AssertNoAllocation no_gc; | 6459 AssertNoAllocation no_gc; |
6460 FixedArray* array = reinterpret_cast<FixedArray*>(obj); | 6460 reinterpret_cast<Array*>(obj)->set_map(Heap::fixed_array_map()); |
6461 array->set_map(Heap::fixed_array_map()); | 6461 FixedArray* array = FixedArray::cast(obj); |
6462 array->set_length(length); | 6462 array->set_length(length); |
6463 | 6463 |
6464 WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc); | 6464 WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc); |
6465 for (int i = 0; i < length; i++) { | 6465 for (int i = 0; i < length; i++) { |
6466 array->set(i, *--parameters, mode); | 6466 array->set(i, *--parameters, mode); |
6467 } | 6467 } |
6468 JSObject::cast(result)->set_elements(FixedArray::cast(obj)); | 6468 JSObject::cast(result)->set_elements(FixedArray::cast(obj)); |
6469 } | 6469 } |
6470 return result; | 6470 return result; |
6471 } | 6471 } |
(...skipping 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7740 static Object* Runtime_SwapElements(Arguments args) { | 7740 static Object* Runtime_SwapElements(Arguments args) { |
7741 HandleScope handle_scope; | 7741 HandleScope handle_scope; |
7742 | 7742 |
7743 ASSERT_EQ(3, args.length()); | 7743 ASSERT_EQ(3, args.length()); |
7744 | 7744 |
7745 CONVERT_ARG_CHECKED(JSObject, object, 0); | 7745 CONVERT_ARG_CHECKED(JSObject, object, 0); |
7746 Handle<Object> key1 = args.at<Object>(1); | 7746 Handle<Object> key1 = args.at<Object>(1); |
7747 Handle<Object> key2 = args.at<Object>(2); | 7747 Handle<Object> key2 = args.at<Object>(2); |
7748 | 7748 |
7749 uint32_t index1, index2; | 7749 uint32_t index1, index2; |
7750 if (!key1->ToArrayIndex(&index1) | 7750 if (!Array::IndexFromObject(*key1, &index1) |
7751 || !key2->ToArrayIndex(&index2)) { | 7751 || !Array::IndexFromObject(*key2, &index2)) { |
7752 return Top::ThrowIllegalOperation(); | 7752 return Top::ThrowIllegalOperation(); |
7753 } | 7753 } |
7754 | 7754 |
7755 Handle<JSObject> jsobject = Handle<JSObject>::cast(object); | 7755 Handle<JSObject> jsobject = Handle<JSObject>::cast(object); |
7756 Handle<Object> tmp1 = GetElement(jsobject, index1); | 7756 Handle<Object> tmp1 = GetElement(jsobject, index1); |
7757 Handle<Object> tmp2 = GetElement(jsobject, index2); | 7757 Handle<Object> tmp2 = GetElement(jsobject, index2); |
7758 | 7758 |
7759 SetElement(jsobject, index1, tmp2); | 7759 SetElement(jsobject, index1, tmp2); |
7760 SetElement(jsobject, index2, tmp1); | 7760 SetElement(jsobject, index2, tmp1); |
7761 | 7761 |
(...skipping 10 matching lines...) Expand all Loading... |
7772 CONVERT_ARG_CHECKED(JSObject, array, 0); | 7772 CONVERT_ARG_CHECKED(JSObject, array, 0); |
7773 CONVERT_NUMBER_CHECKED(uint32_t, length, Uint32, args[1]); | 7773 CONVERT_NUMBER_CHECKED(uint32_t, length, Uint32, args[1]); |
7774 if (array->elements()->IsDictionary()) { | 7774 if (array->elements()->IsDictionary()) { |
7775 // Create an array and get all the keys into it, then remove all the | 7775 // Create an array and get all the keys into it, then remove all the |
7776 // keys that are not integers in the range 0 to length-1. | 7776 // keys that are not integers in the range 0 to length-1. |
7777 Handle<FixedArray> keys = GetKeysInFixedArrayFor(array, INCLUDE_PROTOS); | 7777 Handle<FixedArray> keys = GetKeysInFixedArrayFor(array, INCLUDE_PROTOS); |
7778 int keys_length = keys->length(); | 7778 int keys_length = keys->length(); |
7779 for (int i = 0; i < keys_length; i++) { | 7779 for (int i = 0; i < keys_length; i++) { |
7780 Object* key = keys->get(i); | 7780 Object* key = keys->get(i); |
7781 uint32_t index; | 7781 uint32_t index; |
7782 if (!key->ToArrayIndex(&index) || index >= length) { | 7782 if (!Array::IndexFromObject(key, &index) || index >= length) { |
7783 // Zap invalid keys. | 7783 // Zap invalid keys. |
7784 keys->set_undefined(i); | 7784 keys->set_undefined(i); |
7785 } | 7785 } |
7786 } | 7786 } |
7787 return *Factory::NewJSArrayWithElements(keys); | 7787 return *Factory::NewJSArrayWithElements(keys); |
7788 } else { | 7788 } else { |
7789 ASSERT(array->HasFastElements()); | |
7790 Handle<FixedArray> single_interval = Factory::NewFixedArray(2); | 7789 Handle<FixedArray> single_interval = Factory::NewFixedArray(2); |
7791 // -1 means start of array. | 7790 // -1 means start of array. |
7792 single_interval->set(0, Smi::FromInt(-1)); | 7791 single_interval->set(0, Smi::FromInt(-1)); |
7793 uint32_t actual_length = | 7792 uint32_t actual_length = static_cast<uint32_t>(array->elements()->length()); |
7794 static_cast<uint32_t>(FixedArray::cast(array->elements())->length()); | |
7795 uint32_t min_length = actual_length < length ? actual_length : length; | 7793 uint32_t min_length = actual_length < length ? actual_length : length; |
7796 Handle<Object> length_object = | 7794 Handle<Object> length_object = |
7797 Factory::NewNumber(static_cast<double>(min_length)); | 7795 Factory::NewNumber(static_cast<double>(min_length)); |
7798 single_interval->set(1, *length_object); | 7796 single_interval->set(1, *length_object); |
7799 return *Factory::NewJSArrayWithElements(single_interval); | 7797 return *Factory::NewJSArrayWithElements(single_interval); |
7800 } | 7798 } |
7801 } | 7799 } |
7802 | 7800 |
7803 | 7801 |
7804 // DefineAccessor takes an optional final argument which is the | 7802 // DefineAccessor takes an optional final argument which is the |
(...skipping 2426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10231 } else { | 10229 } else { |
10232 // Handle last resort GC and make sure to allow future allocations | 10230 // Handle last resort GC and make sure to allow future allocations |
10233 // to grow the heap without causing GCs (if possible). | 10231 // to grow the heap without causing GCs (if possible). |
10234 Counters::gc_last_resort_from_js.Increment(); | 10232 Counters::gc_last_resort_from_js.Increment(); |
10235 Heap::CollectAllGarbage(false); | 10233 Heap::CollectAllGarbage(false); |
10236 } | 10234 } |
10237 } | 10235 } |
10238 | 10236 |
10239 | 10237 |
10240 } } // namespace v8::internal | 10238 } } // namespace v8::internal |
OLD | NEW |