Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(336)

Side by Side Diff: test/cctest/test-api.cc

Issue 2010243003: Move hashmap into base/. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/zone.h ('k') | test/cctest/test-hashmap.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 14591 matching lines...) Expand 10 before | Expand all | Expand 10 after
14602 // This test breaks because InstallGetter (function from snapshot that 14602 // This test breaks because InstallGetter (function from snapshot that
14603 // only gets called from experimental natives) is compiled with entry hooks. 14603 // only gets called from experimental natives) is compiled with entry hooks.
14604 i::FLAG_allow_natives_syntax = true; 14604 i::FLAG_allow_natives_syntax = true;
14605 i::FLAG_turbo_inlining = false; 14605 i::FLAG_turbo_inlining = false;
14606 i::FLAG_use_inlining = false; 14606 i::FLAG_use_inlining = false;
14607 14607
14608 SetFunctionEntryHookTest test; 14608 SetFunctionEntryHookTest test;
14609 test.RunTest(); 14609 test.RunTest();
14610 } 14610 }
14611 14611
14612 14612 static v8::base::HashMap* code_map = NULL;
14613 static i::HashMap* code_map = NULL; 14613 static v8::base::HashMap* jitcode_line_info = NULL;
14614 static i::HashMap* jitcode_line_info = NULL;
14615 static int saw_bar = 0; 14614 static int saw_bar = 0;
14616 static int move_events = 0; 14615 static int move_events = 0;
14617 14616
14618 14617
14619 static bool FunctionNameIs(const char* expected, 14618 static bool FunctionNameIs(const char* expected,
14620 const v8::JitCodeEvent* event) { 14619 const v8::JitCodeEvent* event) {
14621 // Log lines for functions are of the general form: 14620 // Log lines for functions are of the general form:
14622 // "LazyCompile:<type><function_name>" or Function:<type><function_name>, 14621 // "LazyCompile:<type><function_name>" or Function:<type><function_name>,
14623 // where the type is one of "*", "~" or "". 14622 // where the type is one of "*", "~" or "".
14624 static const char* kPreamble; 14623 static const char* kPreamble;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
14664 CHECK(jitcode_line_info != NULL); 14663 CHECK(jitcode_line_info != NULL);
14665 14664
14666 class DummyJitCodeLineInfo { 14665 class DummyJitCodeLineInfo {
14667 }; 14666 };
14668 14667
14669 switch (event->type) { 14668 switch (event->type) {
14670 case v8::JitCodeEvent::CODE_ADDED: { 14669 case v8::JitCodeEvent::CODE_ADDED: {
14671 CHECK(event->code_start != NULL); 14670 CHECK(event->code_start != NULL);
14672 CHECK_NE(0, static_cast<int>(event->code_len)); 14671 CHECK_NE(0, static_cast<int>(event->code_len));
14673 CHECK(event->name.str != NULL); 14672 CHECK(event->name.str != NULL);
14674 i::HashMap::Entry* entry = code_map->LookupOrInsert( 14673 v8::base::HashMap::Entry* entry = code_map->LookupOrInsert(
14675 event->code_start, i::ComputePointerHash(event->code_start)); 14674 event->code_start, i::ComputePointerHash(event->code_start));
14676 entry->value = reinterpret_cast<void*>(event->code_len); 14675 entry->value = reinterpret_cast<void*>(event->code_len);
14677 14676
14678 if (FunctionNameIs("bar", event)) { 14677 if (FunctionNameIs("bar", event)) {
14679 ++saw_bar; 14678 ++saw_bar;
14680 } 14679 }
14681 } 14680 }
14682 break; 14681 break;
14683 14682
14684 case v8::JitCodeEvent::CODE_MOVED: { 14683 case v8::JitCodeEvent::CODE_MOVED: {
14685 uint32_t hash = i::ComputePointerHash(event->code_start); 14684 uint32_t hash = i::ComputePointerHash(event->code_start);
14686 // We would like to never see code move that we haven't seen before, 14685 // We would like to never see code move that we haven't seen before,
14687 // but the code creation event does not happen until the line endings 14686 // but the code creation event does not happen until the line endings
14688 // have been calculated (this is so that we can report the line in the 14687 // have been calculated (this is so that we can report the line in the
14689 // script at which the function source is found, see 14688 // script at which the function source is found, see
14690 // Compiler::RecordFunctionCompilation) and the line endings 14689 // Compiler::RecordFunctionCompilation) and the line endings
14691 // calculations can cause a GC, which can move the newly created code 14690 // calculations can cause a GC, which can move the newly created code
14692 // before its existence can be logged. 14691 // before its existence can be logged.
14693 i::HashMap::Entry* entry = code_map->Lookup(event->code_start, hash); 14692 v8::base::HashMap::Entry* entry =
14693 code_map->Lookup(event->code_start, hash);
14694 if (entry != NULL) { 14694 if (entry != NULL) {
14695 ++move_events; 14695 ++move_events;
14696 14696
14697 CHECK_EQ(reinterpret_cast<void*>(event->code_len), entry->value); 14697 CHECK_EQ(reinterpret_cast<void*>(event->code_len), entry->value);
14698 code_map->Remove(event->code_start, hash); 14698 code_map->Remove(event->code_start, hash);
14699 14699
14700 entry = code_map->LookupOrInsert( 14700 entry = code_map->LookupOrInsert(
14701 event->new_code_start, 14701 event->new_code_start,
14702 i::ComputePointerHash(event->new_code_start)); 14702 i::ComputePointerHash(event->new_code_start));
14703 entry->value = reinterpret_cast<void*>(event->code_len); 14703 entry->value = reinterpret_cast<void*>(event->code_len);
14704 } 14704 }
14705 } 14705 }
14706 break; 14706 break;
14707 14707
14708 case v8::JitCodeEvent::CODE_REMOVED: 14708 case v8::JitCodeEvent::CODE_REMOVED:
14709 // Object/code removal events are currently not dispatched from the GC. 14709 // Object/code removal events are currently not dispatched from the GC.
14710 CHECK(false); 14710 CHECK(false);
14711 break; 14711 break;
14712 14712
14713 // For CODE_START_LINE_INFO_RECORDING event, we will create one 14713 // For CODE_START_LINE_INFO_RECORDING event, we will create one
14714 // DummyJitCodeLineInfo data structure pointed by event->user_dat. We 14714 // DummyJitCodeLineInfo data structure pointed by event->user_dat. We
14715 // record it in jitcode_line_info. 14715 // record it in jitcode_line_info.
14716 case v8::JitCodeEvent::CODE_START_LINE_INFO_RECORDING: { 14716 case v8::JitCodeEvent::CODE_START_LINE_INFO_RECORDING: {
14717 DummyJitCodeLineInfo* line_info = new DummyJitCodeLineInfo(); 14717 DummyJitCodeLineInfo* line_info = new DummyJitCodeLineInfo();
14718 v8::JitCodeEvent* temp_event = const_cast<v8::JitCodeEvent*>(event); 14718 v8::JitCodeEvent* temp_event = const_cast<v8::JitCodeEvent*>(event);
14719 temp_event->user_data = line_info; 14719 temp_event->user_data = line_info;
14720 i::HashMap::Entry* entry = jitcode_line_info->LookupOrInsert( 14720 v8::base::HashMap::Entry* entry = jitcode_line_info->LookupOrInsert(
14721 line_info, i::ComputePointerHash(line_info)); 14721 line_info, i::ComputePointerHash(line_info));
14722 entry->value = reinterpret_cast<void*>(line_info); 14722 entry->value = reinterpret_cast<void*>(line_info);
14723 } 14723 }
14724 break; 14724 break;
14725 // For these two events, we will check whether the event->user_data 14725 // For these two events, we will check whether the event->user_data
14726 // data structure is created before during CODE_START_LINE_INFO_RECORDING 14726 // data structure is created before during CODE_START_LINE_INFO_RECORDING
14727 // event. And delete it in CODE_END_LINE_INFO_RECORDING event handling. 14727 // event. And delete it in CODE_END_LINE_INFO_RECORDING event handling.
14728 case v8::JitCodeEvent::CODE_END_LINE_INFO_RECORDING: { 14728 case v8::JitCodeEvent::CODE_END_LINE_INFO_RECORDING: {
14729 CHECK(event->user_data != NULL); 14729 CHECK(event->user_data != NULL);
14730 uint32_t hash = i::ComputePointerHash(event->user_data); 14730 uint32_t hash = i::ComputePointerHash(event->user_data);
14731 i::HashMap::Entry* entry = 14731 v8::base::HashMap::Entry* entry =
14732 jitcode_line_info->Lookup(event->user_data, hash); 14732 jitcode_line_info->Lookup(event->user_data, hash);
14733 CHECK(entry != NULL); 14733 CHECK(entry != NULL);
14734 delete reinterpret_cast<DummyJitCodeLineInfo*>(event->user_data); 14734 delete reinterpret_cast<DummyJitCodeLineInfo*>(event->user_data);
14735 } 14735 }
14736 break; 14736 break;
14737 14737
14738 case v8::JitCodeEvent::CODE_ADD_LINE_POS_INFO: { 14738 case v8::JitCodeEvent::CODE_ADD_LINE_POS_INFO: {
14739 CHECK(event->user_data != NULL); 14739 CHECK(event->user_data != NULL);
14740 uint32_t hash = i::ComputePointerHash(event->user_data); 14740 uint32_t hash = i::ComputePointerHash(event->user_data);
14741 i::HashMap::Entry* entry = 14741 v8::base::HashMap::Entry* entry =
14742 jitcode_line_info->Lookup(event->user_data, hash); 14742 jitcode_line_info->Lookup(event->user_data, hash);
14743 CHECK(entry != NULL); 14743 CHECK(entry != NULL);
14744 } 14744 }
14745 break; 14745 break;
14746 14746
14747 default: 14747 default:
14748 // Impossible event. 14748 // Impossible event.
14749 CHECK(false); 14749 CHECK(false);
14750 break; 14750 break;
14751 } 14751 }
(...skipping 21 matching lines...) Expand all
14773 v8::Isolate* isolate = v8::Isolate::New(create_params); 14773 v8::Isolate* isolate = v8::Isolate::New(create_params);
14774 isolate->Enter(); 14774 isolate->Enter();
14775 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 14775 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
14776 i::Heap* heap = i_isolate->heap(); 14776 i::Heap* heap = i_isolate->heap();
14777 14777
14778 // Start with a clean slate. 14778 // Start with a clean slate.
14779 heap->CollectAllAvailableGarbage("TestSetJitCodeEventHandler_Prepare"); 14779 heap->CollectAllAvailableGarbage("TestSetJitCodeEventHandler_Prepare");
14780 14780
14781 { 14781 {
14782 v8::HandleScope scope(isolate); 14782 v8::HandleScope scope(isolate);
14783 i::HashMap code(MatchPointers); 14783 v8::base::HashMap code(MatchPointers);
14784 code_map = &code; 14784 code_map = &code;
14785 14785
14786 i::HashMap lineinfo(MatchPointers); 14786 v8::base::HashMap lineinfo(MatchPointers);
14787 jitcode_line_info = &lineinfo; 14787 jitcode_line_info = &lineinfo;
14788 14788
14789 saw_bar = 0; 14789 saw_bar = 0;
14790 move_events = 0; 14790 move_events = 0;
14791 14791
14792 isolate->SetJitCodeEventHandler(v8::kJitCodeEventDefault, event_handler); 14792 isolate->SetJitCodeEventHandler(v8::kJitCodeEventDefault, event_handler);
14793 14793
14794 // Generate new code objects sparsely distributed across several 14794 // Generate new code objects sparsely distributed across several
14795 // different fragmented code-space pages. 14795 // different fragmented code-space pages.
14796 const int kIterations = 10; 14796 const int kIterations = 10;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
14839 isolate->Enter(); 14839 isolate->Enter();
14840 14840
14841 // Verify that we get callbacks for existing code objects when we 14841 // Verify that we get callbacks for existing code objects when we
14842 // request enumeration of existing code. 14842 // request enumeration of existing code.
14843 { 14843 {
14844 v8::HandleScope scope(isolate); 14844 v8::HandleScope scope(isolate);
14845 LocalContext env(isolate); 14845 LocalContext env(isolate);
14846 CompileRun(script); 14846 CompileRun(script);
14847 14847
14848 // Now get code through initial iteration. 14848 // Now get code through initial iteration.
14849 i::HashMap code(MatchPointers); 14849 v8::base::HashMap code(MatchPointers);
14850 code_map = &code; 14850 code_map = &code;
14851 14851
14852 i::HashMap lineinfo(MatchPointers); 14852 v8::base::HashMap lineinfo(MatchPointers);
14853 jitcode_line_info = &lineinfo; 14853 jitcode_line_info = &lineinfo;
14854 14854
14855 isolate->SetJitCodeEventHandler(v8::kJitCodeEventEnumExisting, 14855 isolate->SetJitCodeEventHandler(v8::kJitCodeEventEnumExisting,
14856 event_handler); 14856 event_handler);
14857 isolate->SetJitCodeEventHandler(v8::kJitCodeEventDefault, NULL); 14857 isolate->SetJitCodeEventHandler(v8::kJitCodeEventDefault, NULL);
14858 14858
14859 jitcode_line_info = NULL; 14859 jitcode_line_info = NULL;
14860 // We expect that we got some events. Note that if we could get code removal 14860 // We expect that we got some events. Note that if we could get code removal
14861 // notifications, we could compare two collections, one created by listening 14861 // notifications, we could compare two collections, one created by listening
14862 // from the time of creation of an isolate, and the other by subscribing 14862 // from the time of creation of an isolate, and the other by subscribing
(...skipping 10505 matching lines...) Expand 10 before | Expand all | Expand 10 after
25368 } 25368 }
25369 25369
25370 TEST(PrivateForApiIsNumber) { 25370 TEST(PrivateForApiIsNumber) {
25371 LocalContext context; 25371 LocalContext context;
25372 v8::Isolate* isolate = CcTest::isolate(); 25372 v8::Isolate* isolate = CcTest::isolate();
25373 v8::HandleScope scope(isolate); 25373 v8::HandleScope scope(isolate);
25374 25374
25375 // Shouldn't crash. 25375 // Shouldn't crash.
25376 v8::Private::ForApi(isolate, v8_str("42")); 25376 v8::Private::ForApi(isolate, v8_str("42"));
25377 } 25377 }
OLDNEW
« no previous file with comments | « src/zone.h ('k') | test/cctest/test-hashmap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698