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

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

Issue 7618040: Version 3.5.5. (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-accessors.cc ('k') | test/cctest/test-circular-queue.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 static uint16_t* AsciiToTwoByteString(const char* source) { 324 static uint16_t* AsciiToTwoByteString(const char* source) {
325 int array_length = i::StrLength(source) + 1; 325 int array_length = i::StrLength(source) + 1;
326 uint16_t* converted = i::NewArray<uint16_t>(array_length); 326 uint16_t* converted = i::NewArray<uint16_t>(array_length);
327 for (int i = 0; i < array_length; i++) converted[i] = source[i]; 327 for (int i = 0; i < array_length; i++) converted[i] = source[i];
328 return converted; 328 return converted;
329 } 329 }
330 330
331 331
332 class TestResource: public String::ExternalStringResource { 332 class TestResource: public String::ExternalStringResource {
333 public: 333 public:
334 static int dispose_count; 334 explicit TestResource(uint16_t* data, int* counter = NULL)
335 335 : data_(data), length_(0), counter_(counter) {
336 explicit TestResource(uint16_t* data)
337 : data_(data), length_(0) {
338 while (data[length_]) ++length_; 336 while (data[length_]) ++length_;
339 } 337 }
340 338
341 ~TestResource() { 339 ~TestResource() {
342 i::DeleteArray(data_); 340 i::DeleteArray(data_);
343 ++dispose_count; 341 if (counter_ != NULL) ++*counter_;
344 } 342 }
345 343
346 const uint16_t* data() const { 344 const uint16_t* data() const {
347 return data_; 345 return data_;
348 } 346 }
349 347
350 size_t length() const { 348 size_t length() const {
351 return length_; 349 return length_;
352 } 350 }
353 private: 351 private:
354 uint16_t* data_; 352 uint16_t* data_;
355 size_t length_; 353 size_t length_;
354 int* counter_;
356 }; 355 };
357 356
358 357
359 int TestResource::dispose_count = 0;
360
361
362 class TestAsciiResource: public String::ExternalAsciiStringResource { 358 class TestAsciiResource: public String::ExternalAsciiStringResource {
363 public: 359 public:
364 static int dispose_count; 360 explicit TestAsciiResource(const char* data, int* counter = NULL)
365 361 : data_(data), length_(strlen(data)), counter_(counter) { }
366 explicit TestAsciiResource(const char* data)
367 : data_(data),
368 length_(strlen(data)) { }
369 362
370 ~TestAsciiResource() { 363 ~TestAsciiResource() {
371 i::DeleteArray(data_); 364 i::DeleteArray(data_);
372 ++dispose_count; 365 if (counter_ != NULL) ++*counter_;
373 } 366 }
374 367
375 const char* data() const { 368 const char* data() const {
376 return data_; 369 return data_;
377 } 370 }
378 371
379 size_t length() const { 372 size_t length() const {
380 return length_; 373 return length_;
381 } 374 }
382 private: 375 private:
383 const char* data_; 376 const char* data_;
384 size_t length_; 377 size_t length_;
378 int* counter_;
385 }; 379 };
386 380
387 381
388 int TestAsciiResource::dispose_count = 0;
389
390
391 THREADED_TEST(ScriptUsingStringResource) { 382 THREADED_TEST(ScriptUsingStringResource) {
392 TestResource::dispose_count = 0; 383 int dispose_count = 0;
393 const char* c_source = "1 + 2 * 3"; 384 const char* c_source = "1 + 2 * 3";
394 uint16_t* two_byte_source = AsciiToTwoByteString(c_source); 385 uint16_t* two_byte_source = AsciiToTwoByteString(c_source);
395 { 386 {
396 v8::HandleScope scope; 387 v8::HandleScope scope;
397 LocalContext env; 388 LocalContext env;
398 TestResource* resource = new TestResource(two_byte_source); 389 TestResource* resource = new TestResource(two_byte_source, &dispose_count);
399 Local<String> source = String::NewExternal(resource); 390 Local<String> source = String::NewExternal(resource);
400 Local<Script> script = Script::Compile(source); 391 Local<Script> script = Script::Compile(source);
401 Local<Value> value = script->Run(); 392 Local<Value> value = script->Run();
402 CHECK(value->IsNumber()); 393 CHECK(value->IsNumber());
403 CHECK_EQ(7, value->Int32Value()); 394 CHECK_EQ(7, value->Int32Value());
404 CHECK(source->IsExternal()); 395 CHECK(source->IsExternal());
405 CHECK_EQ(resource, 396 CHECK_EQ(resource,
406 static_cast<TestResource*>(source->GetExternalStringResource())); 397 static_cast<TestResource*>(source->GetExternalStringResource()));
407 HEAP->CollectAllGarbage(false); 398 HEAP->CollectAllGarbage(false);
408 CHECK_EQ(0, TestResource::dispose_count); 399 CHECK_EQ(0, dispose_count);
409 } 400 }
410 v8::internal::Isolate::Current()->compilation_cache()->Clear(); 401 v8::internal::Isolate::Current()->compilation_cache()->Clear();
411 HEAP->CollectAllGarbage(false); 402 HEAP->CollectAllGarbage(false);
412 CHECK_EQ(1, TestResource::dispose_count); 403 CHECK_EQ(1, dispose_count);
413 } 404 }
414 405
415 406
416 THREADED_TEST(ScriptUsingAsciiStringResource) { 407 THREADED_TEST(ScriptUsingAsciiStringResource) {
417 TestAsciiResource::dispose_count = 0; 408 int dispose_count = 0;
418 const char* c_source = "1 + 2 * 3"; 409 const char* c_source = "1 + 2 * 3";
419 { 410 {
420 v8::HandleScope scope; 411 v8::HandleScope scope;
421 LocalContext env; 412 LocalContext env;
422 Local<String> source = 413 Local<String> source =
423 String::NewExternal(new TestAsciiResource(i::StrDup(c_source))); 414 String::NewExternal(new TestAsciiResource(i::StrDup(c_source),
415 &dispose_count));
424 Local<Script> script = Script::Compile(source); 416 Local<Script> script = Script::Compile(source);
425 Local<Value> value = script->Run(); 417 Local<Value> value = script->Run();
426 CHECK(value->IsNumber()); 418 CHECK(value->IsNumber());
427 CHECK_EQ(7, value->Int32Value()); 419 CHECK_EQ(7, value->Int32Value());
428 HEAP->CollectAllGarbage(false); 420 HEAP->CollectAllGarbage(false);
429 CHECK_EQ(0, TestAsciiResource::dispose_count); 421 CHECK_EQ(0, dispose_count);
430 } 422 }
431 i::Isolate::Current()->compilation_cache()->Clear(); 423 i::Isolate::Current()->compilation_cache()->Clear();
432 HEAP->CollectAllGarbage(false); 424 HEAP->CollectAllGarbage(false);
433 CHECK_EQ(1, TestAsciiResource::dispose_count); 425 CHECK_EQ(1, dispose_count);
434 } 426 }
435 427
436 428
437 THREADED_TEST(ScriptMakingExternalString) { 429 THREADED_TEST(ScriptMakingExternalString) {
438 TestResource::dispose_count = 0; 430 int dispose_count = 0;
439 uint16_t* two_byte_source = AsciiToTwoByteString("1 + 2 * 3"); 431 uint16_t* two_byte_source = AsciiToTwoByteString("1 + 2 * 3");
440 { 432 {
441 v8::HandleScope scope; 433 v8::HandleScope scope;
442 LocalContext env; 434 LocalContext env;
443 Local<String> source = String::New(two_byte_source); 435 Local<String> source = String::New(two_byte_source);
444 // Trigger GCs so that the newly allocated string moves to old gen. 436 // Trigger GCs so that the newly allocated string moves to old gen.
445 HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now 437 HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now
446 HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now 438 HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now
447 bool success = source->MakeExternal(new TestResource(two_byte_source)); 439 bool success = source->MakeExternal(new TestResource(two_byte_source,
440 &dispose_count));
448 CHECK(success); 441 CHECK(success);
449 Local<Script> script = Script::Compile(source); 442 Local<Script> script = Script::Compile(source);
450 Local<Value> value = script->Run(); 443 Local<Value> value = script->Run();
451 CHECK(value->IsNumber()); 444 CHECK(value->IsNumber());
452 CHECK_EQ(7, value->Int32Value()); 445 CHECK_EQ(7, value->Int32Value());
453 HEAP->CollectAllGarbage(false); 446 HEAP->CollectAllGarbage(false);
454 CHECK_EQ(0, TestResource::dispose_count); 447 CHECK_EQ(0, dispose_count);
455 } 448 }
456 i::Isolate::Current()->compilation_cache()->Clear(); 449 i::Isolate::Current()->compilation_cache()->Clear();
457 HEAP->CollectAllGarbage(false); 450 HEAP->CollectAllGarbage(false);
458 CHECK_EQ(1, TestResource::dispose_count); 451 CHECK_EQ(1, dispose_count);
459 } 452 }
460 453
461 454
462 THREADED_TEST(ScriptMakingExternalAsciiString) { 455 THREADED_TEST(ScriptMakingExternalAsciiString) {
463 TestAsciiResource::dispose_count = 0; 456 int dispose_count = 0;
464 const char* c_source = "1 + 2 * 3"; 457 const char* c_source = "1 + 2 * 3";
465 { 458 {
466 v8::HandleScope scope; 459 v8::HandleScope scope;
467 LocalContext env; 460 LocalContext env;
468 Local<String> source = v8_str(c_source); 461 Local<String> source = v8_str(c_source);
469 // Trigger GCs so that the newly allocated string moves to old gen. 462 // Trigger GCs so that the newly allocated string moves to old gen.
470 HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now 463 HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now
471 HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now 464 HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now
472 bool success = source->MakeExternal( 465 bool success = source->MakeExternal(
473 new TestAsciiResource(i::StrDup(c_source))); 466 new TestAsciiResource(i::StrDup(c_source), &dispose_count));
474 CHECK(success); 467 CHECK(success);
475 Local<Script> script = Script::Compile(source); 468 Local<Script> script = Script::Compile(source);
476 Local<Value> value = script->Run(); 469 Local<Value> value = script->Run();
477 CHECK(value->IsNumber()); 470 CHECK(value->IsNumber());
478 CHECK_EQ(7, value->Int32Value()); 471 CHECK_EQ(7, value->Int32Value());
479 HEAP->CollectAllGarbage(false); 472 HEAP->CollectAllGarbage(false);
480 CHECK_EQ(0, TestAsciiResource::dispose_count); 473 CHECK_EQ(0, dispose_count);
481 } 474 }
482 i::Isolate::Current()->compilation_cache()->Clear(); 475 i::Isolate::Current()->compilation_cache()->Clear();
483 HEAP->CollectAllGarbage(false); 476 HEAP->CollectAllGarbage(false);
484 CHECK_EQ(1, TestAsciiResource::dispose_count); 477 CHECK_EQ(1, dispose_count);
485 } 478 }
486 479
487 480
488 TEST(MakingExternalStringConditions) { 481 TEST(MakingExternalStringConditions) {
489 v8::HandleScope scope; 482 v8::HandleScope scope;
490 LocalContext env; 483 LocalContext env;
491 484
492 // Free some space in the new space so that we can check freshness. 485 // Free some space in the new space so that we can check freshness.
493 HEAP->CollectGarbage(i::NEW_SPACE); 486 HEAP->CollectGarbage(i::NEW_SPACE);
494 HEAP->CollectGarbage(i::NEW_SPACE); 487 HEAP->CollectGarbage(i::NEW_SPACE);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now 591 HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now
599 i::Handle<i::String> isymbol = FACTORY->SymbolFromString(istring); 592 i::Handle<i::String> isymbol = FACTORY->SymbolFromString(istring);
600 CHECK(isymbol->IsSymbol()); 593 CHECK(isymbol->IsSymbol());
601 } 594 }
602 HEAP->CollectAllGarbage(false); 595 HEAP->CollectAllGarbage(false);
603 HEAP->CollectAllGarbage(false); 596 HEAP->CollectAllGarbage(false);
604 } 597 }
605 598
606 599
607 THREADED_TEST(ScavengeExternalString) { 600 THREADED_TEST(ScavengeExternalString) {
608 TestResource::dispose_count = 0; 601 int dispose_count = 0;
609 bool in_new_space = false; 602 bool in_new_space = false;
610 { 603 {
611 v8::HandleScope scope; 604 v8::HandleScope scope;
612 uint16_t* two_byte_string = AsciiToTwoByteString("test string"); 605 uint16_t* two_byte_string = AsciiToTwoByteString("test string");
613 Local<String> string = 606 Local<String> string =
614 String::NewExternal(new TestResource(two_byte_string)); 607 String::NewExternal(new TestResource(two_byte_string,
608 &dispose_count));
615 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); 609 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
616 HEAP->CollectGarbage(i::NEW_SPACE); 610 HEAP->CollectGarbage(i::NEW_SPACE);
617 in_new_space = HEAP->InNewSpace(*istring); 611 in_new_space = HEAP->InNewSpace(*istring);
618 CHECK(in_new_space || HEAP->old_data_space()->Contains(*istring)); 612 CHECK(in_new_space || HEAP->old_data_space()->Contains(*istring));
619 CHECK_EQ(0, TestResource::dispose_count); 613 CHECK_EQ(0, dispose_count);
620 } 614 }
621 HEAP->CollectGarbage(in_new_space ? i::NEW_SPACE : i::OLD_DATA_SPACE); 615 HEAP->CollectGarbage(in_new_space ? i::NEW_SPACE : i::OLD_DATA_SPACE);
622 CHECK_EQ(1, TestResource::dispose_count); 616 CHECK_EQ(1, dispose_count);
623 } 617 }
624 618
625 619
626 THREADED_TEST(ScavengeExternalAsciiString) { 620 THREADED_TEST(ScavengeExternalAsciiString) {
627 TestAsciiResource::dispose_count = 0; 621 int dispose_count = 0;
628 bool in_new_space = false; 622 bool in_new_space = false;
629 { 623 {
630 v8::HandleScope scope; 624 v8::HandleScope scope;
631 const char* one_byte_string = "test string"; 625 const char* one_byte_string = "test string";
632 Local<String> string = String::NewExternal( 626 Local<String> string = String::NewExternal(
633 new TestAsciiResource(i::StrDup(one_byte_string))); 627 new TestAsciiResource(i::StrDup(one_byte_string), &dispose_count));
634 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); 628 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
635 HEAP->CollectGarbage(i::NEW_SPACE); 629 HEAP->CollectGarbage(i::NEW_SPACE);
636 in_new_space = HEAP->InNewSpace(*istring); 630 in_new_space = HEAP->InNewSpace(*istring);
637 CHECK(in_new_space || HEAP->old_data_space()->Contains(*istring)); 631 CHECK(in_new_space || HEAP->old_data_space()->Contains(*istring));
638 CHECK_EQ(0, TestAsciiResource::dispose_count); 632 CHECK_EQ(0, dispose_count);
639 } 633 }
640 HEAP->CollectGarbage(in_new_space ? i::NEW_SPACE : i::OLD_DATA_SPACE); 634 HEAP->CollectGarbage(in_new_space ? i::NEW_SPACE : i::OLD_DATA_SPACE);
641 CHECK_EQ(1, TestAsciiResource::dispose_count); 635 CHECK_EQ(1, dispose_count);
642 } 636 }
643 637
644 638
645 class TestAsciiResourceWithDisposeControl: public TestAsciiResource { 639 class TestAsciiResourceWithDisposeControl: public TestAsciiResource {
646 public: 640 public:
641 // Only used by non-threaded tests, so it can use static fields.
647 static int dispose_calls; 642 static int dispose_calls;
643 static int dispose_count;
648 644
649 TestAsciiResourceWithDisposeControl(const char* data, bool dispose) 645 TestAsciiResourceWithDisposeControl(const char* data, bool dispose)
650 : TestAsciiResource(data), 646 : TestAsciiResource(data, &dispose_count),
651 dispose_(dispose) { } 647 dispose_(dispose) { }
652 648
653 void Dispose() { 649 void Dispose() {
654 ++dispose_calls; 650 ++dispose_calls;
655 if (dispose_) delete this; 651 if (dispose_) delete this;
656 } 652 }
657 private: 653 private:
658 bool dispose_; 654 bool dispose_;
659 }; 655 };
660 656
661 657
658 int TestAsciiResourceWithDisposeControl::dispose_count = 0;
662 int TestAsciiResourceWithDisposeControl::dispose_calls = 0; 659 int TestAsciiResourceWithDisposeControl::dispose_calls = 0;
663 660
664 661
665 TEST(ExternalStringWithDisposeHandling) { 662 TEST(ExternalStringWithDisposeHandling) {
666 const char* c_source = "1 + 2 * 3"; 663 const char* c_source = "1 + 2 * 3";
667 664
668 // Use a stack allocated external string resource allocated object. 665 // Use a stack allocated external string resource allocated object.
669 TestAsciiResource::dispose_count = 0; 666 TestAsciiResourceWithDisposeControl::dispose_count = 0;
670 TestAsciiResourceWithDisposeControl::dispose_calls = 0; 667 TestAsciiResourceWithDisposeControl::dispose_calls = 0;
671 TestAsciiResourceWithDisposeControl res_stack(i::StrDup(c_source), false); 668 TestAsciiResourceWithDisposeControl res_stack(i::StrDup(c_source), false);
672 { 669 {
673 v8::HandleScope scope; 670 v8::HandleScope scope;
674 LocalContext env; 671 LocalContext env;
675 Local<String> source = String::NewExternal(&res_stack); 672 Local<String> source = String::NewExternal(&res_stack);
676 Local<Script> script = Script::Compile(source); 673 Local<Script> script = Script::Compile(source);
677 Local<Value> value = script->Run(); 674 Local<Value> value = script->Run();
678 CHECK(value->IsNumber()); 675 CHECK(value->IsNumber());
679 CHECK_EQ(7, value->Int32Value()); 676 CHECK_EQ(7, value->Int32Value());
680 HEAP->CollectAllGarbage(false); 677 HEAP->CollectAllGarbage(false);
681 CHECK_EQ(0, TestAsciiResource::dispose_count); 678 CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count);
682 } 679 }
683 i::Isolate::Current()->compilation_cache()->Clear(); 680 i::Isolate::Current()->compilation_cache()->Clear();
684 HEAP->CollectAllGarbage(false); 681 HEAP->CollectAllGarbage(false);
685 CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls); 682 CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls);
686 CHECK_EQ(0, TestAsciiResource::dispose_count); 683 CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count);
687 684
688 // Use a heap allocated external string resource allocated object. 685 // Use a heap allocated external string resource allocated object.
689 TestAsciiResource::dispose_count = 0; 686 TestAsciiResourceWithDisposeControl::dispose_count = 0;
690 TestAsciiResourceWithDisposeControl::dispose_calls = 0; 687 TestAsciiResourceWithDisposeControl::dispose_calls = 0;
691 TestAsciiResource* res_heap = 688 TestAsciiResource* res_heap =
692 new TestAsciiResourceWithDisposeControl(i::StrDup(c_source), true); 689 new TestAsciiResourceWithDisposeControl(i::StrDup(c_source), true);
693 { 690 {
694 v8::HandleScope scope; 691 v8::HandleScope scope;
695 LocalContext env; 692 LocalContext env;
696 Local<String> source = String::NewExternal(res_heap); 693 Local<String> source = String::NewExternal(res_heap);
697 Local<Script> script = Script::Compile(source); 694 Local<Script> script = Script::Compile(source);
698 Local<Value> value = script->Run(); 695 Local<Value> value = script->Run();
699 CHECK(value->IsNumber()); 696 CHECK(value->IsNumber());
700 CHECK_EQ(7, value->Int32Value()); 697 CHECK_EQ(7, value->Int32Value());
701 HEAP->CollectAllGarbage(false); 698 HEAP->CollectAllGarbage(false);
702 CHECK_EQ(0, TestAsciiResource::dispose_count); 699 CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count);
703 } 700 }
704 i::Isolate::Current()->compilation_cache()->Clear(); 701 i::Isolate::Current()->compilation_cache()->Clear();
705 HEAP->CollectAllGarbage(false); 702 HEAP->CollectAllGarbage(false);
706 CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls); 703 CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls);
707 CHECK_EQ(1, TestAsciiResource::dispose_count); 704 CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_count);
708 } 705 }
709 706
710 707
711 THREADED_TEST(StringConcat) { 708 THREADED_TEST(StringConcat) {
712 { 709 {
713 v8::HandleScope scope; 710 v8::HandleScope scope;
714 LocalContext env; 711 LocalContext env;
715 const char* one_byte_string_1 = "function a_times_t"; 712 const char* one_byte_string_1 = "function a_times_t";
716 const char* two_byte_string_1 = "wo_plus_b(a, b) {return "; 713 const char* two_byte_string_1 = "wo_plus_b(a, b) {return ";
717 const char* one_byte_extern_1 = "a * 2 + b;} a_times_two_plus_b(4, 8) + "; 714 const char* one_byte_extern_1 = "a * 2 + b;} a_times_two_plus_b(4, 8) + ";
(...skipping 13870 matching lines...) Expand 10 before | Expand all | Expand 10 after
14588 CHECK(instance2->CreationContext() == context2); 14585 CHECK(instance2->CreationContext() == context2);
14589 CheckContextId(instance2, 2); 14586 CheckContextId(instance2, 2);
14590 } 14587 }
14591 14588
14592 context1.Dispose(); 14589 context1.Dispose();
14593 context2.Dispose(); 14590 context2.Dispose();
14594 context3.Dispose(); 14591 context3.Dispose();
14595 } 14592 }
14596 14593
14597 14594
14595 THREADED_TEST(CreationContextOfJsFunction) {
14596 HandleScope handle_scope;
14597 Persistent<Context> context = Context::New();
14598 InstallContextId(context, 1);
14599
14600 Local<Object> function;
14601 {
14602 Context::Scope scope(context);
14603 function = CompileRun("function foo() {}; foo").As<Object>();
14604 }
14605
14606 CHECK(function->CreationContext() == context);
14607 CheckContextId(function, 1);
14608
14609 context.Dispose();
14610 }
14611
14612
14598 Handle<Value> HasOwnPropertyIndexedPropertyGetter(uint32_t index, 14613 Handle<Value> HasOwnPropertyIndexedPropertyGetter(uint32_t index,
14599 const AccessorInfo& info) { 14614 const AccessorInfo& info) {
14600 if (index == 42) return v8_str("yes"); 14615 if (index == 42) return v8_str("yes");
14601 return Handle<v8::Integer>(); 14616 return Handle<v8::Integer>();
14602 } 14617 }
14603 14618
14604 14619
14605 Handle<Value> HasOwnPropertyNamedPropertyGetter(Local<String> property, 14620 Handle<Value> HasOwnPropertyNamedPropertyGetter(Local<String> property,
14606 const AccessorInfo& info) { 14621 const AccessorInfo& info) {
14607 if (property->Equals(v8_str("foo"))) return v8_str("yes"); 14622 if (property->Equals(v8_str("foo"))) return v8_str("yes");
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
14830 } 14845 }
14831 14846
14832 i::Isolate::Current()->heap()->CollectAllGarbage(true); 14847 i::Isolate::Current()->heap()->CollectAllGarbage(true);
14833 { i::Object* raw_map_cache = i::Isolate::Current()->context()->map_cache(); 14848 { i::Object* raw_map_cache = i::Isolate::Current()->context()->map_cache();
14834 if (raw_map_cache != i::Isolate::Current()->heap()->undefined_value()) { 14849 if (raw_map_cache != i::Isolate::Current()->heap()->undefined_value()) {
14835 i::MapCache* map_cache = i::MapCache::cast(raw_map_cache); 14850 i::MapCache* map_cache = i::MapCache::cast(raw_map_cache);
14836 CHECK_GT(elements, map_cache->NumberOfElements()); 14851 CHECK_GT(elements, map_cache->NumberOfElements());
14837 } 14852 }
14838 } 14853 }
14839 } 14854 }
OLDNEW
« no previous file with comments | « test/cctest/test-accessors.cc ('k') | test/cctest/test-circular-queue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698