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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 // nan oddball checks | 202 // nan oddball checks |
203 CHECK(factory->nan_value()->IsNumber()); | 203 CHECK(factory->nan_value()->IsNumber()); |
204 CHECK(std::isnan(factory->nan_value()->Number())); | 204 CHECK(std::isnan(factory->nan_value()->Number())); |
205 | 205 |
206 Handle<String> s = factory->NewStringFromStaticAscii("fisk hest "); | 206 Handle<String> s = factory->NewStringFromStaticAscii("fisk hest "); |
207 CHECK(s->IsString()); | 207 CHECK(s->IsString()); |
208 CHECK_EQ(10, s->length()); | 208 CHECK_EQ(10, s->length()); |
209 | 209 |
210 Handle<String> object_string = Handle<String>::cast(factory->Object_string()); | 210 Handle<String> object_string = Handle<String>::cast(factory->Object_string()); |
211 Handle<GlobalObject> global(CcTest::i_isolate()->context()->global_object()); | 211 Handle<GlobalObject> global(CcTest::i_isolate()->context()->global_object()); |
212 CHECK(JSReceiver::HasLocalProperty(global, object_string)); | 212 CHECK(JSReceiver::HasOwnProperty(global, object_string)); |
213 | 213 |
214 // Check ToString for oddballs | 214 // Check ToString for oddballs |
215 CheckOddball(isolate, heap->true_value(), "true"); | 215 CheckOddball(isolate, heap->true_value(), "true"); |
216 CheckOddball(isolate, heap->false_value(), "false"); | 216 CheckOddball(isolate, heap->false_value(), "false"); |
217 CheckOddball(isolate, heap->null_value(), "null"); | 217 CheckOddball(isolate, heap->null_value(), "null"); |
218 CheckOddball(isolate, heap->undefined_value(), "undefined"); | 218 CheckOddball(isolate, heap->undefined_value(), "undefined"); |
219 | 219 |
220 // Check ToString for Smis | 220 // Check ToString for Smis |
221 CheckSmi(isolate, 0, "0"); | 221 CheckSmi(isolate, 0, "0"); |
222 CheckSmi(isolate, 42, "42"); | 222 CheckSmi(isolate, 42, "42"); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 | 271 |
272 CHECK_EQ(Smi::FromInt(23), | 272 CHECK_EQ(Smi::FromInt(23), |
273 *Object::GetProperty(obj, prop_name).ToHandleChecked()); | 273 *Object::GetProperty(obj, prop_name).ToHandleChecked()); |
274 CHECK_EQ(Smi::FromInt(24), | 274 CHECK_EQ(Smi::FromInt(24), |
275 *Object::GetProperty(obj, prop_namex).ToHandleChecked()); | 275 *Object::GetProperty(obj, prop_namex).ToHandleChecked()); |
276 } | 276 } |
277 | 277 |
278 heap->CollectGarbage(NEW_SPACE); | 278 heap->CollectGarbage(NEW_SPACE); |
279 | 279 |
280 // Function should be alive. | 280 // Function should be alive. |
281 CHECK(JSReceiver::HasLocalProperty(global, name)); | 281 CHECK(JSReceiver::HasOwnProperty(global, name)); |
282 // Check function is retained. | 282 // Check function is retained. |
283 Handle<Object> func_value = | 283 Handle<Object> func_value = |
284 Object::GetProperty(global, name).ToHandleChecked(); | 284 Object::GetProperty(global, name).ToHandleChecked(); |
285 CHECK(func_value->IsJSFunction()); | 285 CHECK(func_value->IsJSFunction()); |
286 Handle<JSFunction> function = Handle<JSFunction>::cast(func_value); | 286 Handle<JSFunction> function = Handle<JSFunction>::cast(func_value); |
287 | 287 |
288 { | 288 { |
289 HandleScope inner_scope(isolate); | 289 HandleScope inner_scope(isolate); |
290 // Allocate another object, make it reachable from global. | 290 // Allocate another object, make it reachable from global. |
291 Handle<JSObject> obj = factory->NewJSObject(function); | 291 Handle<JSObject> obj = factory->NewJSObject(function); |
292 JSReceiver::SetProperty(global, obj_name, obj, NONE, SLOPPY).Check(); | 292 JSReceiver::SetProperty(global, obj_name, obj, NONE, SLOPPY).Check(); |
293 JSReceiver::SetProperty( | 293 JSReceiver::SetProperty( |
294 obj, prop_name, twenty_three, NONE, SLOPPY).Check(); | 294 obj, prop_name, twenty_three, NONE, SLOPPY).Check(); |
295 } | 295 } |
296 | 296 |
297 // After gc, it should survive. | 297 // After gc, it should survive. |
298 heap->CollectGarbage(NEW_SPACE); | 298 heap->CollectGarbage(NEW_SPACE); |
299 | 299 |
300 CHECK(JSReceiver::HasLocalProperty(global, obj_name)); | 300 CHECK(JSReceiver::HasOwnProperty(global, obj_name)); |
301 Handle<Object> obj = | 301 Handle<Object> obj = |
302 Object::GetProperty(global, obj_name).ToHandleChecked(); | 302 Object::GetProperty(global, obj_name).ToHandleChecked(); |
303 CHECK(obj->IsJSObject()); | 303 CHECK(obj->IsJSObject()); |
304 CHECK_EQ(Smi::FromInt(23), | 304 CHECK_EQ(Smi::FromInt(23), |
305 *Object::GetProperty(obj, prop_name).ToHandleChecked()); | 305 *Object::GetProperty(obj, prop_name).ToHandleChecked()); |
306 } | 306 } |
307 | 307 |
308 | 308 |
309 static void VerifyStringAllocation(Isolate* isolate, const char* string) { | 309 static void VerifyStringAllocation(Isolate* isolate, const char* string) { |
310 HandleScope scope(isolate); | 310 HandleScope scope(isolate); |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 CcTest::i_isolate()->global_object(), object_string).ToHandleChecked(); | 648 CcTest::i_isolate()->global_object(), object_string).ToHandleChecked(); |
649 Handle<JSFunction> constructor = Handle<JSFunction>::cast(object); | 649 Handle<JSFunction> constructor = Handle<JSFunction>::cast(object); |
650 Handle<JSObject> obj = factory->NewJSObject(constructor); | 650 Handle<JSObject> obj = factory->NewJSObject(constructor); |
651 Handle<String> first = factory->InternalizeUtf8String("first"); | 651 Handle<String> first = factory->InternalizeUtf8String("first"); |
652 Handle<String> second = factory->InternalizeUtf8String("second"); | 652 Handle<String> second = factory->InternalizeUtf8String("second"); |
653 | 653 |
654 Handle<Smi> one(Smi::FromInt(1), isolate); | 654 Handle<Smi> one(Smi::FromInt(1), isolate); |
655 Handle<Smi> two(Smi::FromInt(2), isolate); | 655 Handle<Smi> two(Smi::FromInt(2), isolate); |
656 | 656 |
657 // check for empty | 657 // check for empty |
658 CHECK(!JSReceiver::HasLocalProperty(obj, first)); | 658 CHECK(!JSReceiver::HasOwnProperty(obj, first)); |
659 | 659 |
660 // add first | 660 // add first |
661 JSReceiver::SetProperty(obj, first, one, NONE, SLOPPY).Check(); | 661 JSReceiver::SetProperty(obj, first, one, NONE, SLOPPY).Check(); |
662 CHECK(JSReceiver::HasLocalProperty(obj, first)); | 662 CHECK(JSReceiver::HasOwnProperty(obj, first)); |
663 | 663 |
664 // delete first | 664 // delete first |
665 JSReceiver::DeleteProperty(obj, first, JSReceiver::NORMAL_DELETION).Check(); | 665 JSReceiver::DeleteProperty(obj, first, JSReceiver::NORMAL_DELETION).Check(); |
666 CHECK(!JSReceiver::HasLocalProperty(obj, first)); | 666 CHECK(!JSReceiver::HasOwnProperty(obj, first)); |
667 | 667 |
668 // add first and then second | 668 // add first and then second |
669 JSReceiver::SetProperty(obj, first, one, NONE, SLOPPY).Check(); | 669 JSReceiver::SetProperty(obj, first, one, NONE, SLOPPY).Check(); |
670 JSReceiver::SetProperty(obj, second, two, NONE, SLOPPY).Check(); | 670 JSReceiver::SetProperty(obj, second, two, NONE, SLOPPY).Check(); |
671 CHECK(JSReceiver::HasLocalProperty(obj, first)); | 671 CHECK(JSReceiver::HasOwnProperty(obj, first)); |
672 CHECK(JSReceiver::HasLocalProperty(obj, second)); | 672 CHECK(JSReceiver::HasOwnProperty(obj, second)); |
673 | 673 |
674 // delete first and then second | 674 // delete first and then second |
675 JSReceiver::DeleteProperty(obj, first, JSReceiver::NORMAL_DELETION).Check(); | 675 JSReceiver::DeleteProperty(obj, first, JSReceiver::NORMAL_DELETION).Check(); |
676 CHECK(JSReceiver::HasLocalProperty(obj, second)); | 676 CHECK(JSReceiver::HasOwnProperty(obj, second)); |
677 JSReceiver::DeleteProperty(obj, second, JSReceiver::NORMAL_DELETION).Check(); | 677 JSReceiver::DeleteProperty(obj, second, JSReceiver::NORMAL_DELETION).Check(); |
678 CHECK(!JSReceiver::HasLocalProperty(obj, first)); | 678 CHECK(!JSReceiver::HasOwnProperty(obj, first)); |
679 CHECK(!JSReceiver::HasLocalProperty(obj, second)); | 679 CHECK(!JSReceiver::HasOwnProperty(obj, second)); |
680 | 680 |
681 // add first and then second | 681 // add first and then second |
682 JSReceiver::SetProperty(obj, first, one, NONE, SLOPPY).Check(); | 682 JSReceiver::SetProperty(obj, first, one, NONE, SLOPPY).Check(); |
683 JSReceiver::SetProperty(obj, second, two, NONE, SLOPPY).Check(); | 683 JSReceiver::SetProperty(obj, second, two, NONE, SLOPPY).Check(); |
684 CHECK(JSReceiver::HasLocalProperty(obj, first)); | 684 CHECK(JSReceiver::HasOwnProperty(obj, first)); |
685 CHECK(JSReceiver::HasLocalProperty(obj, second)); | 685 CHECK(JSReceiver::HasOwnProperty(obj, second)); |
686 | 686 |
687 // delete second and then first | 687 // delete second and then first |
688 JSReceiver::DeleteProperty(obj, second, JSReceiver::NORMAL_DELETION).Check(); | 688 JSReceiver::DeleteProperty(obj, second, JSReceiver::NORMAL_DELETION).Check(); |
689 CHECK(JSReceiver::HasLocalProperty(obj, first)); | 689 CHECK(JSReceiver::HasOwnProperty(obj, first)); |
690 JSReceiver::DeleteProperty(obj, first, JSReceiver::NORMAL_DELETION).Check(); | 690 JSReceiver::DeleteProperty(obj, first, JSReceiver::NORMAL_DELETION).Check(); |
691 CHECK(!JSReceiver::HasLocalProperty(obj, first)); | 691 CHECK(!JSReceiver::HasOwnProperty(obj, first)); |
692 CHECK(!JSReceiver::HasLocalProperty(obj, second)); | 692 CHECK(!JSReceiver::HasOwnProperty(obj, second)); |
693 | 693 |
694 // check string and internalized string match | 694 // check string and internalized string match |
695 const char* string1 = "fisk"; | 695 const char* string1 = "fisk"; |
696 Handle<String> s1 = factory->NewStringFromAsciiChecked(string1); | 696 Handle<String> s1 = factory->NewStringFromAsciiChecked(string1); |
697 JSReceiver::SetProperty(obj, s1, one, NONE, SLOPPY).Check(); | 697 JSReceiver::SetProperty(obj, s1, one, NONE, SLOPPY).Check(); |
698 Handle<String> s1_string = factory->InternalizeUtf8String(string1); | 698 Handle<String> s1_string = factory->InternalizeUtf8String(string1); |
699 CHECK(JSReceiver::HasLocalProperty(obj, s1_string)); | 699 CHECK(JSReceiver::HasOwnProperty(obj, s1_string)); |
700 | 700 |
701 // check internalized string and string match | 701 // check internalized string and string match |
702 const char* string2 = "fugl"; | 702 const char* string2 = "fugl"; |
703 Handle<String> s2_string = factory->InternalizeUtf8String(string2); | 703 Handle<String> s2_string = factory->InternalizeUtf8String(string2); |
704 JSReceiver::SetProperty(obj, s2_string, one, NONE, SLOPPY).Check(); | 704 JSReceiver::SetProperty(obj, s2_string, one, NONE, SLOPPY).Check(); |
705 Handle<String> s2 = factory->NewStringFromAsciiChecked(string2); | 705 Handle<String> s2 = factory->NewStringFromAsciiChecked(string2); |
706 CHECK(JSReceiver::HasLocalProperty(obj, s2)); | 706 CHECK(JSReceiver::HasOwnProperty(obj, s2)); |
707 } | 707 } |
708 | 708 |
709 | 709 |
710 TEST(JSObjectMaps) { | 710 TEST(JSObjectMaps) { |
711 CcTest::InitializeVM(); | 711 CcTest::InitializeVM(); |
712 Isolate* isolate = CcTest::i_isolate(); | 712 Isolate* isolate = CcTest::i_isolate(); |
713 Factory* factory = isolate->factory(); | 713 Factory* factory = isolate->factory(); |
714 | 714 |
715 v8::HandleScope sc(CcTest::isolate()); | 715 v8::HandleScope sc(CcTest::isolate()); |
716 Handle<String> name = factory->InternalizeUtf8String("theFunction"); | 716 Handle<String> name = factory->InternalizeUtf8String("theFunction"); |
(...skipping 3527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4244 "array;"); | 4244 "array;"); |
4245 | 4245 |
4246 Handle<JSObject> o = | 4246 Handle<JSObject> o = |
4247 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(result)); | 4247 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(result)); |
4248 CHECK(heap->InOldPointerSpace(o->elements())); | 4248 CHECK(heap->InOldPointerSpace(o->elements())); |
4249 CHECK(heap->InOldPointerSpace(*o)); | 4249 CHECK(heap->InOldPointerSpace(*o)); |
4250 Page* page = Page::FromAddress(o->elements()->address()); | 4250 Page* page = Page::FromAddress(o->elements()->address()); |
4251 CHECK(page->WasSwept() || | 4251 CHECK(page->WasSwept() || |
4252 Marking::IsBlack(Marking::MarkBitFrom(o->elements()))); | 4252 Marking::IsBlack(Marking::MarkBitFrom(o->elements()))); |
4253 } | 4253 } |
OLD | NEW |