| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Tests of logging functions from log.h | 3 // Tests of logging functions from log.h |
| 4 | 4 |
| 5 #ifdef ENABLE_LOGGING_AND_PROFILING | 5 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 6 | 6 |
| 7 #ifdef __linux__ | 7 #ifdef __linux__ |
| 8 #include <math.h> | 8 #include <math.h> |
| 9 #include <pthread.h> | 9 #include <pthread.h> |
| 10 #include <signal.h> | 10 #include <signal.h> |
| (...skipping 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1052 int ref_len = StrChrLen(ref_s, ','); | 1052 int ref_len = StrChrLen(ref_s, ','); |
| 1053 int new_len = StrChrLen(new_s, ','); | 1053 int new_len = StrChrLen(new_s, ','); |
| 1054 return ref_len == new_len && strncmp(ref_s, new_s, ref_len) == 0; | 1054 return ref_len == new_len && strncmp(ref_s, new_s, ref_len) == 0; |
| 1055 } | 1055 } |
| 1056 | 1056 |
| 1057 | 1057 |
| 1058 static bool AreFuncNamesEqual(CodeEntityInfo ref_s, CodeEntityInfo new_s) { | 1058 static bool AreFuncNamesEqual(CodeEntityInfo ref_s, CodeEntityInfo new_s) { |
| 1059 // Skip size. | 1059 // Skip size. |
| 1060 ref_s = strchr(ref_s, ',') + 1; | 1060 ref_s = strchr(ref_s, ',') + 1; |
| 1061 new_s = strchr(new_s, ',') + 1; | 1061 new_s = strchr(new_s, ',') + 1; |
| 1062 int ref_len = StrChrLen(ref_s, '\n'); | 1062 CHECK_EQ('"', ref_s[0]); |
| 1063 int new_len = StrChrLen(new_s, '\n'); | 1063 CHECK_EQ('"', new_s[0]); |
| 1064 // If reference is anonymous (""), it's OK to have anything in new. | 1064 int ref_len = StrChrLen(ref_s + 1, '\"'); |
| 1065 if (ref_len == 2) return true; | 1065 int new_len = StrChrLen(new_s + 1, '\"'); |
| 1066 // A special case for ErrorPrototype. Haven't yet figured out why they | 1066 // A special case for ErrorPrototype. Haven't yet figured out why they |
| 1067 // are different. | 1067 // are different. |
| 1068 const char* error_prototype = "\"ErrorPrototype"; | 1068 const char* error_prototype = "\"ErrorPrototype"; |
| 1069 if (IsStringEqualTo(error_prototype, ref_s) | 1069 if (IsStringEqualTo(error_prototype, ref_s) |
| 1070 && IsStringEqualTo(error_prototype, new_s)) { | 1070 && IsStringEqualTo(error_prototype, new_s)) { |
| 1071 return true; | 1071 return true; |
| 1072 } | 1072 } |
| 1073 // Built-in objects have problems too. | 1073 // Built-in objects have problems too. |
| 1074 const char* built_ins[] = { | 1074 const char* built_ins[] = { |
| 1075 "\"Boolean\"", "\"Function\"", "\"Number\"", | 1075 "\"Boolean\"", "\"Function\"", "\"Number\"", |
| 1076 "\"Object\"", "\"Script\"", "\"String\"" | 1076 "\"Object\"", "\"Script\"", "\"String\"" |
| 1077 }; | 1077 }; |
| 1078 for (size_t i = 0; i < sizeof(built_ins) / sizeof(*built_ins); ++i) { | 1078 for (size_t i = 0; i < sizeof(built_ins) / sizeof(*built_ins); ++i) { |
| 1079 if (IsStringEqualTo(built_ins[i], new_s)) { | 1079 if (IsStringEqualTo(built_ins[i], new_s)) { |
| 1080 return true; | 1080 return true; |
| 1081 } | 1081 } |
| 1082 } | 1082 } |
| 1083 // Code objects can change their optimizability: code object may start | |
| 1084 // as optimizable, but later be discovered to be actually not optimizable. | |
| 1085 // Alas, we don't record this info as of now, so we allow cases when | |
| 1086 // ref is thought to be optimizable while traverse finds it to be | |
| 1087 // not optimizable. | |
| 1088 if (ref_s[1] == '~') { // Code object used to be optimizable | |
| 1089 if (new_s[1] == ' ') { // ...but later was set unoptimizable. | |
| 1090 CHECK_EQ('"', ref_s[0]); | |
| 1091 CHECK_EQ('"', new_s[0]); | |
| 1092 ref_s += 2; // Cut the leading quote and the marker | |
| 1093 ref_len -= 2; | |
| 1094 new_s += 1; // Cut the leading quote only. | |
| 1095 new_len -= 1; | |
| 1096 } | |
| 1097 } | |
| 1098 return ref_len == new_len && strncmp(ref_s, new_s, ref_len) == 0; | 1083 return ref_len == new_len && strncmp(ref_s, new_s, ref_len) == 0; |
| 1099 } | 1084 } |
| 1100 | 1085 |
| 1101 | 1086 |
| 1102 static bool AreEntitiesEqual(CodeEntityInfo ref_e, CodeEntityInfo new_e) { | 1087 static bool AreEntitiesEqual(CodeEntityInfo ref_e, CodeEntityInfo new_e) { |
| 1103 if (ref_e == NULL && new_e != NULL) return true; | 1088 if (ref_e == NULL && new_e != NULL) return true; |
| 1104 if (ref_e != NULL && new_e != NULL) { | 1089 if (ref_e != NULL && new_e != NULL) { |
| 1105 return AreFuncSizesEqual(ref_e, new_e) && AreFuncNamesEqual(ref_e, new_e); | 1090 return AreFuncSizesEqual(ref_e, new_e) && AreFuncNamesEqual(ref_e, new_e); |
| 1106 } | 1091 } |
| 1107 if (ref_e != NULL && new_e == NULL) { | 1092 if (ref_e != NULL && new_e == NULL) { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1203 // Make sure that all log data is written prior crash due to CHECK failure. | 1188 // Make sure that all log data is written prior crash due to CHECK failure. |
| 1204 fflush(stdout); | 1189 fflush(stdout); |
| 1205 CHECK(results_equal); | 1190 CHECK(results_equal); |
| 1206 | 1191 |
| 1207 env->Exit(); | 1192 env->Exit(); |
| 1208 LOGGER->TearDown(); | 1193 LOGGER->TearDown(); |
| 1209 i::FLAG_always_compact = saved_always_compact; | 1194 i::FLAG_always_compact = saved_always_compact; |
| 1210 } | 1195 } |
| 1211 | 1196 |
| 1212 #endif // ENABLE_LOGGING_AND_PROFILING | 1197 #endif // ENABLE_LOGGING_AND_PROFILING |
| OLD | NEW |