Chromium Code Reviews| 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 11590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11601 v8::internal::Isolate::Current()->compilation_cache()->Clear(); | 11601 v8::internal::Isolate::Current()->compilation_cache()->Clear(); |
| 11602 | 11602 |
| 11603 // Verify that entry hooking is now disabled. | 11603 // Verify that entry hooking is now disabled. |
| 11604 RunLoopInNewEnv(); | 11604 RunLoopInNewEnv(); |
| 11605 CHECK_EQ(0u, bar_count); | 11605 CHECK_EQ(0u, bar_count); |
| 11606 CHECK_EQ(0u, foo_count); | 11606 CHECK_EQ(0u, foo_count); |
| 11607 } | 11607 } |
| 11608 | 11608 |
| 11609 | 11609 |
| 11610 static i::HashMap* code_map = NULL; | 11610 static i::HashMap* code_map = NULL; |
| 11611 static i::HashMap* jitcode_line_info = NULL; | |
| 11611 static int saw_bar = 0; | 11612 static int saw_bar = 0; |
| 11612 static int move_events = 0; | 11613 static int move_events = 0; |
| 11613 | 11614 |
| 11614 | 11615 |
| 11615 static bool FunctionNameIs(const char* expected, | 11616 static bool FunctionNameIs(const char* expected, |
| 11616 const v8::JitCodeEvent* event) { | 11617 const v8::JitCodeEvent* event) { |
| 11617 // Log lines for functions are of the general form: | 11618 // Log lines for functions are of the general form: |
| 11618 // "LazyCompile:<type><function_name>", where the type is one of | 11619 // "LazyCompile:<type><function_name>", where the type is one of |
| 11619 // "*", "~" or "". | 11620 // "*", "~" or "". |
| 11620 static const char kPreamble[] = "LazyCompile:"; | 11621 static const char kPreamble[] = "LazyCompile:"; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 11640 if (tail_len != expected_len) | 11641 if (tail_len != expected_len) |
| 11641 return false; | 11642 return false; |
| 11642 | 11643 |
| 11643 return strncmp(tail, expected, expected_len) == 0; | 11644 return strncmp(tail, expected, expected_len) == 0; |
| 11644 } | 11645 } |
| 11645 | 11646 |
| 11646 | 11647 |
| 11647 static void event_handler(const v8::JitCodeEvent* event) { | 11648 static void event_handler(const v8::JitCodeEvent* event) { |
| 11648 CHECK(event != NULL); | 11649 CHECK(event != NULL); |
| 11649 CHECK(code_map != NULL); | 11650 CHECK(code_map != NULL); |
| 11651 CHECK(jitcode_line_info != NULL); | |
| 11650 | 11652 |
| 11651 switch (event->type) { | 11653 switch (event->type) { |
| 11652 case v8::JitCodeEvent::CODE_ADDED: { | 11654 case v8::JitCodeEvent::CODE_ADDED: { |
| 11653 CHECK(event->code_start != NULL); | 11655 CHECK(event->code_start != NULL); |
| 11654 CHECK_NE(0, static_cast<int>(event->code_len)); | 11656 CHECK_NE(0, static_cast<int>(event->code_len)); |
| 11655 CHECK(event->name.str != NULL); | 11657 CHECK(event->name.str != NULL); |
| 11656 i::HashMap::Entry* entry = | 11658 i::HashMap::Entry* entry = |
| 11657 code_map->Lookup(event->code_start, | 11659 code_map->Lookup(event->code_start, |
| 11658 i::ComputePointerHash(event->code_start), | 11660 i::ComputePointerHash(event->code_start), |
| 11659 true); | 11661 true); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 11688 CHECK(entry != NULL); | 11690 CHECK(entry != NULL); |
| 11689 entry->value = reinterpret_cast<void*>(event->code_len); | 11691 entry->value = reinterpret_cast<void*>(event->code_len); |
| 11690 } | 11692 } |
| 11691 } | 11693 } |
| 11692 break; | 11694 break; |
| 11693 | 11695 |
| 11694 case v8::JitCodeEvent::CODE_REMOVED: | 11696 case v8::JitCodeEvent::CODE_REMOVED: |
| 11695 // Object/code removal events are currently not dispatched from the GC. | 11697 // Object/code removal events are currently not dispatched from the GC. |
| 11696 CHECK(false); | 11698 CHECK(false); |
| 11697 break; | 11699 break; |
| 11700 | |
| 11701 // For CODE_START_LINE_INFO_RECORDING event, we will create one | |
| 11702 // JITCodeLineInfo data structure pointed by event->user_dat. We record it | |
|
danno
2013/01/10 16:47:33
nit: user_data
| |
| 11703 // in jitcode_line_info. | |
| 11704 case v8::JitCodeEvent::CODE_START_LINE_INFO_RECORDING: { | |
| 11705 CHECK(event->user_data != NULL); | |
| 11706 i::HashMap::Entry* entry = | |
| 11707 jitcode_line_info->Lookup(event->user_data, | |
| 11708 i::ComputePointerHash(event->user_data), | |
|
danno
2013/01/10 16:47:33
nit: style, please use Google C++ coding guideline
| |
| 11709 true); | |
| 11710 entry->value = reinterpret_cast<void*>(event->user_data); | |
| 11711 } | |
| 11712 break; | |
| 11713 // For these two events, we will check whether the event->user_data | |
| 11714 // data structure is created before during CODE_START_LINE_INFO_RECORDING | |
| 11715 // event. And delete it in CODE_END_LINE_INFO_RECORDING event handling. | |
| 11716 case v8::JitCodeEvent::CODE_END_LINE_INFO_RECORDING: { | |
| 11717 CHECK(event->user_data != NULL); | |
| 11718 uint32_t hash = i::ComputePointerHash(event->user_data); | |
| 11719 i::HashMap::Entry* entry = | |
| 11720 jitcode_line_info->Lookup(event->user_data, hash, false); | |
| 11721 CHECK(entry != NULL); | |
| 11722 delete reinterpret_cast<i::JITCodeLineInfo*>(event->user_data); | |
|
danno
2013/01/10 16:47:33
YIKES! Disposing of a void* that is allocated with
chunyang.dai
2013/01/18 10:22:44
I am sorry I misused it. I moved the memory manage
| |
| 11723 } | |
| 11724 break; | |
| 11725 | |
| 11726 case v8::JitCodeEvent::CODE_ADD_LINE_POS_INFO: { | |
| 11727 CHECK(event->user_data != NULL); | |
| 11728 uint32_t hash = i::ComputePointerHash(event->user_data); | |
| 11729 i::HashMap::Entry* entry = | |
| 11730 jitcode_line_info->Lookup(event->user_data, hash, false); | |
| 11731 CHECK(entry != NULL); | |
| 11732 } | |
| 11733 break; | |
| 11734 | |
| 11698 default: | 11735 default: |
| 11699 // Impossible event. | 11736 // Impossible event. |
| 11700 CHECK(false); | 11737 CHECK(false); |
| 11701 break; | 11738 break; |
| 11702 } | 11739 } |
| 11703 } | 11740 } |
| 11704 | 11741 |
| 11705 | 11742 |
| 11706 static bool MatchPointers(void* key1, void* key2) { | 11743 static bool MatchPointers(void* key1, void* key2) { |
| 11707 return key1 == key2; | 11744 return key1 == key2; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 11721 | 11758 |
| 11722 // Run this test in a new isolate to make sure we don't | 11759 // Run this test in a new isolate to make sure we don't |
| 11723 // have remnants of state from other code. | 11760 // have remnants of state from other code. |
| 11724 v8::Isolate* isolate = v8::Isolate::New(); | 11761 v8::Isolate* isolate = v8::Isolate::New(); |
| 11725 isolate->Enter(); | 11762 isolate->Enter(); |
| 11726 | 11763 |
| 11727 { | 11764 { |
| 11728 i::HashMap code(MatchPointers); | 11765 i::HashMap code(MatchPointers); |
| 11729 code_map = &code; | 11766 code_map = &code; |
| 11730 | 11767 |
| 11768 i::HashMap lineinfo(MatchPointers); | |
| 11769 jitcode_line_info = &lineinfo; | |
| 11770 | |
| 11731 saw_bar = 0; | 11771 saw_bar = 0; |
| 11732 move_events = 0; | 11772 move_events = 0; |
| 11733 | 11773 |
| 11734 i::FLAG_stress_compaction = true; | 11774 i::FLAG_stress_compaction = true; |
| 11735 V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault, event_handler); | 11775 V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault, event_handler); |
| 11736 | 11776 |
| 11737 v8::HandleScope scope; | 11777 v8::HandleScope scope; |
| 11738 // Generate new code objects sparsely distributed across several | 11778 // Generate new code objects sparsely distributed across several |
| 11739 // different fragmented code-space pages. | 11779 // different fragmented code-space pages. |
| 11740 const int kIterations = 10; | 11780 const int kIterations = 10; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 11753 ISOLATE->compilation_cache()->Clear(); | 11793 ISOLATE->compilation_cache()->Clear(); |
| 11754 } | 11794 } |
| 11755 | 11795 |
| 11756 // Force code movement. | 11796 // Force code movement. |
| 11757 HEAP->CollectAllAvailableGarbage("TestSetJitCodeEventHandler"); | 11797 HEAP->CollectAllAvailableGarbage("TestSetJitCodeEventHandler"); |
| 11758 | 11798 |
| 11759 CHECK_LE(kIterations, saw_bar); | 11799 CHECK_LE(kIterations, saw_bar); |
| 11760 CHECK_NE(0, move_events); | 11800 CHECK_NE(0, move_events); |
| 11761 | 11801 |
| 11762 code_map = NULL; | 11802 code_map = NULL; |
| 11803 jitcode_line_info = NULL; | |
| 11763 V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault, NULL); | 11804 V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault, NULL); |
| 11764 } | 11805 } |
| 11765 | 11806 |
| 11766 isolate->Exit(); | 11807 isolate->Exit(); |
| 11767 isolate->Dispose(); | 11808 isolate->Dispose(); |
| 11768 | 11809 |
| 11769 // Do this in a new isolate. | 11810 // Do this in a new isolate. |
| 11770 isolate = v8::Isolate::New(); | 11811 isolate = v8::Isolate::New(); |
| 11771 isolate->Enter(); | 11812 isolate->Enter(); |
| 11772 | 11813 |
| 11773 // Verify that we get callbacks for existing code objects when we | 11814 // Verify that we get callbacks for existing code objects when we |
| 11774 // request enumeration of existing code. | 11815 // request enumeration of existing code. |
| 11775 { | 11816 { |
| 11776 v8::HandleScope scope; | 11817 v8::HandleScope scope; |
| 11777 LocalContext env; | 11818 LocalContext env; |
| 11778 CompileRun(script); | 11819 CompileRun(script); |
| 11779 | 11820 |
| 11780 // Now get code through initial iteration. | 11821 // Now get code through initial iteration. |
| 11781 i::HashMap code(MatchPointers); | 11822 i::HashMap code(MatchPointers); |
| 11782 code_map = &code; | 11823 code_map = &code; |
| 11783 | 11824 |
| 11825 i::HashMap lineinfo(MatchPointers); | |
| 11826 jitcode_line_info = &lineinfo; | |
| 11827 | |
| 11784 V8::SetJitCodeEventHandler(v8::kJitCodeEventEnumExisting, event_handler); | 11828 V8::SetJitCodeEventHandler(v8::kJitCodeEventEnumExisting, event_handler); |
| 11785 V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault, NULL); | 11829 V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault, NULL); |
| 11786 | 11830 |
| 11787 code_map = NULL; | 11831 code_map = NULL; |
| 11832 jitcode_line_info = NULL; | |
| 11788 | 11833 |
| 11789 // We expect that we got some events. Note that if we could get code removal | 11834 // We expect that we got some events. Note that if we could get code removal |
| 11790 // notifications, we could compare two collections, one created by listening | 11835 // notifications, we could compare two collections, one created by listening |
| 11791 // from the time of creation of an isolate, and the other by subscribing | 11836 // from the time of creation of an isolate, and the other by subscribing |
| 11792 // with EnumExisting. | 11837 // with EnumExisting. |
| 11793 CHECK_NE(0, code.occupancy()); | 11838 CHECK_NE(0, code.occupancy()); |
| 11794 } | 11839 } |
| 11795 | 11840 |
| 11796 isolate->Exit(); | 11841 isolate->Exit(); |
| 11797 isolate->Dispose(); | 11842 isolate->Dispose(); |
| (...skipping 6391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 18189 | 18234 |
| 18190 i::Semaphore* sem_; | 18235 i::Semaphore* sem_; |
| 18191 volatile int sem_value_; | 18236 volatile int sem_value_; |
| 18192 }; | 18237 }; |
| 18193 | 18238 |
| 18194 | 18239 |
| 18195 THREADED_TEST(SemaphoreInterruption) { | 18240 THREADED_TEST(SemaphoreInterruption) { |
| 18196 ThreadInterruptTest().RunTest(); | 18241 ThreadInterruptTest().RunTest(); |
| 18197 } | 18242 } |
| 18198 #endif // WIN32 | 18243 #endif // WIN32 |
| OLD | NEW |