Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(613)

Side by Side Diff: test/cctest/test-heap.cc

Issue 203333004: Handlification of JSArray::SetElementsLength(). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing review notes Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 2991 matching lines...) Expand 10 before | Expand all | Expand 10 after
3777 v8::Handle<v8::Object> global = CcTest::global(); 3777 v8::Handle<v8::Object> global = CcTest::global();
3778 v8::Handle<v8::Function> g = 3778 v8::Handle<v8::Function> g =
3779 v8::Handle<v8::Function>::Cast(global->Get(v8_str("crash"))); 3779 v8::Handle<v8::Function>::Cast(global->Get(v8_str("crash")));
3780 v8::Handle<v8::Value> args1[] = { v8_num(1) }; 3780 v8::Handle<v8::Value> args1[] = { v8_num(1) };
3781 heap->DisableInlineAllocation(); 3781 heap->DisableInlineAllocation();
3782 heap->set_allocation_timeout(1); 3782 heap->set_allocation_timeout(1);
3783 g->Call(global, 1, args1); 3783 g->Call(global, 1, args1);
3784 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 3784 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
3785 } 3785 }
3786 #endif 3786 #endif
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698