| 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 11567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11578 v8::internal::Isolate::Current()->compilation_cache()->Clear(); | 11578 v8::internal::Isolate::Current()->compilation_cache()->Clear(); |
| 11579 | 11579 |
| 11580 // Verify that entry hooking is now disabled. | 11580 // Verify that entry hooking is now disabled. |
| 11581 RunLoopInNewEnv(); | 11581 RunLoopInNewEnv(); |
| 11582 CHECK_EQ(0u, bar_count); | 11582 CHECK_EQ(0u, bar_count); |
| 11583 CHECK_EQ(0u, foo_count); | 11583 CHECK_EQ(0u, foo_count); |
| 11584 } | 11584 } |
| 11585 | 11585 |
| 11586 | 11586 |
| 11587 static i::HashMap* code_map = NULL; | 11587 static i::HashMap* code_map = NULL; |
| 11588 static i::HashMap* jitcode_line_info = NULL; |
| 11588 static int saw_bar = 0; | 11589 static int saw_bar = 0; |
| 11589 static int move_events = 0; | 11590 static int move_events = 0; |
| 11590 | 11591 |
| 11591 | 11592 |
| 11592 static bool FunctionNameIs(const char* expected, | 11593 static bool FunctionNameIs(const char* expected, |
| 11593 const v8::JitCodeEvent* event) { | 11594 const v8::JitCodeEvent* event) { |
| 11594 // Log lines for functions are of the general form: | 11595 // Log lines for functions are of the general form: |
| 11595 // "LazyCompile:<type><function_name>", where the type is one of | 11596 // "LazyCompile:<type><function_name>", where the type is one of |
| 11596 // "*", "~" or "". | 11597 // "*", "~" or "". |
| 11597 static const char kPreamble[] = "LazyCompile:"; | 11598 static const char kPreamble[] = "LazyCompile:"; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 11617 if (tail_len != expected_len) | 11618 if (tail_len != expected_len) |
| 11618 return false; | 11619 return false; |
| 11619 | 11620 |
| 11620 return strncmp(tail, expected, expected_len) == 0; | 11621 return strncmp(tail, expected, expected_len) == 0; |
| 11621 } | 11622 } |
| 11622 | 11623 |
| 11623 | 11624 |
| 11624 static void event_handler(const v8::JitCodeEvent* event) { | 11625 static void event_handler(const v8::JitCodeEvent* event) { |
| 11625 CHECK(event != NULL); | 11626 CHECK(event != NULL); |
| 11626 CHECK(code_map != NULL); | 11627 CHECK(code_map != NULL); |
| 11628 CHECK(jitcode_line_info != NULL); |
| 11629 |
| 11630 class DummyJitCodeLineInfo { |
| 11631 }; |
| 11627 | 11632 |
| 11628 switch (event->type) { | 11633 switch (event->type) { |
| 11629 case v8::JitCodeEvent::CODE_ADDED: { | 11634 case v8::JitCodeEvent::CODE_ADDED: { |
| 11630 CHECK(event->code_start != NULL); | 11635 CHECK(event->code_start != NULL); |
| 11631 CHECK_NE(0, static_cast<int>(event->code_len)); | 11636 CHECK_NE(0, static_cast<int>(event->code_len)); |
| 11632 CHECK(event->name.str != NULL); | 11637 CHECK(event->name.str != NULL); |
| 11633 i::HashMap::Entry* entry = | 11638 i::HashMap::Entry* entry = |
| 11634 code_map->Lookup(event->code_start, | 11639 code_map->Lookup(event->code_start, |
| 11635 i::ComputePointerHash(event->code_start), | 11640 i::ComputePointerHash(event->code_start), |
| 11636 true); | 11641 true); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 11665 CHECK(entry != NULL); | 11670 CHECK(entry != NULL); |
| 11666 entry->value = reinterpret_cast<void*>(event->code_len); | 11671 entry->value = reinterpret_cast<void*>(event->code_len); |
| 11667 } | 11672 } |
| 11668 } | 11673 } |
| 11669 break; | 11674 break; |
| 11670 | 11675 |
| 11671 case v8::JitCodeEvent::CODE_REMOVED: | 11676 case v8::JitCodeEvent::CODE_REMOVED: |
| 11672 // Object/code removal events are currently not dispatched from the GC. | 11677 // Object/code removal events are currently not dispatched from the GC. |
| 11673 CHECK(false); | 11678 CHECK(false); |
| 11674 break; | 11679 break; |
| 11680 |
| 11681 // For CODE_START_LINE_INFO_RECORDING event, we will create one |
| 11682 // DummyJitCodeLineInfo data structure pointed by event->user_dat. We |
| 11683 // record it in jitcode_line_info. |
| 11684 case v8::JitCodeEvent::CODE_START_LINE_INFO_RECORDING: { |
| 11685 DummyJitCodeLineInfo* line_info = new DummyJitCodeLineInfo(); |
| 11686 v8::JitCodeEvent* temp_event = const_cast<v8::JitCodeEvent*>(event); |
| 11687 temp_event->user_data = line_info; |
| 11688 i::HashMap::Entry* entry = |
| 11689 jitcode_line_info->Lookup(line_info, |
| 11690 i::ComputePointerHash(line_info), |
| 11691 true); |
| 11692 entry->value = reinterpret_cast<void*>(line_info); |
| 11693 } |
| 11694 break; |
| 11695 // For these two events, we will check whether the event->user_data |
| 11696 // data structure is created before during CODE_START_LINE_INFO_RECORDING |
| 11697 // event. And delete it in CODE_END_LINE_INFO_RECORDING event handling. |
| 11698 case v8::JitCodeEvent::CODE_END_LINE_INFO_RECORDING: { |
| 11699 CHECK(event->user_data != NULL); |
| 11700 uint32_t hash = i::ComputePointerHash(event->user_data); |
| 11701 i::HashMap::Entry* entry = |
| 11702 jitcode_line_info->Lookup(event->user_data, hash, false); |
| 11703 CHECK(entry != NULL); |
| 11704 delete reinterpret_cast<DummyJitCodeLineInfo*>(event->user_data); |
| 11705 } |
| 11706 break; |
| 11707 |
| 11708 case v8::JitCodeEvent::CODE_ADD_LINE_POS_INFO: { |
| 11709 CHECK(event->user_data != NULL); |
| 11710 uint32_t hash = i::ComputePointerHash(event->user_data); |
| 11711 i::HashMap::Entry* entry = |
| 11712 jitcode_line_info->Lookup(event->user_data, hash, false); |
| 11713 CHECK(entry != NULL); |
| 11714 } |
| 11715 break; |
| 11716 |
| 11675 default: | 11717 default: |
| 11676 // Impossible event. | 11718 // Impossible event. |
| 11677 CHECK(false); | 11719 CHECK(false); |
| 11678 break; | 11720 break; |
| 11679 } | 11721 } |
| 11680 } | 11722 } |
| 11681 | 11723 |
| 11682 | 11724 |
| 11683 static bool MatchPointers(void* key1, void* key2) { | 11725 static bool MatchPointers(void* key1, void* key2) { |
| 11684 return key1 == key2; | 11726 return key1 == key2; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 11698 | 11740 |
| 11699 // Run this test in a new isolate to make sure we don't | 11741 // Run this test in a new isolate to make sure we don't |
| 11700 // have remnants of state from other code. | 11742 // have remnants of state from other code. |
| 11701 v8::Isolate* isolate = v8::Isolate::New(); | 11743 v8::Isolate* isolate = v8::Isolate::New(); |
| 11702 isolate->Enter(); | 11744 isolate->Enter(); |
| 11703 | 11745 |
| 11704 { | 11746 { |
| 11705 i::HashMap code(MatchPointers); | 11747 i::HashMap code(MatchPointers); |
| 11706 code_map = &code; | 11748 code_map = &code; |
| 11707 | 11749 |
| 11750 i::HashMap lineinfo(MatchPointers); |
| 11751 jitcode_line_info = &lineinfo; |
| 11752 |
| 11708 saw_bar = 0; | 11753 saw_bar = 0; |
| 11709 move_events = 0; | 11754 move_events = 0; |
| 11710 | 11755 |
| 11711 i::FLAG_stress_compaction = true; | 11756 i::FLAG_stress_compaction = true; |
| 11712 V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault, event_handler); | 11757 V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault, event_handler); |
| 11713 | 11758 |
| 11714 v8::HandleScope scope; | 11759 v8::HandleScope scope; |
| 11715 // Generate new code objects sparsely distributed across several | 11760 // Generate new code objects sparsely distributed across several |
| 11716 // different fragmented code-space pages. | 11761 // different fragmented code-space pages. |
| 11717 const int kIterations = 10; | 11762 const int kIterations = 10; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 11730 ISOLATE->compilation_cache()->Clear(); | 11775 ISOLATE->compilation_cache()->Clear(); |
| 11731 } | 11776 } |
| 11732 | 11777 |
| 11733 // Force code movement. | 11778 // Force code movement. |
| 11734 HEAP->CollectAllAvailableGarbage("TestSetJitCodeEventHandler"); | 11779 HEAP->CollectAllAvailableGarbage("TestSetJitCodeEventHandler"); |
| 11735 | 11780 |
| 11736 CHECK_LE(kIterations, saw_bar); | 11781 CHECK_LE(kIterations, saw_bar); |
| 11737 CHECK_NE(0, move_events); | 11782 CHECK_NE(0, move_events); |
| 11738 | 11783 |
| 11739 code_map = NULL; | 11784 code_map = NULL; |
| 11785 jitcode_line_info = NULL; |
| 11740 V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault, NULL); | 11786 V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault, NULL); |
| 11741 } | 11787 } |
| 11742 | 11788 |
| 11743 isolate->Exit(); | 11789 isolate->Exit(); |
| 11744 isolate->Dispose(); | 11790 isolate->Dispose(); |
| 11745 | 11791 |
| 11746 // Do this in a new isolate. | 11792 // Do this in a new isolate. |
| 11747 isolate = v8::Isolate::New(); | 11793 isolate = v8::Isolate::New(); |
| 11748 isolate->Enter(); | 11794 isolate->Enter(); |
| 11749 | 11795 |
| 11750 // Verify that we get callbacks for existing code objects when we | 11796 // Verify that we get callbacks for existing code objects when we |
| 11751 // request enumeration of existing code. | 11797 // request enumeration of existing code. |
| 11752 { | 11798 { |
| 11753 v8::HandleScope scope; | 11799 v8::HandleScope scope; |
| 11754 LocalContext env; | 11800 LocalContext env; |
| 11755 CompileRun(script); | 11801 CompileRun(script); |
| 11756 | 11802 |
| 11757 // Now get code through initial iteration. | 11803 // Now get code through initial iteration. |
| 11758 i::HashMap code(MatchPointers); | 11804 i::HashMap code(MatchPointers); |
| 11759 code_map = &code; | 11805 code_map = &code; |
| 11760 | 11806 |
| 11761 V8::SetJitCodeEventHandler(v8::kJitCodeEventEnumExisting, event_handler); | 11807 i::HashMap lineinfo(MatchPointers); |
| 11808 jitcode_line_info = &lineinfo; |
| 11809 |
| 11810 V8::SetJitCodeEventHandler(v8::kJitCodeEventEnumExisting, |
| 11811 event_handler); |
| 11762 V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault, NULL); | 11812 V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault, NULL); |
| 11763 | 11813 |
| 11764 code_map = NULL; | 11814 code_map = NULL; |
| 11815 jitcode_line_info = NULL; |
| 11765 | 11816 |
| 11766 // We expect that we got some events. Note that if we could get code removal | 11817 // We expect that we got some events. Note that if we could get code removal |
| 11767 // notifications, we could compare two collections, one created by listening | 11818 // notifications, we could compare two collections, one created by listening |
| 11768 // from the time of creation of an isolate, and the other by subscribing | 11819 // from the time of creation of an isolate, and the other by subscribing |
| 11769 // with EnumExisting. | 11820 // with EnumExisting. |
| 11770 CHECK_NE(0, code.occupancy()); | 11821 CHECK_NE(0, code.occupancy()); |
| 11771 } | 11822 } |
| 11772 | 11823 |
| 11773 isolate->Exit(); | 11824 isolate->Exit(); |
| 11774 isolate->Dispose(); | 11825 isolate->Dispose(); |
| (...skipping 6437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18212 i::Semaphore* sem_; | 18263 i::Semaphore* sem_; |
| 18213 volatile int sem_value_; | 18264 volatile int sem_value_; |
| 18214 }; | 18265 }; |
| 18215 | 18266 |
| 18216 | 18267 |
| 18217 THREADED_TEST(SemaphoreInterruption) { | 18268 THREADED_TEST(SemaphoreInterruption) { |
| 18218 ThreadInterruptTest().RunTest(); | 18269 ThreadInterruptTest().RunTest(); |
| 18219 } | 18270 } |
| 18220 | 18271 |
| 18221 #endif // WIN32 | 18272 #endif // WIN32 |
| OLD | NEW |