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

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

Issue 1074943002: Split TemplateHashMapImpl::Lookup into two methods (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix arm (and ppc) builds Created 5 years, 8 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
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 12334 matching lines...) Expand 10 before | Expand all | Expand 10 after
12345 CHECK(jitcode_line_info != NULL); 12345 CHECK(jitcode_line_info != NULL);
12346 12346
12347 class DummyJitCodeLineInfo { 12347 class DummyJitCodeLineInfo {
12348 }; 12348 };
12349 12349
12350 switch (event->type) { 12350 switch (event->type) {
12351 case v8::JitCodeEvent::CODE_ADDED: { 12351 case v8::JitCodeEvent::CODE_ADDED: {
12352 CHECK(event->code_start != NULL); 12352 CHECK(event->code_start != NULL);
12353 CHECK_NE(0, static_cast<int>(event->code_len)); 12353 CHECK_NE(0, static_cast<int>(event->code_len));
12354 CHECK(event->name.str != NULL); 12354 CHECK(event->name.str != NULL);
12355 i::HashMap::Entry* entry = 12355 i::HashMap::Entry* entry = code_map->LookupOrInsert(
12356 code_map->Lookup(event->code_start, 12356 event->code_start, i::ComputePointerHash(event->code_start));
12357 i::ComputePointerHash(event->code_start),
12358 true);
12359 entry->value = reinterpret_cast<void*>(event->code_len); 12357 entry->value = reinterpret_cast<void*>(event->code_len);
12360 12358
12361 if (FunctionNameIs("bar", event)) { 12359 if (FunctionNameIs("bar", event)) {
12362 ++saw_bar; 12360 ++saw_bar;
12363 } 12361 }
12364 } 12362 }
12365 break; 12363 break;
12366 12364
12367 case v8::JitCodeEvent::CODE_MOVED: { 12365 case v8::JitCodeEvent::CODE_MOVED: {
12368 uint32_t hash = i::ComputePointerHash(event->code_start); 12366 uint32_t hash = i::ComputePointerHash(event->code_start);
12369 // We would like to never see code move that we haven't seen before, 12367 // We would like to never see code move that we haven't seen before,
12370 // but the code creation event does not happen until the line endings 12368 // but the code creation event does not happen until the line endings
12371 // have been calculated (this is so that we can report the line in the 12369 // have been calculated (this is so that we can report the line in the
12372 // script at which the function source is found, see 12370 // script at which the function source is found, see
12373 // Compiler::RecordFunctionCompilation) and the line endings 12371 // Compiler::RecordFunctionCompilation) and the line endings
12374 // calculations can cause a GC, which can move the newly created code 12372 // calculations can cause a GC, which can move the newly created code
12375 // before its existence can be logged. 12373 // before its existence can be logged.
12376 i::HashMap::Entry* entry = 12374 i::HashMap::Entry* entry = code_map->Lookup(event->code_start, hash);
12377 code_map->Lookup(event->code_start, hash, false);
12378 if (entry != NULL) { 12375 if (entry != NULL) {
12379 ++move_events; 12376 ++move_events;
12380 12377
12381 CHECK_EQ(reinterpret_cast<void*>(event->code_len), entry->value); 12378 CHECK_EQ(reinterpret_cast<void*>(event->code_len), entry->value);
12382 code_map->Remove(event->code_start, hash); 12379 code_map->Remove(event->code_start, hash);
12383 12380
12384 entry = code_map->Lookup(event->new_code_start, 12381 entry = code_map->LookupOrInsert(
12385 i::ComputePointerHash(event->new_code_start), 12382 event->new_code_start,
12386 true); 12383 i::ComputePointerHash(event->new_code_start));
12387 CHECK(entry != NULL);
marja 2015/04/10 07:59:58 Why did you remove this CHECK?
adamk 2015/04/13 18:34:41 Basically because it's testing internal invariants
12388 entry->value = reinterpret_cast<void*>(event->code_len); 12384 entry->value = reinterpret_cast<void*>(event->code_len);
12389 } 12385 }
12390 } 12386 }
12391 break; 12387 break;
12392 12388
12393 case v8::JitCodeEvent::CODE_REMOVED: 12389 case v8::JitCodeEvent::CODE_REMOVED:
12394 // Object/code removal events are currently not dispatched from the GC. 12390 // Object/code removal events are currently not dispatched from the GC.
12395 CHECK(false); 12391 CHECK(false);
12396 break; 12392 break;
12397 12393
12398 // For CODE_START_LINE_INFO_RECORDING event, we will create one 12394 // For CODE_START_LINE_INFO_RECORDING event, we will create one
12399 // DummyJitCodeLineInfo data structure pointed by event->user_dat. We 12395 // DummyJitCodeLineInfo data structure pointed by event->user_dat. We
12400 // record it in jitcode_line_info. 12396 // record it in jitcode_line_info.
12401 case v8::JitCodeEvent::CODE_START_LINE_INFO_RECORDING: { 12397 case v8::JitCodeEvent::CODE_START_LINE_INFO_RECORDING: {
12402 DummyJitCodeLineInfo* line_info = new DummyJitCodeLineInfo(); 12398 DummyJitCodeLineInfo* line_info = new DummyJitCodeLineInfo();
12403 v8::JitCodeEvent* temp_event = const_cast<v8::JitCodeEvent*>(event); 12399 v8::JitCodeEvent* temp_event = const_cast<v8::JitCodeEvent*>(event);
12404 temp_event->user_data = line_info; 12400 temp_event->user_data = line_info;
12405 i::HashMap::Entry* entry = 12401 i::HashMap::Entry* entry = jitcode_line_info->LookupOrInsert(
12406 jitcode_line_info->Lookup(line_info, 12402 line_info, i::ComputePointerHash(line_info));
12407 i::ComputePointerHash(line_info),
12408 true);
12409 entry->value = reinterpret_cast<void*>(line_info); 12403 entry->value = reinterpret_cast<void*>(line_info);
12410 } 12404 }
12411 break; 12405 break;
12412 // For these two events, we will check whether the event->user_data 12406 // For these two events, we will check whether the event->user_data
12413 // data structure is created before during CODE_START_LINE_INFO_RECORDING 12407 // data structure is created before during CODE_START_LINE_INFO_RECORDING
12414 // event. And delete it in CODE_END_LINE_INFO_RECORDING event handling. 12408 // event. And delete it in CODE_END_LINE_INFO_RECORDING event handling.
12415 case v8::JitCodeEvent::CODE_END_LINE_INFO_RECORDING: { 12409 case v8::JitCodeEvent::CODE_END_LINE_INFO_RECORDING: {
12416 CHECK(event->user_data != NULL); 12410 CHECK(event->user_data != NULL);
12417 uint32_t hash = i::ComputePointerHash(event->user_data); 12411 uint32_t hash = i::ComputePointerHash(event->user_data);
12418 i::HashMap::Entry* entry = 12412 i::HashMap::Entry* entry =
12419 jitcode_line_info->Lookup(event->user_data, hash, false); 12413 jitcode_line_info->Lookup(event->user_data, hash);
12420 CHECK(entry != NULL); 12414 CHECK(entry != NULL);
12421 delete reinterpret_cast<DummyJitCodeLineInfo*>(event->user_data); 12415 delete reinterpret_cast<DummyJitCodeLineInfo*>(event->user_data);
12422 } 12416 }
12423 break; 12417 break;
12424 12418
12425 case v8::JitCodeEvent::CODE_ADD_LINE_POS_INFO: { 12419 case v8::JitCodeEvent::CODE_ADD_LINE_POS_INFO: {
12426 CHECK(event->user_data != NULL); 12420 CHECK(event->user_data != NULL);
12427 uint32_t hash = i::ComputePointerHash(event->user_data); 12421 uint32_t hash = i::ComputePointerHash(event->user_data);
12428 i::HashMap::Entry* entry = 12422 i::HashMap::Entry* entry =
12429 jitcode_line_info->Lookup(event->user_data, hash, false); 12423 jitcode_line_info->Lookup(event->user_data, hash);
12430 CHECK(entry != NULL); 12424 CHECK(entry != NULL);
12431 } 12425 }
12432 break; 12426 break;
12433 12427
12434 default: 12428 default:
12435 // Impossible event. 12429 // Impossible event.
12436 CHECK(false); 12430 CHECK(false);
12437 break; 12431 break;
12438 } 12432 }
12439 } 12433 }
(...skipping 9453 matching lines...) Expand 10 before | Expand all | Expand 10 after
21893 } 21887 }
21894 { 21888 {
21895 v8::TryCatch try_catch; 21889 v8::TryCatch try_catch;
21896 uint16_t* data = reinterpret_cast<uint16_t*>(buffer); 21890 uint16_t* data = reinterpret_cast<uint16_t*>(buffer);
21897 CHECK(v8::String::NewFromTwoByte(isolate, data, v8::String::kNormalString, 21891 CHECK(v8::String::NewFromTwoByte(isolate, data, v8::String::kNormalString,
21898 length).IsEmpty()); 21892 length).IsEmpty());
21899 CHECK(!try_catch.HasCaught()); 21893 CHECK(!try_catch.HasCaught());
21900 } 21894 }
21901 free(buffer); 21895 free(buffer);
21902 } 21896 }
OLDNEW
« src/hashmap.h ('K') | « src/strings-storage.cc ('k') | test/cctest/test-hashmap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698