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