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

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

Issue 229943006: ElementsAccessor::SetLength() maybehandlified. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 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/runtime.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 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 Handle<JSFunction> function = Handle<JSFunction>( 766 Handle<JSFunction> function = Handle<JSFunction>(
767 JSFunction::cast(raw_object)); 767 JSFunction::cast(raw_object));
768 768
769 // Allocate the object. 769 // Allocate the object.
770 Handle<JSObject> object = factory->NewJSObject(function); 770 Handle<JSObject> object = factory->NewJSObject(function);
771 Handle<JSArray> array = Handle<JSArray>::cast(object); 771 Handle<JSArray> array = Handle<JSArray>::cast(object);
772 // We just initialized the VM, no heap allocation failure yet. 772 // We just initialized the VM, no heap allocation failure yet.
773 JSArray::Initialize(array, 0); 773 JSArray::Initialize(array, 0);
774 774
775 // Set array length to 0. 775 // Set array length to 0.
776 *JSArray::SetElementsLength(array, handle(Smi::FromInt(0), isolate)); 776 JSArray::SetElementsLength(array, handle(Smi::FromInt(0), isolate)).Check();
777 CHECK_EQ(Smi::FromInt(0), array->length()); 777 CHECK_EQ(Smi::FromInt(0), array->length());
778 // Must be in fast mode. 778 // Must be in fast mode.
779 CHECK(array->HasFastSmiOrObjectElements()); 779 CHECK(array->HasFastSmiOrObjectElements());
780 780
781 // array[length] = name. 781 // array[length] = name.
782 JSReceiver::SetElement(array, 0, name, NONE, SLOPPY).Check(); 782 JSReceiver::SetElement(array, 0, name, NONE, SLOPPY).Check();
783 CHECK_EQ(Smi::FromInt(1), array->length()); 783 CHECK_EQ(Smi::FromInt(1), array->length());
784 CHECK_EQ(*i::Object::GetElement(isolate, array, 0), *name); 784 CHECK_EQ(*i::Object::GetElement(isolate, array, 0), *name);
785 785
786 // Set array length with larger than smi value. 786 // Set array length with larger than smi value.
787 Handle<Object> length = 787 Handle<Object> length =
788 factory->NewNumberFromUint(static_cast<uint32_t>(Smi::kMaxValue) + 1); 788 factory->NewNumberFromUint(static_cast<uint32_t>(Smi::kMaxValue) + 1);
789 *JSArray::SetElementsLength(array, length); 789 JSArray::SetElementsLength(array, length).Check();
790 790
791 uint32_t int_length = 0; 791 uint32_t int_length = 0;
792 CHECK(length->ToArrayIndex(&int_length)); 792 CHECK(length->ToArrayIndex(&int_length));
793 CHECK_EQ(*length, array->length()); 793 CHECK_EQ(*length, array->length());
794 CHECK(array->HasDictionaryElements()); // Must be in slow mode. 794 CHECK(array->HasDictionaryElements()); // Must be in slow mode.
795 795
796 // array[length] = name. 796 // array[length] = name.
797 JSReceiver::SetElement(array, int_length, name, NONE, SLOPPY).Check(); 797 JSReceiver::SetElement(array, int_length, name, NONE, SLOPPY).Check();
798 uint32_t new_int_length = 0; 798 uint32_t new_int_length = 0;
799 CHECK(array->length()->ToArrayIndex(&new_int_length)); 799 CHECK(array->length()->ToArrayIndex(&new_int_length));
(...skipping 3137 matching lines...) Expand 10 before | Expand all | Expand 10 after
3937 v8::Context::Scope cscope(context); 3937 v8::Context::Scope cscope(context);
3938 3938
3939 v8::Local<v8::Value> result = CompileRun( 3939 v8::Local<v8::Value> result = CompileRun(
3940 "var locals = '';" 3940 "var locals = '';"
3941 "for (var i = 0; i < 512; i++) locals += 'var v' + i + '= 42;';" 3941 "for (var i = 0; i < 512; i++) locals += 'var v' + i + '= 42;';"
3942 "eval('function f() {' + locals + 'return function() { return v0; }; }');" 3942 "eval('function f() {' + locals + 'return function() { return v0; }; }');"
3943 "interrupt();" // This triggers a fake stack overflow in f. 3943 "interrupt();" // This triggers a fake stack overflow in f.
3944 "f()()"); 3944 "f()()");
3945 CHECK_EQ(42.0, result->ToNumber()->Value()); 3945 CHECK_EQ(42.0, result->ToNumber()->Value());
3946 } 3946 }
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698