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 15 matching lines...) Expand all Loading... |
11703 // Run this test in a new isolate to make sure we don't | 11745 // Run this test in a new isolate to make sure we don't |
11704 // have remnants of state from other code. | 11746 // have remnants of state from other code. |
11705 v8::Isolate* isolate = v8::Isolate::New(); | 11747 v8::Isolate* isolate = v8::Isolate::New(); |
11706 isolate->Enter(); | 11748 isolate->Enter(); |
11707 | 11749 |
11708 { | 11750 { |
11709 v8::HandleScope scope; | 11751 v8::HandleScope scope; |
11710 i::HashMap code(MatchPointers); | 11752 i::HashMap code(MatchPointers); |
11711 code_map = &code; | 11753 code_map = &code; |
11712 | 11754 |
| 11755 i::HashMap lineinfo(MatchPointers); |
| 11756 jitcode_line_info = &lineinfo; |
| 11757 |
11713 saw_bar = 0; | 11758 saw_bar = 0; |
11714 move_events = 0; | 11759 move_events = 0; |
11715 | 11760 |
11716 V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault, event_handler); | 11761 V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault, event_handler); |
11717 | 11762 |
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; |
11721 for (int i = 0; i < kIterations; ++i) { | 11766 for (int i = 0; i < kIterations; ++i) { |
11722 LocalContext env; | 11767 LocalContext env; |
(...skipping 13 matching lines...) Expand all Loading... |
11736 | 11781 |
11737 // Force code movement. | 11782 // Force code movement. |
11738 HEAP->CollectAllAvailableGarbage("TestSetJitCodeEventHandler"); | 11783 HEAP->CollectAllAvailableGarbage("TestSetJitCodeEventHandler"); |
11739 | 11784 |
11740 V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault, NULL); | 11785 V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault, NULL); |
11741 | 11786 |
11742 CHECK_LE(kIterations, saw_bar); | 11787 CHECK_LE(kIterations, saw_bar); |
11743 CHECK_LT(0, move_events); | 11788 CHECK_LT(0, move_events); |
11744 | 11789 |
11745 code_map = NULL; | 11790 code_map = NULL; |
| 11791 jitcode_line_info = NULL; |
11746 } | 11792 } |
11747 | 11793 |
11748 isolate->Exit(); | 11794 isolate->Exit(); |
11749 isolate->Dispose(); | 11795 isolate->Dispose(); |
11750 | 11796 |
11751 // Do this in a new isolate. | 11797 // Do this in a new isolate. |
11752 isolate = v8::Isolate::New(); | 11798 isolate = v8::Isolate::New(); |
11753 isolate->Enter(); | 11799 isolate->Enter(); |
11754 | 11800 |
11755 // Verify that we get callbacks for existing code objects when we | 11801 // Verify that we get callbacks for existing code objects when we |
11756 // request enumeration of existing code. | 11802 // request enumeration of existing code. |
11757 { | 11803 { |
11758 v8::HandleScope scope; | 11804 v8::HandleScope scope; |
11759 LocalContext env; | 11805 LocalContext env; |
11760 CompileRun(script); | 11806 CompileRun(script); |
11761 | 11807 |
11762 // Now get code through initial iteration. | 11808 // Now get code through initial iteration. |
11763 i::HashMap code(MatchPointers); | 11809 i::HashMap code(MatchPointers); |
11764 code_map = &code; | 11810 code_map = &code; |
11765 | 11811 |
| 11812 i::HashMap lineinfo(MatchPointers); |
| 11813 jitcode_line_info = &lineinfo; |
| 11814 |
11766 V8::SetJitCodeEventHandler(v8::kJitCodeEventEnumExisting, event_handler); | 11815 V8::SetJitCodeEventHandler(v8::kJitCodeEventEnumExisting, event_handler); |
11767 V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault, NULL); | 11816 V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault, NULL); |
11768 | 11817 |
| 11818 jitcode_line_info = NULL; |
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_LT(0, code.occupancy()); | 11823 CHECK_LT(0, code.occupancy()); |
11774 | 11824 |
11775 code_map = NULL; | 11825 code_map = NULL; |
11776 } | 11826 } |
11777 | 11827 |
11778 isolate->Exit(); | 11828 isolate->Exit(); |
(...skipping 6439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18218 i::Semaphore* sem_; | 18268 i::Semaphore* sem_; |
18219 volatile int sem_value_; | 18269 volatile int sem_value_; |
18220 }; | 18270 }; |
18221 | 18271 |
18222 | 18272 |
18223 THREADED_TEST(SemaphoreInterruption) { | 18273 THREADED_TEST(SemaphoreInterruption) { |
18224 ThreadInterruptTest().RunTest(); | 18274 ThreadInterruptTest().RunTest(); |
18225 } | 18275 } |
18226 | 18276 |
18227 #endif // WIN32 | 18277 #endif // WIN32 |
OLD | NEW |