Chromium Code Reviews| Index: test/cctest/test-api.cc |
| =================================================================== |
| --- test/cctest/test-api.cc (revision 13276) |
| +++ test/cctest/test-api.cc (working copy) |
| @@ -11608,6 +11608,7 @@ |
| static i::HashMap* code_map = NULL; |
| +static i::HashMap* jitcode_line_info = NULL; |
| static int saw_bar = 0; |
| static int move_events = 0; |
| @@ -11647,6 +11648,7 @@ |
| static void event_handler(const v8::JitCodeEvent* event) { |
| CHECK(event != NULL); |
| CHECK(code_map != NULL); |
| + CHECK(jitcode_line_info != NULL); |
| switch (event->type) { |
| case v8::JitCodeEvent::CODE_ADDED: { |
| @@ -11695,6 +11697,41 @@ |
| // Object/code removal events are currently not dispatched from the GC. |
| CHECK(false); |
| break; |
| + |
| + // For CODE_START_LINE_INFO_RECORDING event, we will create one |
| + // JITCodeLineInfo data structure pointed by event->user_dat. We record it |
|
danno
2013/01/10 16:47:33
nit: user_data
|
| + // in jitcode_line_info. |
| + case v8::JitCodeEvent::CODE_START_LINE_INFO_RECORDING: { |
| + CHECK(event->user_data != NULL); |
| + i::HashMap::Entry* entry = |
| + jitcode_line_info->Lookup(event->user_data, |
| + i::ComputePointerHash(event->user_data), |
|
danno
2013/01/10 16:47:33
nit: style, please use Google C++ coding guideline
|
| + true); |
| + entry->value = reinterpret_cast<void*>(event->user_data); |
| + } |
| + break; |
| + // For these two events, we will check whether the event->user_data |
| + // data structure is created before during CODE_START_LINE_INFO_RECORDING |
| + // event. And delete it in CODE_END_LINE_INFO_RECORDING event handling. |
| + case v8::JitCodeEvent::CODE_END_LINE_INFO_RECORDING: { |
| + CHECK(event->user_data != NULL); |
| + uint32_t hash = i::ComputePointerHash(event->user_data); |
| + i::HashMap::Entry* entry = |
| + jitcode_line_info->Lookup(event->user_data, hash, false); |
| + CHECK(entry != NULL); |
| + 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
|
| + } |
| + break; |
| + |
| + case v8::JitCodeEvent::CODE_ADD_LINE_POS_INFO: { |
| + CHECK(event->user_data != NULL); |
| + uint32_t hash = i::ComputePointerHash(event->user_data); |
| + i::HashMap::Entry* entry = |
| + jitcode_line_info->Lookup(event->user_data, hash, false); |
| + CHECK(entry != NULL); |
| + } |
| + break; |
| + |
| default: |
| // Impossible event. |
| CHECK(false); |
| @@ -11728,6 +11765,9 @@ |
| i::HashMap code(MatchPointers); |
| code_map = &code; |
| + i::HashMap lineinfo(MatchPointers); |
| + jitcode_line_info = &lineinfo; |
| + |
| saw_bar = 0; |
| move_events = 0; |
| @@ -11760,6 +11800,7 @@ |
| CHECK_NE(0, move_events); |
| code_map = NULL; |
| + jitcode_line_info = NULL; |
| V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault, NULL); |
| } |
| @@ -11781,10 +11822,14 @@ |
| i::HashMap code(MatchPointers); |
| code_map = &code; |
| + i::HashMap lineinfo(MatchPointers); |
| + jitcode_line_info = &lineinfo; |
| + |
| V8::SetJitCodeEventHandler(v8::kJitCodeEventEnumExisting, event_handler); |
| V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault, NULL); |
| code_map = NULL; |
| + jitcode_line_info = NULL; |
| // We expect that we got some events. Note that if we could get code removal |
| // notifications, we could compare two collections, one created by listening |