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 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1030 | 1030 |
1031 template<typename T> | 1031 template<typename T> |
1032 void FastReturnValueCallback(const v8::FunctionCallbackInfo<v8::Value>& info); | 1032 void FastReturnValueCallback(const v8::FunctionCallbackInfo<v8::Value>& info); |
1033 | 1033 |
1034 // constant return values | 1034 // constant return values |
1035 static int32_t fast_return_value_int32 = 471; | 1035 static int32_t fast_return_value_int32 = 471; |
1036 static uint32_t fast_return_value_uint32 = 571; | 1036 static uint32_t fast_return_value_uint32 = 571; |
1037 static const double kFastReturnValueDouble = 2.7; | 1037 static const double kFastReturnValueDouble = 2.7; |
1038 // variable return values | 1038 // variable return values |
1039 static bool fast_return_value_bool = false; | 1039 static bool fast_return_value_bool = false; |
1040 static bool fast_return_value_void_is_null = false; | 1040 enum ReturnValueOddball { |
| 1041 kNullReturnValue, |
| 1042 kUndefinedReturnValue, |
| 1043 kEmptyStringReturnValue |
| 1044 }; |
| 1045 static ReturnValueOddball fast_return_value_void; |
1041 static bool fast_return_value_object_is_empty = false; | 1046 static bool fast_return_value_object_is_empty = false; |
1042 | 1047 |
1043 template<> | 1048 template<> |
1044 void FastReturnValueCallback<int32_t>( | 1049 void FastReturnValueCallback<int32_t>( |
1045 const v8::FunctionCallbackInfo<v8::Value>& info) { | 1050 const v8::FunctionCallbackInfo<v8::Value>& info) { |
1046 CheckReturnValue(info); | 1051 CheckReturnValue(info); |
1047 info.GetReturnValue().Set(fast_return_value_int32); | 1052 info.GetReturnValue().Set(fast_return_value_int32); |
1048 } | 1053 } |
1049 | 1054 |
1050 template<> | 1055 template<> |
(...skipping 14 matching lines...) Expand all Loading... |
1065 void FastReturnValueCallback<bool>( | 1070 void FastReturnValueCallback<bool>( |
1066 const v8::FunctionCallbackInfo<v8::Value>& info) { | 1071 const v8::FunctionCallbackInfo<v8::Value>& info) { |
1067 CheckReturnValue(info); | 1072 CheckReturnValue(info); |
1068 info.GetReturnValue().Set(fast_return_value_bool); | 1073 info.GetReturnValue().Set(fast_return_value_bool); |
1069 } | 1074 } |
1070 | 1075 |
1071 template<> | 1076 template<> |
1072 void FastReturnValueCallback<void>( | 1077 void FastReturnValueCallback<void>( |
1073 const v8::FunctionCallbackInfo<v8::Value>& info) { | 1078 const v8::FunctionCallbackInfo<v8::Value>& info) { |
1074 CheckReturnValue(info); | 1079 CheckReturnValue(info); |
1075 if (fast_return_value_void_is_null) { | 1080 switch (fast_return_value_void) { |
1076 info.GetReturnValue().SetNull(); | 1081 case kNullReturnValue: |
1077 } else { | 1082 info.GetReturnValue().SetNull(); |
1078 info.GetReturnValue().SetUndefined(); | 1083 break; |
| 1084 case kUndefinedReturnValue: |
| 1085 info.GetReturnValue().SetUndefined(); |
| 1086 break; |
| 1087 case kEmptyStringReturnValue: |
| 1088 info.GetReturnValue().SetEmptyString(); |
| 1089 break; |
1079 } | 1090 } |
1080 } | 1091 } |
1081 | 1092 |
1082 template<> | 1093 template<> |
1083 void FastReturnValueCallback<Object>( | 1094 void FastReturnValueCallback<Object>( |
1084 const v8::FunctionCallbackInfo<v8::Value>& info) { | 1095 const v8::FunctionCallbackInfo<v8::Value>& info) { |
1085 v8::Handle<v8::Object> object; | 1096 v8::Handle<v8::Object> object; |
1086 if (!fast_return_value_object_is_empty) object = Object::New(); | 1097 if (!fast_return_value_object_is_empty) object = Object::New(); |
1087 info.GetReturnValue().Set(object); | 1098 info.GetReturnValue().Set(object); |
1088 } | 1099 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1128 CHECK(value->IsNumber()); | 1139 CHECK(value->IsNumber()); |
1129 CHECK_EQ(kFastReturnValueDouble, value->ToNumber()->Value()); | 1140 CHECK_EQ(kFastReturnValueDouble, value->ToNumber()->Value()); |
1130 // check bool values | 1141 // check bool values |
1131 for (int i = 0; i < 2; i++) { | 1142 for (int i = 0; i < 2; i++) { |
1132 fast_return_value_bool = i == 0; | 1143 fast_return_value_bool = i == 0; |
1133 value = TestFastReturnValues<bool>(); | 1144 value = TestFastReturnValues<bool>(); |
1134 CHECK(value->IsBoolean()); | 1145 CHECK(value->IsBoolean()); |
1135 CHECK_EQ(fast_return_value_bool, value->ToBoolean()->Value()); | 1146 CHECK_EQ(fast_return_value_bool, value->ToBoolean()->Value()); |
1136 } | 1147 } |
1137 // check oddballs | 1148 // check oddballs |
1138 for (int i = 0; i < 2; i++) { | 1149 ReturnValueOddball oddballs[] = { |
1139 fast_return_value_void_is_null = i == 0; | 1150 kNullReturnValue, |
| 1151 kUndefinedReturnValue, |
| 1152 kEmptyStringReturnValue |
| 1153 }; |
| 1154 for (size_t i = 0; i < ARRAY_SIZE(oddballs); i++) { |
| 1155 fast_return_value_void = oddballs[i]; |
1140 value = TestFastReturnValues<void>(); | 1156 value = TestFastReturnValues<void>(); |
1141 if (fast_return_value_void_is_null) { | 1157 switch (fast_return_value_void) { |
1142 CHECK(value->IsNull()); | 1158 case kNullReturnValue: |
1143 } else { | 1159 CHECK(value->IsNull()); |
1144 CHECK(value->IsUndefined()); | 1160 break; |
| 1161 case kUndefinedReturnValue: |
| 1162 CHECK(value->IsUndefined()); |
| 1163 break; |
| 1164 case kEmptyStringReturnValue: |
| 1165 CHECK(value->IsString()); |
| 1166 CHECK_EQ(0, v8::String::Cast(*value)->Length()); |
| 1167 break; |
1145 } | 1168 } |
1146 } | 1169 } |
1147 // check handles | 1170 // check handles |
1148 fast_return_value_object_is_empty = false; | 1171 fast_return_value_object_is_empty = false; |
1149 value = TestFastReturnValues<Object>(); | 1172 value = TestFastReturnValues<Object>(); |
1150 CHECK(value->IsObject()); | 1173 CHECK(value->IsObject()); |
1151 fast_return_value_object_is_empty = true; | 1174 fast_return_value_object_is_empty = true; |
1152 value = TestFastReturnValues<Object>(); | 1175 value = TestFastReturnValues<Object>(); |
1153 CHECK(value->IsUndefined()); | 1176 CHECK(value->IsUndefined()); |
1154 } | 1177 } |
(...skipping 18174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19329 i::Semaphore* sem_; | 19352 i::Semaphore* sem_; |
19330 volatile int sem_value_; | 19353 volatile int sem_value_; |
19331 }; | 19354 }; |
19332 | 19355 |
19333 | 19356 |
19334 THREADED_TEST(SemaphoreInterruption) { | 19357 THREADED_TEST(SemaphoreInterruption) { |
19335 ThreadInterruptTest().RunTest(); | 19358 ThreadInterruptTest().RunTest(); |
19336 } | 19359 } |
19337 | 19360 |
19338 #endif // WIN32 | 19361 #endif // WIN32 |
OLD | NEW |