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

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

Issue 268063008: Replace NewFunctionWithPrototype(name, prototype) by NewFunction(name) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 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 | « test/cctest/test-alloc.cc ('k') | test/cctest/test-mark-compact.cc » ('j') | 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 Handle<String> name = factory->InternalizeUtf8String("theFunction"); 254 Handle<String> name = factory->InternalizeUtf8String("theFunction");
255 Handle<String> prop_name = factory->InternalizeUtf8String("theSlot"); 255 Handle<String> prop_name = factory->InternalizeUtf8String("theSlot");
256 Handle<String> prop_namex = factory->InternalizeUtf8String("theSlotx"); 256 Handle<String> prop_namex = factory->InternalizeUtf8String("theSlotx");
257 Handle<String> obj_name = factory->InternalizeUtf8String("theObject"); 257 Handle<String> obj_name = factory->InternalizeUtf8String("theObject");
258 Handle<Smi> twenty_three(Smi::FromInt(23), isolate); 258 Handle<Smi> twenty_three(Smi::FromInt(23), isolate);
259 Handle<Smi> twenty_four(Smi::FromInt(24), isolate); 259 Handle<Smi> twenty_four(Smi::FromInt(24), isolate);
260 260
261 { 261 {
262 HandleScope inner_scope(isolate); 262 HandleScope inner_scope(isolate);
263 // Allocate a function and keep it in global object's property. 263 // Allocate a function and keep it in global object's property.
264 Handle<JSFunction> function = factory->NewFunctionWithPrototype( 264 Handle<JSFunction> function = factory->NewFunction(name);
265 name, factory->undefined_value());
266 Handle<Map> initial_map =
267 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
268 function->set_initial_map(*initial_map);
269 JSReceiver::SetProperty(global, name, function, NONE, SLOPPY).Check(); 265 JSReceiver::SetProperty(global, name, function, NONE, SLOPPY).Check();
270 // Allocate an object. Unrooted after leaving the scope. 266 // Allocate an object. Unrooted after leaving the scope.
271 Handle<JSObject> obj = factory->NewJSObject(function); 267 Handle<JSObject> obj = factory->NewJSObject(function);
272 JSReceiver::SetProperty( 268 JSReceiver::SetProperty(
273 obj, prop_name, twenty_three, NONE, SLOPPY).Check(); 269 obj, prop_name, twenty_three, NONE, SLOPPY).Check();
274 JSReceiver::SetProperty( 270 JSReceiver::SetProperty(
275 obj, prop_namex, twenty_four, NONE, SLOPPY).Check(); 271 obj, prop_namex, twenty_four, NONE, SLOPPY).Check();
276 272
277 CHECK_EQ(Smi::FromInt(23), 273 CHECK_EQ(Smi::FromInt(23),
278 *Object::GetProperty(obj, prop_name).ToHandleChecked()); 274 *Object::GetProperty(obj, prop_name).ToHandleChecked());
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 } 613 }
618 614
619 615
620 TEST(FunctionAllocation) { 616 TEST(FunctionAllocation) {
621 CcTest::InitializeVM(); 617 CcTest::InitializeVM();
622 Isolate* isolate = CcTest::i_isolate(); 618 Isolate* isolate = CcTest::i_isolate();
623 Factory* factory = isolate->factory(); 619 Factory* factory = isolate->factory();
624 620
625 v8::HandleScope sc(CcTest::isolate()); 621 v8::HandleScope sc(CcTest::isolate());
626 Handle<String> name = factory->InternalizeUtf8String("theFunction"); 622 Handle<String> name = factory->InternalizeUtf8String("theFunction");
627 Handle<JSFunction> function = factory->NewFunctionWithPrototype( 623 Handle<JSFunction> function = factory->NewFunction(name);
628 name, factory->undefined_value());
629 Handle<Map> initial_map =
630 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
631 function->set_initial_map(*initial_map);
632 624
633 Handle<Smi> twenty_three(Smi::FromInt(23), isolate); 625 Handle<Smi> twenty_three(Smi::FromInt(23), isolate);
634 Handle<Smi> twenty_four(Smi::FromInt(24), isolate); 626 Handle<Smi> twenty_four(Smi::FromInt(24), isolate);
635 627
636 Handle<String> prop_name = factory->InternalizeUtf8String("theSlot"); 628 Handle<String> prop_name = factory->InternalizeUtf8String("theSlot");
637 Handle<JSObject> obj = factory->NewJSObject(function); 629 Handle<JSObject> obj = factory->NewJSObject(function);
638 JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, SLOPPY).Check(); 630 JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, SLOPPY).Check();
639 CHECK_EQ(Smi::FromInt(23), 631 CHECK_EQ(Smi::FromInt(23),
640 *Object::GetProperty(obj, prop_name).ToHandleChecked()); 632 *Object::GetProperty(obj, prop_name).ToHandleChecked());
641 // Check that we can add properties to function objects. 633 // Check that we can add properties to function objects.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 } 708 }
717 709
718 710
719 TEST(JSObjectMaps) { 711 TEST(JSObjectMaps) {
720 CcTest::InitializeVM(); 712 CcTest::InitializeVM();
721 Isolate* isolate = CcTest::i_isolate(); 713 Isolate* isolate = CcTest::i_isolate();
722 Factory* factory = isolate->factory(); 714 Factory* factory = isolate->factory();
723 715
724 v8::HandleScope sc(CcTest::isolate()); 716 v8::HandleScope sc(CcTest::isolate());
725 Handle<String> name = factory->InternalizeUtf8String("theFunction"); 717 Handle<String> name = factory->InternalizeUtf8String("theFunction");
726 Handle<JSFunction> function = factory->NewFunctionWithPrototype( 718 Handle<JSFunction> function = factory->NewFunction(name);
727 name, factory->undefined_value());
728 Handle<Map> initial_map =
729 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
730 function->set_initial_map(*initial_map);
731 719
732 Handle<String> prop_name = factory->InternalizeUtf8String("theSlot"); 720 Handle<String> prop_name = factory->InternalizeUtf8String("theSlot");
733 Handle<JSObject> obj = factory->NewJSObject(function); 721 Handle<JSObject> obj = factory->NewJSObject(function);
722 Handle<Map> initial_map(function->initial_map());
734 723
735 // Set a propery 724 // Set a propery
736 Handle<Smi> twenty_three(Smi::FromInt(23), isolate); 725 Handle<Smi> twenty_three(Smi::FromInt(23), isolate);
737 JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, SLOPPY).Check(); 726 JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, SLOPPY).Check();
738 CHECK_EQ(Smi::FromInt(23), 727 CHECK_EQ(Smi::FromInt(23),
739 *Object::GetProperty(obj, prop_name).ToHandleChecked()); 728 *Object::GetProperty(obj, prop_name).ToHandleChecked());
740 729
741 // Check the map has changed 730 // Check the map has changed
742 CHECK(*initial_map != obj->map()); 731 CHECK(*initial_map != obj->map());
743 } 732 }
(...skipping 3471 matching lines...) Expand 10 before | Expand all | Expand 10 after
4215 "array;"); 4204 "array;");
4216 4205
4217 Handle<JSObject> o = 4206 Handle<JSObject> o =
4218 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(result)); 4207 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(result));
4219 CHECK(heap->InOldPointerSpace(o->elements())); 4208 CHECK(heap->InOldPointerSpace(o->elements()));
4220 CHECK(heap->InOldPointerSpace(*o)); 4209 CHECK(heap->InOldPointerSpace(*o));
4221 Page* page = Page::FromAddress(o->elements()->address()); 4210 Page* page = Page::FromAddress(o->elements()->address());
4222 CHECK(page->WasSwept() || 4211 CHECK(page->WasSwept() ||
4223 Marking::IsBlack(Marking::MarkBitFrom(o->elements()))); 4212 Marking::IsBlack(Marking::MarkBitFrom(o->elements())));
4224 } 4213 }
OLDNEW
« no previous file with comments | « test/cctest/test-alloc.cc ('k') | test/cctest/test-mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698