| 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 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 Handle<JSFunction> function = Handle<JSFunction>( | 752 Handle<JSFunction> function = Handle<JSFunction>( |
| 753 JSFunction::cast(raw_object)); | 753 JSFunction::cast(raw_object)); |
| 754 | 754 |
| 755 // Allocate the object. | 755 // Allocate the object. |
| 756 Handle<JSObject> object = factory->NewJSObject(function); | 756 Handle<JSObject> object = factory->NewJSObject(function); |
| 757 Handle<JSArray> array = Handle<JSArray>::cast(object); | 757 Handle<JSArray> array = Handle<JSArray>::cast(object); |
| 758 // We just initialized the VM, no heap allocation failure yet. | 758 // We just initialized the VM, no heap allocation failure yet. |
| 759 JSArray::Initialize(array, 0); | 759 JSArray::Initialize(array, 0); |
| 760 | 760 |
| 761 // Set array length to 0. | 761 // Set array length to 0. |
| 762 array->SetElementsLength(Smi::FromInt(0))->ToObjectChecked(); | 762 *JSArray::SetElementsLength(array, handle(Smi::FromInt(0), isolate)); |
| 763 CHECK_EQ(Smi::FromInt(0), array->length()); | 763 CHECK_EQ(Smi::FromInt(0), array->length()); |
| 764 // Must be in fast mode. | 764 // Must be in fast mode. |
| 765 CHECK(array->HasFastSmiOrObjectElements()); | 765 CHECK(array->HasFastSmiOrObjectElements()); |
| 766 | 766 |
| 767 // array[length] = name. | 767 // array[length] = name. |
| 768 JSReceiver::SetElement(array, 0, name, NONE, SLOPPY); | 768 JSReceiver::SetElement(array, 0, name, NONE, SLOPPY); |
| 769 CHECK_EQ(Smi::FromInt(1), array->length()); | 769 CHECK_EQ(Smi::FromInt(1), array->length()); |
| 770 CHECK_EQ(*i::Object::GetElement(isolate, array, 0), *name); | 770 CHECK_EQ(*i::Object::GetElement(isolate, array, 0), *name); |
| 771 | 771 |
| 772 // Set array length with larger than smi value. | 772 // Set array length with larger than smi value. |
| 773 Handle<Object> length = | 773 Handle<Object> length = |
| 774 factory->NewNumberFromUint(static_cast<uint32_t>(Smi::kMaxValue) + 1); | 774 factory->NewNumberFromUint(static_cast<uint32_t>(Smi::kMaxValue) + 1); |
| 775 array->SetElementsLength(*length)->ToObjectChecked(); | 775 *JSArray::SetElementsLength(array, length); |
| 776 | 776 |
| 777 uint32_t int_length = 0; | 777 uint32_t int_length = 0; |
| 778 CHECK(length->ToArrayIndex(&int_length)); | 778 CHECK(length->ToArrayIndex(&int_length)); |
| 779 CHECK_EQ(*length, array->length()); | 779 CHECK_EQ(*length, array->length()); |
| 780 CHECK(array->HasDictionaryElements()); // Must be in slow mode. | 780 CHECK(array->HasDictionaryElements()); // Must be in slow mode. |
| 781 | 781 |
| 782 // array[length] = name. | 782 // array[length] = name. |
| 783 JSReceiver::SetElement(array, int_length, name, NONE, SLOPPY); | 783 JSReceiver::SetElement(array, int_length, name, NONE, SLOPPY); |
| 784 uint32_t new_int_length = 0; | 784 uint32_t new_int_length = 0; |
| 785 CHECK(array->length()->ToArrayIndex(&new_int_length)); | 785 CHECK(array->length()->ToArrayIndex(&new_int_length)); |
| (...skipping 2952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3738 v8::Handle<v8::Object> global = CcTest::global(); | 3738 v8::Handle<v8::Object> global = CcTest::global(); |
| 3739 v8::Handle<v8::Function> g = | 3739 v8::Handle<v8::Function> g = |
| 3740 v8::Handle<v8::Function>::Cast(global->Get(v8_str("crash"))); | 3740 v8::Handle<v8::Function>::Cast(global->Get(v8_str("crash"))); |
| 3741 v8::Handle<v8::Value> args1[] = { v8_num(1) }; | 3741 v8::Handle<v8::Value> args1[] = { v8_num(1) }; |
| 3742 heap->DisableInlineAllocation(); | 3742 heap->DisableInlineAllocation(); |
| 3743 heap->set_allocation_timeout(1); | 3743 heap->set_allocation_timeout(1); |
| 3744 g->Call(global, 1, args1); | 3744 g->Call(global, 1, args1); |
| 3745 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 3745 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
| 3746 } | 3746 } |
| 3747 #endif | 3747 #endif |
| OLD | NEW |