| OLD | NEW |
| 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 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 &dispose_count)); | 438 &dispose_count)); |
| 439 CHECK(success); | 439 CHECK(success); |
| 440 Local<Script> script = Script::Compile(source); | 440 Local<Script> script = Script::Compile(source); |
| 441 Local<Value> value = script->Run(); | 441 Local<Value> value = script->Run(); |
| 442 CHECK(value->IsNumber()); | 442 CHECK(value->IsNumber()); |
| 443 CHECK_EQ(7, value->Int32Value()); | 443 CHECK_EQ(7, value->Int32Value()); |
| 444 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 444 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 445 CHECK_EQ(0, dispose_count); | 445 CHECK_EQ(0, dispose_count); |
| 446 } | 446 } |
| 447 i::Isolate::Current()->compilation_cache()->Clear(); | 447 i::Isolate::Current()->compilation_cache()->Clear(); |
| 448 HEAP->CollectAllGarbage(false); | 448 // TODO(1608): This should use kAbortIncrementalMarking. |
| 449 HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask); |
| 449 CHECK_EQ(1, dispose_count); | 450 CHECK_EQ(1, dispose_count); |
| 450 } | 451 } |
| 451 | 452 |
| 452 | 453 |
| 453 THREADED_TEST(ScriptMakingExternalAsciiString) { | 454 THREADED_TEST(ScriptMakingExternalAsciiString) { |
| 454 int dispose_count = 0; | 455 int dispose_count = 0; |
| 455 const char* c_source = "1 + 2 * 3"; | 456 const char* c_source = "1 + 2 * 3"; |
| 456 { | 457 { |
| 457 v8::HandleScope scope; | 458 v8::HandleScope scope; |
| 458 LocalContext env; | 459 LocalContext env; |
| 459 Local<String> source = v8_str(c_source); | 460 Local<String> source = v8_str(c_source); |
| 460 // Trigger GCs so that the newly allocated string moves to old gen. | 461 // Trigger GCs so that the newly allocated string moves to old gen. |
| 461 HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now | 462 HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now |
| 462 HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now | 463 HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now |
| 463 bool success = source->MakeExternal( | 464 bool success = source->MakeExternal( |
| 464 new TestAsciiResource(i::StrDup(c_source), &dispose_count)); | 465 new TestAsciiResource(i::StrDup(c_source), &dispose_count)); |
| 465 CHECK(success); | 466 CHECK(success); |
| 466 Local<Script> script = Script::Compile(source); | 467 Local<Script> script = Script::Compile(source); |
| 467 Local<Value> value = script->Run(); | 468 Local<Value> value = script->Run(); |
| 468 CHECK(value->IsNumber()); | 469 CHECK(value->IsNumber()); |
| 469 CHECK_EQ(7, value->Int32Value()); | 470 CHECK_EQ(7, value->Int32Value()); |
| 470 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 471 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 471 CHECK_EQ(0, dispose_count); | 472 CHECK_EQ(0, dispose_count); |
| 472 } | 473 } |
| 473 i::Isolate::Current()->compilation_cache()->Clear(); | 474 i::Isolate::Current()->compilation_cache()->Clear(); |
| 474 HEAP->CollectAllGarbage(false); | 475 // TODO(1608): This should use kAbortIncrementalMarking. |
| 476 HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask); |
| 475 CHECK_EQ(1, dispose_count); | 477 CHECK_EQ(1, dispose_count); |
| 476 } | 478 } |
| 477 | 479 |
| 478 | 480 |
| 479 TEST(MakingExternalStringConditions) { | 481 TEST(MakingExternalStringConditions) { |
| 480 v8::HandleScope scope; | 482 v8::HandleScope scope; |
| 481 LocalContext env; | 483 LocalContext env; |
| 482 | 484 |
| 483 // 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. |
| 484 HEAP->CollectGarbage(i::NEW_SPACE); | 486 HEAP->CollectGarbage(i::NEW_SPACE); |
| (...skipping 14681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15166 CHECK(i->Equals(CompileRun("'abcbd'.replace(/b/g,func)[3]"))); | 15168 CHECK(i->Equals(CompileRun("'abcbd'.replace(/b/g,func)[3]"))); |
| 15167 | 15169 |
| 15168 // TODO(1547): Make the following also return "i". | 15170 // TODO(1547): Make the following also return "i". |
| 15169 // Calling with environment record as base. | 15171 // Calling with environment record as base. |
| 15170 TestReceiver(o, context->Global(), "func()"); | 15172 TestReceiver(o, context->Global(), "func()"); |
| 15171 // Calling with no base. | 15173 // Calling with no base. |
| 15172 TestReceiver(o, context->Global(), "(1,func)()"); | 15174 TestReceiver(o, context->Global(), "(1,func)()"); |
| 15173 | 15175 |
| 15174 foreign_context.Dispose(); | 15176 foreign_context.Dispose(); |
| 15175 } | 15177 } |
| OLD | NEW |