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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 CHECK(copy->IsCode()); | 141 CHECK(copy->IsCode()); |
142 HeapObject* obj_copy = HeapObject::cast(copy); | 142 HeapObject* obj_copy = HeapObject::cast(copy); |
143 Object* not_right = isolate->FindCodeObject(obj_copy->address() + | 143 Object* not_right = isolate->FindCodeObject(obj_copy->address() + |
144 obj_copy->Size() / 2); | 144 obj_copy->Size() / 2); |
145 CHECK(not_right != code); | 145 CHECK(not_right != code); |
146 } | 146 } |
147 | 147 |
148 | 148 |
149 TEST(HeapObjects) { | 149 TEST(HeapObjects) { |
150 CcTest::InitializeVM(); | 150 CcTest::InitializeVM(); |
151 Isolate* isolate = Isolate::Current(); | 151 Isolate* isolate = CcTest::i_isolate(); |
152 Factory* factory = isolate->factory(); | 152 Factory* factory = isolate->factory(); |
153 Heap* heap = isolate->heap(); | 153 Heap* heap = isolate->heap(); |
154 | 154 |
155 HandleScope sc(isolate); | 155 HandleScope sc(isolate); |
156 Object* value = heap->NumberFromDouble(1.000123)->ToObjectChecked(); | 156 Object* value = heap->NumberFromDouble(1.000123)->ToObjectChecked(); |
157 CHECK(value->IsHeapNumber()); | 157 CHECK(value->IsHeapNumber()); |
158 CHECK(value->IsNumber()); | 158 CHECK(value->IsNumber()); |
159 CHECK_EQ(1.000123, value->Number()); | 159 CHECK_EQ(1.000123, value->Number()); |
160 | 160 |
161 value = heap->NumberFromDouble(1.0)->ToObjectChecked(); | 161 value = heap->NumberFromDouble(1.0)->ToObjectChecked(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 | 203 |
204 // nan oddball checks | 204 // nan oddball checks |
205 CHECK(heap->nan_value()->IsNumber()); | 205 CHECK(heap->nan_value()->IsNumber()); |
206 CHECK(std::isnan(heap->nan_value()->Number())); | 206 CHECK(std::isnan(heap->nan_value()->Number())); |
207 | 207 |
208 Handle<String> s = factory->NewStringFromAscii(CStrVector("fisk hest ")); | 208 Handle<String> s = factory->NewStringFromAscii(CStrVector("fisk hest ")); |
209 CHECK(s->IsString()); | 209 CHECK(s->IsString()); |
210 CHECK_EQ(10, s->length()); | 210 CHECK_EQ(10, s->length()); |
211 | 211 |
212 Handle<String> object_string = Handle<String>::cast(factory->Object_string()); | 212 Handle<String> object_string = Handle<String>::cast(factory->Object_string()); |
213 Handle<GlobalObject> global(Isolate::Current()->context()->global_object()); | 213 Handle<GlobalObject> global(CcTest::i_isolate()->context()->global_object()); |
214 CHECK(JSReceiver::HasLocalProperty(global, object_string)); | 214 CHECK(JSReceiver::HasLocalProperty(global, object_string)); |
215 | 215 |
216 // Check ToString for oddballs | 216 // Check ToString for oddballs |
217 CheckOddball(isolate, heap->true_value(), "true"); | 217 CheckOddball(isolate, heap->true_value(), "true"); |
218 CheckOddball(isolate, heap->false_value(), "false"); | 218 CheckOddball(isolate, heap->false_value(), "false"); |
219 CheckOddball(isolate, heap->null_value(), "null"); | 219 CheckOddball(isolate, heap->null_value(), "null"); |
220 CheckOddball(isolate, heap->undefined_value(), "undefined"); | 220 CheckOddball(isolate, heap->undefined_value(), "undefined"); |
221 | 221 |
222 // Check ToString for Smis | 222 // Check ToString for Smis |
223 CheckSmi(isolate, 0, "0"); | 223 CheckSmi(isolate, 0, "0"); |
(...skipping 18 matching lines...) Expand all Loading... |
242 CHECK_EQ(OLD_POINTER_SPACE, | 242 CHECK_EQ(OLD_POINTER_SPACE, |
243 Failure::RetryAfterGC(OLD_POINTER_SPACE)->allocation_space()); | 243 Failure::RetryAfterGC(OLD_POINTER_SPACE)->allocation_space()); |
244 CHECK(Failure::Exception()->IsFailure()); | 244 CHECK(Failure::Exception()->IsFailure()); |
245 CHECK(Smi::FromInt(Smi::kMinValue)->IsSmi()); | 245 CHECK(Smi::FromInt(Smi::kMinValue)->IsSmi()); |
246 CHECK(Smi::FromInt(Smi::kMaxValue)->IsSmi()); | 246 CHECK(Smi::FromInt(Smi::kMaxValue)->IsSmi()); |
247 } | 247 } |
248 | 248 |
249 | 249 |
250 TEST(GarbageCollection) { | 250 TEST(GarbageCollection) { |
251 CcTest::InitializeVM(); | 251 CcTest::InitializeVM(); |
252 Isolate* isolate = Isolate::Current(); | 252 Isolate* isolate = CcTest::i_isolate(); |
253 Heap* heap = isolate->heap(); | 253 Heap* heap = isolate->heap(); |
254 Factory* factory = isolate->factory(); | 254 Factory* factory = isolate->factory(); |
255 | 255 |
256 HandleScope sc(isolate); | 256 HandleScope sc(isolate); |
257 // Check GC. | 257 // Check GC. |
258 heap->CollectGarbage(NEW_SPACE); | 258 heap->CollectGarbage(NEW_SPACE); |
259 | 259 |
260 Handle<GlobalObject> global(Isolate::Current()->context()->global_object()); | 260 Handle<GlobalObject> global(CcTest::i_isolate()->context()->global_object()); |
261 Handle<String> name = factory->InternalizeUtf8String("theFunction"); | 261 Handle<String> name = factory->InternalizeUtf8String("theFunction"); |
262 Handle<String> prop_name = factory->InternalizeUtf8String("theSlot"); | 262 Handle<String> prop_name = factory->InternalizeUtf8String("theSlot"); |
263 Handle<String> prop_namex = factory->InternalizeUtf8String("theSlotx"); | 263 Handle<String> prop_namex = factory->InternalizeUtf8String("theSlotx"); |
264 Handle<String> obj_name = factory->InternalizeUtf8String("theObject"); | 264 Handle<String> obj_name = factory->InternalizeUtf8String("theObject"); |
265 Handle<Smi> twenty_three(Smi::FromInt(23), isolate); | 265 Handle<Smi> twenty_three(Smi::FromInt(23), isolate); |
266 Handle<Smi> twenty_four(Smi::FromInt(24), isolate); | 266 Handle<Smi> twenty_four(Smi::FromInt(24), isolate); |
267 | 267 |
268 { | 268 { |
269 HandleScope inner_scope(isolate); | 269 HandleScope inner_scope(isolate); |
270 // Allocate a function and keep it in global object's property. | 270 // Allocate a function and keep it in global object's property. |
(...skipping 10 matching lines...) Expand all Loading... |
281 | 281 |
282 CHECK_EQ(Smi::FromInt(23), obj->GetProperty(*prop_name)); | 282 CHECK_EQ(Smi::FromInt(23), obj->GetProperty(*prop_name)); |
283 CHECK_EQ(Smi::FromInt(24), obj->GetProperty(*prop_namex)); | 283 CHECK_EQ(Smi::FromInt(24), obj->GetProperty(*prop_namex)); |
284 } | 284 } |
285 | 285 |
286 heap->CollectGarbage(NEW_SPACE); | 286 heap->CollectGarbage(NEW_SPACE); |
287 | 287 |
288 // Function should be alive. | 288 // Function should be alive. |
289 CHECK(JSReceiver::HasLocalProperty(global, name)); | 289 CHECK(JSReceiver::HasLocalProperty(global, name)); |
290 // Check function is retained. | 290 // Check function is retained. |
291 Object* func_value = Isolate::Current()->context()->global_object()-> | 291 Object* func_value = CcTest::i_isolate()->context()->global_object()-> |
292 GetProperty(*name)->ToObjectChecked(); | 292 GetProperty(*name)->ToObjectChecked(); |
293 CHECK(func_value->IsJSFunction()); | 293 CHECK(func_value->IsJSFunction()); |
294 Handle<JSFunction> function(JSFunction::cast(func_value)); | 294 Handle<JSFunction> function(JSFunction::cast(func_value)); |
295 | 295 |
296 { | 296 { |
297 HandleScope inner_scope(isolate); | 297 HandleScope inner_scope(isolate); |
298 // Allocate another object, make it reachable from global. | 298 // Allocate another object, make it reachable from global. |
299 Handle<JSObject> obj = factory->NewJSObject(function); | 299 Handle<JSObject> obj = factory->NewJSObject(function); |
300 JSReceiver::SetProperty(global, obj_name, obj, NONE, kNonStrictMode); | 300 JSReceiver::SetProperty(global, obj_name, obj, NONE, kNonStrictMode); |
301 JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, kNonStrictMode); | 301 JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, kNonStrictMode); |
302 } | 302 } |
303 | 303 |
304 // After gc, it should survive. | 304 // After gc, it should survive. |
305 heap->CollectGarbage(NEW_SPACE); | 305 heap->CollectGarbage(NEW_SPACE); |
306 | 306 |
307 CHECK(JSReceiver::HasLocalProperty(global, obj_name)); | 307 CHECK(JSReceiver::HasLocalProperty(global, obj_name)); |
308 CHECK(Isolate::Current()->context()->global_object()-> | 308 CHECK(CcTest::i_isolate()->context()->global_object()-> |
309 GetProperty(*obj_name)->ToObjectChecked()->IsJSObject()); | 309 GetProperty(*obj_name)->ToObjectChecked()->IsJSObject()); |
310 Object* obj = Isolate::Current()->context()->global_object()-> | 310 Object* obj = CcTest::i_isolate()->context()->global_object()-> |
311 GetProperty(*obj_name)->ToObjectChecked(); | 311 GetProperty(*obj_name)->ToObjectChecked(); |
312 JSObject* js_obj = JSObject::cast(obj); | 312 JSObject* js_obj = JSObject::cast(obj); |
313 CHECK_EQ(Smi::FromInt(23), js_obj->GetProperty(*prop_name)); | 313 CHECK_EQ(Smi::FromInt(23), js_obj->GetProperty(*prop_name)); |
314 } | 314 } |
315 | 315 |
316 | 316 |
317 static void VerifyStringAllocation(Isolate* isolate, const char* string) { | 317 static void VerifyStringAllocation(Isolate* isolate, const char* string) { |
318 HandleScope scope(isolate); | 318 HandleScope scope(isolate); |
319 Handle<String> s = isolate->factory()->NewStringFromUtf8(CStrVector(string)); | 319 Handle<String> s = isolate->factory()->NewStringFromUtf8(CStrVector(string)); |
320 CHECK_EQ(StrLength(string), s->length()); | 320 CHECK_EQ(StrLength(string), s->length()); |
(...skipping 10 matching lines...) Expand all Loading... |
331 VerifyStringAllocation(isolate, "a"); | 331 VerifyStringAllocation(isolate, "a"); |
332 VerifyStringAllocation(isolate, "ab"); | 332 VerifyStringAllocation(isolate, "ab"); |
333 VerifyStringAllocation(isolate, "abc"); | 333 VerifyStringAllocation(isolate, "abc"); |
334 VerifyStringAllocation(isolate, "abcd"); | 334 VerifyStringAllocation(isolate, "abcd"); |
335 VerifyStringAllocation(isolate, "fiskerdrengen er paa havet"); | 335 VerifyStringAllocation(isolate, "fiskerdrengen er paa havet"); |
336 } | 336 } |
337 | 337 |
338 | 338 |
339 TEST(LocalHandles) { | 339 TEST(LocalHandles) { |
340 CcTest::InitializeVM(); | 340 CcTest::InitializeVM(); |
341 Isolate* isolate = Isolate::Current(); | 341 Isolate* isolate = CcTest::i_isolate(); |
342 Factory* factory = isolate->factory(); | 342 Factory* factory = isolate->factory(); |
343 | 343 |
344 v8::HandleScope scope(CcTest::isolate()); | 344 v8::HandleScope scope(CcTest::isolate()); |
345 const char* name = "Kasper the spunky"; | 345 const char* name = "Kasper the spunky"; |
346 Handle<String> string = factory->NewStringFromAscii(CStrVector(name)); | 346 Handle<String> string = factory->NewStringFromAscii(CStrVector(name)); |
347 CHECK_EQ(StrLength(name), string->length()); | 347 CHECK_EQ(StrLength(name), string->length()); |
348 } | 348 } |
349 | 349 |
350 | 350 |
351 TEST(GlobalHandles) { | 351 TEST(GlobalHandles) { |
352 CcTest::InitializeVM(); | 352 CcTest::InitializeVM(); |
353 Isolate* isolate = Isolate::Current(); | 353 Isolate* isolate = CcTest::i_isolate(); |
354 Heap* heap = isolate->heap(); | 354 Heap* heap = isolate->heap(); |
355 Factory* factory = isolate->factory(); | 355 Factory* factory = isolate->factory(); |
356 GlobalHandles* global_handles = isolate->global_handles(); | 356 GlobalHandles* global_handles = isolate->global_handles(); |
357 | 357 |
358 Handle<Object> h1; | 358 Handle<Object> h1; |
359 Handle<Object> h2; | 359 Handle<Object> h2; |
360 Handle<Object> h3; | 360 Handle<Object> h3; |
361 Handle<Object> h4; | 361 Handle<Object> h4; |
362 | 362 |
363 { | 363 { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 v8::Persistent<v8::Value>* handle, | 396 v8::Persistent<v8::Value>* handle, |
397 void* id) { | 397 void* id) { |
398 if (1234 == reinterpret_cast<intptr_t>(id)) WeakPointerCleared = true; | 398 if (1234 == reinterpret_cast<intptr_t>(id)) WeakPointerCleared = true; |
399 handle->Dispose(); | 399 handle->Dispose(); |
400 } | 400 } |
401 | 401 |
402 | 402 |
403 TEST(WeakGlobalHandlesScavenge) { | 403 TEST(WeakGlobalHandlesScavenge) { |
404 i::FLAG_stress_compaction = false; | 404 i::FLAG_stress_compaction = false; |
405 CcTest::InitializeVM(); | 405 CcTest::InitializeVM(); |
406 Isolate* isolate = Isolate::Current(); | 406 Isolate* isolate = CcTest::i_isolate(); |
407 Heap* heap = isolate->heap(); | 407 Heap* heap = isolate->heap(); |
408 Factory* factory = isolate->factory(); | 408 Factory* factory = isolate->factory(); |
409 GlobalHandles* global_handles = isolate->global_handles(); | 409 GlobalHandles* global_handles = isolate->global_handles(); |
410 | 410 |
411 WeakPointerCleared = false; | 411 WeakPointerCleared = false; |
412 | 412 |
413 Handle<Object> h1; | 413 Handle<Object> h1; |
414 Handle<Object> h2; | 414 Handle<Object> h2; |
415 | 415 |
416 { | 416 { |
(...skipping 20 matching lines...) Expand all Loading... |
437 CHECK(!global_handles->IsNearDeath(h2.location())); | 437 CHECK(!global_handles->IsNearDeath(h2.location())); |
438 CHECK(!global_handles->IsNearDeath(h1.location())); | 438 CHECK(!global_handles->IsNearDeath(h1.location())); |
439 | 439 |
440 global_handles->Destroy(h1.location()); | 440 global_handles->Destroy(h1.location()); |
441 global_handles->Destroy(h2.location()); | 441 global_handles->Destroy(h2.location()); |
442 } | 442 } |
443 | 443 |
444 | 444 |
445 TEST(WeakGlobalHandlesMark) { | 445 TEST(WeakGlobalHandlesMark) { |
446 CcTest::InitializeVM(); | 446 CcTest::InitializeVM(); |
447 Isolate* isolate = Isolate::Current(); | 447 Isolate* isolate = CcTest::i_isolate(); |
448 Heap* heap = isolate->heap(); | 448 Heap* heap = isolate->heap(); |
449 Factory* factory = isolate->factory(); | 449 Factory* factory = isolate->factory(); |
450 GlobalHandles* global_handles = isolate->global_handles(); | 450 GlobalHandles* global_handles = isolate->global_handles(); |
451 | 451 |
452 WeakPointerCleared = false; | 452 WeakPointerCleared = false; |
453 | 453 |
454 Handle<Object> h1; | 454 Handle<Object> h1; |
455 Handle<Object> h2; | 455 Handle<Object> h2; |
456 | 456 |
457 { | 457 { |
(...skipping 25 matching lines...) Expand all Loading... |
483 CHECK(WeakPointerCleared); | 483 CHECK(WeakPointerCleared); |
484 CHECK(!GlobalHandles::IsNearDeath(h1.location())); | 484 CHECK(!GlobalHandles::IsNearDeath(h1.location())); |
485 | 485 |
486 global_handles->Destroy(h1.location()); | 486 global_handles->Destroy(h1.location()); |
487 } | 487 } |
488 | 488 |
489 | 489 |
490 TEST(DeleteWeakGlobalHandle) { | 490 TEST(DeleteWeakGlobalHandle) { |
491 i::FLAG_stress_compaction = false; | 491 i::FLAG_stress_compaction = false; |
492 CcTest::InitializeVM(); | 492 CcTest::InitializeVM(); |
493 Isolate* isolate = Isolate::Current(); | 493 Isolate* isolate = CcTest::i_isolate(); |
494 Heap* heap = isolate->heap(); | 494 Heap* heap = isolate->heap(); |
495 Factory* factory = isolate->factory(); | 495 Factory* factory = isolate->factory(); |
496 GlobalHandles* global_handles = isolate->global_handles(); | 496 GlobalHandles* global_handles = isolate->global_handles(); |
497 | 497 |
498 WeakPointerCleared = false; | 498 WeakPointerCleared = false; |
499 | 499 |
500 Handle<Object> h; | 500 Handle<Object> h; |
501 | 501 |
502 { | 502 { |
503 HandleScope scope(isolate); | 503 HandleScope scope(isolate); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 TEST(StringTable) { | 605 TEST(StringTable) { |
606 CcTest::InitializeVM(); | 606 CcTest::InitializeVM(); |
607 | 607 |
608 CheckInternalizedStrings(not_so_random_string_table); | 608 CheckInternalizedStrings(not_so_random_string_table); |
609 CheckInternalizedStrings(not_so_random_string_table); | 609 CheckInternalizedStrings(not_so_random_string_table); |
610 } | 610 } |
611 | 611 |
612 | 612 |
613 TEST(FunctionAllocation) { | 613 TEST(FunctionAllocation) { |
614 CcTest::InitializeVM(); | 614 CcTest::InitializeVM(); |
615 Isolate* isolate = Isolate::Current(); | 615 Isolate* isolate = CcTest::i_isolate(); |
616 Factory* factory = isolate->factory(); | 616 Factory* factory = isolate->factory(); |
617 | 617 |
618 v8::HandleScope sc(CcTest::isolate()); | 618 v8::HandleScope sc(CcTest::isolate()); |
619 Handle<String> name = factory->InternalizeUtf8String("theFunction"); | 619 Handle<String> name = factory->InternalizeUtf8String("theFunction"); |
620 Handle<JSFunction> function = | 620 Handle<JSFunction> function = |
621 factory->NewFunction(name, factory->undefined_value()); | 621 factory->NewFunction(name, factory->undefined_value()); |
622 Handle<Map> initial_map = | 622 Handle<Map> initial_map = |
623 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); | 623 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); |
624 function->set_initial_map(*initial_map); | 624 function->set_initial_map(*initial_map); |
625 | 625 |
626 Handle<Smi> twenty_three(Smi::FromInt(23), isolate); | 626 Handle<Smi> twenty_three(Smi::FromInt(23), isolate); |
627 Handle<Smi> twenty_four(Smi::FromInt(24), isolate); | 627 Handle<Smi> twenty_four(Smi::FromInt(24), isolate); |
628 | 628 |
629 Handle<String> prop_name = factory->InternalizeUtf8String("theSlot"); | 629 Handle<String> prop_name = factory->InternalizeUtf8String("theSlot"); |
630 Handle<JSObject> obj = factory->NewJSObject(function); | 630 Handle<JSObject> obj = factory->NewJSObject(function); |
631 JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, kNonStrictMode); | 631 JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, kNonStrictMode); |
632 CHECK_EQ(Smi::FromInt(23), obj->GetProperty(*prop_name)); | 632 CHECK_EQ(Smi::FromInt(23), obj->GetProperty(*prop_name)); |
633 // Check that we can add properties to function objects. | 633 // Check that we can add properties to function objects. |
634 JSReceiver::SetProperty(function, prop_name, twenty_four, NONE, | 634 JSReceiver::SetProperty(function, prop_name, twenty_four, NONE, |
635 kNonStrictMode); | 635 kNonStrictMode); |
636 CHECK_EQ(Smi::FromInt(24), function->GetProperty(*prop_name)); | 636 CHECK_EQ(Smi::FromInt(24), function->GetProperty(*prop_name)); |
637 } | 637 } |
638 | 638 |
639 | 639 |
640 TEST(ObjectProperties) { | 640 TEST(ObjectProperties) { |
641 CcTest::InitializeVM(); | 641 CcTest::InitializeVM(); |
642 Isolate* isolate = Isolate::Current(); | 642 Isolate* isolate = CcTest::i_isolate(); |
643 Factory* factory = isolate->factory(); | 643 Factory* factory = isolate->factory(); |
644 | 644 |
645 v8::HandleScope sc(CcTest::isolate()); | 645 v8::HandleScope sc(CcTest::isolate()); |
646 String* object_string = String::cast(HEAP->Object_string()); | 646 String* object_string = String::cast(HEAP->Object_string()); |
647 Object* raw_object = Isolate::Current()->context()->global_object()-> | 647 Object* raw_object = CcTest::i_isolate()->context()->global_object()-> |
648 GetProperty(object_string)->ToObjectChecked(); | 648 GetProperty(object_string)->ToObjectChecked(); |
649 JSFunction* object_function = JSFunction::cast(raw_object); | 649 JSFunction* object_function = JSFunction::cast(raw_object); |
650 Handle<JSFunction> constructor(object_function); | 650 Handle<JSFunction> constructor(object_function); |
651 Handle<JSObject> obj = factory->NewJSObject(constructor); | 651 Handle<JSObject> obj = factory->NewJSObject(constructor); |
652 Handle<String> first = factory->InternalizeUtf8String("first"); | 652 Handle<String> first = factory->InternalizeUtf8String("first"); |
653 Handle<String> second = factory->InternalizeUtf8String("second"); | 653 Handle<String> second = factory->InternalizeUtf8String("second"); |
654 | 654 |
655 Handle<Smi> one(Smi::FromInt(1), isolate); | 655 Handle<Smi> one(Smi::FromInt(1), isolate); |
656 Handle<Smi> two(Smi::FromInt(2), isolate); | 656 Handle<Smi> two(Smi::FromInt(2), isolate); |
657 | 657 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 const char* string2 = "fugl"; | 703 const char* string2 = "fugl"; |
704 Handle<String> s2_string = factory->InternalizeUtf8String(string2); | 704 Handle<String> s2_string = factory->InternalizeUtf8String(string2); |
705 JSReceiver::SetProperty(obj, s2_string, one, NONE, kNonStrictMode); | 705 JSReceiver::SetProperty(obj, s2_string, one, NONE, kNonStrictMode); |
706 Handle<String> s2 = factory->NewStringFromAscii(CStrVector(string2)); | 706 Handle<String> s2 = factory->NewStringFromAscii(CStrVector(string2)); |
707 CHECK(JSReceiver::HasLocalProperty(obj, s2)); | 707 CHECK(JSReceiver::HasLocalProperty(obj, s2)); |
708 } | 708 } |
709 | 709 |
710 | 710 |
711 TEST(JSObjectMaps) { | 711 TEST(JSObjectMaps) { |
712 CcTest::InitializeVM(); | 712 CcTest::InitializeVM(); |
713 Isolate* isolate = Isolate::Current(); | 713 Isolate* isolate = CcTest::i_isolate(); |
714 Factory* factory = isolate->factory(); | 714 Factory* factory = isolate->factory(); |
715 | 715 |
716 v8::HandleScope sc(CcTest::isolate()); | 716 v8::HandleScope sc(CcTest::isolate()); |
717 Handle<String> name = factory->InternalizeUtf8String("theFunction"); | 717 Handle<String> name = factory->InternalizeUtf8String("theFunction"); |
718 Handle<JSFunction> function = | 718 Handle<JSFunction> function = |
719 factory->NewFunction(name, factory->undefined_value()); | 719 factory->NewFunction(name, factory->undefined_value()); |
720 Handle<Map> initial_map = | 720 Handle<Map> initial_map = |
721 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); | 721 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); |
722 function->set_initial_map(*initial_map); | 722 function->set_initial_map(*initial_map); |
723 | 723 |
724 Handle<String> prop_name = factory->InternalizeUtf8String("theSlot"); | 724 Handle<String> prop_name = factory->InternalizeUtf8String("theSlot"); |
725 Handle<JSObject> obj = factory->NewJSObject(function); | 725 Handle<JSObject> obj = factory->NewJSObject(function); |
726 | 726 |
727 // Set a propery | 727 // Set a propery |
728 Handle<Smi> twenty_three(Smi::FromInt(23), isolate); | 728 Handle<Smi> twenty_three(Smi::FromInt(23), isolate); |
729 JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, kNonStrictMode); | 729 JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, kNonStrictMode); |
730 CHECK_EQ(Smi::FromInt(23), obj->GetProperty(*prop_name)); | 730 CHECK_EQ(Smi::FromInt(23), obj->GetProperty(*prop_name)); |
731 | 731 |
732 // Check the map has changed | 732 // Check the map has changed |
733 CHECK(*initial_map != obj->map()); | 733 CHECK(*initial_map != obj->map()); |
734 } | 734 } |
735 | 735 |
736 | 736 |
737 TEST(JSArray) { | 737 TEST(JSArray) { |
738 CcTest::InitializeVM(); | 738 CcTest::InitializeVM(); |
739 Isolate* isolate = Isolate::Current(); | 739 Isolate* isolate = CcTest::i_isolate(); |
740 Factory* factory = isolate->factory(); | 740 Factory* factory = isolate->factory(); |
741 | 741 |
742 v8::HandleScope sc(CcTest::isolate()); | 742 v8::HandleScope sc(CcTest::isolate()); |
743 Handle<String> name = factory->InternalizeUtf8String("Array"); | 743 Handle<String> name = factory->InternalizeUtf8String("Array"); |
744 Object* raw_object = Isolate::Current()->context()->global_object()-> | 744 Object* raw_object = CcTest::i_isolate()->context()->global_object()-> |
745 GetProperty(*name)->ToObjectChecked(); | 745 GetProperty(*name)->ToObjectChecked(); |
746 Handle<JSFunction> function = Handle<JSFunction>( | 746 Handle<JSFunction> function = Handle<JSFunction>( |
747 JSFunction::cast(raw_object)); | 747 JSFunction::cast(raw_object)); |
748 | 748 |
749 // Allocate the object. | 749 // Allocate the object. |
750 Handle<JSObject> object = factory->NewJSObject(function); | 750 Handle<JSObject> object = factory->NewJSObject(function); |
751 Handle<JSArray> array = Handle<JSArray>::cast(object); | 751 Handle<JSArray> array = Handle<JSArray>::cast(object); |
752 // We just initialized the VM, no heap allocation failure yet. | 752 // We just initialized the VM, no heap allocation failure yet. |
753 array->Initialize(0)->ToObjectChecked(); | 753 array->Initialize(0)->ToObjectChecked(); |
754 | 754 |
(...skipping 23 matching lines...) Expand all Loading... |
778 uint32_t new_int_length = 0; | 778 uint32_t new_int_length = 0; |
779 CHECK(array->length()->ToArrayIndex(&new_int_length)); | 779 CHECK(array->length()->ToArrayIndex(&new_int_length)); |
780 CHECK_EQ(static_cast<double>(int_length), new_int_length - 1); | 780 CHECK_EQ(static_cast<double>(int_length), new_int_length - 1); |
781 CHECK_EQ(array->GetElement(isolate, int_length), *name); | 781 CHECK_EQ(array->GetElement(isolate, int_length), *name); |
782 CHECK_EQ(array->GetElement(isolate, 0), *name); | 782 CHECK_EQ(array->GetElement(isolate, 0), *name); |
783 } | 783 } |
784 | 784 |
785 | 785 |
786 TEST(JSObjectCopy) { | 786 TEST(JSObjectCopy) { |
787 CcTest::InitializeVM(); | 787 CcTest::InitializeVM(); |
788 Isolate* isolate = Isolate::Current(); | 788 Isolate* isolate = CcTest::i_isolate(); |
789 Factory* factory = isolate->factory(); | 789 Factory* factory = isolate->factory(); |
790 | 790 |
791 v8::HandleScope sc(CcTest::isolate()); | 791 v8::HandleScope sc(CcTest::isolate()); |
792 String* object_string = String::cast(HEAP->Object_string()); | 792 String* object_string = String::cast(HEAP->Object_string()); |
793 Object* raw_object = Isolate::Current()->context()->global_object()-> | 793 Object* raw_object = CcTest::i_isolate()->context()->global_object()-> |
794 GetProperty(object_string)->ToObjectChecked(); | 794 GetProperty(object_string)->ToObjectChecked(); |
795 JSFunction* object_function = JSFunction::cast(raw_object); | 795 JSFunction* object_function = JSFunction::cast(raw_object); |
796 Handle<JSFunction> constructor(object_function); | 796 Handle<JSFunction> constructor(object_function); |
797 Handle<JSObject> obj = factory->NewJSObject(constructor); | 797 Handle<JSObject> obj = factory->NewJSObject(constructor); |
798 Handle<String> first = factory->InternalizeUtf8String("first"); | 798 Handle<String> first = factory->InternalizeUtf8String("first"); |
799 Handle<String> second = factory->InternalizeUtf8String("second"); | 799 Handle<String> second = factory->InternalizeUtf8String("second"); |
800 | 800 |
801 Handle<Smi> one(Smi::FromInt(1), isolate); | 801 Handle<Smi> one(Smi::FromInt(1), isolate); |
802 Handle<Smi> two(Smi::FromInt(2), isolate); | 802 Handle<Smi> two(Smi::FromInt(2), isolate); |
803 | 803 |
(...skipping 23 matching lines...) Expand all Loading... |
827 CHECK_EQ(obj->GetElement(isolate, 1), clone->GetElement(isolate, 0)); | 827 CHECK_EQ(obj->GetElement(isolate, 1), clone->GetElement(isolate, 0)); |
828 CHECK_EQ(obj->GetElement(isolate, 0), clone->GetElement(isolate, 1)); | 828 CHECK_EQ(obj->GetElement(isolate, 0), clone->GetElement(isolate, 1)); |
829 | 829 |
830 CHECK_EQ(obj->GetProperty(*second), clone->GetProperty(*first)); | 830 CHECK_EQ(obj->GetProperty(*second), clone->GetProperty(*first)); |
831 CHECK_EQ(obj->GetProperty(*first), clone->GetProperty(*second)); | 831 CHECK_EQ(obj->GetProperty(*first), clone->GetProperty(*second)); |
832 } | 832 } |
833 | 833 |
834 | 834 |
835 TEST(StringAllocation) { | 835 TEST(StringAllocation) { |
836 CcTest::InitializeVM(); | 836 CcTest::InitializeVM(); |
837 Isolate* isolate = Isolate::Current(); | 837 Isolate* isolate = CcTest::i_isolate(); |
838 Factory* factory = isolate->factory(); | 838 Factory* factory = isolate->factory(); |
839 | 839 |
840 const unsigned char chars[] = { 0xe5, 0xa4, 0xa7 }; | 840 const unsigned char chars[] = { 0xe5, 0xa4, 0xa7 }; |
841 for (int length = 0; length < 100; length++) { | 841 for (int length = 0; length < 100; length++) { |
842 v8::HandleScope scope(CcTest::isolate()); | 842 v8::HandleScope scope(CcTest::isolate()); |
843 char* non_ascii = NewArray<char>(3 * length + 1); | 843 char* non_ascii = NewArray<char>(3 * length + 1); |
844 char* ascii = NewArray<char>(length + 1); | 844 char* ascii = NewArray<char>(length + 1); |
845 non_ascii[3 * length] = 0; | 845 non_ascii[3 * length] = 0; |
846 ascii[length] = 0; | 846 ascii[length] = 0; |
847 for (int i = 0; i < length; i++) { | 847 for (int i = 0; i < length; i++) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
882 found_count++; | 882 found_count++; |
883 } | 883 } |
884 } | 884 } |
885 } | 885 } |
886 return found_count; | 886 return found_count; |
887 } | 887 } |
888 | 888 |
889 | 889 |
890 TEST(Iteration) { | 890 TEST(Iteration) { |
891 CcTest::InitializeVM(); | 891 CcTest::InitializeVM(); |
892 Isolate* isolate = Isolate::Current(); | 892 Isolate* isolate = CcTest::i_isolate(); |
893 Factory* factory = isolate->factory(); | 893 Factory* factory = isolate->factory(); |
894 v8::HandleScope scope(CcTest::isolate()); | 894 v8::HandleScope scope(CcTest::isolate()); |
895 | 895 |
896 // Array of objects to scan haep for. | 896 // Array of objects to scan haep for. |
897 const int objs_count = 6; | 897 const int objs_count = 6; |
898 Handle<Object> objs[objs_count]; | 898 Handle<Object> objs[objs_count]; |
899 int next_objs_index = 0; | 899 int next_objs_index = 0; |
900 | 900 |
901 // Allocate a JS array to OLD_POINTER_SPACE and NEW_SPACE | 901 // Allocate a JS array to OLD_POINTER_SPACE and NEW_SPACE |
902 objs[next_objs_index++] = factory->NewJSArray(10); | 902 objs[next_objs_index++] = factory->NewJSArray(10); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
944 | 944 |
945 | 945 |
946 static int LenFromSize(int size) { | 946 static int LenFromSize(int size) { |
947 return (size - FixedArray::kHeaderSize) / kPointerSize; | 947 return (size - FixedArray::kHeaderSize) / kPointerSize; |
948 } | 948 } |
949 | 949 |
950 | 950 |
951 TEST(Regression39128) { | 951 TEST(Regression39128) { |
952 // Test case for crbug.com/39128. | 952 // Test case for crbug.com/39128. |
953 CcTest::InitializeVM(); | 953 CcTest::InitializeVM(); |
954 Isolate* isolate = Isolate::Current(); | 954 Isolate* isolate = CcTest::i_isolate(); |
955 Factory* factory = isolate->factory(); | 955 Factory* factory = isolate->factory(); |
956 | 956 |
957 // Increase the chance of 'bump-the-pointer' allocation in old space. | 957 // Increase the chance of 'bump-the-pointer' allocation in old space. |
958 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 958 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
959 | 959 |
960 v8::HandleScope scope(CcTest::isolate()); | 960 v8::HandleScope scope(CcTest::isolate()); |
961 | 961 |
962 // The plan: create JSObject which references objects in new space. | 962 // The plan: create JSObject which references objects in new space. |
963 // Then clone this object (forcing it to go into old space) and check | 963 // Then clone this object (forcing it to go into old space) and check |
964 // that region dirty marks are updated correctly. | 964 // that region dirty marks are updated correctly. |
965 | 965 |
966 // Step 1: prepare a map for the object. We add 1 inobject property to it. | 966 // Step 1: prepare a map for the object. We add 1 inobject property to it. |
967 Handle<JSFunction> object_ctor( | 967 Handle<JSFunction> object_ctor( |
968 Isolate::Current()->native_context()->object_function()); | 968 CcTest::i_isolate()->native_context()->object_function()); |
969 CHECK(object_ctor->has_initial_map()); | 969 CHECK(object_ctor->has_initial_map()); |
970 Handle<Map> object_map(object_ctor->initial_map()); | 970 Handle<Map> object_map(object_ctor->initial_map()); |
971 // Create a map with single inobject property. | 971 // Create a map with single inobject property. |
972 Handle<Map> my_map = factory->CopyMap(object_map, 1); | 972 Handle<Map> my_map = factory->CopyMap(object_map, 1); |
973 int n_properties = my_map->inobject_properties(); | 973 int n_properties = my_map->inobject_properties(); |
974 CHECK_GT(n_properties, 0); | 974 CHECK_GT(n_properties, 0); |
975 | 975 |
976 int object_size = my_map->instance_size(); | 976 int object_size = my_map->instance_size(); |
977 | 977 |
978 // Step 2: allocate a lot of objects so to almost fill new space: we need | 978 // Step 2: allocate a lot of objects so to almost fill new space: we need |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1023 } | 1023 } |
1024 CHECK(HEAP->old_pointer_space()->Contains(clone->address())); | 1024 CHECK(HEAP->old_pointer_space()->Contains(clone->address())); |
1025 } | 1025 } |
1026 | 1026 |
1027 | 1027 |
1028 TEST(TestCodeFlushing) { | 1028 TEST(TestCodeFlushing) { |
1029 // If we do not flush code this test is invalid. | 1029 // If we do not flush code this test is invalid. |
1030 if (!FLAG_flush_code) return; | 1030 if (!FLAG_flush_code) return; |
1031 i::FLAG_allow_natives_syntax = true; | 1031 i::FLAG_allow_natives_syntax = true; |
1032 CcTest::InitializeVM(); | 1032 CcTest::InitializeVM(); |
1033 Isolate* isolate = Isolate::Current(); | 1033 Isolate* isolate = CcTest::i_isolate(); |
1034 Factory* factory = isolate->factory(); | 1034 Factory* factory = isolate->factory(); |
1035 v8::HandleScope scope(CcTest::isolate()); | 1035 v8::HandleScope scope(CcTest::isolate()); |
1036 const char* source = "function foo() {" | 1036 const char* source = "function foo() {" |
1037 " var x = 42;" | 1037 " var x = 42;" |
1038 " var y = 42;" | 1038 " var y = 42;" |
1039 " var z = x + y;" | 1039 " var z = x + y;" |
1040 "};" | 1040 "};" |
1041 "foo()"; | 1041 "foo()"; |
1042 Handle<String> foo_name = factory->InternalizeUtf8String("foo"); | 1042 Handle<String> foo_name = factory->InternalizeUtf8String("foo"); |
1043 | 1043 |
1044 // This compile will add the code to the compilation cache. | 1044 // This compile will add the code to the compilation cache. |
1045 { v8::HandleScope scope(CcTest::isolate()); | 1045 { v8::HandleScope scope(CcTest::isolate()); |
1046 CompileRun(source); | 1046 CompileRun(source); |
1047 } | 1047 } |
1048 | 1048 |
1049 // Check function is compiled. | 1049 // Check function is compiled. |
1050 Object* func_value = Isolate::Current()->context()->global_object()-> | 1050 Object* func_value = CcTest::i_isolate()->context()->global_object()-> |
1051 GetProperty(*foo_name)->ToObjectChecked(); | 1051 GetProperty(*foo_name)->ToObjectChecked(); |
1052 CHECK(func_value->IsJSFunction()); | 1052 CHECK(func_value->IsJSFunction()); |
1053 Handle<JSFunction> function(JSFunction::cast(func_value)); | 1053 Handle<JSFunction> function(JSFunction::cast(func_value)); |
1054 CHECK(function->shared()->is_compiled()); | 1054 CHECK(function->shared()->is_compiled()); |
1055 | 1055 |
1056 // The code will survive at least two GCs. | 1056 // The code will survive at least two GCs. |
1057 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 1057 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
1058 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 1058 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
1059 CHECK(function->shared()->is_compiled()); | 1059 CHECK(function->shared()->is_compiled()); |
1060 | 1060 |
(...skipping 11 matching lines...) Expand all Loading... |
1072 CHECK(function->shared()->is_compiled()); | 1072 CHECK(function->shared()->is_compiled()); |
1073 CHECK(function->is_compiled()); | 1073 CHECK(function->is_compiled()); |
1074 } | 1074 } |
1075 | 1075 |
1076 | 1076 |
1077 TEST(TestCodeFlushingIncremental) { | 1077 TEST(TestCodeFlushingIncremental) { |
1078 // If we do not flush code this test is invalid. | 1078 // If we do not flush code this test is invalid. |
1079 if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return; | 1079 if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return; |
1080 i::FLAG_allow_natives_syntax = true; | 1080 i::FLAG_allow_natives_syntax = true; |
1081 CcTest::InitializeVM(); | 1081 CcTest::InitializeVM(); |
1082 Isolate* isolate = Isolate::Current(); | 1082 Isolate* isolate = CcTest::i_isolate(); |
1083 Factory* factory = isolate->factory(); | 1083 Factory* factory = isolate->factory(); |
1084 v8::HandleScope scope(CcTest::isolate()); | 1084 v8::HandleScope scope(CcTest::isolate()); |
1085 const char* source = "function foo() {" | 1085 const char* source = "function foo() {" |
1086 " var x = 42;" | 1086 " var x = 42;" |
1087 " var y = 42;" | 1087 " var y = 42;" |
1088 " var z = x + y;" | 1088 " var z = x + y;" |
1089 "};" | 1089 "};" |
1090 "foo()"; | 1090 "foo()"; |
1091 Handle<String> foo_name = factory->InternalizeUtf8String("foo"); | 1091 Handle<String> foo_name = factory->InternalizeUtf8String("foo"); |
1092 | 1092 |
1093 // This compile will add the code to the compilation cache. | 1093 // This compile will add the code to the compilation cache. |
1094 { v8::HandleScope scope(CcTest::isolate()); | 1094 { v8::HandleScope scope(CcTest::isolate()); |
1095 CompileRun(source); | 1095 CompileRun(source); |
1096 } | 1096 } |
1097 | 1097 |
1098 // Check function is compiled. | 1098 // Check function is compiled. |
1099 Object* func_value = Isolate::Current()->context()->global_object()-> | 1099 Object* func_value = CcTest::i_isolate()->context()->global_object()-> |
1100 GetProperty(*foo_name)->ToObjectChecked(); | 1100 GetProperty(*foo_name)->ToObjectChecked(); |
1101 CHECK(func_value->IsJSFunction()); | 1101 CHECK(func_value->IsJSFunction()); |
1102 Handle<JSFunction> function(JSFunction::cast(func_value)); | 1102 Handle<JSFunction> function(JSFunction::cast(func_value)); |
1103 CHECK(function->shared()->is_compiled()); | 1103 CHECK(function->shared()->is_compiled()); |
1104 | 1104 |
1105 // The code will survive at least two GCs. | 1105 // The code will survive at least two GCs. |
1106 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 1106 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
1107 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 1107 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
1108 CHECK(function->shared()->is_compiled()); | 1108 CHECK(function->shared()->is_compiled()); |
1109 | 1109 |
(...skipping 30 matching lines...) Expand all Loading... |
1140 CHECK(function->shared()->is_compiled() || !function->IsOptimized()); | 1140 CHECK(function->shared()->is_compiled() || !function->IsOptimized()); |
1141 CHECK(function->is_compiled() || !function->IsOptimized()); | 1141 CHECK(function->is_compiled() || !function->IsOptimized()); |
1142 } | 1142 } |
1143 | 1143 |
1144 | 1144 |
1145 TEST(TestCodeFlushingIncrementalScavenge) { | 1145 TEST(TestCodeFlushingIncrementalScavenge) { |
1146 // If we do not flush code this test is invalid. | 1146 // If we do not flush code this test is invalid. |
1147 if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return; | 1147 if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return; |
1148 i::FLAG_allow_natives_syntax = true; | 1148 i::FLAG_allow_natives_syntax = true; |
1149 CcTest::InitializeVM(); | 1149 CcTest::InitializeVM(); |
1150 Isolate* isolate = Isolate::Current(); | 1150 Isolate* isolate = CcTest::i_isolate(); |
1151 Factory* factory = isolate->factory(); | 1151 Factory* factory = isolate->factory(); |
1152 v8::HandleScope scope(CcTest::isolate()); | 1152 v8::HandleScope scope(CcTest::isolate()); |
1153 const char* source = "var foo = function() {" | 1153 const char* source = "var foo = function() {" |
1154 " var x = 42;" | 1154 " var x = 42;" |
1155 " var y = 42;" | 1155 " var y = 42;" |
1156 " var z = x + y;" | 1156 " var z = x + y;" |
1157 "};" | 1157 "};" |
1158 "foo();" | 1158 "foo();" |
1159 "var bar = function() {" | 1159 "var bar = function() {" |
1160 " var x = 23;" | 1160 " var x = 23;" |
1161 "};" | 1161 "};" |
1162 "bar();"; | 1162 "bar();"; |
1163 Handle<String> foo_name = factory->InternalizeUtf8String("foo"); | 1163 Handle<String> foo_name = factory->InternalizeUtf8String("foo"); |
1164 Handle<String> bar_name = factory->InternalizeUtf8String("bar"); | 1164 Handle<String> bar_name = factory->InternalizeUtf8String("bar"); |
1165 | 1165 |
1166 // Perfrom one initial GC to enable code flushing. | 1166 // Perfrom one initial GC to enable code flushing. |
1167 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 1167 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
1168 | 1168 |
1169 // This compile will add the code to the compilation cache. | 1169 // This compile will add the code to the compilation cache. |
1170 { v8::HandleScope scope(CcTest::isolate()); | 1170 { v8::HandleScope scope(CcTest::isolate()); |
1171 CompileRun(source); | 1171 CompileRun(source); |
1172 } | 1172 } |
1173 | 1173 |
1174 // Check functions are compiled. | 1174 // Check functions are compiled. |
1175 Object* func_value = Isolate::Current()->context()->global_object()-> | 1175 Object* func_value = CcTest::i_isolate()->context()->global_object()-> |
1176 GetProperty(*foo_name)->ToObjectChecked(); | 1176 GetProperty(*foo_name)->ToObjectChecked(); |
1177 CHECK(func_value->IsJSFunction()); | 1177 CHECK(func_value->IsJSFunction()); |
1178 Handle<JSFunction> function(JSFunction::cast(func_value)); | 1178 Handle<JSFunction> function(JSFunction::cast(func_value)); |
1179 CHECK(function->shared()->is_compiled()); | 1179 CHECK(function->shared()->is_compiled()); |
1180 Object* func_value2 = Isolate::Current()->context()->global_object()-> | 1180 Object* func_value2 = CcTest::i_isolate()->context()->global_object()-> |
1181 GetProperty(*bar_name)->ToObjectChecked(); | 1181 GetProperty(*bar_name)->ToObjectChecked(); |
1182 CHECK(func_value2->IsJSFunction()); | 1182 CHECK(func_value2->IsJSFunction()); |
1183 Handle<JSFunction> function2(JSFunction::cast(func_value2)); | 1183 Handle<JSFunction> function2(JSFunction::cast(func_value2)); |
1184 CHECK(function2->shared()->is_compiled()); | 1184 CHECK(function2->shared()->is_compiled()); |
1185 | 1185 |
1186 // Clear references to functions so that one of them can die. | 1186 // Clear references to functions so that one of them can die. |
1187 { v8::HandleScope scope(CcTest::isolate()); | 1187 { v8::HandleScope scope(CcTest::isolate()); |
1188 CompileRun("foo = 0; bar = 0;"); | 1188 CompileRun("foo = 0; bar = 0;"); |
1189 } | 1189 } |
1190 | 1190 |
(...skipping 17 matching lines...) Expand all Loading... |
1208 CHECK(!function->shared()->is_compiled() || function->IsOptimized()); | 1208 CHECK(!function->shared()->is_compiled() || function->IsOptimized()); |
1209 CHECK(!function->is_compiled() || function->IsOptimized()); | 1209 CHECK(!function->is_compiled() || function->IsOptimized()); |
1210 } | 1210 } |
1211 | 1211 |
1212 | 1212 |
1213 TEST(TestCodeFlushingIncrementalAbort) { | 1213 TEST(TestCodeFlushingIncrementalAbort) { |
1214 // If we do not flush code this test is invalid. | 1214 // If we do not flush code this test is invalid. |
1215 if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return; | 1215 if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return; |
1216 i::FLAG_allow_natives_syntax = true; | 1216 i::FLAG_allow_natives_syntax = true; |
1217 CcTest::InitializeVM(); | 1217 CcTest::InitializeVM(); |
1218 Isolate* isolate = Isolate::Current(); | 1218 Isolate* isolate = CcTest::i_isolate(); |
1219 Factory* factory = isolate->factory(); | 1219 Factory* factory = isolate->factory(); |
1220 Heap* heap = isolate->heap(); | 1220 Heap* heap = isolate->heap(); |
1221 v8::HandleScope scope(CcTest::isolate()); | 1221 v8::HandleScope scope(CcTest::isolate()); |
1222 const char* source = "function foo() {" | 1222 const char* source = "function foo() {" |
1223 " var x = 42;" | 1223 " var x = 42;" |
1224 " var y = 42;" | 1224 " var y = 42;" |
1225 " var z = x + y;" | 1225 " var z = x + y;" |
1226 "};" | 1226 "};" |
1227 "foo()"; | 1227 "foo()"; |
1228 Handle<String> foo_name = factory->InternalizeUtf8String("foo"); | 1228 Handle<String> foo_name = factory->InternalizeUtf8String("foo"); |
1229 | 1229 |
1230 // This compile will add the code to the compilation cache. | 1230 // This compile will add the code to the compilation cache. |
1231 { v8::HandleScope scope(CcTest::isolate()); | 1231 { v8::HandleScope scope(CcTest::isolate()); |
1232 CompileRun(source); | 1232 CompileRun(source); |
1233 } | 1233 } |
1234 | 1234 |
1235 // Check function is compiled. | 1235 // Check function is compiled. |
1236 Object* func_value = Isolate::Current()->context()->global_object()-> | 1236 Object* func_value = CcTest::i_isolate()->context()->global_object()-> |
1237 GetProperty(*foo_name)->ToObjectChecked(); | 1237 GetProperty(*foo_name)->ToObjectChecked(); |
1238 CHECK(func_value->IsJSFunction()); | 1238 CHECK(func_value->IsJSFunction()); |
1239 Handle<JSFunction> function(JSFunction::cast(func_value)); | 1239 Handle<JSFunction> function(JSFunction::cast(func_value)); |
1240 CHECK(function->shared()->is_compiled()); | 1240 CHECK(function->shared()->is_compiled()); |
1241 | 1241 |
1242 // The code will survive at least two GCs. | 1242 // The code will survive at least two GCs. |
1243 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 1243 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
1244 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 1244 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
1245 CHECK(function->shared()->is_compiled()); | 1245 CHECK(function->shared()->is_compiled()); |
1246 | 1246 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1304 | 1304 |
1305 TEST(TestInternalWeakLists) { | 1305 TEST(TestInternalWeakLists) { |
1306 v8::V8::Initialize(); | 1306 v8::V8::Initialize(); |
1307 | 1307 |
1308 // Some flags turn Scavenge collections into Mark-sweep collections | 1308 // Some flags turn Scavenge collections into Mark-sweep collections |
1309 // and hence are incompatible with this test case. | 1309 // and hence are incompatible with this test case. |
1310 if (FLAG_gc_global || FLAG_stress_compaction) return; | 1310 if (FLAG_gc_global || FLAG_stress_compaction) return; |
1311 | 1311 |
1312 static const int kNumTestContexts = 10; | 1312 static const int kNumTestContexts = 10; |
1313 | 1313 |
1314 Isolate* isolate = Isolate::Current(); | 1314 Isolate* isolate = CcTest::i_isolate(); |
1315 Heap* heap = isolate->heap(); | 1315 Heap* heap = isolate->heap(); |
1316 HandleScope scope(isolate); | 1316 HandleScope scope(isolate); |
1317 v8::Handle<v8::Context> ctx[kNumTestContexts]; | 1317 v8::Handle<v8::Context> ctx[kNumTestContexts]; |
1318 | 1318 |
1319 CHECK_EQ(0, CountNativeContexts()); | 1319 CHECK_EQ(0, CountNativeContexts()); |
1320 | 1320 |
1321 // Create a number of global contests which gets linked together. | 1321 // Create a number of global contests which gets linked together. |
1322 for (int i = 0; i < kNumTestContexts; i++) { | 1322 for (int i = 0; i < kNumTestContexts; i++) { |
1323 ctx[i] = v8::Context::New(CcTest::isolate()); | 1323 ctx[i] = v8::Context::New(CcTest::isolate()); |
1324 | 1324 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1447 object = Handle<Object>( | 1447 object = Handle<Object>( |
1448 Object::cast(JSFunction::cast(*object)->next_function_link()), | 1448 Object::cast(JSFunction::cast(*object)->next_function_link()), |
1449 isolate); | 1449 isolate); |
1450 } | 1450 } |
1451 return count; | 1451 return count; |
1452 } | 1452 } |
1453 | 1453 |
1454 | 1454 |
1455 TEST(TestInternalWeakListsTraverseWithGC) { | 1455 TEST(TestInternalWeakListsTraverseWithGC) { |
1456 v8::V8::Initialize(); | 1456 v8::V8::Initialize(); |
1457 Isolate* isolate = Isolate::Current(); | 1457 Isolate* isolate = CcTest::i_isolate(); |
1458 | 1458 |
1459 static const int kNumTestContexts = 10; | 1459 static const int kNumTestContexts = 10; |
1460 | 1460 |
1461 HandleScope scope(isolate); | 1461 HandleScope scope(isolate); |
1462 v8::Handle<v8::Context> ctx[kNumTestContexts]; | 1462 v8::Handle<v8::Context> ctx[kNumTestContexts]; |
1463 | 1463 |
1464 CHECK_EQ(0, CountNativeContexts()); | 1464 CHECK_EQ(0, CountNativeContexts()); |
1465 | 1465 |
1466 // Create an number of contexts and check the length of the weak list both | 1466 // Create an number of contexts and check the length of the weak list both |
1467 // with and without GCs while iterating the list. | 1467 // with and without GCs while iterating the list. |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1864 } | 1864 } |
1865 | 1865 |
1866 | 1866 |
1867 TEST(InstanceOfStubWriteBarrier) { | 1867 TEST(InstanceOfStubWriteBarrier) { |
1868 i::FLAG_allow_natives_syntax = true; | 1868 i::FLAG_allow_natives_syntax = true; |
1869 #ifdef VERIFY_HEAP | 1869 #ifdef VERIFY_HEAP |
1870 i::FLAG_verify_heap = true; | 1870 i::FLAG_verify_heap = true; |
1871 #endif | 1871 #endif |
1872 | 1872 |
1873 CcTest::InitializeVM(); | 1873 CcTest::InitializeVM(); |
1874 if (!i::Isolate::Current()->use_crankshaft()) return; | 1874 if (!CcTest::i_isolate()->use_crankshaft()) return; |
1875 if (i::FLAG_force_marking_deque_overflows) return; | 1875 if (i::FLAG_force_marking_deque_overflows) return; |
1876 v8::HandleScope outer_scope(CcTest::isolate()); | 1876 v8::HandleScope outer_scope(CcTest::isolate()); |
1877 | 1877 |
1878 { | 1878 { |
1879 v8::HandleScope scope(CcTest::isolate()); | 1879 v8::HandleScope scope(CcTest::isolate()); |
1880 CompileRun( | 1880 CompileRun( |
1881 "function foo () { }" | 1881 "function foo () { }" |
1882 "function mkbar () { return new (new Function(\"\")) (); }" | 1882 "function mkbar () { return new (new Function(\"\")) (); }" |
1883 "function f (x) { return (x instanceof foo); }" | 1883 "function f (x) { return (x instanceof foo); }" |
1884 "function g () { f(mkbar()); }" | 1884 "function g () { f(mkbar()); }" |
(...skipping 30 matching lines...) Expand all Loading... |
1915 g->Call(global, 0, NULL); | 1915 g->Call(global, 0, NULL); |
1916 } | 1916 } |
1917 | 1917 |
1918 HEAP->incremental_marking()->set_should_hurry(true); | 1918 HEAP->incremental_marking()->set_should_hurry(true); |
1919 HEAP->CollectGarbage(OLD_POINTER_SPACE); | 1919 HEAP->CollectGarbage(OLD_POINTER_SPACE); |
1920 } | 1920 } |
1921 | 1921 |
1922 | 1922 |
1923 TEST(PrototypeTransitionClearing) { | 1923 TEST(PrototypeTransitionClearing) { |
1924 CcTest::InitializeVM(); | 1924 CcTest::InitializeVM(); |
1925 Isolate* isolate = Isolate::Current(); | 1925 Isolate* isolate = CcTest::i_isolate(); |
1926 Factory* factory = isolate->factory(); | 1926 Factory* factory = isolate->factory(); |
1927 v8::HandleScope scope(CcTest::isolate()); | 1927 v8::HandleScope scope(CcTest::isolate()); |
1928 | 1928 |
1929 CompileRun( | 1929 CompileRun( |
1930 "var base = {};" | 1930 "var base = {};" |
1931 "var live = [];" | 1931 "var live = [];" |
1932 "for (var i = 0; i < 10; i++) {" | 1932 "for (var i = 0; i < 10; i++) {" |
1933 " var object = {};" | 1933 " var object = {};" |
1934 " var prototype = {};" | 1934 " var prototype = {};" |
1935 " object.__proto__ = prototype;" | 1935 " object.__proto__ = prototype;" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1981 | 1981 |
1982 | 1982 |
1983 TEST(ResetSharedFunctionInfoCountersDuringIncrementalMarking) { | 1983 TEST(ResetSharedFunctionInfoCountersDuringIncrementalMarking) { |
1984 i::FLAG_stress_compaction = false; | 1984 i::FLAG_stress_compaction = false; |
1985 i::FLAG_allow_natives_syntax = true; | 1985 i::FLAG_allow_natives_syntax = true; |
1986 #ifdef VERIFY_HEAP | 1986 #ifdef VERIFY_HEAP |
1987 i::FLAG_verify_heap = true; | 1987 i::FLAG_verify_heap = true; |
1988 #endif | 1988 #endif |
1989 | 1989 |
1990 CcTest::InitializeVM(); | 1990 CcTest::InitializeVM(); |
1991 if (!i::Isolate::Current()->use_crankshaft()) return; | 1991 if (!CcTest::i_isolate()->use_crankshaft()) return; |
1992 v8::HandleScope outer_scope(CcTest::isolate()); | 1992 v8::HandleScope outer_scope(CcTest::isolate()); |
1993 | 1993 |
1994 { | 1994 { |
1995 v8::HandleScope scope(CcTest::isolate()); | 1995 v8::HandleScope scope(CcTest::isolate()); |
1996 CompileRun( | 1996 CompileRun( |
1997 "function f () {" | 1997 "function f () {" |
1998 " var s = 0;" | 1998 " var s = 0;" |
1999 " for (var i = 0; i < 100; i++) s += i;" | 1999 " for (var i = 0; i < 100; i++) s += i;" |
2000 " return s;" | 2000 " return s;" |
2001 "}" | 2001 "}" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2038 | 2038 |
2039 | 2039 |
2040 TEST(ResetSharedFunctionInfoCountersDuringMarkSweep) { | 2040 TEST(ResetSharedFunctionInfoCountersDuringMarkSweep) { |
2041 i::FLAG_stress_compaction = false; | 2041 i::FLAG_stress_compaction = false; |
2042 i::FLAG_allow_natives_syntax = true; | 2042 i::FLAG_allow_natives_syntax = true; |
2043 #ifdef VERIFY_HEAP | 2043 #ifdef VERIFY_HEAP |
2044 i::FLAG_verify_heap = true; | 2044 i::FLAG_verify_heap = true; |
2045 #endif | 2045 #endif |
2046 | 2046 |
2047 CcTest::InitializeVM(); | 2047 CcTest::InitializeVM(); |
2048 if (!i::Isolate::Current()->use_crankshaft()) return; | 2048 if (!CcTest::i_isolate()->use_crankshaft()) return; |
2049 v8::HandleScope outer_scope(CcTest::isolate()); | 2049 v8::HandleScope outer_scope(CcTest::isolate()); |
2050 | 2050 |
2051 { | 2051 { |
2052 v8::HandleScope scope(CcTest::isolate()); | 2052 v8::HandleScope scope(CcTest::isolate()); |
2053 CompileRun( | 2053 CompileRun( |
2054 "function f () {" | 2054 "function f () {" |
2055 " var s = 0;" | 2055 " var s = 0;" |
2056 " for (var i = 0; i < 100; i++) s += i;" | 2056 " for (var i = 0; i < 100; i++) s += i;" |
2057 " return s;" | 2057 " return s;" |
2058 "}" | 2058 "}" |
(...skipping 18 matching lines...) Expand all Loading... |
2077 CHECK_EQ(HEAP->global_ic_age(), f->shared()->ic_age()); | 2077 CHECK_EQ(HEAP->global_ic_age(), f->shared()->ic_age()); |
2078 CHECK_EQ(0, f->shared()->opt_count()); | 2078 CHECK_EQ(0, f->shared()->opt_count()); |
2079 CHECK_EQ(0, f->shared()->code()->profiler_ticks()); | 2079 CHECK_EQ(0, f->shared()->code()->profiler_ticks()); |
2080 } | 2080 } |
2081 | 2081 |
2082 | 2082 |
2083 // Test that HAllocateObject will always return an object in new-space. | 2083 // Test that HAllocateObject will always return an object in new-space. |
2084 TEST(OptimizedAllocationAlwaysInNewSpace) { | 2084 TEST(OptimizedAllocationAlwaysInNewSpace) { |
2085 i::FLAG_allow_natives_syntax = true; | 2085 i::FLAG_allow_natives_syntax = true; |
2086 CcTest::InitializeVM(); | 2086 CcTest::InitializeVM(); |
2087 if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return; | 2087 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2088 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2088 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2089 v8::HandleScope scope(CcTest::isolate()); | 2089 v8::HandleScope scope(CcTest::isolate()); |
2090 | 2090 |
2091 SimulateFullSpace(HEAP->new_space()); | 2091 SimulateFullSpace(HEAP->new_space()); |
2092 AlwaysAllocateScope always_allocate; | 2092 AlwaysAllocateScope always_allocate; |
2093 v8::Local<v8::Value> res = CompileRun( | 2093 v8::Local<v8::Value> res = CompileRun( |
2094 "function c(x) {" | 2094 "function c(x) {" |
2095 " this.x = x;" | 2095 " this.x = x;" |
2096 " for (var i = 0; i < 32; i++) {" | 2096 " for (var i = 0; i < 32; i++) {" |
2097 " this['x' + i] = x;" | 2097 " this['x' + i] = x;" |
2098 " }" | 2098 " }" |
2099 "}" | 2099 "}" |
2100 "function f(x) { return new c(x); };" | 2100 "function f(x) { return new c(x); };" |
2101 "f(1); f(2); f(3);" | 2101 "f(1); f(2); f(3);" |
2102 "%OptimizeFunctionOnNextCall(f);" | 2102 "%OptimizeFunctionOnNextCall(f);" |
2103 "f(4);"); | 2103 "f(4);"); |
2104 CHECK_EQ(4, res->ToObject()->GetRealNamedProperty(v8_str("x"))->Int32Value()); | 2104 CHECK_EQ(4, res->ToObject()->GetRealNamedProperty(v8_str("x"))->Int32Value()); |
2105 | 2105 |
2106 Handle<JSObject> o = | 2106 Handle<JSObject> o = |
2107 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2107 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
2108 | 2108 |
2109 CHECK(HEAP->InNewSpace(*o)); | 2109 CHECK(HEAP->InNewSpace(*o)); |
2110 } | 2110 } |
2111 | 2111 |
2112 | 2112 |
2113 TEST(OptimizedPretenuringAllocationFolding) { | 2113 TEST(OptimizedPretenuringAllocationFolding) { |
2114 i::FLAG_allow_natives_syntax = true; | 2114 i::FLAG_allow_natives_syntax = true; |
2115 CcTest::InitializeVM(); | 2115 CcTest::InitializeVM(); |
2116 if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return; | 2116 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2117 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2117 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2118 v8::HandleScope scope(CcTest::isolate()); | 2118 v8::HandleScope scope(CcTest::isolate()); |
2119 HEAP->SetNewSpaceHighPromotionModeActive(true); | 2119 HEAP->SetNewSpaceHighPromotionModeActive(true); |
2120 | 2120 |
2121 v8::Local<v8::Value> res = CompileRun( | 2121 v8::Local<v8::Value> res = CompileRun( |
2122 "function DataObject() {" | 2122 "function DataObject() {" |
2123 " this.a = 1.1;" | 2123 " this.a = 1.1;" |
2124 " this.b = [{}];" | 2124 " this.b = [{}];" |
2125 " this.c = 1.2;" | 2125 " this.c = 1.2;" |
2126 " this.d = [{}];" | 2126 " this.d = [{}];" |
(...skipping 15 matching lines...) Expand all Loading... |
2142 CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(2))); | 2142 CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(2))); |
2143 CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(3))); | 2143 CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(3))); |
2144 CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(4))); | 2144 CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(4))); |
2145 CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(5))); | 2145 CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(5))); |
2146 } | 2146 } |
2147 | 2147 |
2148 | 2148 |
2149 TEST(OptimizedPretenuringAllocationFoldingBlocks) { | 2149 TEST(OptimizedPretenuringAllocationFoldingBlocks) { |
2150 i::FLAG_allow_natives_syntax = true; | 2150 i::FLAG_allow_natives_syntax = true; |
2151 CcTest::InitializeVM(); | 2151 CcTest::InitializeVM(); |
2152 if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return; | 2152 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2153 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2153 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2154 v8::HandleScope scope(CcTest::isolate()); | 2154 v8::HandleScope scope(CcTest::isolate()); |
2155 HEAP->SetNewSpaceHighPromotionModeActive(true); | 2155 HEAP->SetNewSpaceHighPromotionModeActive(true); |
2156 | 2156 |
2157 v8::Local<v8::Value> res = CompileRun( | 2157 v8::Local<v8::Value> res = CompileRun( |
2158 "function DataObject() {" | 2158 "function DataObject() {" |
2159 " this.a = [{}];" | 2159 " this.a = [{}];" |
2160 " this.b = [{}];" | 2160 " this.b = [{}];" |
2161 " this.c = 1.1;" | 2161 " this.c = 1.1;" |
2162 " this.d = 1.2;" | 2162 " this.d = 1.2;" |
(...skipping 15 matching lines...) Expand all Loading... |
2178 CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(2))); | 2178 CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(2))); |
2179 CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(3))); | 2179 CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(3))); |
2180 CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(4))); | 2180 CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(4))); |
2181 CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(5))); | 2181 CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(5))); |
2182 } | 2182 } |
2183 | 2183 |
2184 | 2184 |
2185 TEST(OptimizedPretenuringObjectArrayLiterals) { | 2185 TEST(OptimizedPretenuringObjectArrayLiterals) { |
2186 i::FLAG_allow_natives_syntax = true; | 2186 i::FLAG_allow_natives_syntax = true; |
2187 CcTest::InitializeVM(); | 2187 CcTest::InitializeVM(); |
2188 if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return; | 2188 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2189 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2189 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2190 v8::HandleScope scope(CcTest::isolate()); | 2190 v8::HandleScope scope(CcTest::isolate()); |
2191 HEAP->SetNewSpaceHighPromotionModeActive(true); | 2191 HEAP->SetNewSpaceHighPromotionModeActive(true); |
2192 | 2192 |
2193 v8::Local<v8::Value> res = CompileRun( | 2193 v8::Local<v8::Value> res = CompileRun( |
2194 "function f() {" | 2194 "function f() {" |
2195 " var numbers = [{}, {}, {}];" | 2195 " var numbers = [{}, {}, {}];" |
2196 " return numbers;" | 2196 " return numbers;" |
2197 "};" | 2197 "};" |
2198 "f(); f(); f();" | 2198 "f(); f(); f();" |
2199 "%OptimizeFunctionOnNextCall(f);" | 2199 "%OptimizeFunctionOnNextCall(f);" |
2200 "f();"); | 2200 "f();"); |
2201 | 2201 |
2202 Handle<JSObject> o = | 2202 Handle<JSObject> o = |
2203 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2203 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
2204 | 2204 |
2205 CHECK(HEAP->InOldPointerSpace(o->elements())); | 2205 CHECK(HEAP->InOldPointerSpace(o->elements())); |
2206 CHECK(HEAP->InOldPointerSpace(*o)); | 2206 CHECK(HEAP->InOldPointerSpace(*o)); |
2207 } | 2207 } |
2208 | 2208 |
2209 | 2209 |
2210 TEST(OptimizedPretenuringMixedInObjectProperties) { | 2210 TEST(OptimizedPretenuringMixedInObjectProperties) { |
2211 i::FLAG_allow_natives_syntax = true; | 2211 i::FLAG_allow_natives_syntax = true; |
2212 CcTest::InitializeVM(); | 2212 CcTest::InitializeVM(); |
2213 if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return; | 2213 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2214 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2214 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2215 v8::HandleScope scope(CcTest::isolate()); | 2215 v8::HandleScope scope(CcTest::isolate()); |
2216 HEAP->SetNewSpaceHighPromotionModeActive(true); | 2216 HEAP->SetNewSpaceHighPromotionModeActive(true); |
2217 | 2217 |
2218 v8::Local<v8::Value> res = CompileRun( | 2218 v8::Local<v8::Value> res = CompileRun( |
2219 "function f() {" | 2219 "function f() {" |
2220 " var numbers = {a: {c: 2.2, d: {}}, b: 1.1};" | 2220 " var numbers = {a: {c: 2.2, d: {}}, b: 1.1};" |
2221 " return numbers;" | 2221 " return numbers;" |
2222 "};" | 2222 "};" |
2223 "f(); f(); f();" | 2223 "f(); f(); f();" |
(...skipping 10 matching lines...) Expand all Loading... |
2234 JSObject* inner_object = reinterpret_cast<JSObject*>(o->RawFastPropertyAt(0)); | 2234 JSObject* inner_object = reinterpret_cast<JSObject*>(o->RawFastPropertyAt(0)); |
2235 CHECK(HEAP->InOldPointerSpace(inner_object)); | 2235 CHECK(HEAP->InOldPointerSpace(inner_object)); |
2236 CHECK(HEAP->InOldDataSpace(inner_object->RawFastPropertyAt(0))); | 2236 CHECK(HEAP->InOldDataSpace(inner_object->RawFastPropertyAt(0))); |
2237 CHECK(HEAP->InOldPointerSpace(inner_object->RawFastPropertyAt(1))); | 2237 CHECK(HEAP->InOldPointerSpace(inner_object->RawFastPropertyAt(1))); |
2238 } | 2238 } |
2239 | 2239 |
2240 | 2240 |
2241 TEST(OptimizedPretenuringDoubleArrayProperties) { | 2241 TEST(OptimizedPretenuringDoubleArrayProperties) { |
2242 i::FLAG_allow_natives_syntax = true; | 2242 i::FLAG_allow_natives_syntax = true; |
2243 CcTest::InitializeVM(); | 2243 CcTest::InitializeVM(); |
2244 if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return; | 2244 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2245 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2245 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2246 v8::HandleScope scope(CcTest::isolate()); | 2246 v8::HandleScope scope(CcTest::isolate()); |
2247 HEAP->SetNewSpaceHighPromotionModeActive(true); | 2247 HEAP->SetNewSpaceHighPromotionModeActive(true); |
2248 | 2248 |
2249 v8::Local<v8::Value> res = CompileRun( | 2249 v8::Local<v8::Value> res = CompileRun( |
2250 "function f() {" | 2250 "function f() {" |
2251 " var numbers = {a: 1.1, b: 2.2};" | 2251 " var numbers = {a: 1.1, b: 2.2};" |
2252 " return numbers;" | 2252 " return numbers;" |
2253 "};" | 2253 "};" |
2254 "f(); f(); f();" | 2254 "f(); f(); f();" |
2255 "%OptimizeFunctionOnNextCall(f);" | 2255 "%OptimizeFunctionOnNextCall(f);" |
2256 "f();"); | 2256 "f();"); |
2257 | 2257 |
2258 Handle<JSObject> o = | 2258 Handle<JSObject> o = |
2259 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2259 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
2260 | 2260 |
2261 CHECK(HEAP->InOldPointerSpace(*o)); | 2261 CHECK(HEAP->InOldPointerSpace(*o)); |
2262 CHECK(HEAP->InOldDataSpace(o->properties())); | 2262 CHECK(HEAP->InOldDataSpace(o->properties())); |
2263 } | 2263 } |
2264 | 2264 |
2265 | 2265 |
2266 TEST(OptimizedPretenuringdoubleArrayLiterals) { | 2266 TEST(OptimizedPretenuringdoubleArrayLiterals) { |
2267 i::FLAG_allow_natives_syntax = true; | 2267 i::FLAG_allow_natives_syntax = true; |
2268 CcTest::InitializeVM(); | 2268 CcTest::InitializeVM(); |
2269 if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return; | 2269 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2270 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2270 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2271 v8::HandleScope scope(CcTest::isolate()); | 2271 v8::HandleScope scope(CcTest::isolate()); |
2272 HEAP->SetNewSpaceHighPromotionModeActive(true); | 2272 HEAP->SetNewSpaceHighPromotionModeActive(true); |
2273 | 2273 |
2274 v8::Local<v8::Value> res = CompileRun( | 2274 v8::Local<v8::Value> res = CompileRun( |
2275 "function f() {" | 2275 "function f() {" |
2276 " var numbers = [1.1, 2.2, 3.3];" | 2276 " var numbers = [1.1, 2.2, 3.3];" |
2277 " return numbers;" | 2277 " return numbers;" |
2278 "};" | 2278 "};" |
2279 "f(); f(); f();" | 2279 "f(); f(); f();" |
2280 "%OptimizeFunctionOnNextCall(f);" | 2280 "%OptimizeFunctionOnNextCall(f);" |
2281 "f();"); | 2281 "f();"); |
2282 | 2282 |
2283 Handle<JSObject> o = | 2283 Handle<JSObject> o = |
2284 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2284 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
2285 | 2285 |
2286 CHECK(HEAP->InOldDataSpace(o->elements())); | 2286 CHECK(HEAP->InOldDataSpace(o->elements())); |
2287 CHECK(HEAP->InOldPointerSpace(*o)); | 2287 CHECK(HEAP->InOldPointerSpace(*o)); |
2288 } | 2288 } |
2289 | 2289 |
2290 | 2290 |
2291 TEST(OptimizedPretenuringNestedMixedArrayLiterals) { | 2291 TEST(OptimizedPretenuringNestedMixedArrayLiterals) { |
2292 i::FLAG_allow_natives_syntax = true; | 2292 i::FLAG_allow_natives_syntax = true; |
2293 CcTest::InitializeVM(); | 2293 CcTest::InitializeVM(); |
2294 if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return; | 2294 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2295 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2295 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2296 v8::HandleScope scope(CcTest::isolate()); | 2296 v8::HandleScope scope(CcTest::isolate()); |
2297 HEAP->SetNewSpaceHighPromotionModeActive(true); | 2297 HEAP->SetNewSpaceHighPromotionModeActive(true); |
2298 | 2298 |
2299 v8::Local<v8::Value> res = CompileRun( | 2299 v8::Local<v8::Value> res = CompileRun( |
2300 "function f() {" | 2300 "function f() {" |
2301 " var numbers = [[{}, {}, {}],[1.1, 2.2, 3.3]];" | 2301 " var numbers = [[{}, {}, {}],[1.1, 2.2, 3.3]];" |
2302 " return numbers;" | 2302 " return numbers;" |
2303 "};" | 2303 "};" |
2304 "f(); f(); f();" | 2304 "f(); f(); f();" |
(...skipping 13 matching lines...) Expand all Loading... |
2318 CHECK(HEAP->InOldPointerSpace(*int_array_handle)); | 2318 CHECK(HEAP->InOldPointerSpace(*int_array_handle)); |
2319 CHECK(HEAP->InOldPointerSpace(int_array_handle->elements())); | 2319 CHECK(HEAP->InOldPointerSpace(int_array_handle->elements())); |
2320 CHECK(HEAP->InOldPointerSpace(*double_array_handle)); | 2320 CHECK(HEAP->InOldPointerSpace(*double_array_handle)); |
2321 CHECK(HEAP->InOldDataSpace(double_array_handle->elements())); | 2321 CHECK(HEAP->InOldDataSpace(double_array_handle->elements())); |
2322 } | 2322 } |
2323 | 2323 |
2324 | 2324 |
2325 TEST(OptimizedPretenuringNestedObjectLiterals) { | 2325 TEST(OptimizedPretenuringNestedObjectLiterals) { |
2326 i::FLAG_allow_natives_syntax = true; | 2326 i::FLAG_allow_natives_syntax = true; |
2327 CcTest::InitializeVM(); | 2327 CcTest::InitializeVM(); |
2328 if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return; | 2328 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2329 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2329 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2330 v8::HandleScope scope(CcTest::isolate()); | 2330 v8::HandleScope scope(CcTest::isolate()); |
2331 HEAP->SetNewSpaceHighPromotionModeActive(true); | 2331 HEAP->SetNewSpaceHighPromotionModeActive(true); |
2332 | 2332 |
2333 v8::Local<v8::Value> res = CompileRun( | 2333 v8::Local<v8::Value> res = CompileRun( |
2334 "function f() {" | 2334 "function f() {" |
2335 " var numbers = [[{}, {}, {}],[{}, {}, {}]];" | 2335 " var numbers = [[{}, {}, {}],[{}, {}, {}]];" |
2336 " return numbers;" | 2336 " return numbers;" |
2337 "};" | 2337 "};" |
2338 "f(); f(); f();" | 2338 "f(); f(); f();" |
(...skipping 13 matching lines...) Expand all Loading... |
2352 CHECK(HEAP->InOldPointerSpace(*int_array_handle_1)); | 2352 CHECK(HEAP->InOldPointerSpace(*int_array_handle_1)); |
2353 CHECK(HEAP->InOldPointerSpace(int_array_handle_1->elements())); | 2353 CHECK(HEAP->InOldPointerSpace(int_array_handle_1->elements())); |
2354 CHECK(HEAP->InOldPointerSpace(*int_array_handle_2)); | 2354 CHECK(HEAP->InOldPointerSpace(*int_array_handle_2)); |
2355 CHECK(HEAP->InOldPointerSpace(int_array_handle_2->elements())); | 2355 CHECK(HEAP->InOldPointerSpace(int_array_handle_2->elements())); |
2356 } | 2356 } |
2357 | 2357 |
2358 | 2358 |
2359 TEST(OptimizedPretenuringNestedDoubleLiterals) { | 2359 TEST(OptimizedPretenuringNestedDoubleLiterals) { |
2360 i::FLAG_allow_natives_syntax = true; | 2360 i::FLAG_allow_natives_syntax = true; |
2361 CcTest::InitializeVM(); | 2361 CcTest::InitializeVM(); |
2362 if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return; | 2362 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2363 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2363 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2364 v8::HandleScope scope(CcTest::isolate()); | 2364 v8::HandleScope scope(CcTest::isolate()); |
2365 HEAP->SetNewSpaceHighPromotionModeActive(true); | 2365 HEAP->SetNewSpaceHighPromotionModeActive(true); |
2366 | 2366 |
2367 v8::Local<v8::Value> res = CompileRun( | 2367 v8::Local<v8::Value> res = CompileRun( |
2368 "function f() {" | 2368 "function f() {" |
2369 " var numbers = [[1.1, 1.2, 1.3],[2.1, 2.2, 2.3]];" | 2369 " var numbers = [[1.1, 1.2, 1.3],[2.1, 2.2, 2.3]];" |
2370 " return numbers;" | 2370 " return numbers;" |
2371 "};" | 2371 "};" |
2372 "f(); f(); f();" | 2372 "f(); f(); f();" |
(...skipping 16 matching lines...) Expand all Loading... |
2389 CHECK(HEAP->InOldDataSpace(double_array_handle_1->elements())); | 2389 CHECK(HEAP->InOldDataSpace(double_array_handle_1->elements())); |
2390 CHECK(HEAP->InOldPointerSpace(*double_array_handle_2)); | 2390 CHECK(HEAP->InOldPointerSpace(*double_array_handle_2)); |
2391 CHECK(HEAP->InOldDataSpace(double_array_handle_2->elements())); | 2391 CHECK(HEAP->InOldDataSpace(double_array_handle_2->elements())); |
2392 } | 2392 } |
2393 | 2393 |
2394 | 2394 |
2395 // Test regular array literals allocation. | 2395 // Test regular array literals allocation. |
2396 TEST(OptimizedAllocationArrayLiterals) { | 2396 TEST(OptimizedAllocationArrayLiterals) { |
2397 i::FLAG_allow_natives_syntax = true; | 2397 i::FLAG_allow_natives_syntax = true; |
2398 CcTest::InitializeVM(); | 2398 CcTest::InitializeVM(); |
2399 if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return; | 2399 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2400 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2400 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2401 v8::HandleScope scope(CcTest::isolate()); | 2401 v8::HandleScope scope(CcTest::isolate()); |
2402 | 2402 |
2403 v8::Local<v8::Value> res = CompileRun( | 2403 v8::Local<v8::Value> res = CompileRun( |
2404 "function f() {" | 2404 "function f() {" |
2405 " var numbers = new Array(1, 2, 3);" | 2405 " var numbers = new Array(1, 2, 3);" |
2406 " numbers[0] = 3.14;" | 2406 " numbers[0] = 3.14;" |
2407 " return numbers;" | 2407 " return numbers;" |
2408 "};" | 2408 "};" |
2409 "f(); f(); f();" | 2409 "f(); f(); f();" |
2410 "%OptimizeFunctionOnNextCall(f);" | 2410 "%OptimizeFunctionOnNextCall(f);" |
2411 "f();"); | 2411 "f();"); |
2412 CHECK_EQ(static_cast<int>(3.14), | 2412 CHECK_EQ(static_cast<int>(3.14), |
2413 v8::Object::Cast(*res)->Get(v8_str("0"))->Int32Value()); | 2413 v8::Object::Cast(*res)->Get(v8_str("0"))->Int32Value()); |
2414 | 2414 |
2415 Handle<JSObject> o = | 2415 Handle<JSObject> o = |
2416 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2416 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
2417 | 2417 |
2418 CHECK(HEAP->InNewSpace(o->elements())); | 2418 CHECK(HEAP->InNewSpace(o->elements())); |
2419 } | 2419 } |
2420 | 2420 |
2421 | 2421 |
2422 TEST(OptimizedPretenuringCallNew) { | 2422 TEST(OptimizedPretenuringCallNew) { |
2423 i::FLAG_allow_natives_syntax = true; | 2423 i::FLAG_allow_natives_syntax = true; |
2424 i::FLAG_pretenuring_call_new = true; | 2424 i::FLAG_pretenuring_call_new = true; |
2425 CcTest::InitializeVM(); | 2425 CcTest::InitializeVM(); |
2426 if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return; | 2426 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2427 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2427 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2428 v8::HandleScope scope(CcTest::isolate()); | 2428 v8::HandleScope scope(CcTest::isolate()); |
2429 HEAP->SetNewSpaceHighPromotionModeActive(true); | 2429 HEAP->SetNewSpaceHighPromotionModeActive(true); |
2430 | 2430 |
2431 AlwaysAllocateScope always_allocate; | 2431 AlwaysAllocateScope always_allocate; |
2432 v8::Local<v8::Value> res = CompileRun( | 2432 v8::Local<v8::Value> res = CompileRun( |
2433 "function g() { this.a = 0; }" | 2433 "function g() { this.a = 0; }" |
2434 "function f() {" | 2434 "function f() {" |
2435 " return new g();" | 2435 " return new g();" |
2436 "};" | 2436 "};" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2573 CHECK(root->map()->IsMap()); | 2573 CHECK(root->map()->IsMap()); |
2574 } | 2574 } |
2575 | 2575 |
2576 | 2576 |
2577 TEST(ReleaseOverReservedPages) { | 2577 TEST(ReleaseOverReservedPages) { |
2578 i::FLAG_trace_gc = true; | 2578 i::FLAG_trace_gc = true; |
2579 // The optimizer can allocate stuff, messing up the test. | 2579 // The optimizer can allocate stuff, messing up the test. |
2580 i::FLAG_crankshaft = false; | 2580 i::FLAG_crankshaft = false; |
2581 i::FLAG_always_opt = false; | 2581 i::FLAG_always_opt = false; |
2582 CcTest::InitializeVM(); | 2582 CcTest::InitializeVM(); |
2583 Isolate* isolate = Isolate::Current(); | 2583 Isolate* isolate = CcTest::i_isolate(); |
2584 Factory* factory = isolate->factory(); | 2584 Factory* factory = isolate->factory(); |
2585 v8::HandleScope scope(CcTest::isolate()); | 2585 v8::HandleScope scope(CcTest::isolate()); |
2586 static const int number_of_test_pages = 20; | 2586 static const int number_of_test_pages = 20; |
2587 | 2587 |
2588 // Prepare many pages with low live-bytes count. | 2588 // Prepare many pages with low live-bytes count. |
2589 PagedSpace* old_pointer_space = HEAP->old_pointer_space(); | 2589 PagedSpace* old_pointer_space = HEAP->old_pointer_space(); |
2590 CHECK_EQ(1, old_pointer_space->CountTotalPages()); | 2590 CHECK_EQ(1, old_pointer_space->CountTotalPages()); |
2591 for (int i = 0; i < number_of_test_pages; i++) { | 2591 for (int i = 0; i < number_of_test_pages; i++) { |
2592 AlwaysAllocateScope always_allocate; | 2592 AlwaysAllocateScope always_allocate; |
2593 SimulateFullSpace(old_pointer_space); | 2593 SimulateFullSpace(old_pointer_space); |
(...skipping 21 matching lines...) Expand all Loading... |
2615 // boots, but if the 20 small arrays don't fit on the first page then that's | 2615 // boots, but if the 20 small arrays don't fit on the first page then that's |
2616 // an indication that it is too small. | 2616 // an indication that it is too small. |
2617 HEAP->CollectAllAvailableGarbage("triggered really hard"); | 2617 HEAP->CollectAllAvailableGarbage("triggered really hard"); |
2618 CHECK_EQ(1, old_pointer_space->CountTotalPages()); | 2618 CHECK_EQ(1, old_pointer_space->CountTotalPages()); |
2619 } | 2619 } |
2620 | 2620 |
2621 | 2621 |
2622 TEST(Regress2237) { | 2622 TEST(Regress2237) { |
2623 i::FLAG_stress_compaction = false; | 2623 i::FLAG_stress_compaction = false; |
2624 CcTest::InitializeVM(); | 2624 CcTest::InitializeVM(); |
2625 Isolate* isolate = Isolate::Current(); | 2625 Isolate* isolate = CcTest::i_isolate(); |
2626 Factory* factory = isolate->factory(); | 2626 Factory* factory = isolate->factory(); |
2627 v8::HandleScope scope(CcTest::isolate()); | 2627 v8::HandleScope scope(CcTest::isolate()); |
2628 Handle<String> slice(HEAP->empty_string()); | 2628 Handle<String> slice(HEAP->empty_string()); |
2629 | 2629 |
2630 { | 2630 { |
2631 // Generate a parent that lives in new-space. | 2631 // Generate a parent that lives in new-space. |
2632 v8::HandleScope inner_scope(CcTest::isolate()); | 2632 v8::HandleScope inner_scope(CcTest::isolate()); |
2633 const char* c = "This text is long enough to trigger sliced strings."; | 2633 const char* c = "This text is long enough to trigger sliced strings."; |
2634 Handle<String> s = factory->NewStringFromAscii(CStrVector(c)); | 2634 Handle<String> s = factory->NewStringFromAscii(CStrVector(c)); |
2635 CHECK(s->IsSeqOneByteString()); | 2635 CHECK(s->IsSeqOneByteString()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2668 } | 2668 } |
2669 #endif // OBJECT_PRINT | 2669 #endif // OBJECT_PRINT |
2670 | 2670 |
2671 | 2671 |
2672 TEST(Regress2211) { | 2672 TEST(Regress2211) { |
2673 CcTest::InitializeVM(); | 2673 CcTest::InitializeVM(); |
2674 v8::HandleScope scope(CcTest::isolate()); | 2674 v8::HandleScope scope(CcTest::isolate()); |
2675 | 2675 |
2676 v8::Handle<v8::String> value = v8_str("val string"); | 2676 v8::Handle<v8::String> value = v8_str("val string"); |
2677 Smi* hash = Smi::FromInt(321); | 2677 Smi* hash = Smi::FromInt(321); |
2678 Heap* heap = Isolate::Current()->heap(); | 2678 Heap* heap = CcTest::i_isolate()->heap(); |
2679 | 2679 |
2680 for (int i = 0; i < 2; i++) { | 2680 for (int i = 0; i < 2; i++) { |
2681 // Store identity hash first and common hidden property second. | 2681 // Store identity hash first and common hidden property second. |
2682 v8::Handle<v8::Object> obj = v8::Object::New(); | 2682 v8::Handle<v8::Object> obj = v8::Object::New(); |
2683 Handle<JSObject> internal_obj = v8::Utils::OpenHandle(*obj); | 2683 Handle<JSObject> internal_obj = v8::Utils::OpenHandle(*obj); |
2684 CHECK(internal_obj->HasFastProperties()); | 2684 CHECK(internal_obj->HasFastProperties()); |
2685 | 2685 |
2686 // In the first iteration, set hidden value first and identity hash second. | 2686 // In the first iteration, set hidden value first and identity hash second. |
2687 // In the second iteration, reverse the order. | 2687 // In the second iteration, reverse the order. |
2688 if (i == 0) obj->SetHiddenValue(v8_str("key string"), value); | 2688 if (i == 0) obj->SetHiddenValue(v8_str("key string"), value); |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2953 ReleaseStackTraceDataTest(source1, getter); | 2953 ReleaseStackTraceDataTest(source1, getter); |
2954 ReleaseStackTraceDataTest(source2, getter); | 2954 ReleaseStackTraceDataTest(source2, getter); |
2955 ReleaseStackTraceDataTest(source3, getter); | 2955 ReleaseStackTraceDataTest(source3, getter); |
2956 ReleaseStackTraceDataTest(source4, getter); | 2956 ReleaseStackTraceDataTest(source4, getter); |
2957 } | 2957 } |
2958 | 2958 |
2959 | 2959 |
2960 TEST(Regression144230) { | 2960 TEST(Regression144230) { |
2961 i::FLAG_stress_compaction = false; | 2961 i::FLAG_stress_compaction = false; |
2962 CcTest::InitializeVM(); | 2962 CcTest::InitializeVM(); |
2963 Isolate* isolate = Isolate::Current(); | 2963 Isolate* isolate = CcTest::i_isolate(); |
2964 Heap* heap = isolate->heap(); | 2964 Heap* heap = isolate->heap(); |
2965 HandleScope scope(isolate); | 2965 HandleScope scope(isolate); |
2966 | 2966 |
2967 // First make sure that the uninitialized CallIC stub is on a single page | 2967 // First make sure that the uninitialized CallIC stub is on a single page |
2968 // that will later be selected as an evacuation candidate. | 2968 // that will later be selected as an evacuation candidate. |
2969 { | 2969 { |
2970 HandleScope inner_scope(isolate); | 2970 HandleScope inner_scope(isolate); |
2971 AlwaysAllocateScope always_allocate; | 2971 AlwaysAllocateScope always_allocate; |
2972 SimulateFullSpace(heap->code_space()); | 2972 SimulateFullSpace(heap->code_space()); |
2973 isolate->stub_cache()->ComputeCallInitialize(9, RelocInfo::CODE_TARGET); | 2973 isolate->stub_cache()->ComputeCallInitialize(9, RelocInfo::CODE_TARGET); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3017 // the CallIC is executed the next time. | 3017 // the CallIC is executed the next time. |
3018 JSReceiver::SetProperty(global, name, call_function, NONE, kNonStrictMode); | 3018 JSReceiver::SetProperty(global, name, call_function, NONE, kNonStrictMode); |
3019 CompileRun("call();"); | 3019 CompileRun("call();"); |
3020 } | 3020 } |
3021 | 3021 |
3022 | 3022 |
3023 TEST(Regress159140) { | 3023 TEST(Regress159140) { |
3024 i::FLAG_allow_natives_syntax = true; | 3024 i::FLAG_allow_natives_syntax = true; |
3025 i::FLAG_flush_code_incrementally = true; | 3025 i::FLAG_flush_code_incrementally = true; |
3026 CcTest::InitializeVM(); | 3026 CcTest::InitializeVM(); |
3027 Isolate* isolate = Isolate::Current(); | 3027 Isolate* isolate = CcTest::i_isolate(); |
3028 Heap* heap = isolate->heap(); | 3028 Heap* heap = isolate->heap(); |
3029 HandleScope scope(isolate); | 3029 HandleScope scope(isolate); |
3030 | 3030 |
3031 // Perform one initial GC to enable code flushing. | 3031 // Perform one initial GC to enable code flushing. |
3032 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 3032 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
3033 | 3033 |
3034 // Prepare several closures that are all eligible for code flushing | 3034 // Prepare several closures that are all eligible for code flushing |
3035 // because all reachable ones are not optimized. Make sure that the | 3035 // because all reachable ones are not optimized. Make sure that the |
3036 // optimized code object is directly reachable through a handle so | 3036 // optimized code object is directly reachable through a handle so |
3037 // that it is marked black during incremental marking. | 3037 // that it is marked black during incremental marking. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3079 | 3079 |
3080 // Unoptimized code is missing and the deoptimizer will go ballistic. | 3080 // Unoptimized code is missing and the deoptimizer will go ballistic. |
3081 CompileRun("g('bozo');"); | 3081 CompileRun("g('bozo');"); |
3082 } | 3082 } |
3083 | 3083 |
3084 | 3084 |
3085 TEST(Regress165495) { | 3085 TEST(Regress165495) { |
3086 i::FLAG_allow_natives_syntax = true; | 3086 i::FLAG_allow_natives_syntax = true; |
3087 i::FLAG_flush_code_incrementally = true; | 3087 i::FLAG_flush_code_incrementally = true; |
3088 CcTest::InitializeVM(); | 3088 CcTest::InitializeVM(); |
3089 Isolate* isolate = Isolate::Current(); | 3089 Isolate* isolate = CcTest::i_isolate(); |
3090 Heap* heap = isolate->heap(); | 3090 Heap* heap = isolate->heap(); |
3091 HandleScope scope(isolate); | 3091 HandleScope scope(isolate); |
3092 | 3092 |
3093 // Perform one initial GC to enable code flushing. | 3093 // Perform one initial GC to enable code flushing. |
3094 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 3094 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
3095 | 3095 |
3096 // Prepare an optimized closure that the optimized code map will get | 3096 // Prepare an optimized closure that the optimized code map will get |
3097 // populated. Then age the unoptimized code to trigger code flushing | 3097 // populated. Then age the unoptimized code to trigger code flushing |
3098 // but make sure the optimized code is unreachable. | 3098 // but make sure the optimized code is unreachable. |
3099 { | 3099 { |
(...skipping 28 matching lines...) Expand all Loading... |
3128 CompileRun("var g = mkClosure(); g('bozo');"); | 3128 CompileRun("var g = mkClosure(); g('bozo');"); |
3129 } | 3129 } |
3130 | 3130 |
3131 | 3131 |
3132 TEST(Regress169209) { | 3132 TEST(Regress169209) { |
3133 i::FLAG_stress_compaction = false; | 3133 i::FLAG_stress_compaction = false; |
3134 i::FLAG_allow_natives_syntax = true; | 3134 i::FLAG_allow_natives_syntax = true; |
3135 i::FLAG_flush_code_incrementally = true; | 3135 i::FLAG_flush_code_incrementally = true; |
3136 | 3136 |
3137 CcTest::InitializeVM(); | 3137 CcTest::InitializeVM(); |
3138 Isolate* isolate = Isolate::Current(); | 3138 Isolate* isolate = CcTest::i_isolate(); |
3139 Heap* heap = isolate->heap(); | 3139 Heap* heap = isolate->heap(); |
3140 HandleScope scope(isolate); | 3140 HandleScope scope(isolate); |
3141 | 3141 |
3142 // Perform one initial GC to enable code flushing. | 3142 // Perform one initial GC to enable code flushing. |
3143 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 3143 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
3144 | 3144 |
3145 // Prepare a shared function info eligible for code flushing for which | 3145 // Prepare a shared function info eligible for code flushing for which |
3146 // the unoptimized code will be replaced during optimization. | 3146 // the unoptimized code will be replaced during optimization. |
3147 Handle<SharedFunctionInfo> shared1; | 3147 Handle<SharedFunctionInfo> shared1; |
3148 { | 3148 { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3214 v8::internal::MaybeObject* maybe = space->AllocateRaw(new_linear_size); | 3214 v8::internal::MaybeObject* maybe = space->AllocateRaw(new_linear_size); |
3215 v8::internal::FreeListNode* node = v8::internal::FreeListNode::cast(maybe); | 3215 v8::internal::FreeListNode* node = v8::internal::FreeListNode::cast(maybe); |
3216 node->set_size(space->heap(), new_linear_size); | 3216 node->set_size(space->heap(), new_linear_size); |
3217 } | 3217 } |
3218 | 3218 |
3219 | 3219 |
3220 TEST(Regress169928) { | 3220 TEST(Regress169928) { |
3221 i::FLAG_allow_natives_syntax = true; | 3221 i::FLAG_allow_natives_syntax = true; |
3222 i::FLAG_crankshaft = false; | 3222 i::FLAG_crankshaft = false; |
3223 CcTest::InitializeVM(); | 3223 CcTest::InitializeVM(); |
3224 Isolate* isolate = Isolate::Current(); | 3224 Isolate* isolate = CcTest::i_isolate(); |
3225 Factory* factory = isolate->factory(); | 3225 Factory* factory = isolate->factory(); |
3226 v8::HandleScope scope(CcTest::isolate()); | 3226 v8::HandleScope scope(CcTest::isolate()); |
3227 | 3227 |
3228 // Some flags turn Scavenge collections into Mark-sweep collections | 3228 // Some flags turn Scavenge collections into Mark-sweep collections |
3229 // and hence are incompatible with this test case. | 3229 // and hence are incompatible with this test case. |
3230 if (FLAG_gc_global || FLAG_stress_compaction) return; | 3230 if (FLAG_gc_global || FLAG_stress_compaction) return; |
3231 | 3231 |
3232 // Prepare the environment | 3232 // Prepare the environment |
3233 CompileRun("function fastliteralcase(literal, value) {" | 3233 CompileRun("function fastliteralcase(literal, value) {" |
3234 " literal[0] = value;" | 3234 " literal[0] = value;" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3289 v8::Script::Compile(mote_code_string)->Run(); | 3289 v8::Script::Compile(mote_code_string)->Run(); |
3290 } | 3290 } |
3291 | 3291 |
3292 | 3292 |
3293 TEST(Regress168801) { | 3293 TEST(Regress168801) { |
3294 i::FLAG_always_compact = true; | 3294 i::FLAG_always_compact = true; |
3295 i::FLAG_cache_optimized_code = false; | 3295 i::FLAG_cache_optimized_code = false; |
3296 i::FLAG_allow_natives_syntax = true; | 3296 i::FLAG_allow_natives_syntax = true; |
3297 i::FLAG_flush_code_incrementally = true; | 3297 i::FLAG_flush_code_incrementally = true; |
3298 CcTest::InitializeVM(); | 3298 CcTest::InitializeVM(); |
3299 Isolate* isolate = Isolate::Current(); | 3299 Isolate* isolate = CcTest::i_isolate(); |
3300 Heap* heap = isolate->heap(); | 3300 Heap* heap = isolate->heap(); |
3301 HandleScope scope(isolate); | 3301 HandleScope scope(isolate); |
3302 | 3302 |
3303 // Perform one initial GC to enable code flushing. | 3303 // Perform one initial GC to enable code flushing. |
3304 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 3304 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
3305 | 3305 |
3306 // Ensure the code ends up on an evacuation candidate. | 3306 // Ensure the code ends up on an evacuation candidate. |
3307 SimulateFullSpace(heap->code_space()); | 3307 SimulateFullSpace(heap->code_space()); |
3308 | 3308 |
3309 // Prepare an unoptimized function that is eligible for code flushing. | 3309 // Prepare an unoptimized function that is eligible for code flushing. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3345 heap->CollectAllGarbage(Heap::kNoGCFlags); | 3345 heap->CollectAllGarbage(Heap::kNoGCFlags); |
3346 } | 3346 } |
3347 | 3347 |
3348 | 3348 |
3349 TEST(Regress173458) { | 3349 TEST(Regress173458) { |
3350 i::FLAG_always_compact = true; | 3350 i::FLAG_always_compact = true; |
3351 i::FLAG_cache_optimized_code = false; | 3351 i::FLAG_cache_optimized_code = false; |
3352 i::FLAG_allow_natives_syntax = true; | 3352 i::FLAG_allow_natives_syntax = true; |
3353 i::FLAG_flush_code_incrementally = true; | 3353 i::FLAG_flush_code_incrementally = true; |
3354 CcTest::InitializeVM(); | 3354 CcTest::InitializeVM(); |
3355 Isolate* isolate = Isolate::Current(); | 3355 Isolate* isolate = CcTest::i_isolate(); |
3356 Heap* heap = isolate->heap(); | 3356 Heap* heap = isolate->heap(); |
3357 HandleScope scope(isolate); | 3357 HandleScope scope(isolate); |
3358 | 3358 |
3359 // Perform one initial GC to enable code flushing. | 3359 // Perform one initial GC to enable code flushing. |
3360 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 3360 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
3361 | 3361 |
3362 // Ensure the code ends up on an evacuation candidate. | 3362 // Ensure the code ends up on an evacuation candidate. |
3363 SimulateFullSpace(heap->code_space()); | 3363 SimulateFullSpace(heap->code_space()); |
3364 | 3364 |
3365 // Prepare an unoptimized function that is eligible for code flushing. | 3365 // Prepare an unoptimized function that is eligible for code flushing. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3402 | 3402 |
3403 | 3403 |
3404 class DummyVisitor : public ObjectVisitor { | 3404 class DummyVisitor : public ObjectVisitor { |
3405 public: | 3405 public: |
3406 void VisitPointers(Object** start, Object** end) { } | 3406 void VisitPointers(Object** start, Object** end) { } |
3407 }; | 3407 }; |
3408 | 3408 |
3409 | 3409 |
3410 TEST(DeferredHandles) { | 3410 TEST(DeferredHandles) { |
3411 CcTest::InitializeVM(); | 3411 CcTest::InitializeVM(); |
3412 Isolate* isolate = Isolate::Current(); | 3412 Isolate* isolate = CcTest::i_isolate(); |
3413 Heap* heap = isolate->heap(); | 3413 Heap* heap = isolate->heap(); |
3414 v8::HandleScope scope(reinterpret_cast<v8::Isolate*>(isolate)); | 3414 v8::HandleScope scope(reinterpret_cast<v8::Isolate*>(isolate)); |
3415 v8::ImplementationUtilities::HandleScopeData* data = | 3415 v8::ImplementationUtilities::HandleScopeData* data = |
3416 isolate->handle_scope_data(); | 3416 isolate->handle_scope_data(); |
3417 Handle<Object> init(heap->empty_string(), isolate); | 3417 Handle<Object> init(heap->empty_string(), isolate); |
3418 while (data->next < data->limit) { | 3418 while (data->next < data->limit) { |
3419 Handle<Object> obj(heap->empty_string(), isolate); | 3419 Handle<Object> obj(heap->empty_string(), isolate); |
3420 } | 3420 } |
3421 // An entire block of handles has been filled. | 3421 // An entire block of handles has been filled. |
3422 // Next handle would require a new block. | 3422 // Next handle would require a new block. |
(...skipping 13 matching lines...) Expand all Loading... |
3436 " var a = new Array(n);" | 3436 " var a = new Array(n);" |
3437 " for (var i = 0; i < n; i += 100) a[i] = i;" | 3437 " for (var i = 0; i < n; i += 100) a[i] = i;" |
3438 "};" | 3438 "};" |
3439 "f(10 * 1024 * 1024);"); | 3439 "f(10 * 1024 * 1024);"); |
3440 IncrementalMarking* marking = HEAP->incremental_marking(); | 3440 IncrementalMarking* marking = HEAP->incremental_marking(); |
3441 if (marking->IsStopped()) marking->Start(); | 3441 if (marking->IsStopped()) marking->Start(); |
3442 // This big step should be sufficient to mark the whole array. | 3442 // This big step should be sufficient to mark the whole array. |
3443 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); | 3443 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); |
3444 ASSERT(marking->IsComplete()); | 3444 ASSERT(marking->IsComplete()); |
3445 } | 3445 } |
OLD | NEW |